diff mbox series

[v4,1/5] vfio/pci: Move all the SPAPR PCI specific logic to vfio_pci_core.ko

Message ID 1-v4-7993c351e9dc+33a818-vfio_modules_jgg@nvidia.com (mailing list archive)
State New, archived
Headers show
Series Simplify the module and kconfig structure in vfio | expand

Commit Message

Jason Gunthorpe Nov. 30, 2022, 12:10 a.m. UTC
The vfio_spapr_pci_eeh_open/release() functions are one line wrappers
around an arch function. Just call them directly and move them into
vfio_pci_priv.h. This eliminates some weird exported symbols that don't
need to exist.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/vfio/pci/vfio_pci_core.c | 11 +++++++++--
 drivers/vfio/pci/vfio_pci_priv.h |  1 -
 drivers/vfio/vfio_spapr_eeh.c    | 13 -------------
 include/linux/vfio.h             | 11 -----------
 4 files changed, 9 insertions(+), 27 deletions(-)

Comments

Cornelia Huck Dec. 1, 2022, 11:34 a.m. UTC | #1
On Tue, Nov 29 2022, Jason Gunthorpe <jgg@nvidia.com> wrote:

> The vfio_spapr_pci_eeh_open/release() functions are one line wrappers
> around an arch function. Just call them directly and move them into
> vfio_pci_priv.h. This eliminates some weird exported symbols that don't

Hm, that doesn't seem to match the current patch -- the only change to
vfio_pci_priv.h is removing an empty line :)

> need to exist.
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/vfio/pci/vfio_pci_core.c | 11 +++++++++--
>  drivers/vfio/pci/vfio_pci_priv.h |  1 -
>  drivers/vfio/vfio_spapr_eeh.c    | 13 -------------
>  include/linux/vfio.h             | 11 -----------
>  4 files changed, 9 insertions(+), 27 deletions(-)
Alex Williamson Dec. 1, 2022, 11:59 p.m. UTC | #2
On Thu, 01 Dec 2022 12:34:33 +0100
Cornelia Huck <cohuck@redhat.com> wrote:

> On Tue, Nov 29 2022, Jason Gunthorpe <jgg@nvidia.com> wrote:
> 
> > The vfio_spapr_pci_eeh_open/release() functions are one line wrappers
> > around an arch function. Just call them directly and move them into
> > vfio_pci_priv.h. This eliminates some weird exported symbols that don't  
> 
> Hm, that doesn't seem to match the current patch -- the only change to
> vfio_pci_priv.h is removing an empty line :)

s/ and move them into vfio_pci_priv.h//?


> > need to exist.
> >
> > Reviewed-by: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > ---
> >  drivers/vfio/pci/vfio_pci_core.c | 11 +++++++++--
> >  drivers/vfio/pci/vfio_pci_priv.h |  1 -
> >  drivers/vfio/vfio_spapr_eeh.c    | 13 -------------
> >  include/linux/vfio.h             | 11 -----------
> >  4 files changed, 9 insertions(+), 27 deletions(-)  
>
Jason Gunthorpe Dec. 2, 2022, 12:40 a.m. UTC | #3
On Thu, Dec 01, 2022 at 04:59:08PM -0700, Alex Williamson wrote:
> On Thu, 01 Dec 2022 12:34:33 +0100
> Cornelia Huck <cohuck@redhat.com> wrote:
> 
> > On Tue, Nov 29 2022, Jason Gunthorpe <jgg@nvidia.com> wrote:
> > 
> > > The vfio_spapr_pci_eeh_open/release() functions are one line wrappers
> > > around an arch function. Just call them directly and move them into
> > > vfio_pci_priv.h. This eliminates some weird exported symbols that don't  
> > 
> > Hm, that doesn't seem to match the current patch -- the only change to
> > vfio_pci_priv.h is removing an empty line :)
> 
> s/ and move them into vfio_pci_priv.h//?

