[PATCH 1/1] drm/amdgpu: call release_firmware() without a NULL check

Christian König ckoenig.leichtzumerken at gmail.com
Thu Jun 25 12:45:07 UTC 2020


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 at amd.com>

Reviewed-by: Christian König <christian.koenig at 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;
>   }



More information about the amd-gfx mailing list