[{"id":22001,"web_url":"https://patchwork.libcamera.org/comment/22001/","msgid":"<164183311912.10801.5950069940265789576@Monstersaurus>","date":"2022-01-10T16:45:19","subject":"Re: [libcamera-devel] [PATCH v1 4/5] v4l2: v4l2_compat_manager:\n\tStore V4L2CameraFile in mmaps_","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2021-12-28 21:59:50)\n> The mmaps_ map stores a pointer to the V4L2CameraProxy to avoid\n> increasing the reference count on the V4L2CameraFile shared pointer\n> needlessly. While this provides a small optimization, it prevents\n> accessing the V4L2CameraFile from the munmap() function which doesn't\n> take an fd as argument.\n> \n> To prepare for improved debugging that will require access to\n> V4L2CameraFile in munmap(), store the V4L2CameraFile pointer in mmaps_.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/v4l2/v4l2_compat_manager.cpp | 10 +++-------\n>  src/v4l2/v4l2_compat_manager.h   |  2 +-\n>  2 files changed, 4 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\n> index 585046e97e4b..ded568beb60e 100644\n> --- a/src/v4l2/v4l2_compat_manager.cpp\n> +++ b/src/v4l2/v4l2_compat_manager.cpp\n> @@ -198,11 +198,7 @@ void *V4L2CompatManager::mmap(void *addr, size_t length, int prot, int flags,\n>         if (map == MAP_FAILED)\n>                 return map;\n>  \n> -       /*\n> -        * Map to V4L2CameraProxy directly to prevent adding more references\n> -        * to V4L2CameraFile.\n> -        */\n> -       mmaps_[map] = file->proxy();\n> +       mmaps_[map] = file;\n>         return map;\n>  }\n>  \n> @@ -212,9 +208,9 @@ int V4L2CompatManager::munmap(void *addr, size_t length)\n>         if (device == mmaps_.end())\n>                 return fops_.munmap(addr, length);\n>  \n> -       V4L2CameraProxy *proxy = device->second;\n> +       V4L2CameraFile *file = device->second.get();\n>  \n> -       int ret = proxy->munmap(addr, length);\n> +       int ret = file->proxy()->munmap(addr, length);\n>         if (ret < 0)\n>                 return ret;\n>  \n> diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h\n> index f52069f7b62d..64af9a8c008f 100644\n> --- a/src/v4l2/v4l2_compat_manager.h\n> +++ b/src/v4l2/v4l2_compat_manager.h\n> @@ -65,5 +65,5 @@ private:\n>  \n>         std::vector<std::unique_ptr<V4L2CameraProxy>> proxies_;\n>         std::map<int, std::shared_ptr<V4L2CameraFile>> files_;\n> -       std::map<void *, V4L2CameraProxy *> mmaps_;\n> +       std::map<void *, std::shared_ptr<V4L2CameraFile>> mmaps_;\n>  };\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 9FA16BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 10 Jan 2022 16:45:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D7567604F8;\n\tMon, 10 Jan 2022 17:45:22 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E4A56021A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Jan 2022 17:45:21 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2EC2DA50;\n\tMon, 10 Jan 2022 17:45:21 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"NwlmS6K1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1641833121;\n\tbh=+C/TwxgeTfrBM4OZ6FrMyHF7LuOL0Vwpw72mtLd3nqk=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=NwlmS6K1GivwFMug6rtPkKKuflBLKhUqSRb57cEy4ZfyQomg62oxeawOGCR2+78+q\n\t2+ji+o8CYri6JeHXdzAcIFnYzlkjTfWXr4jQvjkVYKAEZ5gdqsfFkBnzHvf8UnLo2B\n\t3KxRmwh1Pgapp7c1t8pQ/QcInCTLdxf3AnEb0EGA=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211228215951.32396-5-laurent.pinchart@ideasonboard.com>","References":"<20211228215951.32396-1-laurent.pinchart@ideasonboard.com>\n\t<20211228215951.32396-5-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 10 Jan 2022 16:45:19 +0000","Message-ID":"<164183311912.10801.5950069940265789576@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v1 4/5] v4l2: v4l2_compat_manager:\n\tStore V4L2CameraFile in mmaps_","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":22032,"web_url":"https://patchwork.libcamera.org/comment/22032/","msgid":"<20220114105729.GF4255@pyrite.rasen.tech>","date":"2022-01-14T10:57:29","subject":"Re: [libcamera-devel] [PATCH v1 4/5] v4l2: v4l2_compat_manager:\n\tStore V4L2CameraFile in mmaps_","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nOn Tue, Dec 28, 2021 at 11:59:50PM +0200, Laurent Pinchart wrote:\n> The mmaps_ map stores a pointer to the V4L2CameraProxy to avoid\n> increasing the reference count on the V4L2CameraFile shared pointer\n> needlessly. While this provides a small optimization, it prevents\n> accessing the V4L2CameraFile from the munmap() function which doesn't\n> take an fd as argument.\n> \n> To prepare for improved debugging that will require access to\n> V4L2CameraFile in munmap(), store the V4L2CameraFile pointer in mmaps_.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/v4l2/v4l2_compat_manager.cpp | 10 +++-------\n>  src/v4l2/v4l2_compat_manager.h   |  2 +-\n>  2 files changed, 4 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\n> index 585046e97e4b..ded568beb60e 100644\n> --- a/src/v4l2/v4l2_compat_manager.cpp\n> +++ b/src/v4l2/v4l2_compat_manager.cpp\n> @@ -198,11 +198,7 @@ void *V4L2CompatManager::mmap(void *addr, size_t length, int prot, int flags,\n>  \tif (map == MAP_FAILED)\n>  \t\treturn map;\n>  \n> -\t/*\n> -\t * Map to V4L2CameraProxy directly to prevent adding more references\n> -\t * to V4L2CameraFile.\n> -\t */\n> -\tmmaps_[map] = file->proxy();\n> +\tmmaps_[map] = file;\n>  \treturn map;\n>  }\n>  \n> @@ -212,9 +208,9 @@ int V4L2CompatManager::munmap(void *addr, size_t length)\n>  \tif (device == mmaps_.end())\n>  \t\treturn fops_.munmap(addr, length);\n>  \n> -\tV4L2CameraProxy *proxy = device->second;\n> +\tV4L2CameraFile *file = device->second.get();\n>  \n> -\tint ret = proxy->munmap(addr, length);\n> +\tint ret = file->proxy()->munmap(addr, length);\n>  \tif (ret < 0)\n>  \t\treturn ret;\n>  \n> diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h\n> index f52069f7b62d..64af9a8c008f 100644\n> --- a/src/v4l2/v4l2_compat_manager.h\n> +++ b/src/v4l2/v4l2_compat_manager.h\n> @@ -65,5 +65,5 @@ private:\n>  \n>  \tstd::vector<std::unique_ptr<V4L2CameraProxy>> proxies_;\n>  \tstd::map<int, std::shared_ptr<V4L2CameraFile>> files_;\n> -\tstd::map<void *, V4L2CameraProxy *> mmaps_;\n> +\tstd::map<void *, std::shared_ptr<V4L2CameraFile>> mmaps_;\n>  };\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 41ACEBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Jan 2022 10:57:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5FC95604F8;\n\tFri, 14 Jan 2022 11:57:38 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 56AD66017D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Jan 2022 11:57:37 +0100 (CET)","from pyrite.rasen.tech (h175-177-042-148.catv02.itscom.jp\n\t[175.177.42.148])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C545CA2A;\n\tFri, 14 Jan 2022 11:57:35 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Wx1tUkdb\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1642157856;\n\tbh=axm8dVwPMsQfE0/i5Algraukjl3OyC73ZQGoeA4M3xk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Wx1tUkdbQnFSKba8HvP0WSb1YRKzHgU6W0DyxnWA1GiHxNza9d6yrWhMq4MS1VaK/\n\tH0bQfjL3tsoZsGlchcjCmQD+xcTE+3c9EPS9cUfoSKYdIHmwrzO/GsiVKDXxJSSmA6\n\tpNwRi14SPBIVVyukvOEGjPP+AQpA13gqJZCx0Czs=","Date":"Fri, 14 Jan 2022 19:57:29 +0900","From":"paul.elder@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220114105729.GF4255@pyrite.rasen.tech>","References":"<20211228215951.32396-1-laurent.pinchart@ideasonboard.com>\n\t<20211228215951.32396-5-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20211228215951.32396-5-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v1 4/5] v4l2: v4l2_compat_manager:\n\tStore V4L2CameraFile in mmaps_","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>"}}]