All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCHv2 45/45] drm: omapdrm: add lock for fb pinning
Date: Sat, 06 Jun 2015 07:30:01 +0300	[thread overview]
Message-ID: <3275010.mOn69aKIkg@avalon> (raw)
In-Reply-To: <1433408582-9828-46-git-send-email-tomi.valkeinen@ti.com>

Hi Tomi,

Thank you for the patch.

On Thursday 04 June 2015 12:03:02 Tomi Valkeinen wrote:
> Before atomic modesetting omap_framebuffer_pin() and
> omap_framebuffer_unpin() were always called with modesetting locks
> taken. With atomic modesetting support this is no longer the case, and
> we need locking to protect the pin_count and the paddr, as multiple
> threads may pin the same fb concurrently.
> 
> This patch adds a mutex to struct omap_framebuffer, and uses it in
> omap_framebuffer_pin() and omap_framebuffer_unpin().
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/omapdrm/omap_fb.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c
> b/drivers/gpu/drm/omapdrm/omap_fb.c index e505140a8782..0b967e76df1a 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
> @@ -89,6 +89,8 @@ struct omap_framebuffer {
>  	int pin_count;
>  	const struct format *format;
>  	struct plane planes[4];
> +	/* lock for pinning (pin_count and planes.paddr) */
> +	struct mutex lock;
>  };
> 
>  static int omap_framebuffer_create_handle(struct drm_framebuffer *fb,
> @@ -250,8 +252,11 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
>  	struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
>  	int ret, i, n = drm_format_num_planes(fb->pixel_format);
> 
> +	mutex_lock(&omap_fb->lock);
> +
>  	if (omap_fb->pin_count > 0) {
>  		omap_fb->pin_count++;
> +		mutex_unlock(&omap_fb->lock);
>  		return 0;
>  	}
> 
> @@ -265,6 +270,8 @@ int omap_framebuffer_pin(struct drm_framebuffer *fb)
> 
>  	omap_fb->pin_count++;
> 
> +	mutex_unlock(&omap_fb->lock);
> +
>  	return 0;
> 
>  fail:
> @@ -274,6 +281,8 @@ fail:
>  		plane->paddr = 0;
>  	}
> 
> +	mutex_unlock(&omap_fb->lock);
> +
>  	return ret;
>  }
> 
> @@ -283,10 +292,14 @@ int omap_framebuffer_unpin(struct drm_framebuffer *fb)
> struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
>  	int ret, i, n = drm_format_num_planes(fb->pixel_format);
> 
> +	mutex_lock(&omap_fb->lock);
> +
>  	omap_fb->pin_count--;
> 
> -	if (omap_fb->pin_count > 0)
> +	if (omap_fb->pin_count > 0) {
> +		mutex_unlock(&omap_fb->lock);
>  		return 0;
> +	}
> 
>  	for (i = 0; i < n; i++) {
>  		struct plane *plane = &omap_fb->planes[i];
> @@ -296,9 +309,12 @@ int omap_framebuffer_unpin(struct drm_framebuffer *fb)
>  		plane->paddr = 0;
>  	}
> 
> +	mutex_unlock(&omap_fb->lock);
> +
>  	return 0;
> 
>  fail:
> +	mutex_unlock(&omap_fb->lock);
>  	return ret;
>  }
> 
> @@ -411,6 +427,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct
> drm_device *dev,
> 
>  	fb = &omap_fb->base;
>  	omap_fb->format = format;
> +	mutex_init(&omap_fb->lock);
> 
>  	for (i = 0; i < n; i++) {
>  		struct plane *plane = &omap_fb->planes[i];

-- 
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2015-06-06  6:24 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-04  9:02 [PATCHv2 00/45] Convert omapdrm to the atomic updates API Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 01/45] drm: omapdrm: Store the rotation property in dev->mode_config Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 02/45] drm: omapdrm: Apply settings synchronously Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 03/45] drm: omapdrm: Rename omap_crtc_page_flip_locked to omap_crtc_page_flip Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 04/45] drm: omapdrm: Rename omap_crtc page flip-related fields Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 05/45] drm: omapdrm: Simplify IRQ registration Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 06/45] drm: omapdrm: Cancel pending page flips when closing device Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 07/45] drm: omapdrm: Rework page flip handling Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 08/45] drm: omapdrm: Turn vblank on/off when enabling/disabling CRTC Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 09/45] drm: omapdrm: Fix page flip race with CRTC disable Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 10/45] drm: omapdrm: Clean up #include's Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 11/45] drm: omapdrm: Rename CRTC DSS operations with an omap_crtc_dss_ prefix Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 12/45] drm: omapdrm: Rework CRTC enable/disable for atomic updates Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 13/45] drm: omapdrm: Implement encoder .disable() and .enable() operations Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 14/45] drm: omapdrm: Wire up atomic state object scaffolding Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 15/45] drm: omapdrm: Implement planes atomic operations Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 16/45] drm: omapdrm: Handle primary plane config through atomic plane ops Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 17/45] drm: omapdrm: Switch plane update to atomic helpers Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 18/45] drm: omapdrm: Switch mode config " Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 19/45] drm: omapdrm: Switch connector DPMS " Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 20/45] drm: omapdrm: Replace encoder mode_fixup with atomic_check Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 21/45] drm: omapdrm: Implement asynchronous commit support Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 22/45] drm: omapdrm: Switch page flip to atomic helpers Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 23/45] drm: omapdrm: Drop manual framebuffer pin handling Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 24/45] drm: omapdrm: Switch crtc and plane set_property to atomic helpers Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 25/45] drm: omapdrm: Move plane info and win out of the plane structure Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 26/45] drm: omapdrm: Move crtc info out of the crtc structure Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 27/45] drm: omapdrm: Remove omap_crtc enabled field Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 28/45] drm: omapdrm: Remove omap_plane " Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 29/45] drm: omapdrm: Make the omap_crtc_flush function static Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 30/45] drm: omapdrm: Don't get/put dispc in omap_crtc_flush() Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 31/45] drm: omapdrm: omap_crtc_flush() isn't called with modeset locked Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 32/45] drm: omapdrm: Support unlinking page flip events prematurely Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 33/45] drm: omapdrm: Remove nested PM get/sync when configuring encoders Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 34/45] drm: omapdrm: Simplify DSS power management Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 35/45] drm: omapdrm: Move encoder setup to encoder operations Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 36/45] drm: omapdrm: Don't flush CRTC when enabling or disabling it Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 37/45] drm: omapdrm: Don't setup planes manually from CRTC .enable()/.disable() Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 38/45] drm: omapdrm: omap_plane_setup() cannot fail, use WARN Tomi Valkeinen
2015-06-06  3:14   ` Laurent Pinchart
2015-06-04  9:02 ` [PATCHv2 39/45] drm: omapdrm: inline omap_plane_setup into update/disable Tomi Valkeinen
2015-06-06  3:15   ` Laurent Pinchart
2015-06-04  9:02 ` [PATCHv2 40/45] drm: omapdrm: if omap_plane_atomic_update fails, disable plane Tomi Valkeinen
2015-06-06  3:23   ` Laurent Pinchart
2015-06-04  9:02 ` [PATCHv2 41/45] drm: omapdrm: remove omap_crtc_wait_page_flip Tomi Valkeinen
2015-06-06  4:09   ` Laurent Pinchart
2015-06-08 16:02     ` Tomi Valkeinen
2015-06-04  9:02 ` [PATCHv2 42/45] drm: omapdrm: add omap_atomic_wait_for_gos() Tomi Valkeinen
2015-06-06  4:10   ` Laurent Pinchart
2015-06-08  8:36     ` Tomi Valkeinen
2015-06-04  9:03 ` [PATCHv2 43/45] drm: omapdrm: don't wait in crtc_atomic_flush Tomi Valkeinen
2015-06-06  4:20   ` Laurent Pinchart
2015-06-04  9:03 ` [PATCHv2 44/45] drm: omapdrm: merge omap_crtc_flush and omap_crtc_atomic_flush Tomi Valkeinen
2015-06-06  4:01   ` Laurent Pinchart
2015-06-04  9:03 ` [PATCHv2 45/45] drm: omapdrm: add lock for fb pinning Tomi Valkeinen
2015-06-06  4:30   ` 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=3275010.mOn69aKIkg@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=tomi.valkeinen@ti.com \
    /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.