drm/mgag200: Add an option to disable Write-Combine
Subsystems (3)
Jocelyn Falempe
reviewercover drm/mgag200: Add an option to disable Write-Combine
Unfortunately, the G200 ioburst workaround doesn't work on some servers like Dell poweredge XR11, XR5610, or HPE XL260
In this case completely disabling WC is the only option to achieve low-latency.
It's probably useless to maintain two workarounds for this,
so I reverted commit bfa4437fd3938 drm/mgag200: Add a workaround for low-latency and added a new and simpler option, to just disable Write-Combine.
Jocelyn Falempe (2):
Revert "drm/mgag200: Add a workaround for low-latency" drm/mgag200: Add an option to disable Write-Combine
drivers/gpu/drm/mgag200/Kconfig | 18 ++++++++---------- drivers/gpu/drm/mgag200/mgag200_drv.c | 24 +++++++----------------- drivers/gpu/drm/mgag200/mgag200_mode.c | 8 -------- 3 files changed, 15 insertions(+), 35 deletions(-)
base-commit: 2c3d1bd284c5141a85188f48e7f42112e81ffcd8
Signature · 1 line
2.45.0
Jocelyn Falempe
reviewerPATCH 1/2 Revert "drm/mgag200: Add a workaround for low-latency"
This reverts commit bfa4437fd3938ae2e186e7664b2db65bb8775670.
This workaround doesn't work reliably on all servers. I'll replace it with an option to disable Write-Combine, which has more impact on performance, but fix the latency issue on all hardware.
--- drivers/gpu/drm/mgag200/Kconfig | 12 ------------ drivers/gpu/drm/mgag200/mgag200_drv.c | 17 ----------------- drivers/gpu/drm/mgag200/mgag200_mode.c | 8 -------- 3 files changed, 37 deletions(-)
drivers/gpu/drm/mgag200/Kconfig +0 -12
@@ -11,15 +11,3 @@ config DRM_MGAG200 MGA G200 desktop chips and the server variants. It requires 0.3.0 of the modesetting userspace driver, and a version of mga driver that will fail on KMS enabled devices. - -config DRM_MGAG200_IOBURST_WORKAROUND - bool "Disable buffer caching" - depends on DRM_MGAG200 && PREEMPT_RT && X86 - help - Enable a workaround to avoid I/O bursts within the mgag200 driver at - the expense of overall display performance. - It restores the <v5.10 behavior, by mapping the framebuffer in system - RAM as Write-Combining, and flushing the cache after each write. - This is only useful on x86_64 if you want to run processes with - deterministic latency. - If unsure, say N.
drivers/gpu/drm/mgag200/mgag200_drv.c +0 -17
@@ -84,20 +84,6 @@ resource_size_t mgag200_probe_vram(void __iomem *mem, resource_size_t size)return offset -65536 ; } -#if defined(CONFIG_DRM_MGAG200_IOBURST_WORKAROUND ) -static struct drm_gem_object *mgag200_create_object (struct drm_device *dev,size_t size) -{ -struct drm_gem_shmem_object *shmem; - - shmem =kzalloc (sizeof (*shmem),GFP_KERNEL ); -if (!shmem) -return NULL ; - - shmem->map_wc = true; -return &shmem->base; -} -#endif -/* * DRM driver */
@@ -113,9 +99,6 @@ static const struct drm_driver mgag200_driver = { .major = DRIVER_MAJOR, .minor = DRIVER_MINOR, .patchlevel = DRIVER_PATCHLEVEL, -#if defined(CONFIG_DRM_MGAG200_IOBURST_WORKAROUND ) - .gem_create_object = mgag200_create_object, -#endif DRM_GEM_SHMEM_DRIVER_OPS, };
drivers/gpu/drm/mgag200/mgag200_mode.c +0 -8
@@ -13,7 +13,6 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> -#include <drm/drm_cache.h> #include <drm/drm_damage_helper.h> #include <drm/drm_edid.h> #include <drm/drm_format_helper.h>
@@ -438,13 +437,6 @@ static void mgag200_handle_damage(struct mga_device *mdev, const struct iosys_maiosys_map_incr (&dst,drm_fb_clip_offset (fb->pitches[0 ], fb->format, clip));drm_fb_memcpy (&dst, fb->pitches, vmap, fb, clip); - -/* Flushing the cache greatly improves latency on x86_64 */ -#if defined(CONFIG_DRM_MGAG200_IOBURST_WORKAROUND ) -if (!vmap->is_iomem) -drm_clflush_virt_range (vmap->vaddr + clip->y1 * fb->pitches[0 ], -drm_rect_height (clip) * fb->pitches[0 ]); -#endif }/*
Signature · 1 line
2.45.0
Re: [PATCH 1/2] Revert "drm/mgag200: Add a workaround for low-latency"
Am 16.05.24 um 18:17 schrieb Jocelyn Falempe:
Quoted 8 lines
This reverts commit
bfa4437fd3938ae2e186e7664b2db65bb8775670.This workaround doesn't work reliably on all servers. I'll replace it with an option to disable Write-Combine, which has more impact on performance, but fix the latency issue on all hardware.
Signed-off-by Jocelyn Falempe <[email protected]>
Quoted 87 lines
--- drivers/gpu/drm/mgag200/Kconfig | 12 ------------ drivers/gpu/drm/mgag200/mgag200_drv.c | 17 ----------------- drivers/gpu/drm/mgag200/mgag200_mode.c | 8 -------- 3 files changed, 37 deletions(-)drivers/gpu/drm/mgag200/Kconfig +0
-12@@ -11,15 +11,3 @@ config DRM_MGAG200 MGA G200 desktop chips and the server variants. It requires 0.3.0 of the modesetting userspace driver, and a version of mga driver that will fail on KMS enabled devices. - -config DRM_MGAG200_IOBURST_WORKAROUND - bool "Disable buffer caching" - depends on DRM_MGAG200 && PREEMPT_RT && X86 - help - Enable a workaround to avoid I/O bursts within the mgag200 driver at - the expense of overall display performance. - It restores the <v5.10 behavior, by mapping the framebuffer in system - RAM as Write-Combining, and flushing the cache after each write. - This is only useful on x86_64 if you want to run processes with - deterministic latency. - If unsure, say N.drivers/gpu/drm/mgag200/mgag200_drv.c +0
-17@@ -84,20 +84,6 @@ resource_size_t mgag200_probe_vram(void __iomem *mem, resource_size_t size)return offset -65536 ; } -#if defined(CONFIG_DRM_MGAG200_IOBURST_WORKAROUND ) -static struct drm_gem_object *mgag200_create_object (struct drm_device *dev,size_t size) -{ -struct drm_gem_shmem_object *shmem; - - shmem =kzalloc (sizeof (*shmem),GFP_KERNEL ); -if (!shmem) -return NULL ; - - shmem->map_wc = true; -return &shmem->base; -} -#endif -/* * DRM driver */ @@ -113,9 +99,6 @@ static const struct drm_driver mgag200_driver = { .major = DRIVER_MAJOR, .minor = DRIVER_MINOR, .patchlevel = DRIVER_PATCHLEVEL, -#if defined(CONFIG_DRM_MGAG200_IOBURST_WORKAROUND ) - .gem_create_object = mgag200_create_object, -#endif DRM_GEM_SHMEM_DRIVER_OPS, };drivers/gpu/drm/mgag200/mgag200_mode.c +0
-8@@ -13,7 +13,6 @@#include <drm/drm_atomic.h> #include <drm/drm_atomic_helper.h> -#include <drm/drm_cache.h> #include <drm/drm_damage_helper.h> #include <drm/drm_edid.h> #include <drm/drm_format_helper.h> @@ -438,13 +437,6 @@ static void mgag200_handle_damage(struct mga_device *mdev, const struct iosys_maiosys_map_incr (&dst,drm_fb_clip_offset (fb->pitches[0 ], fb->format, clip));drm_fb_memcpy (&dst, fb->pitches, vmap, fb, clip); - -/* Flushing the cache greatly improves latency on x86_64 */ -#if defined(CONFIG_DRM_MGAG200_IOBURST_WORKAROUND ) -if (!vmap->is_iomem) -drm_clflush_virt_range (vmap->vaddr + clip->y1 * fb->pitches[0 ], -drm_rect_height (clip) * fb->pitches[0 ]); -#endif }/*
Signature · 7 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)
Jocelyn Falempe
reviewerPATCH 2/2 drm/mgag200: Add an option to disable Write-Combine
In reply to Jocelyn FalempeUnfortunately, the G200 ioburst workaround doesn't work on some servers like Dell poweredge XR11, XR5610, or HPE XL260
In this case completely disabling WC is the only option to achieve low-latency.
So this adds a new Kconfig option, to disable WC mapping of the G200
--- drivers/gpu/drm/mgag200/Kconfig | 10 ++++++++++ drivers/gpu/drm/mgag200/mgag200_drv.c | 7 +++++++ 2 files changed, 17 insertions(+)
drivers/gpu/drm/mgag200/Kconfig +10 -0
@@ -11,3 +11,13 @@ config DRM_MGAG200 MGA G200 desktop chips and the server variants. It requires 0.3.0 of the modesetting userspace driver, and a version of mga driver that will fail on KMS enabled devices. + +config DRM_MGAG200_DISABLE_WRITECOMBINE + bool "Disable Write Combine mapping of VRAM" + depends on DRM_MGAG200 && PREEMPT_RT + help + The VRAM of the G200 is mapped with Write-Combine, to improve + performances. However this increases the system latency a lot, even + for realtime tasks running on other CPU cores. Typically 40us-80us + latencies are measured with hwlat when Write Combine is enabled. + Recommended if you run realtime tasks on a server with a Matrox G200.
drivers/gpu/drm/mgag200/mgag200_drv.c +7 -0
@@ -146,12 +146,19 @@ int mgag200_device_preinit(struct mga_device *mdev) } mdev->vram_res = res; +#if defined(CONFIG_DRM_MGAG200_DISABLE_WRITECOMBINE ) +drm_info (dev,"Disable Write Combine\n" ); + mdev->vram =devm_ioremap (dev->dev, res->start,resource_size (res)); +if (!mdev->vram) +return -ENOMEM ; +#else 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)); +#endif return 0 ; }
Signature · 1 line
2.45.0
Thomas Zimmermann
maintainerHi,
just nits below.
Am 16.05.24 um 18:17 schrieb Jocelyn Falempe:
Quoted 5 lines
Unfortunately, the G200 ioburst workaround doesn't work on some servers like Dell poweredge XR11, XR5610, or HPE XL260
In this case completely disabling WC is the only option to achieve low-latency.
So this adds a newKconfigoption, to disable WC mapping of the G200
The formatting look off. Maybe make this one single paragraph.
No comma after 'option'.
Quoted 12 lines
Signed-off-by Jocelyn Falempe <[email protected]>--- drivers/gpu/drm/mgag200/Kconfig | 10 ++++++++++ drivers/gpu/drm/mgag200/mgag200_drv.c | 7 +++++++ 2 files changed, 17 insertions(+)drivers/gpu/drm/mgag200/Kconfig +0
-0
drivers/gpu/drm/mgag200/Kconfig config DRM_MGAG200 · line 19
Quoted 9 lines
drivers/gpu/drm/mgag200/Kconfig +6
-0@@ -11,3 +11,13 @@ config DRM_MGAG200 MGA G200 desktop chips and the server variants. It requires 0.3.0 of the modesetting userspace driver, and a version of mga driver that will fail on KMS enabled devices. + +config DRM_MGAG200_DISABLE_WRITECOMBINE + bool "Disable Write Combine mapping of VRAM" + depends on DRM_MGAG200 && PREEMPT_RT + help + The VRAM of the G200 is mapped with Write-Combine, to improve
No comma after Write-Combine
drivers/gpu/drm/mgag200/Kconfig config DRM_MGAG200 · line 20
Quoted 1 line
drivers/gpu/drm/mgag200/Kconfig +1
-0+ performances. However this increases the system latency a lot, even
Just say "This can interfere with real-time tasks; even if they are running on other CPU cores then the graphics output."
drivers/gpu/drm/mgag200/Kconfig config DRM_MGAG200 · line 22
Quoted 2 lines
drivers/gpu/drm/mgag200/Kconfig +2
-0+ for realtime tasks running on other CPU cores. Typically 40us-80us + latencies are measured with hwlat when Write Combine is enabled.
Leave out the next sentence: "Typically ..." The measureed numbers depend on the hardware and everyone is encouraged to test on their own system. You could mention the numbers in the commit description, as you already mention the affected systems there.
drivers/gpu/drm/mgag200/Kconfig config DRM_MGAG200 · line 23
Quoted 1 line
drivers/gpu/drm/mgag200/Kconfig +1
-0+ Recommended if you run realtime tasks on a server with a Matrox G200.
I still think that we should not encourage anyone to use this option. Maybe say "Enable this option only if you run..."
drivers/gpu/drm/mgag200/mgag200_drv.c int mgag200_device_preinit(struct mga_device *mdev) · line 150
Quoted 11 lines
\ No newline at end of file
drivers/gpu/drm/mgag200/mgag200_drv.c +2
-0@@ -146,12 +146,19 @@ int mgag200_device_preinit(struct mga_device *mdev) } mdev->vram_res = res; +#if defined(CONFIG_DRM_MGAG200_DISABLE_WRITECOMBINE ) +drm_info (dev,"Disable Write Combine\n" );
I would not print this drm_info() here. The user has selected the config option, so they should know what happens. It's also listed in /proc/mtrr IIRC.
Best regards
Thomas
Quoted 14 lines
drivers/gpu/drm/mgag200/mgag200_drv.c +5
-0+ mdev->vram =devm_ioremap (dev->dev, res->start,resource_size (res)); +if (!mdev->vram) +return -ENOMEM ; +#else 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)); +#endif return 0 ; }
Signature · 7 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)
Jocelyn Falempe
reviewerQuoted 4 lines · Thomas Zimmermann
Hi,
just nits below.
Quoted 8 lines
Am 16.05.24 um 18:17 schrieb Jocelyn Falempe:
Quoted 5 lines
Unfortunately, the G200 ioburst workaround doesn't work on some servers like Dell poweredge XR11, XR5610, or HPE XL260
In this case completely disabling WC is the only option to achieve low-latency.
So this adds a newKconfigoption, to disable WC mapping of the G200The formatting look off. Maybe make this one single paragraph.
Ok,
Quoted 2 lines
No comma after 'option'.
Ok,
Quoted 8 lines
Quoted 8 lines
Signed-off-by Jocelyn Falempe <[email protected]>---
drivers/gpu/drm/mgag200/Kconfig | 10 ++++++++++drivers/gpu/drm/mgag200/mgag200_drv.c| 7 +++++++2 files changed, 17 insertions(+)
Quoted 15 lines
Quoted 8 lines
drivers/gpu/drm/mgag200/Kconfig +0
-0@@ -11,3 +11,13 @@ config DRM_MGAG200MGA G200 desktop chips and the server variants. It requires 0.3.0 of the modesetting userspace driver, and a version of mga driver that will fail on KMS enabled devices.
drivers/gpu/drm/mgag200/Kconfig config DRM_MGAG200 · line 19
Quoted 6 lines
drivers/gpu/drm/mgag200/Kconfig +6
-0+ +config DRM_MGAG200_DISABLE_WRITECOMBINE + bool "Disable Write Combine mapping of VRAM" + depends on DRM_MGAG200 && PREEMPT_RT + help + The VRAM of the G200 is mapped with Write-Combine, to improveNo comma after Write-Combine
Ok
Quoted 3 lines
Quoted 2 lines
+ performances. However this increases the system latency a lot, even
Just say "This can interfere with real-time tasks; even if they are running on other CPU cores then the graphics output."
Ok
Quoted 5 lines
Quoted 3 lines
+ for realtime tasks running on other CPU cores. Typically 40us-80us + latencies are measured with hwlat when Write Combine is enabled.
Leave out the next sentence: "Typically ..." The measureed numbers depend on the hardware and everyone is encouraged to test on their own system. You could mention the numbers in the commit description, as you already mention the affected systems there.
Ok
Quoted 5 lines
Quoted 3 lines
+ Recommended if you run realtime tasks on a server with a Matrox G200.
I still think that we should not encourage anyone to use this option. Maybe say "Enable this option only if you run..."
Agreed, I will change this.
Quoted 13 lines
drivers/gpu/drm/mgag200/mgag200_drv.c int mgag200_device_preinit(struct mga_device *mdev) · line 149
Quoted 11 lines
\ No newline at end of file
drivers/gpu/drm/mgag200/mgag200_drv.c +2
-0@@ -146,12 +146,19 @@ int mgag200_device_preinit(struct mga_device *mdev) } mdev->vram_res = res; +#if defined(CONFIG_DRM_MGAG200_DISABLE_WRITECOMBINE ) + drm_info(dev, "Disable Write Combine\n");I would not print this
drm_info()here. The user has selected the config option, so they should know what happens. It's also listed in/proc/mtrrIIRC.
Sure, I can remove the drm_info().
Thanks for the review, I will send a v2 shortly.
Quoted 17 lines
Best regards
ThomasQuoted 12 lines
drivers/gpu/drm/mgag200/mgag200_drv.c +5
-0+ mdev->vram = devm_ioremap(dev->dev, res->start, resource_size(res)); + if (!mdev->vram) + return -ENOMEM; +#else 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)); +#endif return 0; }