diff options
author | Will McVicker <willmcvicker@google.com> | 2022-01-10 11:09:32 -0800 |
---|---|---|
committer | Will McVicker <willmcvicker@google.com> | 2022-01-10 15:20:16 -0800 |
commit | 865dfd96edf329fb2ce17cf9df25d6a46d13cd3b (patch) | |
tree | a247d5bf142ddbd13de2b17cba2ae3b6d9a71eb3 | |
parent | e6dc812c2244d17c2fc14ab6f51845bf52e4b4b1 (diff) | |
download | abrolhos-865dfd96edf329fb2ce17cf9df25d6a46d13cd3b.tar.gz |
kbuild: Clean up the build files
* Update build files now that gs/kernel/device-modules is an external
module.
* Move the build objects to Kbuild and update Makefile to just compile
the module.
* Update the trace header defines
* Fix GIT_REPO_TAG to work with kleaf (when compile outside of a git
tree). Also, use THIS_MODULE->scmversion when available.
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: Iea1a3b60a30a1144b8416fc5a111b90e122c6a7e
-rw-r--r-- | drivers/edgetpu/BUILD.bazel | 10 | ||||
-rw-r--r-- | drivers/edgetpu/Kbuild | 35 | ||||
-rw-r--r-- | drivers/edgetpu/Makefile | 28 | ||||
-rw-r--r-- | drivers/edgetpu/abrolhos-platform.c | 8 | ||||
-rw-r--r-- | drivers/edgetpu/include/trace/events/edgetpu.h | 4 |
5 files changed, 49 insertions, 36 deletions
diff --git a/drivers/edgetpu/BUILD.bazel b/drivers/edgetpu/BUILD.bazel index a0c533b..3d54d36 100644 --- a/drivers/edgetpu/BUILD.bazel +++ b/drivers/edgetpu/BUILD.bazel @@ -10,10 +10,20 @@ load("//build/kleaf:kernel.bzl", "kernel_module") kernel_module( name = "edgetpu.slider", + srcs = glob([ + "**/*.c", + "**/*.h", + "Kbuild", + ]) + [ + "//gs/kernel/device-modules:gs101_soc_headers", + ], outs = [ "abrolhos.ko", ], kernel_build = "//gs/kernel/device-modules:slider", + kernel_module_deps = [ + "//gs/kernel/device-modules:gs101_soc", + ], visibility = [ "//gs/kernel/device-modules:__pkg__", ], diff --git a/drivers/edgetpu/Kbuild b/drivers/edgetpu/Kbuild index f1e7f56..9a43816 100644 --- a/drivers/edgetpu/Kbuild +++ b/drivers/edgetpu/Kbuild @@ -1,18 +1,31 @@ -obj-m += abrolhos.o -ccflags-y += -DCONFIG_EDGETPU_TELEMETRY_TRACE=1 -I$(src)/include -# Use the absolute path of this Makefile to get the source directory. -CURRENT_DIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -GIT_PATH=$(CURRENT_DIR)/../../ -ifeq ($(shell git --git-dir=$(GIT_PATH)/.git rev-parse --is-inside-work-tree),true) - GIT_REPO_STATE=$(shell (git --git-dir=$(GIT_PATH)/.git --work-tree=$(GIT_PATH) status --porcelain | grep -q .) && echo -dirty) - ccflags-y += -DGIT_REPO_TAG=\"$(shell git --git-dir=$(GIT_PATH)/.git rev-parse --short HEAD)$(GIT_REPO_STATE)\" +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_ABROLHOS) += abrolhos.o +ccflags-y += -DCONFIG_EDGETPU_TELEMETRY_TRACE=1 +ccflags-y += -I$(srctree)/$(src)/include + +GIT_PATH=$(srctree)/$(src) +ifeq ($(shell git -C $(GIT_PATH) rev-parse --is-inside-work-tree),true) + GIT_REPO_STATE=$(shell (git -C $(GIT_PATH) status --porcelain | grep -q .) && echo -dirty) + ccflags-y += -DGIT_REPO_TAG=\"$(shell git -C $(GIT_PATH) rev-parse --short HEAD)$(GIT_REPO_STATE)\" else ccflags-y += -DGIT_REPO_TAG=\"Not\ a\ git\ repository\" endif -edgetpu-fw-objs := edgetpu-firmware.o edgetpu-firmware-util.o edgetpu-shared-fw.o -edgetpu-objs := edgetpu-mailbox.o edgetpu-kci.o edgetpu-telemetry.o edgetpu-mapping.o edgetpu-dmabuf.o edgetpu-async.o edgetpu-iremap-pool.o edgetpu-sw-watchdog.o $(edgetpu-fw-objs) -abrolhos-y := abrolhos-device.o abrolhos-device-group.o abrolhos-fs.o abrolhos-core.o abrolhos-platform.o abrolhos-firmware.o abrolhos-thermal.o abrolhos-pm.o abrolhos-iommu.o abrolhos-debug-dump.o abrolhos-usage-stats.o abrolhos-wakelock.o $(edgetpu-objs) +edgetpu-fw-objs := edgetpu-firmware.o edgetpu-firmware-util.o edgetpu-shared-fw.o + +edgetpu-objs := edgetpu-async.o edgetpu-dmabuf.o edgetpu-iremap-pool.o \ + edgetpu-kci.o edgetpu-mailbox.o edgetpu-mapping.o \ + edgetpu-sw-watchdog.o edgetpu-telemetry.o \ + $(edgetpu-fw-objs) + +abrolhos-objs := abrolhos-core.o abrolhos-debug-dump.o \ + abrolhos-device-group.o abrolhos-fs.o abrolhos-device.o \ + abrolhos-firmware.o abrolhos-iommu.o \ + abrolhos-platform.o abrolhos-pm.o abrolhos-thermal.o \ + abrolhos-usage-stats.o abrolhos-wakelock.o \ + $(edgetpu-objs) + CFLAGS_abrolhos-fs.o := -DCONFIG_ABROLHOS=1 CFLAGS_abrolhos-core.o := -DCONFIG_ABROLHOS=1 CFLAGS_abrolhos-device.o := -DCONFIG_ABROLHOS=1 diff --git a/drivers/edgetpu/Makefile b/drivers/edgetpu/Makefile index b30f95f..00d966e 100644 --- a/drivers/edgetpu/Makefile +++ b/drivers/edgetpu/Makefile @@ -3,30 +3,10 @@ # Makefile for EdgeTPU framework and dependent drivers. # -obj-$(CONFIG_ABROLHOS) += abrolhos.o - -GIT_PATH=$(srctree) -ifeq ($(shell git --git-dir=$(GIT_PATH)/.git rev-parse --is-inside-work-tree),true) - GIT_REPO_STATE=$(shell (git --git-dir=$(GIT_PATH)/.git --work-tree=$(GIT_PATH) status --porcelain | grep -q .) && echo -dirty) - ccflags-y += -DGIT_REPO_TAG=\"$(shell git --git-dir=$(GIT_PATH)/.git rev-parse --short HEAD)$(GIT_REPO_STATE)\" -else - ccflags-y += -DGIT_REPO_TAG=\"Not\ a\ git\ repository\" -endif - -edgetpu-fw-objs := edgetpu-firmware-util.o edgetpu-firmware.o edgetpu-shared-fw.o -edgetpu-objs := edgetpu-async.o edgetpu-dmabuf.o edgetpu-iremap-pool.o \ - edgetpu-kci.o edgetpu-mailbox.o edgetpu-mapping.o \ - edgetpu-sw-watchdog.o edgetpu-telemetry.o \ - $(edgetpu-fw-objs) - -abrolhos-objs := abrolhos-core.o abrolhos-debug-dump.o \ - abrolhos-device-group.o abrolhos-device.o \ - abrolhos-firmware.o abrolhos-fs.o abrolhos-iommu.o \ - abrolhos-platform.o abrolhos-pm.o abrolhos-thermal.o \ - abrolhos-usage-stats.o abrolhos-wakelock.o \ - $(edgetpu-objs) - KBUILD_OPTIONS += CONFIG_ABROLHOS=m +include $(KERNEL_SRC)/../gs/kernel/device-modules/Makefile.include + modules modules_install clean: - $(MAKE) -C $(KERNEL_SRC) M=$(M) W=1 $(KBUILD_OPTIONS) $(@) + $(MAKE) -C $(KERNEL_SRC) M=$(M) W=1 \ + $(KBUILD_OPTIONS) EXTRA_CFLAGS="$(EXTRA_CFLAGS)" KBUILD_EXTRA_SYMBOLS="$(EXTRA_SYMBOLS)" $(@) diff --git a/drivers/edgetpu/abrolhos-platform.c b/drivers/edgetpu/abrolhos-platform.c index 2a3c50d..9c467f6 100644 --- a/drivers/edgetpu/abrolhos-platform.c +++ b/drivers/edgetpu/abrolhos-platform.c @@ -202,6 +202,7 @@ static int edgetpu_platform_probe(struct platform_device *pdev) /* Common name for embedded SoC devices */ { .name = "edgetpu-soc" }, }; + const char *scmversion; abpdev = devm_kzalloc(dev, sizeof(*abpdev), GFP_KERNEL); if (!abpdev) @@ -308,8 +309,13 @@ static int edgetpu_platform_probe(struct platform_device *pdev) abpdev->edgetpu_dev.thermal = devm_tpu_thermal_create(dev, &abpdev->edgetpu_dev); + if (try_module_get(THIS_MODULE) && THIS_MODULE->scmversion) + scmversion = THIS_MODULE->scmversion; + else + scmversion = GIT_REPO_TAG; + dev_info(dev, "%s edgetpu initialized. Build: %s\n", - abpdev->edgetpu_dev.dev_name, GIT_REPO_TAG); + abpdev->edgetpu_dev.dev_name, scmversion); dev_dbg(dev, "Probe finished, powering down\n"); /* Turn the device off unless a client request is already received. */ diff --git a/drivers/edgetpu/include/trace/events/edgetpu.h b/drivers/edgetpu/include/trace/events/edgetpu.h index 9723eca..e8b9e5d 100644 --- a/drivers/edgetpu/include/trace/events/edgetpu.h +++ b/drivers/edgetpu/include/trace/events/edgetpu.h @@ -128,4 +128,8 @@ TRACE_EVENT(edgetpu_map_dmabuf_end, #endif /* _TRACE_EDGETPU_H */ /* This part must be outside protection */ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE trace/events/edgetpu + #include <trace/define_trace.h> |