All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.
@ 2016-10-12  6:11 Dan Carpenter
  2016-10-13  7:43 ` Zhu, Rex
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2016-10-12  6:11 UTC (permalink / raw)
  To: Rex.Zhu; +Cc: dri-devel

Hello Rex Zhu,

This is a semi-automatic email about new static checker warnings.

The patch 599a7e9fe1b6: "drm/amd/powerplay: implement smu7 hwmgr to 
manager asics with smu ip version 7." from Sep 9, 2016, leads to the 
following Smatch complaint:

drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c:1463 smu7_get_evv_voltages()
	 error: we previously assumed 'table_info' could be null (see line 1455)

drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c
  1454	
  1455		if (table_info != NULL)
                     ^^^^^^^^^^^^^^^^^
Check for non-NULL.

  1456			sclk_table = table_info->vdd_dep_on_sclk;
  1457	
  1458		for (i = 0; i < SMU7_MAX_LEAKAGE_COUNT; i++) {
  1459			vv_id = ATOM_VIRTUAL_VOLTAGE_ID0 + i;
  1460	
  1461			if (data->vdd_gfx_control == SMU7_VOLTAGE_CONTROL_BY_SVID2) {
  1462				if (0 == phm_get_sclk_for_voltage_evv(hwmgr,
  1463							table_info->vddgfx_lookup_table, vv_id, &sclk)) {
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unchecked dereference.

  1464					if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
  1465								PHM_PlatformCaps_ClockStretcher)) {

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] 6+ messages in thread

* RE: [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.
  2016-10-12  6:11 [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7 Dan Carpenter
@ 2016-10-13  7:43 ` Zhu, Rex
  2016-10-13  7:50   ` Christian König
  0 siblings, 1 reply; 6+ messages in thread
From: Zhu, Rex @ 2016-10-13  7:43 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: dri-devel

[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]


Please Review.

Best Regards
Rex

-----Original Message-----
From: Dan Carpenter [mailto:dan.carpenter@oracle.com] 
Sent: Wednesday, October 12, 2016 2:12 PM
To: Zhu, Rex
Cc: dri-devel@lists.freedesktop.org
Subject: [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.

Hello Rex Zhu,

This is a semi-automatic email about new static checker warnings.

The patch 599a7e9fe1b6: "drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7." from Sep 9, 2016, leads to the following Smatch complaint:

drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c:1463 smu7_get_evv_voltages()
	 error: we previously assumed 'table_info' could be null (see line 1455)

drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c
  1454	
  1455		if (table_info != NULL)
                     ^^^^^^^^^^^^^^^^^
Check for non-NULL.

  1456			sclk_table = table_info->vdd_dep_on_sclk;
  1457	
  1458		for (i = 0; i < SMU7_MAX_LEAKAGE_COUNT; i++) {
  1459			vv_id = ATOM_VIRTUAL_VOLTAGE_ID0 + i;
  1460	
  1461			if (data->vdd_gfx_control == SMU7_VOLTAGE_CONTROL_BY_SVID2) {
  1462				if (0 == phm_get_sclk_for_voltage_evv(hwmgr,
  1463							table_info->vddgfx_lookup_table, vv_id, &sclk)) {
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unchecked dereference.

  1464					if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
  1465								PHM_PlatformCaps_ClockStretcher)) {

regards,
dan carpenter

[-- Attachment #2: 0001-drm-amd-powerplay-fix-static-checker-warnings-in-smu.patch --]
[-- Type: application/octet-stream, Size: 1105 bytes --]

From 77a2ee4069658df398534eb669a31ace444f0955 Mon Sep 17 00:00:00 2001
From: Rex Zhu <Rex.Zhu@amd.com>
Date: Thu, 13 Oct 2016 15:32:04 +0800
Subject: [PATCH] drm/amd/powerplay: fix static checker warnings in
 smu7_hwmgr.c

Change-Id: Icefccdecd7a2434047389e4766e69077647d206f
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 49f35c7..ca0413a 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -1474,8 +1474,10 @@ static int smu7_get_evv_voltages(struct pp_hwmgr *hwmgr)
 	struct phm_ppt_v1_clock_voltage_dependency_table *sclk_table = NULL;
 
 
-	if (table_info != NULL)
-		sclk_table = table_info->vdd_dep_on_sclk;
+	if (table_info == NULL)
+		return -EINVAL;
+
+	sclk_table = table_info->vdd_dep_on_sclk;
 
 	for (i = 0; i < SMU7_MAX_LEAKAGE_COUNT; i++) {
 		vv_id = ATOM_VIRTUAL_VOLTAGE_ID0 + i;
-- 
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] 6+ messages in thread

* Re: [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.
  2016-10-13  7:43 ` Zhu, Rex
