AMD-GFX Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/1] drm/amdgpu: call release_firmware() without a NULL check
@ 2020-06-23 16:26 Nirmoy Das
  2020-06-25 10:45 ` Nirmoy
  2020-06-25 12:45 ` Christian König
  0 siblings, 2 replies; 3+ messages in thread
From: Nirmoy Das @ 2020-06-23 16:26 UTC (permalink / raw)
  To: amd-gfx; +Cc: Nirmoy Das, christian.koenig

The release_firmware() function is NULL tolerant so we do not need
to check for NULL param before calling it.

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |  6 ++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c           |  6 ++----
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c            |  4 ++--
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c            |  4 ++--
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c            |  4 ++--
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++++--------
 6 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2858c09fd8c0..a649e40fd96f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3380,10 +3380,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 		amdgpu_pm_sysfs_fini(adev);
 	amdgpu_fbdev_fini(adev);
 	r = amdgpu_device_ip_fini(adev);
-	if (adev->firmware.gpu_info_fw) {
-		release_firmware(adev->firmware.gpu_info_fw);
-		adev->firmware.gpu_info_fw = NULL;
-	}
+	release_firmware(adev->firmware.gpu_info_fw);
+	adev->firmware.gpu_info_fw = NULL;
 	adev->accel_working = false;
 	/* free i2c buses */
 	if (!amdgpu_device_has_dc_support(adev))
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 0723dee2958b..9342a9e8cadf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -196,10 +196,8 @@ static int psp_sw_fini(void *handle)
 	adev->psp.sos_fw = NULL;
 	release_firmware(adev->psp.asd_fw);
 	adev->psp.asd_fw = NULL;
-	if (adev->psp.ta_fw) {
-		release_firmware(adev->psp.ta_fw);
-		adev->psp.ta_fw = NULL;
-	}
+	release_firmware(adev->psp.ta_fw);
+	adev->psp.ta_fw = NULL;
 
 	if (adev->asic_type == CHIP_NAVI10)
 		psp_sysfs_fini(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
index 58382646d962..2985c61bc6a1 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
@@ -559,8 +559,8 @@ static void sdma_v4_0_destroy_inst_ctx(struct amdgpu_device *adev)
 	int i;
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
-		if (adev->sdma.instance[i].fw != NULL)
-			release_firmware(adev->sdma.instance[i].fw);
+		release_firmware(adev->sdma.instance[i].fw);
+		adev->sdma.instance[i].fw = NULL;
 
 		/* arcturus shares the same FW memory across
 		   all SDMA isntances */
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
index 6751ad69ed90..1baeddf2f1e6 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
@@ -1300,8 +1300,8 @@ static int sdma_v5_0_sw_fini(void *handle)
 	int i;
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
-		if (adev->sdma.instance[i].fw != NULL)
-			release_firmware(adev->sdma.instance[i].fw);
+		release_firmware(adev->sdma.instance[i].fw);
+		adev->sdma.instance[i].fw = NULL;
 
 		amdgpu_ring_fini(&adev->sdma.instance[i].ring);
 	}
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
index 95751e7bdfe8..318d32e2bbf6 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
@@ -115,8 +115,8 @@ static void sdma_v5_2_destroy_inst_ctx(struct amdgpu_device *adev)
 	int i;
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
-		if (adev->sdma.instance[i].fw != NULL)
-			release_firmware(adev->sdma.instance[i].fw);
+		release_firmware(adev->sdma.instance[i].fw);
+		adev->sdma.instance[i].fw = NULL;
 
 		if (adev->asic_type == CHIP_SIENNA_CICHLID)
 			break;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 3badf685338f..4767f9ea0352 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1318,15 +1318,11 @@ static int dm_sw_fini(void *handle)
 		adev->dm.dmub_srv = NULL;
 	}
 
-	if (adev->dm.dmub_fw) {
-		release_firmware(adev->dm.dmub_fw);
-		adev->dm.dmub_fw = NULL;
-	}
+	release_firmware(adev->dm.dmub_fw);
+	adev->dm.dmub_fw = NULL;
 
-	if(adev->dm.fw_dmcu) {
-		release_firmware(adev->dm.fw_dmcu);
-		adev->dm.fw_dmcu = NULL;
-	}
+	release_firmware(adev->dm.fw_dmcu);
+	adev->dm.fw_dmcu = NULL;
 
 	return 0;
 }
-- 
2.27.0

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

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

* Re: [PATCH 1/1] drm/amdgpu: call release_firmware() without a NULL check
  2020-06-23 16:26 [PATCH 1/1] drm/amdgpu: call release_firmware() without a NULL check Nirmoy Das
@ 2020-06-25 10:45 ` Nirmoy
  2020-06-25 12:45 ` Christian König
  1 sibling, 0 replies; 3+ messages in thread
From: Nirmoy @ 2020-06-25 10:45 UTC (permalink / raw)
  To: Nirmoy Das, amd-gfx; +Cc: Nirmoy Das, christian.koenig

ping!

On 6/23/20 6:26 PM, Nirmoy Das wrote:
> The release_firmware() function is NULL tolerant so we do not need
> to check for NULL param before calling it.
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |  6 ++----
>   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c           |  6 ++----
>   drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c            |  4 ++--
>   drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c            |  4 ++--
>   drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c            |  4 ++--
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++++--------
>   6 files changed, 14 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 2858c09fd8c0..a649e40fd96f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -3380,10 +3380,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>   		amdgpu_pm_sysfs_fini(adev);
>   	amdgpu_fbdev_fini(adev);
>   	r = amdgpu_device_ip_fini(adev);
> -	if (adev->firmware.gpu_info_fw) {
> -		release_firmware(adev->firmware.gpu_info_fw);
> -		adev->firmware.gpu_info_fw = NULL;
> -	}
> +	release_firmware(adev->firmware.gpu_info_fw);
> +	adev->firmware.gpu_info_fw = NULL;
>   	adev->accel_working = false;
>   	/* free i2c buses */
>   	if (!amdgpu_device_has_dc_support(adev))
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 0723dee2958b..9342a9e8cadf 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -196,10 +196,8 @@ static int psp_sw_fini(void *handle)
>   	adev->psp.sos_fw = NULL;
>   	release_firmware(adev->psp.asd_fw);
>   	adev->psp.asd_fw = NULL;
> -	if (adev->psp.ta_fw) {
> -		release_firmware(adev->psp.ta_fw);
> -		adev->psp.ta_fw = NULL;
> -	}
> +	release_firmware(adev->psp.ta_fw);
> +	adev->psp.ta_fw = NULL;
>   
>   	if (adev->asic_type == CHIP_NAVI10)
>   		psp_sysfs_fini(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> index 58382646d962..2985c61bc6a1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> @@ -559,8 +559,8 @@ static void sdma_v4_0_destroy_inst_ctx(struct amdgpu_device *adev)
>   	int i;
>   
>   	for (i = 0; i < adev->sdma.num_instances; i++) {
> -		if (adev->sdma.instance[i].fw != NULL)
> -			release_firmware(adev->sdma.instance[i].fw);
> +		release_firmware(adev->sdma.instance[i].fw);
> +		adev->sdma.instance[i].fw = NULL;
>   
>   		/* arcturus shares the same FW memory across
>   		   all SDMA isntances */
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> index 6751ad69ed90..1baeddf2f1e6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> @@ -1300,8 +1300,8 @@ static int sdma_v5_0_sw_fini(void *handle)
>   	int i;
>   
>   	for (i = 0; i < adev->sdma.num_instances; i++) {
> -		if (adev->sdma.instance[i].fw != NULL)
> -			release_firmware(adev->sdma.instance[i].fw);
> +		release_firmware(adev->sdma.instance[i].fw);
> +		adev->sdma.instance[i].fw = NULL;
>   
>   		amdgpu_ring_fini(&adev->sdma.instance[i].ring);
>   	}
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
> index 95751e7bdfe8..318d32e2bbf6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
> @@ -115,8 +115,8 @@ static void sdma_v5_2_destroy_inst_ctx(struct amdgpu_device *adev)
>   	int i;
>   
>   	for (i = 0; i < adev->sdma.num_instances; i++) {
> -		if (adev->sdma.instance[i].fw != NULL)
> -			release_firmware(adev->sdma.instance[i].fw);
> +		release_firmware(adev->sdma.instance[i].fw);
> +		adev->sdma.instance[i].fw = NULL;
>   
>   		if (adev->asic_type == CHIP_SIENNA_CICHLID)
>   			break;
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 3badf685338f..4767f9ea0352 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -1318,15 +1318,11 @@ static int dm_sw_fini(void *handle)
>   		adev->dm.dmub_srv = NULL;
>   	}
>   
> -	if (adev->dm.dmub_fw) {
> -		release_firmware(adev->dm.dmub_fw);
> -		adev->dm.dmub_fw = NULL;
> -	}
> +	release_firmware(adev->dm.dmub_fw);
> +	adev->dm.dmub_fw = NULL;
>   
> -	if(adev->dm.fw_dmcu) {
> -		release_firmware(adev->dm.fw_dmcu);
> -		adev->dm.fw_dmcu = NULL;
> -	}
> +	release_firmware(adev->dm.fw_dmcu);
> +	adev->dm.fw_dmcu = NULL;
>   
>   	return 0;
>   }
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH 1/1] drm/amdgpu: call release_firmware() without a NULL check
  2020-06-23 16:26 [PATCH 1/1] drm/amdgpu: call release_firmware() without a NULL check Nirmoy Das
  2020-06-25 10:45 ` Nirmoy
@ 2020-06-25 12:45 ` Christian König
  1 sibling, 0 replies; 3+ messages in thread
From: Christian König @ 2020-06-25 12:45 UTC (permalink / raw)
  To: Nirmoy Das, amd-gfx; +Cc: Nirmoy Das, christian.koenig

Am 23.06.20 um 18:26 schrieb Nirmoy Das:
> The release_firmware() function is NULL tolerant so we do not need
> to check for NULL param before calling it.
>
> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>

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

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        |  6 ++----
>   drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c           |  6 ++----
>   drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c            |  4 ++--
>   drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c            |  4 ++--
>   drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c            |  4 ++--
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++++--------
>   6 files changed, 14 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 2858c09fd8c0..a649e40fd96f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -3380,10 +3380,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
>   		amdgpu_pm_sysfs_fini(adev);
>   	amdgpu_fbdev_fini(adev);
>   	r = amdgpu_device_ip_fini(adev);
> -	if (adev->firmware.gpu_info_fw) {
> -		release_firmware(adev->firmware.gpu_info_fw);
> -		adev->firmware.gpu_info_fw = NULL;
> -	}
> +	release_firmware(adev->firmware.gpu_info_fw);
> +	adev->firmware.gpu_info_fw = NULL;
>   	adev->accel_working = false;
>   	/* free i2c buses */
>   	if (!amdgpu_device_has_dc_support(adev))
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 0723dee2958b..9342a9e8cadf 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -196,10 +196,8 @@ static int psp_sw_fini(void *handle)
>   	adev->psp.sos_fw = NULL;
>   	release_firmware(adev->psp.asd_fw);
>   	adev->psp.asd_fw = NULL;
> -	if (adev->psp.ta_fw) {
> -		release_firmware(adev->psp.ta_fw);
> -		adev->psp.ta_fw = NULL;
> -	}
> +	release_firmware(adev->psp.ta_fw);
> +	adev->psp.ta_fw = NULL;
>   
>   	if (adev->asic_type == CHIP_NAVI10)
>   		psp_sysfs_fini(adev);
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> index 58382646d962..2985c61bc6a1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> @@ -559,8 +559,8 @@ static void sdma_v4_0_destroy_inst_ctx(struct amdgpu_device *adev)
>   	int i;
>   
>   	for (i = 0; i < adev->sdma.num_instances; i++) {
> -		if (adev->sdma.instance[i].fw != NULL)
> -			release_firmware(adev->sdma.instance[i].fw);
> +		release_firmware(adev->sdma.instance[i].fw);
> +		adev->sdma.instance[i].fw = NULL;
>   
>   		/* arcturus shares the same FW memory across
>   		   all SDMA isntances */
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> index 6751ad69ed90..1baeddf2f1e6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
> @@ -1300,8 +1300,8 @@ static int sdma_v5_0_sw_fini(void *handle)
>   	int i;
>   
>   	for (i = 0; i < adev->sdma.num_instances; i++) {
> -		if (adev->sdma.instance[i].fw != NULL)
> -			release_firmware(adev->sdma.instance[i].fw);
> +		release_firmware(adev->sdma.instance[i].fw);
> +		adev->sdma.instance[i].fw = NULL;
>   
>   		amdgpu_ring_fini(&adev->sdma.instance[i].ring);
>   	}
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
> index 95751e7bdfe8..318d32e2bbf6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
> @@ -115,8 +115,8 @@ static void sdma_v5_2_destroy_inst_ctx(struct amdgpu_device *adev)
>   	int i;
>   
>   	for (i = 0; i < adev->sdma.num_instances; i++) {
> -		if (adev->sdma.instance[i].fw != NULL)
> -			release_firmware(adev->sdma.instance[i].fw);
> +		release_firmware(adev->sdma.instance[i].fw);
> +		adev->sdma.instance[i].fw = NULL;
>   
>   		if (adev->asic_type == CHIP_SIENNA_CICHLID)
>   			break;
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 3badf685338f..4767f9ea0352 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -1318,15 +1318,11 @@ static int dm_sw_fini(void *handle)
>   		adev->dm.dmub_srv = NULL;
>   	}
>   
> -	if (adev->dm.dmub_fw) {
> -		release_firmware(adev->dm.dmub_fw);
> -		adev->dm.dmub_fw = NULL;
> -	}
> +	release_firmware(adev->dm.dmub_fw);
> +	adev->dm.dmub_fw = NULL;
>   
> -	if(adev->dm.fw_dmcu) {
> -		release_firmware(adev->dm.fw_dmcu);
> -		adev->dm.fw_dmcu = NULL;
> -	}
> +	release_firmware(adev->dm.fw_dmcu);
> +	adev->dm.fw_dmcu = NULL;
>   
>   	return 0;
>   }

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

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 16:26 [PATCH 1/1] drm/amdgpu: call release_firmware() without a NULL check Nirmoy Das
2020-06-25 10:45 ` Nirmoy
2020-06-25 12:45 ` Christian König

AMD-GFX Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/amd-gfx/0 amd-gfx/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 amd-gfx amd-gfx/ https://lore.kernel.org/amd-gfx \
		amd-gfx@lists.freedesktop.org
	public-inbox-index amd-gfx

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.freedesktop.lists.amd-gfx


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git