From patchwork Wed Nov 9 10:49:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 17759 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 50CEABD16B for ; Wed, 9 Nov 2022 10:49:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DC60D6307E; Wed, 9 Nov 2022 11:49:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1667990986; bh=jPElKgrSeQI8WHz/23Dasw/F9Cj2KvpZPYZUsHs0eUM=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qFb7DXZ1ehJrUeGiy17rkYQq/gkX7IPoIfsBXruk9GMu5VkdX5+5p9Gf+fs4wQGBA peNTn1R03LZSbzPDxlZSIJ9F3L9GGLI4A0cko6iiTt0Wocxr3EJCWrbKfF5CbDoXf9 lGSuv6cVw12UzYQgkj8/nHsGPn3ClzB6zOSzT20q20w3enjehkkZQ2g7E/2usrem9v bsVWoIXpT4b++V2mZCSX3z6RBgiTLRsrU0gec86EeSA+Ze9xjocWhPn8rF2ZA4EMjo UKUE1IUO+DFE9jWnCmPeI+gpLISvCoHlRUDFQRlwmdmk7xVcczOal+r6UnLZMa1BUy gFuOpIENMsGPw== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BF5C61F3F for ; Wed, 9 Nov 2022 11:49:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="e8+N0y7A"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id a11-20020a05600c2d4b00b003cf6f5fd9f1so987630wmg.2 for ; Wed, 09 Nov 2022 02:49:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Zkbneysl50+6H5ecz6pXD+0/peJgnlv9umq9jlDMpQQ=; b=e8+N0y7AMgdLH4IiWJQUKhPMWWkhEeurTq/8Y2RPKGFK1Hhk9KIr2a0eAuC/tJDrT9 6xC3km05mE4VjYXZeKFKlcUk7TMwNmCXycLp+n5SMD0UNMKH8XzwCplvBr0odSap/93B gb7sMIAFLbJzcug6Ttll6Z+Z3dV94gPF9Ms5HaEAIp3W6ODkbeTXGGHfYDEUtVOh146t mQn9A7hwlGgd4jVF0M9/SWHybKRWhB67/ir7Pi+qpJOmx9mKKUW7e44+x1ulH9Yruhxu +PFcSJ6fNRneEE+SeHLIm4p7DstuO0Gvo2KsMCXZGVb09eipvSOSlLqynRb6scXJGz4P 1FKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Zkbneysl50+6H5ecz6pXD+0/peJgnlv9umq9jlDMpQQ=; b=RSx/y9k5hIm6ECgEtMb8UYzmQ4/1mdKkKk9TBsL/5k2mgoIx+cUnSCa7ziEQEC7cNL ufPpJpiVK2lr59RjnusP/R+ZgUJS1TlG14zbe9VZzgYyZY4JHGbf0mmicfYnSrpHJfpr 3Xy9Ya1IN6Mn63QE6Gzqwy/H9gPaJxuWVnNis3JB1oCaQn/V133lUHkQFzCUH3PGetwj OXKDCDmhgs6gnA9CEyyKH98YVkO8SGQw5HT/e4lDYlDMim0ShQc7oX8yYxPkCMOPeRZ8 VDt6uGzCRCyYLDLuNkisx8yMVUOhGSeehXj6a7KIP+REwULCm0KR17U2reOsgi/2uEAr wOhQ== X-Gm-Message-State: ACrzQf296L5dv0XXYaUpsHTM2iUwbbCao+zEhjS6K3jCIwO12ot+yEHo n7RpbyhpeniwT60lQNdUPSNTjMUe037H9g== X-Google-Smtp-Source: AMsMyM7ioJTOsNF3NXfM2IKgbg/wXHH9cB8mqlrcoApi5v9L7t6zGZFWJ9RdZjie0a4mfQ87a0OJaw== X-Received: by 2002:a7b:c30c:0:b0:3c6:f26a:590f with SMTP id k12-20020a7bc30c000000b003c6f26a590fmr40082821wmj.205.1667990984408; Wed, 09 Nov 2022 02:49:44 -0800 (PST) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:e4a2:3070:eea4:e434]) by smtp.gmail.com with ESMTPSA id s25-20020adfa299000000b00236b2804d79sm13238702wra.2.2022.11.09.02.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 02:49:43 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 9 Nov 2022 10:49:40 +0000 Message-Id: <20221109104940.5799-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] Revert "pipeline: raspberrypi: Do not unconditionally free buffers on close" 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: , X-Patchwork-Original-From: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This reverts commit 30d704732badc675f72fe73d14749669cb645c23. It turns out that this commit causes some regressions and is in fact unnecessary because the related commit "libcamera: v4l2_videodevice: Guard against releasing unallocated buffers" (a2bdff6d0b67475492ac7cf9318866b6d89a28fd) fixes the problem completely (if the buffers were never allocated, the video device avoids trying to free them even if the pipeline handler asks). The reason for the regressions is that in this new (broken) scheme we would never call clearBuffers() on all the streams if the internal buffers were never allocated (i.e. buffersAllocated_ is never set). This causes the stream's bufferMap_ list to get longer and longer if there are multiple back-to-back calls to configure, and dev_->importBuffers() will ultimately to fail. So either we need to think more carefully about how to stop the pipeline handler from freeing buffers that it doesn't own, or we just leave it as the other commit resolves the problem on its own. In the interim, simply reverting this commit certainly seems like the best solution. Fixes: 30d704732bad ("pipeline: raspberrypi: Do not unconditionally free buffers on close") Signed-off-by: David Plowman Reviewed-by: Naushir Patuck Acked-by: Kieran Bingham --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 1b599fcc..343f8cb2 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1506,9 +1506,6 @@ void PipelineHandlerRPi::mapBuffers(Camera *camera, const RPi::BufferMap &buffer void RPiCameraData::freeBuffers() { - if (!buffersAllocated_) - return; - if (ipa_) { /* * Copy the buffer ids from the unordered_set to a vector to