summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/mgag200/mgag200_mm.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2020-06-05 15:57:56 +0200
committerThomas Zimmermann <tzimmermann@suse.de>2020-06-11 10:05:47 +0200
commita71ff21e11d906f0ba85544a8267760459428603 (patch)
tree749c2ebc415d16cbd4b4b63e5b0ea6eb07e7c960 /drivers/gpu/drm/mgag200/mgag200_mm.c
parentdrm/mgag200: Merge VRAM setup into MM initialization (diff)
downloadlinux-a71ff21e11d906f0ba85544a8267760459428603.tar.xz
linux-a71ff21e11d906f0ba85544a8267760459428603.zip
drm/mgag200: Switch to managed MM
The memory-management code now cleans up automatically as part of device destruction. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20200605135803.19811-8-tzimmermann@suse.de
Diffstat (limited to '')
-rw-r--r--drivers/gpu/drm/mgag200/mgag200_mm.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/gpu/drm/mgag200/mgag200_mm.c b/drivers/gpu/drm/mgag200/mgag200_mm.c
index f56b0456994f..1b1e5ec5d1ce 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mm.c
@@ -28,6 +28,8 @@
#include <linux/pci.h>
+#include <drm/drm_managed.h>
+
#include "mgag200_drv.h"
static size_t mgag200_probe_vram(struct mga_device *mdev, void __iomem *mem,
@@ -73,6 +75,18 @@ static size_t mgag200_probe_vram(struct mga_device *mdev, void __iomem *mem,
return offset - 65536;
}
+static void mgag200_mm_release(struct drm_device *dev, void *ptr)
+{
+ struct mga_device *mdev = to_mga_device(dev);
+
+ mdev->vram_fb_available = 0;
+ iounmap(mdev->vram);
+ arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
+ pci_resource_len(dev->pdev, 0));
+ arch_phys_wc_del(mdev->fb_mtrr);
+ mdev->fb_mtrr = 0;
+}
+
int mgag200_mm_init(struct mga_device *mdev)
{
struct drm_device *dev = mdev->dev;
@@ -104,22 +118,10 @@ int mgag200_mm_init(struct mga_device *mdev)
mdev->vram_fb_available = mdev->mc.vram_size;
- return 0;
+ return drmm_add_action_or_reset(dev, mgag200_mm_release, NULL);
err_arch_phys_wc_del:
arch_phys_wc_del(mdev->fb_mtrr);
arch_io_free_memtype_wc(start, len);
return ret;
}
-
-void mgag200_mm_fini(struct mga_device *mdev)
-{
- struct drm_device *dev = mdev->dev;
-
- mdev->vram_fb_available = 0;
- iounmap(mdev->vram);
- arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
- pci_resource_len(dev->pdev, 0));
- arch_phys_wc_del(mdev->fb_mtrr);
- mdev->fb_mtrr = 0;
-}