Skip to content

Commit 4df13a6

Browse files
Ben Segalawilliam
authored andcommitted
vfio/pci: Support 8-byte PCI loads and stores
Many PCI adapters can benefit or even require full 64bit read and write access to their registers. In order to enable work on user-space drivers for these devices add two new variations vfio_pci_core_io{read|write}64 of the existing access methods when the architecture supports 64-bit ioreads and iowrites. Signed-off-by: Ben Segal <[email protected]> Co-developed-by: Gerd Bayer <[email protected]> Signed-off-by: Gerd Bayer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent 186bfe4 commit 4df13a6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/vfio/pci/vfio_pci_rdwr.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ EXPORT_SYMBOL_GPL(vfio_pci_core_ioread##size);
8989
VFIO_IOREAD(8)
9090
VFIO_IOREAD(16)
9191
VFIO_IOREAD(32)
92+
#ifdef ioread64
93+
VFIO_IOREAD(64)
94+
#endif
9295

9396
#define VFIO_IORDWR(size) \
9497
static int vfio_pci_iordwr##size(struct vfio_pci_core_device *vdev,\
@@ -124,6 +127,10 @@ static int vfio_pci_iordwr##size(struct vfio_pci_core_device *vdev,\
124127
VFIO_IORDWR(8)
125128
VFIO_IORDWR(16)
126129
VFIO_IORDWR(32)
130+
#if defined(ioread64) && defined(iowrite64)
131+
VFIO_IORDWR(64)
132+
#endif
133+
127134
/*
128135
* Read or write from an __iomem region (MMIO or I/O port) with an excluded
129136
* range which is inaccessible. The excluded range drops writes and fills
@@ -148,6 +155,15 @@ ssize_t vfio_pci_core_do_io_rw(struct vfio_pci_core_device *vdev, bool test_mem,
148155
else
149156
fillable = 0;
150157

158+
#if defined(ioread64) && defined(iowrite64)
159+
if (fillable >= 8 && !(off % 8)) {
160+
ret = vfio_pci_iordwr64(vdev, iswrite, test_mem,
161+
io, buf, off, &filled);
162+
if (ret)
163+
return ret;
164+
165+
} else
166+
#endif
151167
if (fillable >= 4 && !(off % 4)) {
152168
ret = vfio_pci_iordwr32(vdev, iswrite, test_mem,
153169
io, buf, off, &filled);

include/linux/vfio_pci_core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,8 @@ int vfio_pci_core_ioread##size(struct vfio_pci_core_device *vdev, \
155155
VFIO_IOREAD_DECLATION(8)
156156
VFIO_IOREAD_DECLATION(16)
157157
VFIO_IOREAD_DECLATION(32)
158+
#ifdef ioread64
159+
VFIO_IOREAD_DECLATION(64)
160+
#endif
158161

159162
#endif /* VFIO_PCI_CORE_H */

0 commit comments

Comments
 (0)