[{"id":17111,"web_url":"https://patchwork.libcamera.org/comment/17111/","msgid":"<YKjOQj2g5CMg96Zn@oden.dyn.berto.se>","date":"2021-05-22T09:26:26","subject":"Re: [libcamera-devel] [PATCH v3 2/8] libcamera: request: Add\n\tRequest::cancel()","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your patch.\n\nOn 2021-05-21 17:42:21 +0200, Jacopo Mondi wrote:\n> Add a cancel() function to the Request class that allows to forcefully\n> complete the request and its associated buffers in error state.\n> \n> Only pending requests can be forcefully cancelled. Enforce that\n> by asserting the request state to be RequestPending.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  .../libcamera/internal/tracepoints/request.tp |  8 ++++++\n>  include/libcamera/request.h                   |  1 +\n>  src/libcamera/request.cpp                     | 28 +++++++++++++++++++\n>  3 files changed, 37 insertions(+)\n> \n> diff --git a/include/libcamera/internal/tracepoints/request.tp b/include/libcamera/internal/tracepoints/request.tp\n> index 9e872951374d..9c841b97438a 100644\n> --- a/include/libcamera/internal/tracepoints/request.tp\n> +++ b/include/libcamera/internal/tracepoints/request.tp\n> @@ -66,6 +66,14 @@ TRACEPOINT_EVENT_INSTANCE(\n>  \t)\n>  )\n>  \n> +TRACEPOINT_EVENT_INSTANCE(\n> +\tlibcamera,\n> +\trequest,\n> +\trequest_cancel,\n> +\tTP_ARGS(\n> +\t\tlibcamera::Request *, req\n> +\t)\n> +)\n>  \n>  TRACEPOINT_EVENT(\n>  \tlibcamera,\n> diff --git a/include/libcamera/request.h b/include/libcamera/request.h\n> index 4cf5ff3f7d3b..5596901ddd8e 100644\n> --- a/include/libcamera/request.h\n> +++ b/include/libcamera/request.h\n> @@ -65,6 +65,7 @@ private:\n>  \tfriend class PipelineHandler;\n>  \n>  \tvoid complete();\n> +\tvoid cancel();\n>  \n>  \tbool completeBuffer(FrameBuffer *buffer);\n>  \n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index ce2dd7b17f10..69b2d0172e3d 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -292,6 +292,34 @@ void Request::complete()\n>  \tLIBCAMERA_TRACEPOINT(request_complete, this);\n>  }\n>  \n> +/**\n> + * \\brief Cancel a queued request\n> + *\n> + * Mark the request and its associated buffers as cancelled and complete it.\n> + *\n> + * Set each pending buffer in error state and emit the buffer completion signal\n> + * before completing the Request.\n> + */\n> +void Request::cancel()\n> +{\n> +\tLIBCAMERA_TRACEPOINT(request_cancel, this);\n> +\n> +\tASSERT(status_ == RequestPending);\n> +\n> +\t/*\n> +\t * We can't simply loop and call completeBuffer() as the erase() call\n> +\t * invalidates pointers and iterators, so we have to manually cancel the\n> +\t * buffer from the pending buffers list.\n> +\t */\n> +\tfor (auto buffer = pending_.begin(); buffer != pending_.end();) {\n> +\t\t(*buffer)->cancel();\n> +\t\tcamera_->bufferCompleted.emit(this, *buffer);\n> +\t\tbuffer = pending_.erase(buffer);\n> +\t}\n> +\n> +\tcancelled_ = true;\n> +}\n> +\n>  /**\n>   * \\brief Complete a buffer for the request\n>   * \\param[in] buffer The buffer that has completed\n> -- \n> 2.31.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 89E3EC3201\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 22 May 2021 09:26:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E84EC6891F;\n\tSat, 22 May 2021 11:26:29 +0200 (CEST)","from mail-lf1-x135.google.com (mail-lf1-x135.google.com\n\t[IPv6:2a00:1450:4864:20::135])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D218602B0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 22 May 2021 11:26:28 +0200 (CEST)","by mail-lf1-x135.google.com with SMTP id i22so33078821lfl.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 22 May 2021 02:26:28 -0700 (PDT)","from localhost (h-155-4-209-203.A463.priv.bahnhof.se.\n\t[155.4.209.203]) by smtp.gmail.com with ESMTPSA id\n\tk36sm596200lfv.121.2021.05.22.02.26.27\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 22 May 2021 02:26:27 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"UTqVHmIN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=E7sqqDgoQWbdCzWQX028ojWYuIh+IsLlOZX07Eys8Uc=;\n\tb=UTqVHmINN6mCjeh0O+AlDlvskSbyQKNrdhXJDglMSr1z0aIiGl4ylY0uXkxjjZkMzv\n\tV1rCVP/ShNQ+WJs9BQXqpT3fLKBCYsWcdYBW0mNejnKPHJlZFBB+XTQEEr62y4K5gYr9\n\twYCj6BdaEsMZMY0sr45YM0T6f3UOVnElm1eWeXr2HzK5O+EZ7tFXdpyAyWsSYUD8s4H1\n\tru0kUvPjnS/PcJFwELZ3UHOLBeAfDq377PNStc0IIXUwQeXimPAF8zn/FYpwdv1VTh6y\n\toUzqtUI3fmUDGuGPjsYXn2Hh2wNjNWwQWnBjrU8o/rwOlyLeJV5wC4BQZqk/o0b6W/HX\n\ttUqA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=E7sqqDgoQWbdCzWQX028ojWYuIh+IsLlOZX07Eys8Uc=;\n\tb=WNkwc8nlwY0cjL0IABOykbSaX+Tk8P839kYadvXiqfET1d1hwER/AxYAsHKkMGLL9w\n\tIILtlX0ngDzk+GoNQUaPiFtFlHKD19OHpSmzYq825QHMWren+hpMHNJAg0c5+4wCTW7+\n\t+XYiHZYiwnTLyzkJHHAoZH21kFGjIZ+KmFcynuBY3WDEwu93hHe+rXrcM0R2vi2dISxl\n\t5ixyhPmeOAYHpYw7rLZWXgu6YRJ703iVBZENlm7/DlK+cXAiORLrNvCe2/PoUYnhqyUv\n\t/qfb/ISCVeqj2qq0H4O5cTPqZXJ6kcM2v0tdbVSwYNuB1rltxTinML68SMk5uThtRtun\n\tpB5g==","X-Gm-Message-State":"AOAM530UJPqc9zX789PFot3hGIKiKOnemkoM30Kxr7WBcI8bes1BO5E9\n\t0SzrvW/f7N38QH87RyqYHwfhGB8sI0DESQ==","X-Google-Smtp-Source":"ABdhPJxub7Hny8DjcWX+KddLWeecTQ82tOvjtrToJIVfBgZES0zHoIm380Jy9AKXyf+H1e206EnqKw==","X-Received":"by 2002:a05:6512:3456:: with SMTP id\n\tj22mr5160869lfr.532.1621675587941; \n\tSat, 22 May 2021 02:26:27 -0700 (PDT)","Date":"Sat, 22 May 2021 11:26:26 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YKjOQj2g5CMg96Zn@oden.dyn.berto.se>","References":"<20210521154227.60186-1-jacopo@jmondi.org>\n\t<20210521154227.60186-3-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20210521154227.60186-3-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v3 2/8] libcamera: request: Add\n\tRequest::cancel()","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17135,"web_url":"https://patchwork.libcamera.org/comment/17135/","msgid":"<YKqW9JXkBxA0zLO+@pendragon.ideasonboard.com>","date":"2021-05-23T17:55:00","subject":"Re: [libcamera-devel] [PATCH v3 2/8] libcamera: request: Add\n\tRequest::cancel()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Fri, May 21, 2021 at 05:42:21PM +0200, Jacopo Mondi wrote:\n> Add a cancel() function to the Request class that allows to forcefully\n> complete the request and its associated buffers in error state.\n> \n> Only pending requests can be forcefully cancelled. Enforce that\n> by asserting the request state to be RequestPending.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  .../libcamera/internal/tracepoints/request.tp |  8 ++++++\n>  include/libcamera/request.h                   |  1 +\n>  src/libcamera/request.cpp                     | 28 +++++++++++++++++++\n>  3 files changed, 37 insertions(+)\n> \n> diff --git a/include/libcamera/internal/tracepoints/request.tp b/include/libcamera/internal/tracepoints/request.tp\n> index 9e872951374d..9c841b97438a 100644\n> --- a/include/libcamera/internal/tracepoints/request.tp\n> +++ b/include/libcamera/internal/tracepoints/request.tp\n> @@ -66,6 +66,14 @@ TRACEPOINT_EVENT_INSTANCE(\n>  \t)\n>  )\n>  \n> +TRACEPOINT_EVENT_INSTANCE(\n> +\tlibcamera,\n> +\trequest,\n> +\trequest_cancel,\n> +\tTP_ARGS(\n> +\t\tlibcamera::Request *, req\n> +\t)\n> +)\n>  \n>  TRACEPOINT_EVENT(\n>  \tlibcamera,\n> diff --git a/include/libcamera/request.h b/include/libcamera/request.h\n> index 4cf5ff3f7d3b..5596901ddd8e 100644\n> --- a/include/libcamera/request.h\n> +++ b/include/libcamera/request.h\n> @@ -65,6 +65,7 @@ private:\n>  \tfriend class PipelineHandler;\n>  \n>  \tvoid complete();\n> +\tvoid cancel();\n>  \n>  \tbool completeBuffer(FrameBuffer *buffer);\n>  \n> diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp\n> index ce2dd7b17f10..69b2d0172e3d 100644\n> --- a/src/libcamera/request.cpp\n> +++ b/src/libcamera/request.cpp\n> @@ -292,6 +292,34 @@ void Request::complete()\n>  \tLIBCAMERA_TRACEPOINT(request_complete, this);\n>  }\n>  \n> +/**\n> + * \\brief Cancel a queued request\n> + *\n> + * Mark the request and its associated buffers as cancelled and complete it.\n> + *\n> + * Set each pending buffer in error state and emit the buffer completion signal\n> + * before completing the Request.\n> + */\n> +void Request::cancel()\n> +{\n> +\tLIBCAMERA_TRACEPOINT(request_cancel, this);\n> +\n> +\tASSERT(status_ == RequestPending);\n> +\n> +\t/*\n> +\t * We can't simply loop and call completeBuffer() as the erase() call\n> +\t * invalidates pointers and iterators, so we have to manually cancel the\n> +\t * buffer from the pending buffers list.\n> +\t */\n> +\tfor (auto buffer = pending_.begin(); buffer != pending_.end();) {\n> +\t\t(*buffer)->cancel();\n> +\t\tcamera_->bufferCompleted.emit(this, *buffer);\n> +\t\tbuffer = pending_.erase(buffer);\n> +\t}\n\nHow about\n\n\tfor (FrameBuffer *buffer : pending_) {\n\t\tbuffer->cancel();\n\t\tcamera_->bufferCompleted.emit(this, buffer);\n\t}\n\n\tpending_.clear();\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n> +\tcancelled_ = true;\n> +}\n> +\n>  /**\n>   * \\brief Complete a buffer for the request\n>   * \\param[in] buffer The buffer that has completed","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 05927C3201\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 23 May 2021 17:55:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4978E6891B;\n\tSun, 23 May 2021 19:55:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 80DCB601A9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 23 May 2021 19:55:04 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 00F1F2A8;\n\tSun, 23 May 2021 19:55:03 +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=\"VOEyhjTG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1621792504;\n\tbh=Pt0nvzYtjY2QoEQLQf7VQop3NcuWs14t8RBWZLjPs5I=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VOEyhjTGyZtdEbs2Udihr1bQLOI/KN+scRmpKi3cKKAk+ruEBpcjxpBqIqG2PTSIJ\n\tz0hdcNPvoLcQQCeUutf/B/O9DognARrhg+6F0g+1Vrga3u71ZHISPLyR3jaKRGF3tO\n\tf4Qhs3Wq2mKYp5IwgWmITCjD2QIS+JyY8RS80JEo=","Date":"Sun, 23 May 2021 20:55:00 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<YKqW9JXkBxA0zLO+@pendragon.ideasonboard.com>","References":"<20210521154227.60186-1-jacopo@jmondi.org>\n\t<20210521154227.60186-3-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210521154227.60186-3-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v3 2/8] libcamera: request: Add\n\tRequest::cancel()","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]