From 1e125f245e95982d02746aab0fd2b9ea8db009f8 Mon Sep 17 00:00:00 2001 From: Peter Daifuku Date: Thu, 27 Sep 2018 17:23:37 -0700 Subject: gpu: nvgpu: support for clk.measure_freq for igpu Add support for the measure_freq clock op for igpu: - add nvgpu_clk_measure_freq(), which in turn calls the get_rate() clock op. - Initialize the measure_freq clock op to nvgpu_clk_measure_freq() for native linux and vgpu. JIRA ESRM-398 Change-Id: I8a3b2ee79e29e3491a16f55281494f05cd841b07 Signed-off-by: Peter Daifuku Reviewed-on: https://git-master.nvidia.com/r/1850585 Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Debarshi Dutta Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Nirav Patel Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/clk/clk_arb.c | 14 ++++++++++++++ drivers/gpu/nvgpu/include/nvgpu/clk_arb.h | 2 ++ drivers/gpu/nvgpu/os/linux/clk.c | 2 ++ drivers/gpu/nvgpu/vgpu/clk_vgpu.c | 2 ++ 4 files changed, 20 insertions(+) diff --git a/drivers/gpu/nvgpu/clk/clk_arb.c b/drivers/gpu/nvgpu/clk/clk_arb.c index 3d97535d..6cf005c8 100644 --- a/drivers/gpu/nvgpu/clk/clk_arb.c +++ b/drivers/gpu/nvgpu/clk/clk_arb.c @@ -1049,6 +1049,20 @@ int nvgpu_clk_arb_get_arbiter_actual_mhz(struct gk20a *g, return err; } +unsigned long nvgpu_clk_measure_freq(struct gk20a *g, u32 api_domain) +{ + unsigned long freq = 0UL; + + switch (api_domain) { + case CTRL_CLK_DOMAIN_GPC2CLK: + freq = g->ops.clk.get_rate(g, CTRL_CLK_DOMAIN_GPCCLK) * 2UL; + break; + default: + break; + } + return freq; +} + int nvgpu_clk_arb_get_arbiter_effective_mhz(struct gk20a *g, u32 api_domain, u16 *freq_mhz) { diff --git a/drivers/gpu/nvgpu/include/nvgpu/clk_arb.h b/drivers/gpu/nvgpu/include/nvgpu/clk_arb.h index a04e3542..43af6312 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/clk_arb.h +++ b/drivers/gpu/nvgpu/include/nvgpu/clk_arb.h @@ -369,6 +369,8 @@ void nvgpu_clk_notification_queue_free(struct gk20a *g, void nvgpu_clk_arb_event_post_event(struct nvgpu_clk_dev *dev); +unsigned long nvgpu_clk_measure_freq(struct gk20a *g, u32 api_domain); + #ifdef CONFIG_DEBUG_FS int nvgpu_clk_arb_debugfs_init(struct gk20a *g); #endif diff --git a/drivers/gpu/nvgpu/os/linux/clk.c b/drivers/gpu/nvgpu/os/linux/clk.c index e76720ac..36c13577 100644 --- a/drivers/gpu/nvgpu/os/linux/clk.c +++ b/drivers/gpu/nvgpu/os/linux/clk.c @@ -26,6 +26,7 @@ #include "platform_gk20a.h" #include +#include #define HZ_TO_MHZ(x) ((x) / 1000000) @@ -280,4 +281,5 @@ void nvgpu_linux_init_clk_support(struct gk20a *g) g->ops.clk.clk_domain_get_f_points = nvgpu_linux_clk_get_f_points; g->ops.clk.get_clk_range = nvgpu_clk_get_range; g->ops.clk.clk_get_round_rate = nvgpu_clk_get_round_rate; + g->ops.clk.measure_freq = nvgpu_clk_measure_freq; } diff --git a/drivers/gpu/nvgpu/vgpu/clk_vgpu.c b/drivers/gpu/nvgpu/vgpu/clk_vgpu.c index 6aea7c8f..4167f905 100644 --- a/drivers/gpu/nvgpu/vgpu/clk_vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/clk_vgpu.c @@ -22,6 +22,7 @@ #include #include +#include #include "gk20a/gk20a.h" #include "clk_vgpu.h" @@ -214,6 +215,7 @@ void vgpu_init_clk_support(struct gk20a *g) g->ops.clk.clk_get_round_rate = vgpu_clk_get_round_rate; g->ops.clk.get_clk_range = vgpu_clk_get_range; g->ops.clk.clk_domain_get_f_points = vgpu_clk_get_f_points; + g->ops.clk.measure_freq = nvgpu_clk_measure_freq; } int vgpu_clk_get_freqs(struct gk20a *g, unsigned long **freqs_out, -- cgit v1.2.2