Skip to content

Commit 6b8a836

Browse files
nindanaotoclaude
andcommitted
backport changes to support AlmaLinux 9.7
Add RHEL_9_7_GE macro and kernel API compatibility for AlmaLinux 9.7 which backports kernel 6.13+ APIs: - iommu_present() -> device_iommu_mapped() - crc32c_le/crc32c.h -> crc32_le/crc32.h - struct drm_driver .date member removal Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: nindanaoto <matsuoka.kotaro@gmail.com>
1 parent c4a784f commit 6b8a836

6 files changed

Lines changed: 35 additions & 4 deletions

File tree

src/runtime_src/core/pcie/driver/linux/xocl/lib/libxdma.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4344,7 +4344,9 @@ MODULE_AUTHOR("Xilinx, Inc.");
43444344
MODULE_DESCRIPTION(DRV_MODULE_DESC);
43454345
MODULE_VERSION(DRV_MODULE_VERSION);
43464346
MODULE_LICENSE("GPL v2");
4347-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0) || defined(RHEL_9_0_GE)
4347+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0)
4348+
MODULE_IMPORT_NS("DMA_BUF");
4349+
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0) || defined(RHEL_9_0_GE)
43484350
MODULE_IMPORT_NS(DMA_BUF);
43494351
#endif
43504352

src/runtime_src/core/pcie/driver/linux/xocl/mgmtpf/mgmt-core.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313
#include "mgmt-core.h"
1414

15-
#include <linux/crc32c.h>
1615
#include <linux/fs.h>
1716
#include <linux/ioctl.h>
1817
#include <linux/i2c.h>
@@ -24,6 +23,12 @@
2423
#include "version.h"
2524
#include "xclbin.h"
2625
#include "../xocl_drv.h"
26+
27+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0) || defined(RHEL_9_7_GE)
28+
#include <linux/crc32.h>
29+
#else
30+
#include <linux/crc32c.h>
31+
#endif
2732
#include "../xocl_xclbin.h"
2833

2934
#define SIZE_4KB 4096
@@ -852,7 +857,11 @@ static bool xclmgmt_is_same_domain(struct xclmgmt_dev *lro,
852857
return false;
853858
}
854859

860+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0) || defined(RHEL_9_7_GE)
861+
crc_chk = crc32_le(~0, (void *)mb_conn->kaddr, PAGE_SIZE);
862+
#else
855863
crc_chk = crc32c_le(~0, (void *)mb_conn->kaddr, PAGE_SIZE);
864+
#endif
856865
if (crc_chk != mb_conn->crc32) {
857866
mgmt_info(lro, "crc32 : %x, %x\n", mb_conn->crc32, crc_chk);
858867
mgmt_info(lro, "failed to get the same CRC\n");

src/runtime_src/core/pcie/driver/linux/xocl/subdev/p2p.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,11 @@ static void p2p_read_addr_mgmtpf(struct p2p *p2p)
513513
mb_req->req = XCL_MAILBOX_REQ_READ_P2P_BAR_ADDR;
514514
mb_p2p = (struct xcl_mailbox_p2p_bar_addr *)mb_req->data;
515515

516+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 13, 0) && !defined(RHEL_9_7_GE)
516517
if (!iommu_present(&pci_bus_type)){
518+
#else
519+
if (!device_iommu_mapped(&pcidev->dev)) {
520+
#endif
517521
mb_p2p->p2p_bar_len = pci_resource_len(pcidev, p2p->p2p_bar_idx);
518522
mb_p2p->p2p_bar_addr = pci_resource_start(pcidev,
519523
p2p->p2p_bar_idx);

src/runtime_src/core/pcie/driver/linux/xocl/userpf/xocl_drm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,9 @@ static struct drm_driver mm_drm_driver = {
558558
#endif
559559
.name = XOCL_MODULE_NAME,
560560
.desc = XOCL_DRIVER_DESC,
561+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 14, 0) && !defined(RHEL_9_7_GE)
561562
.date = driver_date,
563+
#endif
562564
};
563565

564566
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0) || defined(RHEL_8_5_GE)

src/runtime_src/core/pcie/driver/linux/xocl/userpf/xocl_drv.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
#include <linux/aer.h>
10-
#include <linux/crc32c.h>
1110
#include <linux/iommu.h>
1211
#include <linux/kernel.h>
1312
#include <linux/module.h>
@@ -21,6 +20,12 @@
2120
#include "xocl_errors.h"
2221
#include "../xocl_drv.h"
2322

23+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0) || defined(RHEL_9_7_GE)
24+
#include <linux/crc32.h>
25+
#else
26+
#include <linux/crc32c.h>
27+
#endif
28+
2429

2530
#ifndef PCI_EXT_CAP_ID_REBAR
2631
#define PCI_EXT_CAP_ID_REBAR 0x15
@@ -621,7 +626,11 @@ static void xocl_mb_connect(struct xocl_dev *xdev)
621626
mb_conn->kaddr = (uint64_t)kaddr;
622627
mb_conn->paddr = (uint64_t)virt_to_phys(kaddr);
623628
get_random_bytes(kaddr, PAGE_SIZE);
629+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0) || defined(RHEL_9_7_GE)
630+
mb_conn->crc32 = crc32_le(~0, kaddr, PAGE_SIZE);
631+
#else
624632
mb_conn->crc32 = crc32c_le(~0, kaddr, PAGE_SIZE);
633+
#endif
625634
mb_conn->version = XCL_MB_PROTOCOL_VER;
626635

627636
ret = xocl_peer_request(xdev, mb_req, reqlen, resp, &resplen,
@@ -2052,6 +2061,8 @@ MODULE_VERSION(XRT_DRIVER_VERSION);
20522061
MODULE_DESCRIPTION(XOCL_DRIVER_DESC);
20532062
MODULE_AUTHOR("Lizhi Hou <lizhi.hou@xilinx.com>");
20542063
MODULE_LICENSE("GPL v2");
2055-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0) || defined(RHEL_9_0_GE)
2064+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 13, 0)
2065+
MODULE_IMPORT_NS("DMA_BUF");
2066+
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0) || defined(RHEL_9_0_GE)
20562067
MODULE_IMPORT_NS(DMA_BUF);
20572068
#endif

src/runtime_src/core/pcie/driver/linux/xocl/xocl_drv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@
169169
#endif
170170

171171
#if defined(RHEL_RELEASE_CODE)
172+
#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 7)
173+
#define RHEL_9_7_GE
174+
#endif
172175
#if RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(9, 5)
173176
#define RHEL_9_5_GE
174177
#endif

0 commit comments

Comments
 (0)