From d0a77f558ef8d101059c6238abd46a9a97191564 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Mon, 3 Jul 2017 13:49:27 +0300 Subject: gpu: nvgpu: use u32 for timeout API duration A negative value in the timeout duration does not have any special uses, so change the duration type to u32 (from just int). Delete some unnecessary typecasts to int. Also change MAX_SCHEDULE_TIMEOUT to ULONG_MAX in default gr idle timeout because the value is in milliseconds instead of scheduling units and to drop unnecessary Linux dependency. Change-Id: I5cf6febd4f1cb00c46fe159603436a9ac3b003ac Signed-off-by: Konsta Holtta Reviewed-on: https://git-master/r/1512565 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/timers.c | 8 +------- drivers/gpu/nvgpu/common/pmu/pmu_ipc.c | 4 ++-- drivers/gpu/nvgpu/gk20a/gk20a.h | 2 +- drivers/gpu/nvgpu/gk20a/gr_gk20a.c | 6 ++---- drivers/gpu/nvgpu/gm20b/pmu_gm20b.c | 2 +- drivers/gpu/nvgpu/include/nvgpu/timers.h | 8 ++++---- 6 files changed, 11 insertions(+), 19 deletions(-) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/common/linux/timers.c b/drivers/gpu/nvgpu/common/linux/timers.c index 2953902e..5786b240 100644 --- a/drivers/gpu/nvgpu/common/linux/timers.c +++ b/drivers/gpu/nvgpu/common/linux/timers.c @@ -54,12 +54,9 @@ static int nvgpu_timeout_is_pre_silicon(struct nvgpu_timeout *timeout) * * If neither %NVGPU_TIMER_CPU_TIMER or %NVGPU_TIMER_RETRY_TIMER is passed then * a CPU timer is used by default. - * - * A negative duration is interpreted as the maximum possible, which for our - * purposes means infinite wait. */ int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout, - int duration, unsigned long flags) + u32 duration, unsigned long flags) { if (flags & ~NVGPU_TIMER_FLAG_MASK) return -EINVAL; @@ -69,9 +66,6 @@ int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout, timeout->g = g; timeout->flags = flags; - if (duration < 0) - duration = INT_MAX; - if (flags & NVGPU_TIMER_RETRY_TIMER) timeout->retries.max = duration; else diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c b/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c index 0dbc2df3..6dffdf0f 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_ipc.c @@ -453,7 +453,7 @@ static int pmu_write_cmd(struct nvgpu_pmu *pmu, struct pmu_cmd *cmd, nvgpu_log_fn(g, " "); queue = &pmu->queue[queue_id]; - nvgpu_timeout_init(g, &timeout, (int)timeout_ms, NVGPU_TIMER_CPU_TIMER); + nvgpu_timeout_init(g, &timeout, timeout_ms, NVGPU_TIMER_CPU_TIMER); do { err = pmu_queue_open_write(pmu, queue, cmd->hdr.size); @@ -878,7 +878,7 @@ int pmu_wait_message_cond(struct nvgpu_pmu *pmu, u32 timeout_ms, struct nvgpu_timeout timeout; unsigned long delay = GR_IDLE_CHECK_DEFAULT; - nvgpu_timeout_init(g, &timeout, (int)timeout_ms, NVGPU_TIMER_CPU_TIMER); + nvgpu_timeout_init(g, &timeout, timeout_ms, NVGPU_TIMER_CPU_TIMER); do { if (*var == val) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index f365ac94..dd5f0d17 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -1287,7 +1287,7 @@ struct gk20a { static inline unsigned long gk20a_get_gr_idle_timeout(struct gk20a *g) { return g->timeouts_enabled ? - g->gr_idle_timeout_default : MAX_SCHEDULE_TIMEOUT; + g->gr_idle_timeout_default : ULONG_MAX; } enum BAR0_DEBUG_OPERATION { diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c index c5dab0b5..4dfb6ee8 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c @@ -344,8 +344,7 @@ int gr_gk20a_wait_idle(struct gk20a *g, unsigned long duration_ms, gr_engine_id = gk20a_fifo_get_gr_engine_id(g); - nvgpu_timeout_init(g, &timeout, (int)duration_ms, - NVGPU_TIMER_CPU_TIMER); + nvgpu_timeout_init(g, &timeout, duration_ms, NVGPU_TIMER_CPU_TIMER); do { /* fmodel: host gets fifo_engine_status(gr) from gr @@ -398,8 +397,7 @@ int gr_gk20a_wait_fe_idle(struct gk20a *g, unsigned long duration_ms, gk20a_dbg_fn(""); - nvgpu_timeout_init(g, &timeout, (int)duration_ms, - NVGPU_TIMER_CPU_TIMER); + nvgpu_timeout_init(g, &timeout, duration_ms, NVGPU_TIMER_CPU_TIMER); do { val = gk20a_readl(g, gr_status_r()); diff --git a/drivers/gpu/nvgpu/gm20b/pmu_gm20b.c b/drivers/gpu/nvgpu/gm20b/pmu_gm20b.c index ee55c8ef..0f99c67e 100644 --- a/drivers/gpu/nvgpu/gm20b/pmu_gm20b.c +++ b/drivers/gpu/nvgpu/gm20b/pmu_gm20b.c @@ -184,7 +184,7 @@ static int pmu_gm20b_ctx_wait_lsf_ready(struct gk20a *g, u32 timeout_ms, gk20a_dbg_fn(""); reg = gk20a_readl(g, gr_fecs_ctxsw_mailbox_r(0)); - nvgpu_timeout_init(g, &timeout, (int)timeout_ms, NVGPU_TIMER_CPU_TIMER); + nvgpu_timeout_init(g, &timeout, timeout_ms, NVGPU_TIMER_CPU_TIMER); do { reg = gk20a_readl(g, gr_fecs_ctxsw_mailbox_r(0)); diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h index 5265437e..482f92b7 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/timers.h +++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -52,8 +52,8 @@ struct nvgpu_timeout { union { s64 time; struct { - int max; - int attempted; + u32 max; + u32 attempted; } retries; }; }; @@ -75,7 +75,7 @@ struct nvgpu_timeout { NVGPU_TIMER_SILENT_TIMEOUT) int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout, - int duration, unsigned long flags); + u32 duration, unsigned long flags); int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout); #define nvgpu_timeout_expired(__timeout) \ -- cgit v1.2.2