drm: Support CMA per allocation kernel mappings
Subsystems (16)
cover drm: Support CMA per allocation kernel mappings
This series adds support for CMA/DMA users to skip kernel mappings for GEM allocations. The DMA API only guarantees a kernel mapping at allocation time. Creating mappings with vmap() after allocation may or may not work as not all allocations have a struct page. As virtual memory space is limited on 32-bit systems some drivers will skip kernel mappings when possible. This prevents those drivers from using CMA helpers and the generic fbdev emulation which results in a lot of duplicated code.
In order to distinguish between kernel and userspace allocations, a new flag, DRM_MODE_DUMB_KERNEL_MAP, for drm_mode_create_dumb() is introduced. This allows drivers to override the default behavior for CMA helpers of always creating a kernel mapping.
Mediatek is converted to CMA helpers and Rockchip is converted to generic fbdev support. I also have patches to convert Rockchip to CMA and shmem helpers, but they need a bit more work. Exynos can also probably be converted to use CMA helpers.
Compile tested only. I did test fbdev on Rockchip, but the h/w I have has an IOMMU, so the CMA code path doesn't get tested.
Rob
Rob Herring (6):
drm/kirin: Use DRM_GEM_CMA_VMAP_DRIVER_OPS
drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flag drm/cma-helper: Use the dma_*_attr API variant drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag drm/mediatek: Convert to use CMA helpers drm/rockchip: Convert to use generic fbdev emulation
.../gpu/drm/arm/display/komeda/komeda_kms.c | 1 + drivers/gpu/drm/arm/malidp_drv.c | 1 + drivers/gpu/drm/drm_client.c | 1 + drivers/gpu/drm/drm_dumb_buffers.c | 5 +- drivers/gpu/drm/drm_gem_cma_helper.c | 68 +++-- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 11 +- drivers/gpu/drm/mediatek/Makefile | 1 - drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 28 +- drivers/gpu/drm/mediatek/mtk_drm_fb.c | 1 - drivers/gpu/drm/mediatek/mtk_drm_gem.c | 289 ------------------ drivers/gpu/drm/mediatek/mtk_drm_gem.h | 51 ---- drivers/gpu/drm/mediatek/mtk_drm_plane.c | 7 +- drivers/gpu/drm/meson/meson_drv.c | 1 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 1 + drivers/gpu/drm/rockchip/Makefile | 1 - drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 10 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 - drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 14 - drivers/gpu/drm/rockchip/rockchip_drm_fb.h | 6 - drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 170 ----------- drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h | 24 -- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 6 +- drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 4 - drivers/gpu/drm/stm/drv.c | 1 + drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + include/drm/drm_gem_cma_helper.h | 1 + include/uapi/drm/drm_mode.h | 2 + 28 files changed, 78 insertions(+), 632 deletions(-) delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.c delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.h delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
--
2.20.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/6 drm/kirin: Use DRM_GEM_CMA_VMAP_DRIVER_OPS
drm_gem_cma_dumb_create_internal() is not supposed to be used for .dumb_create directly. drm_gem_cma_dumb_create() should be used instead. If we do that, we might as well convert over to using DRM_GEM_CMA_VMAP_DRIVER_OPS instead.
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +1 -10
@@ -941,16 +941,7 @@ DEFINE_DRM_GEM_CMA_FOPS(ade_fops);static struct drm_driver ade_driver = { .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_ATOMIC , .fops = &ade_fops, - .gem_free_object_unlocked = drm_gem_cma_free_object, - .gem_vm_ops = &drm_gem_cma_vm_ops, - .dumb_create = drm_gem_cma_dumb_create_internal, - .prime_handle_to_fd = drm_gem_prime_handle_to_fd, - .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, - .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, - .gem_prime_vmap = drm_gem_cma_prime_vmap, - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, - .gem_prime_mmap = drm_gem_cma_prime_mmap, +DRM_GEM_CMA_VMAP_DRIVER_OPS , .name ="kirin" , .desc ="Hisilicon Kirin620 SoC DRM Driver" ,
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/6 drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Rob HerringIntroduce a new flag, DRM_MODE_DUMB_KERNEL_MAP, for struct drm_mode_create_dumb. This flag is for internal kernel use to indicate if dumb buffer allocation needs a kernel mapping. This is needed only for CMA where creating a kernel mapping or not has to be decided at allocation time because creating a mapping on demand (with vmap()) is not guaranteed to work. Several drivers are using CMA, but not the CMA helpers because they distinguish between kernel and userspace allocations to create a kernel mapping or not.
Update the callers of drm_mode_dumb_create() to set drm_mode_dumb_create.flags to appropriate defaults. Currently, flags can be set to anything by userspace, but is unused within the kernel. Let's force flags to zero (no kernel mapping) for userspace callers by default. For in kernel clients, set DRM_MODE_DUMB_KERNEL_MAP by default. Drivers can override this as needed.
--- drivers/gpu/drm/drm_client.c | 1 + drivers/gpu/drm/drm_dumb_buffers.c | 5 ++++- include/uapi/drm/drm_mode.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_client.c +1 -0
@@ -264,6 +264,7 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u dumb_args.width = width; dumb_args.height = height; dumb_args.bpp = info->cpp[0 ] *8 ; + dumb_args.flags =DRM_MODE_DUMB_KERNEL_MAP ; ret =drm_mode_create_dumb (dev, &dumb_args, client->file);if (ret) goto err_delete;
drivers/gpu/drm/drm_dumb_buffers.c +4 -1
@@ -97,7 +97,10 @@ int drm_mode_create_dumb(struct drm_device *dev,int drm_mode_create_dumb_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv) { -return drm_mode_create_dumb (dev, data, file_priv); +struct drm_mode_create_dumb *args = data; + + args->flags =0 ; +return drm_mode_create_dumb (dev, args, file_priv); }/**
include/uapi/drm/drm_mode.h +2 -0
@@ -796,6 +796,8 @@ struct drm_mode_crtc_page_flip_target {__u64 user_data; }; +#define DRM_MODE_DUMB_KERNEL_MAP (1<<0)/* For internal kernel use */ +/* create a dumb scanout buffer */ struct drm_mode_create_dumb {__u32 height;
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/6 drm/cma-helper: Use the dma_*_attr API variant
In reply to Rob HerringIn preparation to allow DRM CMA users to adjust the DMA_ATTR_* flags, convert the CMA helper code to use the dma_*_attr APIs instead of the dma_*_wc variants.
Only the DMA_ATTR_WRITE_COMBINE and DMA_ATTR_NO_WARN attributes are set in this commit, so there's no functional change.
--- drivers/gpu/drm/drm_gem_cma_helper.c | 20 ++++++++++++-------- include/drm/drm_gem_cma_helper.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_gem_cma_helper.c +12 -8
@@ -70,6 +70,7 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size) goto error; } + cma_obj->dma_attrs |=DMA_ATTR_NO_WARN |DMA_ATTR_WRITE_COMBINE ;return cma_obj; error:
@@ -102,8 +103,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,if (IS_ERR (cma_obj))return cma_obj; - cma_obj->vaddr =dma_alloc_wc (drm->dev, size, &cma_obj->paddr, -GFP_KERNEL | __GFP_NOWARN); + cma_obj->vaddr =dma_alloc_attrs (drm->dev, size, &cma_obj->paddr, +GFP_KERNEL | __GFP_NOWARN, + cma_obj->dma_attrs);if (!cma_obj->vaddr) {dev_dbg (drm->dev,"failed to allocate buffer with size %zu\n" , size);
@@ -184,8 +186,9 @@ void drm_gem_cma_free_object(struct drm_gem_object *gem_obj)dma_buf_vunmap (gem_obj->import_attach->dmabuf, cma_obj->vaddr);drm_prime_gem_destroy (gem_obj, cma_obj->sgt); }else if (cma_obj->vaddr) { -dma_free_wc (gem_obj->dev->dev, cma_obj->base.size, - cma_obj->vaddr, cma_obj->paddr); +dma_free_attrs (gem_obj->dev->dev, cma_obj->base.size, + cma_obj->vaddr, cma_obj->paddr, + cma_obj->dma_attrs); }drm_gem_object_release (gem_obj);
@@ -279,8 +282,9 @@ static int drm_gem_cma_mmap_obj(struct drm_gem_cma_object *cma_obj, vma->vm_flags &= ~VM_PFNMAP ; vma->vm_pgoff =0 ; - ret =dma_mmap_wc (cma_obj->base.dev->dev, vma, cma_obj->vaddr, - cma_obj->paddr, vma->vm_end - vma->vm_start); + ret =dma_mmap_attrs (cma_obj->base.dev->dev, vma, cma_obj->vaddr, + cma_obj->paddr, vma->vm_end - vma->vm_start, + cma_obj->dma_attrs);if (ret)drm_gem_vm_close (vma);
@@ -434,8 +438,8 @@ struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj)if (!sgt)return ERR_PTR (-ENOMEM ); - ret =dma_get_sgtable (obj->dev->dev, sgt, cma_obj->vaddr, - cma_obj->paddr, obj->size); + ret =dma_get_sgtable_attrs (obj->dev->dev, sgt, cma_obj->vaddr, + cma_obj->paddr, obj->size, cma_obj->dma_attrs);if (ret <0 ) goto out;
include/drm/drm_gem_cma_helper.h +1 -0
@@ -24,6 +24,7 @@ struct drm_gem_cma_object {/* For objects with DMA memory allocated by GEM CMA */ void *vaddr; +unsigned long dma_attrs; };#define to_drm_gem_cma_obj (gem_obj) \
--
2.20.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/6 drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Rob HerringAdd support in CMA helpers to handle callers specifying DRM_MODE_DUMB_KERNEL_MAP flag. Existing behavior is maintained with this change. drm_gem_cma_dumb_create() always creates a kernel mapping as before. drm_gem_cma_dumb_create_internal() lets the caller set the flags as desired. Therefore, update all the existing callers of drm_gem_cma_dumb_create_internal() to also set the DRM_MODE_DUMB_KERNEL_MAP flag.
--- .../gpu/drm/arm/display/komeda/komeda_kms.c | 1 + drivers/gpu/drm/arm/malidp_drv.c | 1 + drivers/gpu/drm/drm_gem_cma_helper.c | 48 +++++++++++-------- drivers/gpu/drm/meson/meson_drv.c | 1 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 1 + drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 1 + drivers/gpu/drm/stm/drv.c | 1 + drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + 8 files changed, 36 insertions(+), 19 deletions(-)
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1 -0
@@ -31,6 +31,7 @@ static int komeda_gem_cma_dumb_create(struct drm_file *file,u32 pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); args->pitch =ALIGN (pitch, mdev->chip.bus_width); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }
drivers/gpu/drm/arm/malidp_drv.c +1 -0
@@ -465,6 +465,7 @@ static int malidp_dumb_create(struct drm_file *file_priv,u8 alignment =malidp_hw_get_pitch_align (malidp->dev,1 ); args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ), alignment); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }
drivers/gpu/drm/drm_gem_cma_helper.c +29 -19
92 lines not on this page · raw message
drivers/gpu/drm/meson/meson_drv.c +1 -0
@@ -81,6 +81,7 @@ static int meson_dumb_create(struct drm_file *file, struct drm_device *dev,*/ args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ),SZ_64 ); args->size =PAGE_ALIGN (args->pitch * args->height); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }
drivers/gpu/drm/rcar-du/rcar_du_kms.c +1 -0
@@ -299,6 +299,7 @@ int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, align =16 * args->bpp /8 ; args->pitch =roundup (min_pitch, align); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +1 -0
@@ -419,6 +419,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv,* align to 64 bytes since Mali requires it. */ args->pitch =ALIGN (min_pitch,64 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ; args->size = args->pitch * args->height; rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size,
drivers/gpu/drm/stm/drv.c +1 -0
@@ -47,6 +47,7 @@ static int stm_gem_cma_dumb_create(struct drm_file *file,*/ args->pitch =roundup (min_pitch,128 ); args->height =roundup (args->height,4 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }
drivers/gpu/drm/sun4i/sun4i_drv.c +1 -0
@@ -34,6 +34,7 @@ static int drm_sun4i_gem_dumb_create(struct drm_file *file_priv, {/* The hardware only allows even pitches for YUV buffers. */ args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ),2 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/6 drm/mediatek: Convert to use CMA helpers
In reply to Rob HerringThe only reason the Mediatek driver doesn't use the CMA helpers is it sets DMA_ATTR_NO_KERNEL_MAPPING and does a vmap() on demand. Using vmap() is not even guaranteed to work as DMA buffers may not have a struct page. Now that the CMA helpers support setting DMA_ATTR_NO_KERNEL_MAPPING as needed or not, convert Mediatek driver to use CMA helpers.
--- drivers/gpu/drm/mediatek/Makefile | 1 - drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 28 +-- drivers/gpu/drm/mediatek/mtk_drm_fb.c | 1 - drivers/gpu/drm/mediatek/mtk_drm_gem.c | 289 ----------------------- drivers/gpu/drm/mediatek/mtk_drm_gem.h | 51 ---- drivers/gpu/drm/mediatek/mtk_drm_plane.c | 7 +- 7 files changed, 15 insertions(+), 364 deletions(-) delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.c delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.h
drivers/gpu/drm/mediatek/Makefile +0 -1
@@ -8,7 +8,6 @@ mediatek-drm-y := mtk_disp_color.o \ mtk_drm_ddp_comp.o \ mtk_drm_drv.o \ mtk_drm_fb.o \ - mtk_drm_gem.o \ mtk_drm_plane.o \ mtk_dsi.o \ mtk_mipi_tx.o \
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +1 -1
@@ -11,6 +11,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_plane_helper.h> +#include <drm/drm_print.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h>
@@ -18,7 +19,6 @@#include "mtk_drm_crtc.h" #include "mtk_drm_ddp.h" #include "mtk_drm_ddp_comp.h" -#include "mtk_drm_gem.h" #include "mtk_drm_plane.h" /**
drivers/gpu/drm/mediatek/mtk_drm_drv.c +11 -17
@@ -28,7 +28,6 @@#include "mtk_drm_ddp_comp.h" #include "mtk_drm_drv.h" #include "mtk_drm_fb.h" -#include "mtk_drm_gem.h" #define DRIVER_NAME "mediatek"#define DRIVER_DESC "Mediatek SoC DRM"
@@ -335,16 +334,14 @@ static void mtk_drm_kms_deinit(struct drm_device *drm)drm_mode_config_cleanup (drm); } -static const struct file_operations mtk_drm_fops = { - .owner =THIS_MODULE , - .open = drm_open, - .release = drm_release, - .unlocked_ioctl = drm_ioctl, - .mmap = mtk_drm_gem_mmap, - .poll = drm_poll, - .read = drm_read, - .compat_ioctl = drm_compat_ioctl, -}; +DEFINE_DRM_GEM_CMA_FOPS (mtk_drm_fops); + +static int mtk_drm_gem_dumb_create (struct drm_file *file_priv, +struct drm_device *dev, +struct drm_mode_create_dumb *args) +{ +return drm_gem_cma_dumb_create_internal (file_priv, dev, args); +}/* * We need to override this because the device used to import the memory is
@@ -361,18 +358,15 @@ struct drm_gem_object *mtk_drm_gem_prime_import(struct drm_device *dev,static struct drm_driver mtk_drm_driver = { .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC , - .gem_free_object_unlocked = mtk_drm_gem_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, + .gem_create_object = drm_cma_gem_create_object_default_funcs, .dumb_create = mtk_drm_gem_dumb_create, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_import = mtk_drm_gem_prime_import, - .gem_prime_get_sg_table = mtk_gem_prime_get_sg_table, - .gem_prime_import_sg_table = mtk_gem_prime_import_sg_table, - .gem_prime_mmap = mtk_drm_gem_mmap_buf, - .gem_prime_vmap = mtk_drm_gem_prime_vmap, - .gem_prime_vunmap = mtk_drm_gem_prime_vunmap, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table_vmap, + .gem_prime_mmap = drm_gem_prime_mmap, .fops = &mtk_drm_fops, .name =DRIVER_NAME ,
drivers/gpu/drm/mediatek/mtk_drm_fb.c +0 -1
@@ -14,7 +14,6 @@#include "mtk_drm_drv.h" #include "mtk_drm_fb.h" -#include "mtk_drm_gem.h" static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = { .create_handle = drm_gem_fb_create_handle,
drivers/gpu/drm/mediatek/mtk_drm_gem.c deleted +0 -289
289 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_drm_gem.h deleted +0 -51
51 lines not on this page · raw message
drivers/gpu/drm/mediatek/mtk_drm_plane.c +3 -4
@@ -8,13 +8,14 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_plane_helper.h> +#include <drm/drm_print.h> +#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include "mtk_drm_crtc.h" #include "mtk_drm_ddp_comp.h" #include "mtk_drm_drv.h" #include "mtk_drm_fb.h" -#include "mtk_drm_gem.h" #include "mtk_drm_plane.h" static const u32 formats[] = {
@@ -108,7 +109,6 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,struct drm_crtc *crtc = plane->state->crtc;struct drm_framebuffer *fb = plane->state->fb;struct drm_gem_object *gem; -struct mtk_drm_gem_obj *mtk_gem;unsigned int pitch, format;dma_addr_t addr;
@@ -116,8 +116,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,return ; gem = fb->obj[0 ]; - mtk_gem =to_mtk_gem_obj (gem); - addr = mtk_gem->dma_addr; + addr =to_drm_gem_cma_obj (gem)->paddr; pitch = fb->pitches[0 ]; format = fb->format->format;
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/6 drm/rockchip: Convert to use generic fbdev emulation
In reply to Rob HerringNow that we have the DRM_MODE_DUMB_KERNEL_MAP flag to indicate whether or not a kernel mapping is required, the Rockchip driver can be converted to using the generic fbdev emulation.
This patch makes full use of the generic fbdev emulation by using its drm_client callbacks. This means that drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are now handled by the emulation code. Additionally fbdev unregister happens automatically on drm_dev_unregister().
The drm_fbdev_generic_setup() call is put after drm_dev_register() in the driver. This is done to highlight the fact that fbdev emulation is an internal client that makes use of the driver, it is not part of the driver as such. If fbdev setup fails, an error is printed, but the driver succeeds probing.
--- drivers/gpu/drm/rockchip/Makefile | 1 - drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 10 +- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 - drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 14 -- drivers/gpu/drm/rockchip/rockchip_drm_fb.h | 6 - drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c | 170 ------------------ drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h | 24 --- drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +- drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 4 - 9 files changed, 6 insertions(+), 230 deletions(-) delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c delete mode 100644 drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h
drivers/gpu/drm/rockchip/Makefile +0 -1
@@ -5,7 +5,6 @@ rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \ rockchip_drm_gem.o rockchip_drm_vop.o rockchip_vop_reg.o -rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o rockchipdrm-$(CONFIG_ROCKCHIP_ANALOGIX_DP) += analogix_dp-rockchip.o rockchipdrm-$(CONFIG_ROCKCHIP_CDN_DP) += cdn-dp-core.o cdn-dp-reg.o
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +2 -8
@@ -25,7 +25,6 @@#include "rockchip_drm_drv.h" #include "rockchip_drm_fb.h" -#include "rockchip_drm_fbdev.h" #include "rockchip_drm_gem.h" #define DRIVER_NAME "rockchip"
@@ -156,10 +155,6 @@ static int rockchip_drm_bind(struct device *dev)*/ drm_dev->irq_enabled = true; - ret =rockchip_drm_fbdev_init (drm_dev); -if (ret) - goto err_unbind_all; -/* init kms poll for handling hpd */ drm_kms_helper_poll_init (drm_dev);
@@ -167,10 +162,11 @@ static int rockchip_drm_bind(struct device *dev)if (ret) goto err_kms_helper_poll_fini; +drm_fbdev_generic_setup (drm_dev,32 ); +return 0 ; err_kms_helper_poll_fini:drm_kms_helper_poll_fini (drm_dev); -rockchip_drm_fbdev_fini (drm_dev); err_unbind_all:component_unbind_all (dev, drm_dev); err_mode_config_cleanup:
@@ -189,7 +185,6 @@ static void rockchip_drm_unbind(struct device *dev)drm_dev_unregister (drm_dev); -rockchip_drm_fbdev_fini (drm_dev);drm_kms_helper_poll_fini (drm_dev);drm_atomic_helper_shutdown (drm_dev);
@@ -215,7 +210,6 @@ static const struct file_operations rockchip_drm_driver_fops = {static struct drm_driver rockchip_drm_driver = { .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC , - .lastclose = drm_fb_helper_lastclose, .gem_vm_ops = &drm_gem_cma_vm_ops, .gem_free_object_unlocked = rockchip_gem_free_object, .dumb_create = rockchip_gem_dumb_create,
drivers/gpu/drm/rockchip/rockchip_drm_drv.h +0 -2
@@ -42,8 +42,6 @@ struct rockchip_crtc_state {* @mm_lock: protect drm_mm on multi-threads. */ struct rockchip_drm_private { -struct drm_fb_helper fbdev_helper; -struct drm_gem_object *fbdev_bo;struct iommu_domain *domain;struct mutex mm_lock;struct drm_mm mm;
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +0 -14
@@ -116,20 +116,6 @@ static const struct drm_mode_config_funcs rockchip_drm_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; -struct drm_framebuffer * -rockchip_drm_framebuffer_init (struct drm_device *dev, -const struct drm_mode_fb_cmd2 *mode_cmd, -struct drm_gem_object *obj) -{ -struct drm_framebuffer *fb; - - fb =rockchip_fb_alloc (dev, mode_cmd, &obj,1 ); -if (IS_ERR (fb)) -return ERR_CAST (fb); - -return fb; -} -void rockchip_drm_mode_config_init (struct drm_device *dev) { dev->mode_config.min_width =0 ;
drivers/gpu/drm/rockchip/rockchip_drm_fb.h +0 -6
@@ -7,11 +7,5 @@#ifndef _ROCKCHIP_DRM_FB_H#define _ROCKCHIP_DRM_FB_H -struct drm_framebuffer * -rockchip_drm_framebuffer_init (struct drm_device *dev, -const struct drm_mode_fb_cmd2 *mode_cmd, -struct drm_gem_object *obj); -void rockchip_drm_framebuffer_fini (struct drm_framebuffer *fb); -void rockchip_drm_mode_config_init (struct drm_device *dev);#endif /* _ROCKCHIP_DRM_FB_H */
drivers/gpu/drm/rockchip/rockchip_drm_fbdev.c deleted +0 -170
170 lines not on this page · raw message
drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h deleted +0 -24
@@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Copyright (C) Fuzhou Rockchip Electronics Co.Ltd -* Author:Mark Yao <[email protected]> -*/ - -#ifndef _ROCKCHIP_DRM_FBDEV_H -#define _ROCKCHIP_DRM_FBDEV_H - -#ifdef CONFIG_DRM_FBDEV_EMULATION -int rockchip_drm_fbdev_init (struct drm_device *dev); -void rockchip_drm_fbdev_fini (struct drm_device *dev); -#else -static inline int rockchip_drm_fbdev_init (struct drm_device *dev) -{ -return 0 ; -} - -static inline void rockchip_drm_fbdev_fini (struct drm_device *dev) -{ -} -#endif - -#endif /* _ROCKCHIP_DRM_FBDEV_H */
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +4 -1
@@ -370,13 +370,14 @@ void rockchip_gem_free_object(struct drm_gem_object *obj)static struct rockchip_gem_object *rockchip_gem_create_with_handle (struct drm_file *file_priv,struct drm_device *drm,unsigned int size, +bool alloc_kmap,unsigned int *handle) {struct rockchip_gem_object *rk_obj;struct drm_gem_object *obj;int ret; - rk_obj =rockchip_gem_create_object (drm, size, false); + rk_obj =rockchip_gem_create_object (drm, size, alloc_kmap);if (IS_ERR (rk_obj))return ERR_CAST (rk_obj);
@@ -414,6 +415,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv, {struct rockchip_gem_object *rk_obj;int min_pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); +bool alloc_kmap = args->flags &DRM_MODE_DUMB_KERNEL_MAP ;/* * align to 64 bytes since Mali requires it.
@@ -423,6 +425,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv, args->size = args->pitch * args->height; rk_obj =rockchip_gem_create_with_handle (file_priv, dev, args->size, + alloc_kmap, &args->handle);return PTR_ERR_OR_ZERO (rk_obj);
drivers/gpu/drm/rockchip/rockchip_drm_gem.h +0 -4
@@ -41,10 +41,6 @@ int rockchip_gem_mmap(struct file *filp, struct vm_area_struct *vma);int rockchip_gem_mmap_buf (struct drm_gem_object *obj,struct vm_area_struct *vma); -struct rockchip_gem_object * -rockchip_gem_create_object (struct drm_device *drm,unsigned int size, -bool alloc_kmap); -void rockchip_gem_free_object (struct drm_gem_object *obj); int rockchip_gem_dumb_create(struct drm_file *file_priv,
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
kbuild test robot
build botRe: [PATCH 3/6] drm/cma-helper: Use the dma_*_attr API variant
In reply to Rob HerringI love your patch! Perhaps something to improve:
Hi Rob,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[cannot apply to v5.4-rc4 next-20191021]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Rob-Herring/drm-Support-CMA-per-allocation-kernel-mappings/20191022-073347 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 7d194c2100ad2a6dded545887d02754948ca5241 reproduce: make htmldocs
If you fix the issue, kindly add following tag
All warnings (new ones prefixed by >>):
include/linux/regulator/machine.h:196: warning: Function parameter or member 'max_uV_step' not described in 'regulation_constraints' include/linux/regulator/driver.h:223: warning: Function parameter or member 'resume' not described in 'regulator_ops' include/linux/spi/spi.h:190: warning: Function parameter or member 'driver_override' not described in 'spi_device' drivers/usb/typec/bus.c:1: warning: 'typec_altmode_register_driver' not found
drivers/usb/typec/bus.c:1: warning: 'typec_altmode_unregister_driver' not found
drivers/usb/typec/class.c:1: warning: 'typec_altmode_register_notifier' not found
drivers/usb/typec/class.c:1: warning: 'typec_altmode_unregister_notifier' not found
drivers/gpio/gpiolib-of.c:92: warning: Excess function parameter 'dev' description in 'of_gpio_need_valid_mask' include/linux/i2c.h:337: warning: Function parameter or member 'init_irq' not described in 'i2c_client'
fs/posix_acl.c:647: warning: Function parameter or member 'inode' not described in 'posix_acl_update_mode'
fs/posix_acl.c:647: warning: Function parameter or member 'mode_p' not described in 'posix_acl_update_mode'
fs/posix_acl.c:647: warning: Function parameter or member 'acl' not described in 'posix_acl_update_mode'
Error: Cannot open file drivers/dma-buf/reservation.c
Error: Cannot open file drivers/dma-buf/reservation.c
Error: Cannot open file drivers/dma-buf/reservation.c
Error: Cannot open file include/linux/reservation.h
Error: Cannot open file include/linux/reservation.h
kernel/dma/coherent.c:1: warning: no structured comments found
include/linux/input/sparse-keymap.h:43: warning: Function parameter or member 'sw' not described in 'key_entry' include/linux/skbuff.h:888: warning: Function parameter or member 'dev_scratch' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'list' not described in 'sk_buff'
include/linux/skbuff.h:888: warning: Function parameter or member 'ip_defrag_offset' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'skb_mstamp_ns' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member '__cloned_offset' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'head_frag' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member '__pkt_type_offset' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'encapsulation' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'encap_hdr_csum' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'csum_valid' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member '__pkt_vlan_present_offset' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'vlan_present' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'csum_complete_sw' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'csum_level' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'inner_protocol_type' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'remcsum_offload' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'sender_cpu' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'reserved_tailroom' not described in 'sk_buff' include/linux/skbuff.h:888: warning: Function parameter or member 'inner_ipproto' not described in 'sk_buff' include/net/sock.h:233: warning: Function parameter or member 'skc_addrpair' not described in 'sock_common' include/net/sock.h:233: warning: Function parameter or member 'skc_portpair' not described in 'sock_common' include/net/sock.h:233: warning: Function parameter or member 'skc_ipv6only' not described in 'sock_common' include/net/sock.h:233: warning: Function parameter or member 'skc_net_refcnt' not described in 'sock_common' include/net/sock.h:233: warning: Function parameter or member 'skc_v6_daddr' not described in 'sock_common' include/net/sock.h:233: warning: Function parameter or member 'skc_v6_rcv_saddr' not described in 'sock_common' include/net/sock.h:233: warning: Function parameter or member 'skc_cookie' not described in 'sock_common' include/net/sock.h:233: warning: Function parameter or member 'skc_listener' not described in 'sock_common' include/net/sock.h:233: warning: Function parameter or member 'skc_tw_dr' not described in 'sock_common'
include/net/sock.h:233: warning: Function parameter or member 'skc_rcv_wnd' not described in 'sock_common' include/net/sock.h:233: warning: Function parameter or member 'skc_tw_rcv_nxt' not described in 'sock_common' include/net/sock.h:515: warning: Function parameter or member 'sk_rx_skb_cache' not described in 'sock'
include/net/sock.h:515: warning: Function parameter or member 'sk_wq_raw' not described in 'sock'
include/net/sock.h:515: warning: Function parameter or member 'tcp_rtx_queue' not described in 'sock'
include/net/sock.h:515: warning: Function parameter or member 'sk_tx_skb_cache' not described in 'sock'
include/net/sock.h:515: warning: Function parameter or member 'sk_route_forced_caps' not described in 'sock' include/net/sock.h:515: warning: Function parameter or member 'sk_txtime_report_errors' not described in 'sock' include/net/sock.h:515: warning: Function parameter or member 'sk_validate_xmit_skb' not described in 'sock' include/net/sock.h:515: warning: Function parameter or member 'sk_bpf_storage' not described in 'sock'
include/net/sock.h:2450: warning: Function parameter or member 'tcp_rx_skb_cache_key' not described in 'DECLARE_STATIC_KEY_FALSE' include/net/sock.h:2450: warning: Excess function parameter 'sk' description in 'DECLARE_STATIC_KEY_FALSE' include/net/sock.h:2450: warning: Excess function parameter 'skb' description in 'DECLARE_STATIC_KEY_FALSE' include/linux/netdevice.h:2053: warning: Function parameter or member 'gso_partial_features' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'l3mdev_ops' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'xfrmdev_ops' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'tlsdev_ops' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'name_assign_type' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'ieee802154_ptr' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'mpls_ptr' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'xdp_prog' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'gro_flush_timeout' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'nf_hooks_ingress' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member '____cacheline_aligned_in_smp' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'qdisc_hash' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'xps_cpus_map' not described in 'net_device' include/linux/netdevice.h:2053: warning: Function parameter or member 'xps_rxqs_map' not described in 'net_device' include/linux/phylink.h:56: warning: Function parameter or member '__ETHTOOL_DECLARE_LINK_MODE_MASK(advertising' not described in 'phylink_link_state' include/linux/phylink.h:56: warning: Function parameter or member '__ETHTOOL_DECLARE_LINK_MODE_MASK(lp_advertising' not described in 'phylink_link_state' lib/genalloc.c:1: warning: 'gen_pool_add_virt' not found
lib/genalloc.c:1: warning: 'gen_pool_alloc' not found
lib/genalloc.c:1: warning: 'gen_pool_free' not found
lib/genalloc.c:1: warning: 'gen_pool_alloc_algo' not found
include/linux/rculist.h:374: warning: Excess function parameter 'cond' description in 'list_for_each_entry_rcu' include/linux/rculist.h:651: warning: Excess function parameter 'cond' description in 'hlist_for_each_entry_rcu'
mm/util.c:1: warning: 'get_user_pages_fast' not found
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:132: warning: Incorrect use of kernel-doc format: * @atomic_obj
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:238: warning: Incorrect use of kernel-doc format: * gpu_info FW provided soc bounding box struct or 0 if not
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'atomic_obj' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'backlight_link' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'backlight_caps' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'freesync_module' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'fw_dmcu' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'dmcu_fw_version' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h:243: warning: Function parameter or member 'soc_bounding_box' not described in 'amdgpu_display_manager' drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:1: warning: 'register_hpd_handlers' not found drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:1: warning: 'dm_pflip_high_irq' not found drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:1: warning: 'dm_crtc_high_irq' not found include/drm/drm_modeset_helper_vtables.h:1053: warning: Function parameter or member 'prepare_writeback_job' not described in 'drm_connector_helper_funcs' include/drm/drm_modeset_helper_vtables.h:1053: warning: Function parameter or member 'cleanup_writeback_job' not described in 'drm_connector_helper_funcs' include/drm/drm_atomic_state_helper.h:1: warning: no structured comments found
include/drm/drm_gem_shmem_helper.h:87: warning: Function parameter or member 'madv' not described in 'drm_gem_shmem_object' include/drm/drm_gem_shmem_helper.h:87: warning: Function parameter or member 'madv_list' not described in 'drm_gem_shmem_object'
>> include/drm/drm_gem_cma_helper.h:29: warning: Function parameter or member 'dma_attrs' not described in 'drm_gem_cma_object' drivers/gpu/drm/i915/display/intel_dpll_mgr.h:158: warning: Enum value 'DPLL_ID_TGL_MGPLL5' not described in enum 'intel_dpll_id' drivers/gpu/drm/i915/display/intel_dpll_mgr.h:158: warning: Enum value 'DPLL_ID_TGL_MGPLL6' not described in enum 'intel_dpll_id' drivers/gpu/drm/i915/display/intel_dpll_mgr.h:158: warning: Excess enum value 'DPLL_ID_TGL_TCPLL5' description in 'intel_dpll_id' drivers/gpu/drm/i915/display/intel_dpll_mgr.h:158: warning: Excess enum value 'DPLL_ID_TGL_TCPLL6' description in 'intel_dpll_id' drivers/gpu/drm/i915/display/intel_dpll_mgr.h:342: warning: Function parameter or member 'wakeref' not described in 'intel_shared_dpll' Error: Cannot open file drivers/gpu/drm/i915/i915_gem_batch_pool.c Error: Cannot open file drivers/gpu/drm/i915/i915_gem_batch_pool.c Error: Cannot open file drivers/gpu/drm/i915/i915_gem_batch_pool.c drivers/gpu/drm/i915/i915_drv.h:1129: warning: Incorrect use of kernel-doc format: * The OA context specific information. drivers/gpu/drm/i915/i915_drv.h:1143: warning: Incorrect use of kernel-doc format: * State of the OA buffer. drivers/gpu/drm/i915/i915_drv.h:1154: warning: Incorrect use of kernel-doc format: * Locks reads and writes to all head/tail state drivers/gpu/drm/i915/i915_drv.h:1176: warning: Incorrect use of kernel-doc format: * One 'aging' tail pointer and one 'aged' tail pointer ready to drivers/gpu/drm/i915/i915_drv.h:1188: warning: Incorrect use of kernel-doc format: * Index for the aged tail ready to read() data up to. drivers/gpu/drm/i915/i915_drv.h:1193: warning: Incorrect use of kernel-doc format: * A monotonic timestamp for when the current aging tail pointer drivers/gpu/drm/i915/i915_drv.h:1199: warning: Incorrect use of kernel-doc format: * Although we can always read back the head pointer register, drivers/gpu/drm/i915/i915_drv.h:1207: warning: Function parameter or member 'pinned_ctx' not described in 'i915_perf_stream' drivers/gpu/drm/i915/i915_drv.h:1207: warning: Function parameter or member 'specific_ctx_id' not described in 'i915_perf_stream' drivers/gpu/drm/i915/i915_drv.h:1207: warning: Function parameter or member 'specific_ctx_id_mask' not described in 'i915_perf_stream' drivers/gpu/drm/i915/i915_drv.h:1207: warning: Function parameter or member 'poll_check_timer' not described in 'i915_perf_stream' drivers/gpu/drm/i915/i915_drv.h:1207: warning: Function parameter or member 'poll_wq' not described in 'i915_perf_stream' drivers/gpu/drm/i915/i915_drv.h:1207: warning: Function parameter or member 'pollin' not described in 'i915_perf_stream' drivers/gpu/drm/i915/i915_drv.h:1207: warning: Function parameter or member 'periodic' not described in 'i915_perf_stream' drivers/gpu/drm/i915/i915_drv.h:1207: warning: Function parameter or member 'period_exponent' not described in 'i915_perf_stream' drivers/gpu/drm/i915/i915_drv.h:1207: warning: Function parameter or member 'oa_buffer' not described in 'i915_perf_stream' drivers/gpu/drm/i915/i915_drv.h:1129: warning: Incorrect use of kernel-doc format: * The OA context specific information. drivers/gpu/drm/i915/i915_drv.h:1143: warning: Incorrect use of kernel-doc format: * State of the OA buffer. drivers/gpu/drm/i915/i915_drv.h:1154: warning: Incorrect use of kernel-doc format: * Locks reads and writes to all head/tail state drivers/gpu/drm/i915/i915_drv.h:1176: warning: Incorrect use of kernel-doc format: * One 'aging' tail pointer and one 'aged' tail pointer ready to drivers/gpu/drm/i915/i915_drv.h:1188: warning: Incorrect use of kernel-doc format: * Index for the aged tail ready to read() data up to. drivers/gpu/drm/i915/i915_drv.h:1193: warning: Incorrect use of kernel-doc format: * A monotonic timestamp for when the current aging tail pointer drivers/gpu/drm/i915/i915_drv.h:1199: warning: Incorrect use of kernel-doc format: * Although we can always read back the head pointer register, drivers/gpu/drm/i915/i915_drv.h:1129: warning: Incorrect use of kernel-doc format: * The OA context specific information. drivers/gpu/drm/i915/i915_drv.h:1143: warning: Incorrect use of kernel-doc format: * State of the OA buffer. drivers/gpu/drm/i915/i915_drv.h:1154: warning: Incorrect use of kernel-doc format: * Locks reads and writes to all head/tail state drivers/gpu/drm/i915/i915_drv.h:1176: warning: Incorrect use of kernel-doc format: * One 'aging' tail pointer and one 'aged' tail pointer ready to drivers/gpu/drm/i915/i915_drv.h:1188: warning: Incorrect use of kernel-doc format: * Index for the aged tail ready to read() data up to. drivers/gpu/drm/i915/i915_drv.h:1193: warning: Incorrect use of kernel-doc format: * A monotonic timestamp for when the current aging tail pointer drivers/gpu/drm/i915/i915_drv.h:1199: warning: Incorrect use of kernel-doc format: * Although we can always read back the head pointer register,
drivers/gpu/drm/mcde/mcde_drv.c:1: warning: 'ST-Ericsson MCDE DRM Driver' not found
include/net/cfg80211.h:1185: warning: Function parameter or member 'txpwr' not described in 'station_parameters' include/net/mac80211.h:4056: warning: Function parameter or member 'sta_set_txpwr' not described in 'ieee80211_ops' include/net/mac80211.h:2018: warning: Function parameter or member 'txpwr' not described in 'ieee80211_sta' Documentation/admin-guide/perf/imx-ddr.rst:21: WARNING: Unexpected indentation. Documentation/admin-guide/perf/imx-ddr.rst:34: WARNING: Unexpected indentation. Documentation/admin-guide/perf/imx-ddr.rst:40: WARNING: Unexpected indentation. Documentation/admin-guide/perf/imx-ddr.rst:45: WARNING: Unexpected indentation. Documentation/admin-guide/perf/imx-ddr.rst:52: WARNING: Unexpected indentation. Documentation/admin-guide/xfs.rst:257: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/usb/index.rst:5: WARNING: toctree contains reference to nonexisting document 'usb/rio' Documentation/usb/index.rst:5: WARNING: toctree contains reference to nonexisting document 'usb/wusb-design-overview' Documentation/usb/text_files.rst:22: WARNING: Include file 'Documentation/usb/wusb-cbaf' not found or reading it failed include/uapi/linux/firewire-cdev.h:312: WARNING: Inline literal start-string without end-string. drivers/firewire/core-transaction.c:606: WARNING: Inline strong start-string without end-string. Documentation/translations/it_IT/process/maintainer-pgp-guide.rst:458: WARNING: Unknown target name: "nitrokey pro". Documentation/trace/kprobetrace.rst:100: WARNING: Explicit markup ends without a blank line; unexpected unindent. Documentation/security/keys/core.rst:1110: WARNING: Inline emphasis start-string without end-string. Documentation/security/keys/core.rst:1110: WARNING: Inline emphasis start-string without end-string. Documentation/security/keys/core.rst:1108: WARNING: Inline emphasis start-string without end-string. Documentation/security/keys/core.rst:1108: WARNING: Inline emphasis start-string without end-string. Documentation/security/keys/core.rst:1108: WARNING: Inline emphasis start-string without end-string. drivers/message/fusion/mptbase.c:5057: WARNING: Definition list ends without a blank line; unexpected unindent. Documentation/filesystems/ubifs-authentication.rst:94: WARNING: Inline interpreted text or phrase reference start-string without end-string. drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c:248: WARNING: Unexpected indentation. drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c:251: WARNING: Block quote ends without a blank line; unexpected unindent. drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:213: WARNING: Unexpected indentation. drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:224: WARNING: Unexpected indentation. drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:233: WARNING: Definition list ends without a blank line; unexpected unindent. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c:2199: WARNING: Inline emphasis start-string without end-string. drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c:2201: WARNING: Inline emphasis start-string without end-string. Documentation/misc-devices/index.rst:14: WARNING: toctree contains reference to nonexisting document 'misc-devices/xilinx_sdfec' include/linux/regulator/driver.h:284: WARNING: Unknown target name: "regulator_regmap_x_voltage". include/linux/spi/spi.h:382: WARNING: Unexpected indentation.
Documentation/driver-api/gpio/driver.rst:420: WARNING: Unexpected indentation. Documentation/driver-api/gpio/driver.rst:418: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:422: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/driver-api/gpio/driver.rst:424: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:424: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:424: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:428: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:441: WARNING: Unexpected indentation. Documentation/driver-api/gpio/driver.rst:435: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:435: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:442: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/driver-api/gpio/driver.rst:444: WARNING: Definition list ends without a blank line; unexpected unindent. Documentation/driver-api/gpio/driver.rst:455: WARNING: Unexpected indentation. Documentation/driver-api/gpio/driver.rst:453: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:455: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:458: WARNING: Block quote ends without a blank line; unexpected unindent. Documentation/driver-api/gpio/driver.rst:460: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:460: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:460: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:464: WARNING: Inline emphasis start-string without end-string. Documentation/driver-api/gpio/driver.rst:471: WARNING: Inline emphasis start-string without end-string. include/linux/i2c.h:522: WARNING: Inline strong start-string without end-string.
fs/seq_file.c:40: WARNING: Inline strong start-string without end-string.
fs/seq_file.c:40: WARNING: Inline strong start-string without end-string.
fs/seq_file.c:40: WARNING: Inline strong start-string without end-string.
fs/seq_file.c:40: WARNING: Inline strong start-string without end-string.
fs/posix_acl.c:636: WARNING: Inline emphasis start-string without end-string.
fs/debugfs/inode.c:427: WARNING: Inline literal start-string without end-string.
vim +29 include/drm/drm_gem_cma_helper.h
b9d47450054616 Sascha Hauer 2012-06-27 @29
:::::: The code at line 29 was first introduced by commit :::::: b9d474500546160dd6af35f60cd8bc20edd13807 DRM: Add DRM GEM CMA helper
:::::: TO: Sascha Hauer <[email protected]> :::::: CC: Laurent Pinchart <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Rob HerringQuoted 51 lines · Rob Herring
Add support in CMA helpers to handle callers specifying
DRM_MODE_DUMB_KERNEL_MAPflag. Existing behavior is maintained with this change.drm_gem_cma_dumb_create()always creates a kernel mapping as before.drm_gem_cma_dumb_create_internal()lets the caller set the flags as desired. Therefore, update all the existing callers ofdrm_gem_cma_dumb_create_internal()to also set theDRM_MODE_DUMB_KERNEL_MAPflag.Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc "James (Qian) Wang" <[email protected]>Cc Liviu Dudau <[email protected]>Cc Brian Starkey <[email protected]>Cc Neil Armstrong <[email protected]>Cc Kevin Hilman <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Sandy Huang <[email protected]>Cc "Heiko Stübner" <[email protected]>Cc Yannick Fertre <[email protected]>Cc Philippe Cornu <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Chen-Yu Tsai <[email protected]>Signed-off-by Rob Herring <[email protected]>--- .../gpu/drm/arm/display/komeda/komeda_kms.c | 1 + drivers/gpu/drm/arm/malidp_drv.c | 1 + drivers/gpu/drm/drm_gem_cma_helper.c | 48 +++++++++++-------- drivers/gpu/drm/meson/meson_drv.c | 1 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 1 + drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 1 + drivers/gpu/drm/stm/drv.c | 1 + drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + 8 files changed, 36 insertions(+), 19 deletions(-)drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0
drivers/gpu/drm/arm/display/komeda/komeda_kms.c static int komeda_gem_cma_dumb_create(struct drm_file *file, · line 35
Quoted 5 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -31,6 +31,7 @@ static int komeda_gem_cma_dumb_create(struct drm_file *file,u32 pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); args->pitch =ALIGN (pitch, mdev->chip.bus_width); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;
Hi Rob:
komeda doesn't need the kernel map either, so you can del this line for komeda. and with this.
Quoted 178 lines
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +0
-0return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/arm/malidp_drv.c +1
-0@@ -465,6 +465,7 @@ static int malidp_dumb_create(struct drm_file *file_priv,u8 alignment =malidp_hw_get_pitch_align (malidp->dev,1 ); args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ), alignment); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }drivers/gpu/drm/drm_gem_cma_helper.c +29
-19@@ -78,21 +78,8 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)return ERR_PTR (ret); } -/** -* drm_gem_cma_create - allocate an object with the given size -* @drm: DRM device -* @size: size of the object to allocate -* -* This function creates a CMA GEM object and allocates a contiguous chunk of -* memory as backing store. The backing memory has the writecombine attribute -* set. -* -* Returns: -* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative -* error code on failure. -*/ -struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm, -size_t size) +static struct drm_gem_cma_object * +drm_gem_cma_create_flags (struct drm_device *drm,size_t size,u32 flags) {struct drm_gem_cma_object *cma_obj;int ret;@@ -103,6 +90,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,if (IS_ERR (cma_obj))return cma_obj; +if (!(flags &DRM_MODE_DUMB_KERNEL_MAP )) + cma_obj->dma_attrs |=DMA_ATTR_NO_KERNEL_MAPPING ; + cma_obj->vaddr =dma_alloc_attrs (drm->dev, size, &cma_obj->paddr,GFP_KERNEL | __GFP_NOWARN, cma_obj->dma_attrs);@@ -119,6 +109,25 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,drm_gem_object_put_unlocked (&cma_obj->base);return ERR_PTR (ret); } + +/** +* drm_gem_cma_create - allocate an object with the given size +* @drm: DRM device +* @size: size of the object to allocate +* +* This function creates a CMA GEM object and allocates a contiguous chunk of +* memory as backing store. The backing memory has the writecombine attribute +* set. +* +* Returns: +* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative +* error code on failure. +*/ +struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm, +size_t size) +{ +return drm_gem_cma_create_flags (drm, size,DRM_MODE_DUMB_KERNEL_MAP ); +}EXPORT_SYMBOL_GPL (drm_gem_cma_create);/** @@ -139,14 +148,14 @@ EXPORT_SYMBOL_GPL(drm_gem_cma_create);*/ static struct drm_gem_cma_object *drm_gem_cma_create_with_handle (struct drm_file *file_priv, -struct drm_device *drm,size_t size, +struct drm_device *drm,size_t size,u32 flags,uint32_t *handle) {struct drm_gem_cma_object *cma_obj;struct drm_gem_object *gem_obj;int ret; - cma_obj =drm_gem_cma_create (drm, size); + cma_obj =drm_gem_cma_create_flags (drm, size, flags);if (IS_ERR (cma_obj))return cma_obj;@@ -225,7 +234,7 @@ int drm_gem_cma_dumb_create_internal(struct drm_file *file_priv, args->size = args->pitch * args->height; cma_obj =drm_gem_cma_create_with_handle (file_priv, drm, args->size, - &args->handle); + args->flags, &args->handle);return PTR_ERR_OR_ZERO (cma_obj); }EXPORT_SYMBOL_GPL (drm_gem_cma_dumb_create_internal);@@ -256,9 +265,10 @@ int drm_gem_cma_dumb_create(struct drm_file *file_priv, args->pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); args->size = args->pitch * args->height; + args->flags =DRM_MODE_DUMB_KERNEL_MAP ; cma_obj =drm_gem_cma_create_with_handle (file_priv, drm, args->size, - &args->handle); + args->flags, &args->handle);return PTR_ERR_OR_ZERO (cma_obj); }EXPORT_SYMBOL_GPL (drm_gem_cma_dumb_create);drivers/gpu/drm/meson/meson_drv.c +1
-0@@ -81,6 +81,7 @@ static int meson_dumb_create(struct drm_file *file, struct drm_device *dev,*/ args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ),SZ_64 ); args->size =PAGE_ALIGN (args->pitch * args->height); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/rcar-du/rcar_du_kms.c +1
-0@@ -299,6 +299,7 @@ int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, align =16 * args->bpp /8 ; args->pitch =roundup (min_pitch, align); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/rockchip/rockchip_drm_gem.c +1
-0@@ -419,6 +419,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv,* align to 64 bytes since Mali requires it. */ args->pitch =ALIGN (min_pitch,64 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ; args->size = args->pitch * args->height; rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size,drivers/gpu/drm/stm/drv.c +1
-0@@ -47,6 +47,7 @@ static int stm_gem_cma_dumb_create(struct drm_file *file,*/ args->pitch =roundup (min_pitch,128 ); args->height =roundup (args->height,4 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/sun4i/sun4i_drv.c +1
-0@@ -34,6 +34,7 @@ static int drm_sun4i_gem_dumb_create(struct drm_file *file_priv, {/* The hardware only allows even pitches for YUV buffers. */ args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ),2 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }Signature · 1 line
2.20.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Rob HerringQuoted 226 lines · Rob Herring
Add support in CMA helpers to handle callers specifying
DRM_MODE_DUMB_KERNEL_MAPflag. Existing behavior is maintained with this change.drm_gem_cma_dumb_create()always creates a kernel mapping as before.drm_gem_cma_dumb_create_internal()lets the caller set the flags as desired. Therefore, update all the existing callers ofdrm_gem_cma_dumb_create_internal()to also set theDRM_MODE_DUMB_KERNEL_MAPflag.Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc "James (Qian) Wang" <[email protected]>Cc Liviu Dudau <[email protected]>Cc Brian Starkey <[email protected]>Cc Neil Armstrong <[email protected]>Cc Kevin Hilman <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Sandy Huang <[email protected]>Cc "Heiko Stübner" <[email protected]>Cc Yannick Fertre <[email protected]>Cc Philippe Cornu <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Chen-Yu Tsai <[email protected]>Signed-off-by Rob Herring <[email protected]>--- .../gpu/drm/arm/display/komeda/komeda_kms.c | 1 + drivers/gpu/drm/arm/malidp_drv.c | 1 + drivers/gpu/drm/drm_gem_cma_helper.c | 48 +++++++++++-------- drivers/gpu/drm/meson/meson_drv.c | 1 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 1 + drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 1 + drivers/gpu/drm/stm/drv.c | 1 + drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + 8 files changed, 36 insertions(+), 19 deletions(-)drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -31,6 +31,7 @@ static int komeda_gem_cma_dumb_create(struct drm_file *file,u32 pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); args->pitch =ALIGN (pitch, mdev->chip.bus_width); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/arm/malidp_drv.c +1
-0@@ -465,6 +465,7 @@ static int malidp_dumb_create(struct drm_file *file_priv,u8 alignment =malidp_hw_get_pitch_align (malidp->dev,1 ); args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ), alignment); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }drivers/gpu/drm/drm_gem_cma_helper.c +29
-19@@ -78,21 +78,8 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)return ERR_PTR (ret); } -/** -* drm_gem_cma_create - allocate an object with the given size -* @drm: DRM device -* @size: size of the object to allocate -* -* This function creates a CMA GEM object and allocates a contiguous chunk of -* memory as backing store. The backing memory has the writecombine attribute -* set. -* -* Returns: -* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative -* error code on failure. -*/ -struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm, -size_t size) +static struct drm_gem_cma_object * +drm_gem_cma_create_flags (struct drm_device *drm,size_t size,u32 flags) {struct drm_gem_cma_object *cma_obj;int ret;@@ -103,6 +90,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,if (IS_ERR (cma_obj))return cma_obj; +if (!(flags &DRM_MODE_DUMB_KERNEL_MAP )) + cma_obj->dma_attrs |=DMA_ATTR_NO_KERNEL_MAPPING ; + cma_obj->vaddr =dma_alloc_attrs (drm->dev, size, &cma_obj->paddr,GFP_KERNEL | __GFP_NOWARN, cma_obj->dma_attrs);@@ -119,6 +109,25 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,drm_gem_object_put_unlocked (&cma_obj->base);return ERR_PTR (ret); } + +/** +* drm_gem_cma_create - allocate an object with the given size +* @drm: DRM device +* @size: size of the object to allocate +* +* This function creates a CMA GEM object and allocates a contiguous chunk of +* memory as backing store. The backing memory has the writecombine attribute +* set. +* +* Returns: +* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative +* error code on failure. +*/ +struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm, +size_t size) +{ +return drm_gem_cma_create_flags (drm, size,DRM_MODE_DUMB_KERNEL_MAP ); +}EXPORT_SYMBOL_GPL (drm_gem_cma_create);/** @@ -139,14 +148,14 @@ EXPORT_SYMBOL_GPL(drm_gem_cma_create);*/ static struct drm_gem_cma_object *drm_gem_cma_create_with_handle (struct drm_file *file_priv, -struct drm_device *drm,size_t size, +struct drm_device *drm,size_t size,u32 flags,uint32_t *handle) {struct drm_gem_cma_object *cma_obj;struct drm_gem_object *gem_obj;int ret; - cma_obj =drm_gem_cma_create (drm, size); + cma_obj =drm_gem_cma_create_flags (drm, size, flags);if (IS_ERR (cma_obj))return cma_obj;@@ -225,7 +234,7 @@ int drm_gem_cma_dumb_create_internal(struct drm_file *file_priv, args->size = args->pitch * args->height; cma_obj =drm_gem_cma_create_with_handle (file_priv, drm, args->size, - &args->handle); + args->flags, &args->handle);return PTR_ERR_OR_ZERO (cma_obj); }EXPORT_SYMBOL_GPL (drm_gem_cma_dumb_create_internal);@@ -256,9 +265,10 @@ int drm_gem_cma_dumb_create(struct drm_file *file_priv, args->pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); args->size = args->pitch * args->height; + args->flags =DRM_MODE_DUMB_KERNEL_MAP ; cma_obj =drm_gem_cma_create_with_handle (file_priv, drm, args->size, - &args->handle); + args->flags, &args->handle);return PTR_ERR_OR_ZERO (cma_obj); }EXPORT_SYMBOL_GPL (drm_gem_cma_dumb_create);drivers/gpu/drm/meson/meson_drv.c +1
-0@@ -81,6 +81,7 @@ static int meson_dumb_create(struct drm_file *file, struct drm_device *dev,*/ args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ),SZ_64 ); args->size =PAGE_ALIGN (args->pitch * args->height); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/rcar-du/rcar_du_kms.c +1
-0@@ -299,6 +299,7 @@ int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, align =16 * args->bpp /8 ; args->pitch =roundup (min_pitch, align); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/rockchip/rockchip_drm_gem.c +1
-0@@ -419,6 +419,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv,* align to 64 bytes since Mali requires it. */ args->pitch =ALIGN (min_pitch,64 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ; args->size = args->pitch * args->height; rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size,drivers/gpu/drm/stm/drv.c +1
-0@@ -47,6 +47,7 @@ static int stm_gem_cma_dumb_create(struct drm_file *file,*/ args->pitch =roundup (min_pitch,128 ); args->height =roundup (args->height,4 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/sun4i/sun4i_drv.c +0
-0
drivers/gpu/drm/sun4i/sun4i_drv.c static int drm_sun4i_gem_dumb_create(struct drm_file *file_priv, · line 40
Quoted 7 lines
drivers/gpu/drm/sun4i/sun4i_drv.c +1
-0@@ -34,6 +34,7 @@ static int drm_sun4i_gem_dumb_create(struct drm_file *file_priv, {/* The hardware only allows even pitches for YUV buffers. */ args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ),2 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/6] drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Rob HerringHi Rob,
Thank you for the patch.
Quoted 45 lines · Rob Herring
Introduce a new flag,
DRM_MODE_DUMB_KERNEL_MAP, for structdrm_mode_create_dumb. This flag is for internal kernel use to indicate if dumb buffer allocation needs a kernel mapping. This is needed only for CMA where creating a kernel mapping or not has to be decided at allocation time because creating a mapping on demand (withvmap()) is not guaranteed to work. Several drivers are using CMA, but not the CMA helpers because they distinguish between kernel and userspace allocations to create a kernel mapping or not.Update the callers of
drm_mode_dumb_create()to set drm_mode_dumb_create.flags to appropriate defaults. Currently, flags can be set to anything by userspace, but is unused within the kernel. Let's force flags to zero (no kernel mapping) for userspace callers by default. For in kernel clients, setDRM_MODE_DUMB_KERNEL_MAPby default. Drivers can override this as needed.Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/gpu/drm/drm_client.c | 1 + drivers/gpu/drm/drm_dumb_buffers.c | 5 ++++- include/uapi/drm/drm_mode.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_client.c +1
-0@@ -264,6 +264,7 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u dumb_args.width = width; dumb_args.height = height; dumb_args.bpp = info->cpp[0 ] *8 ; + dumb_args.flags =DRM_MODE_DUMB_KERNEL_MAP ; ret =drm_mode_create_dumb (dev, &dumb_args, client->file);if (ret) goto err_delete;drivers/gpu/drm/drm_dumb_buffers.c +0
-0
drivers/gpu/drm/drm_dumb_buffers.c int drm_mode_create_dumb(struct drm_device *dev, · line 102
Quoted 7 lines
drivers/gpu/drm/drm_dumb_buffers.c +3
-1@@ -97,7 +97,10 @@ int drm_mode_create_dumb(struct drm_device *dev,int drm_mode_create_dumb_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv) { -return drm_mode_create_dumb (dev, data, file_priv); +struct drm_mode_create_dumb *args = data; + + args->flags =0 ;
I would prefer returning an error if flags is set to a non-zero value, to catch userspace errors early, but I'm also worried it would break existing userspace by uncovering existing bugs. Still, if we later add flags that userspace can set, those existing bugs will be triggered, so we'll have to deal with them anyway, and we could already give it a try.
The patch otherwise looks good to me.
Quoted 17 lines
drivers/gpu/drm/drm_dumb_buffers.c +1
-0+return drm_mode_create_dumb (dev, args, file_priv); }/** include/uapi/drm/drm_mode.h +2
-0@@ -796,6 +796,8 @@ struct drm_mode_crtc_page_flip_target {__u64 user_data; }; +#define DRM_MODE_DUMB_KERNEL_MAP (1<<0)/* For internal kernel use */ +/* create a dumb scanout buffer */ struct drm_mode_create_dumb {__u32 height;
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/6] drm/cma-helper: Use the dma_*_attr API variant
In reply to Rob HerringHi Rob,
Thank you for the patch.
Quoted 6 lines · Rob Herring
In preparation to allow DRM CMA users to adjust the DMA_ATTR_* flags, convert the CMA helper code to use the dma_*_attr APIs instead of the dma_*_wc variants.
Only the
DMA_ATTR_WRITE_COMBINEandDMA_ATTR_NO_WARNattributes are set in this commit, so there's no functional change.
Apart from the documentation issue reported by kbuild,
Quoted 82 lines
Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/gpu/drm/drm_gem_cma_helper.c | 20 ++++++++++++-------- include/drm/drm_gem_cma_helper.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-)drivers/gpu/drm/drm_gem_cma_helper.c +12
-8@@ -70,6 +70,7 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size) goto error; } + cma_obj->dma_attrs |=DMA_ATTR_NO_WARN |DMA_ATTR_WRITE_COMBINE ;return cma_obj; error:@@ -102,8 +103,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,if (IS_ERR (cma_obj))return cma_obj; - cma_obj->vaddr =dma_alloc_wc (drm->dev, size, &cma_obj->paddr, -GFP_KERNEL | __GFP_NOWARN); + cma_obj->vaddr =dma_alloc_attrs (drm->dev, size, &cma_obj->paddr, +GFP_KERNEL | __GFP_NOWARN, + cma_obj->dma_attrs);if (!cma_obj->vaddr) {dev_dbg (drm->dev,"failed to allocate buffer with size %zu\n" , size);@@ -184,8 +186,9 @@ void drm_gem_cma_free_object(struct drm_gem_object *gem_obj)dma_buf_vunmap (gem_obj->import_attach->dmabuf, cma_obj->vaddr);drm_prime_gem_destroy (gem_obj, cma_obj->sgt); }else if (cma_obj->vaddr) { -dma_free_wc (gem_obj->dev->dev, cma_obj->base.size, - cma_obj->vaddr, cma_obj->paddr); +dma_free_attrs (gem_obj->dev->dev, cma_obj->base.size, + cma_obj->vaddr, cma_obj->paddr, + cma_obj->dma_attrs); }drm_gem_object_release (gem_obj);@@ -279,8 +282,9 @@ static int drm_gem_cma_mmap_obj(struct drm_gem_cma_object *cma_obj, vma->vm_flags &= ~VM_PFNMAP ; vma->vm_pgoff =0 ; - ret =dma_mmap_wc (cma_obj->base.dev->dev, vma, cma_obj->vaddr, - cma_obj->paddr, vma->vm_end - vma->vm_start); + ret =dma_mmap_attrs (cma_obj->base.dev->dev, vma, cma_obj->vaddr, + cma_obj->paddr, vma->vm_end - vma->vm_start, + cma_obj->dma_attrs);if (ret)drm_gem_vm_close (vma);@@ -434,8 +438,8 @@ struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj)if (!sgt)return ERR_PTR (-ENOMEM ); - ret =dma_get_sgtable (obj->dev->dev, sgt, cma_obj->vaddr, - cma_obj->paddr, obj->size); + ret =dma_get_sgtable_attrs (obj->dev->dev, sgt, cma_obj->vaddr, + cma_obj->paddr, obj->size, cma_obj->dma_attrs);if (ret <0 ) goto out;include/drm/drm_gem_cma_helper.h +1
-0@@ -24,6 +24,7 @@ struct drm_gem_cma_object {/* For objects with DMA memory allocated by GEM CMA */ void *vaddr; +unsigned long dma_attrs; };#define to_drm_gem_cma_obj (gem_obj) \
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Rob HerringHi Rob,
Thank you for the patch.
Quoted 112 lines · Rob Herring
Add support in CMA helpers to handle callers specifying
DRM_MODE_DUMB_KERNEL_MAPflag. Existing behavior is maintained with this change.drm_gem_cma_dumb_create()always creates a kernel mapping as before.drm_gem_cma_dumb_create_internal()lets the caller set the flags as desired. Therefore, update all the existing callers ofdrm_gem_cma_dumb_create_internal()to also set theDRM_MODE_DUMB_KERNEL_MAPflag.Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc "James (Qian) Wang" <[email protected]>Cc Liviu Dudau <[email protected]>Cc Brian Starkey <[email protected]>Cc Neil Armstrong <[email protected]>Cc Kevin Hilman <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Sandy Huang <[email protected]>Cc "Heiko Stübner" <[email protected]>Cc Yannick Fertre <[email protected]>Cc Philippe Cornu <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Chen-Yu Tsai <[email protected]>Signed-off-by Rob Herring <[email protected]>--- .../gpu/drm/arm/display/komeda/komeda_kms.c | 1 + drivers/gpu/drm/arm/malidp_drv.c | 1 + drivers/gpu/drm/drm_gem_cma_helper.c | 48 +++++++++++-------- drivers/gpu/drm/meson/meson_drv.c | 1 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 1 + drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 1 + drivers/gpu/drm/stm/drv.c | 1 + drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + 8 files changed, 36 insertions(+), 19 deletions(-)drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -31,6 +31,7 @@ static int komeda_gem_cma_dumb_create(struct drm_file *file,u32 pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); args->pitch =ALIGN (pitch, mdev->chip.bus_width); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/arm/malidp_drv.c +1
-0@@ -465,6 +465,7 @@ static int malidp_dumb_create(struct drm_file *file_priv,u8 alignment =malidp_hw_get_pitch_align (malidp->dev,1 ); args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ), alignment); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }drivers/gpu/drm/drm_gem_cma_helper.c +5
-15@@ -78,21 +78,8 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)return ERR_PTR (ret); } -/** -* drm_gem_cma_create - allocate an object with the given size -* @drm: DRM device -* @size: size of the object to allocate -* -* This function creates a CMA GEM object and allocates a contiguous chunk of -* memory as backing store. The backing memory has the writecombine attribute -* set. -* -* Returns: -* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative -* error code on failure. -*/ -struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm, -size_t size) +static struct drm_gem_cma_object * +drm_gem_cma_create_flags (struct drm_device *drm,size_t size,u32 flags) {struct drm_gem_cma_object *cma_obj;int ret;@@ -103,6 +90,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,if (IS_ERR (cma_obj))return cma_obj; +if (!(flags &DRM_MODE_DUMB_KERNEL_MAP )) + cma_obj->dma_attrs |=DMA_ATTR_NO_KERNEL_MAPPING ; + cma_obj->vaddr =dma_alloc_attrs (drm->dev, size, &cma_obj->paddr,GFP_KERNEL | __GFP_NOWARN, cma_obj->dma_attrs);@@ -119,6 +109,25 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,drm_gem_object_put_unlocked (&cma_obj->base);return ERR_PTR (ret); }
drivers/gpu/drm/drm_gem_cma_helper.c struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, · line 121
Quoted 10 lines
drivers/gpu/drm/drm_gem_cma_helper.c +10
-0+ +/** +* drm_gem_cma_create - allocate an object with the given size +* @drm: DRM device +* @size: size of the object to allocate +* +* This function creates a CMA GEM object and allocates a contiguous chunk of +* memory as backing store. The backing memory has the writecombine attribute +* set. +*
Shouldn't you mention here that the function always creates a kernel mapping, and that callers that don't need the mapping should use drm_gem_cma_dumb_create_internal() instead ? drm_gem_cma_dumb_create_internal() operates at a different level though, and drm_gem_cma_create() is only exported for a single driver. There's no equivalent to drm_gem_cma_create() that can skip the kernel mapping.
Apart from this,
Quoted 79 lines
drivers/gpu/drm/drm_gem_cma_helper.c +14
-4+* Returns: +* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative +* error code on failure. +*/ +struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm, +size_t size) +{ +return drm_gem_cma_create_flags (drm, size,DRM_MODE_DUMB_KERNEL_MAP ); +}EXPORT_SYMBOL_GPL (drm_gem_cma_create);/** @@ -139,14 +148,14 @@ EXPORT_SYMBOL_GPL(drm_gem_cma_create);*/ static struct drm_gem_cma_object *drm_gem_cma_create_with_handle (struct drm_file *file_priv, -struct drm_device *drm,size_t size, +struct drm_device *drm,size_t size,u32 flags,uint32_t *handle) {struct drm_gem_cma_object *cma_obj;struct drm_gem_object *gem_obj;int ret; - cma_obj =drm_gem_cma_create (drm, size); + cma_obj =drm_gem_cma_create_flags (drm, size, flags);if (IS_ERR (cma_obj))return cma_obj;@@ -225,7 +234,7 @@ int drm_gem_cma_dumb_create_internal(struct drm_file *file_priv, args->size = args->pitch * args->height; cma_obj =drm_gem_cma_create_with_handle (file_priv, drm, args->size, - &args->handle); + args->flags, &args->handle);return PTR_ERR_OR_ZERO (cma_obj); }EXPORT_SYMBOL_GPL (drm_gem_cma_dumb_create_internal);@@ -256,9 +265,10 @@ int drm_gem_cma_dumb_create(struct drm_file *file_priv, args->pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); args->size = args->pitch * args->height; + args->flags =DRM_MODE_DUMB_KERNEL_MAP ; cma_obj =drm_gem_cma_create_with_handle (file_priv, drm, args->size, - &args->handle); + args->flags, &args->handle);return PTR_ERR_OR_ZERO (cma_obj); }EXPORT_SYMBOL_GPL (drm_gem_cma_dumb_create);drivers/gpu/drm/meson/meson_drv.c +1
-0@@ -81,6 +81,7 @@ static int meson_dumb_create(struct drm_file *file, struct drm_device *dev,*/ args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ),SZ_64 ); args->size =PAGE_ALIGN (args->pitch * args->height); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/rcar-du/rcar_du_kms.c +1
-0@@ -299,6 +299,7 @@ int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, align =16 * args->bpp /8 ; args->pitch =roundup (min_pitch, align); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/rockchip/rockchip_drm_gem.c +0
-0
drivers/gpu/drm/rockchip/rockchip_drm_gem.c int rockchip_gem_dumb_create(struct drm_file *file_priv, · line 423
Quoted 5 lines
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +1
-0@@ -419,6 +419,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv,* align to 64 bytes since Mali requires it. */ args->pitch =ALIGN (min_pitch,64 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ; args->size = args->pitch * args->height;
My OCD gets triggered by flags appearing in the middle here while it is at the end in other drivers :-)
Quoted 26 lines
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +0
-0rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size,drivers/gpu/drm/stm/drv.c +1
-0@@ -47,6 +47,7 @@ static int stm_gem_cma_dumb_create(struct drm_file *file,*/ args->pitch =roundup (min_pitch,128 ); args->height =roundup (args->height,4 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/sun4i/sun4i_drv.c +1
-0@@ -34,6 +34,7 @@ static int drm_sun4i_gem_dumb_create(struct drm_file *file_priv, {/* The hardware only allows even pitches for YUV buffers. */ args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ),2 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag
Hi Laurent,
Quoted 13 lines · Laurent Pinchart
drivers/gpu/drm/rockchip/rockchip_drm_gem.c int rockchip_gem_dumb_create(struct drm_file *file_priv, · line 423
Quoted 8 lines · Rob Herring
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +1
-0@@ -419,6 +419,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv,* align to 64 bytes since Mali requires it. */ args->pitch =ALIGN (min_pitch,64 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ; args->size = args->pitch * args->height;My OCD gets triggered by flags appearing in the middle here while it is at the end in other drivers :-)
... while "flags" appears before "pitch" and "size" in the actual struct definition... Aaarghl ;-)
Gr{oetje,eeting}s,
Geert
Signature · 9 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/6] drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Laurent PinchartQuoted 56 lines · Laurent Pinchart
Hi Rob,
Thank you for the patch.
Quoted 50 lines · Rob Herring
Introduce a new flag,
DRM_MODE_DUMB_KERNEL_MAP, for structdrm_mode_create_dumb. This flag is for internal kernel use to indicate if dumb buffer allocation needs a kernel mapping. This is needed only for CMA where creating a kernel mapping or not has to be decided at allocation time because creating a mapping on demand (withvmap()) is not guaranteed to work. Several drivers are using CMA, but not the CMA helpers because they distinguish between kernel and userspace allocations to create a kernel mapping or not.Update the callers of
drm_mode_dumb_create()to set drm_mode_dumb_create.flags to appropriate defaults. Currently, flags can be set to anything by userspace, but is unused within the kernel. Let's force flags to zero (no kernel mapping) for userspace callers by default. For in kernel clients, setDRM_MODE_DUMB_KERNEL_MAPby default. Drivers can override this as needed.Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/gpu/drm/drm_client.c | 1 + drivers/gpu/drm/drm_dumb_buffers.c | 5 ++++- include/uapi/drm/drm_mode.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_client.c +1
-0@@ -264,6 +264,7 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u dumb_args.width = width; dumb_args.height = height; dumb_args.bpp = info->cpp[0 ] *8 ; + dumb_args.flags =DRM_MODE_DUMB_KERNEL_MAP ; ret =drm_mode_create_dumb (dev, &dumb_args, client->file);if (ret) goto err_delete;drivers/gpu/drm/drm_dumb_buffers.c +1
-1@@ -97,7 +97,10 @@ int drm_mode_create_dumb(struct drm_device *dev,int drm_mode_create_dumb_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv) { -return drm_mode_create_dumb (dev, data, file_priv); +struct drm_mode_create_dumb *args = data;
Quoted 8 lines
drivers/gpu/drm/drm_dumb_buffers.c int drm_mode_create_dumb(struct drm_device *dev, · line 102
Quoted 2 lines
drivers/gpu/drm/drm_dumb_buffers.c +2
-0+ + args->flags =0 ;I would prefer returning an error if flags is set to a non-zero value, to catch userspace errors early, but I'm also worried it would break existing userspace by uncovering existing bugs. Still, if we later add flags that userspace can set, those existing bugs will be triggered, so we'll have to deal with them anyway, and we could already give it a try.
I would like that too, but the comment just above this code tells me that's likely to break things:
/*
* handle, pitch and size are output parameters. Zero them out to
* prevent drivers from accidentally using uninitialized data. Since
* not all existing userspace is clearing these fields properly we
* cannot reject IOCTL with garbage in them.
*/
Maybe userspace does correctly zero out input params.
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Matthias Brugger
maintainerRe: [PATCH 5/6] drm/mediatek: Convert to use CMA helpers
In reply to Rob HerringHi Rob,
Quoted 15 lines · Rob Herring
The only reason the Mediatek driver doesn't use the CMA helpers is it sets
DMA_ATTR_NO_KERNEL_MAPPINGand does avmap()on demand. Usingvmap()is not even guaranteed to work as DMA buffers may not have a struct page. Now that the CMA helpers support settingDMA_ATTR_NO_KERNEL_MAPPINGas needed or not, convert Mediatek driver to use CMA helpers.Cc CK Hu <[email protected]>Cc Philipp Zabel <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Matthias Brugger <[email protected]>Signed-off-by Rob Herring <[email protected]>
Quoted 1 line
---
I tested this on my Chromebook with some patches on top of v5.4-rc1 [1], which work. If I add your patches on top of that, the system does not boot up. Unfortunately I don't have a serial console, so I wasn't able to see if there is any error message.
I checked the config and didn't see any suspicious
I added Uli and some guys from chromium, maybe someone can provide some logs/insights.
Regards,
Matthias
[1] https://github.com/uli/kernel/tree/elm-working-5.4
Quoted 496 lines
drivers/gpu/drm/mediatek/Makefile | 1 - drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 28 +-- drivers/gpu/drm/mediatek/mtk_drm_fb.c | 1 - drivers/gpu/drm/mediatek/mtk_drm_gem.c | 289 ----------------------- drivers/gpu/drm/mediatek/mtk_drm_gem.h | 51 ---- drivers/gpu/drm/mediatek/mtk_drm_plane.c | 7 +- 7 files changed, 15 insertions(+), 364 deletions(-) delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.c delete mode 100644 drivers/gpu/drm/mediatek/mtk_drm_gem.hdrivers/gpu/drm/mediatek/Makefile +0
-1@@ -8,7 +8,6 @@ mediatek-drm-y := mtk_disp_color.o \ mtk_drm_ddp_comp.o \ mtk_drm_drv.o \ mtk_drm_fb.o \ - mtk_drm_gem.o \ mtk_drm_plane.o \ mtk_dsi.o \ mtk_mipi_tx.o \drivers/gpu/drm/mediatek/mtk_drm_crtc.c +1
-1@@ -11,6 +11,7 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_plane_helper.h> +#include <drm/drm_print.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h> @@ -18,7 +19,6 @@#include "mtk_drm_crtc.h" #include "mtk_drm_ddp.h" #include "mtk_drm_ddp_comp.h" -#include "mtk_drm_gem.h" #include "mtk_drm_plane.h" /** drivers/gpu/drm/mediatek/mtk_drm_drv.c +11
-17@@ -28,7 +28,6 @@#include "mtk_drm_ddp_comp.h" #include "mtk_drm_drv.h" #include "mtk_drm_fb.h" -#include "mtk_drm_gem.h" #define DRIVER_NAME "mediatek"#define DRIVER_DESC "Mediatek SoC DRM"@@ -335,16 +334,14 @@ static void mtk_drm_kms_deinit(struct drm_device *drm)drm_mode_config_cleanup (drm); } -static const struct file_operations mtk_drm_fops = { - .owner =THIS_MODULE , - .open = drm_open, - .release = drm_release, - .unlocked_ioctl = drm_ioctl, - .mmap = mtk_drm_gem_mmap, - .poll = drm_poll, - .read = drm_read, - .compat_ioctl = drm_compat_ioctl, -}; +DEFINE_DRM_GEM_CMA_FOPS (mtk_drm_fops); + +static int mtk_drm_gem_dumb_create (struct drm_file *file_priv, +struct drm_device *dev, +struct drm_mode_create_dumb *args) +{ +return drm_gem_cma_dumb_create_internal (file_priv, dev, args); +}/* * We need to override this because the device used to import the memory is @@ -361,18 +358,15 @@ struct drm_gem_object *mtk_drm_gem_prime_import(struct drm_device *dev,static struct drm_driver mtk_drm_driver = { .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC , - .gem_free_object_unlocked = mtk_drm_gem_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, + .gem_create_object = drm_cma_gem_create_object_default_funcs, .dumb_create = mtk_drm_gem_dumb_create, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_import = mtk_drm_gem_prime_import, - .gem_prime_get_sg_table = mtk_gem_prime_get_sg_table, - .gem_prime_import_sg_table = mtk_gem_prime_import_sg_table, - .gem_prime_mmap = mtk_drm_gem_mmap_buf, - .gem_prime_vmap = mtk_drm_gem_prime_vmap, - .gem_prime_vunmap = mtk_drm_gem_prime_vunmap, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table_vmap, + .gem_prime_mmap = drm_gem_prime_mmap, .fops = &mtk_drm_fops, .name =DRIVER_NAME ,drivers/gpu/drm/mediatek/mtk_drm_fb.c +0
-1@@ -14,7 +14,6 @@#include "mtk_drm_drv.h" #include "mtk_drm_fb.h" -#include "mtk_drm_gem.h" static const struct drm_framebuffer_funcs mtk_drm_fb_funcs = { .create_handle = drm_gem_fb_create_handle,drivers/gpu/drm/mediatek/mtk_drm_gem.c deleted +0
-289@@ -1,289 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* -* Copyright (c) 2015 MediaTek Inc. -*/ - -#include <linux/dma-buf.h> - -#include <drm/drm.h> -#include <drm/drm_device.h> -#include <drm/drm_gem.h> -#include <drm/drm_prime.h> - -#include "mtk_drm_drv.h" -#include "mtk_drm_gem.h" - -static struct mtk_drm_gem_obj *mtk_drm_gem_init (struct drm_device *dev, -unsigned long size) -{ -struct mtk_drm_gem_obj *mtk_gem_obj; -int ret; - - size =round_up (size,PAGE_SIZE ); - - mtk_gem_obj =kzalloc (sizeof (*mtk_gem_obj),GFP_KERNEL ); -if (!mtk_gem_obj) -return ERR_PTR (-ENOMEM ); - - ret =drm_gem_object_init (dev, &mtk_gem_obj->base, size); -if (ret <0 ) { -DRM_ERROR ("failed to initialize gem object\n" ); -kfree (mtk_gem_obj); -return ERR_PTR (ret); - } - -return mtk_gem_obj; -} - -struct mtk_drm_gem_obj *mtk_drm_gem_create (struct drm_device *dev, -size_t size,bool alloc_kmap) -{ -struct mtk_drm_private *priv = dev->dev_private; -struct mtk_drm_gem_obj *mtk_gem; -struct drm_gem_object *obj; -int ret; - - mtk_gem =mtk_drm_gem_init (dev, size); -if (IS_ERR (mtk_gem)) -return ERR_CAST (mtk_gem); - - obj = &mtk_gem->base; - - mtk_gem->dma_attrs =DMA_ATTR_WRITE_COMBINE ; - -if (!alloc_kmap) - mtk_gem->dma_attrs |=DMA_ATTR_NO_KERNEL_MAPPING ; - - mtk_gem->cookie =dma_alloc_attrs (priv->dma_dev, obj->size, - &mtk_gem->dma_addr,GFP_KERNEL , - mtk_gem->dma_attrs); -if (!mtk_gem->cookie) { -DRM_ERROR ("failed to allocate %zx byte dma buffer" , obj->size); - ret = -ENOMEM ; - goto err_gem_free; - } - -if (alloc_kmap) - mtk_gem->kvaddr = mtk_gem->cookie; - -DRM_DEBUG_DRIVER ("cookie = %p dma_addr = %pad size = %zu\n" , - mtk_gem->cookie, &mtk_gem->dma_addr, - size); - -return mtk_gem; - -err_gem_free: -drm_gem_object_release (obj); -kfree (mtk_gem); -return ERR_PTR (ret); -} - -void mtk_drm_gem_free_object (struct drm_gem_object *obj) -{ -struct mtk_drm_gem_obj *mtk_gem =to_mtk_gem_obj (obj); -struct mtk_drm_private *priv = obj->dev->dev_private; - -if (mtk_gem->sg) -drm_prime_gem_destroy (obj, mtk_gem->sg); -else -dma_free_attrs (priv->dma_dev, obj->size, mtk_gem->cookie, - mtk_gem->dma_addr, mtk_gem->dma_attrs); - -/* release file pointer to gem object. */ -drm_gem_object_release (obj); - -kfree (mtk_gem); -} - -int mtk_drm_gem_dumb_create (struct drm_file *file_priv,struct drm_device *dev, -struct drm_mode_create_dumb *args) -{ -struct mtk_drm_gem_obj *mtk_gem; -int ret; - - args->pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); - args->size = args->pitch * args->height; - - mtk_gem =mtk_drm_gem_create (dev, args->size, false); -if (IS_ERR (mtk_gem)) -return PTR_ERR (mtk_gem); - -/* -* allocate a id of idr table where the obj is registered -* and handle has the id what user can see. -*/ - ret =drm_gem_handle_create (file_priv, &mtk_gem->base, &args->handle); -if (ret) - goto err_handle_create; - -/* drop reference from allocate - handle holds it now. */ -drm_gem_object_put_unlocked (&mtk_gem->base); - -return 0 ; - -err_handle_create: -mtk_drm_gem_free_object (&mtk_gem->base); -return ret; -} - -static int mtk_drm_gem_object_mmap (struct drm_gem_object *obj, -struct vm_area_struct *vma) - -{ -int ret; -struct mtk_drm_gem_obj *mtk_gem =to_mtk_gem_obj (obj); -struct mtk_drm_private *priv = obj->dev->dev_private; - -/* -* dma_alloc_attrs() allocated a struct page table for mtk_gem, so clear -* VM_PFNMAP flag that was set by drm_gem_mmap_obj()/drm_gem_mmap(). -*/ - vma->vm_flags &= ~VM_PFNMAP ; - - ret =dma_mmap_attrs (priv->dma_dev, vma, mtk_gem->cookie, - mtk_gem->dma_addr, obj->size, mtk_gem->dma_attrs); -if (ret) -drm_gem_vm_close (vma); - -return ret; -} - -int mtk_drm_gem_mmap_buf (struct drm_gem_object *obj,struct vm_area_struct *vma) -{ -int ret; - - ret =drm_gem_mmap_obj (obj, obj->size, vma); -if (ret) -return ret; - -return mtk_drm_gem_object_mmap (obj, vma); -} - -int mtk_drm_gem_mmap (struct file *filp,struct vm_area_struct *vma) -{ -struct drm_gem_object *obj; -int ret; - - ret =drm_gem_mmap (filp, vma); -if (ret) -return ret; - - obj = vma->vm_private_data; - -/* -* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 and map the -* whole buffer from the start. -*/ - vma->vm_pgoff =0 ; - -return mtk_drm_gem_object_mmap (obj, vma); -} - -/* -* Allocate a sg_table for this GEM object. -* Note: Both the table's contents, and the sg_table itself must be freed by -* the caller. -* Returns a pointer to the newly allocated sg_table, or an ERR_PTR() error. -*/ -struct sg_table *mtk_gem_prime_get_sg_table (struct drm_gem_object *obj) -{ -struct mtk_drm_gem_obj *mtk_gem =to_mtk_gem_obj (obj); -struct mtk_drm_private *priv = obj->dev->dev_private; -struct sg_table *sgt; -int ret; - - sgt =kzalloc (sizeof (*sgt),GFP_KERNEL ); -if (!sgt) -return ERR_PTR (-ENOMEM ); - - ret =dma_get_sgtable_attrs (priv->dma_dev, sgt, mtk_gem->cookie, - mtk_gem->dma_addr, obj->size, - mtk_gem->dma_attrs); -if (ret) { -DRM_ERROR ("failed to allocate sgt, %d\n" , ret); -kfree (sgt); -return ERR_PTR (ret); - } - -return sgt; -} - -struct drm_gem_object *mtk_gem_prime_import_sg_table (struct drm_device *dev, -struct dma_buf_attachment *attach,struct sg_table *sg) -{ -struct mtk_drm_gem_obj *mtk_gem; -int ret; -struct scatterlist *s; -unsigned int i; -dma_addr_t expected; - - mtk_gem =mtk_drm_gem_init (dev, attach->dmabuf->size); - -if (IS_ERR (mtk_gem)) -return ERR_CAST (mtk_gem); - - expected =sg_dma_address (sg->sgl); -for_each_sg (sg->sgl, s, sg->nents, i) { -if (sg_dma_address (s) != expected) { -DRM_ERROR ("sg_table is not contiguous" ); - ret = -EINVAL ; - goto err_gem_free; - } - expected =sg_dma_address (s) +sg_dma_len (s); - } - - mtk_gem->dma_addr =sg_dma_address (sg->sgl); - mtk_gem->sg = sg; - -return &mtk_gem->base; - -err_gem_free: -kfree (mtk_gem); -return ERR_PTR (ret); -} - -void *mtk_drm_gem_prime_vmap (struct drm_gem_object *obj) -{ -struct mtk_drm_gem_obj *mtk_gem =to_mtk_gem_obj (obj); -struct sg_table *sgt; -struct sg_page_iter iter; -unsigned int npages; -unsigned int i =0 ; - -if (mtk_gem->kvaddr) -return mtk_gem->kvaddr; - - sgt =mtk_gem_prime_get_sg_table (obj); -if (IS_ERR (sgt)) -return NULL ; - - npages = obj->size >>PAGE_SHIFT ; - mtk_gem->pages =kcalloc (npages,sizeof (*mtk_gem->pages),GFP_KERNEL ); -if (!mtk_gem->pages) - goto out; - -for_each_sg_page (sgt->sgl, &iter, sgt->orig_nents,0 ) { - mtk_gem->pages[i++] =sg_page_iter_page (&iter); -if (i > npages) -break ; - } - mtk_gem->kvaddr =vmap (mtk_gem->pages, npages,VM_MAP , -pgprot_writecombine (PAGE_KERNEL )); - -out: -kfree ((void *)sgt); - -return mtk_gem->kvaddr; -} - -void mtk_drm_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr) -{ -struct mtk_drm_gem_obj *mtk_gem =to_mtk_gem_obj (obj); - -if (!mtk_gem->pages) -return ; - -vunmap (vaddr); - mtk_gem->kvaddr =0 ; -kfree ((void *)mtk_gem->pages); -}drivers/gpu/drm/mediatek/mtk_drm_gem.h deleted +0
-51@@ -1,51 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Copyright (c) 2015 MediaTek Inc. -*/ - -#ifndef _MTK_DRM_GEM_H_ -#define _MTK_DRM_GEM_H_ - -#include <drm/drm_gem.h> - -/* -* mtk drm buffer structure. -* -* @base: a gem object. -* - a new handle to this gem object would be created -* by drm_gem_handle_create(). -* @cookie: the return value of dma_alloc_attrs(), keep it for dma_free_attrs() -* @kvaddr: kernel virtual address of gem buffer. -* @dma_addr: dma address of gem buffer. -* @dma_attrs: dma attributes of gem buffer. -* -* P.S. this object would be transferred to user as kms_bo.handle so -* user can access the buffer through kms_bo.handle. -*/ -struct mtk_drm_gem_obj { -struct drm_gem_object base; -void *cookie; -void *kvaddr; -dma_addr_t dma_addr; -unsigned long dma_attrs; -struct sg_table *sg; -struct page **pages; -}; - -#define to_mtk_gem_obj (x) container_of(x, struct mtk_drm_gem_obj, base) - -void mtk_drm_gem_free_object (struct drm_gem_object *gem); -struct mtk_drm_gem_obj *mtk_drm_gem_create (struct drm_device *dev,size_t size, -bool alloc_kmap); -int mtk_drm_gem_dumb_create (struct drm_file *file_priv,struct drm_device *dev, -struct drm_mode_create_dumb *args); -int mtk_drm_gem_mmap (struct file *filp,struct vm_area_struct *vma); -int mtk_drm_gem_mmap_buf (struct drm_gem_object *obj, -struct vm_area_struct *vma); -struct sg_table *mtk_gem_prime_get_sg_table (struct drm_gem_object *obj); -struct drm_gem_object *mtk_gem_prime_import_sg_table (struct drm_device *dev, -struct dma_buf_attachment *attach,struct sg_table *sg); -void *mtk_drm_gem_prime_vmap (struct drm_gem_object *obj); -void mtk_drm_gem_prime_vunmap (struct drm_gem_object *obj,void *vaddr); - -#endif drivers/gpu/drm/mediatek/mtk_drm_plane.c +2
-2@@ -8,13 +8,14 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_fourcc.h> #include <drm/drm_plane_helper.h> +#include <drm/drm_print.h> +#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include "mtk_drm_crtc.h" #include "mtk_drm_ddp_comp.h" #include "mtk_drm_drv.h" #include "mtk_drm_fb.h" -#include "mtk_drm_gem.h" #include "mtk_drm_plane.h" static const u32 formats[] = {@@ -108,7 +109,6 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,struct drm_crtc *crtc = plane->state->crtc;struct drm_framebuffer *fb = plane->state->fb;struct drm_gem_object *gem; -struct mtk_drm_gem_obj *mtk_gem;unsigned int pitch, format;dma_addr_t addr;
drivers/gpu/drm/mediatek/mtk_drm_plane.c static void mtk_plane_atomic_update(struct drm_plane *plane, · line 122
Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1
-2@@ -116,8 +116,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,return ; gem = fb->obj[0 ]; - mtk_gem =to_mtk_gem_obj (gem); - addr = mtk_gem->dma_addr; + addr =to_drm_gem_cma_obj (gem)->paddr; pitch = fb->pitches[0 ]; format = fb->format->format;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Geert UytterhoevenQuoted 19 lines · Geert Uytterhoeven
Hi Laurent,
Quoted 13 lines · Laurent Pinchart
drivers/gpu/drm/rockchip/rockchip_drm_gem.c int rockchip_gem_dumb_create(struct drm_file *file_priv, · line 423
Quoted 8 lines · Rob Herring
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +1
-0@@ -419,6 +419,7 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv,* align to 64 bytes since Mali requires it. */ args->pitch =ALIGN (min_pitch,64 ); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ; args->size = args->pitch * args->height;My OCD gets triggered by flags appearing in the middle here while it is at the end in other drivers :-)
Quoted 2 lines
... while "flags" appears before "pitch" and "size" in the actual struct definition... Aaarghl ;-)
There was some reasoning here as my CMA helper conversion patch is going to insert code between flags and size.
But to keep everyone's OCD in check, I can set flags first.
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Laurent PinchartQuoted 124 lines · Laurent Pinchart
Hi Rob,
Thank you for the patch.
Quoted 118 lines · Rob Herring
Add support in CMA helpers to handle callers specifying
DRM_MODE_DUMB_KERNEL_MAPflag. Existing behavior is maintained with this change.drm_gem_cma_dumb_create()always creates a kernel mapping as before.drm_gem_cma_dumb_create_internal()lets the caller set the flags as desired. Therefore, update all the existing callers ofdrm_gem_cma_dumb_create_internal()to also set theDRM_MODE_DUMB_KERNEL_MAPflag.Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc "James (Qian) Wang" <[email protected]>Cc Liviu Dudau <[email protected]>Cc Brian Starkey <[email protected]>Cc Neil Armstrong <[email protected]>Cc Kevin Hilman <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Sandy Huang <[email protected]>Cc "Heiko Stübner" <[email protected]>Cc Yannick Fertre <[email protected]>Cc Philippe Cornu <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Chen-Yu Tsai <[email protected]>Signed-off-by Rob Herring <[email protected]>--- .../gpu/drm/arm/display/komeda/komeda_kms.c | 1 + drivers/gpu/drm/arm/malidp_drv.c | 1 + drivers/gpu/drm/drm_gem_cma_helper.c | 48 +++++++++++-------- drivers/gpu/drm/meson/meson_drv.c | 1 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 1 + drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 1 + drivers/gpu/drm/stm/drv.c | 1 + drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + 8 files changed, 36 insertions(+), 19 deletions(-)drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -31,6 +31,7 @@ static int komeda_gem_cma_dumb_create(struct drm_file *file,u32 pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); args->pitch =ALIGN (pitch, mdev->chip.bus_width); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/arm/malidp_drv.c +1
-0@@ -465,6 +465,7 @@ static int malidp_dumb_create(struct drm_file *file_priv,u8 alignment =malidp_hw_get_pitch_align (malidp->dev,1 ); args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ), alignment); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }drivers/gpu/drm/drm_gem_cma_helper.c +11
-15@@ -78,21 +78,8 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)return ERR_PTR (ret); } -/** -* drm_gem_cma_create - allocate an object with the given size -* @drm: DRM device -* @size: size of the object to allocate -* -* This function creates a CMA GEM object and allocates a contiguous chunk of -* memory as backing store. The backing memory has the writecombine attribute -* set. -* -* Returns: -* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative -* error code on failure. -*/ -struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm, -size_t size) +static struct drm_gem_cma_object * +drm_gem_cma_create_flags (struct drm_device *drm,size_t size,u32 flags) {struct drm_gem_cma_object *cma_obj;int ret;@@ -103,6 +90,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,if (IS_ERR (cma_obj))return cma_obj; +if (!(flags &DRM_MODE_DUMB_KERNEL_MAP )) + cma_obj->dma_attrs |=DMA_ATTR_NO_KERNEL_MAPPING ; + cma_obj->vaddr =dma_alloc_attrs (drm->dev, size, &cma_obj->paddr,GFP_KERNEL | __GFP_NOWARN, cma_obj->dma_attrs);@@ -119,6 +109,25 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,drm_gem_object_put_unlocked (&cma_obj->base);return ERR_PTR (ret); } + +/** +* drm_gem_cma_create - allocate an object with the given size +* @drm: DRM device +* @size: size of the object to allocate +*
Quoted 8 lines
drivers/gpu/drm/drm_gem_cma_helper.c struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, · line 121
Quoted 4 lines
drivers/gpu/drm/drm_gem_cma_helper.c +4
-0+* This function creates a CMA GEM object and allocates a contiguous chunk of +* memory as backing store. The backing memory has the writecombine attribute +* set. +* Shouldn't you mention here that the function always creates a kernel mapping, and that callers that don't need the mapping should use
drm_gem_cma_dumb_create_internal()instead ?
Are you confusing drm_gem_cma_create with drm_gem_cma_dumb_create? drm_gem_cma_dumb_create() uses defaults and drm_gem_cma_dumb_create_internal() allows the caller to tweak parameters. Nothing new there other than an additional param to tweak.
Quoted 3 lines
drm_gem_cma_dumb_create_internal()operates at a different level though, anddrm_gem_cma_create()is only exported for a single driver. There's no equivalent todrm_gem_cma_create()that can skip the kernel mapping.
Because we don't yet need one. drm_gem_cma_create_flags() can be made public when we do. I could do that now I guess and make drm_gem_cma_create an inline wrapper.
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/6] drm/cma-helper: Support DRM_MODE_DUMB_KERNEL_MAP flag
Hi Rob,
Quoted 134 lines · Rob Herring
Quoted 119 lines · Laurent Pinchart
Quoted 118 lines · Rob Herring
Add support in CMA helpers to handle callers specifying
DRM_MODE_DUMB_KERNEL_MAPflag. Existing behavior is maintained with this change.drm_gem_cma_dumb_create()always creates a kernel mapping as before.drm_gem_cma_dumb_create_internal()lets the caller set the flags as desired. Therefore, update all the existing callers ofdrm_gem_cma_dumb_create_internal()to also set theDRM_MODE_DUMB_KERNEL_MAPflag.Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc "James (Qian) Wang" <[email protected]>Cc Liviu Dudau <[email protected]>Cc Brian Starkey <[email protected]>Cc Neil Armstrong <[email protected]>Cc Kevin Hilman <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Kieran Bingham <[email protected]>Cc Sandy Huang <[email protected]>Cc "Heiko Stübner" <[email protected]>Cc Yannick Fertre <[email protected]>Cc Philippe Cornu <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Vincent Abriou <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Chen-Yu Tsai <[email protected]>Signed-off-by Rob Herring <[email protected]>--- .../gpu/drm/arm/display/komeda/komeda_kms.c | 1 + drivers/gpu/drm/arm/malidp_drv.c | 1 + drivers/gpu/drm/drm_gem_cma_helper.c | 48 +++++++++++-------- drivers/gpu/drm/meson/meson_drv.c | 1 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 1 + drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 1 + drivers/gpu/drm/stm/drv.c | 1 + drivers/gpu/drm/sun4i/sun4i_drv.c | 1 + 8 files changed, 36 insertions(+), 19 deletions(-)drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-0@@ -31,6 +31,7 @@ static int komeda_gem_cma_dumb_create(struct drm_file *file,u32 pitch =DIV_ROUND_UP (args->width * args->bpp,8 ); args->pitch =ALIGN (pitch, mdev->chip.bus_width); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file, dev, args); }drivers/gpu/drm/arm/malidp_drv.c +1
-0@@ -465,6 +465,7 @@ static int malidp_dumb_create(struct drm_file *file_priv,u8 alignment =malidp_hw_get_pitch_align (malidp->dev,1 ); args->pitch =ALIGN (DIV_ROUND_UP (args->width * args->bpp,8 ), alignment); + args->flags =DRM_MODE_DUMB_KERNEL_MAP ;return drm_gem_cma_dumb_create_internal (file_priv, drm, args); }drivers/gpu/drm/drm_gem_cma_helper.c +11
-15@@ -78,21 +78,8 @@ __drm_gem_cma_create(struct drm_device *drm, size_t size)return ERR_PTR (ret); } -/** -* drm_gem_cma_create - allocate an object with the given size -* @drm: DRM device -* @size: size of the object to allocate -* -* This function creates a CMA GEM object and allocates a contiguous chunk of -* memory as backing store. The backing memory has the writecombine attribute -* set. -* -* Returns: -* A struct drm_gem_cma_object * on success or an ERR_PTR()-encoded negative -* error code on failure. -*/ -struct drm_gem_cma_object *drm_gem_cma_create (struct drm_device *drm, -size_t size) +static struct drm_gem_cma_object * +drm_gem_cma_create_flags (struct drm_device *drm,size_t size,u32 flags) {struct drm_gem_cma_object *cma_obj;int ret;@@ -103,6 +90,9 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,if (IS_ERR (cma_obj))return cma_obj; +if (!(flags &DRM_MODE_DUMB_KERNEL_MAP )) + cma_obj->dma_attrs |=DMA_ATTR_NO_KERNEL_MAPPING ; + cma_obj->vaddr =dma_alloc_attrs (drm->dev, size, &cma_obj->paddr,GFP_KERNEL | __GFP_NOWARN, cma_obj->dma_attrs);@@ -119,6 +109,25 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,drm_gem_object_put_unlocked (&cma_obj->base);return ERR_PTR (ret); } + +/** +* drm_gem_cma_create - allocate an object with the given size +* @drm: DRM device +* @size: size of the object to allocate +* Quoted 8 lines
drivers/gpu/drm/drm_gem_cma_helper.c struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, · line 121
Quoted 4 lines
drivers/gpu/drm/drm_gem_cma_helper.c +4
-0+* This function creates a CMA GEM object and allocates a contiguous chunk of +* memory as backing store. The backing memory has the writecombine attribute +* set. +* Shouldn't you mention here that the function always creates a kernel mapping, and that callers that don't need the mapping should use
drm_gem_cma_dumb_create_internal()instead ?Are you confusing
drm_gem_cma_createwithdrm_gem_cma_dumb_create?drm_gem_cma_dumb_create()uses defaults anddrm_gem_cma_dumb_create_internal()allows the caller to tweak parameters. Nothing new there other than an additional param to tweak.
Quoted 7 lines
Quoted 3 lines
drm_gem_cma_dumb_create_internal()operates at a different level though, anddrm_gem_cma_create()is only exported for a single driver. There's no equivalent todrm_gem_cma_create()that can skip the kernel mapping.Because we don't yet need one.
drm_gem_cma_create_flags()can be made public when we do. I could do that now I guess and makedrm_gem_cma_createan inline wrapper.
I don't mind not having drm_gem_cma_create_flags() made public (but you can do so already if you prefer) if there's no user. My point is that we now have a mechanism to skip creation of kernel mappings, and that drm_gem_cma_create() will always result in the creation of a kernel mapping. I thought it was worth mentioning it, but if you think that's not needed, feel free to ignore the comment.
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/6] drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flag
In reply to Rob HerringHi Rob,
Quoted 64 lines · Rob Herring
Quoted 51 lines · Laurent Pinchart
Quoted 50 lines · Rob Herring
Introduce a new flag,
DRM_MODE_DUMB_KERNEL_MAP, for structdrm_mode_create_dumb. This flag is for internal kernel use to indicate if dumb buffer allocation needs a kernel mapping. This is needed only for CMA where creating a kernel mapping or not has to be decided at allocation time because creating a mapping on demand (withvmap()) is not guaranteed to work. Several drivers are using CMA, but not the CMA helpers because they distinguish between kernel and userspace allocations to create a kernel mapping or not.Update the callers of
drm_mode_dumb_create()to set drm_mode_dumb_create.flags to appropriate defaults. Currently, flags can be set to anything by userspace, but is unused within the kernel. Let's force flags to zero (no kernel mapping) for userspace callers by default. For in kernel clients, setDRM_MODE_DUMB_KERNEL_MAPby default. Drivers can override this as needed.Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/gpu/drm/drm_client.c | 1 + drivers/gpu/drm/drm_dumb_buffers.c | 5 ++++- include/uapi/drm/drm_mode.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_client.c +1
-0@@ -264,6 +264,7 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u dumb_args.width = width; dumb_args.height = height; dumb_args.bpp = info->cpp[0 ] *8 ; + dumb_args.flags =DRM_MODE_DUMB_KERNEL_MAP ; ret =drm_mode_create_dumb (dev, &dumb_args, client->file);if (ret) goto err_delete;drivers/gpu/drm/drm_dumb_buffers.c +1
-1@@ -97,7 +97,10 @@ int drm_mode_create_dumb(struct drm_device *dev,int drm_mode_create_dumb_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv) { -return drm_mode_create_dumb (dev, data, file_priv); +struct drm_mode_create_dumb *args = data;Quoted 8 lines
drivers/gpu/drm/drm_dumb_buffers.c int drm_mode_create_dumb(struct drm_device *dev, · line 102
Quoted 2 lines
drivers/gpu/drm/drm_dumb_buffers.c +2
-0+ + args->flags =0 ;I would prefer returning an error if flags is set to a non-zero value, to catch userspace errors early, but I'm also worried it would break existing userspace by uncovering existing bugs. Still, if we later add flags that userspace can set, those existing bugs will be triggered, so we'll have to deal with them anyway, and we could already give it a try.
I would like that too, but the comment just above this code tells me that's likely to break things:
Quoted 8 lines
/*
* handle, pitch and size are output parameters. Zero them out to
* prevent drivers from accidentally using uninitialized data. Since
* not all existing userspace is clearing these fields properly we
* cannot reject IOCTL with garbage in them.
*/Maybe userspace does correctly zero out input params.
But if that holds true, it means that we will never be able to add userspace flags, as doing so could break applications for the same reason. The flag field should thus be marked as deprecated for userspace usage. I wonder how big the risk is.
Signature · 7 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/6] drm: Introduce DRM_MODE_DUMB_KERNEL_MAP flag
Quoted 75 lines · Laurent Pinchart
Hi Rob,
Quoted 71 lines · Rob Herring
Quoted 51 lines · Laurent Pinchart
Quoted 50 lines · Rob Herring
Introduce a new flag,
DRM_MODE_DUMB_KERNEL_MAP, for structdrm_mode_create_dumb. This flag is for internal kernel use to indicate if dumb buffer allocation needs a kernel mapping. This is needed only for CMA where creating a kernel mapping or not has to be decided at allocation time because creating a mapping on demand (withvmap()) is not guaranteed to work. Several drivers are using CMA, but not the CMA helpers because they distinguish between kernel and userspace allocations to create a kernel mapping or not.Update the callers of
drm_mode_dumb_create()to set drm_mode_dumb_create.flags to appropriate defaults. Currently, flags can be set to anything by userspace, but is unused within the kernel. Let's force flags to zero (no kernel mapping) for userspace callers by default. For in kernel clients, setDRM_MODE_DUMB_KERNEL_MAPby default. Drivers can override this as needed.Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Maarten Lankhorst <[email protected]>Cc Maxime Ripard <[email protected]>Cc Sean Paul <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/gpu/drm/drm_client.c | 1 + drivers/gpu/drm/drm_dumb_buffers.c | 5 ++++- include/uapi/drm/drm_mode.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_client.c +1
-0@@ -264,6 +264,7 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u dumb_args.width = width; dumb_args.height = height; dumb_args.bpp = info->cpp[0 ] *8 ; + dumb_args.flags =DRM_MODE_DUMB_KERNEL_MAP ; ret =drm_mode_create_dumb (dev, &dumb_args, client->file);if (ret) goto err_delete;drivers/gpu/drm/drm_dumb_buffers.c +1
-1@@ -97,7 +97,10 @@ int drm_mode_create_dumb(struct drm_device *dev,int drm_mode_create_dumb_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv) { -return drm_mode_create_dumb (dev, data, file_priv); +struct drm_mode_create_dumb *args = data;Quoted 8 lines
drivers/gpu/drm/drm_dumb_buffers.c int drm_mode_create_dumb(struct drm_device *dev, · line 102
Quoted 2 lines
drivers/gpu/drm/drm_dumb_buffers.c +2
-0+ + args->flags =0 ;I would prefer returning an error if flags is set to a non-zero value, to catch userspace errors early, but I'm also worried it would break existing userspace by uncovering existing bugs. Still, if we later add flags that userspace can set, those existing bugs will be triggered, so we'll have to deal with them anyway, and we could already give it a try.
I would like that too, but the comment just above this code tells me that's likely to break things:
/*
* handle, pitch and size are output parameters. Zero them out to
* prevent drivers from accidentally using uninitialized data. Since
* not all existing userspace is clearing these fields properly we
* cannot reject IOCTL with garbage in them.
*/
Quoted 6 lines
Quoted 1 line
Maybe userspace does correctly zero out input params.
But if that holds true, it means that we will never be able to add userspace flags, as doing so could break applications for the same reason. The flag field should thus be marked as deprecated for userspace usage. I wonder how big the risk is.
Good point. I guess another option is add a WARN(flags != 0) and see what happens.
The commit adding the comment was f60859522a83 ("drm: Sanitize DRM_IOCTL_MODE_CREATE_DUMB input"). Maybe Thierry has some comment?
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/6] drm/mediatek: Convert to use CMA helpers
In reply to Matthias BruggerQuoted 21 lines · Matthias Brugger
Hi Rob,
Quoted 15 lines · Rob Herring
The only reason the Mediatek driver doesn't use the CMA helpers is it sets
DMA_ATTR_NO_KERNEL_MAPPINGand does avmap()on demand. Usingvmap()is not even guaranteed to work as DMA buffers may not have a struct page. Now that the CMA helpers support settingDMA_ATTR_NO_KERNEL_MAPPINGas needed or not, convert Mediatek driver to use CMA helpers.Cc CK Hu <[email protected]>Cc Philipp Zabel <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Matthias Brugger <[email protected]>Signed-off-by Rob Herring <[email protected]>Quoted 1 line
---
Quoted 4 lines
I tested this on my Chromebook with some patches on top of v5.4-rc1 [1], which work. If I add your patches on top of that, the system does not boot up. Unfortunately I don't have a serial console, so I wasn't able to see if there is any error message.
Thanks for testing. I'm based on drm-misc-next, but don't see anything obvious there that would matter. There are some mmap changes, but I think they shouldn't matter.
Did you have fbcon enabled? That may give more clues about where the problem is.
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/6] drm/mediatek: Convert to use CMA helpers
Hi, Rob:
Quoted 28 lines · Rob Herring
Quoted 21 lines · Matthias Brugger
Hi Rob,
Quoted 15 lines · Rob Herring
The only reason the Mediatek driver doesn't use the CMA helpers is it sets
DMA_ATTR_NO_KERNEL_MAPPINGand does avmap()on demand. Usingvmap()is not even guaranteed to work as DMA buffers may not have a struct page. Now that the CMA helpers support settingDMA_ATTR_NO_KERNEL_MAPPINGas needed or not, convert Mediatek driver to use CMA helpers.Cc CK Hu <[email protected]>Cc Philipp Zabel <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Matthias Brugger <[email protected]>Signed-off-by Rob Herring <[email protected]>Quoted 1 line
---
Quoted 4 lines
I tested this on my Chromebook with some patches on top of v5.4-rc1 [1], which work. If I add your patches on top of that, the system does not boot up. Unfortunately I don't have a serial console, so I wasn't able to see if there is any error message.
Quoted 5 lines
Thanks for testing. I'm based on drm-misc-next, but don't see anything obvious there that would matter. There are some mmap changes, but I think they shouldn't matter.
Did you have fbcon enabled? That may give more clues about where the problem is.
There are priv->dma_dev for dma device, but it is not drm device. In mt8173.dtsi [1], there are mmsys device and ovl device, mmsys device is drm device and ovl device is mmsys's sub device which provide dma function, so ovl is the priv->dma_dev. I think your patch directly use drm device for dma operation and this would cause dma function fail. Please use priv->dma_dev for dma operation.
Regards,
CK
Quoted 2 lines
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/6] drm/mediatek: Convert to use CMA helpers
Quoted 36 lines · CK Hu
Hi, Rob:
Quoted 32 lines · Rob Herring
Quoted 21 lines · Matthias Brugger
Hi Rob,
Quoted 15 lines · Rob Herring
The only reason the Mediatek driver doesn't use the CMA helpers is it sets
DMA_ATTR_NO_KERNEL_MAPPINGand does avmap()on demand. Usingvmap()is not even guaranteed to work as DMA buffers may not have a struct page. Now that the CMA helpers support settingDMA_ATTR_NO_KERNEL_MAPPINGas needed or not, convert Mediatek driver to use CMA helpers.Cc CK Hu <[email protected]>Cc Philipp Zabel <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Matthias Brugger <[email protected]>Signed-off-by Rob Herring <[email protected]>Quoted 1 line
---
Quoted 4 lines
I tested this on my Chromebook with some patches on top of v5.4-rc1 [1], which work. If I add your patches on top of that, the system does not boot up. Unfortunately I don't have a serial console, so I wasn't able to see if there is any error message.
Thanks for testing. I'm based on drm-misc-next, but don't see anything obvious there that would matter. There are some mmap changes, but I think they shouldn't matter.
Quoted 8 lines
Quoted 1 line
Did you have fbcon enabled? That may give more clues about where the problem is.
There are
priv->dma_devfor dma device, but it is not drm device. Inmt8173.dtsi[1], there are mmsys device and ovl device, mmsys device is drm device and ovl device is mmsys's sub device which provide dma function, so ovl is thepriv->dma_dev. I think your patch directly use drm device for dma operation and this would cause dma function fail. Please usepriv->dma_devfor dma operation.
Right, thanks for catching that. Either we'll need to make CMA GEM object have a struct device ptr or adjust the drm_device.dev to have the necessary DMA setup.
One question though, why do you use CMA when you have an IOMMU? That's not optimal as CMA size may be limited. Or you don't always have an IOMMU?
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/6] drm/mediatek: Convert to use CMA helpers
Hi, Rob:
Quoted 46 lines · Rob Herring
Quoted 36 lines · CK Hu
Hi, Rob:
Quoted 32 lines · Rob Herring
Quoted 21 lines · Matthias Brugger
Hi Rob,
Quoted 15 lines · Rob Herring
The only reason the Mediatek driver doesn't use the CMA helpers is it sets
DMA_ATTR_NO_KERNEL_MAPPINGand does avmap()on demand. Usingvmap()is not even guaranteed to work as DMA buffers may not have a struct page. Now that the CMA helpers support settingDMA_ATTR_NO_KERNEL_MAPPINGas needed or not, convert Mediatek driver to use CMA helpers.Cc CK Hu <[email protected]>Cc Philipp Zabel <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Matthias Brugger <[email protected]>Signed-off-by Rob Herring <[email protected]>Quoted 1 line
---
Quoted 4 lines
I tested this on my Chromebook with some patches on top of v5.4-rc1 [1], which work. If I add your patches on top of that, the system does not boot up. Unfortunately I don't have a serial console, so I wasn't able to see if there is any error message.
Thanks for testing. I'm based on drm-misc-next, but don't see anything obvious there that would matter. There are some mmap changes, but I think they shouldn't matter.
Quoted 8 lines
Quoted 1 line
Did you have fbcon enabled? That may give more clues about where the problem is.
There are
priv->dma_devfor dma device, but it is not drm device. Inmt8173.dtsi[1], there are mmsys device and ovl device, mmsys device is drm device and ovl device is mmsys's sub device which provide dma function, so ovl is thepriv->dma_dev. I think your patch directly use drm device for dma operation and this would cause dma function fail. Please usepriv->dma_devfor dma operation.
Quoted 7 lines
Right, thanks for catching that. Either we'll need to make CMA GEM object have a struct device ptr or adjust the drm_device.dev to have the necessary DMA setup.
One question though, why do you use CMA when you have an IOMMU? That's not optimal as CMA size may be limited. Or you don't always have an IOMMU?
For all upstreamed mediatek SoC, all has IOMMU, so it does not need CMA. I think we use CMA just because we refer to other drm driver to implement mediatek drm driver and we misused CMA helper function but it works. I think we should change to more accurate implementation. If you want, you could modify it in this series.
Regards,
CK
Quoted 2 lines
Rob
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/6] drm/mediatek: Convert to use CMA helpers
Hi Rob,
Quoted 40 lines · CK Hu
Quoted 39 lines · Rob Herring
Quoted 37 lines · CK Hu
Quoted 24 lines · Rob Herring
Quoted 18 lines · Matthias Brugger
Quoted 15 lines · Rob Herring
The only reason the Mediatek driver doesn't use the CMA helpers is it sets
DMA_ATTR_NO_KERNEL_MAPPINGand does avmap()on demand. Usingvmap()is not even guaranteed to work as DMA buffers may not have a struct page. Now that the CMA helpers support settingDMA_ATTR_NO_KERNEL_MAPPINGas needed or not, convert Mediatek driver to use CMA helpers.Cc CK Hu <[email protected]>Cc Philipp Zabel <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Matthias Brugger <[email protected]>Signed-off-by Rob Herring <[email protected]>Quoted 1 line
---
Quoted 4 lines
I tested this on my Chromebook with some patches on top of v5.4-rc1 [1], which work. If I add your patches on top of that, the system does not boot up. Unfortunately I don't have a serial console, so I wasn't able to see if there is any error message.
Quoted 5 lines
Thanks for testing. I'm based on drm-misc-next, but don't see anything obvious there that would matter. There are some mmap changes, but I think they shouldn't matter.
Did you have fbcon enabled? That may give more clues about where the problem is.
There are
priv->dma_devfor dma device, but it is not drm device. Inmt8173.dtsi[1], there are mmsys device and ovl device, mmsys device is drm device and ovl device is mmsys's sub device which provide dma function, so ovl is thepriv->dma_dev. I think your patch directly use drm device for dma operation and this would cause dma function fail. Please usepriv->dma_devfor dma operation.
Quoted 7 lines
Quoted 7 lines
Right, thanks for catching that. Either we'll need to make CMA GEM object have a struct device ptr or adjust the drm_device.dev to have the necessary DMA setup.
One question though, why do you use CMA when you have an IOMMU? That's not optimal as CMA size may be limited. Or you don't always have an IOMMU?
Please note that the DRM GEM CMA helpers are misnamed, they use the DMA coherent allocation API, and thus don't use CMA if the device is backed by an IOMMU. They should really have been named DRM GEM DMA helpers.
Quoted 6 lines
For all upstreamed mediatek SoC, all has IOMMU, so it does not need CMA. I think we use CMA just because we refer to other drm driver to implement mediatek drm driver and we misused CMA helper function but it works. I think we should change to more accurate implementation. If you want, you could modify it in this series.
Signature · 3 lines
Regards, Laurent Pinchart