From 2371f60ad9a1c171c56036e9bcf6fc25391b47ae Mon Sep 17 00:00:00 2001 From: DAEYEONG LEE Date: Thu, 23 Jul 2026 15:23:51 +0900 Subject: [PATCH] fix(driver): guard el9 (RHEL 9) backported kernel APIs with RHEL_RELEASE_CODE RHEL 9 ships a 5.14 kernel but backports class_create(), vm_flags, device_find_child match, and devnode signatures, so LINUX_VERSION_CODE alone selected the wrong branch and mx_dma failed to build. Gate the four sites on RHEL_RELEASE_CODE >= 9.6 as well. --- core_v1.c | 2 +- init.c | 6 +++--- mx_dma.h | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core_v1.c b/core_v1.c index 9d6fa97..62e2d23 100644 --- a/core_v1.c +++ b/core_v1.c @@ -429,7 +429,7 @@ static int mxdma_bar_mmap_v1(struct mx_pci_dev *mx_pdev, } vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) || RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 6) vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP); #else vma->vm_flags |= (VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP); diff --git a/init.c b/init.c index 60ed271..c7dab2d 100644 --- a/init.c +++ b/init.c @@ -551,7 +551,7 @@ static const struct pci_device_id pci_ids[] = { MODULE_DEVICE_TABLE(pci, pci_ids); #ifndef CONFIG_WO_CXL -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 12, 0) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9, 6) static int match_mem_prefix(struct device *dev, void *data) #else static int match_mem_prefix(struct device *dev, const void *data) @@ -659,7 +659,7 @@ static struct pci_driver pci_driver = { }; #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 6) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 6) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9, 6) static char *mxdma_devnode(struct device *dev, umode_t *mode) #else static char *mxdma_devnode(const struct device *dev, umode_t *mode) @@ -715,7 +715,7 @@ static struct notifier_block mxdma_pci_notifier = { static int mxdma_init(void) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 3) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 3) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(9, 6) mxdma_class = class_create(THIS_MODULE, MXDMA_NODE_NAME); #else mxdma_class = class_create(MXDMA_NODE_NAME); diff --git a/mx_dma.h b/mx_dma.h index 9a30c02..cd9c2dc 100644 --- a/mx_dma.h +++ b/mx_dma.h @@ -8,6 +8,14 @@ #include #include #include + +/* RHEL ships a 5.14 kernel but backports later mainline APIs, so a bare + * LINUX_VERSION_CODE test picks the wrong branch; guards below also gate on + * RHEL_RELEASE_CODE, stubbed here to lose every comparison off RHEL. */ +#ifndef RHEL_RELEASE_CODE +#define RHEL_RELEASE_CODE 0 +#define RHEL_RELEASE_VERSION(a, b) 1 +#endif #include #include #include