From 7f006193a393e90018b82d6065c101358a90f089 Mon Sep 17 00:00:00 2001 From: Arvind M Date: Wed, 18 Dec 2024 06:18:12 -0800 Subject: [PATCH] nvdla: kmd: add support for ACPI Bug 4988970 Jira DLA-7673 Change-Id: I8d611932cf7b7af107f135e9ae44caad9032a6c0 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3272418 Signed-off-by: Amit Sharma (cherry picked from commit e01c86ebdf123d6e9a40986c16f7f3ccbb989cc1) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3270720 Reviewed-by: Ayush Kumar Reviewed-by: Arvind M Reviewed-by: Vishal Thoke GVS: buildbot_gerritrpt Reviewed-by: Mitch Harwell Reviewed-by: svcacv --- drivers/video/tegra/host/nvdla/axi/Makefile | 1 + drivers/video/tegra/host/nvdla/nvdla.c | 48 +++++++++++++++++-- drivers/video/tegra/host/nvdla/nvdla_t194.h | 6 ++- drivers/video/tegra/host/nvdla/nvdla_t234.h | 6 ++- drivers/video/tegra/host/nvdla/nvdla_t25x.h | 8 ++-- .../video/tegra/host/nvdla/nvdla_t264_sim.h | 7 +-- .../host/nvdla/port/device/nvdla_device_axi.c | 19 +++++--- 7 files changed, 74 insertions(+), 21 deletions(-) diff --git a/drivers/video/tegra/host/nvdla/axi/Makefile b/drivers/video/tegra/host/nvdla/axi/Makefile index 7888778a..3284a84a 100644 --- a/drivers/video/tegra/host/nvdla/axi/Makefile +++ b/drivers/video/tegra/host/nvdla/axi/Makefile @@ -29,6 +29,7 @@ ccflags-y += -DNVDLA_HAVE_CONFIG_HSIERRINJ=0 ccflags-y += -DBUG_4942853=1 ccflags-y += -DBUG_4960393=1 ccflags-y += -DBUG_4972382=1 +ccflags-y += -DBUG_5054810=1 NVDLA_OBJS := \ $(NVDLA_COMMON_OBJS) \ diff --git a/drivers/video/tegra/host/nvdla/nvdla.c b/drivers/video/tegra/host/nvdla/nvdla.c index 2dea5a11..0acba50b 100644 --- a/drivers/video/tegra/host/nvdla/nvdla.c +++ b/drivers/video/tegra/host/nvdla/nvdla.c @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -928,6 +929,20 @@ static struct of_device_id tegra_nvdla_of_match[] = { .data = (struct nvhost_device_data *)&t264_sim_nvdla0_info }, { }, }; + +static struct acpi_device_id tegra_nvdla_acpi_match[] = { + { + .id = "NVDA200A", + .driver_data = 0x0, + }, + { }, +}; + +static void *acpi_data[] = { + /*0x0*/ &t25x_nvdla0_info, + NULL, +}; + #else static struct of_device_id tegra_nvdla_of_match[] = { { @@ -948,8 +963,18 @@ static struct of_device_id tegra_nvdla_of_match[] = { .data = (struct nvhost_device_data *)&t23x_nvdla1_info }, { }, }; + +static struct acpi_device_id tegra_nvdla_acpi_match[] = { + { }, +}; + +static void *acpi_data[] = { + NULL, +}; + #endif /* NVDLA_HAVE_CONFIG_AXI */ MODULE_DEVICE_TABLE(of, tegra_nvdla_of_match); +MODULE_DEVICE_TABLE(acpi, tegra_nvdla_acpi_match); static uint32_t num_enabled_dla_instances(uint32_t soft_fuse_ret, int hw_reg_fuse_ret) @@ -999,6 +1024,13 @@ static int nvdla_probe(struct platform_device *pdev) match = of_match_device(tegra_nvdla_of_match, dev); if (match) pdata = (struct nvhost_device_data *)match->data; + } else if (ACPI_HANDLE(&pdev->dev)) { + const struct acpi_device_id *match; + + match = acpi_match_device(tegra_nvdla_acpi_match, dev); + if (match) + pdata = (struct nvhost_device_data *) + acpi_data[match->driver_data]; } else { pdata = (struct nvhost_device_data *)pdev->dev.platform_data; } @@ -1074,10 +1106,12 @@ static int nvdla_probe(struct platform_device *pdev) goto err_alloc_nvdla; } - nvdla_dev->icc_write = devm_of_icc_get(dev, "write"); - if (IS_ERR(nvdla_dev->icc_write)) - return dev_err_probe(&pdev->dev, PTR_ERR(nvdla_dev->icc_write), + if (pdev->dev.of_node) { + nvdla_dev->icc_write = devm_of_icc_get(dev, "write"); + if (IS_ERR(nvdla_dev->icc_write)) + return dev_err_probe(&pdev->dev, PTR_ERR(nvdla_dev->icc_write), "failed to get icc write handle\n"); + } nvdla_dev->dev = dev; nvdla_dev->pdev = pdev; @@ -1098,7 +1132,10 @@ static int nvdla_probe(struct platform_device *pdev) if (pdata->version == FIRMWARE_ENCODE_VERSION(T23X)) { if (num_enabled_dla_instances(soft_fuse_ret, fuse_register_ret) == 1) { - pdev->dev.of_node->name = "nvdla0"; + if (pdev->dev.of_node) + pdev->dev.of_node->name = "nvdla0"; + else + pdata->devfs_name = "nvdla0"; } } @@ -1349,6 +1386,9 @@ static struct platform_driver nvdla_driver = { #ifdef CONFIG_OF .of_match_table = tegra_nvdla_of_match, #endif +#ifdef CONFIG_ACPI + .acpi_match_table = ACPI_PTR(tegra_nvdla_acpi_match), +#endif #ifdef CONFIG_PM .pm = &nvdla_module_pm_ops, #endif diff --git a/drivers/video/tegra/host/nvdla/nvdla_t194.h b/drivers/video/tegra/host/nvdla/nvdla_t194.h index 99d2460b..aa04b799 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_t194.h +++ b/drivers/video/tegra/host/nvdla/nvdla_t194.h @@ -15,6 +15,7 @@ #include "dla_t19x_fw_version.h" static struct nvhost_device_data t19_nvdla0_info = { + .devfs_name = "nvdla0", .devfs_name_family = "nvdla", .class = NV_DLA0_CLASS_ID, .clocks = { @@ -29,7 +30,7 @@ static struct nvhost_device_data t19_nvdla0_info = { .resource_policy = RESOURCE_PER_CHANNEL_INSTANCE, .finalize_poweron = nvdla_finalize_poweron, .prepare_poweroff = nvdla_prepare_poweroff, - .flcn_isr = nvdla_flcn_isr, + .flcn_isr = nvdla_flcn_isr, .self_config_flcn_isr = true, .vm_regs = {{0x30, true}, {0x34, false} }, .firmware_name = NV_DLA_TEGRA194_FW, @@ -55,6 +56,7 @@ static struct nvhost_device_data t19_nvdla0_info = { }; static struct nvhost_device_data t19_nvdla1_info = { + .devfs_name = "nvdla1", .devfs_name_family = "nvdla", .class = NV_DLA1_CLASS_ID, .clocks = { @@ -67,7 +69,7 @@ static struct nvhost_device_data t19_nvdla1_info = { .resource_policy = RESOURCE_PER_CHANNEL_INSTANCE, .finalize_poweron = nvdla_finalize_poweron, .prepare_poweroff = nvdla_prepare_poweroff, - .flcn_isr = nvdla_flcn_isr, + .flcn_isr = nvdla_flcn_isr, .self_config_flcn_isr = true, .vm_regs = {{0x30, true}, {0x34, false} }, .firmware_name = NV_DLA_TEGRA194_FW, diff --git a/drivers/video/tegra/host/nvdla/nvdla_t234.h b/drivers/video/tegra/host/nvdla/nvdla_t234.h index 9f610402..ec6b9ff8 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_t234.h +++ b/drivers/video/tegra/host/nvdla/nvdla_t234.h @@ -15,6 +15,7 @@ #include "dla_t23x_fw_version.h" static struct nvhost_device_data t23x_nvdla0_info = { + .devfs_name = "nvdla0", .devfs_name_family = "nvdla", .class = NV_DLA0_CLASS_ID, .clocks = { @@ -24,7 +25,7 @@ static struct nvhost_device_data t23x_nvdla0_info = { .resource_policy = RESOURCE_PER_CHANNEL_INSTANCE, .finalize_poweron = nvdla_finalize_poweron, .prepare_poweroff = nvdla_prepare_poweroff, - .flcn_isr = nvdla_flcn_isr, + .flcn_isr = nvdla_flcn_isr, .self_config_flcn_isr = true, .vm_regs = {{0x30, true}, {0x34, false} }, .firmware_name = NV_DLA_TEGRA234_FW, @@ -50,6 +51,7 @@ static struct nvhost_device_data t23x_nvdla0_info = { }; static struct nvhost_device_data t23x_nvdla1_info = { + .devfs_name = "nvdla1", .devfs_name_family = "nvdla", .class = NV_DLA1_CLASS_ID, .clocks = { @@ -59,7 +61,7 @@ static struct nvhost_device_data t23x_nvdla1_info = { .resource_policy = RESOURCE_PER_CHANNEL_INSTANCE, .finalize_poweron = nvdla_finalize_poweron, .prepare_poweroff = nvdla_prepare_poweroff, - .flcn_isr = nvdla_flcn_isr, + .flcn_isr = nvdla_flcn_isr, .self_config_flcn_isr = true, .vm_regs = {{0x30, true}, {0x34, false} }, .firmware_name = NV_DLA_TEGRA234_FW, diff --git a/drivers/video/tegra/host/nvdla/nvdla_t25x.h b/drivers/video/tegra/host/nvdla/nvdla_t25x.h index afef727c..dfa01ee2 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_t25x.h +++ b/drivers/video/tegra/host/nvdla/nvdla_t25x.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +/* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * * Device data for T25X simulator */ @@ -14,6 +14,7 @@ #include "dla_t25x_fw_version.h" static struct nvhost_device_data t25x_nvdla0_info = { + .devfs_name = "nvdla0", .devfs_name_family = "nvdla", #if defined(BUG_4972382) && (BUG_4972382 == 1) .class = NV_DLA0_SIM_CLASS_ID, @@ -27,7 +28,7 @@ static struct nvhost_device_data t25x_nvdla0_info = { .resource_policy = RESOURCE_PER_CHANNEL_INSTANCE, .finalize_poweron = nvdla_finalize_poweron, .prepare_poweroff = nvdla_prepare_poweroff, - .flcn_isr = nvdla_flcn_isr, + .flcn_isr = nvdla_flcn_isr, .self_config_flcn_isr = true, .vm_regs = {{0x30, true}, {0x34, false} }, .firmware_name = NV_DLA_TEGRA25X_FW, @@ -48,6 +49,7 @@ static struct nvhost_device_data t25x_nvdla0_info = { }; static struct nvhost_device_data t25x_nvdla1_info = { + .devfs_name = "nvdla1", .devfs_name_family = "nvdla", #if defined(BUG_4972382) && (BUG_4972382 == 1) .class = NV_DLA1_SIM_CLASS_ID, @@ -61,7 +63,7 @@ static struct nvhost_device_data t25x_nvdla1_info = { .resource_policy = RESOURCE_PER_CHANNEL_INSTANCE, .finalize_poweron = nvdla_finalize_poweron, .prepare_poweroff = nvdla_prepare_poweroff, - .flcn_isr = nvdla_flcn_isr, + .flcn_isr = nvdla_flcn_isr, .self_config_flcn_isr = true, .vm_regs = {{0x30, true}, {0x34, false} }, .firmware_name = NV_DLA_TEGRA25X_FW, diff --git a/drivers/video/tegra/host/nvdla/nvdla_t264_sim.h b/drivers/video/tegra/host/nvdla/nvdla_t264_sim.h index d55a1d96..a68b9b46 100644 --- a/drivers/video/tegra/host/nvdla/nvdla_t264_sim.h +++ b/drivers/video/tegra/host/nvdla/nvdla_t264_sim.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +/* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * - * Device data for T264 simulator + * Device data for t264 simulator */ #ifndef __NVHOST_NVDLA_T264_SIM_H__ @@ -14,6 +14,7 @@ #include "dla_t25x_fw_version.h" static struct nvhost_device_data t264_sim_nvdla0_info = { + .devfs_name = "nvdla0", .devfs_name_family = "nvdla", .class = NV_DLA0_SIM_CLASS_ID, .clocks = { @@ -23,7 +24,7 @@ static struct nvhost_device_data t264_sim_nvdla0_info = { .resource_policy = RESOURCE_PER_CHANNEL_INSTANCE, .finalize_poweron = nvdla_finalize_poweron, .prepare_poweroff = nvdla_prepare_poweroff, - .flcn_isr = nvdla_flcn_isr, + .flcn_isr = nvdla_flcn_isr, .self_config_flcn_isr = true, .vm_regs = {{0x30, true}, {0x34, false} }, .firmware_name = NV_DLA_TEGRA25X_FW, diff --git a/drivers/video/tegra/host/nvdla/port/device/nvdla_device_axi.c b/drivers/video/tegra/host/nvdla/port/device/nvdla_device_axi.c index 7cfc936c..3ed9843b 100644 --- a/drivers/video/tegra/host/nvdla/port/device/nvdla_device_axi.c +++ b/drivers/video/tegra/host/nvdla/port/device/nvdla_device_axi.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +/* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * * NVDLA device implementation as AXI client. */ @@ -70,7 +70,12 @@ static int32_t s_nvdla_module_get_platform_resources( regs = devm_ioremap_resource(&pdev->dev, r); if (IS_ERR(regs)) { err = PTR_ERR(regs); +#if defined(BUG_5054810) && (BUG_5054810 == 1) + nvdla_dbg_err(pdev, "Failed to map the resources. Continuing as WAR.\n"); + continue; +#else goto fail; +#endif } pdata->aperture[i] = regs; @@ -181,16 +186,16 @@ static int32_t s_nvdla_module_device_create(struct platform_device *pdev) struct class *dla_class; dev_t devno; - err = alloc_chrdev_region(&devno, 0, NVDLA_NUM_CDEV, "nvhost"); + err = alloc_chrdev_region(&devno, 0, NVDLA_NUM_CDEV, "nvdla"); if (err < 0) { nvdla_dbg_err(pdev, "failed to reserve chrdev region\n"); goto fail; } #if defined(NV_CLASS_CREATE_HAS_NO_OWNER_ARG) /* Linux v6.4 */ - dla_class = class_create(pdev->dev.of_node->name); + dla_class = class_create(pdata->devfs_name); #else - dla_class = class_create(THIS_MODULE, pdev->dev.of_node->name); + dla_class = class_create(THIS_MODULE, pdata->devfs_name); #endif if (IS_ERR(dla_class)) { nvdla_dbg_err(pdev, "failed to create class\n"); @@ -212,10 +217,10 @@ static int32_t s_nvdla_module_device_create(struct platform_device *pdev) devno, NULL, "nvhost-ctrl-%s", - pdev->dev.of_node->name); + pdata->devfs_name); if (IS_ERR(dev)) { nvdla_dbg_err(pdev, "failed to create nvhost-ctrl-%s device\n", - pdev->dev.of_node->name); + pdata->devfs_name); err = PTR_ERR(dev); goto delete_cdev; } @@ -272,7 +277,7 @@ int32_t nvdla_module_init(struct platform_device *pdev) goto disable_pm; } - pdata->debugfs = debugfs_create_dir(pdev->dev.of_node->name, NULL); + pdata->debugfs = debugfs_create_dir(pdata->devfs_name, NULL); return 0;