From 375fd13eb81b0b819dba40d693b623ec10aa3240 Mon Sep 17 00:00:00 2001 From: Ramesh Mylavarapu Date: Tue, 10 Sep 2019 22:38:19 -0700 Subject: [PATCH] Revert "Revert "nvgpu: gpu: Changes in therm_channel table parsing"" This reverts commit 33b031ed0513c379d93cdc1084c6724189dfbb80. Change-Id: I1f260ed518d7b00c1ce65f0af9f47fd64ff66b33 Signed-off-by: rmylavarapu Reviewed-on: https://git-master.nvidia.com/r/2194825 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/pmu/therm/thrmchannel.c | 6 ++++++ drivers/gpu/nvgpu/common/pmu/therm/thrmdev.c | 6 ++++++ drivers/gpu/nvgpu/common/pmu/therm/thrmdev.h | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/common/pmu/therm/thrmchannel.c b/drivers/gpu/nvgpu/common/pmu/therm/thrmchannel.c index 0ae827d07..0e6319088 100644 --- a/drivers/gpu/nvgpu/common/pmu/therm/thrmchannel.c +++ b/drivers/gpu/nvgpu/common/pmu/therm/thrmchannel.c @@ -29,6 +29,7 @@ #include #include "thrmchannel.h" +#include "thrmdev.h" #include "thrm.h" static int _therm_channel_pmudatainit_device(struct gk20a *g, @@ -182,6 +183,11 @@ static int devinit_get_therm_channel_table(struct gk20a *g, } therm_channel_data.device.therm_dev_idx = therm_channel_table_entry->param0; + /* Check for valid therm device index */ + if (!nvgpu_therm_dev_idx_is_valid(g->pmu->therm_pmu, + therm_channel_data.device.therm_dev_idx)) { + continue; + } therm_channel_data.device.therm_dev_prov_idx = therm_channel_table_entry->param1; therm_channel_size = sizeof(struct therm_channel_device); diff --git a/drivers/gpu/nvgpu/common/pmu/therm/thrmdev.c b/drivers/gpu/nvgpu/common/pmu/therm/thrmdev.c index 38f7c1b41..e025a2ab8 100644 --- a/drivers/gpu/nvgpu/common/pmu/therm/thrmdev.c +++ b/drivers/gpu/nvgpu/common/pmu/therm/thrmdev.c @@ -32,6 +32,12 @@ #include "thrmdev.h" #include "thrm.h" +bool nvgpu_therm_dev_idx_is_valid(struct therm_pmupstate *therm_pmu, u8 idx) +{ + return boardobjgrp_idxisvalid( + &(therm_pmu->therm_deviceobjs.super.super), idx); +} + static int _therm_device_pmudata_instget(struct gk20a *g, struct nv_pmu_boardobjgrp *pmuboardobjgrp, struct nv_pmu_boardobj **ppboardobjpmudata, diff --git a/drivers/gpu/nvgpu/common/pmu/therm/thrmdev.h b/drivers/gpu/nvgpu/common/pmu/therm/thrmdev.h index 0837087dc..8bbe57b6f 100644 --- a/drivers/gpu/nvgpu/common/pmu/therm/thrmdev.h +++ b/drivers/gpu/nvgpu/common/pmu/therm/thrmdev.h @@ -1,7 +1,7 @@ /* * general thermal device structures & definitions * - * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2019, 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"), @@ -58,5 +58,6 @@ struct therm_device_hbm2_combined { }; int therm_device_sw_setup(struct gk20a *g); +bool nvgpu_therm_dev_idx_is_valid(struct therm_pmupstate *therm_pmu, u8 idx); #endif /* NVGPU_THERM_THRMDEV_H */