Yes, and drop this:

> > >  drivers/vfio/pci/vfio_pci_priv.h |  1 -

It is a rebase error, I didn't notice it.

I made the two notes from Cornelia in my branch, I can send a v5
tomorrow.

Thanks,
Jason
diff mbox series

Patch

diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index badc9d828cac20..c8b8a7a03eae7e 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -27,6 +27,9 @@ 
 #include <linux/vgaarb.h>
 #include <linux/nospec.h>
 #include <linux/sched/mm.h>
+#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH)
+#include <asm/eeh.h>
+#endif
 
 #include "vfio_pci_priv.h"
 
@@ -686,7 +689,9 @@  void vfio_pci_core_close_device(struct vfio_device *core_vdev)
 		vdev->sriov_pf_core_dev->vf_token->users--;
 		mutex_unlock(&vdev->sriov_pf_core_dev->vf_token->lock);
 	}
-	vfio_spapr_pci_eeh_release(vdev->pdev);
+#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH)
+	eeh_dev_release(vdev->pdev);
+#endif
 	vfio_pci_core_disable(vdev);
 
 	mutex_lock(&vdev->igate);
@@ -705,7 +710,9 @@  EXPORT_SYMBOL_GPL(vfio_pci_core_close_device);
 void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev)
 {
 	vfio_pci_probe_mmaps(vdev);
-	vfio_spapr_pci_eeh_open(vdev->pdev);
+#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH)
+	eeh_dev_open(vdev->pdev);
+#endif
 
 	if (vdev->sriov_pf_core_dev) {
 		mutex_lock(&vdev->sriov_pf_core_dev->vf_token->lock);
diff --git a/drivers/vfio/pci/vfio_pci_priv.h b/drivers/vfio/pci/vfio_pci_priv.h
index 5e4fa69aee16c1..13c0858eb5df28 100644
--- a/drivers/vfio/pci/vfio_pci_priv.h
+++ b/drivers/vfio/pci/vfio_pci_priv.h
@@ -100,5 +100,4 @@  static inline bool vfio_pci_is_vga(struct pci_dev *pdev)
 {
 	return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
 }
-
 #endif
diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c
index 67f55ac1d459cc..c9d102aafbcd11 100644
--- a/drivers/vfio/vfio_spapr_eeh.c
+++ b/drivers/vfio/vfio_spapr_eeh.c
@@ -15,19 +15,6 @@ 
 #define DRIVER_AUTHOR	"Gavin Shan, IBM Corporation"
 #define DRIVER_DESC	"VFIO IOMMU SPAPR EEH"
 
-/* We might build address mapping here for "fast" path later */
-void vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
-{
-	eeh_dev_open(pdev);
-}
-EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_open);
-
-void vfio_spapr_pci_eeh_release(struct pci_dev *pdev)
-{
-	eeh_dev_release(pdev);
-}
-EXPORT_SYMBOL_GPL(vfio_spapr_pci_eeh_release);
-
 long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
 				unsigned int cmd, unsigned long arg)
 {
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index e7cebeb875dd1a..e8a5a9cdb9067f 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -231,21 +231,10 @@  int vfio_set_irqs_validate_and_prepare(struct vfio_irq_set *hdr,
 				       int num_irqs, int max_irq_type,
 				       size_t *data_size);
 
-struct pci_dev;
 #if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH)
-void vfio_spapr_pci_eeh_open(struct pci_dev *pdev);
-void vfio_spapr_pci_eeh_release(struct pci_dev *pdev);
 long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group, unsigned int cmd,
 				unsigned long arg);
 #else
-static inline void vfio_spapr_pci_eeh_open(struct pci_dev *pdev)
-{
-}
-
-static inline void vfio_spapr_pci_eeh_release(struct pci_dev *pdev)
-{
-}
-
 static inline long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
 					      unsigned int cmd,
 					      unsigned long arg)