diff options
author | Arun Kannan <akannan@nvidia.com> | 2018-03-05 17:32:08 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-04-23 15:12:52 -0400 |
commit | e9a6d179a42e7bdd6bb4876fb14f4ff7ab0df852 (patch) | |
tree | f2700ecb7c4f04041f9b333e6c8fe888bef7e082 /drivers/gpu/nvgpu/common/linux/clk.c | |
parent | 0e3181a5d710a4ef066c81ec9d699dbcb3d9c995 (diff) |
gpu: nvgpu: cache gpu clk rate
Cache the rate used in clk_set_rate().
Return that cached rate on clk_get_rate(), don't read from hardware.
This cached rate is used to avoid duplicate requests to clk_set_rate().
Motivation is to support multiple governors for gpu clk.
Reading clock from hardware is unreliable in multi-governor situation.
Relying on hardware clock value could mislead the kernel gpu governor
in its scaling calculations.
Bug 2051688
Change-Id: I43fc056eea6f69fe0889c45640fcb892b658071c
Signed-off-by: Arun Kannan <akannan@nvidia.com>
(cherry picked from commit 7f819a9ba707e6e905168b00b0f3bf6348e86188)
Reviewed-on: https://git-master.nvidia.com/r/1662759
Reviewed-on: https://git-master.nvidia.com/r/1668919
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/clk.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/clk.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/clk.c b/drivers/gpu/nvgpu/common/linux/clk.c index ea5b023d..8bffc07b 100644 --- a/drivers/gpu/nvgpu/common/linux/clk.c +++ b/drivers/gpu/nvgpu/common/linux/clk.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Linux clock support | 2 | * Linux clock support |
3 | * | 3 | * |
4 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | 4 | * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms and conditions of the GNU General Public License, | 7 | * under the terms and conditions of the GNU General Public License, |
@@ -34,9 +34,13 @@ static unsigned long nvgpu_linux_clk_get_rate(struct gk20a *g, u32 api_domain) | |||
34 | switch (api_domain) { | 34 | switch (api_domain) { |
35 | case CTRL_CLK_DOMAIN_GPCCLK: | 35 | case CTRL_CLK_DOMAIN_GPCCLK: |
36 | if (g->clk.tegra_clk) | 36 | if (g->clk.tegra_clk) |
37 | ret = clk_get_rate(g->clk.tegra_clk); | 37 | ret = g->clk.cached_rate ? |
38 | g->clk.cached_rate : | ||
39 | clk_get_rate(g->clk.tegra_clk); | ||
38 | else | 40 | else |
39 | ret = clk_get_rate(platform->clk[0]); | 41 | ret = platform->cached_rate ? |
42 | platform->cached_rate : | ||
43 | clk_get_rate(platform->clk[0]); | ||
40 | break; | 44 | break; |
41 | case CTRL_CLK_DOMAIN_PWRCLK: | 45 | case CTRL_CLK_DOMAIN_PWRCLK: |
42 | ret = clk_get_rate(platform->clk[1]); | 46 | ret = clk_get_rate(platform->clk[1]); |
@@ -58,10 +62,15 @@ static int nvgpu_linux_clk_set_rate(struct gk20a *g, | |||
58 | 62 | ||
59 | switch (api_domain) { | 63 | switch (api_domain) { |
60 | case CTRL_CLK_DOMAIN_GPCCLK: | 64 | case CTRL_CLK_DOMAIN_GPCCLK: |
61 | if (g->clk.tegra_clk) | 65 | if (g->clk.tegra_clk) { |
62 | ret = clk_set_rate(g->clk.tegra_clk, rate); | 66 | ret = clk_set_rate(g->clk.tegra_clk, rate); |
63 | else | 67 | if (!ret) |
68 | g->clk.cached_rate = rate; | ||
69 | } else { | ||
64 | ret = clk_set_rate(platform->clk[0], rate); | 70 | ret = clk_set_rate(platform->clk[0], rate); |
71 | if (!ret) | ||
72 | platform->cached_rate = rate; | ||
73 | } | ||
65 | break; | 74 | break; |
66 | case CTRL_CLK_DOMAIN_PWRCLK: | 75 | case CTRL_CLK_DOMAIN_PWRCLK: |
67 | ret = clk_set_rate(platform->clk[1], rate); | 76 | ret = clk_set_rate(platform->clk[1], rate); |