From 15115e7db99d86c6e7f2f1db7afce3a099f24141 Mon Sep 17 00:00:00 2001 From: Tejal Kudav Date: Fri, 25 Jan 2019 09:41:37 +0530 Subject: [PATCH] gpu: nvgpu: Add nvlink.c to POSIX build 1. The nvlink code in common/ is clean from any external API usage. There should not be any compilation issues with POSIX build if we include nvlink.c to it. 2. Rename the nvlink file in POSIX build to avoid the tmake duplicate filename issue. 3. Set CONFIG_TEGRA_NVLINK for POSIX to enable reporting of MISRA violations in nvlink code by the MISRA scanner. 4. To fix the build issues: a. Add stubs in POSIX b. Return the 'err' variable set during dev_shutdown() as 'err' is set but not used. JIRA NVGPU-1921 JIRA NVGPU-1319 Change-Id: Ifdd6574d772167856782bafa74994507b3cedf4c Signed-off-by: Tejal Kudav Reviewed-on: https://git-master.nvidia.com/r/2005622 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/Makefile.sources | 6 +- drivers/gpu/nvgpu/Makefile.tmk | 4 +- drivers/gpu/nvgpu/common/nvlink/nvlink.c | 2 +- .../os/posix/{nvlink.c => posix-nvlink.c} | 62 ++++++++++++++++++- userspace/Makefile.configs | 4 +- userspace/Makefile.tmk | 4 +- userspace/units/Makefile.units.common.tmk | 4 +- 7 files changed, 75 insertions(+), 11 deletions(-) rename drivers/gpu/nvgpu/os/posix/{nvlink.c => posix-nvlink.c} (58%) diff --git a/drivers/gpu/nvgpu/Makefile.sources b/drivers/gpu/nvgpu/Makefile.sources index ba1994016..a9620bd72 100644 --- a/drivers/gpu/nvgpu/Makefile.sources +++ b/drivers/gpu/nvgpu/Makefile.sources @@ -43,7 +43,7 @@ srcs += os/posix/nvgpu.c \ os/posix/posix-clk_arb.c \ os/posix/posix-channel.c \ os/posix/posix-tsg.c \ - os/posix/nvlink.c \ + os/posix/posix-nvlink.c \ os/posix/lock.c \ os/posix/stubs.c \ os/posix/posix-fault-injection.c \ @@ -52,9 +52,6 @@ srcs += os/posix/nvgpu.c \ os/posix/posix-vgpu.c \ os/posix/posix-dt.c \ os/posix/posix-vidmem.c -else -# Causes duplicate file name if included -srcs += common/nvlink/nvlink.c endif # POSIX sources shared between the POSIX and QNX builds. @@ -268,6 +265,7 @@ srcs += common/sim.c \ common/nvlink/probe.c \ common/nvlink/nvlink_gv100.c \ common/nvlink/nvlink_tu104.c \ + common/nvlink/nvlink.c \ gv100/hal_gv100.c \ gv100/gsp_gv100.c \ gv100/clk_gv100.c \ diff --git a/drivers/gpu/nvgpu/Makefile.tmk b/drivers/gpu/nvgpu/Makefile.tmk index 61f3a3590..9e8c2ef12 100644 --- a/drivers/gpu/nvgpu/Makefile.tmk +++ b/drivers/gpu/nvgpu/Makefile.tmk @@ -56,7 +56,9 @@ NV_COMPONENT_CFLAGS += \ -DCONFIG_TEGRA_ACR=1 \ -DCONFIG_TEGRA_GR_VIRTUALIZATION \ -DCONFIG_GK20A_VIDMEM=1 \ - -DCONFIG_PCI_MSI + -DCONFIG_PCI_MSI \ + -DCONFIG_TEGRA_NVLINK + _NV_TOOLCHAIN_CFLAGS += -rdynamic -g -include $(NV_COMPONENT_DIR)/Makefile.sources diff --git a/drivers/gpu/nvgpu/common/nvlink/nvlink.c b/drivers/gpu/nvgpu/common/nvlink/nvlink.c index 354b2c16d..f5db39198 100644 --- a/drivers/gpu/nvgpu/common/nvlink/nvlink.c +++ b/drivers/gpu/nvgpu/common/nvlink/nvlink.c @@ -99,7 +99,7 @@ int nvgpu_nvlink_dev_shutdown(struct gk20a *g) int err; err = g->ops.nvlink.shutdown(g); - return 0; + return err; } int nvgpu_nvlink_reg_init(struct gk20a *g) diff --git a/drivers/gpu/nvgpu/os/posix/nvlink.c b/drivers/gpu/nvgpu/os/posix/posix-nvlink.c similarity index 58% rename from drivers/gpu/nvgpu/os/posix/nvlink.c rename to drivers/gpu/nvgpu/os/posix/posix-nvlink.c index c830d6edb..52a5e30d5 100644 --- a/drivers/gpu/nvgpu/os/posix/nvlink.c +++ b/drivers/gpu/nvgpu/os/posix/posix-nvlink.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -21,6 +21,11 @@ */ #include +#include +#include + +struct gk20a; +struct nvgpu_firmware; int nvgpu_nvlink_train(struct gk20a *g, u32 link_id, bool from_off) { @@ -31,3 +36,58 @@ int nvgpu_nvlink_enumerate(struct gk20a *g) { return -ENOSYS; } + +int nvgpu_nvlink_register_device(struct gk20a *g) +{ + BUG(); + return 0; +} + +int nvgpu_nvlink_unregister_device(struct gk20a *g) +{ + BUG(); + return 0; +} + +int nvgpu_nvlink_register_link(struct gk20a *g) +{ + BUG(); + return 0; +} + +int nvgpu_nvlink_unregister_link(struct gk20a *g) +{ + BUG(); + return 0; +} + +int nvgpu_nvlink_setup_ndev(struct gk20a *g) +{ + BUG(); + return 0; +} + +int nvgpu_nvlink_init_ops(struct gk20a *g) +{ + BUG(); + return 0; +} + +int nvgpu_nvlink_read_dt_props(struct gk20a *g) +{ + BUG(); + return 0; +} + +u32 nvgpu_nvlink_minion_load_ucode(struct gk20a *g, + struct nvgpu_firmware *nvgpu_minion_fw) +{ + BUG(); + return 0; +} + +void nvgpu_nvlink_free_minion_used_mem(struct gk20a *g, + struct nvgpu_firmware *nvgpu_minion_fw) +{ + BUG(); +} diff --git a/userspace/Makefile.configs b/userspace/Makefile.configs index 26e3c88b4..0df1997de 100644 --- a/userspace/Makefile.configs +++ b/userspace/Makefile.configs @@ -21,8 +21,8 @@ CONFIGS := \ -DCONFIG_ARCH_TEGRA_18x_SOC=1 \ -DCONFIG_GK20A_VIDMEM=1 \ -DCONFIG_PCI_MSI \ - -DCONFIG_SUPPORT_PMU_PSTATE - + -DCONFIG_SUPPORT_PMU_PSTATE \ + -DCONFIG_TEGRA_NVLINK # Uncomment these to enable the config. # CONFIGS += -DCONFIG_NVGPU_TRACK_MEM_USAGE=y diff --git a/userspace/Makefile.tmk b/userspace/Makefile.tmk index 5cb259972..5b5038cc0 100644 --- a/userspace/Makefile.tmk +++ b/userspace/Makefile.tmk @@ -112,7 +112,9 @@ NV_COMPONENT_CFLAGS += \ -DCONFIG_ARCH_TEGRA_18x_SOC=1 \ -DCONFIG_GK20A_VIDMEM=1 \ -DCONFIG_PCI_MSI \ - -DCONFIG_SUPPORT_PMU_PSTATE + -DCONFIG_SUPPORT_PMU_PSTATE \ + -DCONFIG_TEGRA_NVLINK + NV_COMPONENT_SYSTEMIMAGE_DIR := $(NV_SYSTEMIMAGE_TEST_EXECUTABLE_DIR)/nvgpu_unit/ systemimage:: $(NV_COMPONENT_SYSTEMIMAGE_DIR) $(NV_COMPONENT_SYSTEMIMAGE_DIR) : $(NV_SYSTEMIMAGE_TEST_EXECUTABLE_DIR) diff --git a/userspace/units/Makefile.units.common.tmk b/userspace/units/Makefile.units.common.tmk index a82450a95..d90eedff6 100644 --- a/userspace/units/Makefile.units.common.tmk +++ b/userspace/units/Makefile.units.common.tmk @@ -50,7 +50,9 @@ NV_COMPONENT_CFLAGS += \ -DCONFIG_ARCH_TEGRA_18x_SOC=1 \ -DCONFIG_GK20A_VIDMEM=1 \ -DCONFIG_PCI_MSI \ - -DCONFIG_SUPPORT_PMU_PSTATE + -DCONFIG_SUPPORT_PMU_PSTATE \ + -DCONFIG_TEGRA_NVLINK + NV_COMPONENT_NEEDED_INTERFACE_DIRS += \ $(NV_SOURCE)/kernel/nvgpu/drivers/gpu/nvgpu \ $(NV_SOURCE)/kernel/nvgpu/userspace