From patchwork Fri Sep 20 06:26:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaik Ameer Basha X-Patchwork-Id: 2915241 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A41439F1F1 for ; Fri, 20 Sep 2013 06:23:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADDF0202C1 for ; Fri, 20 Sep 2013 06:23:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5170202C8 for ; Fri, 20 Sep 2013 06:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754085Ab3ITGXS (ORCPT ); Fri, 20 Sep 2013 02:23:18 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:52576 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754051Ab3ITGXR (ORCPT ); Fri, 20 Sep 2013 02:23:17 -0400 Received: by mail-pd0-f180.google.com with SMTP id y10so8021pdj.25 for ; Thu, 19 Sep 2013 23:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=WgO0Zzw8Q2b772BNDDxrw1z3lOQNV5di+3jggROx9c0=; b=LVhmJcTa1OgR//kWJveB41QcdS52O2565cZs9Wnjoblo31QMVu4SBzPIPjrBTI4SEp am95uEF0zWjJ5dy9iAEfzGxewSotkpx52vP9lpX+/STUsR8CdSvzGnaQoh+R/Kb8kKb2 2kKnS9P+WgqlxZGLYU+XRC0/JdKyYjyuPsZXGGMGnHiMt1QFAy/YSK0eCiHZ6Zxw+3Wm VX55yXpz9vVDzZ1oEkhgV8n+3NvYtdCwiDCm3ML9NRePVnlP67cNrr9dS5CsioLV3qj/ xEsupecE4qkgZigen7m6aof41HZxivpWYgsut2Z7Iy5YmMsOQUJ7dK23E7E4GwUPLZY8 kXqg== X-Received: by 10.66.152.102 with SMTP id ux6mr6827093pab.79.1379658196788; Thu, 19 Sep 2013 23:23:16 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPSA id so2sm9793669pbc.5.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Sep 2013 23:23:16 -0700 (PDT) From: Shaik Ameer Basha To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: s.nawrocki@samsung.com, posciak@google.com, shaik.ameer@samsung.com Subject: [PATCH] [media] v4l2-mem2mem: Don't schedule the context if abort job is called Date: Fri, 20 Sep 2013 11:56:18 +0530 Message-Id: <1379658378-31163-2-git-send-email-shaik.ameer@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1379658378-31163-1-git-send-email-shaik.ameer@samsung.com> References: <1379658378-31163-1-git-send-email-shaik.ameer@samsung.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the current context is running, 1] If release is called, it waits until the job is finished. 2] As soon as the job is finished, v4l2_mem_ctx_release()tries to release the vb2 queues. 3] But if the current context can be scheduled in the v4l2_m2m_job_finish() it schedules the context and tries to call device_run(). 4] As the release() and device_run() sequence can't be predicted sometimes device_run() may get empty vb2 buffers. This patch adds the ABORT state to the job_flags. Once the job_abort() or release() is called on the context, the same context will not be scheduled in the v4l2_m2m_job_finish(). Signed-off-by: Shaik Ameer Basha --- drivers/media/v4l2-core/v4l2-mem2mem.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c index 7c43712..d5741be 100644 --- a/drivers/media/v4l2-core/v4l2-mem2mem.c +++ b/drivers/media/v4l2-core/v4l2-mem2mem.c @@ -41,6 +41,8 @@ module_param(debug, bool, 0644); #define TRANS_QUEUED (1 << 0) /* Instance is currently running in hardware */ #define TRANS_RUNNING (1 << 1) +/* Instance is currently aborting */ +#define TRANS_ABORT (1 << 2) /* Offset base for buffers on the destination queue - used to distinguish @@ -221,6 +223,14 @@ static void v4l2_m2m_try_schedule(struct v4l2_m2m_ctx *m2m_ctx) } spin_lock_irqsave(&m2m_dev->job_spinlock, flags_job); + + /* If the context is aborted then don't schedule it */ + if (m2m_ctx->job_flags & TRANS_ABORT) { + spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job); + dprintk("Aborted context\n"); + return; + } + if (m2m_ctx->job_flags & TRANS_QUEUED) { spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags_job); dprintk("On job queue already\n"); @@ -280,6 +290,8 @@ static void v4l2_m2m_cancel_job(struct v4l2_m2m_ctx *m2m_ctx) m2m_dev = m2m_ctx->m2m_dev; spin_lock_irqsave(&m2m_dev->job_spinlock, flags); + + m2m_ctx->job_flags |= TRANS_ABORT; if (m2m_ctx->job_flags & TRANS_RUNNING) { spin_unlock_irqrestore(&m2m_dev->job_spinlock, flags); m2m_dev->m2m_ops->job_abort(m2m_ctx->priv);