@ 2016-10-13  7:50   ` Christian König
  0 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2016-10-13  7:50 UTC (permalink / raw)
  To: Zhu, Rex, Dan Carpenter; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1888 bytes --]

Patch is Reviewed-by: Christian König <christian.koenig@amd.com>.

Regards,
Christian.

Am 13.10.2016 um 09:43 schrieb Zhu, Rex:
> Please Review.
>
> Best Regards
> Rex
>
> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> Sent: Wednesday, October 12, 2016 2:12 PM
> To: Zhu, Rex
> Cc: dri-devel@lists.freedesktop.org
> Subject: [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.
>
> Hello Rex Zhu,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 599a7e9fe1b6: "drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7." from Sep 9, 2016, leads to the following Smatch complaint:
>
> drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c:1463 smu7_get_evv_voltages()
> 	 error: we previously assumed 'table_info' could be null (see line 1455)
>
> drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c
>    1454	
>    1455		if (table_info != NULL)
>                       ^^^^^^^^^^^^^^^^^
> Check for non-NULL.
>
>    1456			sclk_table = table_info->vdd_dep_on_sclk;
>    1457	
>    1458		for (i = 0; i < SMU7_MAX_LEAKAGE_COUNT; i++) {
>    1459			vv_id = ATOM_VIRTUAL_VOLTAGE_ID0 + i;
>    1460	
>    1461			if (data->vdd_gfx_control == SMU7_VOLTAGE_CONTROL_BY_SVID2) {
>    1462				if (0 == phm_get_sclk_for_voltage_evv(hwmgr,
>    1463							table_info->vddgfx_lookup_table, vv_id, &sclk)) {
>                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unchecked dereference.
>
>    1464					if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
>    1465								PHM_PlatformCaps_ClockStretcher)) {
>
> 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: 2795 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] 6+ messages in thread

* RE: [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.
  2016-10-14 15:13 ` Alex Deucher
