mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: add __must_check to gk20a_busy
The return value of gk20a_busy must be checked since it may not succeed in some cases. Add the __must_check attribute that generates a compiler warning for code that does not read the return value and fix all uses of the function to take error cases into account. Bug 200040921 Change-Id: Ibc2b119985fa230324c88026fe94fc5f1894fe4f Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: http://git-master/r/542552 Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
committed by
Dan Willemsen
parent
79ab01debd
commit
2d0bcfa331
@@ -82,8 +82,12 @@ int gk20a_as_release_share(struct gk20a_as_share *as_share)
|
||||
if (atomic_dec_return(&as_share->ref_cnt) > 0)
|
||||
return 0;
|
||||
|
||||
gk20a_busy(g->dev);
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = gk20a_vm_release_share(as_share);
|
||||
|
||||
gk20a_idle(g->dev);
|
||||
|
||||
release_as_share_id(as_share->as, as_share->id);
|
||||
|
||||
@@ -136,7 +136,7 @@ static int gk20a_ctrl_mark_compressible_write(
|
||||
struct gk20a *g,
|
||||
struct nvgpu_gpu_mark_compressible_write_args *args)
|
||||
{
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
ret = gk20a_busy(g->dev);
|
||||
if (ret)
|
||||
|
||||
@@ -571,7 +571,10 @@ static int dbg_set_powergate(struct dbg_session_gk20a *dbg_s,
|
||||
(g->dbg_powergating_disabled_refcount++ == 0)) {
|
||||
|
||||
gk20a_dbg(gpu_dbg_gpu_dbg | gpu_dbg_fn, "module busy");
|
||||
gk20a_busy(g->dev);
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = gk20a_busy(dbg_s->pdev);
|
||||
if (err)
|
||||
return -EPERM;
|
||||
|
||||
@@ -166,9 +166,14 @@ void gk20a_debug_show_dump(struct platform_device *pdev,
|
||||
struct gk20a *g = platform->g;
|
||||
struct fifo_gk20a *f = &g->fifo;
|
||||
u32 chid;
|
||||
int i;
|
||||
int i, err;
|
||||
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err) {
|
||||
gk20a_debug_output(o, "failed to power on gpu: %d\n", err);
|
||||
return;
|
||||
}
|
||||
|
||||
gk20a_busy(g->dev);
|
||||
for (i = 0; i < fifo_pbdma_status__size_1_v(); i++) {
|
||||
u32 status = gk20a_readl(g, fifo_pbdma_status_r(i));
|
||||
u32 chan_status = fifo_pbdma_status_chan_status_v(status);
|
||||
|
||||
@@ -703,7 +703,7 @@ void gk20a_create_sysfs(struct platform_device *dev);
|
||||
#define GK20A_SIM_IORESOURCE_MEM 2
|
||||
|
||||
void gk20a_busy_noresume(struct platform_device *pdev);
|
||||
int gk20a_busy(struct platform_device *pdev);
|
||||
int __must_check gk20a_busy(struct platform_device *pdev);
|
||||
void gk20a_idle(struct platform_device *pdev);
|
||||
void gk20a_disable(struct gk20a *g, u32 units);
|
||||
void gk20a_enable(struct gk20a *g, u32 units);
|
||||
|
||||
@@ -45,11 +45,15 @@ static ssize_t elcg_enable_store(struct device *device,
|
||||
struct platform_device *ndev = to_platform_device(device);
|
||||
struct gk20a *g = get_gk20a(ndev);
|
||||
unsigned long val = 0;
|
||||
int err;
|
||||
|
||||
if (kstrtoul(buf, 10, &val) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
gk20a_busy(g->dev);
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (val) {
|
||||
g->elcg_enabled = true;
|
||||
gr_gk20a_init_elcg_mode(g, ELCG_AUTO, ENGINE_GR_GK20A);
|
||||
@@ -84,6 +88,7 @@ static ssize_t blcg_enable_store(struct device *device,
|
||||
struct platform_device *ndev = to_platform_device(device);
|
||||
struct gk20a *g = get_gk20a(ndev);
|
||||
unsigned long val = 0;
|
||||
int err;
|
||||
|
||||
if (kstrtoul(buf, 10, &val) < 0)
|
||||
return -EINVAL;
|
||||
@@ -93,7 +98,10 @@ static ssize_t blcg_enable_store(struct device *device,
|
||||
else
|
||||
g->blcg_enabled = false;
|
||||
|
||||
gk20a_busy(g->dev);
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (g->ops.clock_gating.blcg_bus_load_gating_prod)
|
||||
g->ops.clock_gating.blcg_bus_load_gating_prod(g, g->blcg_enabled);
|
||||
if (g->ops.clock_gating.blcg_ctxsw_firmware_load_gating_prod)
|
||||
@@ -133,6 +141,7 @@ static ssize_t slcg_enable_store(struct device *device,
|
||||
struct platform_device *ndev = to_platform_device(device);
|
||||
struct gk20a *g = get_gk20a(ndev);
|
||||
unsigned long val = 0;
|
||||
int err;
|
||||
|
||||
if (kstrtoul(buf, 10, &val) < 0)
|
||||
return -EINVAL;
|
||||
@@ -147,7 +156,10 @@ static ssize_t slcg_enable_store(struct device *device,
|
||||
* init. Therefore, it would be incongruous to add it here. Once
|
||||
* it is added to init, we should add it here too.
|
||||
*/
|
||||
gk20a_busy(g->dev);
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (g->ops.clock_gating.slcg_bus_load_gating_prod)
|
||||
g->ops.clock_gating.slcg_bus_load_gating_prod(g, g->slcg_enabled);
|
||||
if (g->ops.clock_gating.slcg_ce2_load_gating_prod)
|
||||
@@ -305,11 +317,15 @@ static ssize_t gk20a_load_show(struct device *dev,
|
||||
struct gk20a *g = get_gk20a(pdev);
|
||||
u32 busy_time;
|
||||
ssize_t res;
|
||||
int err;
|
||||
|
||||
if (!g->power_on) {
|
||||
busy_time = 0;
|
||||
} else {
|
||||
gk20a_busy(g->dev);
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
gk20a_pmu_load_update(g);
|
||||
gk20a_pmu_load_norm(g, &busy_time);
|
||||
gk20a_idle(g->dev);
|
||||
@@ -436,6 +452,9 @@ static ssize_t aelpg_enable_store(struct device *device,
|
||||
return -EINVAL;
|
||||
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (g->pmu.pmu_ready) {
|
||||
if (val && !g->aelpg_enabled) {
|
||||
g->aelpg_enabled = true;
|
||||
|
||||
@@ -3721,13 +3721,12 @@ int gk20a_pmu_load_update(struct gk20a *g)
|
||||
void gk20a_pmu_get_load_counters(struct gk20a *g, u32 *busy_cycles,
|
||||
u32 *total_cycles)
|
||||
{
|
||||
if (!g->power_on) {
|
||||
if (!g->power_on || gk20a_busy(g->dev)) {
|
||||
*busy_cycles = 0;
|
||||
*total_cycles = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
gk20a_busy(g->dev);
|
||||
*busy_cycles = pwr_pmu_idle_count_value_v(
|
||||
gk20a_readl(g, pwr_pmu_idle_count_r(1)));
|
||||
rmb();
|
||||
@@ -3740,10 +3739,9 @@ void gk20a_pmu_reset_load_counters(struct gk20a *g)
|
||||
{
|
||||
u32 reg_val = pwr_pmu_idle_count_reset_f(1);
|
||||
|
||||
if (!g->power_on)
|
||||
if (!g->power_on || gk20a_busy(g->dev))
|
||||
return;
|
||||
|
||||
gk20a_busy(g->dev);
|
||||
gk20a_writel(g, pwr_pmu_idle_count_r(2), reg_val);
|
||||
wmb();
|
||||
gk20a_writel(g, pwr_pmu_idle_count_r(1), reg_val);
|
||||
@@ -3929,10 +3927,14 @@ static int elpg_residency_show(struct seq_file *s, void *data)
|
||||
u32 ungating_time = 0;
|
||||
u32 gating_cnt;
|
||||
u64 total_ingating, total_ungating, residency, divisor, dividend;
|
||||
int err;
|
||||
|
||||
/* Don't unnecessarily power on the device */
|
||||
if (g->power_on) {
|
||||
gk20a_busy(g->dev);
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
gk20a_pmu_get_elpg_residency_gating(g, &ingating_time,
|
||||
&ungating_time, &gating_cnt);
|
||||
gk20a_idle(g->dev);
|
||||
@@ -3974,9 +3976,13 @@ static int elpg_transitions_show(struct seq_file *s, void *data)
|
||||
struct gk20a *g = s->private;
|
||||
u32 ingating_time, ungating_time, total_gating_cnt;
|
||||
u32 gating_cnt = 0;
|
||||
int err;
|
||||
|
||||
if (g->power_on) {
|
||||
gk20a_busy(g->dev);
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
gk20a_pmu_get_elpg_residency_gating(g, &ingating_time,
|
||||
&ungating_time, &gating_cnt);
|
||||
gk20a_idle(g->dev);
|
||||
@@ -4066,6 +4072,7 @@ static ssize_t perfmon_events_enable_write(struct file *file,
|
||||
unsigned long val = 0;
|
||||
char buf[40];
|
||||
int buf_size;
|
||||
int err;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
buf_size = min(count, (sizeof(buf)-1));
|
||||
@@ -4078,7 +4085,10 @@ static ssize_t perfmon_events_enable_write(struct file *file,
|
||||
|
||||
/* Don't turn on gk20a unnecessarily */
|
||||
if (g->power_on) {
|
||||
gk20a_busy(g->dev);
|
||||
err = gk20a_busy(g->dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (val && !g->pmu.perfmon_sampling_enabled) {
|
||||
g->pmu.perfmon_sampling_enabled = true;
|
||||
pmu_perfmon_start_sampling(&(g->pmu));
|
||||
|
||||
Reference in New Issue
Block a user