* [bug report] drm/amd/powerplay: add vce state tables initialize for ppt v1.
@ 2016-10-13 13:25 Dan Carpenter
2016-10-17 10:37 ` Zhu, Rex
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2016-10-13 13:25 UTC (permalink / raw)
To: Rex.Zhu; +Cc: dri-devel
Hello Rex Zhu,
The patch 48d7b759a8bc: "drm/amd/powerplay: add vce state tables
initialize for ppt v1." from Aug 31, 2016, leads to the following
static checker warning:
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/process_pptables_v1_0.c:1211 ppt_get_num_of_vce_state_table_entries_v1_0()
warn: 'vce_state_table' can't be NULL.
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/process_pptables_v1_0.c
1200
1201 static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr)
1202 {
1203 const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr);
1204 const ATOM_Tonga_VCE_State_Table *vce_state_table =
1205 (ATOM_Tonga_VCE_State_Table *)(((unsigned long)pp_table) + le16_to_cpu(pp_table->usVCEStateTableOffset));
^^^^^^^^
pp_table can't be NULL because we're dereferencing it here. That
means vce_state_table can't be NULL either.
1206
1207 if (vce_state_table == NULL)
1208 return 0;
1209
1210 return vce_state_table->ucNumEntries;
1211 }
1212
A cleaner way to write this is maybe:
static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr)
{
const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr);
const ATOM_Tonga_VCE_State_Table *vce_state_table;
if (!pp_table)
return 0;
vce_state_table = (void *)pp_table + le16_to_cpu(pp_table->usVCEStateTableOffset);
return vce_state_table->ucNumEntries;
}
regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [bug report] drm/amd/powerplay: add vce state tables initialize for ppt v1.
2016-10-13 13:25 [bug report] drm/amd/powerplay: add vce state tables initialize for ppt v1 Dan Carpenter
@ 2016-10-17 10:37 ` Zhu, Rex
2016-10-17 14:16 ` Christian König
0 siblings, 1 reply; 3+ messages in thread
From: Zhu, Rex @ 2016-10-17 10:37 UTC (permalink / raw)
To: Dan Carpenter; +Cc: dri-devel@lists.freedesktop.org
[-- Attachment #1: Type: text/plain, Size: 2015 bytes --]
Thanks, please help to review the attached patch.
Best Regards
Rex
-----Original Message-----
From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
Sent: Thursday, October 13, 2016 9:26 PM
To: Zhu, Rex
Cc: dri-devel@lists.freedesktop.org
Subject: [bug report] drm/amd/powerplay: add vce state tables initialize for ppt v1.
Hello Rex Zhu,
The patch 48d7b759a8bc: "drm/amd/powerplay: add vce state tables initialize for ppt v1." from Aug 31, 2016, leads to the following static checker warning:
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/process_pptables_v1_0.c:1211 ppt_get_num_of_vce_state_table_entries_v1_0()
warn: 'vce_state_table' can't be NULL.
drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/process_pptables_v1_0.c
1200
1201 static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr)
1202 {
1203 const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr);
1204 const ATOM_Tonga_VCE_State_Table *vce_state_table =
1205 (ATOM_Tonga_VCE_State_Table *)(((unsigned long)pp_table) + le16_to_cpu(pp_table->usVCEStateTableOffset));
^^^^^^^^ pp_table can't be NULL because we're dereferencing it here. That means vce_state_table can't be NULL either.
1206
1207 if (vce_state_table == NULL)
1208 return 0;
1209
1210 return vce_state_table->ucNumEntries;
1211 }
1212
A cleaner way to write this is maybe:
static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr) {
const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr);
const ATOM_Tonga_VCE_State_Table *vce_state_table;
if (!pp_table)
return 0;
vce_state_table = (void *)pp_table + le16_to_cpu(pp_table->usVCEStateTableOffset);
return vce_state_table->ucNumEntries;
}
regards,
dan carpenter
[-- Attachment #2: 0001-drm-amd-powerplay-fix-static-checker-warning-in-proc.patch --]
[-- Type: application/octet-stream, Size: 1439 bytes --]
From f5691bb487b4edfd7e9735e760162c0a216034c0 Mon Sep 17 00:00:00 2001
From: Rex Zhu <Rex.Zhu@amd.com>
Date: Mon, 17 Oct 2016 18:15:26 +0800
Subject: [PATCH] drm/amd/powerplay: fix static checker warning in
process_pptables_v1_0.c
Change-Id: Id1a43326c547cf0e2b83b8ee02318e2a2b80b182
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
index b0b5f3a..7925185 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
@@ -1202,12 +1202,15 @@ static uint32_t make_classification_flags(struct pp_hwmgr *hwmgr,
static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr)
{
const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr);
- const ATOM_Tonga_VCE_State_Table *vce_state_table =
- (ATOM_Tonga_VCE_State_Table *)(((unsigned long)pp_table) + le16_to_cpu(pp_table->usVCEStateTableOffset));
+ const ATOM_Tonga_VCE_State_Table *vce_state_table;
- if (vce_state_table == NULL)
+
+ if (pp_table == NULL)
return 0;
+ vce_state_table = (void *)pp_table +
+ le16_to_cpu(pp_table->usVCEStateTableOffset);
+
return vce_state_table->ucNumEntries;
}
--
1.9.1
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [bug report] drm/amd/powerplay: add vce state tables initialize for ppt v1.
2016-10-17 10:37 ` Zhu, Rex
@ 2016-10-17 14:16 ` Christian König
0 siblings, 0 replies; 3+ messages in thread
From: Christian König @ 2016-10-17 14:16 UTC (permalink / raw)
To: Zhu, Rex, Dan Carpenter; +Cc: dri-devel@lists.freedesktop.org
[-- Attachment #1.1: Type: text/plain, Size: 2335 bytes --]
Reviewed-by: Christian König <christian.koenig@amd.com>.
Am 17.10.2016 um 12:37 schrieb Zhu, Rex:
> Thanks, please help to review the attached patch.
>
> Best Regards
> Rex
>
> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> Sent: Thursday, October 13, 2016 9:26 PM
> To: Zhu, Rex
> Cc: dri-devel@lists.freedesktop.org
> Subject: [bug report] drm/amd/powerplay: add vce state tables initialize for ppt v1.
>
> Hello Rex Zhu,
>
> The patch 48d7b759a8bc: "drm/amd/powerplay: add vce state tables initialize for ppt v1." from Aug 31, 2016, leads to the following static checker warning:
>
> drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/process_pptables_v1_0.c:1211 ppt_get_num_of_vce_state_table_entries_v1_0()
> warn: 'vce_state_table' can't be NULL.
>
> drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/process_pptables_v1_0.c
> 1200
> 1201 static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr)
> 1202 {
> 1203 const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr);
> 1204 const ATOM_Tonga_VCE_State_Table *vce_state_table =
> 1205 (ATOM_Tonga_VCE_State_Table *)(((unsigned long)pp_table) + le16_to_cpu(pp_table->usVCEStateTableOffset));
> ^^^^^^^^ pp_table can't be NULL because we're dereferencing it here. That means vce_state_table can't be NULL either.
>
> 1206
> 1207 if (vce_state_table == NULL)
> 1208 return 0;
> 1209
> 1210 return vce_state_table->ucNumEntries;
> 1211 }
> 1212
>
> A cleaner way to write this is maybe:
>
> static int ppt_get_num_of_vce_state_table_entries_v1_0(struct pp_hwmgr *hwmgr) {
> const ATOM_Tonga_POWERPLAYTABLE *pp_table = get_powerplay_table(hwmgr);
> const ATOM_Tonga_VCE_State_Table *vce_state_table;
>
> if (!pp_table)
> return 0;
>
> vce_state_table = (void *)pp_table + le16_to_cpu(pp_table->usVCEStateTableOffset);
> return vce_state_table->ucNumEntries;
> }
>
> regards,
> dan carpenter
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
[-- Attachment #1.2: Type: text/html, Size: 3194 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-17 14:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-13 13:25 [bug report] drm/amd/powerplay: add vce state tables initialize for ppt v1 Dan Carpenter
2016-10-17 10:37 ` Zhu, Rex
2016-10-17 14:16 ` Christian König
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.