From e4c63e7b36badccc76e014d04adfb290ff5cb079 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 8 May 2019 08:23:11 -0700 Subject: [PATCH] nvgpu: arch: Add YAML compilation check Add makefile targets to the tmake nvgpu-drv build to execute the arch.py script before compiling the driver. This ensures that our source matches our YAML at all times. Also add one YAML fix to make sure the arch check actually passes! JIRA NVGPU-3075 Change-Id: Ic893a26889732ce55ce16b0188da337629921e6b Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/2119821 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Philip Elcan GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions Tested-by: mobile promotions --- arch/nvgpu-common.yaml | 3 ++- drivers/gpu/nvgpu/Makefile.tmk | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/arch/nvgpu-common.yaml b/arch/nvgpu-common.yaml index 76548472f..26331a743 100644 --- a/arch/nvgpu-common.yaml +++ b/arch/nvgpu-common.yaml @@ -13,7 +13,8 @@ nvgpu: safe: yes owner: Alex W sources: [ include/nvgpu/gk20a.h, - include/nvgpu/nvgpu_common.h ] + include/nvgpu/nvgpu_common.h, + include/nvgpu/secure_ops.h ] bios: safe: yes diff --git a/drivers/gpu/nvgpu/Makefile.tmk b/drivers/gpu/nvgpu/Makefile.tmk index 1e92f7ea5..c94555f9b 100644 --- a/drivers/gpu/nvgpu/Makefile.tmk +++ b/drivers/gpu/nvgpu/Makefile.tmk @@ -15,6 +15,10 @@ ifdef NV_COMPONENT_FLAG_SHARED_LIBRARY_SECTION include $(NV_BUILD_START_COMPONENT) +# Architecture script. This validates our YAML architecture against the +# source code we have. +ARCH_PY := $(NV_SOURCE)/core-private/tools/arch/arch.py + # # Include the nvgpu-next repo, if it's present. It's expected to be # located in the same directory as nvgpu, like so: @@ -32,6 +36,8 @@ NVGPU_NEXT_SOURCE := \ $(NV_COMPONENT_DIR)/../../../../nvgpu-next/drivers/gpu/nvgpu NVGPU_POSIX := -D__NVGPU_POSIX__ +NVGPU_ARCH := $(NV_COMPONENT_DIR)/../../../arch +NVGPU_ARCH_YAML := $(NVGPU_ARCH)/*.yaml NV_COMPONENT_NAME := nvgpu-drv NV_COMPONENT_OWN_INTERFACE_DIR := . @@ -74,6 +80,34 @@ NV_COMPONENT_SOURCES := \ $(srcs) \ $(addprefix $(NVGPU_NEXT_SOURCE)/,$(srcs_next)) +# $(srcs_next) already has the NV_COMPONENT_DIR prefix so we already have the +# absolute path to those files. srcs are all relative, so we have to prefix +# those with the absolute path. +SRC_DEPS := srcs_next +SRC_DEPS += \ + $(addprefix $(NV_COMPONENT_DIR)/,$(srcs)) + +# +# A little bit of magic to get tmake to execute the arch.py python script +# before we build the driver. Currently it ensures that the source code matches +# the arch. +# +# The way this works is we define a special target $(SRC_DEPS) which contains +# each .c file in the driver. Then when each .o target requires the +# corresponding .c file, this target is triggered. It in turn depends on the +# YAML files. Those files, then depend on a phony target (nvgpu-arch) that +# actually executes the check. +# +$(SRC_DEPS): $(NVGPU_ARCH_YAML) +$(NVGPU_ARCH_YAML): nvgpu-arch +nvgpu-arch: $(ARCH_PY) + $(PYTHON2) $(ARCH_PY) \ + --arch-file $(NVGPU_ARCH)/nvgpu.yaml \ + --source $(NV_COMPONENT_DIR) \ + sources --check + +.PHONY: nvgpu-arch + 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)