2016-11-30 12:35 GMT+01:00 Laurent Pinchart laurent.pinchart@ideasonboard.com:
Hi Benjamin,
Thank you for the patch.
On Wednesday 30 Nov 2016 12:21:24 Benjamin Gaignard wrote:
Some platforms without MMU have display drivers where a drm/kms driver could be implemented. Before doing such kind of thing drm/kms must allow to use mmuless devices. This patch proposes to remove MMU configuration flag and add some cma helpers functions to help implementing mmuless display driver
Signed-off-by: Benjamin Gaignard benjamin.gaignard@linaro.org
drivers/gpu/drm/Kconfig | 4 +-- drivers/gpu/drm/drm_fb_cma_helper.c | 20 ++++++++++++ drivers/gpu/drm/drm_gem_cma_helper.c | 62 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_vm.c | 4 +++
I'll let someone more knowledgeable than me comment on these two files.
drivers/video/fbdev/core/fbmem.c | 8 +++++ include/drm/drm_gem_cma_helper.h | 6 ++++ 6 files changed, 102 insertions(+), 2 deletions(-)
[snip]
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 81b3558..a3cef79 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -343,10 +343,30 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg)
static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma) { +#ifdef CONFIG_MMU return dma_mmap_writecombine(info->device, vma, info->screen_base, info->fix.smem_start, info- fix.smem_len); +#else
return vm_iomap_memory(vma, vma->vm_start, info->fix.smem_len);
+#endif }
+#ifdef HAVE_ARCH_FB_UNMAPPED_AREA
Shouldn't this be #ifndef ? When the symbol is defined the implementation is provided by the architecture.
By the way, given that you provide a generic implementation here, what's the reason some architecture need to implement the function in a special way ? Couldn't we come up with a generic implementation across all architectures ?
+unsigned long get_fb_unmapped_area(struct file *filp,
unsigned long addr, unsigned long len,
unsigned long pgoff, unsigned long flags)
+{
struct fb_info * const info = filp->private_data;
unsigned long fb_size = PAGE_ALIGN(info->fix.smem_len);
if (pgoff > fb_size || len > fb_size - pgoff)
return -EINVAL;
return (unsigned long)info->screen_base + pgoff;
+} +EXPORT_SYMBOL_GPL(get_fb_unmapped_area);
Shouldn't this be defined somewhere in drivers/video/ instead, as the code is fbdev-specific and only used in drivers/video/fbdev/core/fbmem.c ?
maybe I could migrate this code in drivers/video/fbdev/core/fbmem.c and play with HAVE_ARCH_FB_UNMAPPED_AREA and get_fb_unmapped_area to know if the symbol already exist or not. I think that would also fix your previous and next remark because I this case I will not have declare the prototype.
+#endif
static struct fb_ops drm_fbdev_cma_ops = { .owner = THIS_MODULE, DRM_FB_HELPER_DEFAULT_OPS,
[snip]
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 76c1ad9..d6a83bd 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1492,6 +1492,14 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd, return 0; }
+#ifdef HAVE_ARCH_FB_UNMAPPED_AREA +extern unsigned long get_fb_unmapped_area(struct file *filp,
unsigned long addr,
unsigned long len,
unsigned long pgoff,
unsigned long flags);
+#endif
This should come from a header file.
static const struct file_operations fb_fops = { .owner = THIS_MODULE, .read = fb_read, diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h index acd6af8..79e9dbd 100644 --- a/include/drm/drm_gem_cma_helper.h +++ b/include/drm/drm_gem_cma_helper.h @@ -51,6 +51,12 @@ int drm_gem_cma_dumb_map_offset(struct drm_file *file_priv, struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm, size_t size);
+unsigned long drm_gem_cma_get_unmapped_area(struct file *filp,
unsigned long addr,
unsigned long len,
unsigned long pgoff,
unsigned long flags);
extern const struct vm_operations_struct drm_gem_cma_vm_ops;
#ifdef CONFIG_DEBUG_FS
-- Regards,
Laurent Pinchart