Skip to contentSkip to conversation

PCI/ATS: Clean up unnecessary stubs and exports

PATCH In review Bjorn Helgaas 3 participants 7 messages Oct 9, 2019 – Oct 15, 2019 PCI

lore
Share & tools
lore
#0 lore raw

cover PCI/ATS: Clean up unnecessary stubs and exports

From: Bjorn Helgaas <[email protected]>

Most of the ATS/PRI/PASID interfaces are only used by IOMMU drivers that can only be built statically, not as modules. A couple are only used by the PCI core and don't need to be visible outside at all.

These are intended to be cleanup only, but let me know if they would break something.

Bjorn Helgaas (3):
PCI/ATS: Remove unused PRI and PASID stubs
PCI/ATS: Remove unnecessary EXPORT_SYMBOL_GPL() PCI/ATS: Make pci_restore_pri_state(), pci_restore_pasid_state()
private

 drivers/pci/ats.c       | 14 --------------
 drivers/pci/pci.h       |  4 ++++
 include/linux/pci-ats.h | 15 ---------------
 3 files changed, 4 insertions(+), 29 deletions(-)
Signature · 6 lines
2.23.0.581.g78d2f28ef7-goog

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
#1 lore raw

PATCH 1/3 PCI/ATS: Remove unused PRI and PASID stubs

From: Bjorn Helgaas <[email protected]>

The following functions are only used by amd_iommu.c and intel-iommu.c (when CONFIG_INTEL_IOMMU_SVM is enabled). CONFIG_PCI_PRI and CONFIG_PCI_PASID are always defined in those cases, so there's no need for the stubs.

pci_enable_pri()
pci_disable_pri()
pci_reset_pri()
pci_prg_resp_pasid_required()
pci_enable_pasid()
pci_disable_pasid()

Remove the unused stubs.

---
 include/linux/pci-ats.h | 10 ----------
 1 file changed, 10 deletions(-)
include/linux/pci-ats.h +0 -10
index 67de3a9499bb..963c11f7c56b 100644
@@ -27,14 +27,7 @@ void pci_restore_pri_state(struct pci_dev *pdev);
 int pci_reset_pri(struct pci_dev *pdev);
 int pci_prg_resp_pasid_required(struct pci_dev *pdev);
 #else /* CONFIG_PCI_PRI */
-static inline int pci_enable_pri(struct pci_dev *pdev, u32 reqs)
-{ return -ENODEV; }
-static inline void pci_disable_pri(struct pci_dev *pdev) { }
 static inline void pci_restore_pri_state(struct pci_dev *pdev) { }
-static inline int pci_reset_pri(struct pci_dev *pdev)
-{ return -ENODEV; }
-static inline int pci_prg_resp_pasid_required(struct pci_dev *pdev)
-{ return 0; }
 #endif /* CONFIG_PCI_PRI */
 
 #ifdef CONFIG_PCI_PASID
@@ -44,9 +37,6 @@ void pci_restore_pasid_state(struct pci_dev *pdev);
 int pci_pasid_features(struct pci_dev *pdev);
 int pci_max_pasids(struct pci_dev *pdev);
 #else /* CONFIG_PCI_PASID */
-static inline int pci_enable_pasid(struct pci_dev *pdev, int features)
-{ return -EINVAL; }
-static inline void pci_disable_pasid(struct pci_dev *pdev) { }
 static inline void pci_restore_pasid_state(struct pci_dev *pdev) { }
 static inline int pci_pasid_features(struct pci_dev *pdev)
 { return -EINVAL; }
Signature · 6 lines
2.23.0.581.g78d2f28ef7-goog

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
#3 lore raw

PATCH 2/3 PCI/ATS: Remove unnecessary EXPORT_SYMBOL_GPL()

In reply to Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

The following functions are only used by the PCI core or by IOMMU drivers that cannot be modular, so there's no need to export them at all:

pci_enable_ats()
pci_disable_ats()
pci_restore_ats_state()
pci_ats_queue_depth()
pci_ats_page_aligned()

pci_enable_pri()
pci_restore_pri_state()
pci_reset_pri()
pci_prg_resp_pasid_required()

