drm/amdgpu/vcn: Remove unused assignment in vcn_v4_0_stop
Subsystems (2)
PATCH 1/1 drm/amdgpu/vcn: Remove unused assignment in vcn_v4_0_stop
The value assigned from vcn_v4_0_stop_dbg_mode to r is overwritten before it can be used. Remove this assignment.
Addresses-Coverity: 1504988 ("Unused value")
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1 -1
@@ -1154,7 +1154,7 @@ static int vcn_v4_0_stop(struct amdgpu_device *adev) fw_shared->sq.queue_mode |=FW_QUEUE_DPG_HOLD_OFF ;if (adev->pg_flags &AMD_PG_SUPPORT_VCN_DPG ) { - r =vcn_v4_0_stop_dpg_mode (adev, i); +vcn_v4_0_stop_dpg_mode (adev, i);continue ; }
Signature · 6 lines
2.37.1 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 15 lines · Khalid Masum
The value assigned from
vcn_v4_0_stop_dbg_modeto r is overwritten before it can be used. Remove this assignment.Addresses-Coverity: 1504988 ("Unused value")
Fixes 8da1170a16e4 ("drm/amdgpu: add VCN4 ip block support")Signed-off-by Khalid Masum<[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c static int vcn_v4_0_stop(struct amdgpu_device *adev) · line 1160
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1
-1@@ -1154,7 +1154,7 @@ static int vcn_v4_0_stop(struct amdgpu_device *adev) fw_shared->sq.queue_mode |=FW_QUEUE_DPG_HOLD_OFF ;if (adev->pg_flags &AMD_PG_SUPPORT_VCN_DPG ) { - r =vcn_v4_0_stop_dpg_mode (adev, i); +vcn_v4_0_stop_dpg_mode (adev, i);continue ; }
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
[AMD Official Use Only - General]
Sorry, which "r" value was overwritten? I didn't see the point of making this change.
Thanks
Ruijing
-----Original Message-----
From: Khalid Masum <[email protected]>
Sent: Monday, August 15, 2022 3:01 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Zhu, James <[email protected]>; Jiang, Sonny <[email protected]>; Dong, Ruijing <[email protected]>; Wan Jiabing <[email protected]>; Liu, Leo <[email protected]>; Khalid Masum <[email protected]>
Subject: [PATCH linux-next] drm/amdgpu/vcn: Remove unused assignment in vcn_v4_0_stop
The value assigned from vcn_v4_0_stop_dbg_mode to r is overwritten before it can be used. Remove this assignment.
Addresses-Coverity: 1504988 ("Unused value")
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1 -1
@@ -1154,7 +1154,7 @@ static int vcn_v4_0_stop(struct amdgpu_device *adev) fw_shared->sq.queue_mode |=FW_QUEUE_DPG_HOLD_OFF ;if (adev->pg_flags &AMD_PG_SUPPORT_VCN_DPG ) { - r =vcn_v4_0_stop_dpg_mode (adev, i); +vcn_v4_0_stop_dpg_mode (adev, i);continue ; }
--
2.37.1
Quoted 37 lines · Ruijing
[AMD Official Use Only - General]
Sorry, which "r" value was overwritten? I didn't see the point of making this change.
Thanks
Ruijing-----Original Message-----
From: Khalid Masum <[email protected]>
Sent: Monday, August 15, 2022 3:01 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Zhu, James <[email protected]>; Jiang, Sonny <[email protected]>; Dong, Ruijing <[email protected]>; Wan Jiabing <[email protected]>; Liu, Leo <[email protected]>; Khalid Masum <[email protected]>
Subject: [PATCH linux-next] drm/amdgpu/vcn: Remove unused assignment invcn_v4_0_stopThe value assigned from
vcn_v4_0_stop_dbg_modeto r is overwritten before it can be used. Remove this assignment.Addresses-Coverity: 1504988 ("Unused value")
Fixes 8da1170a16e4 ("drm/amdgpu: add VCN4 ip block support")Signed-off-by Khalid Masum <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1
-2@@ -1154,7 +1154,7 @@ static int vcn_v4_0_stop(struct amdgpu_device *adev) fw_shared->sq.queue_mode |=FW_QUEUE_DPG_HOLD_OFF ;if (adev->pg_flags &AMD_PG_SUPPORT_VCN_DPG ) { - r =vcn_v4_0_stop_dpg_mode (adev, i); +vcn_v4_0_stop_dpg_mode (adev, i);continue ; } --
Quoted 2 lines
2.37.1
After value is overwritten soon right after the diff.
See:drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
static int vcn_v4_0_stop(struct amdgpu_device *adev)
{
volatile struct amdgpu_vcn4_fw_shared *fw_shared;...
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
fw_shared = adev->vcn.inst[i].fw_shared.cpu_addr;
fw_shared->sq.queue_mode |= FW_QUEUE_DPG_HOLD_OFF;
if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) {
r = vcn_v4_0_stop_dpg_mode(adev, i);
continue;
}
/* wait for vcn idle */
r = SOC15_WAIT_ON_RREG(VCN, i, regUVD_STATUS, UVD_STATUS__IDLE, 0x7);
Here, any value assigned to r is overwritten before it could be used. So the assignment in the true branch of the if statement here can be removed.
Thanks,
-- Khalid Masum
[AMD Official Use Only - General]
If the condition was met and it came to execute vcn_4_0_stop_dpg_mode, then it would never have a chance to go for /*wait for vcn idle*/, isn't it? I still didn't see obvious purpose of this change.
if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) {
==> r = vcn_v4_0_stop_dpg_mode(adev, i);
continue;
}
/* wait for vcn idle */
r = SOC15_WAIT_ON_RREG(VCN, i, regUVD_STATUS, UVD_STATUS__IDLE, 0x7);Thanks
Ruijing
-----Original Message-----
From: Khalid Masum <[email protected]>
Sent: Monday, August 15, 2022 11:11 AM
To: Dong, Ruijing <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Zhu, James <[email protected]>; Jiang, Sonny <[email protected]>; Wan Jiabing <[email protected]>; Liu, Leo <[email protected]>
Subject: Re: [PATCH linux-next] drm/amdgpu/vcn: Remove unused assignment in vcn_v4_0_stop
Quoted 46 lines · Ruijing
[AMD Official Use Only - General]
Sorry, which "r" value was overwritten? I didn't see the point of making this change.
Thanks
Ruijing-----Original Message-----
From: Khalid Masum <[email protected]>
Sent: Monday, August 15, 2022 3:01 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Zhu, James <[email protected]>; Jiang, Sonny <[email protected]>; Dong, Ruijing <[email protected]>; Wan Jiabing <[email protected]>; Liu, Leo <[email protected]>; Khalid Masum <[email protected]>
Subject: [PATCH linux-next] drm/amdgpu/vcn: Remove unused assignment invcn_v4_0_stopThe value assigned from
vcn_v4_0_stop_dbg_modeto r is overwritten before it can be used. Remove this assignment.Addresses-Coverity: 1504988 ("Unused value")
Fixes 8da1170a16e4 ("drm/amdgpu: add VCN4 ip block support")Signed-off-by Khalid Masum <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1
-2@@ -1154,7 +1154,7 @@ static int vcn_v4_0_stop(struct amdgpu_device *adev) fw_shared->sq.queue_mode |=FW_QUEUE_DPG_HOLD_OFF ;if (adev->pg_flags &AMD_PG_SUPPORT_VCN_DPG ) { - r =vcn_v4_0_stop_dpg_mode (adev, i); +vcn_v4_0_stop_dpg_mode (adev, i);continue ; } --
Quoted 2 lines
2.37.1
After value is overwritten soon right after the diff.
See:drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
static int vcn_v4_0_stop(struct amdgpu_device *adev) {
volatile struct amdgpu_vcn4_fw_shared *fw_shared; ...
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
fw_shared = adev->vcn.inst[i].fw_shared.cpu_addr;
fw_shared->sq.queue_mode |= FW_QUEUE_DPG_HOLD_OFF;
if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) {
r = vcn_v4_0_stop_dpg_mode(adev, i);
continue;
}
/* wait for vcn idle */
r = SOC15_WAIT_ON_RREG(VCN, i, regUVD_STATUS, UVD_STATUS__IDLE, 0x7);Here, any value assigned to r is overwritten before it could be used. So the assignment in the true branch of the if statement here can be removed.
Thanks,
-- Khalid Masum
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 3 lines · Ruijing
[AMD Official Use Only - General]
If the condition was met and it came to execute
vcn_4_0_stop_dpg_mode, then it would never have a chance to go for /*wait for vcn idle*/, isn't it?
Hypothetically, some other thread might set adev->pg_flags NULL and in that case it will get the chance to go for /* wait for vcn idle */.
Quoted 4 lines
I still didn't see obvious purpose of this change.
if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) { ==> r = vcn_v4_0_stop_dpg_mode(adev, i);
Regardless of that, this assignment to r is unnecessary. Because this value of r is never used. This patch simply removes this unnecessary assignment.
Quoted 9 lines
continue; } /* wait for vcn idle */ r = SOC15_WAIT_ON_RREG(VCN, i, regUVD_STATUS, UVD_STATUS__IDLE, 0x7);Thanks
Ruijing
Thanks,
-- Khalid Masum
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
[AMD Official Use Only - General]
Then please update commit message, this change is due to "value r is never used, and remove unnecessary assignment", that makes sense to me.
Thanks
Ruijing
-----Original Message-----
From: Khalid Masum <[email protected]>
Sent: Monday, August 15, 2022 11:54 AM
To: Dong, Ruijing <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Zhu, James <[email protected]>; Jiang, Sonny <[email protected]>; Wan Jiabing <[email protected]>; Liu, Leo <[email protected]>
Subject: Re: [PATCH linux-next] drm/amdgpu/vcn: Remove unused assignment in vcn_v4_0_stop
Quoted 3 lines · Ruijing
[AMD Official Use Only - General]
If the condition was met and it came to execute
vcn_4_0_stop_dpg_mode, then it would never have a chance to go for /*wait for vcn idle*/, isn't it?
Hypothetically, some other thread might set adev->pg_flags NULL and in that case it will get the chance to go for /* wait for vcn idle */.
Quoted 4 lines
I still didn't see obvious purpose of this change.
if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) { ==> r = vcn_v4_0_stop_dpg_mode(adev, i);
Regardless of that, this assignment to r is unnecessary. Because this value of r is never used. This patch simply removes this unnecessary assignment.
Quoted 9 lines
continue; } /* wait for vcn idle */ r = SOC15_WAIT_ON_RREG(VCN, i, regUVD_STATUS, UVD_STATUS__IDLE, 0x7);Thanks
Ruijing
Thanks,
-- Khalid Masum
Quoted 7 lines · Ruijing
[AMD Official Use Only - General]
Then please update commit message, this change is due to "value r is never used, and remove unnecessary assignment", that makes sense to me.
Thanks
Ruijing
Greg also pointed out that the function vcn_v4_0_stop_dpg_mode should return void. I shall send a patch shortly with these two changes. Thanks for your suggestion.
Thanks,
-- Khalid Masum
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 62 lines · Khalid Masum
Quoted 37 lines · Ruijing
[AMD Official Use Only - General]
Sorry, which "r" value was overwritten? I didn't see the point of making this change.
Thanks
Ruijing-----Original Message-----
From: Khalid Masum <[email protected]>
Sent: Monday, August 15, 2022 3:01 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Zhu, James <[email protected]>; Jiang, Sonny <[email protected]>; Dong, Ruijing <[email protected]>; Wan Jiabing <[email protected]>; Liu, Leo <[email protected]>; Khalid Masum <[email protected]>
Subject: [PATCH linux-next] drm/amdgpu/vcn: Remove unused assignment invcn_v4_0_stopThe value assigned from
vcn_v4_0_stop_dbg_modeto r is overwritten before it can be used. Remove this assignment.Addresses-Coverity: 1504988 ("Unused value")
Fixes 8da1170a16e4 ("drm/amdgpu: add VCN4 ip block support")Signed-off-by Khalid Masum <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1
-2@@ -1154,7 +1154,7 @@ static int vcn_v4_0_stop(struct amdgpu_device *adev) fw_shared->sq.queue_mode |=FW_QUEUE_DPG_HOLD_OFF ;if (adev->pg_flags &AMD_PG_SUPPORT_VCN_DPG ) { - r =vcn_v4_0_stop_dpg_mode (adev, i); +vcn_v4_0_stop_dpg_mode (adev, i);continue ; } --Quoted 2 lines
2.37.1
After value is overwritten soon right after the diff.
See:
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.cstatic int
vcn_v4_0_stop(struct amdgpu_device *adev){ volatile struct amdgpu_vcn4_fw_shared *fw_shared;...
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { fw_shared = adev->vcn.inst[i].fw_shared.cpu_addr; fw_shared->sq.queue_mode |= FW_QUEUE_DPG_HOLD_OFF; if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) { r = vcn_v4_0_stop_dpg_mode(adev, i); continue; } /* wait for vcn idle */ r = SOC15_WAIT_ON_RREG(VCN, i, regUVD_STATUS,
Quoted 5 lines
UVD_STATUS__IDLE,0x7);Here, any value assigned to r is overwritten before it could be used. So the assignment in the true branch of the if statement here can be removed.
Why not fix vcn_v4_0_stop_dpg_mode() to not return anything, as it does not, and then remove this assignment as well, which would fix up everything at once to be more obvious what is happening and why.
thanks,
greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 65 lines · Greg KH
Quoted 64 lines · Khalid Masum
Quoted 37 lines · Ruijing
[AMD Official Use Only - General]
Sorry, which "r" value was overwritten? I didn't see the point of making this change.
Thanks
Ruijing-----Original Message-----
From: Khalid Masum <[email protected]>
Sent: Monday, August 15, 2022 3:01 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; Zhu, James <[email protected]>; Jiang, Sonny <[email protected]>; Dong, Ruijing <[email protected]>; Wan Jiabing <[email protected]>; Liu, Leo <[email protected]>; Khalid Masum <[email protected]>
Subject: [PATCH linux-next] drm/amdgpu/vcn: Remove unused assignment invcn_v4_0_stopThe value assigned from
vcn_v4_0_stop_dbg_modeto r is overwritten before it can be used. Remove this assignment.Addresses-Coverity: 1504988 ("Unused value")
Fixes 8da1170a16e4 ("drm/amdgpu: add VCN4 ip block support")Signed-off-by Khalid Masum <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1
-2@@ -1154,7 +1154,7 @@ static int vcn_v4_0_stop(struct amdgpu_device *adev) fw_shared->sq.queue_mode |=FW_QUEUE_DPG_HOLD_OFF ;if (adev->pg_flags &AMD_PG_SUPPORT_VCN_DPG ) { - r =vcn_v4_0_stop_dpg_mode (adev, i); +vcn_v4_0_stop_dpg_mode (adev, i);continue ; } --Quoted 2 lines
2.37.1
After value is overwritten soon right after the diff.
See:
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.cstatic int
vcn_v4_0_stop(struct amdgpu_device *adev){ volatile struct amdgpu_vcn4_fw_shared *fw_shared;...
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { fw_shared = adev->vcn.inst[i].fw_shared.cpu_addr; fw_shared->sq.queue_mode |= FW_QUEUE_DPG_HOLD_OFF; if (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) { r = vcn_v4_0_stop_dpg_mode(adev, i); continue; } /* wait for vcn idle */ r = SOC15_WAIT_ON_RREG(VCN, i, regUVD_STATUS,
UVD_STATUS__IDLE,0x7);
Quoted 7 lines
Quoted 3 lines
Here, any value assigned to r is overwritten before it could be used. So the assignment in the true branch of the if statement here can be removed.
Why not fix
vcn_v4_0_stop_dpg_mode()to not return anything, as it does not, and then remove this assignment as well, which would fix up everything at once to be more obvious what is happening and why.
That makes sense. I shall send a v2 this way. Thanks for your suggestion.
Quoted 4 lines
thanks,
greg k-h
thanks,
-- Khalid Masum
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees