WC-mapped video memory presumably has PCI I/O bursts that interfere
with real-time tasks. Seen on AST2600 hardware.

Add an Kconfig option to ast for vmapping the video memory uncached
if CONFIG_RT=y. If set, video-memory access is slower, but avoids
I/O bursts on the PCI us. Mirrors a similar change to mgag200 in
commit b593ea940623 ("drm/mgag200: Add an option to disable
Write-Combine").

Signed-off-by: Thomas Zimmermann <[email protected]>
Fixes: f2fa5a99ca81 ("drm/ast: Convert ast to SHMEM")
Cc: <[email protected]> # v6.2+
---
 drivers/gpu/drm/ast/Kconfig  |  9 +++++++++
 drivers/gpu/drm/ast/ast_mm.c | 13 +++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/ast/Kconfig b/drivers/gpu/drm/ast/Kconfig
index 242fbccdf844..f2c99e99b5b4 100644
--- a/drivers/gpu/drm/ast/Kconfig
+++ b/drivers/gpu/drm/ast/Kconfig
@@ -14,3 +14,12 @@ config DRM_AST
         is bound to the driver. These GPUs are commonly found
         in server chipsets.
 
+config DRM_AST_DISABLE_WRITECOMBINE
+       bool "Disable Write Combine mapping of VRAM"
+       depends on DRM_AST && (PREEMPT_RT || COMPILE_TEST)
+       help
+         The VRAM of AST GPUs is mapped with Write-Combine to improve
+         performances. This can interfere with real-time tasks; even if they
+         are running on other CPU cores than the graphics output.
+         Enable this option only if you run real-time tasks on a server with
+         Aspeed graphics.
diff --git a/drivers/gpu/drm/ast/ast_mm.c b/drivers/gpu/drm/ast/ast_mm.c
index 0bc140319464..cc882d2c172d 100644
--- a/drivers/gpu/drm/ast/ast_mm.c
+++ b/drivers/gpu/drm/ast/ast_mm.c
@@ -74,6 +74,18 @@ int ast_mm_init(struct ast_device *ast)
 {
        struct drm_device *dev = &ast->base;
        struct pci_dev *pdev = to_pci_dev(dev->dev);
+#if defined(CONFIG_DRM_AST_DISABLE_WRITECOMBINE)
+       resource_size_t base;
+       u32 vram_size;
+
+       base = pci_resource_start(pdev, 0);
+
+       vram_size = ast_get_vram_size(ast);
+
+       ast->vram = devm_ioremap(dev->dev, base, vram_size);
+       if (!ast->vram)
+               return -ENOMEM;
+#else
        resource_size_t base, size;
        u32 vram_size;
 
@@ -89,6 +101,7 @@ int ast_mm_init(struct ast_device *ast)
        ast->vram = devm_ioremap_wc(dev->dev, base, vram_size);
        if (!ast->vram)
                return -ENOMEM;
+#endif
 
        ast->vram_base = base;
        ast->vram_size = vram_size;

base-commit: 7d502136b31169f6b5575f7f89c3da60cdf7891d
-- 
2.56.0

Reply via email to