Re: [PATCH 3/3] RDMA/hfi1: Use RMW accessors for changing LNKCTL2

2024-05-05 Thread Leon Romanovsky
On Fri, May 03, 2024 at 10:04:16AM -0300, Jason Gunthorpe wrote:
> On Fri, May 03, 2024 at 01:18:35PM +0300, Ilpo Järvinen wrote:
> > On Thu, 15 Feb 2024, Ilpo Järvinen wrote:
> > 
> > > Convert open coded RMW accesses for LNKCTL2 to use
> > > pcie_capability_clear_and_set_word() which makes its easier to
> > > understand what the code tries to do.
> > > 
> > > LNKCTL2 is not really owned by any driver because it is a collection of
> > > control bits that PCI core might need to touch. RMW accessors already
> > > have support for proper locking for a selected set of registers
> > > (LNKCTL2 is not yet among them but likely will be in the future) to
> > > avoid losing concurrent updates.
> > > 
> > > Suggested-by: Lukas Wunner 
> > > Signed-off-by: Ilpo Järvinen 
> > > Reviewed-by: Dean Luick 
> > 
> > I found out from Linux RDMA and InfiniBand patchwork that this patch had 
> > been silently closed as "Not Applicable". Is there some reason for
> > that?
> 
> It is part of a series that crosses subsystems, series like that
> usually go through some other trees.

Exactly, this is why I marked it as "Not Applicable".

> 
> If you want single patches applied then please send single
> patches.. It is hard to understand intent from mixed series.
> 
> Jason


[PATCH] drm/amd/amdxcp: Fix warnings

2024-05-05 Thread Lijo Lazar
Range of possible values of pdev_num is 0-63. Use int8_t as data type.
That also fixes below warnings:

>> drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c:59:58: warning: '%d'
>> directive output may be truncated writing between 1 and 11 bytes into
>> a region of size 9 [-Wformat-truncation=]
  59 | snprintf(dev_name, sizeof(dev_name), "amdgpu_xcp_%d", 
pdev_num);
 |  ^~
   drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c:59:46: note: directive argument 
in the range [-2147483648, 63]
  59 | snprintf(dev_name, sizeof(dev_name), "amdgpu_xcp_%d", 
pdev_num);
 |  ^~~
   drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c:59:9: note: 'snprintf' output 
between 13 and 23 bytes into a destination of size 20
  59 | snprintf(dev_name, sizeof(dev_name), "amdgpu_xcp_%d", 
pdev_num);
 | 
^~~

Fixes: f3b4c9a2746c ("drm/amd/amdxcp: Use unique name for partition dev")
Signed-off-by: Lijo Lazar 
Reported-by: kernel test robot 
---
 drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c 
b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c
index b4131053b31b..faed84172dd4 100644
--- a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c
+++ b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c
@@ -43,7 +43,7 @@ static const struct drm_driver amdgpu_xcp_driver = {
.minor = 0,
 };
 
-static int pdev_num;
+static int8_t pdev_num;
 static struct xcp_device *xcp_dev[MAX_XCP_PLATFORM_DEVICE];
 
 int amdgpu_xcp_drm_dev_alloc(struct drm_device **ddev)
-- 
2.25.1



RE: [PATCH] drm/amd/amdxcp: Fix warnings

2024-05-05 Thread Zhang, Hawking
[AMD Official Use Only - General]

Reviewed-by: Hawking Zhang 

Regards,
Hawking
-Original Message-
From: Lazar, Lijo 
Sent: Monday, May 6, 2024 11:31
To: amd-gfx@lists.freedesktop.org
Cc: Zhang, Hawking ; Deucher, Alexander 
; kernel test robot 
Subject: [PATCH] drm/amd/amdxcp: Fix warnings

Range of possible values of pdev_num is 0-63. Use int8_t as data type.
That also fixes below warnings:

>> drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c:59:58: warning: '%d'
>> directive output may be truncated writing between 1 and 11 bytes into
>> a region of size 9 [-Wformat-truncation=]
  59 | snprintf(dev_name, sizeof(dev_name), "amdgpu_xcp_%d", 
pdev_num);
 |  ^~
   drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c:59:46: note: directive argument 
