From a5f3fe9506dcf87910eba24c80a4b30c03dcced1 Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Tue, 20 Feb 2018 20:39:22 -0800 Subject: gpu: nvgpu: gv100: enable syncpt shim for nvlink Get host1x node reference from c1_rp device tree node, and enable syncpoints shim in case of nvlink. JIRA EVLR-2441 JIRA EVLR-2585 Change-Id: Idbf1edf656557f2ed2d3bd27393c2f4d5d1ad75a Signed-off-by: Thomas Fleury Reviewed-on: https://git-master.nvidia.com/r/1663360 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/nvhost.c | 33 +++++++++++++++++++++ drivers/gpu/nvgpu/common/linux/pci.c | 14 +++++++++ .../gpu/nvgpu/common/linux/platform_gv11b_tegra.c | 34 ++++------------------ 3 files changed, 52 insertions(+), 29 deletions(-) (limited to 'drivers/gpu/nvgpu/common') diff --git a/drivers/gpu/nvgpu/common/linux/nvhost.c b/drivers/gpu/nvgpu/common/linux/nvhost.c index fa169cf0..6ab60248 100644 --- a/drivers/gpu/nvgpu/common/linux/nvhost.c +++ b/drivers/gpu/nvgpu/common/linux/nvhost.c @@ -258,4 +258,37 @@ u32 nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id) { return nvhost_syncpt_unit_interface_get_byte_offset(syncpt_id); } + +int nvgpu_nvhost_syncpt_init(struct gk20a *g) +{ + int err = 0; + + if (!g->has_syncpoints) + return -ENOSYS; + + err = nvgpu_get_nvhost_dev(g); + if (err) { + nvgpu_err(g, "host1x device not available"); + g->has_syncpoints = false; + return -ENOSYS; + } + + err = nvgpu_nvhost_syncpt_unit_interface_get_aperture( + g->nvhost_dev, + &g->syncpt_unit_base, + &g->syncpt_unit_size); + if (err) { + nvgpu_err(g, "Failed to get syncpt interface"); + g->has_syncpoints = false; + return -ENOSYS; + } + + g->syncpt_size = + nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(1); + nvgpu_info(g, "syncpt_unit_base %llx syncpt_unit_size %zx size %x\n", + g->syncpt_unit_base, g->syncpt_unit_size, + g->syncpt_size); + + return 0; +} #endif diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c index bb44efbc..3c7de4ff 100644 --- a/drivers/gpu/nvgpu/common/linux/pci.c +++ b/drivers/gpu/nvgpu/common/linux/pci.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -316,6 +317,7 @@ static struct gk20a_platform nvgpu_pci_device[] = { .vbios_min_version = 0x88000126, .hardcode_sw_threshold = false, .run_preos = true, + .has_syncpoints = true, }, { /* SKU250 */ /* ptimer src frequency in hz */ @@ -350,6 +352,7 @@ static struct gk20a_platform nvgpu_pci_device[] = { .vbios_min_version = 0x1, .hardcode_sw_threshold = false, .run_preos = true, + .has_syncpoints = true, }, { /* SKU 0x1e3f */ /* ptimer src frequency in hz */ @@ -700,6 +703,17 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, nvgpu_err(g, "fatal error probing nvlink, bailing out"); goto err_free_irq; } + /* Enable Semaphore SHIM on nvlink only for now. */ + __nvgpu_set_enabled(g, NVGPU_SUPPORT_NVLINK, false); + g->has_syncpoints = false; + } else { + err = nvgpu_nvhost_syncpt_init(g); + if (err) { + if (err != -ENOSYS) { + nvgpu_err(g, "syncpt init failed"); + goto err_free_irq; + } + } } g->mm.has_physical_mode = false; diff --git a/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c index 0e8e173f..f8ff57b9 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c +++ b/drivers/gpu/nvgpu/common/linux/platform_gv11b_tegra.c @@ -49,37 +49,13 @@ static void gr_gv11b_remove_sysfs(struct device *dev); static int gv11b_tegra_probe(struct device *dev) { struct gk20a_platform *platform = dev_get_drvdata(dev); -#ifdef CONFIG_TEGRA_GK20A_NVHOST - struct gk20a *g = platform->g; - int err = 0; - - if (g->has_syncpoints) { - err = nvgpu_get_nvhost_dev(g); - if (err) { - dev_err(dev, "host1x device not available"); - return err; - } - } + int err; - if (g->has_syncpoints) { - err = nvgpu_nvhost_syncpt_unit_interface_get_aperture( - g->nvhost_dev, - &g->syncpt_unit_base, - &g->syncpt_unit_size); - if (err) { - dev_err(dev, "Failed to get syncpt interface"); - return -ENOSYS; - } - g->syncpt_size = - nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(1); - nvgpu_info(g, "syncpt_unit_base %llx " - "syncpt_unit_size %zx size %x\n", - g->syncpt_unit_base, g->syncpt_unit_size, - g->syncpt_size); + err = nvgpu_nvhost_syncpt_init(platform->g); + if (err) { + if (err != -ENOSYS) + return err; } -#else - g->has_syncpoints = false; -#endif err = gk20a_tegra_init_secure_alloc(platform); if (err) -- cgit v1.2.2