From f10ee4ab0ec106e4eed66047e1882afeac67e91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konsta=20H=C3=B6ltt=C3=A4?= Date: Wed, 23 Feb 2022 12:11:20 +0200 Subject: [PATCH] gpu: nvgpu: add domain name API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add nvgpu_nvs_domain_get_name() to minimize messing up with nvs internals and to help code organization when nvs is not built in yet. A stub to help compilation returns NULL because no domains can exist when the stub is built in, and thus it won't be used. Jira NVGPU-6788 Change-Id: If663f7c0e8434ef00dd3a3f40f6404a35b477f2b Signed-off-by: Konsta Hölttä Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2673120 Reviewed-by: svcacv Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/fifo/tsg.c | 8 ++++---- drivers/gpu/nvgpu/common/nvs/nvs_sched.c | 7 +++++++ drivers/gpu/nvgpu/include/nvgpu/nvs.h | 7 +++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/tsg.c b/drivers/gpu/nvgpu/common/fifo/tsg.c index 938642980..15ecba6a1 100644 --- a/drivers/gpu/nvgpu/common/fifo/tsg.c +++ b/drivers/gpu/nvgpu/common/fifo/tsg.c @@ -167,23 +167,23 @@ int nvgpu_tsg_bind_channel(struct nvgpu_tsg *tsg, struct nvgpu_channel *ch) int nvgpu_tsg_bind_domain(struct nvgpu_tsg *tsg, struct nvgpu_nvs_domain *nnvs_domain) { struct nvgpu_runlist_domain *rl_domain; - struct nvs_domain *nvs_domain; struct gk20a *g = tsg->g; + const char *name; /* Hopping channels from one domain to another is not allowed */ if (tsg->num_active_channels != 0U) { return -EINVAL; } - nvs_domain = nnvs_domain->parent; + name = nvgpu_nvs_domain_get_name(nnvs_domain); /* * The domain ptr will get updated with the right id once the runlist * gets specified based on the first channel. */ - rl_domain = nvgpu_rl_domain_get(g, 0, nvs_domain->name); + rl_domain = nvgpu_rl_domain_get(g, 0, name); if (rl_domain == NULL) { - nvgpu_err(g, "rl domain not found (%s)", nvs_domain->name); + nvgpu_err(g, "rl domain not found (%s)", name); /* * This shouldn't happen because the nvs domain guarantees RL domains. * diff --git a/drivers/gpu/nvgpu/common/nvs/nvs_sched.c b/drivers/gpu/nvgpu/common/nvs/nvs_sched.c index a54e6f785..5066b9e80 100644 --- a/drivers/gpu/nvgpu/common/nvs/nvs_sched.c +++ b/drivers/gpu/nvgpu/common/nvs/nvs_sched.c @@ -490,6 +490,13 @@ u32 nvgpu_nvs_domain_count(struct gk20a *g) return count; } +const char *nvgpu_nvs_domain_get_name(struct nvgpu_nvs_domain *dom) +{ + struct nvs_domain *nvs_dom = dom->parent; + + return nvs_dom->name; +} + void nvgpu_nvs_get_log(struct gk20a *g, s64 *timestamp, const char **msg) { struct nvs_log_event ev; diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvs.h b/drivers/gpu/nvgpu/include/nvgpu/nvs.h index d44c9f106..7210bbc18 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvs.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvs.h @@ -103,6 +103,7 @@ struct nvgpu_nvs_domain * nvgpu_nvs_domain_by_name(struct gk20a *g, const char *name); void nvgpu_nvs_domain_get(struct gk20a *g, struct nvgpu_nvs_domain *dom); void nvgpu_nvs_domain_put(struct gk20a *g, struct nvgpu_nvs_domain *dom); +const char *nvgpu_nvs_domain_get_name(struct nvgpu_nvs_domain *dom); /* * Debug wrapper for NVS code. */ @@ -134,6 +135,12 @@ static inline void nvgpu_nvs_domain_put(struct gk20a *g, struct nvgpu_nvs_domain (void)g; (void)dom; } + +static inline const char *nvgpu_nvs_domain_get_name(struct nvgpu_nvs_domain *dom) +{ + (void)dom; + return NULL; +} #endif #endif