All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/4] drm: Renesas SH Mobile DRM driver
Date: Thu, 31 May 2012 11:42:54 +0200	[thread overview]
Message-ID: <8808172.vy8FdYeAoo@avalon> (raw)
In-Reply-To: <20120530164056.GM30400@pengutronix.de>

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@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

      reply	other threads:[~2012-05-31  9:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-30 12:32 [PATCH 0/4] Renesas SH Mobile DRM driver Laurent Pinchart
2012-05-30 12:32 ` [PATCH 1/4] fbdev: sh_mobile_meram: Add MERAM operations wrappers Laurent Pinchart
2012-05-30 12:32 ` [PATCH 2/4] fbdev: sh_mobile_lcdc: Use " Laurent Pinchart
2012-05-30 12:32 ` [PATCH 3/4] drm: Add NV24 and NV42 pixel formats Laurent Pinchart
2012-05-30 13:09   ` Ville Syrjälä
2012-05-30 13:20     ` Laurent Pinchart
2012-05-30 14:05       ` Ville Syrjälä
2012-05-30 14:09         ` Laurent Pinchart
2012-05-30 12:32 ` [PATCH 4/4] drm: Renesas SH Mobile DRM driver Laurent Pinchart
2012-05-30 13:43   ` Sascha Hauer
2012-05-30 13:48     ` Lars-Peter Clausen
2012-05-30 14:12     ` Laurent Pinchart
2012-05-30 14:16   ` Ville Syrjälä
2012-06-27 12:40     ` Laurent Pinchart
2012-05-30 14:45   ` Lars-Peter Clausen
2012-05-30 15:10     ` Lars-Peter Clausen
2012-06-27 12:40       ` Laurent Pinchart
2012-06-27 20:06         ` Lars-Peter Clausen
2012-06-27 20:27           ` Laurent Pinchart
2012-06-27 20:56             ` Lars-Peter Clausen
2012-05-30 16:40   ` Sascha Hauer
2012-05-31  9:42     ` Laurent Pinchart [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8808172.vy8FdYeAoo@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.