amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu/soc15: fix nullptr issue in soc15_read_register() for reg base accessing
@ 2020-06-08  7:34 Prike.Liang
  2020-06-08 14:51 ` Deucher, Alexander
  0 siblings, 1 reply; 2+ messages in thread
From: Prike.Liang @ 2020-06-08  7:34 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alexander.Deucher, Prike.Liang, ray.huang

The failed case is no SDMA1 IP for Renoir discovery table while in accessing SDMA1 reg base,
thus need have nullptr test for soc15_read_register invoked in MMR addres space inqure opt.

Signed-off-by: Prike.Liang <Prike.Liang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 623745b..3e406ee 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -415,7 +415,8 @@ static int soc15_read_register(struct amdgpu_device *adev, u32 se_num,
 	*value = 0;
 	for (i = 0; i < ARRAY_SIZE(soc15_allowed_read_registers); i++) {
 		en = &soc15_allowed_read_registers[i];
-		if (reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
+		if (adev->reg_offset[en->hwip][en->inst] &&
+			reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
 					+ en->reg_offset))
 			continue;
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu/soc15: fix nullptr issue in soc15_read_register() for reg base accessing
  2020-06-08  7:34 [PATCH] drm/amdgpu/soc15: fix nullptr issue in soc15_read_register() for reg base accessing Prike.Liang
@ 2020-06-08 14:51 ` Deucher, Alexander
  0 siblings, 0 replies; 2+ messages in thread
From: Deucher, Alexander @ 2020-06-08 14:51 UTC (permalink / raw)
  To: Liang, Prike, amd-gfx; +Cc: Huang, Ray


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

[AMD Public Use]

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
________________________________
From: Liang, Prike <Prike.Liang@amd.com>
Sent: Monday, June 8, 2020 3:34 AM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Huang, Ray <Ray.Huang@amd.com>; Liang, Prike <Prike.Liang@amd.com>
Subject: [PATCH] drm/amdgpu/soc15: fix nullptr issue in soc15_read_register() for reg base accessing

The failed case is no SDMA1 IP for Renoir discovery table while in accessing SDMA1 reg base,
thus need have nullptr test for soc15_read_register invoked in MMR addres space inqure opt.

Signed-off-by: Prike.Liang <Prike.Liang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c
index 623745b..3e406ee 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -415,7 +415,8 @@ static int soc15_read_register(struct amdgpu_device *adev, u32 se_num,
         *value = 0;
         for (i = 0; i < ARRAY_SIZE(soc15_allowed_read_registers); i++) {
                 en = &soc15_allowed_read_registers[i];
-               if (reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
+               if (adev->reg_offset[en->hwip][en->inst] &&
+                       reg_offset != (adev->reg_offset[en->hwip][en->inst][en->seg]
                                         + en->reg_offset))
                         continue;

--
2.7.4


[-- Attachment #1.2: Type: text/html, Size: 3420 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2020-06-08 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08  7:34 [PATCH] drm/amdgpu/soc15: fix nullptr issue in soc15_read_register() for reg base accessing Prike.Liang
2020-06-08 14:51 ` Deucher, Alexander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).