From patchwork Thu Feb 7 00:03:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Sheu X-Patchwork-Id: 2109061 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B157E3FDF1 for ; Thu, 7 Feb 2013 00:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758568Ab3BGAJm (ORCPT ); Wed, 6 Feb 2013 19:09:42 -0500 Received: from mail-ia0-f201.google.com ([209.85.210.201]:61363 "EHLO mail-ia0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758099Ab3BGAJm (ORCPT ); Wed, 6 Feb 2013 19:09:42 -0500 X-Greylist: delayed 356 seconds by postgrey-1.27 at vger.kernel.org; Wed, 06 Feb 2013 19:09:42 EST Received: by mail-ia0-f201.google.com with SMTP id t4so388505iag.4 for ; Wed, 06 Feb 2013 16:09:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=T93AEd8R+NQYWgVPo+srFFVQPRiIFnWZI1DYpLxZdCg=; b=Uw12ODF6drw+9anqPnMF1J9EgNd7ZZs4gUjCQkpWFA4JuWA07rLn/hchzmnnD694VK kIGlerBDKrOiuKuHMnkcPOB1Bg9S+dcMGsDlj5c7gh3cFlXbARbxf965WwQVteaSQhpg MRCMtIgi+tlFEa3Pi7Qsm+68emTYMQ5SYAFIIuoJ8shkoYQc/jIpdoL01zE359TJuzbB IT+oxDP7bCnyG30+aazPgpNCnsmh3/WAmC67u8g9vLGv8e5EOV7rHsk7vvE+4nVsIP2H V1Z9YYH8wjE6AIJ4rc+tOKQ3e4ifsYRT3uakwyKtFZXeAwZD3HzAyR/PWOX/C3ieSOb2 skEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=T93AEd8R+NQYWgVPo+srFFVQPRiIFnWZI1DYpLxZdCg=; b=B8Of/l5yFgMeBenk2VcsdOEZCqpVLLbibEALsObbwNsvb1XlqG0Jyck52s/p/gczgp URg5AzI2iyGfD5+pjmFhSomQA4UH+IjJK9GeSUd4b18GOjLx8i1MSwHKt9mKcZ4zT+Bf V7buNO5JdygmUOtlKIEnKBqSp0vWiot04MTLv7NlYwLTusgk4xsOK6yq5ffyJXnWgB76 GF5bnHfuoB2e6IXjHoiAhjyFrnS2Fk5G5iFC5tZpvfVBMSw/xjvtSKT0JPZA0sms+4Cy kjpvAZp82Af2O5GktXxZhZtRJr38T4sVO0aD4nZtx7g1vHHSx9qk/fkZzvBGn2YwBqmN /qrA== X-Received: by 10.42.110.15 with SMTP id n15mr23048973icp.11.1360195425891; Wed, 06 Feb 2013 16:03:45 -0800 (PST) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id d5si335902iga.1.2013.02.06.16.03.45 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Wed, 06 Feb 2013 16:03:45 -0800 (PST) Received: from shortskirt.mtv.corp.google.com (shortskirt.mtv.corp.google.com [172.22.70.255]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 5858131C15E; Wed, 6 Feb 2013 16:03:45 -0800 (PST) Received: by shortskirt.mtv.corp.google.com (Postfix, from userid 157237) id 09A19C0651; Wed, 6 Feb 2013 16:03:44 -0800 (PST) From: John Sheu To: linux-media@vger.kernel.org Cc: John Sheu , John Sheu Subject: [PATCH 2/3] [media]: v4l2-mem2mem: drop rdy_queue on STREAMOFF Date: Wed, 6 Feb 2013 16:03:01 -0800 Message-Id: <1360195382-32317-2-git-send-email-sheu@google.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1360195382-32317-1-git-send-email-sheu@google.com> References: <1360195382-32317-1-git-send-email-sheu@google.com> X-Gm-Message-State: ALoCoQkjC+PwnnNBE4T/WYXCjs8IhiQYE22/mbsjN7TnajTlhBV6ib5XLp/TeGwNkmMjRandHGhKMVhA+1yZCGZDH6jlq+ItITpl40gGm8uJsnLGbswa0Jclon+vMock3FHkFPIciuq9ujiXCf/bKPgkiaBe9ih2GRvetBSDqwpdkvzLIrHM28XlZOAQYKOxqEO2R8pLA4LJlIysZtKipYklKS0HvznEDA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: John Sheu When a v4l2-mem2mem context gets a STREAMOFF call on either its CAPTURE or OUTPUT queues, we should: * Drop the corresponding rdy_queue, since a subsequent STREAMON expects an empty queue. * Deschedule the context, as it now has at least one empty queue and cannot run. Signed-off-by: John Sheu Acked-by: Pawel Osciak --- drivers/media/v4l2-core/v4l2-mem2mem.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index c52a2c5..c5c9d24 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -408,10 +408,35 @@ EXPORT_SYMBOL_GPL(v4l2_m2m_streamon); int v4l2_m2m_streamoff(struct file *file, struct v4l2_m2m_ctx *m2m_ctx, enum v4l2_buf_type type) { - struct vb2_queue *vq; + struct v4l2_m2m_dev *m2m_dev; + struct v4l2_m2m_queue_ctx *q_ctx; + unsigned long flags_job, flags; + int ret; - vq = v4l2_m2m_get_vq(m2m_ctx, type); - return vb2_streamoff(vq, type); + q_ctx = get_queue_ctx(m2m_ctx, type); + ret = vb2_streamoff(&q_ctx->q, type); + if (ret) + return ret; + + m2m_dev = m2m_ctx->m2m_dev; + spin_lock_irqsave(&m2m_dev->job_spinlock, flags_job); + /* We should not be scheduled anymore, since we're dropping a queue. */ + INIT_LIST_HEAD(&m2m_ctx->queue); + m2m_ctx->job_flags = 0; + + spin_lock_irqsave(&q_ctx->rdy_spinlock, flags); + /* Drop queue, since streamoff returns device to the same state as after + * calling reqbufs. */ + INIT_LIST_HEAD(&q_ctx->rdy_queue); + spin_unlock_irqrestore(&q_ctx->rdy_spinlock, flags); + + if (m2m_dev->curr_ctx == m2m_ctx) { + m2m_dev->curr_ctx = NULL; + wake_up(&m2m_ctx->finished); + } + spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job); + + return 0; } EXPORT_SYMBOL_GPL(v4l2_m2m_streamoff);