From patchwork Wed Jun 20 06:12:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dima Zavin X-Patchwork-Id: 9487 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3C3C123EE3 for ; Wed, 20 Jun 2012 11:44:38 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id DF488A182CE for ; Wed, 20 Jun 2012 11:44:37 +0000 (UTC) Received: by ggnf1 with SMTP id f1so5983194ggn.11 for ; Wed, 20 Jun 2012 04:44:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:date:from:to:message-id:references:mime-version :content-disposition:in-reply-to:user-agent:x-mailman-approved-at:cc :subject:x-beenthere:x-mailman-version:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :content-type:content-transfer-encoding:sender:errors-to :x-gm-message-state; bh=Co/nDL7q6NfKjiKz/7/2FrCwgEH8RIIaAhoBEpXnLyE=; b=GQvF8KXHI6C6f/S0Sw8dT5MVWU5PbJxQeTFFBAQGmrMmt3aIEqifpsSZVMPiJdI5Tn rXlAoEExo/C0J+kdX5wM4ALKh6WoGdy8+to8O8mNh06HN8wEQa8IEPQtpMRHyRHNgpco pn8zS1tW4hYlqxzdF0/fU2Zai/i7mJKFi9ziaAVNVfsspCLeSILaNAVXBUMXC+hZ5swJ sv99R4J42JlOwyoqqwOC6UdftY59eAqPGtQtudpqTIpzb7mJIhn/Q4R9KvXH0ztAs3HG 22/nA9D3dsaC/olME3zFHs5uMlfX9hceNpbGki9ctBpFgvghZd+HlbIeCdh6SNTWYbGo bMyA== Received: by 10.50.46.232 with SMTP id y8mr4103220igm.57.1340192677102; Wed, 20 Jun 2012 04:44:37 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp175391ibb; Wed, 20 Jun 2012 04:44:35 -0700 (PDT) Received: by 10.204.157.144 with SMTP id b16mr9974387bkx.12.1340192673260; Wed, 20 Jun 2012 04:44:33 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id gc3si17767877bkc.140.2012.06.20.04.44.31; Wed, 20 Jun 2012 04:44:33 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@google.com Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1ShJKm-0000I5-0y; Wed, 20 Jun 2012 11:44:28 +0000 Received: from mail-yw0-f74.google.com ([209.85.213.74]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1ShE9K-0004dk-9a for linaro-mm-sig@lists.linaro.org; Wed, 20 Jun 2012 06:12:18 +0000 Received: by yhgm50 with SMTP id m50so731907yhg.1 for ; Tue, 19 Jun 2012 23:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=SNL2e8kSgleM5+pr9WH4oIcgC9A9Ks0uA6JkxF4S7RQ=; b=nU0U3nEcGC8n25TXV4wy+XJcz0rJMNBhAOseOkQNiJ6nydilOwLVuDnzeiy88vahU1 FfwX04pdl4P/2d5JYrxnFfUyYHLUaKfODVX3pLeuHmR4dnyPGkV/3S/MlSWQeotJ3dgP 6C7D4/j9InFD4SvOOghAhYXwiErSYK6Djlmmrt/Y9kpiBa0r1/Us3cf+fDhNmBNguaM+ FJr5t6Wj/kcw+4kF0KToIkmWdo/v9TEGQCPxFBSVmsTvR0+PRvZT6lA9IKNICvgJXdyl lPtz876X7rq6+L9yuIc6I10JAHGG+gAdVzdTnYImRKJDpu4Qa68qv9NadKat1M4dnfcb s9qQ== Received: by 10.101.175.34 with SMTP id c34mr11720034anp.13.1340172737362; Tue, 19 Jun 2012 23:12:17 -0700 (PDT) Received: by 10.101.175.34 with SMTP id c34mr11720012anp.13.1340172737187; Tue, 19 Jun 2012 23:12:17 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id z27si16140691yhn.2.2012.06.19.23.12.17 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 19 Jun 2012 23:12:17 -0700 (PDT) Received: from dzavin.mtv.corp.google.com (dzavin.mtv.corp.google.com [172.18.104.77]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 17A431E0043; Tue, 19 Jun 2012 23:12:17 -0700 (PDT) Received: by dzavin.mtv.corp.google.com (Postfix, from userid 17275) id AD5172A0C40; Tue, 19 Jun 2012 23:12:16 -0700 (PDT) Date: Tue, 19 Jun 2012 23:12:16 -0700 From: Dima Zavin To: Tomasz Stanislawski Message-ID: <20120620061216.GA19245@google.com> References: <1339681069-8483-1-git-send-email-t.stanislaws@samsung.com> <1339681069-8483-4-git-send-email-t.stanislaws@samsung.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1339681069-8483-4-git-send-email-t.stanislaws@samsung.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Mailman-Approved-At: Wed, 20 Jun 2012 11:44:27 +0000 Cc: pawel@osciak.com, sumit.semwal@ti.com, mchehab@redhat.com, robdclark@gmail.com, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com, airlied@redhat.com, remi@remlab.net, linux-media@vger.kernel.org, g.liakhovetski@gmx.de Subject: Re: [Linaro-mm-sig] [PATCHv7 03/15] v4l: vb2: add support for shared buffer (dma_buf) X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQk+Tsn3czx7qZIclCsMQOPXHrwRGHLN2vMWqh2MvvbGJwGJbx4hIvkVv8YPcaGbuLuvnXLf Tomasz, I've encountered an issue with this patch when userspace does several stream_on/stream_off cycles. When the user tries to qbuf a buffer after doing stream_off, we trigger the "dmabuf already pinned" warning since we didn't unmap the buffer as dqbuf was never called. The below patch adds calls to unmap in queue_cancel, but my feeling is that we probably should be calling detach too (i.e. put_dmabuf). Thoughts? --Dima Subject: [PATCH] v4l: vb2: unmap dmabufs on STREAM_OFF event Currently, if the user issues a STREAM_OFF request and then tries to re-enqueue buffers, it will trigger a warning in the vb2 allocators as the buffer would still be mapped from before STREAM_OFF was called. The current expectation is that buffers will be unmapped in dqbuf, but that will never be called on the mapped buffers after a STREAM_OFF event. Cc: Sumit Semwal Cc: Tomasz Stanislawski Signed-off-by: Dima Zavin --- drivers/media/video/videobuf2-core.c | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index b431dc6..e2a8f12 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -1592,8 +1592,26 @@ static void __vb2_queue_cancel(struct vb2_queue *q) /* * Reinitialize all buffers for next use. */ - for (i = 0; i < q->num_buffers; ++i) - q->bufs[i]->state = VB2_BUF_STATE_DEQUEUED; + for (i = 0; i < q->num_buffers; ++i) { + struct vb2_buffer *vb = q->bufs[i]; + int plane; + + vb->state = VB2_BUF_STATE_DEQUEUED; + + if (q->memory != V4L2_MEMORY_DMABUF) + continue; + + for (plane = 0; plane < vb->num_planes; ++plane) { + struct vb2_plane *p = &vb->planes[plane]; + + if (!p->mem_priv) + continue; + if (p->dbuf_mapped) { + call_memop(q, unmap_dmabuf, p->mem_priv); + p->dbuf_mapped = 0; + } + } + } } /**