From 9e46d3731e5ce555bdc46410220bc5a6d8db6067 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Mon, 28 Nov 2016 12:48:37 -0800 Subject: gpu: nvgpu: Check for dead GPU Check if the GPU is present after each register read. If the a register read returns 0xffffffff then it's possible the GPU has fallen off the bus for some reason or another. However, to confirm that a register read is due to a dead GPU vs just a 0xffffffff being returned by happenstance the chip ID register is read which should never return 0xffffffff. If that read returns 0xffffffff as well then certainly the GPU is dead. Bug 1805082 Bug 1816516 Bug 1807277 Change-Id: I4de61b56289217d9c0d8167e84615a67c8bde8a9 Signed-off-by: Alex Waterman Reviewed-on: http://git-master/r/1239518 (cherry picked from commit bd50828de20aba9b2887ee99c2269602c21a793f) Reviewed-on: http://git-master/r/1261916 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gk20a.c | 8 ++++++++ drivers/gpu/nvgpu/gk20a/gk20a.h | 7 +++++++ 2 files changed, 15 insertions(+) (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 156d33ed..b921be7c 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -262,6 +262,14 @@ static const struct file_operations gk20a_sched_ops = { .read = gk20a_sched_dev_read, }; +void __nvgpu_check_gpu_state(struct gk20a *g) +{ + u32 boot_0 = readl(g->regs + mc_boot_0_r()); + + if (boot_0 == 0xffffffff) + pr_err("nvgpu: GPU has disappeared from bus!!\n"); +} + static inline void sim_writel(struct gk20a *g, u32 r, u32 v) { writel(v, g->sim.regs+r); diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 144cb37d..a4cbb4b2 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -1111,6 +1111,8 @@ void gk20a_init_clk_ops(struct gpu_ops *gops); int gk20a_lockout_registers(struct gk20a *g); int gk20a_restore_registers(struct gk20a *g); +void __nvgpu_check_gpu_state(struct gk20a *g); + static inline void gk20a_writel(struct gk20a *g, u32 r, u32 v) { gk20a_dbg(gpu_dbg_reg, " r=0x%x v=0x%x", r, v); @@ -1120,7 +1122,12 @@ static inline void gk20a_writel(struct gk20a *g, u32 r, u32 v) static inline u32 gk20a_readl(struct gk20a *g, u32 r) { u32 v = readl(g->regs + r); + + if (v == 0xffffffff) + __nvgpu_check_gpu_state(g); + gk20a_dbg(gpu_dbg_reg, " r=0x%x v=0x%x", r, v); + return v; } static inline void gk20a_writel_check(struct gk20a *g, u32 r, u32 v) -- cgit v1.2.2