From e997e8ae5abcccebad28f6f8cb8c7903f95e76e8 Mon Sep 17 00:00:00 2001 From: Manish Bhardwaj Date: Sat, 18 Nov 2023 15:37:37 +0000 Subject: [PATCH] hv: port tegra hypervisor driver on noble kernel Bug 4377196 Change-Id: Idecaac1915c444fe04c40f0e848e36bd3f90b78f Signed-off-by: Manish Bhardwaj Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3018492 (cherry picked from commit 912dda68d12bf58f8ab4431bcf29c819265bc3bd) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3059277 Tested-by: Jonathan Hunter Reviewed-by: Jonathan Hunter Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- drivers/virt/tegra/tegra_hv.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/virt/tegra/tegra_hv.c b/drivers/virt/tegra/tegra_hv.c index 8210c371..134f5e78 100644 --- a/drivers/virt/tegra/tegra_hv.c +++ b/drivers/virt/tegra/tegra_hv.c @@ -216,7 +216,11 @@ static int tegra_hv_add_ivc(struct tegra_hv_data *hvd, struct hv_ivc *ivc; int ret; int rx_first; +#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP) + struct iosys_map rx_map, tx_map; +#else uintptr_t rx_base, tx_base; +#endif uint32_t i; struct irq_data *d; uint64_t va_offset; @@ -264,6 +268,17 @@ static int tegra_hv_add_ivc(struct tegra_hv_data *hvd, BUG_ON(qd->offset >= ivc->givci->length); BUG_ON(qd->offset + qd->size * 2 > ivc->givci->length); +#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP) + rx_map.is_iomem = false; + tx_map.is_iomem = false; + if (rx_first) { + rx_map.vaddr = (void *)ivc->givci->shmem + qd->offset; + tx_map.vaddr = (void *)ivc->givci->shmem + qd->offset + qd->size; + } else { + tx_map.vaddr = (void *)ivc->givci->shmem + qd->offset; + rx_map.vaddr = (void *)ivc->givci->shmem + qd->offset + qd->size; + } +#else if (rx_first) { rx_base = ivc->givci->shmem + qd->offset; tx_base = ivc->givci->shmem + qd->offset + qd->size; @@ -271,6 +286,7 @@ static int tegra_hv_add_ivc(struct tegra_hv_data *hvd, tx_base = ivc->givci->shmem + qd->offset; rx_base = ivc->givci->shmem + qd->offset + qd->size; } +#endif ret = snprintf(ivc->name, sizeof(ivc->name), "ivc%u", qd->id); if (ret < 0) { @@ -316,10 +332,17 @@ static int tegra_hv_add_ivc(struct tegra_hv_data *hvd, return -EINVAL; } +#if defined(NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP) + INFO("adding ivc%u: rx_base=%lx tx_base = %lx size=%x irq = %d (%lu)\n", + qd->id, (uintptr_t)rx_map.vaddr, (uintptr_t)tx_map.vaddr, qd->size, ivc->irq, d->hwirq); + ret = tegra_ivc_init(&ivc->ivc, NULL, &rx_map, 0, &tx_map, 0, qd->nframes, + qd->frame_size, ivc_raise_irq, ivc); +#else INFO("adding ivc%u: rx_base=%lx tx_base = %lx size=%x irq = %d (%lu)\n", qd->id, rx_base, tx_base, qd->size, ivc->irq, d->hwirq); ret = tegra_ivc_init(&ivc->ivc, NULL, (void *)rx_base, 0, (void *)tx_base, 0, qd->nframes, qd->frame_size, ivc_raise_irq, ivc); +#endif if (ret != 0) { ERR("failed to init ivc queue #%u\n", qd->id); return ret;