From cfc5bac05960f19c42710b6965861e06c1a47157 Mon Sep 17 00:00:00 2001 From: Seema Khowala Date: Fri, 1 May 2020 22:10:31 -0700 Subject: [PATCH] gpu: nvgpu: add assert in nvgpu_writel_check nvgpu_writel_check outputs dbg message if updated read value does not match with requested write value. Change dbg message to error message. Use BUG_ON for write mismatch as failure to update h/w register is a bug and tells s/w to either add fixed delay or use timeout to check for updated register value. JIRA NVGPU-5490 Change-Id: Ib11b7862d2990a56259d2f8c10d75c12c84bae5d Signed-off-by: Seema Khowala Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2338004 Reviewed-by: automaticguardword Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/io/io.c | 6 ++++-- userspace/units/io/common_io.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/common/io/io.c b/drivers/gpu/nvgpu/common/io/io.c index 0636e6454..371e0e0aa 100644 --- a/drivers/gpu/nvgpu/common/io/io.c +++ b/drivers/gpu/nvgpu/common/io/io.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,6 +22,7 @@ #include #include +#include #include void nvgpu_writel_check(struct gk20a *g, u32 r, u32 v) @@ -31,7 +32,8 @@ void nvgpu_writel_check(struct gk20a *g, u32 r, u32 v) nvgpu_writel(g, r, v); read_val = nvgpu_readl(g, r); if (v != read_val) { - nvgpu_log(g, gpu_dbg_reg, "r=0x%x rd=0x%x wr=0x%x (mismatch)", + nvgpu_err(g, "r=0x%x rd=0x%x wr=0x%x (mismatch)", r, read_val, v); + BUG_ON(1); } } diff --git a/userspace/units/io/common_io.c b/userspace/units/io/common_io.c index df4eaa986..039d0e522 100644 --- a/userspace/units/io/common_io.c +++ b/userspace/units/io/common_io.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "common_io.h" @@ -56,7 +57,7 @@ int test_writel_check(struct unit_module *m, struct gk20a *g, void *args) /* Value 0 will force to fail readback call as read API returns * NVGPU_READ_VAL. */ - nvgpu_writel_check(g, USER_MODE_BASE, 0); + EXPECT_BUG(nvgpu_writel_check(g, USER_MODE_BASE, 0)); /* Value NVGPU_READ_VAL will pass the readback call as read API returns * NVGPU_READ_VAL. */