Commit 13daf536 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'drm-misc-next-fixes-2023-02-21' of...

Merge tag 'drm-misc-next-fixes-2023-02-21' of git://anongit.freedesktop.org/drm/drm-misc into drm-next

Short summary of fixes pull:

Fixes GEM SHMEM locking and generic fbdev hotplugging. Constifies
dma_buf kobj type.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>

From: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/Y/S6tu3gdQ0VizR+@linux-uq9g
parents 5582f3c1 3fb1f62f
...@@ -112,7 +112,7 @@ static void dma_buf_sysfs_release(struct kobject *kobj) ...@@ -112,7 +112,7 @@ static void dma_buf_sysfs_release(struct kobject *kobj)
kfree(sysfs_entry); kfree(sysfs_entry);
} }
static struct kobj_type dma_buf_ktype = { static const struct kobj_type dma_buf_ktype = {
.sysfs_ops = &dma_buf_stats_sysfs_ops, .sysfs_ops = &dma_buf_stats_sysfs_ops,
.release = dma_buf_sysfs_release, .release = dma_buf_sysfs_release,
.default_groups = dma_buf_stats_default_groups, .default_groups = dma_buf_stats_default_groups,
......
...@@ -147,6 +147,7 @@ int armada_fbdev_init(struct drm_device *dev) ...@@ -147,6 +147,7 @@ int armada_fbdev_init(struct drm_device *dev)
err_fb_setup: err_fb_setup:
drm_fb_helper_fini(fbh); drm_fb_helper_fini(fbh);
err_fb_helper: err_fb_helper:
drm_fb_helper_unprepare(fbh);
priv->fbdev = NULL; priv->fbdev = NULL;
return ret; return ret;
} }
...@@ -164,6 +165,8 @@ void armada_fbdev_fini(struct drm_device *dev) ...@@ -164,6 +165,8 @@ void armada_fbdev_fini(struct drm_device *dev)
if (fbh->fb) if (fbh->fb)
fbh->fb->funcs->destroy(fbh->fb); fbh->fb->funcs->destroy(fbh->fb);
drm_fb_helper_unprepare(fbh);
priv->fbdev = NULL; priv->fbdev = NULL;
} }
} }
...@@ -590,8 +590,6 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper) ...@@ -590,8 +590,6 @@ void drm_fb_helper_fini(struct drm_fb_helper *fb_helper)
} }
mutex_unlock(&kernel_fb_helper_lock); mutex_unlock(&kernel_fb_helper_lock);
drm_fb_helper_unprepare(fb_helper);
if (!fb_helper->client.funcs) if (!fb_helper->client.funcs)
drm_client_release(&fb_helper->client); drm_client_release(&fb_helper->client);
} }
......
...@@ -65,6 +65,8 @@ static void drm_fbdev_fb_destroy(struct fb_info *info) ...@@ -65,6 +65,8 @@ static void drm_fbdev_fb_destroy(struct fb_info *info)
drm_client_framebuffer_delete(fb_helper->buffer); drm_client_framebuffer_delete(fb_helper->buffer);
drm_client_release(&fb_helper->client); drm_client_release(&fb_helper->client);
drm_fb_helper_unprepare(fb_helper);
kfree(fb_helper); kfree(fb_helper);
} }
......
...@@ -678,23 +678,7 @@ struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem) ...@@ -678,23 +678,7 @@ struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem)
} }
EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table); EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table);
/** static struct sg_table *drm_gem_shmem_get_pages_sgt_locked(struct drm_gem_shmem_object *shmem)
* drm_gem_shmem_get_pages_sgt - Pin pages, dma map them, and return a
* scatter/gather table for a shmem GEM object.
* @shmem: shmem GEM object
*
* This function returns a scatter/gather table suitable for driver usage. If
* the sg table doesn't exist, the pages are pinned, dma-mapped, and a sg
* table created.
*
* This is the main function for drivers to get at backing storage, and it hides
* and difference between dma-buf imported and natively allocated objects.
* drm_gem_shmem_get_sg_table() should not be directly called by drivers.
*
* Returns:
* A pointer to the scatter/gather table of pinned pages or errno on failure.
*/
struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)
{ {
struct drm_gem_object *obj = &shmem->base; struct drm_gem_object *obj = &shmem->base;
int ret; int ret;
...@@ -705,7 +689,7 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem) ...@@ -705,7 +689,7 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)
WARN_ON(obj->import_attach); WARN_ON(obj->import_attach);
ret = drm_gem_shmem_get_pages(shmem); ret = drm_gem_shmem_get_pages_locked(shmem);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -727,10 +711,40 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem) ...@@ -727,10 +711,40 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)
sg_free_table(sgt); sg_free_table(sgt);
kfree(sgt); kfree(sgt);
err_put_pages: err_put_pages:
drm_gem_shmem_put_pages(shmem); drm_gem_shmem_put_pages_locked(shmem);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(drm_gem_shmem_get_pages_sgt);
/**
* drm_gem_shmem_get_pages_sgt - Pin pages, dma map them, and return a
* scatter/gather table for a shmem GEM object.
* @shmem: shmem GEM object
*
* This function returns a scatter/gather table suitable for driver usage. If
* the sg table doesn't exist, the pages are pinned, dma-mapped, and a sg
* table created.
*
* This is the main function for drivers to get at backing storage, and it hides
* and difference between dma-buf imported and natively allocated objects.
* drm_gem_shmem_get_sg_table() should not be directly called by drivers.
*
* Returns:
* A pointer to the scatter/gather table of pinned pages or errno on failure.
*/
struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)
{
int ret;
struct sg_table *sgt;
ret = mutex_lock_interruptible(&shmem->pages_lock);
if (ret)
return ERR_PTR(ret);
sgt = drm_gem_shmem_get_pages_sgt_locked(shmem);
mutex_unlock(&shmem->pages_lock);
return sgt;
}
EXPORT_SYMBOL(drm_gem_shmem_get_pages_sgt);
/** /**
* drm_gem_shmem_prime_import_sg_table - Produce a shmem GEM object from * drm_gem_shmem_prime_import_sg_table - Produce a shmem GEM object from
......
...@@ -183,8 +183,8 @@ int exynos_drm_fbdev_init(struct drm_device *dev) ...@@ -183,8 +183,8 @@ int exynos_drm_fbdev_init(struct drm_device *dev)
err_setup: err_setup:
drm_fb_helper_fini(helper); drm_fb_helper_fini(helper);
err_init: err_init:
drm_fb_helper_unprepare(helper);
private->fb_helper = NULL; private->fb_helper = NULL;
kfree(fbdev); kfree(fbdev);
...@@ -219,6 +219,7 @@ void exynos_drm_fbdev_fini(struct drm_device *dev) ...@@ -219,6 +219,7 @@ void exynos_drm_fbdev_fini(struct drm_device *dev)
fbdev = to_exynos_fbdev(private->fb_helper); fbdev = to_exynos_fbdev(private->fb_helper);
exynos_drm_fbdev_destroy(dev, private->fb_helper); exynos_drm_fbdev_destroy(dev, private->fb_helper);
drm_fb_helper_unprepare(private->fb_helper);
kfree(fbdev); kfree(fbdev);
private->fb_helper = NULL; private->fb_helper = NULL;
} }
......
...@@ -427,6 +427,7 @@ int psb_fbdev_init(struct drm_device *dev) ...@@ -427,6 +427,7 @@ int psb_fbdev_init(struct drm_device *dev)
fini: fini:
drm_fb_helper_fini(fb_helper); drm_fb_helper_fini(fb_helper);
free: free:
drm_fb_helper_unprepare(fb_helper);
kfree(fb_helper); kfree(fb_helper);
return ret; return ret;
} }
...@@ -439,6 +440,7 @@ static void psb_fbdev_fini(struct drm_device *dev) ...@@ -439,6 +440,7 @@ static void psb_fbdev_fini(struct drm_device *dev)
return; return;
psb_fbdev_destroy(dev, dev_priv->fb_helper); psb_fbdev_destroy(dev, dev_priv->fb_helper);
drm_fb_helper_unprepare(dev_priv->fb_helper);
kfree(dev_priv->fb_helper); kfree(dev_priv->fb_helper);
dev_priv->fb_helper = NULL; dev_priv->fb_helper = NULL;
} }
......
...@@ -340,6 +340,7 @@ static void intel_fbdev_destroy(struct intel_fbdev *ifbdev) ...@@ -340,6 +340,7 @@ static void intel_fbdev_destroy(struct intel_fbdev *ifbdev)
if (ifbdev->fb) if (ifbdev->fb)
drm_framebuffer_remove(&ifbdev->fb->base); drm_framebuffer_remove(&ifbdev->fb->base);
drm_fb_helper_unprepare(&ifbdev->helper);
kfree(ifbdev); kfree(ifbdev);
} }
......
...@@ -170,6 +170,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev) ...@@ -170,6 +170,7 @@ struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev)
fini: fini:
drm_fb_helper_fini(helper); drm_fb_helper_fini(helper);
fail: fail:
drm_fb_helper_unprepare(helper);
kfree(fbdev); kfree(fbdev);
return NULL; return NULL;
} }
...@@ -196,6 +197,7 @@ void msm_fbdev_free(struct drm_device *dev) ...@@ -196,6 +197,7 @@ void msm_fbdev_free(struct drm_device *dev)
drm_framebuffer_remove(fbdev->fb); drm_framebuffer_remove(fbdev->fb);
} }
drm_fb_helper_unprepare(helper);
kfree(fbdev); kfree(fbdev);
priv->fbdev = NULL; priv->fbdev = NULL;
......
...@@ -256,6 +256,7 @@ void omap_fbdev_init(struct drm_device *dev) ...@@ -256,6 +256,7 @@ void omap_fbdev_init(struct drm_device *dev)
fini: fini:
drm_fb_helper_fini(helper); drm_fb_helper_fini(helper);
fail: fail:
drm_fb_helper_unprepare(helper);
kfree(fbdev); kfree(fbdev);
dev_warn(dev->dev, "omap_fbdev_init failed\n"); dev_warn(dev->dev, "omap_fbdev_init failed\n");
...@@ -286,6 +287,7 @@ void omap_fbdev_fini(struct drm_device *dev) ...@@ -286,6 +287,7 @@ void omap_fbdev_fini(struct drm_device *dev)
if (fbdev->fb) if (fbdev->fb)
drm_framebuffer_remove(fbdev->fb); drm_framebuffer_remove(fbdev->fb);
drm_fb_helper_unprepare(helper);
kfree(fbdev); kfree(fbdev);
priv->fbdev = NULL; priv->fbdev = NULL;
......
...@@ -367,6 +367,7 @@ int radeon_fbdev_init(struct radeon_device *rdev) ...@@ -367,6 +367,7 @@ int radeon_fbdev_init(struct radeon_device *rdev)
fini: fini:
drm_fb_helper_fini(&rfbdev->helper); drm_fb_helper_fini(&rfbdev->helper);
free: free:
drm_fb_helper_unprepare(&rfbdev->helper);
kfree(rfbdev); kfree(rfbdev);
return ret; return ret;
} }
...@@ -377,6 +378,7 @@ void radeon_fbdev_fini(struct radeon_device *rdev) ...@@ -377,6 +378,7 @@ void radeon_fbdev_fini(struct radeon_device *rdev)
return; return;
radeon_fbdev_destroy(rdev->ddev, rdev->mode_info.rfbdev); radeon_fbdev_destroy(rdev->ddev, rdev->mode_info.rfbdev);
drm_fb_helper_unprepare(&rdev->mode_info.rfbdev->helper);
kfree(rdev->mode_info.rfbdev); kfree(rdev->mode_info.rfbdev);
rdev->mode_info.rfbdev = NULL; rdev->mode_info.rfbdev = NULL;
} }
......
...@@ -315,6 +315,7 @@ static struct tegra_fbdev *tegra_fbdev_create(struct drm_device *drm) ...@@ -315,6 +315,7 @@ static struct tegra_fbdev *tegra_fbdev_create(struct drm_device *drm)
static void tegra_fbdev_free(struct tegra_fbdev *fbdev) static void tegra_fbdev_free(struct tegra_fbdev *fbdev)
{ {
drm_fb_helper_unprepare(&fbdev->base);
kfree(fbdev); kfree(fbdev);
} }
......
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