Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DMA changes post 5.18.* #1

Open
wants to merge 6 commits into
base: kernel5.11
Choose a base branch
from
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
1 change: 1 addition & 0 deletions drv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions drv/gim_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 20 additions & 3 deletions drv/gim_irqmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,37 @@ 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->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);
(struct page *)list[1], 0,
PAGE_SIZE,
PCI_DMA_BIDIRECTIONAL);
#else
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);

Expand Down
13 changes: 11 additions & 2 deletions drv/gim_kcl_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,17 @@ 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)
{
return pci_map_page(pci_dev, (struct page *)p, 0,
PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
#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->dev,
(struct page *)p, 0,
PAGE_SIZE,
DMA_BIDIRECTIONAL);
#endif
}

void kcl_mem_unmap(void *addr)
Expand Down
5 changes: 4 additions & 1 deletion drv/gim_monitor_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down