From patchwork Wed May 1 08:52:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 2507201 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 3B166DF230 for ; Wed, 1 May 2013 08:54:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 20001E6211 for ; Wed, 1 May 2013 01:54:46 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) by gabe.freedesktop.org (Postfix) with ESMTP id 8794BE61B3 for ; Wed, 1 May 2013 01:52:54 -0700 (PDT) Received: by mail-wg0-f48.google.com with SMTP id f11so1168341wgh.15 for ; Wed, 01 May 2013 01:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=QSppWKRCXiVRRZKdhh4L/WkehKidYm/chFXNiD5/hXw=; b=Mb2Y5r72hNeSsjnk1ghWaK7qrZieQ6HOWEIpxBH/Xp7nk7GqSiRmkIeupkib2YuwMq qvoPSSJpkA0BGSTSkfNBV2fTOKlMS+of0udYlP4iSbvwxrIg6dqM6UWRpeHsQ+NrB6tU bBK4rPaNkaag2PCJ0E5t2ZVTxI2rWKf3UT7rXoi68xXhsTS7IspjRH6SN3gVZ/SP6+0C yV0nMe6dCjgHOSxZ9llQSVCE7BmN0N72G1XtwE0Hpj26yYi6jW07UQO5qIdQbaLf2xpi +t67wpWtcKngGOq8OwI3mRKJ6lpT4zhVOERsBPGixlx0SrAesTUb8NCYf5jRvZ+GaHh1 oLRA== X-Received: by 10.194.7.68 with SMTP id h4mr1778920wja.49.1367398373563; Wed, 01 May 2013 01:52:53 -0700 (PDT) Received: from localhost (5ED49945.cm-7-5c.dynamic.ziggo.nl. [94.212.153.69]) by mx.google.com with ESMTPSA id ge7sm30863252wic.0.2013.05.01.01.52.51 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 01 May 2013 01:52:52 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Wed, 01 May 2013 10:52:50 +0200 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/7] drm: add unpin function to prime helpers Date: Wed, 1 May 2013 10:52:38 +0200 Message-Id: <1367398364-28997-1-git-send-email-maarten.lankhorst@canonical.com> X-Mailer: git-send-email 1.8.2.2 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Prevents buffers from being pinned forever. Signed-off-by: Maarten Lankhorst Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_prime.c | 13 +++++++++++-- include/drm/drmP.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 366910d..85bbc52 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -91,10 +91,13 @@ static void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach, static void drm_gem_dmabuf_release(struct dma_buf *dma_buf) { struct drm_gem_object *obj = dma_buf->priv; + struct drm_device *dev = obj->dev; if (obj->export_dma_buf == dma_buf) { /* drop the reference on the export fd holds */ obj->export_dma_buf = NULL; + if (dev->driver->gem_prime_unpin) + dev->driver->gem_prime_unpin(obj); drm_gem_object_unreference_unlocked(obj); } } @@ -184,13 +187,19 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = { struct dma_buf *drm_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags) { + struct dma_buf *buf; + if (dev->driver->gem_prime_pin) { int ret = dev->driver->gem_prime_pin(obj); if (ret) return ERR_PTR(ret); } - return dma_buf_export(obj, &drm_gem_prime_dmabuf_ops, obj->size, - 0600); + buf = dma_buf_export(obj, &drm_gem_prime_dmabuf_ops, obj->size, + 0600); + + if (IS_ERR(buf) && dev->driver->gem_prime_unpin) + dev->driver->gem_prime_unpin(obj); + return buf; } EXPORT_SYMBOL(drm_gem_prime_export); diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 2d94d74..99dc622 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -932,6 +932,7 @@ struct drm_driver { struct dma_buf *dma_buf); /* low-level interface used by drm_gem_prime_{import,export} */ int (*gem_prime_pin)(struct drm_gem_object *obj); + void (*gem_prime_unpin)(struct drm_gem_object *obj); struct sg_table *(*gem_prime_get_sg_table)(struct drm_gem_object *obj); struct drm_gem_object *(*gem_prime_import_sg_table)( struct drm_device *dev, size_t size,