From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: Andrey Grodzovsky <andrey.grodzovsky@amd.com>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: horace.chen@amd.com, lijo.lazar@amd.com, jingwech@amd.com,
christian.koenig@amd.com, Monk.Liu@amd.com
Subject: Re: [RFC v4 10/11] drm/amdgpu: Rework amdgpu_device_lock_adev
Date: Wed, 9 Feb 2022 09:04:15 +0100 [thread overview]
Message-ID: <efa1a3c2-110f-7995-a4fd-d470e5bd8138@gmail.com> (raw)
In-Reply-To: <20220209002320.6077-11-andrey.grodzovsky@amd.com>
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
> This functions needs to be split into 2 parts where
> one is called only once for locking single instance of
> reset_domain's sem and reset flag and the other part
> which handles MP1 states should still be called for
> each device in XGMI hive.
>
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 48 ++++++++++++++++------
> 1 file changed, 35 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index e05d7cbefd2c..aaecf0797484 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -4825,16 +4825,20 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,
> return r;
> }
>
> -static void amdgpu_device_lock_adev(struct amdgpu_device *adev,
> - struct amdgpu_hive_info *hive)
> +static void amdgpu_device_lock_reset_domain(struct amdgpu_reset_domain *reset_domain,
> + struct amdgpu_hive_info *hive)
> {
> - atomic_set(&adev->reset_domain->in_gpu_reset, 1);
> + atomic_set(&reset_domain->in_gpu_reset, 1);
>
> if (hive) {
> - down_write_nest_lock(&adev->reset_domain->sem, &hive->hive_lock);
> + down_write_nest_lock(&reset_domain->sem, &hive->hive_lock);
> } else {
> - down_write(&adev->reset_domain->sem);
> + down_write(&reset_domain->sem);
> }
> +}
> +
> +static void amdgpu_device_set_mp1_state(struct amdgpu_device *adev)
> +{
>
> switch (amdgpu_asic_reset_method(adev)) {
> case AMD_RESET_METHOD_MODE1:
> @@ -4849,14 +4853,19 @@ static void amdgpu_device_lock_adev(struct amdgpu_device *adev,
> }
> }
>
> -static void amdgpu_device_unlock_adev(struct amdgpu_device *adev)
> +static void amdgpu_device_unset_mp1_state(struct amdgpu_device *adev)
> {
> amdgpu_vf_error_trans_all(adev);
> adev->mp1_state = PP_MP1_STATE_NONE;
> - atomic_set(&adev->reset_domain->in_gpu_reset, 0);
> - up_write(&adev->reset_domain->sem);
> }
>
> +static void amdgpu_device_unlock_reset_domain(struct amdgpu_reset_domain *reset_domain)
> +{
> + atomic_set(&reset_domain->in_gpu_reset, 0);
> + up_write(&reset_domain->sem);
> +}
I would move this into amdgpu_reset.c and call it
amdgpu_reset_domain_unlock().
Same of course for amdgpu_reset_domain_lock()...
Apart from that looks good to me,
Christian.
> +
> +
> static void amdgpu_device_resume_display_audio(struct amdgpu_device *adev)
> {
> struct pci_dev *p = NULL;
> @@ -5060,10 +5069,15 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,
> device_list_handle = &device_list;
> }
>
> + /* We need to lock reset domain only once both for XGMI and single device */
> + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device,
> + reset_list);
> + amdgpu_device_lock_reset_domain(tmp_adev->reset_domain, hive);
> +
> /* block all schedulers and reset given job's ring */
> list_for_each_entry(tmp_adev, device_list_handle, reset_list) {
>
> - amdgpu_device_lock_adev(tmp_adev, hive);
> + amdgpu_device_set_mp1_state(tmp_adev);
>
> /*
> * Try to put the audio codec into suspend state
> @@ -5213,9 +5227,14 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,
>
> if (audio_suspended)
> amdgpu_device_resume_display_audio(tmp_adev);
> - amdgpu_device_unlock_adev(tmp_adev);
> +
> + amdgpu_device_unset_mp1_state(tmp_adev);
> }
>
> + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device,
> + reset_list);
> + amdgpu_device_unlock_reset_domain(tmp_adev->reset_domain);
> +
> if (hive) {
> mutex_unlock(&hive->hive_lock);
> amdgpu_put_xgmi_hive(hive);
> @@ -5477,7 +5496,8 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta
> * Locking adev->reset_domain->sem will prevent any external access
> * to GPU during PCI error recovery
> */
> - amdgpu_device_lock_adev(adev, NULL);
> + amdgpu_device_lock_reset_domain(adev->reset_domain, NULL);
> + amdgpu_device_set_mp1_state(adev);
>
> /*
> * Block any work scheduling as we do for regular GPU reset
> @@ -5584,7 +5604,8 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev)
> DRM_INFO("PCIe error recovery succeeded\n");
> } else {
> DRM_ERROR("PCIe error recovery failed, err:%d", r);
> - amdgpu_device_unlock_adev(adev);
> + amdgpu_device_unset_mp1_state(adev);
> + amdgpu_device_unlock_reset_domain(adev->reset_domain);
> }
>
> return r ? PCI_ERS_RESULT_DISCONNECT : PCI_ERS_RESULT_RECOVERED;
> @@ -5621,7 +5642,8 @@ void amdgpu_pci_resume(struct pci_dev *pdev)
> drm_sched_start(&ring->sched, true);
> }
>
> - amdgpu_device_unlock_adev(adev);
> + amdgpu_device_unset_mp1_state(adev);
> + amdgpu_device_unlock_reset_domain(adev->reset_domain);
> }
>
> bool amdgpu_device_cache_pci_state(struct pci_dev *pdev)
next prev parent reply other threads:[~2022-02-09 8:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 0:23 [RFC v4 00/11] Define and use reset domain for GPU recovery in amdgpu Andrey Grodzovsky
2022-02-09 0:23 ` [RFC v4 01/11] drm/amdgpu: Introduce reset domain Andrey Grodzovsky
2022-02-09 0:23 ` [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready Andrey Grodzovsky
2022-02-09 7:53 ` Christian König
2022-02-09 18:06 ` Andrey Grodzovsky
2022-02-24 6:47 ` JingWen Chen
2022-02-24 16:24 ` Andrey Grodzovsky
2022-02-24 17:12 ` Deucher, Alexander
2022-02-24 17:26 ` Andrey Grodzovsky
2022-02-25 3:13 ` JingWen Chen
2022-02-09 0:23 ` [RFC v4 03/11] drm/amdgpu: Serialize non TDR gpu recovery with TDRs Andrey Grodzovsky
2022-02-09 0:23 ` [RFC v4 04/11] drm/amd/virt: For SRIOV send GPU reset directly to TDR queue Andrey Grodzovsky
2022-02-09 0:49 ` Liu, Shaoyun
2022-02-09 7:54 ` Christian König
2022-02-09 0:23 ` [RFC v4 05/11] drm/amdgpu: Drop hive->in_reset Andrey Grodzovsky
2022-02-09 0:23 ` [RFC v4 06/11] drm/amdgpu: Drop concurrent GPU reset protection for device Andrey Grodzovsky
2022-02-09 0:23 ` [RFC v4 07/11] drm/amdgpu: Rework reset domain to be refcounted Andrey Grodzovsky
2022-02-09 7:57 ` Christian König
2022-02-09 0:23 ` [RFC v4 08/11] drm/amdgpu: Move reset sem into reset_domain Andrey Grodzovsky
2022-02-09 7:59 ` Christian König
2022-02-09 0:23 ` [RFC v4 09/11] drm/amdgpu: Move in_gpu_reset " Andrey Grodzovsky
2022-02-09 8:00 ` Christian König
2022-02-09 0:23 ` [RFC v4 10/11] drm/amdgpu: Rework amdgpu_device_lock_adev Andrey Grodzovsky
2022-02-09 8:04 ` Christian König [this message]
2022-02-09 0:23 ` [RFC v4 11/11] Revert 'drm/amdgpu: annotate a false positive recursive locking' Andrey Grodzovsky
2022-02-09 8:06 ` Christian König
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=efa1a3c2-110f-7995-a4fd-d470e5bd8138@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=Monk.Liu@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andrey.grodzovsky@amd.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=horace.chen@amd.com \
--cc=jingwech@amd.com \
--cc=lijo.lazar@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