pci_enable_pasid()
pci_disable_pasid()
pci_restore_pasid_state()
pci_pasid_features()
pci_max_pasids()

Remove the unnecessary EXPORT_SYMBOL_GPL()s.

---
 drivers/pci/ats.c | 14 --------------
 1 file changed, 14 deletions(-)
drivers/pci/ats.c +0 -14
index 76ae518d55f4..982b46f0a54d 100644
@@ -69,7 +69,6 @@ int pci_enable_ats(struct pci_dev *dev, int ps)
 	dev->ats_enabled = 1;
 	return 0;
 }
-EXPORT_SYMBOL_GPL(pci_enable_ats);
 
 /**
  * pci_disable_ats - disable the ATS capability
@@ -88,7 +87,6 @@ void pci_disable_ats(struct pci_dev *dev)
 
 	dev->ats_enabled = 0;
 }
-EXPORT_SYMBOL_GPL(pci_disable_ats);
 
 void pci_restore_ats_state(struct pci_dev *dev)
 {
@@ -102,7 +100,6 @@ void pci_restore_ats_state(struct pci_dev *dev)
 		ctrl |= PCI_ATS_CTRL_STU(dev->ats_stu - PCI_ATS_MIN_STU);
 	pci_write_config_word(dev, dev->ats_cap + PCI_ATS_CTRL, ctrl);
 }
-EXPORT_SYMBOL_GPL(pci_restore_ats_state);
 
 /**
  * pci_ats_queue_depth - query the ATS Invalidate Queue Depth
@@ -129,7 +126,6 @@ int pci_ats_queue_depth(struct pci_dev *dev)
 	pci_read_config_word(dev, dev->ats_cap + PCI_ATS_CAP, &cap);
 	return PCI_ATS_CAP_QDEP(cap) ? PCI_ATS_CAP_QDEP(cap) : PCI_ATS_MAX_QDEP;
 }
-EXPORT_SYMBOL_GPL(pci_ats_queue_depth);
 
 /**
  * pci_ats_page_aligned - Return Page Aligned Request bit status.
@@ -156,7 +152,6 @@ int pci_ats_page_aligned(struct pci_dev *pdev)
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(pci_ats_page_aligned);
 
 #ifdef CONFIG_PCI_PRI
 void pci_pri_init(struct pci_dev *pdev)
@@ -218,7 +213,6 @@ int pci_enable_pri(struct pci_dev *pdev, u32 reqs)
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(pci_enable_pri);
 
 /**
  * pci_disable_pri - Disable PRI capability
@@ -271,7 +265,6 @@ void pci_restore_pri_state(struct pci_dev *pdev)
 	pci_write_config_dword(pdev, pri + PCI_PRI_ALLOC_REQ, reqs);
 	pci_write_config_word(pdev, pri + PCI_PRI_CTRL, control);
 }
-EXPORT_SYMBOL_GPL(pci_restore_pri_state);
 
 /**
  * pci_reset_pri - Resets device's PRI state
@@ -299,7 +292,6 @@ int pci_reset_pri(struct pci_dev *pdev)
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(pci_reset_pri);
 
 /**
  * pci_prg_resp_pasid_required - Return PRG Response PASID Required bit
@@ -315,7 +307,6 @@ int pci_prg_resp_pasid_required(struct pci_dev *pdev)
 
 	return pdev->pasid_required;
 }
-EXPORT_SYMBOL_GPL(pci_prg_resp_pasid_required);
 #endif /* CONFIG_PCI_PRI */
 
 #ifdef CONFIG_PCI_PASID
