Message ID | 20220906222351.64760-6-helgaas@kernel.org (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | PCI/PM: Always disable PTM for all devices during suspend | expand |
On Tue, Sep 06, 2022 at 05:23:46PM -0500, Bjorn Helgaas wrote: > @@ -42,6 +42,13 @@ void pci_disable_ptm(struct pci_dev *dev) > pci_write_config_word(dev, ptm + PCI_PTM_CTRL, ctrl); > } Since you export these, I suggest adding kernel-doc to explain how these are supposed to be used in drivers (pre-conditions etc.). > +void pci_disable_ptm(struct pci_dev *dev) > +{ > + __pci_disable_ptm(dev); > + dev->ptm_enabled = 0; > +} > +EXPORT_SYMBOL(pci_disable_ptm); EXPORT_SYMBOL_GPL()?
On Wed, Sep 07, 2022 at 08:28:43AM +0300, Mika Westerberg wrote: > On Tue, Sep 06, 2022 at 05:23:46PM -0500, Bjorn Helgaas wrote: > > @@ -42,6 +42,13 @@ void pci_disable_ptm(struct pci_dev *dev) > > pci_write_config_word(dev, ptm + PCI_PTM_CTRL, ctrl); > > } > > Since you export these, I suggest adding kernel-doc to explain how these > are supposed to be used in drivers (pre-conditions etc.). Currently there really aren't any preconditions, so kernel-doc would repeat the function name and parameters without adding any real information, but I think it would be good to add a few explanatory comments. It always seems obvious when writing it, but it's never so obvious without all the context ;) > > +void pci_disable_ptm(struct pci_dev *dev) > > +{ > > + __pci_disable_ptm(dev); > > + dev->ptm_enabled = 0; > > +} > > +EXPORT_SYMBOL(pci_disable_ptm); > > EXPORT_SYMBOL_GPL()? I don't feel strongly either way, but am inclined to do the same as pci_enable_ptm() and pcie_ptm_enabled(), which are both EXPORT_SYMBOL. We could change all of them at once if it's worthwhile. Currently there's only one caller (igc) in the tree. Bjorn
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 785f31086313..91a465460d0f 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -507,11 +507,9 @@ static inline int pci_iov_bus_range(struct pci_bus *bus) #ifdef CONFIG_PCIE_PTM void pci_save_ptm_state(struct pci_dev *dev); void pci_restore_ptm_state(struct pci_dev *dev); -void pci_disable_ptm(struct pci_dev *dev); #else static inline void pci_save_ptm_state(struct pci_dev *dev) { } static inline void pci_restore_ptm_state(struct pci_dev *dev) { } -static inline void pci_disable_ptm(struct pci_dev *dev) { } #endif unsigned long pci_cardbus_resource_alignment(struct resource *); diff --git a/drivers/pci/pcie/ptm.c b/drivers/pci/pcie/ptm.c index ac51cd84793f..762299984469 100644 --- a/drivers/pci/pcie/ptm.c +++ b/drivers/pci/pcie/ptm.c @@ -29,7 +29,7 @@ static void pci_ptm_info(struct pci_dev *dev) dev->ptm_root ? " (root)" : "", clock_desc); } -void pci_disable_ptm(struct pci_dev *dev) +static void __pci_disable_ptm(struct pci_dev *dev) { int ptm = dev->ptm_cap; u16 ctrl; @@ -42,6 +42,13 @@ void pci_disable_ptm(struct pci_dev *dev) pci_write_config_word(dev, ptm + PCI_PTM_CTRL, ctrl); } +void pci_disable_ptm(struct pci_dev *dev) +{ + __pci_disable_ptm(dev); + dev->ptm_enabled = 0; +} +EXPORT_SYMBOL(pci_disable_ptm); + void pci_save_ptm_state(struct pci_dev *dev) { int ptm = dev->ptm_cap; diff --git a/include/linux/pci.h b/include/linux/pci.h index 54be939023a3..cb5f796e3319 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1678,10 +1678,12 @@ bool pci_ats_disabled(void); #ifdef CONFIG_PCIE_PTM int pci_enable_ptm(struct pci_dev *dev, u8 *granularity); +void pci_disable_ptm(struct pci_dev *dev); bool pcie_ptm_enabled(struct pci_dev *dev); #else static inline int pci_enable_ptm(struct pci_dev *dev, u8 *granularity) { return -EINVAL; } +static inline void pci_disable_ptm(struct pci_dev *dev) { } static inline bool pcie_ptm_enabled(struct pci_dev *dev) { return false; } #endif