Commit 8ec6a72d authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/simpledrm: Request memory region in driver

Requesting the framebuffer memory in simpledrm marks the memory
range as busy. This used to be done by the firmware sysfb code,
but the driver is the correct place.

v2:
	* use I/O memory if request_mem_region() fails (Jocelyn)
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Reviewed-by: default avatarJocelyn Falempe <jfalempe@redhat.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220125091222.21457-4-tzimmermann@suse.de
parent c9689834
...@@ -526,21 +526,33 @@ static int simpledrm_device_init_mm(struct simpledrm_device *sdev) ...@@ -526,21 +526,33 @@ static int simpledrm_device_init_mm(struct simpledrm_device *sdev)
{ {
struct drm_device *dev = &sdev->dev; struct drm_device *dev = &sdev->dev;
struct platform_device *pdev = sdev->pdev; struct platform_device *pdev = sdev->pdev;
struct resource *mem; struct resource *res, *mem;
void __iomem *screen_base; void __iomem *screen_base;
int ret; int ret;
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) if (!res)
return -EINVAL; return -EINVAL;
ret = devm_aperture_acquire_from_firmware(dev, mem->start, resource_size(mem)); ret = devm_aperture_acquire_from_firmware(dev, res->start, resource_size(res));
if (ret) { if (ret) {
drm_err(dev, "could not acquire memory range %pr: error %d\n", drm_err(dev, "could not acquire memory range %pr: error %d\n",
mem, ret); res, ret);
return ret; return ret;
} }
mem = devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
sdev->dev.driver->name);
if (!mem) {
/*
* We cannot make this fatal. Sometimes this comes from magic
* spaces our resource handlers simply don't know about. Use
* the I/O-memory resource as-is and try to map that instead.
*/
drm_warn(dev, "could not acquire memory region %pr\n", res);
mem = res;
}
screen_base = devm_ioremap_wc(&pdev->dev, mem->start, screen_base = devm_ioremap_wc(&pdev->dev, mem->start,
resource_size(mem)); resource_size(mem));
if (!screen_base) if (!screen_base)
......
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