Message ID | 20220818135140.5996-8-kabel@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | PCI: aardvark controller changes BATCH 6 | expand |
On Thu, Aug 18, 2022 at 03:51:36PM +0200, Marek Behún wrote: > From: Miquel Raynal <miquel.raynal@bootlin.com> > > Add suspend and resume callbacks. We need to use the NOIRQ variants to > ensure the controller's IRQ handlers are not run during suspend() / > resume(), which could cause races. Be more explicit please, which races, which IRQ handlers. This is useful information for future testers/reviewers in case something has to be changed, thanks. Lorenzo > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> > Signed-off-by: Pali Rohár <pali@kernel.org> > Signed-off-by: Marek Behún <kabel@kernel.org> > --- > Changes since batch 5: > - clarified commit message > - changed to new macro NOIRQ_SYSTEM_SLEEP_PM_OPS, as was done for many > PCI controller drivers with commit 19b7858c3357 ("PCI: Convert to new > *_PM_OPS macros") > --- > drivers/pci/controller/pci-aardvark.c | 34 +++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > > diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c > index 3beafc893969..e30a33a4ecc6 100644 > --- a/drivers/pci/controller/pci-aardvark.c > +++ b/drivers/pci/controller/pci-aardvark.c > @@ -1890,6 +1890,39 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie) > return ret; > } > > +static int advk_pcie_suspend(struct device *dev) > +{ > + struct advk_pcie *pcie = dev_get_drvdata(dev); > + > + advk_pcie_disable_phy(pcie); > + > + clk_disable_unprepare(pcie->clk); > + > + return 0; > +} > + > +static int advk_pcie_resume(struct device *dev) > +{ > + struct advk_pcie *pcie = dev_get_drvdata(dev); > + int ret; > + > + ret = clk_prepare_enable(pcie->clk); > + if (ret) > + return ret; > + > + ret = advk_pcie_enable_phy(pcie); > + if (ret) > + return ret; > + > + advk_pcie_setup_hw(pcie); > + > + return 0; > +} > + > +static const struct dev_pm_ops advk_pcie_dev_pm_ops = { > + NOIRQ_SYSTEM_SLEEP_PM_OPS(advk_pcie_suspend, advk_pcie_resume) > +}; > + > static int advk_pcie_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -2167,6 +2200,7 @@ static struct platform_driver advk_pcie_driver = { > .driver = { > .name = "advk-pcie", > .of_match_table = advk_pcie_of_match_table, > + .pm = &advk_pcie_dev_pm_ops, > }, > .probe = advk_pcie_probe, > .remove = advk_pcie_remove, > -- > 2.35.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Fri, Sep 09, 2022 at 12:33:01PM +0200, Lorenzo Pieralisi wrote: > On Thu, Aug 18, 2022 at 03:51:36PM +0200, Marek Behún wrote: > > From: Miquel Raynal <miquel.raynal@bootlin.com> > > > > Add suspend and resume callbacks. We need to use the NOIRQ variants to > > ensure the controller's IRQ handlers are not run during suspend() / > > resume(), which could cause races. > > Be more explicit please, which races, which IRQ handlers. This is useful > information for future testers/reviewers in case something has to be > changed, thanks. Can we update the log please ? Thanks, Lorenzo > Lorenzo > > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> > > Signed-off-by: Pali Rohár <pali@kernel.org> > > Signed-off-by: Marek Behún <kabel@kernel.org> > > --- > > Changes since batch 5: > > - clarified commit message > > - changed to new macro NOIRQ_SYSTEM_SLEEP_PM_OPS, as was done for many > > PCI controller drivers with commit 19b7858c3357 ("PCI: Convert to new > > *_PM_OPS macros") > > --- > > drivers/pci/controller/pci-aardvark.c | 34 +++++++++++++++++++++++++++ > > 1 file changed, 34 insertions(+) > > > > diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c > > index 3beafc893969..e30a33a4ecc6 100644 > > --- a/drivers/pci/controller/pci-aardvark.c > > +++ b/drivers/pci/controller/pci-aardvark.c > > @@ -1890,6 +1890,39 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie) > > return ret; > > } > > > > +static int advk_pcie_suspend(struct device *dev) > > +{ > > + struct advk_pcie *pcie = dev_get_drvdata(dev); > > + > > + advk_pcie_disable_phy(pcie); > > + > > + clk_disable_unprepare(pcie->clk); > > + > > + return 0; > > +} > > + > > +static int advk_pcie_resume(struct device *dev) > > +{ > > + struct advk_pcie *pcie = dev_get_drvdata(dev); > > + int ret; > > + > > + ret = clk_prepare_enable(pcie->clk); > > + if (ret) > > + return ret; > > + > > + ret = advk_pcie_enable_phy(pcie); > > + if (ret) > > + return ret; > > + > > + advk_pcie_setup_hw(pcie); > > + > > + return 0; > > +} > > + > > +static const struct dev_pm_ops advk_pcie_dev_pm_ops = { > > + NOIRQ_SYSTEM_SLEEP_PM_OPS(advk_pcie_suspend, advk_pcie_resume) > > +}; > > + > > static int advk_pcie_probe(struct platform_device *pdev) > > { > > struct device *dev = &pdev->dev; > > @@ -2167,6 +2200,7 @@ static struct platform_driver advk_pcie_driver = { > > .driver = { > > .name = "advk-pcie", > > .of_match_table = advk_pcie_of_match_table, > > + .pm = &advk_pcie_dev_pm_ops, > > }, > > .probe = advk_pcie_probe, > > .remove = advk_pcie_remove, > > -- > > 2.35.1 > > > > > > _______________________________________________ > > linux-arm-kernel mailing list > > linux-arm-kernel@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 3beafc893969..e30a33a4ecc6 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1890,6 +1890,39 @@ static int advk_pcie_setup_phy(struct advk_pcie *pcie) return ret; } +static int advk_pcie_suspend(struct device *dev) +{ + struct advk_pcie *pcie = dev_get_drvdata(dev); + + advk_pcie_disable_phy(pcie); + + clk_disable_unprepare(pcie->clk); + + return 0; +} + +static int advk_pcie_resume(struct device *dev) +{ + struct advk_pcie *pcie = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(pcie->clk); + if (ret) + return ret; + + ret = advk_pcie_enable_phy(pcie); + if (ret) + return ret; + + advk_pcie_setup_hw(pcie); + + return 0; +} + +static const struct dev_pm_ops advk_pcie_dev_pm_ops = { + NOIRQ_SYSTEM_SLEEP_PM_OPS(advk_pcie_suspend, advk_pcie_resume) +}; + static int advk_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -2167,6 +2200,7 @@ static struct platform_driver advk_pcie_driver = { .driver = { .name = "advk-pcie", .of_match_table = advk_pcie_of_match_table, + .pm = &advk_pcie_dev_pm_ops, }, .probe = advk_pcie_probe, .remove = advk_pcie_remove,