From patchwork Tue Mar 11 22:52:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Sheu X-Patchwork-Id: 3814791 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 63401BF540 for ; Tue, 11 Mar 2014 22:52:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B38120260 for ; Tue, 11 Mar 2014 22:52:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 535922025B for ; Tue, 11 Mar 2014 22:52:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755077AbaCKWwY (ORCPT ); Tue, 11 Mar 2014 18:52:24 -0400 Received: from mail-qc0-f202.google.com ([209.85.216.202]:59348 "EHLO mail-qc0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754055AbaCKWwX (ORCPT ); Tue, 11 Mar 2014 18:52:23 -0400 Received: by mail-qc0-f202.google.com with SMTP id m20so1228268qcx.1 for ; Tue, 11 Mar 2014 15:52:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4AqhNXcWq4z+gb/T5mRvRucGWTQWX2HmcMajpJCMvDE=; b=YI4G6zo+hZBHcLheCIWXlXpIa17vDMikxmEHHJGS9iMFKYqvAlXmfivRRKGQ07k4Tb Sa610QbWvVO5Gqf25rg13/Jr5dN4xhbd5xyES5AliwMsxOW0fQulhEpVdcj4acbsxuGc /zyz16adEJIUtysSv4f+pI3ocwmn+wvg2k23qy6Uito5jEYFDlzdaNF+4cNpyHXSxyRo z7WvC9W08nWums4IfpnC0rA6C19hwbzvUeXFBav10vhkfG5f86JckxmysABADBuiRzWR jJw4p5Rce/HhpBN3dWIT2Tt/5mtKx04G73SY56UYbzGvNgjhq2yrMjqT5e5bxmqxkeg7 R9kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4AqhNXcWq4z+gb/T5mRvRucGWTQWX2HmcMajpJCMvDE=; b=j0WG9g+aVwy+GO+JX1+r300fpyX8CKk4Cn6TyppNmK3OomEHTZGWTgh3wWkYWp4LV5 +NM3C/e8pKYFdUI0AjD5yljw4xPs0CJiq4ajA4Hz5XKR1yxMI3sRcUlquE1IBso20i+L 6kl4cJm7AqIbyQ8Lhg4GWGitFgV2ZFnsqOICs7fHxR0G5rAsNRRbcwXY8Unt2hIvzI8j WNBpeWuKDXNjuKEkhQMMpEgGmgk3f+ZG9iYhQY3TYiPkRHvjFAIxOZFd2cK0Uh6OjOaJ MtKqMaLoBcKxWK/H9dmRZpvfkMOTHm54N0bhYrSBO4rPuHqvXoIK529xZEUhE/o1pB5U vRig== X-Gm-Message-State: ALoCoQnMBqhY8Jy+Rsu0PLhbG9gjY4vwM2MHSshb4dA8zXTiHb18CbHBdayZGQ6PnuFx9/4imjebL2gVWrQmW9i4IFj+11Ej5IwdnLKxcCE9mz62aZ8fSn8NK018ISFWcUXv5Q8or9eYvBbjqPVOW4JCzslbTHh1opnNYEd71n+iJYUdwRhiFGzVeH6UoGP082dXpD3xbxS0l8vMRgYU/DR0+qfk8+1AQQ== X-Received: by 10.224.124.5 with SMTP id s5mr17569484qar.1.1394578342340; Tue, 11 Mar 2014 15:52:22 -0700 (PDT) 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 u4si3719394yhb.5.2014.03.11.15.52.22 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Mar 2014 15:52:22 -0700 (PDT) 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 2932031C24B; Tue, 11 Mar 2014 15:52:22 -0700 (PDT) Received: by shortskirt.mtv.corp.google.com (Postfix, from userid 157237) id D98E4C0575; Tue, 11 Mar 2014 15:52:21 -0700 (PDT) From: John Sheu To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com, k.debski@samsung.com, posciak@google.com, arun.m@samsung.com, kgene.kim@samsung.com, John Sheu Subject: [PATCH 1/4] s5p-mfc: fix encoder crash after VIDIOC_STREAMOFF Date: Tue, 11 Mar 2014 15:52:02 -0700 Message-Id: <1394578325-11298-2-git-send-email-sheu@google.com> X-Mailer: git-send-email 1.9.0.279.gdc9e3eb In-Reply-To: <1394578325-11298-1-git-send-email-sheu@google.com> References: <1394578325-11298-1-git-send-email-sheu@google.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=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 VIDIOC_STREAMOFF clears the encoder's destination queue -- routines run from the interrupt handler cannot assume that the queue is non-empty. Signed-off-by: John Sheu --- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c index df83cd15..04236229 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c @@ -772,13 +772,16 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx) if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) { spin_lock_irqsave(&dev->irqlock, flags); - dst_mb = list_entry(ctx->dst_queue.next, - struct s5p_mfc_buf, list); - list_del(&dst_mb->list); - ctx->dst_queue_cnt--; - vb2_set_plane_payload(dst_mb->b, 0, - s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev)); - vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE); + if (!list_empty(&ctx->dst_queue)) { + dst_mb = list_entry(ctx->dst_queue.next, + struct s5p_mfc_buf, list); + list_del(&dst_mb->list); + ctx->dst_queue_cnt--; + vb2_set_plane_payload(dst_mb->b, 0, + s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, + dev)); + vb2_buffer_done(dst_mb->b, VB2_BUF_STATE_DONE); + } spin_unlock_irqrestore(&dev->irqlock, flags); } @@ -883,8 +886,7 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx) mfc_debug(2, "enc src count: %d, enc ref count: %d\n", ctx->src_queue_cnt, ctx->ref_queue_cnt); } - if (strm_size > 0) { - /* at least one more dest. buffers exist always */ + if ((ctx->dst_queue_cnt > 0) && (strm_size > 0)) { mb_entry = list_entry(ctx->dst_queue.next, struct s5p_mfc_buf, list); list_del(&mb_entry->list);