Commit f3eb831e authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/mgag200: Use managed interfaces for framebuffer write combining

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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210916181601.9146-5-tzimmermann@suse.de
parent 23b405bf
...@@ -224,8 +224,6 @@ struct mga_device { ...@@ -224,8 +224,6 @@ struct mga_device {
enum mga_type type; enum mga_type type;
int fb_mtrr;
union { union {
struct { struct {
long ref_clk; long ref_clk;
......
...@@ -75,26 +75,12 @@ static size_t mgag200_probe_vram(struct mga_device *mdev, void __iomem *mem, ...@@ -75,26 +75,12 @@ static size_t mgag200_probe_vram(struct mga_device *mdev, void __iomem *mem,
return offset - 65536; return offset - 65536;
} }
static void mgag200_mm_release(struct drm_device *dev, void *ptr)
{
struct mga_device *mdev = to_mga_device(dev);
struct pci_dev *pdev = to_pci_dev(dev->dev);
mdev->vram_fb_available = 0;
iounmap(mdev->vram);
arch_io_free_memtype_wc(pci_resource_start(pdev, 0),
pci_resource_len(pdev, 0));
arch_phys_wc_del(mdev->fb_mtrr);
mdev->fb_mtrr = 0;
}
int mgag200_mm_init(struct mga_device *mdev) int mgag200_mm_init(struct mga_device *mdev)
{ {
struct drm_device *dev = &mdev->base; struct drm_device *dev = &mdev->base;
struct pci_dev *pdev = to_pci_dev(dev->dev); struct pci_dev *pdev = to_pci_dev(dev->dev);
u8 misc; u8 misc;
resource_size_t start, len; resource_size_t start, len;
int ret;
WREG_ECRT(0x04, 0x00); WREG_ECRT(0x04, 0x00);
...@@ -112,15 +98,13 @@ int mgag200_mm_init(struct mga_device *mdev) ...@@ -112,15 +98,13 @@ int mgag200_mm_init(struct mga_device *mdev)
return -ENXIO; return -ENXIO;
} }
arch_io_reserve_memtype_wc(start, len); /* Don't fail on errors, but performance might be reduced. */
devm_arch_io_reserve_memtype_wc(dev->dev, start, len);
mdev->fb_mtrr = arch_phys_wc_add(start, len); devm_arch_phys_wc_add(dev->dev, start, len);
mdev->vram = ioremap(start, len); mdev->vram = devm_ioremap(dev->dev, start, len);
if (!mdev->vram) { if (!mdev->vram)
ret = -ENOMEM; return -ENOMEM;
goto err_arch_phys_wc_del;
}
mdev->mc.vram_size = mgag200_probe_vram(mdev, mdev->vram, len); mdev->mc.vram_size = mgag200_probe_vram(mdev, mdev->vram, len);
mdev->mc.vram_base = start; mdev->mc.vram_base = start;
...@@ -128,10 +112,5 @@ int mgag200_mm_init(struct mga_device *mdev) ...@@ -128,10 +112,5 @@ int mgag200_mm_init(struct mga_device *mdev)
mdev->vram_fb_available = mdev->mc.vram_size; mdev->vram_fb_available = mdev->mc.vram_size;
return drmm_add_action_or_reset(dev, mgag200_mm_release, NULL); return 0;
err_arch_phys_wc_del:
arch_phys_wc_del(mdev->fb_mtrr);
arch_io_free_memtype_wc(start, len);
return ret;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment