Skip to content

Commit 8bccc5b

Browse files
yishaihAlex Williamson
authored andcommitted
vfio/pci: Expose vfio_pci_core_setup_barmap()
Expose vfio_pci_core_setup_barmap() to be used by drivers. This will let drivers to mmap a BAR and re-use it from both vfio and the driver when it's applicable. This API will be used in the next patches by the vfio/virtio coming driver. Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Yishai Hadas <yishaih@nvidia.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Link: https://lore.kernel.org/r/20231219093247.170936-8-yishaih@nvidia.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent c3fc3e0 commit 8bccc5b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/vfio/pci/vfio_pci_rdwr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ static ssize_t do_io_rw(struct vfio_pci_core_device *vdev, bool test_mem,
200200
return done;
201201
}
202202

203-
static int vfio_pci_setup_barmap(struct vfio_pci_core_device *vdev, int bar)
203+
int vfio_pci_core_setup_barmap(struct vfio_pci_core_device *vdev, int bar)
204204
{
205205
struct pci_dev *pdev = vdev->pdev;
206206
int ret;
@@ -223,6 +223,7 @@ static int vfio_pci_setup_barmap(struct vfio_pci_core_device *vdev, int bar)
223223

224224
return 0;
225225
}
226+
EXPORT_SYMBOL_GPL(vfio_pci_core_setup_barmap);
226227

227228
ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf,
228229
size_t count, loff_t *ppos, bool iswrite)
@@ -262,7 +263,7 @@ ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf,
262263
}
263264
x_end = end;
264265
} else {
265-
int ret = vfio_pci_setup_barmap(vdev, bar);
266+
int ret = vfio_pci_core_setup_barmap(vdev, bar);
266267
if (ret) {
267268
done = ret;
268269
goto out;
@@ -438,7 +439,7 @@ int vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t offset,
438439
return -EINVAL;
439440
#endif
440441

441-
ret = vfio_pci_setup_barmap(vdev, bar);
442+
ret = vfio_pci_core_setup_barmap(vdev, bar);
442443
if (ret)
443444
return ret;
444445

include/linux/vfio_pci_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ int vfio_pci_core_match(struct vfio_device *core_vdev, char *buf);
127127
int vfio_pci_core_enable(struct vfio_pci_core_device *vdev);
128128
void vfio_pci_core_disable(struct vfio_pci_core_device *vdev);
129129
void vfio_pci_core_finish_enable(struct vfio_pci_core_device *vdev);
130+
int vfio_pci_core_setup_barmap(struct vfio_pci_core_device *vdev, int bar);
130131
pci_ers_result_t vfio_pci_core_aer_err_detected(struct pci_dev *pdev,
131132
pci_channel_state_t state);
132133

0 commit comments

Comments
 (0)