FW: [PATCH 2/3] drm/amdgpu: use some wrapper functions in amdgpu_device_fini_sw()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[AMD Official Use Only]



>-----Original Message-----
>From: Yu, Lang <Lang.Yu@xxxxxxx>
>Sent: Thursday, October 21, 2021 3:18 PM
>To: Grodzovsky, Andrey <Andrey.Grodzovsky@xxxxxxx>
>Cc: Deucher, Alexander <Alexander.Deucher@xxxxxxx>; Koenig, Christian
><Christian.Koenig@xxxxxxx>; Huang, Ray <Ray.Huang@xxxxxxx>; Yu, Lang
><Lang.Yu@xxxxxxx>
>Subject: [PATCH 2/3] drm/amdgpu: use some wrapper functions in
>amdgpu_device_fini_sw()
>
>Add some wrapper functions to make amdgpu_device_fini_sw() more clear.
>
>Fix an error handling in amdgpu_device_parse_gpu_info_fw().
>
>Signed-off-by: Lang Yu <lang.yu@xxxxxxx>
>---
> drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 10 +++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 32 ++++++++++++++++------
> 2 files changed, 34 insertions(+), 8 deletions(-)
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>index d58e37fd01f4..5df194259e15 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>@@ -372,6 +372,11 @@ int amdgpu_device_ip_block_add(struct amdgpu_device
>*adev,
>  */
> bool amdgpu_get_bios(struct amdgpu_device *adev);  bool
>amdgpu_read_bios(struct amdgpu_device *adev);
>+static inline void amdgpu_free_bios(struct amdgpu_device *adev) {
>+	kfree(adev->bios);
>+	adev->bios = NULL;
>+}
>
> /*
>  * Clocks
>@@ -1440,6 +1445,11 @@ void amdgpu_pci_resume(struct pci_dev *pdev);
>
> bool amdgpu_device_cache_pci_state(struct pci_dev *pdev);  bool
>amdgpu_device_load_pci_state(struct pci_dev *pdev);
>+static inline void amdgpu_device_free_pci_state(struct amdgpu_device
>+*adev) {
>+	kfree(adev->pci_state);
>+	adev->pci_state = NULL;
>+}
>
> bool amdgpu_device_skip_hw_access(struct amdgpu_device *adev);
>
>diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>index 5654c4790773..be64861ed19a 100644
>--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
>@@ -1871,6 +1871,19 @@ static void
>amdgpu_device_enable_virtual_display(struct amdgpu_device *adev)
> 	}
> }
>
>+/**
>+ * amdgpu_device_release_gpu_info_fw - release gpu info firmware
>+ *
>+ * @adev: amdgpu_device pointer
>+ *
>+ *  Wrapper to release gpu info firmware  */ static inline void
>+amdgpu_device_release_gpu_info_fw(struct amdgpu_device *adev) {
>+	release_firmware(adev->firmware.gpu_info_fw);
>+	adev->firmware.gpu_info_fw = NULL;
>+}
>+
> /**
>  * amdgpu_device_parse_gpu_info_fw - parse gpu info firmware
>  *
>@@ -1987,7 +2000,7 @@ static int amdgpu_device_parse_gpu_info_fw(struct
>amdgpu_device *adev)
> 		dev_err(adev->dev,
> 			"Failed to validate gpu_info firmware \"%s\"\n",
> 			fw_name);
>-		goto out;
>+		goto release_fw;
> 	}
>
> 	hdr = (const struct gpu_info_firmware_header_v1_0 *)adev-
>>firmware.gpu_info_fw->data;
>@@ -2051,8 +2064,12 @@ static int amdgpu_device_parse_gpu_info_fw(struct
>amdgpu_device *adev)
> 		dev_err(adev->dev,
> 			"Unsupported gpu_info table %d\n", hdr-
>>header.ucode_version);
> 		err = -EINVAL;
>-		goto out;
>+		goto release_fw;
> 	}
>+
>+	return 0;
>+release_fw:
>+	amdgpu_device_release_gpu_info_fw(adev);
> out:
> 	return err;
> }
>@@ -3845,8 +3862,8 @@ void amdgpu_device_fini_sw(struct amdgpu_device
>*adev)  {
> 	amdgpu_fence_driver_sw_fini(adev);
> 	amdgpu_device_ip_fini(adev);
>-	release_firmware(adev->firmware.gpu_info_fw);
>-	adev->firmware.gpu_info_fw = NULL;
>+	amdgpu_device_release_gpu_info_fw(adev);
>+
> 	adev->accel_working = false;
>
> 	amdgpu_reset_fini(adev);
>@@ -3858,8 +3875,8 @@ void amdgpu_device_fini_sw(struct amdgpu_device
>*adev)
> 	if (amdgpu_emu_mode != 1)
> 		amdgpu_atombios_fini(adev);
>
>-	kfree(adev->bios);
>-	adev->bios = NULL;
>+	amdgpu_free_bios(adev);
>+
> 	if (amdgpu_device_supports_px(adev_to_drm(adev))) {
> 		vga_switcheroo_unregister_client(adev->pdev);
> 		vga_switcheroo_fini_domain_pm_ops(adev->dev);
>@@ -3872,8 +3889,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device
>*adev)
> 	if (adev->mman.discovery_bin)
> 		amdgpu_discovery_fini(adev);
>
>-	kfree(adev->pci_state);
>-
>+	amdgpu_device_free_pci_state(adev);
> }
>
> /**
>--
>2.25.1




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux