Skip to contentSkip to conversation

drm/amdgpu: Fix missing comment for mb() in 'amdgpu_device_aper_access'

PATCH Superseded Srinivasan Shanmugam 2 participants 2 messages Aug 9, 2023

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/amdgpu: Fix missing comment for mb() in 'amdgpu_device_aper_access'

This patch adds the missing code comment for memory barrier

WARNING: memory barrier without comment
+ mb();

WARNING: memory barrier without comment
+ mb();

Cc Guchun Chen <[email protected]>
Cc Christian König <[email protected]>
Cc Alex Deucher <[email protected]>
Cc "Pan, Xinhui" <[email protected]>

---
v3:

Corrected title message

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -0
index 4f818f13dc9d..bb65e12ed027 100644
@@ -305,10 +305,17 @@ size_t amdgpu_device_aper_access(struct amdgpu_device *adev, loff_t pos,
 
 		if (write) {
 			memcpy_toio(addr, buf, count);
+			/* Make sure contents of system memory are copied/flushed
+			 * without messing up order of writes to PCI device I/O memory
+			 */
 			mb();
 			amdgpu_device_flush_hdp(adev, NULL);
 		} else {
 			amdgpu_device_invalidate_hdp(adev, NULL);
+			/* Make sure contents of system memory drained/invalidated
+			 * before copying contents from PCI device I/O memory
+			 * to system memory
+			 */
 			mb();
 			memcpy_fromio(buf, addr, count);
 		}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 26 lines · Srinivasan Shanmugam

This patch adds the missing code comment for memory barrier

WARNING: memory barrier without comment
+ mb();

WARNING: memory barrier without comment
+ mb();

Cc Guchun Chen <[email protected]>
Cc Christian König <[email protected]>
Cc Alex Deucher <[email protected]>
Cc "Pan, Xinhui" <[email protected]>

---
v3:

Corrected title message

  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 4f818f13dc9d..bb65e12ed027 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c size_t amdgpu_device_aper_access(struct amdgpu_device *adev, loff_t pos, · line 310

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
@@ -305,10 +305,17 @@ size_t amdgpu_device_aper_access(struct amdgpu_device *adev, loff_t pos,
 
  		if (write) {
  			memcpy_toio(addr, buf, count);
+			/* Make sure contents of system memory are copied/flushed
+			 * without messing up order of writes to PCI device I/O memory
+			 */

Make sure HDP write cache flush happens after the memory contents are sent over PCIe.

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c size_t amdgpu_device_aper_access(struct amdgpu_device *adev, loff_t pos, · line 315

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
  			mb();
  			amdgpu_device_flush_hdp(adev, NULL);
  		} else {
  			amdgpu_device_invalidate_hdp(adev, NULL);
+			/* Make sure contents of system memory drained/invalidated

Similarly, make sure HDP read cache is invalidated before issuing a read to the device. No reordering in both cases.

Thanks,
Lijo

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
+			 * before copying contents from PCI device I/O memory
+			 * to system memory
+			 */
  			mb();
  			memcpy_fromio(buf, addr, count);
  		}