[{"id":26885,"web_url":"https://patchwork.libcamera.org/comment/26885/","msgid":"<7p3rrwlpewdy4jpzig6akndhtyc5m6kjaklkndscwn3ktm6lbt@kx3v6cowoocw>","date":"2023-04-17T06:30:33","subject":"Re: [libcamera-devel] [RFC PATCH v1] libcamera:\n\tdevice_enumerator_udev: remove devnum from dependency map","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Sat, Apr 15, 2023 at 09:03:40PM +0000, Barnabás Pőcze via libcamera-devel wrote:\n> Previously, after `addV4L2Device()` had seen all dependecies, it would\n> remove the `MediaDeviceDeps` object from the `pending_` list, which\n> would result in it being destroyed. However, there would still be\n> (dangling) pointers to this object in `devMap_` that were added in\n> `addUdevDevice()` (line 103). So remove the entry with the given\n> devnum when it is removed from the corresponding `MediaDeviceDeps`\n> object.\n>\n> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n> ---\n>  src/libcamera/device_enumerator_udev.cpp | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\n> index 5317afbd..a63cd360 100644\n> --- a/src/libcamera/device_enumerator_udev.cpp\n> +++ b/src/libcamera/device_enumerator_udev.cpp\n> @@ -315,6 +315,7 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)\n>  \t * enumerator.\n>  \t */\n>  \tdeps->deps_.erase(devnum);\n> +\tdevMap_.erase(it);\n\nShouldn't this be done only when all the dependencies are actually\nsatisfied ?\n\n>\n>  \tif (deps->deps_.empty()) {\n\nLikely inside this if() clause ?\n\nOtherwise, if there still are dependencies to meet for the devnum at\nhand, the next time addV4L2Device(devnum) is called it won't find any item\non the devMap_ for that key.\n\n>  \t\tLOG(DeviceEnumerator, Debug)\n> --\n> 2.40.0\n>\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 3E03CBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Apr 2023 06:30:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8DED9627B8;\n\tMon, 17 Apr 2023 08:30:38 +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 3DF5B61EB8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Apr 2023 08:30:37 +0200 (CEST)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DE44075B;\n\tMon, 17 Apr 2023 08:30:31 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681713038;\n\tbh=l5pI5NeNzcf5ig9fGSCbrYWxdeE0XRJPzPb5UvoMPw0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=It/yX2YhqubeKzGD4FWwi+crnlBK1NmLbQDJi8S1VnbNYrSjwaX/koiChNzue3v3l\n\tsGcznZNBFtPpCXHv/40s14JpO5w3ArBDpLXrlGySGv4i8H0+HV8VCq5Scs+yPoCYi3\n\tqxNxp1fKCbpYZTZu4uDGJl2XxbcNwB3tmQhjls1HhKwhjjPKDzeKn7BAkH/BoXLnKy\n\tozNx/+4K5t2ORzSxj3Ch4q85Wbj4YiO1HHelwZRzSnx7lU5NYpEV9tSE4Ms642wTpe\n\tXs8T6qElBT+N+EQkaIfbdm62nMM3Y4vrTNduVttfe5SZiADOSVP/ftOE6lYiklWkNG\n\th9QP1yLKeE9UA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1681713032;\n\tbh=l5pI5NeNzcf5ig9fGSCbrYWxdeE0XRJPzPb5UvoMPw0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AqSoNmnVf5LdBFNpqBzCQ2VSHqhckZtX6Oq+VKvmkVyCrOfpHnp+NVEArjEgSPNLw\n\tSPiBwvROBF0w2IS+EssxLeWOg93mxdd3PugioghTk/IXkQZkMY1iTRKML0zoSIk9JD\n\tHqxVpTXnfb+UcAmJYOPxgsPkXKxN/LrItTs85RjU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"AqSoNmnV\"; dkim-atps=neutral","Date":"Mon, 17 Apr 2023 08:30:33 +0200","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Message-ID":"<7p3rrwlpewdy4jpzig6akndhtyc5m6kjaklkndscwn3ktm6lbt@kx3v6cowoocw>","References":"<20230415205742.268255-1-pobrn@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20230415205742.268255-1-pobrn@protonmail.com>","Subject":"Re: [libcamera-devel] [RFC PATCH v1] libcamera:\n\tdevice_enumerator_udev: remove devnum from dependency map","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26889,"web_url":"https://patchwork.libcamera.org/comment/26889/","msgid":"<MHpsMSFII_apg3qicetfG8YpqigcbkVHVRvzUTsX1IU7P9j6d0ENxW2Ws5aj1pNQFOluYneCqxok7GjenrGSmVwgkt4YFOcAmr6zYYJNtqQ=@protonmail.com>","date":"2023-04-17T17:41:58","subject":"Re: [libcamera-devel] [RFC PATCH v1] libcamera:\n\tdevice_enumerator_udev: remove devnum from dependency map","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/people/133/","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"content":"Hi\n\n\n2023. április 17., hétfő 8:30 keltezéssel, Jacopo Mondi <jacopo.mondi@ideasonboard.com> írta:\n\n> [...]\n> > diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\n> > index 5317afbd..a63cd360 100644\n> > --- a/src/libcamera/device_enumerator_udev.cpp\n> > +++ b/src/libcamera/device_enumerator_udev.cpp\n> > @@ -315,6 +315,7 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)\n> >  \t * enumerator.\n> >  \t */\n> >  \tdeps->deps_.erase(devnum);\n> > +\tdevMap_.erase(it);\n> \n> Shouldn't this be done only when all the dependencies are actually\n> satisfied ?\n> \n\nEvery dependency has its own entry in `devMap_` with a pointer to\nthe corresponding `MediaDeviceDeps` object. I think when one dependency\nappears it should be removed from the map, just like it is removed\nfrom `MediaDeviceDeps::deps_` (in the previous line).\n\n\n> >\n> >  \tif (deps->deps_.empty()) {\n> \n> Likely inside this if() clause ?\n\n`deps->deps_` is empty at this point, so we cannot efficiently find all\nentries in `devMap_` that belong to `deps`.\n\n\n> \n> Otherwise, if there still are dependencies to meet for the devnum at\n> hand, the next time addV4L2Device(devnum) is called it won't find any item\n> on the devMap_ for that key.\n\nMy reading of the code suggests that devnum is unique and each v4l2 device\ncan be a dependency of at most 1 media device. Is that not correct?\n\n\n> \n> >  \t\tLOG(DeviceEnumerator, Debug)\n> > --\n> > 2.40.0\n> >\n> >\n> \n\n\nRegards,\nBarnabás Pőcze","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 5B2C0BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Apr 2023 17:42:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 74A04627B6;\n\tMon, 17 Apr 2023 19:42:13 +0200 (CEST)","from mail-40134.protonmail.ch (mail-40134.protonmail.ch\n\t[185.70.40.134])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 63BA5603A3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Apr 2023 19:42:11 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681753333;\n\tbh=4frVKGjjg1kLIFe6f2ojZhfifOxEw+gKF/vZORSEkLE=;\n\th=Date:To:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=w3f90XeRog77dd64jUBhZagDBkIAyr7PdLiKyxkqAnbWX6mExgzB/nlwk1lE8Euce\n\tzj5lpPjPeZwWBe2/t7FHJQFi9IDrQcfh6H7KVc3zRy1+BGJXJbrzasY1U5d3fQbxH8\n\tsI5IDjFH/8UhTEUGWv9XEc1/umpE90I5xuKIuTwzBWjG5/ga6YIgGYQ5CF+TgGRVgp\n\t5tx26ZhMgfO2Dxn92xjaiuUn1HsXG1Fg6O4sfdii+U3awulDP7LSkOn5yvr7WjpCtb\n\tkes3dX4oWn1hcAtr0KNFLTQtdPgKQ5DvGdZHeNLPgK5dfPO2RMfpTpok/Rkx1J0pPg\n\txye3IXrB0y4LQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1681753330; x=1682012530;\n\tbh=H/GrBN/oCbMht7+VnZQXXMmOARHELkvsJsDvCfvpRpI=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector;\n\tb=VDeFkpP4/EIJSGLbhCOk+s23zDi+ujElENfkH4p5kvrihUyuyziJlDEfJkDp3+6Bt\n\tBhC21dgThFEKIjHZ8qVsHILAnuGC8QQDEo1D5ggG0Jf2n/suCnUEuNvQf0v+4Qodzl\n\ti8Uts2C/c4yNQUtVStpf/sZFzrFAxZY9vFWxZK6J73Kyg8I9dexM9h4H83Qb+VYdPo\n\tHQ2b37PWnX/F0NBj4bQqJbpAwgCJ5YQIlsyKc63792Gu2ZZbvx6SBU+KRhVGdQN6YA\n\tCvYei1h2djQYHmm4t3mSz6P2wOSWB4DQf/7R7sNtTQqZugl2BLrIS1eJfc75gnRX10\n\tmIbZ3aDz4P0PA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=protonmail.com\n\theader.i=@protonmail.com\n\theader.b=\"VDeFkpP4\"; dkim-atps=neutral","Date":"Mon, 17 Apr 2023 17:41:58 +0000","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Message-ID":"<MHpsMSFII_apg3qicetfG8YpqigcbkVHVRvzUTsX1IU7P9j6d0ENxW2Ws5aj1pNQFOluYneCqxok7GjenrGSmVwgkt4YFOcAmr6zYYJNtqQ=@protonmail.com>","In-Reply-To":"<7p3rrwlpewdy4jpzig6akndhtyc5m6kjaklkndscwn3ktm6lbt@kx3v6cowoocw>","References":"<20230415205742.268255-1-pobrn@protonmail.com>\n\t<7p3rrwlpewdy4jpzig6akndhtyc5m6kjaklkndscwn3ktm6lbt@kx3v6cowoocw>","Feedback-ID":"20568564:user:proton","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [RFC PATCH v1] libcamera:\n\tdevice_enumerator_udev: remove devnum from dependency map","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>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze_via_libcamera-devel?=\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26890,"web_url":"https://patchwork.libcamera.org/comment/26890/","msgid":"<20230418050500.GB4703@pendragon.ideasonboard.com>","date":"2023-04-18T05:05:00","subject":"Re: [libcamera-devel] [RFC PATCH v1] libcamera:\n\tdevice_enumerator_udev: remove devnum from dependency map","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hello Barnabás,\n\nOn Mon, Apr 17, 2023 at 05:41:58PM +0000, Barnabás Pőcze via libcamera-devel wrote:\n> 2023. április 17., hétfő 8:30 keltezéssel, Jacopo Mondi írta:\n> > [...]\n> > > diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\n> > > index 5317afbd..a63cd360 100644\n> > > --- a/src/libcamera/device_enumerator_udev.cpp\n> > > +++ b/src/libcamera/device_enumerator_udev.cpp\n> > > @@ -315,6 +315,7 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)\n> > >  \t * enumerator.\n> > >  \t */\n> > >  \tdeps->deps_.erase(devnum);\n> > > +\tdevMap_.erase(it);\n> > \n> > Shouldn't this be done only when all the dependencies are actually\n> > satisfied ?\n> \n> Every dependency has its own entry in `devMap_` with a pointer to\n> the corresponding `MediaDeviceDeps` object. I think when one dependency\n> appears it should be removed from the map, just like it is removed\n> from `MediaDeviceDeps::deps_` (in the previous line).\n> \n> > >  \tif (deps->deps_.empty()) {\n> > \n> > Likely inside this if() clause ?\n> \n> `deps->deps_` is empty at this point, so we cannot efficiently find all\n> entries in `devMap_` that belong to `deps`.\n\nWe could iterate over the whole map to remove all entries that point to\ndeps, but I don't think that's needed.\n\n> > Otherwise, if there still are dependencies to meet for the devnum at\n> > hand, the next time addV4L2Device(devnum) is called it won't find any item\n> > on the devMap_ for that key.\n> \n> My reading of the code suggests that devnum is unique and each v4l2 device\n> can be a dependency of at most 1 media device. Is that not correct?\n\nYour assumption is correct. The only issue I can see would be if the\nV4L2 device is removed and re-added without the media device being\nremoved too. addV4L2Device() wouldn't find the dependency in that case,\nbut this is a completely unsupported use case that would cause other\nproblems anyway. I think this patch is fine.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > >  \t\tLOG(DeviceEnumerator, Debug)","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 D5A45BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 18 Apr 2023 05:04:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 40D90627AB;\n\tTue, 18 Apr 2023 07:04:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B80A61EB7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Apr 2023 07:04:49 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(133-32-181-51.west.xps.vectant.ne.jp [133.32.181.51])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8FED5802;\n\tTue, 18 Apr 2023 07:04:42 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681794292;\n\tbh=JPyCiFxjC282U/teaJcnUXyzMlAdxjtBzYt2T3Y6/HU=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=2lLfuOa+9b7OFXcLDktlAVxhZYIg3kjbDKq2IXYgZdC5NzDO1hN4TJktQ0sVJtZax\n\tk0WQY8+NduBzof9UmGy5sGElANfgGrCCWdlhy5mNmGDBXbxNiaImhJZmiRnVuOhkhV\n\tGounvkC88SokeIcisxcZmxt+VADnXMpV6Fmbnj0G3jLgebsKHcmmYLNaWUqcXmh9sg\n\t75a2sX4ddCK7Tl07RcuImcf6CC4e2xLedFib71eL7ViKk/5w8OWjfeFtfYMgCdszKn\n\tIWvCJZOe8JdL750XXrZXN96dkFx4FOzYiQIV0nGM4bpAXUJfprmzwu0R7hfu7wW30T\n\tAA2arKnZBoZEA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1681794283;\n\tbh=JPyCiFxjC282U/teaJcnUXyzMlAdxjtBzYt2T3Y6/HU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=rnU6Y36rOhB1SFCgoPnLxNoTEwzYvKd0IaqTgcrZajM25pFPvgKBRkThIydvPUuLR\n\t4lOdFYWKRHNa5SqaeRxk5PBetwFeQxlAGBOtwXzmkWnREUjDwIpYhXI1Yyt7CuI3HA\n\txN4n07U1n6RzxJl3Pp+3t9+h2SsmFgzJ8d6jprd4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"rnU6Y36r\"; dkim-atps=neutral","Date":"Tue, 18 Apr 2023 08:05:00 +0300","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Message-ID":"<20230418050500.GB4703@pendragon.ideasonboard.com>","References":"<20230415205742.268255-1-pobrn@protonmail.com>\n\t<7p3rrwlpewdy4jpzig6akndhtyc5m6kjaklkndscwn3ktm6lbt@kx3v6cowoocw>\n\t<MHpsMSFII_apg3qicetfG8YpqigcbkVHVRvzUTsX1IU7P9j6d0ENxW2Ws5aj1pNQFOluYneCqxok7GjenrGSmVwgkt4YFOcAmr6zYYJNtqQ=@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<MHpsMSFII_apg3qicetfG8YpqigcbkVHVRvzUTsX1IU7P9j6d0ENxW2Ws5aj1pNQFOluYneCqxok7GjenrGSmVwgkt4YFOcAmr6zYYJNtqQ=@protonmail.com>","Subject":"Re: [libcamera-devel] [RFC PATCH v1] libcamera:\n\tdevice_enumerator_udev: remove devnum from dependency map","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":26891,"web_url":"https://patchwork.libcamera.org/comment/26891/","msgid":"<np4ug2ycz5kabuqgnnu3cpsijdfqrtrgo6lay5s4fdkekwtwbx@rce5r34otjuq>","date":"2023-04-18T07:33:57","subject":"Re: [libcamera-devel] [RFC PATCH v1] libcamera:\n\tdevice_enumerator_udev: remove devnum from dependency map","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Mon, Apr 17, 2023 at 05:41:58PM +0000, Barnabás Pőcze via libcamera-devel wrote:\n> Hi\n>\n>\n> 2023. április 17., hétfő 8:30 keltezéssel, Jacopo Mondi <jacopo.mondi@ideasonboard.com> írta:\n>\n> > [...]\n> > > diff --git a/src/libcamera/device_enumerator_udev.cpp b/src/libcamera/device_enumerator_udev.cpp\n> > > index 5317afbd..a63cd360 100644\n> > > --- a/src/libcamera/device_enumerator_udev.cpp\n> > > +++ b/src/libcamera/device_enumerator_udev.cpp\n> > > @@ -315,6 +315,7 @@ int DeviceEnumeratorUdev::addV4L2Device(dev_t devnum)\n> > >  \t * enumerator.\n> > >  \t */\n> > >  \tdeps->deps_.erase(devnum);\n> > > +\tdevMap_.erase(it);\n> >\n> > Shouldn't this be done only when all the dependencies are actually\n> > satisfied ?\n> >\n>\n> Every dependency has its own entry in `devMap_` with a pointer to\n> the corresponding `MediaDeviceDeps` object. I think when one dependency\n> appears it should be removed from the map, just like it is removed\n> from `MediaDeviceDeps::deps_` (in the previous line).\n>\n>\n> > >\n> > >  \tif (deps->deps_.empty()) {\n> >\n> > Likely inside this if() clause ?\n>\n> `deps->deps_` is empty at this point, so we cannot efficiently find all\n> entries in `devMap_` that belong to `deps`.\n>\n>\n> >\n> > Otherwise, if there still are dependencies to meet for the devnum at\n> > hand, the next time addV4L2Device(devnum) is called it won't find any item\n> > on the devMap_ for that key.\n>\n> My reading of the code suggests that devnum is unique and each v4l2 device\n> can be a dependency of at most 1 media device. Is that not correct?\n>\n\nIndeed, from a superficial read I thought devMap_ was associating\nmedia devices with their dependencies while instead, as you said, each\ndependency has its own entry in devMap_.\n\nSorry for the noise, it makes sense to me now\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n>\n> >\n> > >  \t\tLOG(DeviceEnumerator, Debug)\n> > > --\n> > > 2.40.0\n> > >\n> > >\n> >\n>\n>\n> Regards,\n> Barnabás Pőcze","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 16DD5BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 18 Apr 2023 07:34:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 57419627B1;\n\tTue, 18 Apr 2023 09:34:03 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BD4161EBB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Apr 2023 09:34:01 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2001:b07:5d2e:52c9:1cf0:b3bc:c785:4625])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0FC64802;\n\tTue, 18 Apr 2023 09:33:55 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1681803243;\n\tbh=XzH8zKZ1nZakw4om5FQpi9rV44Qu02ZmK85G0skjR3k=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=lJURyRGcU4NlVopIy2dNy4pHJ4ElggaFiq+HXCAjV5ZXHbEahwdv3AUrWTsrX/jXS\n\tZGKBWkljvQR+bq0yfnbTUS0AoR7cFL7oNA92/t2QaRpmryKgn3hHgwVU3uMLFAJOXp\n\tskcDt7NKg1FsQ+xw4IhcuFI4mV1+GP1sZoKcI3bcAbXdiyjLGjuVFwPARTqaD7xTT7\n\t+RDKZ5gtF7DSbdjr30f0KaEIrAj5IEciNijWdoYcdGJrwMofOoZ34f2q7rFvBPeJ1f\n\txDKlOfucL5N5hj/2roz9lg+R4tYgG+tNVhFpRPsLqd6OtZzAo5MijFjVTY92UTCuKp\n\tfit6NBTN56QOw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1681803235;\n\tbh=XzH8zKZ1nZakw4om5FQpi9rV44Qu02ZmK85G0skjR3k=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wLlESGu+sIez/NisH7DXGPvDt8EGUBk/HZB5x2+McUlUDPkMX1tQvIdiwnHtGIzjC\n\t/hYkTyV3InYq6ClUTGtQEYdkW89Jz4P6vbmOdQApW89044/74oKqp/yKy4gNF6lBEX\n\tcHCkqOdPtY7Z0ROYE+DkjAE7CT5Agl35hD0b46PY="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"wLlESGu+\"; dkim-atps=neutral","Date":"Tue, 18 Apr 2023 09:33:57 +0200","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Message-ID":"<np4ug2ycz5kabuqgnnu3cpsijdfqrtrgo6lay5s4fdkekwtwbx@rce5r34otjuq>","References":"<20230415205742.268255-1-pobrn@protonmail.com>\n\t<7p3rrwlpewdy4jpzig6akndhtyc5m6kjaklkndscwn3ktm6lbt@kx3v6cowoocw>\n\t<MHpsMSFII_apg3qicetfG8YpqigcbkVHVRvzUTsX1IU7P9j6d0ENxW2Ws5aj1pNQFOluYneCqxok7GjenrGSmVwgkt4YFOcAmr6zYYJNtqQ=@protonmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<MHpsMSFII_apg3qicetfG8YpqigcbkVHVRvzUTsX1IU7P9j6d0ENxW2Ws5aj1pNQFOluYneCqxok7GjenrGSmVwgkt4YFOcAmr6zYYJNtqQ=@protonmail.com>","Subject":"Re: [libcamera-devel] [RFC PATCH v1] libcamera:\n\tdevice_enumerator_udev: remove devnum from dependency map","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]