Files
linux-nvgpu/drivers/gpu/nvgpu/hal/clk/clk_mon_tu104.h
Jinesh Parakh 48257490be gpu: nvgpu: Update the number of clock domains supported
Fix the following Coverity Defects:
clk_mon_tu104.c : Out-of-bounds write
clk_mon_tu104.c : Out-of-bounds read
clk_mon_tu104.c : Out-of-bounds access

Fix the following CERT-C Defects:
clk_mon_tu104.c : CERT STR31-C

For fixing an older Coverity defect,
we had changed datatype of domain mask
from u32 to unsigned long.
This thing generates another issue.
bit_pos range changes from [0,32) to [0,64).
Changing CLK_CLOCK_MON_DOMAIN_COUNT from 0x32U to 0x40U
solves the issue.

CID 10138023
CID 10138024
CID 10138025
CID 518885
CID 518887
CID 518890

Bug 3460991
Bug 3512546

Signed-off-by: Jinesh Parakh <jparakh@nvidia.com>
Change-Id: I2a4853d87d7bb316db3de56ef34a039bf02486d7
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2728545
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-06-16 17:59:19 -07:00

59 lines
2.1 KiB
C

/*
* Copyright (c) 2020-2022, 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.
*/
#ifndef CLK_MON_TU104_H
#define CLK_MON_TU104_H
/**
* FMON register types
*/
#define FMON_THRESHOLD_HIGH 0x0U
#define FMON_THRESHOLD_LOW 0x1U
#define FMON_FAULT_STATUS 0x2U
#define FMON_FAULT_STATUS_PRIV_MASK 0x3U
#define CLK_CLOCK_MON_REG_TYPE_COUNT 0x4U
#define CLK_MON_BITS_PER_BYTE 0x8U
/*
* The Maximum count of clock domains supported
*/
#define CLK_CLOCK_MON_DOMAIN_COUNT 0x40U
struct clk_domain_mon_status {
u32 clk_api_domain;
u32 low_threshold;
u32 high_threshold;
u32 clk_domain_fault_status;
};
struct clk_domains_mon_status_params {
u32 clk_mon_domain_mask;
struct clk_domain_mon_status
clk_mon_list[CLK_CLOCK_MON_DOMAIN_COUNT];
};
bool tu104_clk_mon_check_master_fault_status(struct gk20a *g);
int tu104_clk_mon_check_status(struct gk20a *g, unsigned long domain_mask);
bool tu104_clk_mon_check_clk_good(struct gk20a *g);
bool tu104_clk_mon_check_pll_lock(struct gk20a *g);
#endif /* CLK_MON_TU104_H */