Commit 06fddc7a authored by Leon Romanovsky's avatar Leon Romanovsky
Browse files

Merge tag 'common_phys_vec_via_vfio' into HEAD



 * Reuse common phys_vec, phase out dma_buf_phys_vec

Signed-off-by: default avatarAlex Williamson <alex@shazbot.org>

* tag 'common_phys_vec_via_vfio':
  types: reuse common phys_vec type instead of DMABUF open‑coded variant
  types: move phys_vec definition to common header
  nvme-pci: Use size_t for length fields to handle larger sizes
parents 14ab3da1 b703b31e
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -6,11 +6,6 @@
#include <linux/blk-mq-dma.h>
#include "blk.h"

struct phys_vec {
	phys_addr_t	paddr;
	u32		len;
};

static bool __blk_map_iter_next(struct blk_map_iter *iter)
{
	if (iter->iter.bi_size)
@@ -112,8 +107,8 @@ static bool blk_rq_dma_map_iova(struct request *req, struct device *dma_dev,
		struct phys_vec *vec)
{
	enum dma_data_direction dir = rq_dma_dir(req);
	unsigned int mapped = 0;
	unsigned int attrs = 0;
	size_t mapped = 0;
	int error;

	iter->addr = state->addr;
@@ -297,6 +292,8 @@ int __blk_rq_map_sg(struct request *rq, struct scatterlist *sglist,
	blk_rq_map_iter_init(rq, &iter);
	while (blk_map_iter_next(rq, &iter, &vec)) {
		*last_sg = blk_next_sg(last_sg, sglist);

		WARN_ON_ONCE(overflows_type(vec.len, unsigned int));
		sg_set_page(*last_sg, phys_to_page(vec.paddr), vec.len,
				offset_in_page(vec.paddr));
		nsegs++;
@@ -417,6 +414,8 @@ int blk_rq_map_integrity_sg(struct request *rq, struct scatterlist *sglist)

	while (blk_map_iter_next(rq, &iter, &vec)) {
		sg = blk_next_sg(&sg, sglist);

		WARN_ON_ONCE(overflows_type(vec.len, unsigned int));
		sg_set_page(sg, phys_to_page(vec.paddr), vec.len,
				offset_in_page(vec.paddr));
		segments++;
+3 −3
Original line number Diff line number Diff line
@@ -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)
{
+1 −1
Original line number Diff line number Diff line
@@ -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;
+2 −3
Original line number Diff line number Diff line
@@ -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;
}
+2 −2
Original line number Diff line number Diff line
@@ -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;
Loading