From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CA04C43142 for ; Wed, 20 Jan 2021 12:44:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCE2F23371 for ; Wed, 20 Jan 2021 12:44:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388773AbhATMjv (ORCPT ); Wed, 20 Jan 2021 07:39:51 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:40230 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387433AbhATMNL (ORCPT ); Wed, 20 Jan 2021 07:13:11 -0500 Received: from [192.168.0.20] (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 677A2813; Wed, 20 Jan 2021 13:12:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1611144740; bh=OBsgCLskM2jyxkGvxB8sQDhm7TPcsjMVw6cYko8kHYs=; h=Reply-To:Subject:From:To:Cc:References:Date:In-Reply-To:From; b=Q64NvK/HjtD11ausNQTn7v0lt69PCkpM17Wv6lvl1qIRvw6DGG0tdQSbs70W/T8TB eMZBw146UyYXkHT0jKfViPRzoAOu/vUY9oF+Jxv1QGTB7XD0a80KMMOrJlZbHsjbTu SDLDo0afHv8ZsgUlchJus18PcP4cPj4H7typzS+g= Reply-To: kieran.bingham+renesas@ideasonboard.com, kieran.bingham+renesas@ideasonboard.com Subject: Re: [PATCH v4] media: v4l2-async: Add waiting subdevices debugfs From: Kieran Bingham To: Ezequiel Garcia , linux-media@vger.kernel.org, Hans Verkuil Cc: kernel@collabora.com, Laurent Pinchart , Sakari Ailus , Hans Verkuil References: <20210108171728.39434-2-ezequiel@collabora.com> <20210115191415.164127-1-ezequiel@collabora.com> Organization: Ideas on Board Message-ID: <3c636547-cef8-291e-34a0-7dfa1995040e@ideasonboard.com> Date: Wed, 20 Jan 2021 12:12:18 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Ezequiel, On 15/01/2021 19:47, Kieran Bingham wrote: > Hi Ezequiel, > > On 15/01/2021 19:14, Ezequiel Garcia wrote: >> There is currently little to no information available >> about the reasons why a v4l2-async device hasn't >> probed completely. >> >> Inspired by the "devices_deferred" debugfs file, >> add a file to list information about the subdevices >> that are on waiting lists, for each notifier. >> >> This is useful to debug v4l2-async subdevices >> and notifiers, for instance when doing device bring-up. >> >> For instance, a typical output would be: >> >> $ cat /sys/kernel/debug/video4linux/pending_async_subdevices >> ipu1_csi1: >> [fwnode] dev=20e0000.iomuxc-gpr:ipu1_csi1_mux, node=/soc/bus@2000000/iomuxc-gpr@20e0000/ipu1_csi1_mux >> ipu1_csi0: >> [fwnode] dev=20e0000.iomuxc-gpr:ipu1_csi0_mux, node=/soc/bus@2000000/iomuxc-gpr@20e0000/ipu1_csi0_mux >> imx6-mipi-csi2: >> [fwnode] dev=1-003c, node=/soc/bus@2100000/i2c@21a4000/camera@3c >> imx-media: > > Oh this is very exciting. I started looking at something like this > recently, hitting async failures, and this already looks better. > > In other words, - Thank you! > > Reviewed-by: Kieran Bingham Throwing in an extra tag: > root@salvator-x:/home/kbingham# cat /sys/kernel/debug/video4linux/pending_async_subdevices > max9286 4-006c: > [fwnode] dev=15-0035, node=/soc/i2c@e66d8000/gmsl-deserializer@6c/i2c-mux/i2c@0/camera@35/port/endpoint > max9286 4-004c: > [fwnode] dev=10-0031, node=/soc/i2c@e66d8000/gmsl-deserializer@4c/i2c-mux/i2c@0/camera@31/port/endpoint > [fwnode] dev=11-0032, node=/soc/i2c@e66d8000/gmsl-deserializer@4c/i2c-mux/i2c@1/camera@32/port/endpoint > [fwnode] dev=12-0033, node=/soc/i2c@e66d8000/gmsl-deserializer@4c/i2c-mux/i2c@2/camera@33/port/endpoint > [fwnode] dev=13-0034, node=/soc/i2c@e66d8000/gmsl-deserializer@4c/i2c-mux/i2c@3/camera@34/port/endpoint > rcar-vin e6ef7000.video: > rcar_csi2 feab0000.csi2: > rcar_csi2 feaa0000.csi2: > rcar_csi2 fea80000.csi2: That looks good and really helpful to me ;-) Tested-by: Kieran Bingham > >> Signed-off-by: Ezequiel Garcia >> Reviewed-by: Laurent Pinchart >> Reviewed-by: Hans Verkuil >> --- >> drivers/media/v4l2-core/v4l2-async.c | 63 ++++++++++++++++++++++++++++ >> drivers/media/v4l2-core/v4l2-dev.c | 5 +++ >> include/media/v4l2-async.h | 8 ++++ >> 3 files changed, 76 insertions(+) >> >> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c >> index e3ab003a6c85..e35f18706792 100644 >> --- a/drivers/media/v4l2-core/v4l2-async.c >> +++ b/drivers/media/v4l2-core/v4l2-async.c >> @@ -5,6 +5,7 @@ >> * Copyright (C) 2012-2013, Guennadi Liakhovetski >> */ >> >> +#include >> #include >> #include >> #include >> @@ -14,6 +15,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> >> @@ -837,3 +839,64 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) >> mutex_unlock(&list_lock); >> } >> EXPORT_SYMBOL(v4l2_async_unregister_subdev); >> + >> +static void print_waiting_subdev(struct seq_file *s, >> + struct v4l2_async_subdev *asd) >> +{ >> + switch (asd->match_type) { >> + case V4L2_ASYNC_MATCH_I2C: >> + seq_printf(s, " [i2c] dev=%d-%04x\n", asd->match.i2c.adapter_id, >> + asd->match.i2c.address); >> + break; >> + case V4L2_ASYNC_MATCH_FWNODE: { >> + struct fwnode_handle *devnode, *fwnode = asd->match.fwnode; >> + >> + devnode = fwnode_graph_is_endpoint(fwnode) ? >> + fwnode_graph_get_port_parent(fwnode) : >> + fwnode_handle_get(fwnode); >> + >> + seq_printf(s, " [fwnode] dev=%s, node=%pfw\n", >> + devnode->dev ? dev_name(devnode->dev) : "nil", >> + fwnode); >> + >> + fwnode_handle_put(devnode); >> + break; >> + } >> + } >> +} >> + >> +static const char * >> +v4l2_async_notifier_name(struct v4l2_async_notifier *notifier) >> +{ >> + if (notifier->v4l2_dev) >> + return notifier->v4l2_dev->name; >> + else if (notifier->sd) >> + return notifier->sd->name; >> + else >> + return "nil"; >> +} >> + >> +static int pending_subdevs_show(struct seq_file *s, void *data) >> +{ >> + struct v4l2_async_notifier *notif; >> + struct v4l2_async_subdev *asd; >> + >> + mutex_lock(&list_lock); >> + >> + list_for_each_entry(notif, ¬ifier_list, list) { >> + seq_printf(s, "%s:\n", v4l2_async_notifier_name(notif)); >> + list_for_each_entry(asd, ¬if->waiting, list) >> + print_waiting_subdev(s, asd); >> + } >> + >> + mutex_unlock(&list_lock); >> + >> + return 0; >> +} >> +DEFINE_SHOW_ATTRIBUTE(pending_subdevs); >> + >> +void v4l2_async_debug_init(struct dentry *debugfs_dir) >> +{ >> + debugfs_create_file("pending_async_subdevices", 0444, debugfs_dir, NULL, >> + &pending_subdevs_fops); >> +} >> diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c >> index f9cff033d0dc..b6a72d297775 100644 >> --- a/drivers/media/v4l2-core/v4l2-dev.c >> +++ b/drivers/media/v4l2-core/v4l2-dev.c >> @@ -14,6 +14,7 @@ >> >> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt >> >> +#include >> #include >> #include >> #include >> @@ -38,6 +39,7 @@ >> __func__, ##arg); \ >> } while (0) >> >> +static struct dentry *v4l2_debugfs_dir; >> >> /* >> * sysfs stuff >> @@ -1118,6 +1120,8 @@ static int __init videodev_init(void) >> return -EIO; >> } >> >> + v4l2_debugfs_dir = debugfs_create_dir("video4linux", NULL); >> + v4l2_async_debug_init(v4l2_debugfs_dir); >> return 0; >> } >> >> @@ -1125,6 +1129,7 @@ static void __exit videodev_exit(void) >> { >> dev_t dev = MKDEV(VIDEO_MAJOR, 0); >> >> + debugfs_remove_recursive(v4l2_debugfs_dir); >> class_unregister(&video_class); >> unregister_chrdev_region(dev, VIDEO_NUM_DEVICES); >> } >> diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h >> index 0e04b5b2ebb0..243ac10a53c6 100644 >> --- a/include/media/v4l2-async.h >> +++ b/include/media/v4l2-async.h >> @@ -11,6 +11,7 @@ >> #include >> #include >> >> +struct dentry; >> struct device; >> struct device_node; >> struct v4l2_device; >> @@ -137,6 +138,13 @@ struct v4l2_async_notifier { >> struct list_head list; >> }; >> >> +/** >> + * v4l2_async_debug_init - Initialize debugging tools. >> + * >> + * @debugfs_dir: pointer to the parent debugfs &struct dentry >> + */ >> +void v4l2_async_debug_init(struct dentry *debugfs_dir); >> + >> /** >> * v4l2_async_notifier_init - Initialize a notifier. >> * >> >