mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
Currently, nvgpu_writel_loop() writes to a register and immediately checks if register value is updated. It might take some time for hardware registers to get updated with value written by software. Modify nvgpu_writel_loop() to accept number of retries to check if register value is updated and assert with nvgpu_assert(). Also, move nvgpu_writel_loop() to common code and use generic nvgpu_readl() and nvgpu_writel() APIs. JIRA NVGPU-5490 Change-Id: Iaaf24203a91eee3d05de7d0c7dea18113367de5f Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2348628 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com> Reviewed-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
55 lines
1.8 KiB
C
55 lines
1.8 KiB
C
/*
|
|
* 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"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <nvgpu/io.h>
|
|
#include <nvgpu/types.h>
|
|
#include <nvgpu/bug.h>
|
|
#include <nvgpu/static_analysis.h>
|
|
#include <nvgpu/gk20a.h>
|
|
|
|
void nvgpu_writel_check(struct gk20a *g, u32 r, u32 v)
|
|
{
|
|
u32 read_val = 0U;
|
|
|
|
nvgpu_writel(g, r, v);
|
|
read_val = nvgpu_readl(g, r);
|
|
if (v != read_val) {
|
|
nvgpu_err(g, "r=0x%x rd=0x%x wr=0x%x (mismatch)",
|
|
r, read_val, v);
|
|
nvgpu_assert(v == read_val);
|
|
}
|
|
}
|
|
|
|
void nvgpu_writel_loop(struct gk20a *g, u32 r, u32 v, u32 retries)
|
|
{
|
|
u32 reg_val = 0U;
|
|
|
|
nvgpu_writel(g, r, v);
|
|
|
|
do {
|
|
retries = nvgpu_safe_sub_u32(retries, 1U);
|
|
reg_val = nvgpu_readl(g, r);
|
|
} while ((reg_val != v) && (retries > 0U));
|
|
|
|
nvgpu_assert(reg_val == v);
|
|
}
|