From 4bb304b03c441e579784031e8433f8869ef395e5 Mon Sep 17 00:00:00 2001 From: Tom Day Date: Mon, 29 Jul 2024 01:04:40 +0100 Subject: [PATCH 1/6] Fix DMA changes post 5.18.* --- drv/Makefile | 1 + drv/gim_irqmgr.c | 15 +++++++++++++++ drv/gim_kcl_os.c | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/drv/Makefile b/drv/Makefile index e9c91e5..6c19288 100644 --- a/drv/Makefile +++ b/drv/Makefile @@ -28,6 +28,7 @@ LINUXINCLUDE := $(LINUXINCLUDE) -I$(src)/asic_reg #ccflags-y += -DCONFIG_GIM_HEARTBEAT_TIMER #ccflags-y += -D DRV_VERSION=1.0 #ccflags-y += -DCONFIG_MMIO_QEMU_SECURITY +ccflags-y += -Wno-error=implicit-function-declaration PWD := $(shell pwd) diff --git a/drv/gim_irqmgr.c b/drv/gim_irqmgr.c index e799f74..bb691b1 100644 --- a/drv/gim_irqmgr.c +++ b/drv/gim_irqmgr.c @@ -140,20 +140,35 @@ static int alloc_iv_ring(struct adapter *adapt) ih->ivr_va = (struct iv_ring_entry *)kcl_mem_map_page_list(list, cnt); gim_info("ih->ivr_va = %p\n", ih->ivr_va); +#if(LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)) ih->ivr_ma.quad_part = pci_map_page(adapt->pf.pci_dev, (struct page *)list[0], 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); +#else + ih->ivr_ma.quad_part = dma_map_page(adapt->pf.pci_dev, + (struct page *)list[0], 0, + PAGE_SIZE, + DMA_BIDIRECTIONAL); +#endif gim_info("ih->ivr_ma.quad_part = 0x%llx\n", ih->ivr_ma.quad_part); + ih->ivr_wptr_wb = (unsigned int *)((unsigned int *)ih->ivr_va + (ih->ivr_size_in_bytes/4)); gim_info("ih->ivr_wptr_wb = %p\n", ih->ivr_wptr_wb); +#if(LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)) ih->ivr_wptr_wa.quad_part = pci_map_page(adapt->pf.pci_dev, (struct page *)list[1], 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); +#else + ih->ivr_wptr_wa.quad_part = dma_map_page(adapt->pf.pci_dev, + (struct page *)list[1], 0, + PAGE_SIZE, + DMA_BIDIRECTIONAL); +#endif gim_info("ih->ivr_wptr_wa.quad_part = 0x%llx\n", ih->ivr_wptr_wa.quad_part); diff --git a/drv/gim_kcl_os.c b/drv/gim_kcl_os.c index cdfeaf1..92b11fc 100644 --- a/drv/gim_kcl_os.c +++ b/drv/gim_kcl_os.c @@ -71,8 +71,13 @@ void *kcl_mem_map_page_list(unsigned long *pagelist, unsigned int count) unsigned long long kcl_map_page(struct pci_dev *pci_dev, unsigned long p) { +#if(LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)) return pci_map_page(pci_dev, (struct page *)p, 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); +#else + return dma_map_page(pci_dev, (struct page *)p, 0, + PAGE_SIZE, DMA_BIDIRECTIONAL); +#endif } void kcl_mem_unmap(void *addr) From 256bcfa86fba6a6f88b9b027524fb9fb6549d06a Mon Sep 17 00:00:00 2001 From: Tom Day Date: Mon, 29 Jul 2024 01:29:25 +0100 Subject: [PATCH 2/6] Fix DMA pointers --- drv/gim_irqmgr.c | 16 ++++++++-------- drv/gim_kcl_os.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drv/gim_irqmgr.c b/drv/gim_irqmgr.c index bb691b1..413212a 100644 --- a/drv/gim_irqmgr.c +++ b/drv/gim_irqmgr.c @@ -146,7 +146,7 @@ static int alloc_iv_ring(struct adapter *adapt) PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); #else - ih->ivr_ma.quad_part = dma_map_page(adapt->pf.pci_dev, + ih->ivr_ma.quad_part = dma_map_page(adapt->pf.pci_dev->dev, (struct page *)list[0], 0, PAGE_SIZE, DMA_BIDIRECTIONAL); @@ -160,14 +160,14 @@ static int alloc_iv_ring(struct adapter *adapt) #if(LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)) ih->ivr_wptr_wa.quad_part = pci_map_page(adapt->pf.pci_dev, - (struct page *)list[1], 0, - PAGE_SIZE, - PCI_DMA_BIDIRECTIONAL); + (struct page *)list[1], 0, + PAGE_SIZE, + PCI_DMA_BIDIRECTIONAL); #else - ih->ivr_wptr_wa.quad_part = dma_map_page(adapt->pf.pci_dev, - (struct page *)list[1], 0, - PAGE_SIZE, - DMA_BIDIRECTIONAL); + ih->ivr_wptr_wa.quad_part = dma_map_page(adapt->pf.pci_dev->dev, + (struct page *)list[1], 0, + PAGE_SIZE, + DMA_BIDIRECTIONAL); #endif gim_info("ih->ivr_wptr_wa.quad_part = 0x%llx\n", ih->ivr_wptr_wa.quad_part); diff --git a/drv/gim_kcl_os.c b/drv/gim_kcl_os.c index 92b11fc..e406bb4 100644 --- a/drv/gim_kcl_os.c +++ b/drv/gim_kcl_os.c @@ -75,7 +75,7 @@ unsigned long long kcl_map_page(struct pci_dev *pci_dev, unsigned long p) return pci_map_page(pci_dev, (struct page *)p, 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); #else - return dma_map_page(pci_dev, (struct page *)p, 0, + return dma_map_page(&pci_dev->dev, (struct page *)p, 0, PAGE_SIZE, DMA_BIDIRECTIONAL); #endif } From f30038f23dd5ac3d4fba8432221d2f8979a93c53 Mon Sep 17 00:00:00 2001 From: Tom Day Date: Mon, 29 Jul 2024 01:34:27 +0100 Subject: [PATCH 3/6] Fix casting --- drv/gim_irqmgr.c | 6 ++++-- drv/gim_kcl_os.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drv/gim_irqmgr.c b/drv/gim_irqmgr.c index 413212a..c42e196 100644 --- a/drv/gim_irqmgr.c +++ b/drv/gim_irqmgr.c @@ -146,7 +146,8 @@ static int alloc_iv_ring(struct adapter *adapt) PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); #else - ih->ivr_ma.quad_part = dma_map_page(adapt->pf.pci_dev->dev, + ih->ivr_ma.quad_part = dma_map_page( + (struct device *)adapt->pf.pci_dev->dev, (struct page *)list[0], 0, PAGE_SIZE, DMA_BIDIRECTIONAL); @@ -164,7 +165,8 @@ static int alloc_iv_ring(struct adapter *adapt) PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); #else - ih->ivr_wptr_wa.quad_part = dma_map_page(adapt->pf.pci_dev->dev, + ih->ivr_wptr_wa.quad_part = dma_map_page( + (struct device *)adapt->pf.pci_dev->dev, (struct page *)list[1], 0, PAGE_SIZE, DMA_BIDIRECTIONAL); diff --git a/drv/gim_kcl_os.c b/drv/gim_kcl_os.c index e406bb4..f6c37c9 100644 --- a/drv/gim_kcl_os.c +++ b/drv/gim_kcl_os.c @@ -72,11 +72,15 @@ void *kcl_mem_map_page_list(unsigned long *pagelist, unsigned int count) unsigned long long kcl_map_page(struct pci_dev *pci_dev, unsigned long p) { #if(LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)) - return pci_map_page(pci_dev, (struct page *)p, 0, - PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); + return pci_map_page(pci_dev, + (struct page *)p, 0, + PAGE_SIZE, + PCI_DMA_BIDIRECTIONAL); #else - return dma_map_page(&pci_dev->dev, (struct page *)p, 0, - PAGE_SIZE, DMA_BIDIRECTIONAL); + return dma_map_page(&pci_dev->dev, + (struct page *)p, 0, + PAGE_SIZE, + DMA_BIDIRECTIONAL); #endif } From 527b4d48beef704724efa3bf2399450779e58941 Mon Sep 17 00:00:00 2001 From: Tom Day Date: Mon, 29 Jul 2024 01:37:19 +0100 Subject: [PATCH 4/6] syntax --- drv/gim_irqmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drv/gim_irqmgr.c b/drv/gim_irqmgr.c index c42e196..b676971 100644 --- a/drv/gim_irqmgr.c +++ b/drv/gim_irqmgr.c @@ -147,7 +147,7 @@ static int alloc_iv_ring(struct adapter *adapt) PCI_DMA_BIDIRECTIONAL); #else ih->ivr_ma.quad_part = dma_map_page( - (struct device *)adapt->pf.pci_dev->dev, + &adapt->pf.pci_dev->dev, (struct page *)list[0], 0, PAGE_SIZE, DMA_BIDIRECTIONAL); @@ -166,7 +166,7 @@ static int alloc_iv_ring(struct adapter *adapt) PCI_DMA_BIDIRECTIONAL); #else ih->ivr_wptr_wa.quad_part = dma_map_page( - (struct device *)adapt->pf.pci_dev->dev, + &adapt->pf.pci_dev->dev, (struct page *)list[1], 0, PAGE_SIZE, DMA_BIDIRECTIONAL); From fd8df1c74f37af6d647b2e99c45b76ff7a8efb3d Mon Sep 17 00:00:00 2001 From: Tom Day Date: Mon, 29 Jul 2024 01:43:39 +0100 Subject: [PATCH 5/6] fix usages of create_class() for 6.4+ --- drv/gim_monitor_ioctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drv/gim_monitor_ioctl.c b/drv/gim_monitor_ioctl.c index 8fba6de..3a85cf8 100644 --- a/drv/gim_monitor_ioctl.c +++ b/drv/gim_monitor_ioctl.c @@ -289,8 +289,11 @@ int amdgim_create_cdev(void) gim_err("Error %d while adding amdgim", ret); goto fail_cdevadd; } - +#if(LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)) amdgim_class = class_create(THIS_MODULE, AMDGIM_CLASS_NAME); +#else + amdgim_class = class_create(AMDGIM_CLASS_NAME); +#endif device_create(amdgim_class, NULL, MKDEV(amdgim_pdev->major, 0), NULL, AMDGIM_DEVICE_FILE_NAME); From ca45e6bd7a2fc0fec561f23b9a9af4175edd8929 Mon Sep 17 00:00:00 2001 From: Tom Day Date: Mon, 29 Jul 2024 01:49:11 +0100 Subject: [PATCH 6/6] fix usages of pci_set_dma_mask --- drv/gim_adapter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drv/gim_adapter.c b/drv/gim_adapter.c index 601df39..5ae530d 100644 --- a/drv/gim_adapter.c +++ b/drv/gim_adapter.c @@ -694,7 +694,11 @@ uint32_t set_new_adapter(struct pci_dev *pdev) write_register(pf, mmSMU_IND_INDEX_0, 0); /* Set the dma mask to be 40 bits address range */ +#if(LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0)) pci_set_dma_mask(curr->pf.pci_dev, 0xffffffffffull); +#else + dma_set_mask(&curr->pf.pci_dev->dev, 0xffffffffffull); +#endif /* interrupt */ size = sizeof(struct interrupt_handler);