@ 2016-10-17 10:17   ` Zhu, Rex
  0 siblings, 0 replies; 6+ messages in thread
From: Zhu, Rex @ 2016-10-17 10:17 UTC (permalink / raw)
  To: Alex Deucher, Dan Carpenter; +Cc: Maling list - DRI developers

Thanks, Alex.

Patch was Reviewed-by: Rex Zhu <Rex.Zhu@amd.com>


Best Regards
Rex

-----Original Message-----
From: Alex Deucher [mailto:alexdeucher@gmail.com] 
Sent: Friday, October 14, 2016 11:14 PM
To: Dan Carpenter
Cc: Zhu, Rex; Maling list - DRI developers
Subject: Re: [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.

On Fri, Oct 14, 2016 at 10:32 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Hello Rex Zhu,
>
> The patch 599a7e9fe1b6: "drm/amd/powerplay: implement smu7 hwmgr to 
> manager asics with smu ip version 7." from Sep 9, 2016, leads to the 
> following static checker warning:
>
>         drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c:2125 smu7_patch_limits_vddc()
>         warn: passing casted pointer '&tab->vddc' to 'smu7_patch_ppt_v0_with_vdd_leakage()' 16 vs 32.
>
> drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c
>   2119  static int smu7_patch_limits_vddc(struct pp_hwmgr *hwmgr,
>   2120                                       struct phm_clock_and_voltage_limits *tab)
>   2121  {
>   2122          struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
>   2123
>   2124          if (tab) {
>   2125                  smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddc,
>   2126                                                          &data->vddc_leakage);
>
> This call corrupts vddci.
>
>   2127                  smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddci,
>   2128                                                          &data->vddci_leakage);
>
> But that's fine since we immediately overwrite it here.  But 
> unfortunately this call corrupt tab->vddgfx.

Thanks.  Should be fixed in the attached patch.

Alex

>
>   2129          }
>   2130
>   2131          return 0;
>   2132  }
>
> regards,
> dan carpenter
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.
  2016-10-14 14:32 Dan Carpenter
@ 2016-10-14 15:13 ` Alex Deucher
  2016-10-17 10:17   ` Zhu, Rex
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Deucher @ 2016-10-14 15:13 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Rex Zhu, Maling list - DRI developers

[-- Attachment #1: Type: text/plain, Size: 1666 bytes --]

On Fri, Oct 14, 2016 at 10:32 AM, Dan Carpenter
<dan.carpenter@oracle.com> wrote:
> Hello Rex Zhu,
>
> The patch 599a7e9fe1b6: "drm/amd/powerplay: implement smu7 hwmgr to
> manager asics with smu ip version 7." from Sep 9, 2016, leads to the
> following static checker warning:
>
>         drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c:2125 smu7_patch_limits_vddc()
>         warn: passing casted pointer '&tab->vddc' to 'smu7_patch_ppt_v0_with_vdd_leakage()' 16 vs 32.
>
> drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c
>   2119  static int smu7_patch_limits_vddc(struct pp_hwmgr *hwmgr,
>   2120                                       struct phm_clock_and_voltage_limits *tab)
>   2121  {
>   2122          struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
>   2123
>   2124          if (tab) {
>   2125                  smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddc,
>   2126                                                          &data->vddc_leakage);
>
> This call corrupts vddci.
>
>   2127                  smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddci,
>   2128                                                          &data->vddci_leakage);
>
> But that's fine since we immediately overwrite it here.  But
> unfortunately this call corrupt tab->vddgfx.

Thanks.  Should be fixed in the attached patch.

Alex

>
>   2129          }
>   2130
>   2131          return 0;
>   2132  }
>
> regards,
> dan carpenter
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[-- Attachment #2: 0001-drm-amdgpu-powerplay-smu7-fix-static-checker-warning.patch --]
[-- Type: text/x-patch, Size: 1557 bytes --]

From 2e94250b99ceb556335a34a01ea9d36cd9ce6cec Mon Sep 17 00:00:00 2001
From: Alex Deucher <alexander.deucher@amd.com>
Date: Fri, 14 Oct 2016 11:11:06 -0400
Subject: [PATCH] drm/amdgpu/powerplay/smu7: fix static checker warning

Casting of voltage values to a larger size results in
overwriting adjacent memory in the structure.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 7fba97e..11df7b2 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -2133,15 +2133,18 @@ static int smu7_patch_acp_vddc(struct pp_hwmgr *hwmgr,
 }
 
 static int smu7_patch_limits_vddc(struct pp_hwmgr *hwmgr,
-				     struct phm_clock_and_voltage_limits *tab)
+				  struct phm_clock_and_voltage_limits *tab)
 {
+	uint32_t vddc, vddci;
 	struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
 
 	if (tab) {
-		smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddc,
-							&data->vddc_leakage);
-		smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddci,
-							&data->vddci_leakage);
+		smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, &vddc,
+						   &data->vddc_leakage);
+		tab->vddc = vddc;
+		smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, &vddci,
+						   &data->vddci_leakage);
+		tab->vddci = vddci;
 	}
 
 	return 0;
-- 
2.5.5


[-- 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] 6+ messages in thread

* [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7.
@ 2016-10-14 14:32 Dan Carpenter
  2016-10-14 15:13 ` Alex Deucher
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2016-10-14 14:32 UTC (permalink / raw)
  To: Rex.Zhu; +Cc: dri-devel

Hello Rex Zhu,

The patch 599a7e9fe1b6: "drm/amd/powerplay: implement smu7 hwmgr to
manager asics with smu ip version 7." from Sep 9, 2016, leads to the
following static checker warning:

	drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c:2125 smu7_patch_limits_vddc()
	warn: passing casted pointer '&tab->vddc' to 'smu7_patch_ppt_v0_with_vdd_leakage()' 16 vs 32.

drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/smu7_hwmgr.c
  2119  static int smu7_patch_limits_vddc(struct pp_hwmgr *hwmgr,
  2120                                       struct phm_clock_and_voltage_limits *tab)
  2121  {
  2122          struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
  2123  
  2124          if (tab) {
  2125                  smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddc,
  2126                                                          &data->vddc_leakage);

This call corrupts vddci.

  2127                  smu7_patch_ppt_v0_with_vdd_leakage(hwmgr, (uint32_t *)&tab->vddci,
  2128                                                          &data->vddci_leakage);

But that's fine since we immediately overwrite it here.  But
unfortunately this call corrupt tab->vddgfx.

  2129          }
  2130  
  2131          return 0;
  2132  }

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] 6+ messages in thread

end of thread, other threads:[~2016-10-17 10:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12  6:11 [bug report] drm/amd/powerplay: implement smu7 hwmgr to manager asics with smu ip version 7 Dan Carpenter
2016-10-13  7:43 ` Zhu, Rex
2016-10-13  7:50   ` Christian König
2016-10-14 14:32 Dan Carpenter
2016-10-14 15:13 ` Alex Deucher
2016-10-17 10:17   ` Zhu, Rex

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.