From patchwork Fri Oct 8 10:15:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14072 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 866DBC323E for ; Fri, 8 Oct 2021 10:16:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 07C81691B6; Fri, 8 Oct 2021 12:16:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pO/QA+2/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5963691AB for ; Fri, 8 Oct 2021 12:16:10 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3E1D0581; Fri, 8 Oct 2021 12:16:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1633688170; bh=IH9Tp4ibZLmqS8+yxuES226T9mx9VUt+2MkyCJ8bzks=; h=From:To:Cc:Subject:Date:From; b=pO/QA+2/Yt618GVzArnQA+ayPCm2lifAEKU4x44FBUtdDcIGswNOLRk8skTn3Sp8j /LJ3mUtfLCbUjxmVxqfqNZiWI2uPc4kpT47gFvvbTQ1eNB/hL7Y2mHTRAoAxwLCy+h PtHvOFDsc13nZ1gq9Fu44fiUXiVDj1lQYPepWPks= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 8 Oct 2021 13:15:56 +0300 Message-Id: <20211008101556.22987-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: v4l2_videodevice: Improve debugging when buffer is too small X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When a dequeued buffer is too small, the condition is logged and an error is returned. The logged message doesn't provide any information about the sizes, making debugging more difficult. Improve it by logging both the bytesused value and the length of each plane. Signed-off-by: Laurent Pinchart Tested-by: Eugen Hristev Reviewed-by: Kieran Bingham Reviewed-by: Kieran Bingham --- Compile-tested only. Eugen, could you give it a try to debug the problem you're facing ? --- src/libcamera/v4l2_videodevice.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) base-commit: 962df634bd0afe12e6f38464f5e602cf1460c430 diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index ba5f88cd41ed..bd74103de7af 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1713,19 +1713,25 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() unsigned int bytesused = multiPlanar ? planes[0].bytesused : buf.bytesused; + unsigned int remaining = bytesused; for (auto [i, plane] : utils::enumerate(buffer->planes())) { - if (!bytesused) { + if (!remaining) { LOG(V4L2, Error) - << "Dequeued buffer is too small"; + << "Dequeued buffer (" << bytesused + << " bytes) too small for plane lengths " + << utils::join(buffer->planes(), "/", + [](const FrameBuffer::Plane &p){ + return p.length; + }); metadata.status = FrameMetadata::FrameError; return buffer; } metadata.planes()[i].bytesused = - std::min(plane.length, bytesused); - bytesused -= metadata.planes()[i].bytesused; + std::min(plane.length, remaining); + remaining -= metadata.planes()[i].bytesused; } } else if (multiPlanar) { /*