Skip to contentSkip to conversation

drm/amdgpu: ensure no_hw_access is visible before MMIO

PATCH In review Perry Yuan 3 participants 3 messages Jan 28

Subsystems (2)
lore
Share & tools
lore

Perry Yuan

author
#0 lore raw

PATCH 1/1 drm/amdgpu: ensure no_hw_access is visible before MMIO

Add a full memory barrier after clearing no_hw_access in amdgpu_device_mode1_reset() so subsequent PCI state restore access cannot observe stale state on other CPUs.

Fixes 91ae0045130b ("drm/amd/pm: Disable MMIO access during SMU Mode 1 reset")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index b2deb6a74eb2..e69ab8a923e3 100644
@@ -5735,6 +5735,9 @@ int amdgpu_device_mode1_reset(struct amdgpu_device *adev)
 	/* enable mmio access after mode 1 reset completed */
 	adev->no_hw_access = false;
 
+	/* ensure no_hw_access is updated before we access hw */
+	smp_mb();
+
 	amdgpu_device_load_pci_state(adev->pdev);
 	ret = amdgpu_psp_wait_for_bootloader(adev);
 	if (ret)
Signature · 1 line
2.34.1
#1 lore raw
Quoted 4 lines · Perry Yuan

Add a full memory barrier after clearing no_hw_access in amdgpu_device_mode1_reset() so subsequent PCI state restore access cannot observe stale state on other CPUs.

Just want to reiterate that this approach masks the original logical errors within amdgpu.

For ex: this is one such which would not have been caught in the first place with shortcuts like these.

12caf3b76150 drm/amdkfd: Handle GPU reset and drain retry fault race

Thanks,
Lijo

Quoted 21 lines
Fixes 91ae0045130b ("drm/amd/pm: Disable MMIO access during SMU Mode 1 reset")
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index b2deb6a74eb2..e69ab8a923e3 100644
@@ -5735,6 +5735,9 @@ int amdgpu_device_mode1_reset(struct amdgpu_device *adev)
  	/* enable mmio access after mode 1 reset completed */
  	adev->no_hw_access = false;
 
+	/* ensure no_hw_access is updated before we access hw */
+	smp_mb();
+
  	amdgpu_device_load_pci_state(adev->pdev);
  	ret = amdgpu_psp_wait_for_bootloader(adev);
  	if (ret)
maintainer
#2 lore raw
Quoted 7 lines · Lijo
Quoted 4 lines · Perry Yuan

Add a full memory barrier after clearing no_hw_access in amdgpu_device_mode1_reset() so subsequent PCI state restore access cannot observe stale state on other CPUs.

Just want to reiterate that this approach masks the original logical errors within amdgpu.

Yeah, completely agree. A single smp_mb() is actually forbidden by upstreaming rules.

So absolutely clear NAK from my side to this patch here.

Regards,
Christian.

Quoted 29 lines

For ex: this is one such which would not have been caught in the first place with shortcuts like these.

12caf3b76150 drm/amdkfd: Handle GPU reset and drain retry fault race

Thanks,
Lijo

Quoted 20 lines
Fixes 91ae0045130b ("drm/amd/pm: Disable MMIO access during SMU Mode 1 reset")

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++

  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index b2deb6a74eb2..e69ab8a923e3 100644
@@ -5735,6 +5735,9 @@ int amdgpu_device_mode1_reset(struct amdgpu_device *adev)
       /* enable mmio access after mode 1 reset completed */
       adev->no_hw_access = false;

  +    /* ensure no_hw_access is updated before we access hw */ +    smp_mb();
+
      amdgpu_device_load_pci_state(adev->pdev);
      ret = amdgpu_psp_wait_for_bootloader(adev);
      if (ret)