]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/ast: Use managed interfaces for framebuffer write combining
authorThomas Zimmermann <tzimmermann@suse.de>
Thu, 16 Sep 2021 18:15:59 +0000 (20:15 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Thu, 23 Sep 2021 07:26:09 +0000 (09:26 +0200)
Replace arch_phys_wc_add() and arch_io_reserve_memtype_wc() with
the rsp managed functions. Allows for removing the cleanup code
for memory management

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210916181601.9146-4-tzimmermann@suse.de
drivers/gpu/drm/ast/ast_drv.h
drivers/gpu/drm/ast/ast_mm.c

index 39ca338eb80b310c51e6767f57afa127b24a08a1..2cfce7dc95aff0519fdb283f9f29711336771418 100644 (file)
@@ -158,8 +158,6 @@ struct ast_private {
        uint32_t dram_type;
        uint32_t mclk;
 
-       int fb_mtrr;
-
        struct drm_plane primary_plane;
        struct ast_cursor_plane cursor_plane;
        struct drm_crtc crtc;
index 7592f1b9e1f1973107aca1a52b38c02a3a1f2700..6e999408dda9a25acbe492329eb3c94bf40d2b28 100644 (file)
@@ -74,35 +74,28 @@ static u32 ast_get_vram_size(struct ast_private *ast)
        return vram_size;
 }
 
-static void ast_mm_release(struct drm_device *dev, void *ptr)
-{
-       struct ast_private *ast = to_ast_private(dev);
-       struct pci_dev *pdev = to_pci_dev(dev->dev);
-
-       arch_phys_wc_del(ast->fb_mtrr);
-       arch_io_free_memtype_wc(pci_resource_start(pdev, 0),
-                               pci_resource_len(pdev, 0));
-}
-
 int ast_mm_init(struct ast_private *ast)
 {
        struct drm_device *dev = &ast->base;
        struct pci_dev *pdev = to_pci_dev(dev->dev);
+       resource_size_t base, size;
        u32 vram_size;
        int ret;
 
+       base = pci_resource_start(pdev, 0);
+       size = pci_resource_len(pdev, 0);
+
+       /* Don't fail on errors, but performance might be reduced. */
+       devm_arch_io_reserve_memtype_wc(dev->dev, base, size);
+       devm_arch_phys_wc_add(dev->dev, base, size);
+
        vram_size = ast_get_vram_size(ast);
 
-       ret = drmm_vram_helper_init(dev, pci_resource_start(pdev, 0), vram_size);
+       ret = drmm_vram_helper_init(dev, base, vram_size);
        if (ret) {
                drm_err(dev, "Error initializing VRAM MM; %d\n", ret);
                return ret;
        }
 
-       arch_io_reserve_memtype_wc(pci_resource_start(pdev, 0),
-                                  pci_resource_len(pdev, 0));
-       ast->fb_mtrr = arch_phys_wc_add(pci_resource_start(pdev, 0),
-                                       pci_resource_len(pdev, 0));
-
-       return drmm_add_action_or_reset(dev, ast_mm_release, NULL);
+       return 0;
 }