@@ -373,7 +364,6 @@ int pci_enable_pasid(struct pci_dev *pdev, int features)
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(pci_enable_pasid);
 
 /**
  * pci_disable_pasid - Disable the PASID capability
@@ -398,7 +388,6 @@ void pci_disable_pasid(struct pci_dev *pdev)
 
 	pdev->pasid_enabled = 0;
 }
-EXPORT_SYMBOL_GPL(pci_disable_pasid);
 
 /**
  * pci_restore_pasid_state - Restore PASID capabilities
@@ -421,7 +410,6 @@ void pci_restore_pasid_state(struct pci_dev *pdev)
 	control = PCI_PASID_CTRL_ENABLE | pdev->pasid_features;
 	pci_write_config_word(pdev, pasid + PCI_PASID_CTRL, control);
 }
-EXPORT_SYMBOL_GPL(pci_restore_pasid_state);
 
 /**
  * pci_pasid_features - Check which PASID features are supported
@@ -450,7 +438,6 @@ int pci_pasid_features(struct pci_dev *pdev)
 
 	return supported;
 }
-EXPORT_SYMBOL_GPL(pci_pasid_features);
 
 #define PASID_NUMBER_SHIFT	8
 #define PASID_NUMBER_MASK	(0x1f << PASID_NUMBER_SHIFT)
@@ -478,5 +465,4 @@ int pci_max_pasids(struct pci_dev *pdev)
 
 	return (1 << supported);
 }
-EXPORT_SYMBOL_GPL(pci_max_pasids);
 #endif /* CONFIG_PCI_PASID */
Signature · 6 lines
2.23.0.581.g78d2f28ef7-goog

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
#4 lore raw

PATCH 3/3 PCI/ATS: Make pci_restore_pri_state(), pci_restore_pasid_state() private

In reply to Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

These interfaces:

  void pci_restore_pri_state(struct pci_dev *pdev);
  void pci_restore_pasid_state(struct pci_dev *pdev);

are only used in drivers/pci and do not need to be seen by the rest of the kernel. Most them to drivers/pci/pci.h so they're private to the PCI subsystem.

---
 drivers/pci/pci.h       | 4 ++++
 include/linux/pci-ats.h | 5 -----
 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/pci/pci.h +4 -0
index ae84d28ba03a..e6b46d2b9846 100644
@@ -458,14 +458,18 @@ static inline void pci_restore_ats_state(struct pci_dev *dev) { }
 
 #ifdef CONFIG_PCI_PRI
 void pci_pri_init(struct pci_dev *dev);
+void pci_restore_pri_state(struct pci_dev *pdev);
 #else
 static inline void pci_pri_init(struct pci_dev *dev) { }
+static inline void pci_restore_pri_state(struct pci_dev *pdev) { }
 #endif
 
 #ifdef CONFIG_PCI_PASID
 void pci_pasid_init(struct pci_dev *dev);
+void pci_restore_pasid_state(struct pci_dev *pdev);
 #else
 static inline void pci_pasid_init(struct pci_dev *dev) { }
+static inline void pci_restore_pasid_state(struct pci_dev *pdev) { }
 #endif
 
 #ifdef CONFIG_PCI_IOV
include/linux/pci-ats.h +0 -5
index 963c11f7c56b..5d62e78946a3 100644
@@ -23,21 +23,16 @@ static inline int pci_ats_page_aligned(struct pci_dev *dev)
 #ifdef CONFIG_PCI_PRI
 int pci_enable_pri(struct pci_dev *pdev, u32 reqs);
 void pci_disable_pri(struct pci_dev *pdev);
-void pci_restore_pri_state(struct pci_dev *pdev);
 int pci_reset_pri(struct pci_dev *pdev);
 int pci_prg_resp_pasid_required(struct pci_dev *pdev);
-#else /* CONFIG_PCI_PRI */
-static inline void pci_restore_pri_state(struct pci_dev *pdev) { }
 #endif /* CONFIG_PCI_PRI */
 
 #ifdef CONFIG_PCI_PASID
 int pci_enable_pasid(struct pci_dev *pdev, int features);
 void pci_disable_pasid(struct pci_dev *pdev);
-void pci_restore_pasid_state(struct pci_dev *pdev);
 int pci_pasid_features(struct pci_dev *pdev);
 int pci_max_pasids(struct pci_dev *pdev);
 #else /* CONFIG_PCI_PASID */
-static inline void pci_restore_pasid_state(struct pci_dev *pdev) { }
 static inline int pci_pasid_features(struct pci_dev *pdev)
 { return -EINVAL; }
 static inline int pci_max_pasids(struct pci_dev *pdev)
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] PCI/ATS: Remove unused PRI and PASID stubs

