From e203df245de628ad06646c635a9c6259d7ed4c29 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Mon, 9 Mar 2020 15:59:01 -0700 Subject: [PATCH] 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 --- drivers/pci/controller/pci-msm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/pci-msm.c b/drivers/pci/controller/pci-msm.c index b27d28f65595..f7b5d8fa4f76 100644 --- a/drivers/pci/controller/pci-msm.c +++ b/drivers/pci/controller/pci-msm.c @@ -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)) {