[{"id":31672,"web_url":"https://patchwork.libcamera.org/comment/31672/","msgid":"<172851046444.532453.5902178981597161930@ping.linuxembedded.co.uk>","date":"2024-10-09T21:47:44","subject":"Re: [PATCH v3 1/2] libcamera: pipeline_handler: Provide\n\tcancelRequest","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Milan Zamazal (2024-10-09 18:21:07)\n> Let's extract the two occurrences of canceling a request to a common\n> helper.  This is especially useful for the followup patch, which needs\n> to cancel a request from outside.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>  include/libcamera/internal/pipeline_handler.h |  1 +\n>  src/libcamera/pipeline_handler.cpp            | 23 +++++++++++++------\n>  2 files changed, 17 insertions(+), 7 deletions(-)\n> \n> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n> index 0d3808036..fb28a18d0 100644\n> --- a/include/libcamera/internal/pipeline_handler.h\n> +++ b/include/libcamera/internal/pipeline_handler.h\n> @@ -60,6 +60,7 @@ public:\n>  \n>         bool completeBuffer(Request *request, FrameBuffer *buffer);\n>         void completeRequest(Request *request);\n> +       void cancelRequest(Request *request);\n>  \n>         std::string configurationFile(const std::string &subdir,\n>                                       const std::string &name) const;\n> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n> index e59404691..c9cb11f0f 100644\n> --- a/src/libcamera/pipeline_handler.cpp\n> +++ b/src/libcamera/pipeline_handler.cpp\n> @@ -367,9 +367,7 @@ void PipelineHandler::stop(Camera *camera)\n>         while (!waitingRequests_.empty()) {\n>                 Request *request = waitingRequests_.front();\n>                 waitingRequests_.pop();\n> -\n> -               request->_d()->cancel();\n> -               completeRequest(request);\n> +               cancelRequest(request);\n>         }\n>  \n>         /* Make sure no requests are pending. */\n> @@ -470,10 +468,8 @@ void PipelineHandler::doQueueRequest(Request *request)\n>         }\n>  \n>         int ret = queueRequestDevice(camera, request);\n> -       if (ret) {\n> -               request->_d()->cancel();\n> -               completeRequest(request);\n> -       }\n> +       if (ret)\n> +               cancelRequest(request);\n>  }\n>  \n>  /**\n> @@ -568,6 +564,19 @@ void PipelineHandler::completeRequest(Request *request)\n>         }\n>  }\n>  \n> +/**\n> + * \\brief Cancel request and signal its completion\n> + * \\param[in] request The request to cancel\n> + *\n> + * This function cancels the request in addition to its completion. The same\n> + * rules as for completeRequest() apply.\n\n\n\n> + */\n> +void PipelineHandler::cancelRequest(Request *request)\n> +{\n\nI think I saw a comment from Laurent about what happens if the request\nis already cancelled...\n\nIs this an opportune location that should do any extra checks? Or\nactually - I think completeRequest() probably already does that in it's\ncall to request->_d()->complete(), where it has an\nASSERT(request->status() == RequestPending); so its' already covered.\n\n\nAnd anyway - as a clean up - it still stands alone for the above\nduplications so I think:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +       request->_d()->cancel();\n> +       completeRequest(request);\n> +}\n> +\n>  /**\n>   * \\brief Retrieve the absolute path to a platform configuration file\n>   * \\param[in] subdir The pipeline handler specific subdirectory name\n> -- \n> 2.44.1\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 B662CC32E0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Oct 2024 21:47:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B35C563538;\n\tWed,  9 Oct 2024 23:47:48 +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 3FA4E618C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Oct 2024 23:47:47 +0200 (CEST)","from pendragon.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 8E81F594;\n\tWed,  9 Oct 2024 23:46:09 +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=\"uAZCrrBh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1728510369;\n\tbh=jlOyQXwro1cd663yiVna0zpqx+6cnCQV9C7E58sec0o=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=uAZCrrBhKdzXxAlQyf8k4yLN7F7xRgKgTYKDifFqNAvz77QFVGv0rqgLE+2dQfgsX\n\tJlrc6OJjaJrZk6fCL8ByyTyfSLCoGg6B6604xY6q/m/oOpRZXMmxDg/BlOFOcqydC1\n\t/W9KNZ1JknXw468Q4s3imvUyEDERjeG35IjAfJks=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241009172108.2058320-2-mzamazal@redhat.com>","References":"<20241009172108.2058320-1-mzamazal@redhat.com>\n\t<20241009172108.2058320-2-mzamazal@redhat.com>","Subject":"Re: [PATCH v3 1/2] libcamera: pipeline_handler: Provide\n\tcancelRequest","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>, robert.mader@posteo.de,\n\tlaurent.pinchart@ideasonboard.com","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Wed, 09 Oct 2024 22:47:44 +0100","Message-ID":"<172851046444.532453.5902178981597161930@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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":31687,"web_url":"https://patchwork.libcamera.org/comment/31687/","msgid":"<87r08oquhe.fsf@redhat.com>","date":"2024-10-10T07:37:17","subject":"Re: [PATCH v3 1/2] libcamera: pipeline_handler: Provide\n\tcancelRequest","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Kieran Bingham <kieran.bingham@ideasonboard.com> writes:\n\n> Quoting Milan Zamazal (2024-10-09 18:21:07)\n>> Let's extract the two occurrences of canceling a request to a common\n>> helper.  This is especially useful for the followup patch, which needs\n>\n>> to cancel a request from outside.\n>> \n>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>> ---\n>>  include/libcamera/internal/pipeline_handler.h |  1 +\n>>  src/libcamera/pipeline_handler.cpp            | 23 +++++++++++++------\n>>  2 files changed, 17 insertions(+), 7 deletions(-)\n>> \n>> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\n>> index 0d3808036..fb28a18d0 100644\n>> --- a/include/libcamera/internal/pipeline_handler.h\n>> +++ b/include/libcamera/internal/pipeline_handler.h\n>> @@ -60,6 +60,7 @@ public:\n>>  \n>>         bool completeBuffer(Request *request, FrameBuffer *buffer);\n>>         void completeRequest(Request *request);\n>> +       void cancelRequest(Request *request);\n>>  \n>>         std::string configurationFile(const std::string &subdir,\n>>                                       const std::string &name) const;\n>> diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\n>> index e59404691..c9cb11f0f 100644\n>> --- a/src/libcamera/pipeline_handler.cpp\n>> +++ b/src/libcamera/pipeline_handler.cpp\n>> @@ -367,9 +367,7 @@ void PipelineHandler::stop(Camera *camera)\n>>         while (!waitingRequests_.empty()) {\n>>                 Request *request = waitingRequests_.front();\n>>                 waitingRequests_.pop();\n>> -\n>> -               request->_d()->cancel();\n>> -               completeRequest(request);\n>> +               cancelRequest(request);\n>>         }\n>>  \n>>         /* Make sure no requests are pending. */\n>> @@ -470,10 +468,8 @@ void PipelineHandler::doQueueRequest(Request *request)\n>>         }\n>>  \n>>         int ret = queueRequestDevice(camera, request);\n>> -       if (ret) {\n>> -               request->_d()->cancel();\n>> -               completeRequest(request);\n>> -       }\n>> +       if (ret)\n>> +               cancelRequest(request);\n>>  }\n>>  \n>>  /**\n>> @@ -568,6 +564,19 @@ void PipelineHandler::completeRequest(Request *request)\n>>         }\n>>  }\n>>  \n>> +/**\n>> + * \\brief Cancel request and signal its completion\n>> + * \\param[in] request The request to cancel\n>> + *\n>> + * This function cancels the request in addition to its completion. The same\n>> + * rules as for completeRequest() apply.\n>\n>\n>\n>> + */\n>> +void PipelineHandler::cancelRequest(Request *request)\n>> +{\n>\n> I think I saw a comment from Laurent about what happens if the request\n> is already cancelled...\n\nThis has been addressed in the followup patch in v3.\n\n> Is this an opportune location that should do any extra checks? Or\n> actually - I think completeRequest() probably already does that in it's\n> call to request->_d()->complete(), where it has an\n> ASSERT(request->status() == RequestPending); so its' already covered.\n\nYes, that check is enough IMO.\n\n> And anyway - as a clean up - it still stands alone for the above\n> duplications so I think:\n>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n>> +       request->_d()->cancel();\n>> +       completeRequest(request);\n>> +}\n>> +\n>>  /**\n>>   * \\brief Retrieve the absolute path to a platform configuration file\n>>   * \\param[in] subdir The pipeline handler specific subdirectory name\n>> -- \n>> 2.44.1\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 3FD6BC32E0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 10 Oct 2024 07:37:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C77E6536B;\n\tThu, 10 Oct 2024 09:37:26 +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 335E863538\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Oct 2024 09:37:24 +0200 (CEST)","from mail-wm1-f69.google.com (mail-wm1-f69.google.com\n\t[209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-537-uQxB-1UtNUScuduL6ng5OA-1; Thu, 10 Oct 2024 03:37:21 -0400","by mail-wm1-f69.google.com with SMTP id\n\t5b1f17b1804b1-4311407ae76so2759475e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 10 Oct 2024 00:37:21 -0700 (PDT)","from nuthatch (nat-pool-brq-t.redhat.com. [213.175.37.10])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-431182ffd14sm7479535e9.18.2024.10.10.00.37.17\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 10 Oct 2024 00:37:18 -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=\"eBdVMb/n\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1728545843;\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=x4u3pJ+TYSYhWNIugcFnWakFERPE+nci5vDP6nFr80o=;\n\tb=eBdVMb/n5af7KDhiWtRddR70MQFT1mjHdRD7WGjeGY4fgOsvIG+EnCdSLRJre1wKe/isgB\n\tulQVqz8LweE9SXErzu0XVChqjr728v2MhUJKlLcpO5RYW7b+/2DMlIqc/0Ojdj5N62PGf+\n\t3zjYIdqVhyE1Xhr+oIUS/6k1TGqPWTE=","X-MC-Unique":"uQxB-1UtNUScuduL6ng5OA-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1728545840; x=1729150640;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=x4u3pJ+TYSYhWNIugcFnWakFERPE+nci5vDP6nFr80o=;\n\tb=oLA5V1PXr6Ps0xCPvWummK70lA3+WtlWziFUg/M41R6vSorZxSv4n7xl376fg2x07S\n\tQH+nxDPE3mAgv6ClnskhGBJGJzKK0kgVDvoE6yIEXuw8hRMrs6Le81Usb4Gft35unKrR\n\tMluKjdA3RZVErR+OqOZcppsVdCpy/EshKJ79UF1rsQvqqAmiqZ6wrzVpXxcskFnmhLJQ\n\tAGBaF1SIS0j/kp7+leppk8eUp5T091I46ye2n439yIoaZW0Rbgkw7LT6AVqU6eANWNFi\n\t1fQqbwFB0wgm5Jp+Z3HWKWM4RiWQwTSQ/yGaCGsxmHzK4P/c8kCHxLzWlLphUABxg9+g\n\tp69A==","X-Gm-Message-State":"AOJu0YyhG1g8t/KtcFzL2Rqucw8KZJNGJ3U1KwZwHPsBqkZGDVbQY7gO\n\tWeedGzdc/xk6fB4boo5B2UsLJD6sTPRlZZkTSVG82sq0jDCWXds6TnkcsKscPnEYkY1+nvzOiUj\n\t7Q/UoPxUPD7Xz6G3HUUnCLrAWMXvn+woEnM+8g2Ph0BwHk7T64ulZdG1SAb3mGcEmQ4ujgko=","X-Received":["by 2002:a05:600c:4ec7:b0:426:6f17:531 with SMTP id\n\t5b1f17b1804b1-430ccf1f704mr40507825e9.13.1728545840151; \n\tThu, 10 Oct 2024 00:37:20 -0700 (PDT)","by 2002:a05:600c:4ec7:b0:426:6f17:531 with SMTP id\n\t5b1f17b1804b1-430ccf1f704mr40507665e9.13.1728545839797; \n\tThu, 10 Oct 2024 00:37:19 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IGQBKeEkA6XOS091UnD83nuGBP/4Icg9F5fIAUNZh4YanyiJza/8uvqDogPEx5/64qcPF42hg==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,  robert.mader@posteo.de,\n\tlaurent.pinchart@ideasonboard.com","Subject":"Re: [PATCH v3 1/2] libcamera: pipeline_handler: Provide\n\tcancelRequest","In-Reply-To":"<172851046444.532453.5902178981597161930@ping.linuxembedded.co.uk>\n\t(Kieran Bingham's message of \"Wed, 09 Oct 2024 22:47:44 +0100\")","References":"<20241009172108.2058320-1-mzamazal@redhat.com>\n\t<20241009172108.2058320-2-mzamazal@redhat.com>\n\t<172851046444.532453.5902178981597161930@ping.linuxembedded.co.uk>","Date":"Thu, 10 Oct 2024 09:37:17 +0200","Message-ID":"<87r08oquhe.fsf@redhat.com>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","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>"}}]