From patchwork Wed Jul 21 09:28:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 13064 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 47427C0109 for ; Wed, 21 Jul 2021 09:28:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8BF0F6027A; Wed, 21 Jul 2021 11:28:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="tWtYmLbP"; dkim-atps=neutral Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 280746027A for ; Wed, 21 Jul 2021 11:28:11 +0200 (CEST) Received: by mail-wr1-x432.google.com with SMTP id c12so1421453wrt.3 for ; Wed, 21 Jul 2021 02:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pxcK8Q1JMJMroEKUBaArncxKI5F80ngrYZR40U/6rfc=; b=tWtYmLbPqcbB+9SqE8J9L94wKKwUXTjFZrXFjAQgEIPUrSXBZxlmrwYWKBp50QrKS3 gIiI14sjl+aRTsjPqtYrLDAK056PwTVqG0+A7nHSKOnCIgK1MSnuihLvONpNTQhFt0bU Og/qmVsswTO5z581xgbdzSS/GvLD7HIc/offB8vlOMATa5q0IpkQuJetNlLX+n83fBXV v3ba09O7oui+8EqT/XxNNF1twiPWsdgN5CuLJ5e3kLisKoQ9aeMV9tuB3DuNZDsvaWW6 YmjDztHoMP1Muk1gbmuzu8CgXEV2i9jyoxHqAcfpqzCXughCSB/vPDxGYmjlk90gk3XR esNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pxcK8Q1JMJMroEKUBaArncxKI5F80ngrYZR40U/6rfc=; b=WD1oEvVxavEMnOGE1JHUgFKWuaM6sd9d5ccTGBDEUd4dIsTfuIQzVhOreEpH0djDic pfd2jD3J49P626eUoHAyXk3AibDjzzUlBouaZpy1cr5iUsBORKaw6NHKxM2sHUwlbxDU H6iZOTO+i8MB4PXtJ0XRYh6uqtwSwuTMtxA/VQX0Dj89RfldHVHk27Y1xV3cK+pU6yAI hw69oquqRD3HUa2eqHq9udgpJTTdZAfKknmuD7ZfQ5WSf8LXXc/GslbCRN9A2TvsYo79 +Olrfr+nuIhmygRMvVPDgnlXtHOSADRfQdto59H8Op1s7R2yZZXBvX43wBpMj1wdwFIP B8AA== X-Gm-Message-State: AOAM531SRW8bYnABXD/M5ITx9FpcO79sde1Zjy1TDIpbC7M8G/69EFRZ MM6E2fsniiw4ovvFAJXZ9g1VXR6KanYoCA== X-Google-Smtp-Source: ABdhPJyvoyFrU5OlGdpJSq/j8L35M/mVXOCayqZf8G1mygi5b6/DpnEDyxLIMLdoKWQO5rw/hGPICA== X-Received: by 2002:adf:e4d1:: with SMTP id v17mr40454816wrm.206.1626859690519; Wed, 21 Jul 2021 02:28:10 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:71d0:d02:dc34:e964]) by smtp.gmail.com with ESMTPSA id p11sm25863286wro.78.2021.07.21.02.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 02:28:10 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Jul 2021 10:28:00 +0100 Message-Id: <20210721092800.1735805-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] pipeline: raspberrypi: Fix a bug when clearing out Request buffers on stop 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 RPiCameraData::clearIncompleteRequests() clears out the request queue during a stop condition, it unconditionally calls completeBuffer() on all buffers in each request. This is wrong, as a buffer could have already been completed as part of the current request, but the request itself may not yet have completed. Fix this by checking if the buffers in the request have been completed before cancelling them. Fixes: d372aaa10ddb ("pipeline: raspberrypi: Simplify RPiCameraData::clearIncompleteRequests()") Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index f821d8fe1b6c..0bab3bedd402 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1520,8 +1520,14 @@ void RPiCameraData::clearIncompleteRequests() for (auto &b : request->buffers()) { FrameBuffer *buffer = b.second; - buffer->cancel(); - pipe_->completeBuffer(request, buffer); + /* + * Has the buffer already been handed back to the + * request? If not, do so now. + */ + if (buffer->request()) { + buffer->cancel(); + pipe_->completeBuffer(request, buffer); + } } pipe_->completeRequest(request);