]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
types: reuse common phys_vec type instead of DMABUF open‑coded variant
authorLeon Romanovsky <leonro@nvidia.com>
Wed, 7 Jan 2026 09:14:14 +0000 (11:14 +0200)
committerAlex Williamson <alex@shazbot.org>
Mon, 19 Jan 2026 17:13:29 +0000 (10:13 -0700)
After commit fcf463b92a08 ("types: move phys_vec definition to common header"),
we can use the shared phys_vec type instead of the DMABUF‑specific
dma_buf_phys_vec, which duplicated the same structure and semantics.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20260107-convert-to-pvec-v1-1-6e3ab8079708@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
drivers/dma-buf/dma-buf-mapping.c
drivers/iommu/iommufd/io_pagetable.h
drivers/iommu/iommufd/iommufd_private.h
drivers/iommu/iommufd/pages.c
drivers/iommu/iommufd/selftest.c
drivers/vfio/pci/nvgrace-gpu/main.c
drivers/vfio/pci/vfio_pci_dmabuf.c
include/linux/dma-buf-mapping.h
include/linux/dma-buf.h
include/linux/vfio_pci_core.h

index b7352e609fbdfa87be5acf44230c7c30456f0538..174677faa577c0ec7d91b2da85c2ca6f9fa8d2fc 100644 (file)
@@ -33,8 +33,8 @@ static struct scatterlist *fill_sg_entry(struct scatterlist *sgl, size_t length,
 }
 
 static unsigned int calc_sg_nents(struct dma_iova_state *state,
-                                 struct dma_buf_phys_vec *phys_vec,
-                                 size_t nr_ranges, size_t size)
+                                 struct phys_vec *phys_vec, size_t nr_ranges,
+                                 size_t size)
 {
        unsigned int nents = 0;
        size_t i;
@@ -91,7 +91,7 @@ struct dma_buf_dma {
  */
 struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
                                         struct p2pdma_provider *provider,
-                                        struct dma_buf_phys_vec *phys_vec,
+                                        struct phys_vec *phys_vec,
                                         size_t nr_ranges, size_t size,
                                         enum dma_data_direction dir)
 {
index 14cd052fd3204e94684eebe230b97ec72d384ac3..27e3e311d395b22c8ac5d86c0b50aefedaa109be 100644 (file)
@@ -202,7 +202,7 @@ struct iopt_pages_dmabuf_track {
 
 struct iopt_pages_dmabuf {
        struct dma_buf_attachment *attach;
-       struct dma_buf_phys_vec phys;
+       struct phys_vec phys;
        /* Always PAGE_SIZE aligned */
        unsigned long start;
        struct list_head tracker;
index eb6d1a70f6732cd3e0ffd4083dc9393dcf6a7ae5..6ac1965199e9ac221c590bc6751be0bdcd636bf7 100644 (file)
@@ -20,7 +20,6 @@ struct iommu_group;
 struct iommu_option;
 struct iommufd_device;
 struct dma_buf_attachment;
-struct dma_buf_phys_vec;
 
 struct iommufd_sw_msi_map {
        struct list_head sw_msi_item;
@@ -718,7 +717,7 @@ int __init iommufd_test_init(void);
 void iommufd_test_exit(void);
 bool iommufd_selftest_is_mock_dev(struct device *dev);
 int iommufd_test_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,
-                                    struct dma_buf_phys_vec *phys);
+                                    struct phys_vec *phys);
 #else
 static inline void iommufd_test_syz_conv_iova_id(struct iommufd_ucmd *ucmd,
                                                 unsigned int ioas_id,
@@ -742,7 +741,7 @@ static inline bool iommufd_selftest_is_mock_dev(struct device *dev)
 }
 static inline int
 iommufd_test_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,
-                                struct dma_buf_phys_vec *phys)
+                                struct phys_vec *phys)
 {
        return -EOPNOTSUPP;
 }
index dbe51ecb9a20f81efdb4211223c0360a403fee29..bababd564cf91aafa32e6626fbe803da917cea96 100644 (file)
@@ -1077,7 +1077,7 @@ static int pfn_reader_user_update_pinned(struct pfn_reader_user *user,
 }
 
 struct pfn_reader_dmabuf {
-       struct dma_buf_phys_vec phys;
+       struct phys_vec phys;
        unsigned long start_offset;
 };
 
@@ -1460,7 +1460,7 @@ static struct dma_buf_attach_ops iopt_dmabuf_attach_revoke_ops = {
  */
 static int
 sym_vfio_pci_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,
-                                struct dma_buf_phys_vec *phys)
+                                struct phys_vec *phys)
 {
        typeof(&vfio_pci_dma_buf_iommufd_map) fn;
        int rc;
index 550ff36dec3a35ff334d43108e92ccce7305333f..989d8c4c60a702e6f1f0c5dc366d1a848b2e5b6e 100644 (file)
@@ -2002,7 +2002,7 @@ static const struct dma_buf_ops iommufd_test_dmabuf_ops = {
 };
 
 int iommufd_test_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,
-                                    struct dma_buf_phys_vec *phys)
+                                    struct phys_vec *phys)
 {
        struct iommufd_test_dma_buf *priv = attachment->dmabuf->priv;
 
index 84d142a47ec67f89b279dc6d307b6df0c0fff3f3..a0f4edd6a30ba35f60187446d28ba3ce48517d7c 100644 (file)
@@ -784,7 +784,7 @@ nvgrace_gpu_write(struct vfio_device *core_vdev,
 static int nvgrace_get_dmabuf_phys(struct vfio_pci_core_device *core_vdev,
                                   struct p2pdma_provider **provider,
                                   unsigned int region_index,
-                                  struct dma_buf_phys_vec *phys_vec,
+                                  struct phys_vec *phys_vec,
                                   struct vfio_region_dma_range *dma_ranges,
                                   size_t nr_ranges)
 {
index d4d0f7d08c53e2b9b756f00b0bd41b2cd3d5370d..9a84c238c0135c87fccc72c9c99cf232c2bc01df 100644 (file)
@@ -14,7 +14,7 @@ struct vfio_pci_dma_buf {
        struct vfio_pci_core_device *vdev;
        struct list_head dmabufs_elm;
        size_t size;
-       struct dma_buf_phys_vec *phys_vec;
+       struct phys_vec *phys_vec;
        struct p2pdma_provider *provider;
        u32 nr_ranges;
        u8 revoked : 1;
@@ -94,7 +94,7 @@ static const struct dma_buf_ops vfio_pci_dmabuf_ops = {
  *    will fail if it is currently revoked
  */
 int vfio_pci_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,
-                                struct dma_buf_phys_vec *phys)
+                                struct phys_vec *phys)
 {
        struct vfio_pci_dma_buf *priv;
 
@@ -116,7 +116,7 @@ int vfio_pci_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,
 }
 EXPORT_SYMBOL_FOR_MODULES(vfio_pci_dma_buf_iommufd_map, "iommufd");
 
-int vfio_pci_core_fill_phys_vec(struct dma_buf_phys_vec *phys_vec,
+int vfio_pci_core_fill_phys_vec(struct phys_vec *phys_vec,
                                struct vfio_region_dma_range *dma_ranges,
                                size_t nr_ranges, phys_addr_t start,
                                phys_addr_t len)
@@ -148,7 +148,7 @@ EXPORT_SYMBOL_GPL(vfio_pci_core_fill_phys_vec);
 int vfio_pci_core_get_dmabuf_phys(struct vfio_pci_core_device *vdev,
                                  struct p2pdma_provider **provider,
                                  unsigned int region_index,
-                                 struct dma_buf_phys_vec *phys_vec,
+                                 struct phys_vec *phys_vec,
                                  struct vfio_region_dma_range *dma_ranges,
                                  size_t nr_ranges)
 {
index a3c0ce2d3a42fe1f4f1f76fdce127a248cac2d4d..09bde3f748e4c4fc78e5e70f7bfcbbe9be61600f 100644 (file)
@@ -9,7 +9,7 @@
 
 struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
                                         struct p2pdma_provider *provider,
-                                        struct dma_buf_phys_vec *phys_vec,
+                                        struct phys_vec *phys_vec,
                                         size_t nr_ranges, size_t size,
                                         enum dma_data_direction dir);
 void dma_buf_free_sgt(struct dma_buf_attachment *attach, struct sg_table *sgt,
index 0bc492090237ed8c4e335ecdb2e01ed8064ebbf1..400a5311368ed126cfea0c854218dc24c74ebb6d 100644 (file)
@@ -531,16 +531,6 @@ struct dma_buf_export_info {
        void *priv;
 };
 
-/**
- * struct dma_buf_phys_vec - describe continuous chunk of memory
- * @paddr:   physical address of that chunk
- * @len:     Length of this chunk
- */
-struct dma_buf_phys_vec {
-       phys_addr_t paddr;
-       size_t len;
-};
-
 /**
  * DEFINE_DMA_BUF_EXPORT_INFO - helper macro for exporters
  * @name: export-info name
index 706877f998ff37f42e2c302ef31211aff330d76f..2ac288bb2c6095bc4e274f12f4b20b0608c70ee1 100644 (file)
@@ -28,7 +28,6 @@
 struct vfio_pci_core_device;
 struct vfio_pci_region;
 struct p2pdma_provider;
-struct dma_buf_phys_vec;
 struct dma_buf_attachment;
 
 struct vfio_pci_eventfd {
@@ -62,25 +61,25 @@ struct vfio_pci_device_ops {
        int (*get_dmabuf_phys)(struct vfio_pci_core_device *vdev,
                               struct p2pdma_provider **provider,
                               unsigned int region_index,
-                              struct dma_buf_phys_vec *phys_vec,
+                              struct phys_vec *phys_vec,
                               struct vfio_region_dma_range *dma_ranges,
                               size_t nr_ranges);
 };
 
 #if IS_ENABLED(CONFIG_VFIO_PCI_DMABUF)
-int vfio_pci_core_fill_phys_vec(struct dma_buf_phys_vec *phys_vec,
+int vfio_pci_core_fill_phys_vec(struct phys_vec *phys_vec,
                                struct vfio_region_dma_range *dma_ranges,
                                size_t nr_ranges, phys_addr_t start,
                                phys_addr_t len);
 int vfio_pci_core_get_dmabuf_phys(struct vfio_pci_core_device *vdev,
                                  struct p2pdma_provider **provider,
                                  unsigned int region_index,
-                                 struct dma_buf_phys_vec *phys_vec,
+                                 struct phys_vec *phys_vec,
                                  struct vfio_region_dma_range *dma_ranges,
                                  size_t nr_ranges);
 #else
 static inline int
-vfio_pci_core_fill_phys_vec(struct dma_buf_phys_vec *phys_vec,
+vfio_pci_core_fill_phys_vec(struct phys_vec *phys_vec,
                            struct vfio_region_dma_range *dma_ranges,
                            size_t nr_ranges, phys_addr_t start,
                            phys_addr_t len)
@@ -89,7 +88,7 @@ vfio_pci_core_fill_phys_vec(struct dma_buf_phys_vec *phys_vec,
 }
 static inline int vfio_pci_core_get_dmabuf_phys(
        struct vfio_pci_core_device *vdev, struct p2pdma_provider **provider,
-       unsigned int region_index, struct dma_buf_phys_vec *phys_vec,
+       unsigned int region_index, struct phys_vec *phys_vec,
        struct vfio_region_dma_range *dma_ranges, size_t nr_ranges)
 {
        return -EOPNOTSUPP;
@@ -228,6 +227,6 @@ static inline bool is_aligned_for_order(struct vm_area_struct *vma,
 }
 
 int vfio_pci_dma_buf_iommufd_map(struct dma_buf_attachment *attachment,
-                                struct dma_buf_phys_vec *phys);
+                                struct phys_vec *phys);
 
 #endif /* VFIO_PCI_CORE_H */