From ebeeec68ed8e17845c73997cb85973bb22d58054 Mon Sep 17 00:00:00 2001 From: Abdul Salam Date: Thu, 13 Jun 2019 11:55:38 +0530 Subject: [PATCH] gpu: nvgpu: Add support to query dgpu max freq Implement get_maxrate for TU104. This function will use the clk_arb to get the P0 Max from VBIOS. Bug 2610308 Change-Id: I09c692676bf949f300c9edd00f4faa26118b124f Signed-off-by: Abdul Salam Reviewed-on: https://git-master.nvidia.com/r/2133427 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Vaibhav Kachore Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/hal/clk/clk_gv100.c | 16 ++++++++++++++++ drivers/gpu/nvgpu/hal/clk/clk_gv100.h | 3 ++- drivers/gpu/nvgpu/hal/init/hal_tu104.c | 1 + drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 7 +++++-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/hal/clk/clk_gv100.c b/drivers/gpu/nvgpu/hal/clk/clk_gv100.c index 82a7efe9e..3368c8804 100644 --- a/drivers/gpu/nvgpu/hal/clk/clk_gv100.c +++ b/drivers/gpu/nvgpu/hal/clk/clk_gv100.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -234,3 +235,18 @@ void gv100_suspend_clk_support(struct gk20a *g) { nvgpu_mutex_destroy(&g->clk.clk_mutex); } + +unsigned long gv100_clk_maxrate(struct gk20a *g, u32 api_domain) +{ + u16 min_mhz, max_mhz; + int status; + + status = nvgpu_clk_arb_get_arbiter_clk_range(g, api_domain, &min_mhz, + &max_mhz); + if (status != 0) { + nvgpu_err(g, "failed to fetch clock range"); + return 0U; + } + + return (max_mhz * 1000UL * 1000UL); +} diff --git a/drivers/gpu/nvgpu/hal/clk/clk_gv100.h b/drivers/gpu/nvgpu/hal/clk/clk_gv100.h index d2a15aba5..766d0af84 100644 --- a/drivers/gpu/nvgpu/hal/clk/clk_gv100.h +++ b/drivers/gpu/nvgpu/hal/clk/clk_gv100.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-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"), @@ -35,4 +35,5 @@ int gv100_clk_domain_get_f_points( u32 clkapidomain, u32 *pfpointscount, u16 *pfreqpointsinmhz); +unsigned long gv100_clk_maxrate(struct gk20a *g, u32 api_domain); #endif /* CLK_GV100_H */ diff --git a/drivers/gpu/nvgpu/hal/init/hal_tu104.c b/drivers/gpu/nvgpu/hal/init/hal_tu104.c index a4cfdf92b..de8bbfa7a 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_tu104.c +++ b/drivers/gpu/nvgpu/hal/init/hal_tu104.c @@ -1130,6 +1130,7 @@ static const struct gpu_ops tu104_ops = { .suspend_clk_support = gv100_suspend_clk_support, .perf_pmu_vfe_load = nvgpu_perf_pmu_vfe_load_ps35, .clk_domain_get_f_points = gv100_clk_domain_get_f_points, + .get_maxrate = gv100_clk_maxrate, }, .clk_arb = { .check_clk_arb_support = gv100_check_clk_arb_support, diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index 7894f2518..831475ff8 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c @@ -47,6 +47,7 @@ #include #include #include +#include #include "ioctl_ctrl.h" #include "ioctl_dbg.h" @@ -376,8 +377,10 @@ gk20a_ctrl_ioctl_gpu_characteristics( gpu.cbc_cache_line_size = nvgpu_ltc_get_cacheline_size(g); gpu.cbc_comptags_per_line = g->cbc->comptags_per_cacheline; - if (g->ops.clk.get_maxrate) - gpu.max_freq = g->ops.clk.get_maxrate(g, CTRL_CLK_DOMAIN_GPCCLK); + if ((g->ops.clk.get_maxrate) && nvgpu_platform_is_silicon(g)) { + gpu.max_freq = g->ops.clk.get_maxrate(g, + CTRL_CLK_DOMAIN_GPCCLK); + } gpu.local_video_memory_size = g->mm.vidmem.size;