RE: [PATCH] misc: rtsx: Fix an error access Page fault
From: Ricky WU
Date: Tue Oct 10 2023 - 23:23:12 EST
Hi Kai-Heng,
I finished testing this patch it's working fine, re-plug card many time don't see the issue reproduce
I think this patch can fix the problem
thank you
Tested-by: Ricky Wu <ricky_wu@xxxxxxxxxxx>
> 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