Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions userspace/dpdk/enav2-vfio-patch/get-vfio-with-wc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ function get_kernel_version {
printf "%d%02d%04d" "${ver_major}" "${ver_minor}" "${ver_subminor}"
}

function download_kernel_src_yum {
echo "Use yum to get the kernel sources"
function download_kernel_src_dnf {
echo "Use dnf to get the kernel sources"

bold "\nInstall required applications and kernel headers"
yum install -y gcc "kernel-$(uname -r)" "kernel-devel-$(uname -r)" \
git make elfutils-libelf-devel patch yum-utils
dnf install -y gcc kernel6.12-devel kernel6.12-headers \
git make elfutils-libelf-devel patch dnf-plugins-core
green Done

# Download kernel source
bold "\nDownload kernel source with vfio"
yumdownloader --source "kernel-devel-$(uname -r)"
dnf download --source kernel6.12-devel
rpm2cpio kernel*.src.rpm | cpio -idmv
green Done

Expand Down Expand Up @@ -96,18 +96,21 @@ function download_kernel_src {
if apt-get -v >/dev/null 2>/dev/null; then
download_kernel_src_apt
else
download_kernel_src_yum
download_kernel_src_dnf
fi
cd linux-*
}

function apply_wc_patch {
if [ "${KERNEL_VERSION}" -ge 6080000 ]; then
echo "Using patch for kernel version 6.8"
local wc_patch="${BASE_PATH}/patches/linux-6.8-vfio-wc.patch"
elif [ "${KERNEL_VERSION}" -ge 5150000 ]; then
echo "Using patch for kernel version 5.15"
local wc_patch="${BASE_PATH}/patches/linux-5.15-vfio-wc.patch"
if [ "${KERNEL_VERSION}" -ge 6120000 ]; then
echo "Using patch for kernel version 6.12"
local wc_patch="${BASE_PATH}/patches/linux-6.12-vfio-wc.patch"
elif [ "${KERNEL_VERSION}" -ge 6080000 ]; then
echo "Using patch for kernel version 6.8"
local wc_patch="${BASE_PATH}/patches/linux-6.8-vfio-wc.patch"
elif [ "${KERNEL_VERSION}" -ge 5150000 ]; then
echo "Using patch for kernel version 5.15"
local wc_patch="${BASE_PATH}/patches/linux-5.15-vfio-wc.patch"
elif [ "${KERNEL_VERSION}" -ge 5080000 ]; then
echo "Using patch for kernel version 5.8"
local wc_patch="${BASE_PATH}/patches/linux-5.8-vfio-wc.patch"
Expand Down
30 changes: 30 additions & 0 deletions userspace/dpdk/enav2-vfio-patch/patches/linux-6.12-vfio-wc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index 1ab58da9f..1370b466a 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -1769,7 +1769,12 @@ int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma
if (ret)
return ret;

- vdev->barmap[index] = pci_iomap(pdev, index, 0);
+ if (pci_resource_flags(pdev, index) & IORESOURCE_PREFETCH)
+ vdev->barmap[index] = ioremap_wc(
+ pci_resource_start(pdev, index),
+ pci_resource_len(pdev, index));
+ else
+ vdev->barmap[index] = pci_iomap(pdev, index, 0);
if (!vdev->barmap[index]) {
pci_release_selected_regions(pdev, 1 << index);
return -ENOMEM;
@@ -1777,7 +1782,10 @@ int vfio_pci_core_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma
}

vma->vm_private_data = vdev;
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+ if (pci_resource_flags(pdev, index) & IORESOURCE_PREFETCH)
+ vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+ else
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);

/*