in the range [-2147483648, 63]
  59 | snprintf(dev_name, sizeof(dev_name), "amdgpu_xcp_%d", 
pdev_num);
 |  ^~~
   drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c:59:9: note: 'snprintf' output 
between 13 and 23 bytes into a destination of size 20
  59 | snprintf(dev_name, sizeof(dev_name), "amdgpu_xcp_%d", 
pdev_num);
 | 
^~~

Fixes: f3b4c9a2746c ("drm/amd/amdxcp: Use unique name for partition dev")
Signed-off-by: Lijo Lazar 
Reported-by: kernel test robot 
---
 drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c 
b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c
index b4131053b31b..faed84172dd4 100644
--- a/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c
+++ b/drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c
@@ -43,7 +43,7 @@ static const struct drm_driver amdgpu_xcp_driver = {
.minor = 0,
 };

-static int pdev_num;
+static int8_t pdev_num;
 static struct xcp_device *xcp_dev[MAX_XCP_PLATFORM_DEVICE];

 int amdgpu_xcp_drm_dev_alloc(struct drm_device **ddev)
--
2.25.1



[PATCH v2] drm/amdgpu: Fix out-of-bounds write warning

2024-05-05 Thread Ma Jun
Check the ring type value to fix the out-of-bounds
write warning

Signed-off-by: Ma Jun 
Suggested-by: Christian König 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
index 15c240656470..ad49cecb20b8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
@@ -352,7 +352,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct 
amdgpu_ring *ring,
ring->max_dw = max_dw;
ring->hw_prio = hw_prio;
 
