{"id":12213,"url":"https://patchwork.libcamera.org/api/1.1/patches/12213/?format=json","web_url":"https://patchwork.libcamera.org/patch/12213/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210506180249.318346-5-nfraprado@collabora.com>","date":"2021-05-06T18:02:47","name":"[libcamera-devel,v4,4/6] lc-compliance: Add test to queue more requests than hardware depth","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"4d1b57419a28c7112f1c318f44458b7f3ea1c3b1","submitter":{"id":84,"url":"https://patchwork.libcamera.org/api/1.1/people/84/?format=json","name":"Nícolas F. R. A. Prado","email":"nfraprado@collabora.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12213/mbox/","series":[{"id":2005,"url":"https://patchwork.libcamera.org/api/1.1/series/2005/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2005","date":"2021-05-06T18:02:43","name":"lc-compliance: Add test to queue more requests than hardware depth","version":4,"mbox":"https://patchwork.libcamera.org/series/2005/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12213/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12213/checks/","tags":{},"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 DE043BDE7F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  6 May 2021 18:04:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A578568926;\n\tThu,  6 May 2021 20:04:02 +0200 (CEST)","from bhuna.collabora.co.uk (bhuna.collabora.co.uk\n\t[IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 30D8D68926\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 May 2021 20:04:01 +0200 (CEST)","from localhost.localdomain (unknown\n\t[IPv6:2804:14c:1a9:2978:995d:672b:100f:2fd9])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits))\n\t(No client certificate requested) (Authenticated sender: nfraprado)\n\tby bhuna.collabora.co.uk (Postfix) with ESMTPSA id 6A3B11F43B94;\n\tThu,  6 May 2021 19:03:59 +0100 (BST)"],"From":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  6 May 2021 15:02:47 -0300","Message-Id":"<20210506180249.318346-5-nfraprado@collabora.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210506180249.318346-1-nfraprado@collabora.com>","References":"<20210506180249.318346-1-nfraprado@collabora.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v4 4/6] lc-compliance: Add test to queue\n\tmore requests than hardware depth","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":"kernel@collabora.com, =?utf-8?q?Andr=C3=A9_Almeida?=\n\t<andrealmeid@collabora.com>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"A pipeline handler should be able to handle an arbitrary number of\nsimultaneous requests by submitting what it can to the video device and\nqueuing the rest internally until resources are available. This isn't\ncurrently done by some pipeline handlers however [1].\n\nAdd a new test to lc-compliance that submits a lot of requests at once\nto check if the pipeline handler is behaving well in this situation.\n\n[1] https://bugs.libcamera.org/show_bug.cgi?id=24\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n---\n src/lc-compliance/simple_capture.cpp | 48 ++++++++++++++++++++++++++++\n src/lc-compliance/simple_capture.h   | 12 +++++++\n src/lc-compliance/single_stream.cpp  | 31 +++++++++++++++++-\n 3 files changed, 90 insertions(+), 1 deletion(-)","diff":"diff --git a/src/lc-compliance/simple_capture.cpp b/src/lc-compliance/simple_capture.cpp\nindex bb173ef1f71a..598c5aebe033 100644\n--- a/src/lc-compliance/simple_capture.cpp\n+++ b/src/lc-compliance/simple_capture.cpp\n@@ -249,3 +249,51 @@ void SimpleCaptureUnbalanced::requestComplete(Request *request)\n \tif (camera_->queueRequest(request))\n \t\tloop_->exit(-EINVAL);\n }\n+\n+/* SimpleCaptureOverflow */\n+\n+SimpleCaptureOverflow::SimpleCaptureOverflow(std::shared_ptr<Camera> camera)\n+\t: SimpleCapture(camera)\n+{\n+}\n+\n+Results::Result SimpleCaptureOverflow::capture()\n+{\n+\tResults::Result ret = start();\n+\tif (ret.first != Results::Pass)\n+\t\treturn ret;\n+\n+\tStream *stream = config_->at(0).stream();\n+\tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers = allocator_->buffers(stream);\n+\n+\tcaptureCount_ = 0;\n+\tcaptureLimit_ = buffers.size();\n+\n+\tstd::vector<std::unique_ptr<libcamera::Request>> requests;\n+\tret = queueRequests(stream, requests, buffers);\n+\tif (ret.first != Results::Pass)\n+\t\treturn ret;\n+\n+\trunCaptureSession();\n+\n+\tif (captureCount_ != captureLimit_)\n+\t\treturn { Results::Fail, \"Got \" + std::to_string(captureCount_) +\n+\t\t\t\" request, wanted \" + std::to_string(captureLimit_) };\n+\n+\treturn { Results::Pass, \"Overflow capture of \" +\n+\t\tstd::to_string(captureLimit_) + \" requests\" };\n+}\n+\n+void SimpleCaptureOverflow::requestComplete([[maybe_unused]] Request *request)\n+{\n+\tcaptureCompleted();\n+}\n+\n+Results::Result SimpleCaptureOverflow::allocateBuffers(unsigned int count)\n+{\n+\tStream *stream = config_->at(0).stream();\n+\tif (allocator_->allocate(stream, count) < 0)\n+\t\treturn { Results::Fail, \"Failed to allocate buffers\" };\n+\n+\treturn { Results::Pass, \"Allocated buffers\" };\n+}\ndiff --git a/src/lc-compliance/simple_capture.h b/src/lc-compliance/simple_capture.h\nindex 8d0f94f0c3e5..3b818c640477 100644\n--- a/src/lc-compliance/simple_capture.h\n+++ b/src/lc-compliance/simple_capture.h\n@@ -72,4 +72,16 @@ private:\n \tvoid requestComplete(libcamera::Request *request) override;\n };\n \n+class SimpleCaptureOverflow : public SimpleCapture\n+{\n+public:\n+\tSimpleCaptureOverflow(std::shared_ptr<libcamera::Camera> camera);\n+\n+\tResults::Result allocateBuffers(unsigned int count);\n+\tResults::Result capture();\n+\n+private:\n+\tvoid requestComplete(libcamera::Request *request) override;\n+};\n+\n #endif /* __LC_COMPLIANCE_SIMPLE_CAPTURE_H__ */\ndiff --git a/src/lc-compliance/single_stream.cpp b/src/lc-compliance/single_stream.cpp\nindex 649291c7bb73..7035d9cf5df5 100644\n--- a/src/lc-compliance/single_stream.cpp\n+++ b/src/lc-compliance/single_stream.cpp\n@@ -12,6 +12,23 @@\n \n using namespace libcamera;\n \n+static const unsigned int MAX_SIMULTANEOUS_REQUESTS = 8;\n+\n+Results::Result testRequestOverflow(std::shared_ptr<Camera> camera,\n+\t\t\t\t   StreamRole role, unsigned int numRequests)\n+{\n+\tSimpleCaptureOverflow capture(camera);\n+\n+\tResults::Result ret = capture.configure(role);\n+\tif (ret.first != Results::Pass)\n+\t\treturn ret;\n+\tcapture.allocateBuffers(numRequests);\n+\tif (ret.first != Results::Pass)\n+\t\treturn ret;\n+\n+\treturn capture.capture();\n+}\n+\n Results::Result testRequestBalance(std::shared_ptr<Camera> camera,\n \t\t\t\t   StreamRole role, unsigned int startCycles,\n \t\t\t\t   unsigned int numRequests)\n@@ -61,7 +78,7 @@ Results testSingleStream(std::shared_ptr<Camera> camera)\n \t};\n \tstatic const std::vector<unsigned int> numRequests = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };\n \n-\tResults results(numRequests.size() * roles.size() * 3);\n+\tResults results(numRequests.size() * roles.size() * 3 + roles.size());\n \n \tfor (const auto &role : roles) {\n \t\tstd::cout << \"= Test role \" << role.first << std::endl;\n@@ -97,6 +114,18 @@ Results testSingleStream(std::shared_ptr<Camera> camera)\n \t\tstd::cout << \"* Test unbalanced stop\" << std::endl;\n \t\tfor (unsigned int num : numRequests)\n \t\t\tresults.add(testRequestUnbalance(camera, role.second, num));\n+\n+\t\t/*\n+\t\t * Test overflowing pipeline with requests\n+\t\t *\n+\t\t * Makes sure that the camera supports receiving a large number\n+\t\t * of requests at once. Example failure is a camera that doesn't\n+\t\t * check if there are available resources (free internal\n+\t\t * buffers, free buffers in the video devices) before handling a\n+\t\t * request.\n+\t\t */\n+\t\tstd::cout << \"* Test overflowing requests\" << std::endl;\n+\t\tresults.add(testRequestOverflow(camera, role.second, MAX_SIMULTANEOUS_REQUESTS));\n \t}\n \n \treturn results;\n","prefixes":["libcamera-devel","v4","4/6"]}