In reply to Bjorn Helgaas
Quoted 14 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

The following functions are only used by amd_iommu.c and intel-iommu.c (when CONFIG_INTEL_IOMMU_SVM is enabled). CONFIG_PCI_PRI and CONFIG_PCI_PASID are always defined in those cases, so there's no need for the stubs.

   pci_enable_pri()
   pci_disable_pri()
   pci_reset_pri()
   pci_prg_resp_pasid_required()
   pci_enable_pasid()
   pci_disable_pasid()
Quoted 3 lines

Remove the unused stubs.

Looks good to me.

Quoted 33 lines
---
  include/linux/pci-ats.h | 10 ----------
  1 file changed, 10 deletions(-)
include/linux/pci-ats.h +0 -10
index 67de3a9499bb..963c11f7c56b 100644
@@ -27,14 +27,7 @@ void pci_restore_pri_state(struct pci_dev *pdev);
  int pci_reset_pri(struct pci_dev *pdev);
  int pci_prg_resp_pasid_required(struct pci_dev *pdev);
  #else /* CONFIG_PCI_PRI */
-static inline int pci_enable_pri(struct pci_dev *pdev, u32 reqs)
-{ return -ENODEV; }
-static inline void pci_disable_pri(struct pci_dev *pdev) { }
  static inline void pci_restore_pri_state(struct pci_dev *pdev) { }
-static inline int pci_reset_pri(struct pci_dev *pdev)
-{ return -ENODEV; }
-static inline int pci_prg_resp_pasid_required(struct pci_dev *pdev)
-{ return 0; }
  #endif /* CONFIG_PCI_PRI */
 
  #ifdef CONFIG_PCI_PASID
@@ -44,9 +37,6 @@ void pci_restore_pasid_state(struct pci_dev *pdev);
  int pci_pasid_features(struct pci_dev *pdev);
  int pci_max_pasids(struct pci_dev *pdev);
  #else /* CONFIG_PCI_PASID */
-static inline int pci_enable_pasid(struct pci_dev *pdev, int features)
-{ return -EINVAL; }
-static inline void pci_disable_pasid(struct pci_dev *pdev) { }
  static inline void pci_restore_pasid_state(struct pci_dev *pdev) { }
  static inline int pci_pasid_features(struct pci_dev *pdev)
  { return -EINVAL; }
Signature · 7 lines
Sathyanarayanan Kuppuswamy
Linux kernel developer

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Reviewed-by on the v1 series
#5 lore raw
In reply to Bjorn Helgaas

Hi Bjorn,

Quoted 6 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Most of the ATS/PRI/PASID interfaces are only used by IOMMU drivers that can only be built statically, not as modules. A couple are only used by the PCI core and don't need to be visible outside at all.

Quoted 8 lines

These are intended to be cleanup only, but let me know if they would break something.

Bjorn Helgaas (3):
PCI/ATS: Remove unused PRI and PASID stubs
PCI/ATS: Remove unnecessary EXPORT_SYMBOL_GPL() PCI/ATS: Make pci_restore_pri_state(), pci_restore_pasid_state()
private

The series looks good to me, for the whole series:

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#6 lore raw
In reply to Bjorn Helgaas
Quoted 15 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Most of the ATS/PRI/PASID interfaces are only used by IOMMU drivers that can only be built statically, not as modules. A couple are only used by the PCI core and don't need to be visible outside at all.

These are intended to be cleanup only, but let me know if they would break something.

Bjorn Helgaas (3):
PCI/ATS: Remove unused PRI and PASID stubs
PCI/ATS: Remove unnecessary EXPORT_SYMBOL_GPL() PCI/ATS: Make pci_restore_pri_state(), pci_restore_pasid_state()
private

Quoted 4 lines
 drivers/pci/ats.c       | 14 --------------
 drivers/pci/pci.h       |  4 ++++
 include/linux/pci-ats.h | 15 ---------------
 3 files changed, 4 insertions(+), 29 deletions(-)

I applied these to pci/virtualization for v5.5, with Kuppuswamy's Reviewed-by on the first and Joerg's on all three. Thank you both for taking a look!

Bjorn