-   if (!ring->no_scheduler) {
+   if (!ring->no_scheduler && ring->funcs->type < AMDGPU_HW_IP_NUM) {
hw_ip = ring->funcs->type;
num_sched = &adev->gpu_sched[hw_ip][hw_prio].num_scheds;
adev->gpu_sched[hw_ip][hw_prio].sched[(*num_sched)++] =
-- 
2.34.1



[PATCH 1/3] drm/amdgpu: fix uninitialized variable warning for sdma_v7

2024-05-05 Thread Tim Huang
Clear warning that using uninitialized variable index.

Signed-off-by: Tim Huang 
---
 drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c 
b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
index 35d99a4afe83..0b5af1c50461 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c
@@ -876,7 +876,8 @@ static int sdma_v7_0_ring_test_ring(struct amdgpu_ring 
*ring)
r = amdgpu_ring_alloc(ring, 5);
if (r) {
DRM_ERROR("amdgpu: dma failed to lock ring %d (%d).\n", 
ring->idx, r);
-   amdgpu_device_wb_free(adev, index);
+   if (!ring->is_mes_queue)
+   amdgpu_device_wb_free(adev, index);
return r;
}
 
-- 
2.39.2



[PATCH 2/3] drm/amdgpu: fix uninitialized variable warning for amdgpu_xgmi

2024-05-05 Thread Tim Huang
Clear warning that using uninitialized variable current_node.

Signed-off-by: Tim Huang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index dd2ec48cf5c2..4a14f9c1bfe8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -434,6 +434,9 @@ static ssize_t amdgpu_xgmi_show_connected_port_num(struct 
device *dev,
}
}
 
+   if (i == top->num_nodes)
+   return -EINVAL;
+
for (i = 0; i < top->num_nodes; i++) {
for (j = 0; j < top->nodes[i].num_links; j++)
/* node id in sysfs starts from 1 rather than 0 so +1 
here */
-- 
2.39.2



[PATCH 3/3] drm/amdgpu: fix uninitialized variable warning for jpeg_v4

2024-05-05 Thread Tim Huang
Clear warning that using uninitialized variable r.

Signed-off-by: Tim Huang 
---
 drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c 
b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c
index da6bb9022b80..4c8f9772437b 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_5.c
@@ -187,7 +187,7 @@ static int jpeg_v4_0_5_hw_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct amdgpu_ring *ring;
-   int r, i;
+   int i, r = 0;
 
// TODO: Enable ring test with DPG support
if (adev->pg_flags & AMD_PG_SUPPORT_JPEG_DPG) {
-- 
2.39.2



RE: [PATCH] drm/amd/pm: fix the uninitialized scalar variable warning

2024-05-05 Thread Zhang, Jesse(Jie)
[AMD Official Use Only - General]

Ping ...

-Original Message-
From: Jesse Zhang 
Sent: Tuesday, April 30, 2024 3:14 PM
To: amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; Koenig, Christian 
; Huang, Tim ; Zhang, Jesse(Jie) 
; Zhang, Jesse(Jie) 
Subject: [PATCH] drm/amd/pm: fix the uninitialized scalar variable warning

Fix warning for using uninitialized values sclk_mask, mclk_mask and soc_mask.
v2:Set default variable to UMD PSTATE(Tim Huang)

Signed-off-by: Jesse Zhang 
---
 .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c   | 32 ---
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
index 8908bbb3ff1f..36a49cfc22e4 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
@@ -835,10 +835,20 @@ static int renoir_force_clk_levels(struct smu_context 
*smu,
ret = renoir_get_dpm_clk_limited(smu, clk_type, soft_max_level, 
&max_freq);
if (ret)
return ret;
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetSoftMaxSocclkByFreq, max_freq, NULL);
+/* =  0: min_freq
+ * =  1: UMD_PSTATE_CLK
+ * >= 2: max_freq
+ */
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetSoftMaxSocclkByFreq,
+   soft_max_level == 0 ? 
min_freq :
+   soft_max_level == 1 ? 
RENOIR_UMD_PSTATE_SOCCLK : max_freq,
+   NULL);
if (ret)
return ret;
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetHardMinSocclkByFreq, min_freq, NULL);
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetHardMinSocclkByFreq,
+   soft_min_level == 0 ? 
min_freq :
+   soft_min_level == 1 ? 
RENOIR_UMD_PSTATE_SOCCLK : max_freq,
+   NULL);
if (ret)
return ret;
break;
@@ -850,10 +860,21 @@ static int renoir_force_clk_levels(struct smu_context 
*smu,
ret = renoir_get_dpm_clk_limited(smu, clk_type, soft_max_level, 
&max_freq);
if (ret)
return ret;
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetSoftMaxFclkByFreq, max_freq, NULL);
+   /* mclk levels are in reverse order
+* =  0: max_freq
+* =  1: UMD_PSTATE_CLK
+* >= 2: min_freq
+*/
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetSoftMaxFclkByFreq,
+   soft_max_level >= 2 ? 
min_freq :
+   soft_max_level == 1 ? 
RENOIR_UMD_PSTATE_FCLK : max_freq,
+   NULL);
if (ret)
return ret;
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetHardMinFclkByFreq, min_freq, NULL);
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetHardMinFclkByFreq,
+   soft_min_level >= 2  ? 
min_freq :
+   soft_min_level == 1 ? 
RENOIR_UMD_PSTATE_SOCCLK : max_freq,
+   NULL);
if (ret)
return ret;
break;
@@ -932,7 +953,8 @@ static int renoir_set_performance_level(struct smu_context 
*smu,
enum amd_dpm_forced_level level)
 {
int ret = 0;
-   uint32_t sclk_mask, mclk_mask, soc_mask;
+   /* default mask is UMD PSTATE CLK */
+   uint32_t sclk_mask = 1, mclk_mask = 1, soc_mask = 1;

switch (level) {
case AMD_DPM_FORCED_LEVEL_HIGH:
--
2.25.1



RE: [PATCH] drm/amd/pm: fix the uninitialized scalar variable warning

2024-05-05 Thread Wang, Yang(Kevin)
[AMD Official Use Only - General]

Acked-by: Yang Wang 

Best Regards,
Kevin

-Original Message-
From: amd-gfx  On Behalf Of Zhang, 
Jesse(Jie)
Sent: 2024年5月6日 14:21
To: Zhang, Jesse(Jie) ; amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; Koenig, Christian 
; Huang, Tim 
Subject: RE: [PATCH] drm/amd/pm: fix the uninitialized scalar variable warning

[AMD Official Use Only - General]

[AMD Official Use Only - General]

Ping ...

-Original Message-
From: Jesse Zhang 
Sent: Tuesday, April 30, 2024 3:14 PM
To: amd-gfx@lists.freedesktop.org
Cc: Deucher, Alexander ; Koenig, Christian 
; Huang, Tim ; Zhang, Jesse(Jie) 
; Zhang, Jesse(Jie) 
Subject: [PATCH] drm/amd/pm: fix the uninitialized scalar variable warning

Fix warning for using uninitialized values sclk_mask, mclk_mask and soc_mask.
v2:Set default variable to UMD PSTATE(Tim Huang)

Signed-off-by: Jesse Zhang 
---
 .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c   | 32 ---
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c 
b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
index 8908bbb3ff1f..36a49cfc22e4 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
@@ -835,10 +835,20 @@ static int renoir_force_clk_levels(struct smu_context 
*smu,
ret = renoir_get_dpm_clk_limited(smu, clk_type, soft_max_level, 
&max_freq);
if (ret)
return ret;
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetSoftMaxSocclkByFreq, max_freq, NULL);
+/* =  0: min_freq
+ * =  1: UMD_PSTATE_CLK
+ * >= 2: max_freq
+ */
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetSoftMaxSocclkByFreq,
+   soft_max_level == 0 ? 
min_freq :
+   soft_max_level == 1 ? 
RENOIR_UMD_PSTATE_SOCCLK : max_freq,
+   NULL);
if (ret)
return ret;
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetHardMinSocclkByFreq, min_freq, NULL);
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetHardMinSocclkByFreq,
+   soft_min_level == 0 ? 
min_freq :
+   soft_min_level == 1 ? 
RENOIR_UMD_PSTATE_SOCCLK : max_freq,
+   NULL);
if (ret)
return ret;
break;
@@ -850,10 +860,21 @@ static int renoir_force_clk_levels(struct smu_context 
*smu,
ret = renoir_get_dpm_clk_limited(smu, clk_type, soft_max_level, 
&max_freq);
if (ret)
return ret;
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetSoftMaxFclkByFreq, max_freq, NULL);
+   /* mclk levels are in reverse order
+* =  0: max_freq
+* =  1: UMD_PSTATE_CLK
+* >= 2: min_freq
+*/
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetSoftMaxFclkByFreq,
+   soft_max_level >= 2 ? 
min_freq :
+   soft_max_level == 1 ? 
RENOIR_UMD_PSTATE_FCLK : max_freq,
+   NULL);
if (ret)
return ret;
-   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetHardMinFclkByFreq, min_freq, NULL);
+   ret = smu_cmn_send_smc_msg_with_param(smu, 
SMU_MSG_SetHardMinFclkByFreq,
+   soft_min_level >= 2  ? 
min_freq :
+   soft_min_level == 1 ? 
RENOIR_UMD_PSTATE_SOCCLK : max_freq,
+   NULL);
if (ret)
return ret;
break;
@@ -932,7 +953,8 @@ static int renoir_set_performance_level(struct smu_context 
*smu,
enum amd_dpm_forced_level level)  {
int ret = 0;
-   uint32_t sclk_mask, mclk_mask, soc_mask;
+   /* default mask is UMD PSTATE CLK */
+   uint32_t sclk_mask = 1, mclk_mask = 1, soc_mask = 1;

switch (level) {
case AMD_DPM_FORCED_LEVEL_HIGH:
--
2.25.1

<>

[PATCH] drm/amdgpu: ignoring unsupported ras blocks when MCA bank dispatches

2024-05-05 Thread Yang Wang
This patch is used to solve the problem of incorrect parsing of error counts.
When the UE trigger gpu is reset, the driver will attempt to parse all possible 
ras blocks.
For ras blocks that are not supported by the current ASIC, the driver should 
ignore this error.

Signed-off-by: Yang Wang 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c
index a7736aa58ba9..0c9a271c5028 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mca.c
@@ -415,7 +415,7 @@ static int amdgpu_mca_dispatch_mca_set(struct amdgpu_device 
*adev, enum amdgpu_r
 
count = 0;
ret = amdgpu_mca_smu_parse_mca_error_count(adev, blk, type, 
entry, &count);
-   if (ret)
+   if (ret && ret != -EOPNOTSUPP)
return ret;
 
if (!count)
-- 
2.34.1