[PATCH 4/4] drm: Renesas SH Mobile DRM driver
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Thu May 31 02:42:54 PDT 2012
Hi Sascha,
On Wednesday 30 May 2012 18:40:56 Sascha Hauer wrote:
> On Wed, May 30, 2012 at 02:32:59PM +0200, Laurent Pinchart wrote:
> > The SH Mobile LCD controller (LCDC) DRM driver supports the main
> > graphics plane in RGB and YUV formats, as well as the overlay planes (in
> > alpha-blending mode only).
> >
> > Only flat panel outputs using the parallel interface are supported.
> > Support for SYS panels, HDMI and DSI is currently not implemented.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > ---
>
> [...]
>
> > +int shmob_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
> > +{
> > + struct drm_file *priv = filp->private_data;
> > + struct drm_device *dev = priv->minor->dev;
> > + struct drm_gem_mm *mm = dev->mm_private;
> > + struct shmob_drm_gem_object *sobj;
> > + struct drm_local_map *map;
> > + struct drm_gem_object *obj;
> > + struct drm_hash_item *hash;
> > + pgprot_t prot;
> > + int ret;
> > +
> > + if (drm_device_is_unplugged(dev))
> > + return -ENODEV;
> > +
> > + mutex_lock(&dev->struct_mutex);
> > +
> > + if (drm_ht_find_item(&mm->offset_hash, vma->vm_pgoff, &hash)) {
> > + ret = -EINVAL;
> > + goto out_unlock;
> > + }
> > +
> > + map = drm_hash_entry(hash, struct drm_map_list, hash)->map;
> > + if (!map ||
> > + ((map->flags & _DRM_RESTRICTED) && !capable(CAP_SYS_ADMIN))) {
> > + ret = -EPERM;
> > + goto out_unlock;
> > + }
> > +
> > + /* Check for valid size. */
> > + if (map->size < vma->vm_end - vma->vm_start) {
> > + ret = -EINVAL;
> > + goto out_unlock;
> > + }
> > +
> > + obj = map->handle;
> > + if (!obj->dev->driver->gem_vm_ops) {
> > + ret = -EINVAL;
> > + goto out_unlock;
> > + }
> > +
> > + sobj = to_shmob_gem_object(obj);
> > + prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
> > + ret = remap_pfn_range(vma, vma->vm_start, sobj->dma >> PAGE_SHIFT,
> > + vma->vm_end - vma->vm_start, prot);
> > + if (ret < 0)
> > + goto out_unlock;
> > +
> > + vma->vm_flags |= VM_RESERVED | VM_IO | VM_PFNMAP | VM_DONTEXPAND;
> > + vma->vm_ops = obj->dev->driver->gem_vm_ops;
> > + vma->vm_private_data = obj;
> > + vma->vm_page_prot = prot;
> > +
> > + /* Take a ref for this mapping of the object, so that the fault
> > + * handler can dereference the mmap offset's pointer to the object.
> > + * This reference is cleaned up by the corresponding vm_close
> > + * (which should happen whether the vma was created by this call, or
> > + * by a vm_open due to mremap or partial unmap or whatever).
> > + */
> > + drm_gem_object_reference(obj);
> > +
> > + drm_vm_open_locked(dev, vma);
> > +
> > +out_unlock:
> > + mutex_unlock(&dev->struct_mutex);
> > +
> > + return ret;
> > +}
>
> I just noticed this function is nearly a copy of drm_gem_mmap except for
> the the additional remap_pfn_range here. Would it make sense to turn
> drm_gem_mmap into a wrapper around a drm_gem_mmap_locked, call this one
> from here and add the remap_pfn_range?
>
> If yes, I would do so in my cma gem helper patch.
Seems you've already done so :-) I don't think locking is an issue, but as I
mentioned in my review I don't know with 100% certainty what dev->struct_mutex
covers.
--
Regards,
Laurent Pinchart
More information about the dri-devel
mailing list