[{"id":39005,"web_url":"https://patchwork.libcamera.org/comment/39005/","msgid":"<178059838285.1119811.5500173666150259611@ping.linuxembedded.co.uk>","date":"2026-06-04T18:39:42","subject":"Re: [RFC PATCH v3 04/17] libcamera: software_isp: Handle\n\tqueueBuffers failure","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Milan Zamazal (2026-06-04 10:50:47)\n> Currently, if a call to queueBuffers fails, the error is ignored.  Which\n> means buffers are not returned back, as would be the case at the end of\n> normal processing.  Let's cancel the request, which also returns the\n> output buffers.  The input buffer is returned as well in case of raw\n> streams and must be returned manually in case of non-raw streams.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 28 +++++++++++++++++++-----\n>  1 file changed, 23 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index c6fe12d65..93899699e 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -955,16 +955,34 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\n>                         return;\n>                 }\n>  \n> -               if (converter_)\n> -                       converter_->queueBuffers(buffer, conversionQueue_.front().outputs);\n> -               else\n> +               int ret;\n> +               if (converter_) {\n> +                       ret = converter_->queueBuffers(buffer, conversionQueue_.front().outputs);\n> +               } else {\n>                         /*\n>                          * request->sequence() cannot be retrieved from `buffer' inside\n>                          * queueBuffers because unique_ptr's make buffer->request() invalid\n>                          * already here.\n>                          */\n> -                       swIsp_->queueBuffers(request->sequence(), buffer,\n> -                                            conversionQueue_.front().outputs);\n> +                       ret = swIsp_->queueBuffers(request->sequence(), buffer,\n> +                                                  conversionQueue_.front().outputs);\n> +               }\n> +\n> +               if (ret < 0) {\n> +                       LOG(SimplePipeline, Error)\n> +                               << \"Failed to queue buffers for conversion: \"\n> +                               << strerror(-ret);\n> +                       /*\n> +                        * The buffers were rejected before starting any processing, so the\n> +                        * output buffers will not be returned via the normal done\n> +                        * signals. Cancel the request; this handles the output buffers and\n> +                        * also the input buffer if it's a raw stream buffer. For non-raw\n> +                        * streams, return the input buffer to the video device manually.\n> +                        */\n\nThis feels a bit awkward, I wonder if we could do better here (globally?\nnot just in simple I think unless this is due to something specific to\nsimple?)\n\n\n> +                       pipe->cancelRequest(request);\n\nIs there any difference calling request->_d()->cancel()?\n\nAha, I see, we have to call cancel on the pipeline handler to complete\nit back to the application.\n\nI'm curious why this is only called by simple and virtual... \n\nSomething seems fishy here ... ? \n\n\n> +                       if (!rawStream_)\n> +                               video_->queueBuffer(buffer);\n> +               }\n>  \n>                 conversionQueue_.pop();\n>                 return;\n> -- \n> 2.54.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D6CCCC324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Jun 2026 18:39:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E39576344D;\n\tThu,  4 Jun 2026 20:39:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 00CAD62DC4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jun 2026 20:39:45 +0200 (CEST)","from monstersaurus.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0503A13D7;\n\tThu,  4 Jun 2026 20:39:20 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"AFntE1OB\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1780598361;\n\tbh=lgEJ1gdUjDFKN01d22D+mcxO+9ygdQqTmwnBA9QRTPA=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=AFntE1OBcuYuji0a9oNIGM/FmWOBESkYzysBQLMcrt2H3fSsHo64WpL2ELDQy5S4F\n\tRwmaRLNVKuqXpiCqTsy2SYvxZhh9kstyMkeA1IEaZgqI+P3NEBuETMlWMDFqmvC61s\n\tMvN3zCzQNUUzqsmEAJ5gcVNFnjV+SRFDdA5kg3OE=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260604095105.68798-6-mzamazal@redhat.com>","References":"<20260604095105.68798-1-mzamazal@redhat.com>\n\t<20260604095105.68798-6-mzamazal@redhat.com>","Subject":"Re: [RFC PATCH v3 04/17] libcamera: software_isp: Handle\n\tqueueBuffers failure","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>, =?utf-8?b?QmFybmFiw6FzIFDFkWN6?=\n\t=?utf-8?q?e?= <barnabas.pocze@ideasonboard.com>,\n\tjohannes.goede@oss.qualcomm.com","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Thu, 04 Jun 2026 19:39:42 +0100","Message-ID":"<178059838285.1119811.5500173666150259611@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":39011,"web_url":"https://patchwork.libcamera.org/comment/39011/","msgid":"<85se6xxffg.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-06-08T14:41:39","subject":"Re: [RFC PATCH v3 04/17] libcamera: software_isp: Handle\n\tqueueBuffers failure","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Kieran,\n\nthank you for review.\n\nKieran Bingham <kieran.bingham@ideasonboard.com> writes:\n\n> Quoting Milan Zamazal (2026-06-04 10:50:47)\n>> Currently, if a call to queueBuffers fails, the error is ignored.  Which\n>> means buffers are not returned back, as would be the case at the end of\n>\n>> normal processing.  Let's cancel the request, which also returns the\n>> output buffers.  The input buffer is returned as well in case of raw\n>> streams and must be returned manually in case of non-raw streams.\n>> \n>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>> ---\n>>  src/libcamera/pipeline/simple/simple.cpp | 28 +++++++++++++++++++-----\n>>  1 file changed, 23 insertions(+), 5 deletions(-)\n>> \n>> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n>> index c6fe12d65..93899699e 100644\n>> --- a/src/libcamera/pipeline/simple/simple.cpp\n>> +++ b/src/libcamera/pipeline/simple/simple.cpp\n>> @@ -955,16 +955,34 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\n>>                         return;\n>>                 }\n>>  \n>> -               if (converter_)\n>> -                       converter_->queueBuffers(buffer, conversionQueue_.front().outputs);\n>> -               else\n>> +               int ret;\n>> +               if (converter_) {\n>> +                       ret = converter_->queueBuffers(buffer, conversionQueue_.front().outputs);\n>> +               } else {\n>>                         /*\n>>                          * request->sequence() cannot be retrieved from `buffer' inside\n>>                          * queueBuffers because unique_ptr's make buffer->request() invalid\n>>                          * already here.\n>>                          */\n>> -                       swIsp_->queueBuffers(request->sequence(), buffer,\n>> -                                            conversionQueue_.front().outputs);\n>> +                       ret = swIsp_->queueBuffers(request->sequence(), buffer,\n>> +                                                  conversionQueue_.front().outputs);\n>> +               }\n>> +\n>> +               if (ret < 0) {\n>> +                       LOG(SimplePipeline, Error)\n>> +                               << \"Failed to queue buffers for conversion: \"\n>> +                               << strerror(-ret);\n>> +                       /*\n>> +                        * The buffers were rejected before starting any processing, so the\n>> +                        * output buffers will not be returned via the normal done\n>> +                        * signals. Cancel the request; this handles the output buffers and\n>> +                        * also the input buffer if it's a raw stream buffer. For non-raw\n>> +                        * streams, return the input buffer to the video device manually.\n>> +                        */\n>\n> This feels a bit awkward, \n\nYes.\n\n> I wonder if we could do better here (globally?  not just in simple I\n> think unless this is due to something specific to simple?)\n\nA tricky question, I'm afraid I don't have an answer.\n\n>> +                       pipe->cancelRequest(request);\n>\n> Is there any difference calling request->_d()->cancel()?\n> \n> Aha, I see, we have to call cancel on the pipeline handler to complete\n> it back to the application.\n>\n> I'm curious why this is only called by simple and virtual... \n>\n> Something seems fishy here ... ? \n\nAnother tricky question...\n\n>> +                       if (!rawStream_)\n>> +                               video_->queueBuffer(buffer);\n>> +               }\n>>  \n>>                 conversionQueue_.pop();\n>>                 return;\n>> -- \n>> 2.54.0\n>>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 08C3FC328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Jun 2026 14:41:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E0C061E77;\n\tMon,  8 Jun 2026 16:41:48 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3664561E74\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Jun 2026 16:41:47 +0200 (CEST)","from mail-wm1-f70.google.com (mail-wm1-f70.google.com\n\t[209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-225-_37walR-PtuX8yjD4IIU9A-1; Mon, 08 Jun 2026 10:41:42 -0400","by mail-wm1-f70.google.com with SMTP id\n\t5b1f17b1804b1-490b37e1f48so36780245e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 08 Jun 2026 07:41:42 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-4.net.vodafone.cz. [77.48.47.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-4601f2dcb13sm52887914f8f.2.2026.06.08.07.41.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 08 Jun 2026 07:41:40 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"HyAkrFMp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1780929705;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=n4itpo1PJfLNu/2NySjsme9RRJ/MrA7YICm1SEx4JvM=;\n\tb=HyAkrFMp13CFv6YpFzyUGzoPBu4G/B7cm8ElAdHI8/DaJ6ZioVmfaGMsep/HpRSOaAx1Oc\n\tQ3jfUp4vlV8H7qSQ4LaGU4czqvamHmLJaKYtioMnz8/bn/CpbPFFFrpjYdN1T+7jfQRQtE\n\tZcGMDfLrlT2pX8kdJ75U/xRx+2hJzqU=","X-MC-Unique":"_37walR-PtuX8yjD4IIU9A-1","X-Mimecast-MFC-AGG-ID":"_37walR-PtuX8yjD4IIU9A_1780929701","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1780929701; x=1781534501;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=n4itpo1PJfLNu/2NySjsme9RRJ/MrA7YICm1SEx4JvM=;\n\tb=gQpD1U0mkEtBo9NlYqFFZ3t21qQE0EqqMpaFbFCP7nQFxuyZZaq2K9+n48FZOSrbs9\n\tqmo19x4CS2BxxNLPdhKDkgB0ZKiA7/N19xyOw9uePB9Gj9GSQHzoBng+Ups1dnLILx8X\n\t13/rBY2KE0Zug5ntqCo6xUX1D2ZdCCo4lb7SOM/4GA1+VbjO9WkDFcJ5H6ny0J1t/3MZ\n\t8j3advcACzkE2au6xn3/QxQffbvowCn1GbE6drbgn1hxYve6hdFPSsDgLhwl5ixYo8O9\n\t5DYV18ogYZoMVc3RH1mKnKts6oGcg92vNZNGOOyBSvwM4B0VkW/i2ISxUl54tAnPrYdo\n\tHy/g==","X-Gm-Message-State":"AOJu0YwR4boNcnaKaGPpx8TlzQxDR8vQYt3JbO5WDdShfcP86bgAB+nR\n\tZfaCxa5oQmOZ4OyIjVfde6QbyCFsuAXVJvaAYcq7e9XTcY/fyEHBwFYQYBC/VGObv8xKVzLGFMH\n\th42YBcEBlGGiMaDq6q/VwuC5QX7cqlMqq9uB2AUA/WsaqTpbjQf/U3Qhus8zRlOAFehrMKxLcDf\n\tUI8JtVpPY=","X-Gm-Gg":"Acq92OG0NBNXspnNYp2qiarydve2s3M8jhtELWOX67OSMFdzMGSoVirHxKSYv33wQ+Z\n\tv3DA6Fu6DVf24S2kJt0npYrfRrysorh/jQPvd8WMa4+wkNKMwfa0QTREwFLFg7VVP8Wnc4SPJFe\n\tzB+Kd1aDbpsCiPhHi68pSXs32iUQFdQ88DWHtUqaGfCM+8h5n74Ic3XMAJS26Mhm3den5BZjuRV\n\twMqs7/ZALTp+DVCS3m2o6VCe8ddPudtvB98177CTBA0yjYTMgglIeT46dwjx3bTYZGT9Kf6Eunu\n\tQA9rXx7ICet7EPk7EVMF6a2Xc5w11AGoqUr+v+bYStliKMTCcjiHEA3ID3Zb32xHA/fW9YFl6Z+\n\tS3PMxkYVAWJ8e9AlBNisOYjukJWd+vMulVbhJHBoeT2jb/KCg8JB4Yry0DwmtkWajLR2/uQUYGE\n\tXyGqDflu899g==","X-Received":["by 2002:a05:600d:644a:20b0:490:c6c2:bdc2 with SMTP id\n\t5b1f17b1804b1-490c6c2bdf6mr114292885e9.4.1780929701481; \n\tMon, 08 Jun 2026 07:41:41 -0700 (PDT)","by 2002:a05:600d:644a:20b0:490:c6c2:bdc2 with SMTP id\n\t5b1f17b1804b1-490c6c2bdf6mr114292515e9.4.1780929701017; \n\tMon, 08 Jun 2026 07:41:41 -0700 (PDT)"],"From":"Milan Zamazal <mzamazal@redhat.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, =?utf-8?b?QmFybmFiw6FzIFDFkWN6?=\n\t=?utf-8?q?e?= <barnabas.pocze@ideasonboard.com>,\n\tjohannes.goede@oss.qualcomm.com","Subject":"Re: [RFC PATCH v3 04/17] libcamera: software_isp: Handle\n\tqueueBuffers failure","In-Reply-To":"<178059838285.1119811.5500173666150259611@ping.linuxembedded.co.uk>\n\t(Kieran Bingham's message of \"Thu, 04 Jun 2026 19:39:42 +0100\")","References":"<20260604095105.68798-1-mzamazal@redhat.com>\n\t<20260604095105.68798-6-mzamazal@redhat.com>\n\t<178059838285.1119811.5500173666150259611@ping.linuxembedded.co.uk>","Date":"Mon, 08 Jun 2026 16:41:39 +0200","Message-ID":"<85se6xxffg.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"COVtS8KmeooEhnxUjopsEKMfj--2XwlNNlXpde0wNW8_1780929701","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]