msm: pcie: use a local copy for PCIe event callback

Instead of directly modifying client's callback event, make a
local copy and give that to the client. This will prevent race
condition where the latest event is updated before the client
has had the chance to see the previous event.

Change-Id: Icb77471e71d48095eaa2610da26c22a161ff02e2
Signed-off-by: Tony Truong <truong@codeaurora.org>
This commit is contained in:
Tony Truong 2020-03-09 15:59:01 -07:00 • committed by Gerrit - the friendly Code Review server
commit e203df245d

View file

@ -4690,12 +4690,15 @@ static void msm_pcie_notify_client(struct msm_pcie_dev_t *dev,
if (dev->event_reg && dev->event_reg->callback &&
(dev->event_reg->events & event)) {
struct msm_pcie_notify *notify = &dev->event_reg->notify;
struct msm_pcie_notify client_notify;
notify->event = event;
notify->user = dev->event_reg->user;
client_notify.event = event;
client_notify.user = notify->user;
client_notify.data = notify->data;
client_notify.options = notify->options;
PCIE_DUMP(dev, "PCIe: callback RC%d for event %d\n",
dev->rc_idx, event);
dev->event_reg->callback(notify);
dev->event_reg->callback(&client_notify);
if ((dev->event_reg->options & MSM_PCIE_CONFIG_NO_RECOVERY) &&
(event == MSM_PCIE_EVENT_LINKDOWN)) {