From patchwork Thu Feb 7 22:36:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylwester Nawrocki X-Patchwork-Id: 2113631 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id EA9EADFB7B for ; Thu, 7 Feb 2013 22:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1945905Ab3BGWgZ (ORCPT ); Thu, 7 Feb 2013 17:36:25 -0500 Received: from mail-ea0-f171.google.com ([209.85.215.171]:48220 "EHLO mail-ea0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1945900Ab3BGWgX (ORCPT ); Thu, 7 Feb 2013 17:36:23 -0500 Received: by mail-ea0-f171.google.com with SMTP id c13so1404857eaa.2 for ; Thu, 07 Feb 2013 14:36:22 -0800 (PST) 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=4xWeNdy2+PBQqZJZl37yTYSe5dSUeOSpfGdJZFAHi7g=; b=eqbm3smIwy9RcAenQsF3jx0LiEs92nkEUePJlQUp3l7O/PldL4daoijNENad3EPZ6Y l1J12O3n6nryBQKGhKUaL7epcUu3WuwKzJ0ZMoMWV4dg/F57lFDM0TMXGRWv6F2GgXqm 5aycsrdVgheW2HDkNVFGC89+yYL9LJLwVCnvzV9gfjJR2YejOFbzyB5DU9DvuyE3KONe Wq5Rfgi5JdJvQ8kkDtj3R6buG8yZQJn96o71ZP1eYSTK0kP0L2uEUBj5sjEy3171vz1N arMMd4wkrf5BRnjxqC/ZI2JmGbPJyw4s9YRgMtL3GLXUtdE4x/oVx9nnQr+6rNyW+5R5 xiSg== X-Received: by 10.14.4.194 with SMTP id 42mr8600973eej.35.1360276582018; Thu, 07 Feb 2013 14:36:22 -0800 (PST) Received: from localhost.localdomain (093105185086.warszawa.vectranet.pl. [93.105.185.86]) by mx.google.com with ESMTPS id q42sm35087603eem.14.2013.02.07.14.36.20 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 07 Feb 2013 14:36:20 -0800 (PST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: Sylwester Nawrocki Subject: [PATCH RFC] s3c-camif: Fail on insufficient number of allocated buffers Date: Thu, 7 Feb 2013 23:36:12 +0100 Message-Id: <1360276572-10890-1-git-send-email-sylvester.nawrocki@gmail.com> X-Mailer: git-send-email 1.7.4.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Ensure the driver gets always at least its minimum required number of buffers allocated by checking actual number of allocated buffers in vb2_reqbufs(). And free any partially allocated buffer queue with signaling an error to user space. Without this patch applications may wait forever to dequeue a filled buffer, because the hardware didn't even start after VIDIOC_STREAMON, VIDIOC_QBUF calls, due to insufficient number of empty buffers. Reported-by: Alexander Nestorov Signed-off-by: Sylwester Nawrocki --- drivers/media/platform/s3c-camif/camif-capture.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c index a55793c..b8466f3 100644 --- a/drivers/media/platform/s3c-camif/camif-capture.c +++ b/drivers/media/platform/s3c-camif/camif-capture.c @@ -934,12 +934,19 @@ static int s3c_camif_reqbufs(struct file *file, void *priv, vp->owner = NULL; ret = vb2_reqbufs(&vp->vb_queue, rb); - if (!ret) { - vp->reqbufs_count = rb->count; - if (vp->owner == NULL && rb->count > 0) - vp->owner = priv; + if (ret < 0) + return ret; + + if (rb->count && rb->count < CAMIF_REQ_BUFS_MIN) { + rb->count = 0; + vb2_reqbufs(&vp->vb_queue, rb); + ret = -ENOMEM; } + vp->reqbufs_count = rb->count; + if (vp->owner == NULL && rb->count > 0) + vp->owner = priv; + return ret; }