diff options
Diffstat (limited to 'drivers/gpu/drm/omapdrm/omap_fb.c')
-rw-r--r-- | drivers/gpu/drm/omapdrm/omap_fb.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c index b2c1a29cc12b..51b1219af87f 100644 --- a/drivers/gpu/drm/omapdrm/omap_fb.c +++ b/drivers/gpu/drm/omapdrm/omap_fb.c @@ -17,11 +17,11 @@ * this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "omap_drv.h" -#include "omap_dmm_tiler.h" +#include <drm/drm_crtc.h> +#include <drm/drm_crtc_helper.h> -#include "drm_crtc.h" -#include "drm_crtc_helper.h" +#include "omap_dmm_tiler.h" +#include "omap_drv.h" /* * framebuffer funcs @@ -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,32 +281,33 @@ fail: plane->paddr = 0; } + mutex_unlock(&omap_fb->lock); + return ret; } /* unpin, no longer being scanned out: */ -int omap_framebuffer_unpin(struct drm_framebuffer *fb) +void 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); + int i, n = drm_format_num_planes(fb->pixel_format); + + mutex_lock(&omap_fb->lock); omap_fb->pin_count--; - if (omap_fb->pin_count > 0) - return 0; + if (omap_fb->pin_count > 0) { + mutex_unlock(&omap_fb->lock); + return; + } for (i = 0; i < n; i++) { struct plane *plane = &omap_fb->planes[i]; - ret = omap_gem_put_paddr(plane->bo); - if (ret) - goto fail; + omap_gem_put_paddr(plane->bo); plane->paddr = 0; } - return 0; - -fail: - return ret; + mutex_unlock(&omap_fb->lock); } struct drm_gem_object *omap_framebuffer_bo(struct drm_framebuffer *fb, int p) @@ -411,6 +419,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]; |