From 13027c8c906700941ab660f7fb5ff6270d33ae78 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 2 Jul 2024 11:50:13 +0000 Subject: [PATCH] pci: Port pci-epf-tegra-vnet to support 5.14.0 Most of the code in the file pci-epf-tegra-vnet.c is written to support the linux kernel version 5.14.x (x != 0), all minor version above 0. Make the condition of linux version check such that 5.14.0 is also part of 5.14.x i.e. (5.14). Jira HOSTX-5375 Change-Id: Ib3d7ca619497761b8bc77796c9fe0f59c2ab9cf8 Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3166767 GVS: buildbot_gerritrpt --- .../endpoint/functions/pci-epf-tegra-vnet.c | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c b/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c index 02e3917c..6d0f2f7a 100644 --- a/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c +++ b/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c @@ -15,7 +15,7 @@ #include #include -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) #include #include #include @@ -50,7 +50,7 @@ struct bar0_amap { dma_addr_t phy; }; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) /* syncpoint handling. */ struct syncpt_t { u32 id; @@ -86,7 +86,7 @@ struct syncpt_t { #endif struct irqsp_data { -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) /* Notification. */ struct syncpt_t syncpt; #else @@ -138,7 +138,7 @@ struct pci_epf_tvnet { struct tvnet_counter h2ep_full; struct tvnet_counter ep2h_empty; struct tvnet_counter ep2h_full; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) /* DRV_MODE specific.*/ struct pci_epc *epc; struct platform_device *host1x_pdev; @@ -957,7 +957,7 @@ static void tvnet_ep_setup_dma(struct pci_epf_tvnet *tvnet) } #endif -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) /* Returns aperture offset of syncpoint on SHIM_BASE. */ static inline u64 get_syncpt_shim_offset(u32 id) { @@ -1039,7 +1039,7 @@ fence_do_work(struct syncpt_t *syncpt) static void tvnet_ep_ctrl_irqsp_work(struct work_struct *work) { -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) struct syncpt_t *syncpt = container_of(work, struct syncpt_t, work); @@ -1071,14 +1071,14 @@ static void tvnet_ep_ctrl_irqsp_callback(void *private_data) if (!tvnet_ivc_full(&tvnet->h2ep_empty) && (tvnet->os_link_state == OS_LINK_STATE_UP)) tvnet_ep_alloc_empty_buffers(tvnet); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) schedule_work(&data_irqsp->reprime_work); #endif } static void tvnet_ep_data_irqsp_work(struct work_struct *work) { -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) struct syncpt_t *syncpt = container_of(work, struct syncpt_t, work); @@ -1098,7 +1098,7 @@ static void tvnet_ep_data_irqsp_callback(void *private_data) if (tvnet_ivc_rd_available(&tvnet->h2ep_full)) napi_schedule(&tvnet->napi); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) else schedule_work(&data_irqsp->reprime_work); #endif @@ -1108,7 +1108,7 @@ static int tvnet_ep_poll(struct napi_struct *napi, int budget) { struct pci_epf_tvnet *tvnet = container_of(napi, struct pci_epf_tvnet, napi); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) struct irqsp_data *data_irqsp = tvnet->data_irqsp; #endif int work_done; @@ -1116,7 +1116,7 @@ static int tvnet_ep_poll(struct napi_struct *napi, int budget) work_done = tvnet_ep_process_h2ep_msg(tvnet); if (work_done < budget) { napi_complete(napi); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) schedule_work(&data_irqsp->reprime_work); #endif } @@ -1136,7 +1136,7 @@ static int tvnet_ep_pci_epf_setup_irqsp(struct pci_epf_tvnet *tvnet) struct irq_md *irq; phys_addr_t syncpt_addr; int ret; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) struct host1x *host1x = NULL; struct syncpt_t *syncpt = NULL; @@ -1152,7 +1152,7 @@ static int tvnet_ep_pci_epf_setup_irqsp(struct pci_epf_tvnet *tvnet) goto fail; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) syncpt = &ctrl_irqsp->syncpt; syncpt->sp = host1x_syncpt_alloc(host1x, HOST1X_SYNCPT_CLIENT_MANAGED, "pcie-ep-vnet-ctrl"); @@ -1202,7 +1202,7 @@ static int tvnet_ep_pci_epf_setup_irqsp(struct pci_epf_tvnet *tvnet) goto free_ctrl_sp; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) syncpt = &data_irqsp->syncpt; syncpt->sp = host1x_syncpt_alloc(host1x, HOST1X_SYNCPT_CLIENT_MANAGED, "pcie-ep-vnet-data"); @@ -1268,7 +1268,7 @@ static int tvnet_ep_pci_epf_setup_irqsp(struct pci_epf_tvnet *tvnet) irq->irq_addr = PAGE_SIZE; irq->irq_type = IRQ_SIMPLE; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) syncpt_addr = get_syncpt_shim_offset(data_irqsp->syncpt.id); data_irqsp->syncpt.phy_addr = syncpt_addr; data_irqsp->syncpt.size = PAGE_SIZE; @@ -1296,7 +1296,7 @@ static int tvnet_ep_pci_epf_setup_irqsp(struct pci_epf_tvnet *tvnet) free_ctrl_ivoa: iommu_unmap(domain, amap->iova, PAGE_SIZE); free_data_sp: -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) host1x_syncpt_put(data_irqsp->syncpt.sp); free_ctrl_sp: host1x_syncpt_put(ctrl_irqsp->syncpt.sp); @@ -1319,7 +1319,7 @@ static void tvnet_ep_pci_epf_destroy_irqsp(struct pci_epf_tvnet *tvnet) iommu_unmap(domain, tvnet->bar0_amap[SIMPLE_IRQ].iova + PAGE_SIZE, PAGE_SIZE); iommu_unmap(domain, tvnet->bar0_amap[SIMPLE_IRQ].iova, PAGE_SIZE); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) host1x_syncpt_put(tvnet->data_irqsp->syncpt.sp); host1x_syncpt_put(tvnet->ctrl_irqsp->syncpt.sp); #else @@ -1470,7 +1470,7 @@ static void tvnet_ep_free_multi_page_bar0_mem(struct pci_epf *epf, vfree(amap->virt); } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) static int tvnet_get_host1x_dev(struct pci_epf *epf) { struct pci_epc *epc = epf->epc; @@ -1510,7 +1510,7 @@ static int tvnet_ep_pci_epf_core_init(struct pci_epf *epf) struct pci_epf_bar *epf_bar = &epf->bar[BAR_0]; int ret; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) if (atomic_read(&tvnet->core_initialized)) { pr_err("Received CORE_INIT callback again\n"); return -EINVAL; @@ -1542,7 +1542,7 @@ static int tvnet_ep_pci_epf_core_init(struct pci_epf *epf) return ret; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) atomic_set(&tvnet->core_initialized, 1); #endif @@ -1551,7 +1551,7 @@ static int tvnet_ep_pci_epf_core_init(struct pci_epf *epf) #endif #if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 15, 0) && \ - LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) + LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) static int tvnet_ep_pci_epf_notifier(struct notifier_block *nb, unsigned long val, void *data) { @@ -1590,7 +1590,7 @@ static int tvnet_ep_pci_epf_notifier(struct notifier_block *nb, return NOTIFY_OK; } #else -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) static int tvnet_ep_pci_epf_linkup(struct pci_epf *epf) #else static void tvnet_ep_pci_epf_linkup(struct pci_epf *epf) @@ -1610,13 +1610,13 @@ static void tvnet_ep_pci_epf_linkup(struct pci_epf *epf) tvnet_ivc_get_rd_cnt(&tvnet->ep2h_full)); tvnet->pcie_link_status = true; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) return 0; #endif } #endif -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) #if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) static int tvnet_ep_pci_epf_core_deinit(struct pci_epf *epf) { @@ -1682,7 +1682,7 @@ static int tvnet_ep_pci_epf_bind(struct pci_epf *epf) struct bar0_amap *amap; struct tvnet_dma_desc *dma_desc; int ret, size, bitmap_size; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) unsigned long shift; #endif if (!domain) { @@ -1714,7 +1714,7 @@ static int tvnet_ep_pci_epf_bind(struct pci_epf *epf) goto fail; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) tvnet->iovad = (struct iova_domain *)&domain->iova_cookie->iovad; shift = iova_shift(tvnet->iovad); @@ -1984,7 +1984,7 @@ static int tvnet_ep_pci_epf_bind(struct pci_epf *epf) 0xffffffff); dma_desc[DMA_DESC_COUNT].ctrl_reg.ctrl_e.llp = 1; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) nvhost_interrupt_syncpt_prime(tvnet->ctrl_irqsp->is); nvhost_interrupt_syncpt_prime(tvnet->data_irqsp->is); @@ -2019,7 +2019,7 @@ free_irqsp: free_bar0_md: tvnet_ep_free_single_page_bar0_mem(epf, META_DATA); free_iova: -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) __free_iova(tvnet->iovad, tvnet->iova); #else iommu_dma_free_iova(cdev, tvnet->bar0_iova, BAR0_SIZE); @@ -2028,7 +2028,7 @@ fail: return ret; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) static void free_fence_resource(struct syncpt_t *syncpt) { int ret = 0; @@ -2061,7 +2061,7 @@ static void tvnet_ep_pci_epf_unbind(struct pci_epf *epf) #endif struct pci_epc *epc = epf->epc; struct device *cdev = epc->dev.parent; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) struct syncpt_t *syncpt = NULL; syncpt = &tvnet->ctrl_irqsp->syncpt; @@ -2091,7 +2091,7 @@ static void tvnet_ep_pci_epf_unbind(struct pci_epf *epf) tvnet_ep_free_multi_page_bar0_mem(epf, EP_MEM); tvnet_ep_pci_epf_destroy_irqsp(tvnet); tvnet_ep_free_single_page_bar0_mem(epf, META_DATA); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) __free_iova(tvnet->iovad, tvnet->iova); tvnet->bar0_iova = 0x0; #else @@ -2099,7 +2099,7 @@ static void tvnet_ep_pci_epf_unbind(struct pci_epf *epf) #endif } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) static const struct pci_epf_device_id tvnet_ep_epf_tvnet_ids[] = { { .name = "pci_epf_tvnet", }, { }, @@ -2123,7 +2123,7 @@ static int tvnet_ep_epf_tvnet_probe(struct pci_epf *epf) tvnet->fdev = fdev; tvnet->epf = epf; -#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) epf->event_ops = &tvnet_event_ops; #endif tvnet->header.vendorid = PCI_VENDOR_ID_NVIDIA;