Re: [PATCH] misc: rtsx: Fix an error access Page fault

From: Kai-Heng Feng
Date: Fri Oct 06 2023 - 01:00:40 EST


Ricky,

On Tue, Sep 26, 2023 at 11:04 PM Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote:
>
> On Thu, 14 Sept 2023 at 16:47, Ulf Hansson <ulf.hansson@xxxxxxxxxx> wrote:
> >
> > On Wed, 6 Sept 2023 at 10:03, Ricky WU <ricky_wu@xxxxxxxxxxx> wrote:
> > >
> > > an error occurs on insert SD7.0 card.
> > > The pci slot of rtsx_pci will Link Down when the SD7.0 card inserted,
> > > but the rtsx_pci not exit from runtime_idle at that time,
> > > then do the power_saving function to access the wrong resource
> > >
> > > Fixes: 597568e8df04 ("misc: rtsx: Rework runtime power management flow")
> > > Cc: Kai-Heng Feng <kai.heng.feng@xxxxxxxxxxxxx>
> > > Signed-off-by: Ricky Wu <ricky_wu@xxxxxxxxxxx>
> >
> > Applied for fixes, thanks!
>
> This was not ready to be applied, my bad! Fortunately, I haven't
> submitted a pull-request with this yet, so I am simply dropping the
> patch for now, to make sure we find the proper solution.

Can you please see if the following change helps:

diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index ad12515a4a121..89480e31c2266 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -18,9 +18,18 @@
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/pci.h>
+#include <linux/pm_runtime.h>
#include "../pci.h"
#include "pciehp.h"

+int pciehp_pm_runtime_barrier(struct pci_dev *pdev, void *unused)
+{
+ pm_runtime_barrier(&pdev->dev);
+ pci_dev_set_disconnected(pdev, NULL);
+
+ return 0;
+}
+
/**
* pciehp_configure_device() - enumerate PCI devices below a hotplug bridge
* @ctrl: PCIe hotplug controller
@@ -98,7 +107,7 @@ void pciehp_unconfigure_device(struct controller
*ctrl, bool presence)
__func__, pci_domain_nr(parent), parent->number);

if (!presence)
- pci_walk_bus(parent, pci_dev_set_disconnected, NULL);
+ pci_walk_bus(parent, pciehp_pm_runtime_barrier, NULL);

pci_lock_rescan_remove();


>
> [...]
>
> Kind regards
> Uffe