From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Nirmoy Das <nirmoy.aiemd@gmail.com>, amd-gfx@lists.freedesktop.org
Cc: Nirmoy Das <nirmoy.das@amd.com>, christian.koenig@amd.com
Subject: Re: [PATCH 1/1] drm/amdgpu: call release_firmware() without a NULL check
Date: Thu, 25 Jun 2020 14:45:07 +0200 [thread overview]
Message-ID: <fb40c220-7402-10cb-24a6-e697c85447d0@gmail.com> (raw)
In-Reply-To: <20200623162637.26011-1-nirmoy.das@amd.com>
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
prev parent reply other threads:[~2020-06-25 12:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fb40c220-7402-10cb-24a6-e697c85447d0@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=nirmoy.aiemd@gmail.com \
--cc=nirmoy.das@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).