* [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h
@ 2022-08-26 19:34 Jason Gunthorpe
2022-08-26 19:34 ` [PATCH v2 1/3] vfio/pci: Split linux/vfio_pci_core.h Jason Gunthorpe
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2022-08-26 19:34 UTC (permalink / raw)
To: Alex Williamson, Cornelia Huck, Eric Farman, kvm, linux-s390,
Matthew Rosato
Cc: Kevin Tian
The include/linux header should only include things that are intended to
be used outside the internal implementation of the vfio_pci_core
module. Several internal-only items were left over in this file after the
conversion from vfio_pci.
Transfer most of the items to a new vfio_pci_priv.h located under
drivers/vfio/pci/.
v2:
- Add "vfio/pci: Rename vfio_pci_register_dev_region()"v1: https://lore.kernel.org/r/0-v1-da6fc51ee22e+562-vfio_pci_priv_jgg@nvidia.com
v1: https://lore.kernel.org/r/0-v1-da6fc51ee22e+562-vfio_pci_priv_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Jason Gunthorpe (3):
vfio/pci: Split linux/vfio_pci_core.h
vfio/pci: Rename vfio_pci_register_dev_region()
vfio/pci: Simplify the is_intx/msi/msix/etc defines
drivers/vfio/pci/vfio_pci.c | 2 +-
drivers/vfio/pci/vfio_pci_config.c | 4 +-
drivers/vfio/pci/vfio_pci_core.c | 29 ++++--
drivers/vfio/pci/vfio_pci_igd.c | 8 +-
drivers/vfio/pci/vfio_pci_intrs.c | 28 +++++-
drivers/vfio/pci/vfio_pci_priv.h | 104 +++++++++++++++++++++
drivers/vfio/pci/vfio_pci_rdwr.c | 2 +-
drivers/vfio/pci/vfio_pci_zdev.c | 2 +-
include/linux/vfio_pci_core.h | 140 +----------------------------
9 files changed, 167 insertions(+), 152 deletions(-)
create mode 100644 drivers/vfio/pci/vfio_pci_priv.h
base-commit: 1c23f9e627a7b412978b4e852793c5e3c3efc555
--
2.37.2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/3] vfio/pci: Split linux/vfio_pci_core.h
2022-08-26 19:34 [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h Jason Gunthorpe
@ 2022-08-26 19:34 ` Jason Gunthorpe
2022-08-29 11:47 ` Cornelia Huck
2022-08-26 19:34 ` [PATCH v2 2/3] vfio/pci: Rename vfio_pci_register_dev_region() Jason Gunthorpe
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Jason Gunthorpe @ 2022-08-26 19:34 UTC (permalink / raw)
To: Alex Williamson, Cornelia Huck, Eric Farman, kvm, linux-s390,
Matthew Rosato
Cc: Kevin Tian
The header in include/linux should have only the exported interface for
other vfio_pci module's to use. Internal definitions for vfio_pci.ko
should be in a "priv" header along side the .c files.
Move the internal declarations out of vfio_pci_core.h. They either move to
vfio_pci_priv.h or to the C file that is the only user.
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/vfio/pci/vfio_pci.c | 2 +-
drivers/vfio/pci/vfio_pci_config.c | 2 +-
drivers/vfio/pci/vfio_pci_core.c | 19 +++-
drivers/vfio/pci/vfio_pci_igd.c | 2 +-
drivers/vfio/pci/vfio_pci_intrs.c | 16 +++-
drivers/vfio/pci/vfio_pci_priv.h | 106 +++++++++++++++++++++++
drivers/vfio/pci/vfio_pci_rdwr.c | 2 +-
drivers/vfio/pci/vfio_pci_zdev.c | 2 +-
include/linux/vfio_pci_core.h | 134 +----------------------------
9 files changed, 145 insertions(+), 140 deletions(-)
create mode 100644 drivers/vfio/pci/vfio_pci_priv.h
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 4d1a97415a27bf..d9b5c03f8d5b23 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -25,7 +25,7 @@
#include <linux/types.h>
#include <linux/uaccess.h>
-#include <linux/vfio_pci_core.h>
+#include "vfio_pci_priv.h"
#define DRIVER_AUTHOR "Alex Williamson <alex.williamson@redhat.com>"
#define DRIVER_DESC "VFIO PCI - User Level meta-driver"
diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index 442d3ba4122b22..5f43b28075eecd 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -26,7 +26,7 @@
#include <linux/vfio.h>
#include <linux/slab.h>
-#include <linux/vfio_pci_core.h>
+#include "vfio_pci_priv.h"
/* Fake capability ID for standard config space */
#define PCI_CAP_ID_BASIC 0
diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index c8d3b0450fb35b..04180a0836cc90 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -28,7 +28,7 @@
#include <linux/nospec.h>
#include <linux/sched/mm.h>
-#include <linux/vfio_pci_core.h>
+#include "vfio_pci_priv.h"
#define DRIVER_AUTHOR "Alex Williamson <alex.williamson@redhat.com>"
#define DRIVER_DESC "core driver for VFIO based PCI devices"
@@ -41,6 +41,23 @@ static bool disable_idle_d3;
static DEFINE_MUTEX(vfio_pci_sriov_pfs_mutex);
static LIST_HEAD(vfio_pci_sriov_pfs);
+struct vfio_pci_dummy_resource {
+ struct resource resource;
+ int index;
+ struct list_head res_next;
+};
+
+struct vfio_pci_vf_token {
+ struct mutex lock;
+ uuid_t uuid;
+ int users;
+};
+
+struct vfio_pci_mmap_vma {
+ struct vm_area_struct *vma;
+ struct list_head vma_next;
+};
+
static inline bool vfio_vga_disabled(void)
{
#ifdef CONFIG_VFIO_PCI_VGA
diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c
index 352c725ccf1812..8177e9a1da3bfd 100644
--- a/drivers/vfio/pci/vfio_pci_igd.c
+++ b/drivers/vfio/pci/vfio_pci_igd.c
@@ -15,7 +15,7 @@
#include <linux/uaccess.h>
#include <linux/vfio.h>
-#include <linux/vfio_pci_core.h>
+#include "vfio_pci_priv.h"
#define OPREGION_SIGNATURE "IntelGraphicsMem"
#define OPREGION_SIZE (8 * 1024)
diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 6069a11fb51acf..32d014421c1f61 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -20,7 +20,21 @@
#include <linux/wait.h>
#include <linux/slab.h>
-#include <linux/vfio_pci_core.h>
+#include "vfio_pci_priv.h"
+
+#define is_intx(vdev) (vdev->irq_type == VFIO_PCI_INTX_IRQ_INDEX)
+#define is_msix(vdev) (vdev->irq_type == VFIO_PCI_MSIX_IRQ_INDEX)
+#define is_irq_none(vdev) (!(is_intx(vdev) || is_msi(vdev) || is_msix(vdev)))
+#define irq_is(vdev, type) (vdev->irq_type == type)
+
+struct vfio_pci_irq_ctx {
+ struct eventfd_ctx *trigger;
+ struct virqfd *unmask;
+ struct virqfd *mask;
+ char *name;
+ bool masked;
+ struct irq_bypass_producer producer;
+};
/*
* INTx
diff --git a/drivers/vfio/pci/vfio_pci_priv.h b/drivers/vfio/pci/vfio_pci_priv.h
new file mode 100644
index 00000000000000..ac701f05bef022
--- /dev/null
+++ b/drivers/vfio/pci/vfio_pci_priv.h
@@ -0,0 +1,106 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef VFIO_PCI_PRIV_H
+#define VFIO_PCI_PRIV_H
+
+#include <linux/vfio_pci_core.h>
+
+/* Special capability IDs predefined access */
+#define PCI_CAP_ID_INVALID 0xFF /* default raw access */
+#define PCI_CAP_ID_INVALID_VIRT 0xFE /* default virt access */
+
+/* Cap maximum number of ioeventfds per device (arbitrary) */
+#define VFIO_PCI_IOEVENTFD_MAX 1000
+
+struct vfio_pci_ioeventfd {
+ struct list_head next;
+ struct vfio_pci_core_device *vdev;
+ struct virqfd *virqfd;
+ void __iomem *addr;
+ uint64_t data;
+ loff_t pos;
+ int bar;
+ int count;
+ bool test_mem;
+};
+
+#define is_msi(vdev) (vdev->irq_type == VFIO_PCI_MSI_IRQ_INDEX)
+
+void vfio_pci_intx_mask(struct vfio_pci_core_device *vdev);
+void vfio_pci_intx_unmask(struct vfio_pci_core_device *vdev);
+
+int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device *vdev, uint32_t flags,
+ unsigned index, unsigned start, unsigned count,
+ void *data);
+
+ssize_t vfio_pci_config_rw(struct vfio_pci_core_device *vdev, char __user *buf,
+ size_t count, loff_t *ppos, bool iswrite);
+
+ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf,
+ size_t count, loff_t *ppos, bool iswrite);
+
+#ifdef CONFIG_VFIO_PCI_VGA
+ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __user *buf,
+ size_t count, loff_t *ppos, bool iswrite);
+#else
+static inline ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev,
+ char __user *buf, size_t count,
+ loff_t *ppos, bool iswrite)
+{
+ return -EINVAL;
+}
+#endif
+
+long vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t offset,
+ uint64_t data, int count, int fd);
+
+int vfio_pci_init_perm_bits(void);
+void vfio_pci_uninit_perm_bits(void);
+
+int vfio_config_init(struct vfio_pci_core_device *vdev);
+void vfio_config_free(struct vfio_pci_core_device *vdev);
+
+int vfio_pci_set_power_state(struct vfio_pci_core_device *vdev,
+ pci_power_t state);
+
+bool __vfio_pci_memory_enabled(struct vfio_pci_core_device *vdev);
+void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_core_device *vdev);
+u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_core_device *vdev);
+void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev,
+ u16 cmd);
+
+#ifdef CONFIG_VFIO_PCI_IGD
+int vfio_pci_igd_init(struct vfio_pci_core_device *vdev);
+#else
+static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
+{
+ return -ENODEV;
+}
+#endif
+
+#ifdef CONFIG_VFIO_PCI_ZDEV_KVM
+int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
+ struct vfio_info_cap *caps);
+int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev);
+void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev);
+#else
+static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
+ struct vfio_info_cap *caps)
+{
+ return -ENODEV;
+}
+
+static inline int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
+{
+ return 0;
+}
+
+static inline void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)
+{}
+#endif
+
+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/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c
index 82ac1569deb052..d5e9883c1eee10 100644
--- a/drivers/vfio/pci/vfio_pci_rdwr.c
+++ b/drivers/vfio/pci/vfio_pci_rdwr.c
@@ -17,7 +17,7 @@
#include <linux/vfio.h>
#include <linux/vgaarb.h>
-#include <linux/vfio_pci_core.h>
+#include "vfio_pci_priv.h"
#ifdef __LITTLE_ENDIAN
#define vfio_ioread64 ioread64
diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c
index e163aa9f61444f..0bff24f0d4d717 100644
--- a/drivers/vfio/pci/vfio_pci_zdev.c
+++ b/drivers/vfio/pci/vfio_pci_zdev.c
@@ -15,7 +15,7 @@
#include <asm/pci_clp.h>
#include <asm/pci_io.h>
-#include <linux/vfio_pci_core.h>
+#include "vfio_pci_priv.h"
/*
* Add the Base PCI Function information to the device info region.
diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h
index 5579ece4347bdc..9d18b832e61a0d 100644
--- a/include/linux/vfio_pci_core.h
+++ b/include/linux/vfio_pci_core.h
@@ -20,39 +20,10 @@
#define VFIO_PCI_CORE_H
#define VFIO_PCI_OFFSET_SHIFT 40
-
#define VFIO_PCI_OFFSET_TO_INDEX(off) (off >> VFIO_PCI_OFFSET_SHIFT)
#define VFIO_PCI_INDEX_TO_OFFSET(index) ((u64)(index) << VFIO_PCI_OFFSET_SHIFT)
#define VFIO_PCI_OFFSET_MASK (((u64)(1) << VFIO_PCI_OFFSET_SHIFT) - 1)
-/* Special capability IDs predefined access */
-#define PCI_CAP_ID_INVALID 0xFF /* default raw access */
-#define PCI_CAP_ID_INVALID_VIRT 0xFE /* default virt access */
-
-/* Cap maximum number of ioeventfds per device (arbitrary) */
-#define VFIO_PCI_IOEVENTFD_MAX 1000
-
-struct vfio_pci_ioeventfd {
- struct list_head next;
- struct vfio_pci_core_device *vdev;
- struct virqfd *virqfd;
- void __iomem *addr;
- uint64_t data;
- loff_t pos;
- int bar;
- int count;
- bool test_mem;
-};
-
-struct vfio_pci_irq_ctx {
- struct eventfd_ctx *trigger;
- struct virqfd *unmask;
- struct virqfd *mask;
- char *name;
- bool masked;
- struct irq_bypass_producer producer;
-};
-
struct vfio_pci_core_device;
struct vfio_pci_region;
@@ -78,23 +49,6 @@ struct vfio_pci_region {
u32 flags;
};
-struct vfio_pci_dummy_resource {
- struct resource resource;
- int index;
- struct list_head res_next;
-};
-
-struct vfio_pci_vf_token {
- struct mutex lock;
- uuid_t uuid;
- int users;
-};
-
-struct vfio_pci_mmap_vma {
- struct vm_area_struct *vma;
- struct list_head vma_next;
-};
-
struct vfio_pci_core_device {
struct vfio_device vdev;
struct pci_dev *pdev;
@@ -141,92 +95,11 @@ struct vfio_pci_core_device {
struct rw_semaphore memory_lock;
};
-#define is_intx(vdev) (vdev->irq_type == VFIO_PCI_INTX_IRQ_INDEX)
-#define is_msi(vdev) (vdev->irq_type == VFIO_PCI_MSI_IRQ_INDEX)
-#define is_msix(vdev) (vdev->irq_type == VFIO_PCI_MSIX_IRQ_INDEX)
-#define is_irq_none(vdev) (!(is_intx(vdev) || is_msi(vdev) || is_msix(vdev)))
-#define irq_is(vdev, type) (vdev->irq_type == type)
-
-void vfio_pci_intx_mask(struct vfio_pci_core_device *vdev);
-void vfio_pci_intx_unmask(struct vfio_pci_core_device *vdev);
-
-int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device *vdev,
- uint32_t flags, unsigned index,
- unsigned start, unsigned count, void *data);
-
-ssize_t vfio_pci_config_rw(struct vfio_pci_core_device *vdev,
- char __user *buf, size_t count,
- loff_t *ppos, bool iswrite);
-
-ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf,
- size_t count, loff_t *ppos, bool iswrite);
-
-#ifdef CONFIG_VFIO_PCI_VGA
-ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __user *buf,
- size_t count, loff_t *ppos, bool iswrite);
-#else
-static inline ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev,
- char __user *buf, size_t count,
- loff_t *ppos, bool iswrite)
-{
- return -EINVAL;
-}
-#endif
-
-long vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t offset,
- uint64_t data, int count, int fd);
-
-int vfio_pci_init_perm_bits(void);
-void vfio_pci_uninit_perm_bits(void);
-
-int vfio_config_init(struct vfio_pci_core_device *vdev);
-void vfio_config_free(struct vfio_pci_core_device *vdev);
-
+/* Will be exported for vfio pci drivers usage */
int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev,
unsigned int type, unsigned int subtype,
const struct vfio_pci_regops *ops,
size_t size, u32 flags, void *data);
-
-int vfio_pci_set_power_state(struct vfio_pci_core_device *vdev,
- pci_power_t state);
-
-bool __vfio_pci_memory_enabled(struct vfio_pci_core_device *vdev);
-void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_core_device *vdev);
-u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_core_device *vdev);
-void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev,
- u16 cmd);
-
-#ifdef CONFIG_VFIO_PCI_IGD
-int vfio_pci_igd_init(struct vfio_pci_core_device *vdev);
-#else
-static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
-{
- return -ENODEV;
-}
-#endif
-
-#ifdef CONFIG_VFIO_PCI_ZDEV_KVM
-int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
- struct vfio_info_cap *caps);
-int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev);
-void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev);
-#else
-static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
- struct vfio_info_cap *caps)
-{
- return -ENODEV;
-}
-
-static inline int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
-{
- return 0;
-}
-
-static inline void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)
-{}
-#endif
-
-/* Will be exported for vfio pci drivers usage */
void vfio_pci_core_set_params(bool nointxmask, bool is_disable_vga,
bool is_disable_idle_d3);
void vfio_pci_core_close_device(struct vfio_device *core_vdev);
@@ -256,9 +129,4 @@ void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev);
pci_ers_result_t vfio_pci_core_aer_err_detected(struct pci_dev *pdev,
pci_channel_state_t state);
-static inline bool vfio_pci_is_vga(struct pci_dev *pdev)
-{
- return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
-}
-
#endif /* VFIO_PCI_CORE_H */
--
2.37.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] vfio/pci: Rename vfio_pci_register_dev_region()
2022-08-26 19:34 [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h Jason Gunthorpe
2022-08-26 19:34 ` [PATCH v2 1/3] vfio/pci: Split linux/vfio_pci_core.h Jason Gunthorpe
@ 2022-08-26 19:34 ` Jason Gunthorpe
2022-08-29 0:45 ` Tian, Kevin
2022-08-29 11:49 ` Cornelia Huck
2022-08-26 19:34 ` [PATCH v2 3/3] vfio/pci: Simplify the is_intx/msi/msix/etc defines Jason Gunthorpe
2022-09-02 18:42 ` [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h Alex Williamson
3 siblings, 2 replies; 9+ messages in thread
From: Jason Gunthorpe @ 2022-08-26 19:34 UTC (permalink / raw)
To: Alex Williamson, Cornelia Huck, Eric Farman, kvm, linux-s390,
Matthew Rosato
Cc: Kevin Tian
As this is part of the vfio_pci_core component it should be called
vfio_pci_core_register_dev_region() like everything else exported from
this module.
Suggested-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/vfio/pci/vfio_pci_core.c | 10 +++++-----
drivers/vfio/pci/vfio_pci_igd.c | 6 +++---
include/linux/vfio_pci_core.h | 8 ++++----
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index 04180a0836cc90..84279b6941bc2a 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -662,10 +662,10 @@ static int msix_mmappable_cap(struct vfio_pci_core_device *vdev,
return vfio_info_add_capability(caps, &header, sizeof(header));
}
-int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev,
- unsigned int type, unsigned int subtype,
- const struct vfio_pci_regops *ops,
- size_t size, u32 flags, void *data)
+int vfio_pci_core_register_dev_region(struct vfio_pci_core_device *vdev,
+ unsigned int type, unsigned int subtype,
+ const struct vfio_pci_regops *ops,
+ size_t size, u32 flags, void *data)
{
struct vfio_pci_region *region;
@@ -687,7 +687,7 @@ int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev,
return 0;
}
-EXPORT_SYMBOL_GPL(vfio_pci_register_dev_region);
+EXPORT_SYMBOL_GPL(vfio_pci_core_register_dev_region);
long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd,
unsigned long arg)
diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c
index 8177e9a1da3bfd..5e6ca592695485 100644
--- a/drivers/vfio/pci/vfio_pci_igd.c
+++ b/drivers/vfio/pci/vfio_pci_igd.c
@@ -257,7 +257,7 @@ static int vfio_pci_igd_opregion_init(struct vfio_pci_core_device *vdev)
}
}
- ret = vfio_pci_register_dev_region(vdev,
+ ret = vfio_pci_core_register_dev_region(vdev,
PCI_VENDOR_ID_INTEL | VFIO_REGION_TYPE_PCI_VENDOR_TYPE,
VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION, &vfio_pci_igd_regops,
size, VFIO_REGION_INFO_FLAG_READ, opregionvbt);
@@ -402,7 +402,7 @@ static int vfio_pci_igd_cfg_init(struct vfio_pci_core_device *vdev)
return -EINVAL;
}
- ret = vfio_pci_register_dev_region(vdev,
+ ret = vfio_pci_core_register_dev_region(vdev,
PCI_VENDOR_ID_INTEL | VFIO_REGION_TYPE_PCI_VENDOR_TYPE,
VFIO_REGION_SUBTYPE_INTEL_IGD_HOST_CFG,
&vfio_pci_igd_cfg_regops, host_bridge->cfg_size,
@@ -422,7 +422,7 @@ static int vfio_pci_igd_cfg_init(struct vfio_pci_core_device *vdev)
return -EINVAL;
}
- ret = vfio_pci_register_dev_region(vdev,
+ ret = vfio_pci_core_register_dev_region(vdev,
PCI_VENDOR_ID_INTEL | VFIO_REGION_TYPE_PCI_VENDOR_TYPE,
VFIO_REGION_SUBTYPE_INTEL_IGD_LPC_CFG,
&vfio_pci_igd_cfg_regops, lpc_bridge->cfg_size,
diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h
index 9d18b832e61a0d..e5cf0d3313a694 100644
--- a/include/linux/vfio_pci_core.h
+++ b/include/linux/vfio_pci_core.h
@@ -96,10 +96,10 @@ struct vfio_pci_core_device {
};
/* Will be exported for vfio pci drivers usage */
-int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev,
- unsigned int type, unsigned int subtype,
- const struct vfio_pci_regops *ops,
- size_t size, u32 flags, void *data);
+int vfio_pci_core_register_dev_region(struct vfio_pci_core_device *vdev,
+ unsigned int type, unsigned int subtype,
+ const struct vfio_pci_regops *ops,
+ size_t size, u32 flags, void *data);
void vfio_pci_core_set_params(bool nointxmask, bool is_disable_vga,
bool is_disable_idle_d3);
void vfio_pci_core_close_device(struct vfio_device *core_vdev);
--
2.37.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] vfio/pci: Simplify the is_intx/msi/msix/etc defines
2022-08-26 19:34 [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h Jason Gunthorpe
2022-08-26 19:34 ` [PATCH v2 1/3] vfio/pci: Split linux/vfio_pci_core.h Jason Gunthorpe
2022-08-26 19:34 ` [PATCH v2 2/3] vfio/pci: Rename vfio_pci_register_dev_region() Jason Gunthorpe
@ 2022-08-26 19:34 ` Jason Gunthorpe
2022-08-29 11:51 ` Cornelia Huck
2022-09-02 18:42 ` [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h Alex Williamson
3 siblings, 1 reply; 9+ messages in thread
From: Jason Gunthorpe @ 2022-08-26 19:34 UTC (permalink / raw)
To: Alex Williamson, Cornelia Huck, Eric Farman, kvm, linux-s390,
Matthew Rosato
Cc: Kevin Tian
Only three of these are actually used, simplify to three inline functions,
and open code the if statement in vfio_pci_config.c.
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/vfio/pci/vfio_pci_config.c | 2 +-
drivers/vfio/pci/vfio_pci_intrs.c | 22 +++++++++++++++++-----
drivers/vfio/pci/vfio_pci_priv.h | 2 --
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index 5f43b28075eecd..4a350421c5f62a 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -1166,7 +1166,7 @@ static int vfio_msi_config_write(struct vfio_pci_core_device *vdev, int pos,
flags = le16_to_cpu(*pflags);
/* MSI is enabled via ioctl */
- if (!is_msi(vdev))
+ if (vdev->irq_type != VFIO_PCI_MSI_IRQ_INDEX)
flags &= ~PCI_MSI_FLAGS_ENABLE;
/* Check queue size */
diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 32d014421c1f61..8cb987ef3c4763 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -22,11 +22,6 @@
#include "vfio_pci_priv.h"
-#define is_intx(vdev) (vdev->irq_type == VFIO_PCI_INTX_IRQ_INDEX)
-#define is_msix(vdev) (vdev->irq_type == VFIO_PCI_MSIX_IRQ_INDEX)
-#define is_irq_none(vdev) (!(is_intx(vdev) || is_msi(vdev) || is_msix(vdev)))
-#define irq_is(vdev, type) (vdev->irq_type == type)
-
struct vfio_pci_irq_ctx {
struct eventfd_ctx *trigger;
struct virqfd *unmask;
@@ -36,6 +31,23 @@ struct vfio_pci_irq_ctx {
struct irq_bypass_producer producer;
};
+static bool irq_is(struct vfio_pci_core_device *vdev, int type)
+{
+ return vdev->irq_type == type;
+}
+
+static bool is_intx(struct vfio_pci_core_device *vdev)
+{
+ return vdev->irq_type == VFIO_PCI_INTX_IRQ_INDEX;
+}
+
+static bool is_irq_none(struct vfio_pci_core_device *vdev)
+{
+ return !(vdev->irq_type == VFIO_PCI_INTX_IRQ_INDEX ||
+ vdev->irq_type == VFIO_PCI_MSI_IRQ_INDEX ||
+ vdev->irq_type == VFIO_PCI_MSIX_IRQ_INDEX);
+}
+
/*
* INTx
*/
diff --git a/drivers/vfio/pci/vfio_pci_priv.h b/drivers/vfio/pci/vfio_pci_priv.h
index ac701f05bef022..4830fb01a1caa2 100644
--- a/drivers/vfio/pci/vfio_pci_priv.h
+++ b/drivers/vfio/pci/vfio_pci_priv.h
@@ -23,8 +23,6 @@ struct vfio_pci_ioeventfd {
bool test_mem;
};
-#define is_msi(vdev) (vdev->irq_type == VFIO_PCI_MSI_IRQ_INDEX)
-
void vfio_pci_intx_mask(struct vfio_pci_core_device *vdev);
void vfio_pci_intx_unmask(struct vfio_pci_core_device *vdev);
--
2.37.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH v2 2/3] vfio/pci: Rename vfio_pci_register_dev_region()
2022-08-26 19:34 ` [PATCH v2 2/3] vfio/pci: Rename vfio_pci_register_dev_region() Jason Gunthorpe
@ 2022-08-29 0:45 ` Tian, Kevin
2022-08-29 11:49 ` Cornelia Huck
1 sibling, 0 replies; 9+ messages in thread
From: Tian, Kevin @ 2022-08-29 0:45 UTC (permalink / raw)
To: Jason Gunthorpe, Alex Williamson, Cornelia Huck, Eric Farman,
kvm, linux-s390, Matthew Rosato
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Saturday, August 27, 2022 3:34 AM
>
> As this is part of the vfio_pci_core component it should be called
> vfio_pci_core_register_dev_region() like everything else exported from
> this module.
>
> Suggested-by: Kevin Tian <kevin.tian@intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/3] vfio/pci: Split linux/vfio_pci_core.h
2022-08-26 19:34 ` [PATCH v2 1/3] vfio/pci: Split linux/vfio_pci_core.h Jason Gunthorpe
@ 2022-08-29 11:47 ` Cornelia Huck
0 siblings, 0 replies; 9+ messages in thread
From: Cornelia Huck @ 2022-08-29 11:47 UTC (permalink / raw)
To: Jason Gunthorpe, Alex Williamson, Eric Farman, kvm, linux-s390,
Matthew Rosato
Cc: Kevin Tian
On Fri, Aug 26 2022, Jason Gunthorpe <jgg@nvidia.com> wrote:
> The header in include/linux should have only the exported interface for
> other vfio_pci module's to use. Internal definitions for vfio_pci.ko
s/module's/modules/
> should be in a "priv" header along side the .c files.
>
> Move the internal declarations out of vfio_pci_core.h. They either move to
> vfio_pci_priv.h or to the C file that is the only user.
>
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/vfio/pci/vfio_pci.c | 2 +-
> drivers/vfio/pci/vfio_pci_config.c | 2 +-
> drivers/vfio/pci/vfio_pci_core.c | 19 +++-
> drivers/vfio/pci/vfio_pci_igd.c | 2 +-
> drivers/vfio/pci/vfio_pci_intrs.c | 16 +++-
> drivers/vfio/pci/vfio_pci_priv.h | 106 +++++++++++++++++++++++
> drivers/vfio/pci/vfio_pci_rdwr.c | 2 +-
> drivers/vfio/pci/vfio_pci_zdev.c | 2 +-
> include/linux/vfio_pci_core.h | 134 +----------------------------
> 9 files changed, 145 insertions(+), 140 deletions(-)
> create mode 100644 drivers/vfio/pci/vfio_pci_priv.h
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] vfio/pci: Rename vfio_pci_register_dev_region()
2022-08-26 19:34 ` [PATCH v2 2/3] vfio/pci: Rename vfio_pci_register_dev_region() Jason Gunthorpe
2022-08-29 0:45 ` Tian, Kevin
@ 2022-08-29 11:49 ` Cornelia Huck
1 sibling, 0 replies; 9+ messages in thread
From: Cornelia Huck @ 2022-08-29 11:49 UTC (permalink / raw)
To: Jason Gunthorpe, Alex Williamson, Eric Farman, kvm, linux-s390,
Matthew Rosato
Cc: Kevin Tian
On Fri, Aug 26 2022, Jason Gunthorpe <jgg@nvidia.com> wrote:
> As this is part of the vfio_pci_core component it should be called
> vfio_pci_core_register_dev_region() like everything else exported from
> this module.
>
> Suggested-by: Kevin Tian <kevin.tian@intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/vfio/pci/vfio_pci_core.c | 10 +++++-----
> drivers/vfio/pci/vfio_pci_igd.c | 6 +++---
> include/linux/vfio_pci_core.h | 8 ++++----
> 3 files changed, 12 insertions(+), 12 deletions(-)
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] vfio/pci: Simplify the is_intx/msi/msix/etc defines
2022-08-26 19:34 ` [PATCH v2 3/3] vfio/pci: Simplify the is_intx/msi/msix/etc defines Jason Gunthorpe
@ 2022-08-29 11:51 ` Cornelia Huck
0 siblings, 0 replies; 9+ messages in thread
From: Cornelia Huck @ 2022-08-29 11:51 UTC (permalink / raw)
To: Jason Gunthorpe, Alex Williamson, Eric Farman, kvm, linux-s390,
Matthew Rosato
Cc: Kevin Tian
On Fri, Aug 26 2022, Jason Gunthorpe <jgg@nvidia.com> wrote:
> Only three of these are actually used, simplify to three inline functions,
> and open code the if statement in vfio_pci_config.c.
>
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/vfio/pci/vfio_pci_config.c | 2 +-
> drivers/vfio/pci/vfio_pci_intrs.c | 22 +++++++++++++++++-----
> drivers/vfio/pci/vfio_pci_priv.h | 2 --
> 3 files changed, 18 insertions(+), 8 deletions(-)
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h
2022-08-26 19:34 [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h Jason Gunthorpe
` (2 preceding siblings ...)
2022-08-26 19:34 ` [PATCH v2 3/3] vfio/pci: Simplify the is_intx/msi/msix/etc defines Jason Gunthorpe
@ 2022-09-02 18:42 ` Alex Williamson
3 siblings, 0 replies; 9+ messages in thread
From: Alex Williamson @ 2022-09-02 18:42 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Cornelia Huck, Eric Farman, kvm, linux-s390, Matthew Rosato, Kevin Tian
On Fri, 26 Aug 2022 16:34:00 -0300
Jason Gunthorpe <jgg@nvidia.com> wrote:
> The include/linux header should only include things that are intended to
> be used outside the internal implementation of the vfio_pci_core
> module. Several internal-only items were left over in this file after the
> conversion from vfio_pci.
>
> Transfer most of the items to a new vfio_pci_priv.h located under
> drivers/vfio/pci/.
>
> v2:
Applied to vfio next branch for v6.1. Thanks,
Alex
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-09-02 18:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26 19:34 [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h Jason Gunthorpe
2022-08-26 19:34 ` [PATCH v2 1/3] vfio/pci: Split linux/vfio_pci_core.h Jason Gunthorpe
2022-08-29 11:47 ` Cornelia Huck
2022-08-26 19:34 ` [PATCH v2 2/3] vfio/pci: Rename vfio_pci_register_dev_region() Jason Gunthorpe
2022-08-29 0:45 ` Tian, Kevin
2022-08-29 11:49 ` Cornelia Huck
2022-08-26 19:34 ` [PATCH v2 3/3] vfio/pci: Simplify the is_intx/msi/msix/etc defines Jason Gunthorpe
2022-08-29 11:51 ` Cornelia Huck
2022-09-02 18:42 ` [PATCH v2 0/3] Remove private items from linux/vfio_pci_core.h Alex Williamson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).