Skip to contentSkip to conversation

drm/mgag200: Fix caching setup for remapped video memory

PATCH In review Thomas Zimmermann 2 participants 3 messages Jan 5, 2024 – Jan 8, 2024

Subsystems (3)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

PATCH 1/1 drm/mgag200: Fix caching setup for remapped video memory

I/O video memory for the framebuffer supports write-combine caching mode. Simplify the driver's code that sets up the caching mode.

* Map video memory with ioremap_wc(), which automatically sets up
the PAT entry with write-combine caching.

* Remove the now obsolete call to devm_arch_io_reserve_memtype_wc().
It is only required to mmap the video memory to user space, which the driver doesn't do.

* According to the PAT documentation, arch_phys_wc_add() is best
called after remapping I/O memory, so move it after ioremap.

---
 drivers/gpu/drm/mgag200/mgag200_drv.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/mgag200/mgag200_drv.c +4 -5
index 2fb18b782b05..54fce00e2136 100644
@@ -146,14 +146,13 @@ int mgag200_device_preinit(struct mga_device *mdev)
 	}
 	mdev->vram_res = res;
 
-	/* Don't fail on errors, but performance might be reduced. */
-	devm_arch_io_reserve_memtype_wc(dev->dev, res->start, resource_size(res));
-	devm_arch_phys_wc_add(dev->dev, res->start, resource_size(res));
-
-	mdev->vram = devm_ioremap(dev->dev, res->start, resource_size(res));
+	mdev->vram = devm_ioremap_wc(dev->dev, res->start, resource_size(res));
 	if (!mdev->vram)
 		return -ENOMEM;
 
+	/* Don't fail on errors, but performance might be reduced. */
+	devm_arch_phys_wc_add(dev->dev, res->start, resource_size(res));
+
 	return 0;
 }
 
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 6 lines · Thomas Zimmermann

I/O video memory for the framebuffer supports write-combine caching mode. Simplify the driver's code that sets up the caching mode.

* Map video memory with ioremap_wc(), which automatically sets up
the PAT entry with write-combine caching.

Quoted 7 lines

* Remove the now obsolete call to devm_arch_io_reserve_memtype_wc().
It is only required to mmap the video memory to user space, which the driver doesn't do.

* According to the PAT documentation, arch_phys_wc_add() is best
called after remapping I/O memory, so move it after ioremap.

Thanks a lot for taking some time to look at the latency issue. This looks good to me.

Signature · 1 line
Jocelyn
author maintainer
#2 lore raw

Hi

Am 05.01.24 um 11:41 schrieb Jocelyn Falempe:

Quoted 13 lines

Hi,

Quoted 10 lines · Thomas Zimmermann

I/O video memory for the framebuffer supports write-combine caching mode. Simplify the driver's code that sets up the caching mode.

  * Map video memory with ioremap_wc(), which automatically sets up the PAT entry with write-combine caching.

  * Remove the now obsolete call to devm_arch_io_reserve_memtype_wc(). It is only required to mmap the video memory to user space, which the driver doesn't do.

Quoted 9 lines
Quoted 3 lines

  * According to the PAT documentation, arch_phys_wc_add() is best called after remapping I/O memory, so move it after ioremap.

Thanks a lot for taking some time to look at the latency issue. This looks good to me.

Thanks a lot for the review. I'll send out a similar patch for ast, which has the same issues.

Best regards
Thomas

Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)