Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp134103rdb; Tue, 5 Dec 2023 00:23:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWe5zIAcBIYwXS+K3lkCdRQGJx/ndBGuIydIzes5/ZNQQR2o753B6VItTiZxY5yOKChFGG X-Received: by 2002:a17:90a:d181:b0:286:6cc1:273 with SMTP id fu1-20020a17090ad18100b002866cc10273mr633022pjb.62.1701764592111; Tue, 05 Dec 2023 00:23:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701764592; cv=none; d=google.com; s=arc-20160816; b=CI8kk6G05N8icfIhFtPP491x5gqd8NEuPcjaq9ARBK382jAbiOFpQ3ZBgmcrbSsr64 vhIlRZBzurliIa0D0Qrtde/6qTn911rl0qHZg55fet+4F5pbJdt+FIGQRqWwk8EQas8O VZQUnyGmhxHNtHW5szGOEcU9er1A974bzZ24P2vIFUVXe9+S5hQHHvDVrwQ9GtfzsS4k Vk9g7wODrHI0NMXbSQ3D3OrLD1Z2nehMHJOjtl/niVORysSezfmCsby2DZZF6t3z7LQX sD/GWoNs4gXLYLwTP1lg82wy8s2X/BhggSSsyhXhLKTmsG2r972LCSsAoruJIkXVcnHB j8/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=/xTQDWabbOZC/33fkbyLicZJPD3WWtx9uXhcsCcs2g0=; fh=Ur8XmkWDAGjW9ELWEwmmWdnoq3CAlJnJ+6+mUUwoQRo=; b=c/TtQmWrzCOK9m1QP1luu7Y2ZG65XO+AGeGsPaY73W71fMYGhd2lEQuwFY0qSUrSX3 BLH+7VNKRIRFzIIYVvnVTH7gkjmtG7kZEeKtILEf/ySuOW7XIocYDYlX3WrGjWgKt4fp NejoHBuPXH874WKb3/DVkBW3xgVk05AWY88pViQxa/4lBHunjs+amkdiYqSALwE2o7KX SPR33D9Ua5EIfdJ0an66bwAUFK1P3zi3JLEf+q1MPPrCyGHeswcadCwpGI7BffzPY2On lSFipPlekgu/BZH+Nf9o3G2voIq0IasgRhzz/4IKPd9Mz4xAzyhZXE2vhGSnuTv5+izV 1GYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=fVcy5reb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id l11-20020a17090ac58b00b00286c168876asi2190058pjt.54.2023.12.05.00.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 00:23:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=fVcy5reb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E265B8028574; Tue, 5 Dec 2023 00:23:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344789AbjLEIWt (ORCPT + 99 others); Tue, 5 Dec 2023 03:22:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjLEIWs (ORCPT ); Tue, 5 Dec 2023 03:22:48 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1A7E138; Tue, 5 Dec 2023 00:22:52 -0800 (PST) Received: from [192.168.88.20] (91-158-149-209.elisa-laajakaista.fi [91.158.149.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5CEB34DB; Tue, 5 Dec 2023 09:22:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701764531; bh=Lh9y/UDPcpcgejbtvdp2SqZpH1oMeRlPkdcPPMctZeQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=fVcy5rebgdISrcgE3t8ShSmFOGgXvacSEi47L7DeLoE+z0cJleoHQ5vhDxix69Ezz 7+tqeab9fm0gaPPPrci13uL7fWQbvOeC4/8iHYhop39zerrGT9M+Ns2wjeyH7xyF1m qkqnhxXNXZtSd7C4pSD+eUmzzdbwzZiGwbJQ7FpA= Message-ID: <212f4a89-7135-41ca-9638-b36a474b1bfa@ideasonboard.com> Date: Tue, 5 Dec 2023 10:22:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 4/4] media: rkisp1: debug: Consolidate counter debugfs files Content-Language: en-US To: Paul Elder , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org Cc: laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com, umang.jain@ideasonboard.com, Dafna Hirschfeld , Mauro Carvalho Chehab , Heiko Stuebner , "moderated list:ARM/Rockchip SoC support" , open list References: <20231201140433.2126011-1-paul.elder@ideasonboard.com> <20231201140433.2126011-5-paul.elder@ideasonboard.com> From: Tomi Valkeinen Autocrypt: addr=tomi.valkeinen@ideasonboard.com; keydata= xsFNBE6ms0cBEACyizowecZqXfMZtnBniOieTuFdErHAUyxVgtmr0f5ZfIi9Z4l+uUN4Zdw2 wCEZjx3o0Z34diXBaMRJ3rAk9yB90UJAnLtb8A97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AO8eMAEQEAAcLBXwQYAQIACQUCTqazRwIbDAAKCRD6PaqMvJYe 9fA7EACS6exUedsBKmt4pT7nqXBcRsqm6YzT6DeCM8PWMTeaVGHiR4TnNFiT3otD5UpYQI7S suYxoTdHrrrBzdlKe5rUWpzoZkVK6p0s9OIvGzLT0lrb0HC9iNDWT3JgpYDnk4Z2mFi6tTbq xKMtpVFRA6FjviGDRsfkfoURZI51nf2RSAk/A8BEDDZ7lgJHskYoklSpwyrXhkp9FHGMaYII m9EKuUTX9JPDG2FTthCBrdsgWYPdJQvM+zscq09vFMQ9Fykbx5N8z/oFEUy3ACyPqW2oyfvU CH5WDpWBG0s5BALp1gBJPytIAd/pY/5ZdNoi0Cx3+Z7jaBFEyYJdWy1hGddpkgnMjyOfLI7B CFrdecTZbR5upjNSDvQ7RG85SnpYJTIin+SAUazAeA2nS6gTZzumgtdw8XmVXZwdBfF+ICof 92UkbYcYNbzWO/GHgsNT1WnM4sa9lwCSWH8Fw1o/3bX1VVPEsnESOfxkNdu+gAF5S6+I6n3a ueeIlwJl5CpT5l8RpoZXEOVtXYn8zzOJ7oGZYINRV9Pf8qKGLf3Dft7zKBP832I3PQjeok7F yjt+9S+KgSFSHP3Pa4E7lsSdWhSlHYNdG/czhoUkSCN09C0rEK93wxACx3vtxPLjXu6RptBw 3dRq7n+mQChEB1am0BueV1JZaBboIL0AGlSJkm23kw== In-Reply-To: <20231201140433.2126011-5-paul.elder@ideasonboard.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 05 Dec 2023 00:23:09 -0800 (PST) On 01/12/2023 16:04, Paul Elder wrote: > Consolidate all the debugfs files that were each a single counter into a > single "counters" file. > > While at it, reset the counters at stream on time to make it easier for > to interpret the values in userspace. > > Signed-off-by: Paul Elder > > --- > New in v2 > > .../platform/rockchip/rkisp1/rkisp1-capture.c | 2 + > .../platform/rockchip/rkisp1/rkisp1-common.h | 4 ++ > .../platform/rockchip/rkisp1/rkisp1-debug.c | 69 ++++++++++++------- > 3 files changed, 50 insertions(+), 25 deletions(-) > > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c > index c6d7e01c8949..67b2e94dfd67 100644 > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c > @@ -1030,6 +1030,8 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) > struct media_entity *entity = &cap->vnode.vdev.entity; > int ret; > > + rkisp1_debug_reset_counters(cap->rkisp1); > + > mutex_lock(&cap->rkisp1->stream_lock); > > ret = video_device_pipeline_start(&cap->vnode.vdev, &cap->rkisp1->pipe); > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h > index be69173958a4..789259fb304a 100644 > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h > @@ -599,9 +599,13 @@ int rkisp1_params_register(struct rkisp1_device *rkisp1); > void rkisp1_params_unregister(struct rkisp1_device *rkisp1); > > #if IS_ENABLED(CONFIG_DEBUG_FS) > +void rkisp1_debug_reset_counters(struct rkisp1_device *rkisp1); > void rkisp1_debug_init(struct rkisp1_device *rkisp1); > void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1); > #else > +static inline void rkisp1_debug_reset_counters(struct rkisp1_device *rkisp1) > +{ > +} > static inline void rkisp1_debug_init(struct rkisp1_device *rkisp1) > { > } > diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c > index 79cda589d935..4358ed1367ed 100644 > --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c > +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c > @@ -25,6 +25,11 @@ struct rkisp1_debug_register { > const char * const name; > }; > > +struct rkisp1_debug_counter { > + const char * const name; > + unsigned long *value; > +}; > + > #define RKISP1_DEBUG_REG(name) { RKISP1_CIF_##name, 0, #name } > #define RKISP1_DEBUG_SHD_REG(name) { \ > RKISP1_CIF_##name, RKISP1_CIF_##name##_SHD, #name \ > @@ -191,6 +196,43 @@ static int rkisp1_debug_input_status_show(struct seq_file *m, void *p) > } > DEFINE_SHOW_ATTRIBUTE(rkisp1_debug_input_status); > > +static int rkisp1_debug_counters_show(struct seq_file *m, void *p) > +{ > + struct rkisp1_device *rkisp1 = m->private; > + struct rkisp1_debug *debug = &rkisp1->debug; > + > + const struct rkisp1_debug_counter counters[] = { > + { "data_loss", &debug->data_loss }, > + { "outform_size_err", &debug->outform_size_error }, > + { "img_stabilization_size_error", &debug->img_stabilization_size_error }, > + { "inform_size_error", &debug->inform_size_error }, > + { "irq_delay", &debug->irq_delay }, > + { "mipi_error", &debug->mipi_error }, > + { "stats_error", &debug->stats_error }, > + { "mp_stop_timeout", &debug->stop_timeout[RKISP1_MAINPATH] }, > + { "sp_stop_timeout", &debug->stop_timeout[RKISP1_SELFPATH] }, > + { "mp_frame_drop", &debug->frame_drop[RKISP1_MAINPATH] }, > + { "sp_frame_drop", &debug->frame_drop[RKISP1_SELFPATH] }, > + { "complete_frames", &debug->complete_frames }, > + { /* Sentinel */ }, > + }; > + > + const struct rkisp1_debug_counter *counter = counters; > + > + for (; counter->name; ++counter) > + seq_printf(m, "%s: %lu\n", counter->name, *counter->value); > + You could also do: const struct { const char *name; unsigned long value; } counters[] = { { "data_loss", debug->data_loss }, { "outform_size_err", debug->outform_size_error }, { "img_stabilization_size_error", debug->img_stabilization_size_error }, { "inform_size_error", debug->inform_size_error }, { "irq_delay", debug->irq_delay }, { "mipi_error", debug->mipi_error }, { "stats_error", debug->stats_error }, { "mp_stop_timeout", debug->stop_timeout[RKISP1_MAINPATH] }, { "sp_stop_timeout", debug->stop_timeout[RKISP1_SELFPATH] }, { "mp_frame_drop", debug->frame_drop[RKISP1_MAINPATH] }, { "sp_frame_drop", debug->frame_drop[RKISP1_SELFPATH] }, { "complete_frames", debug->complete_frames }, }; for (unsigned int i = 0; i < ARRAY_SIZE(counters); ++i) seq_printf(m, "%s: %lu\n", counters[i].name, counters[i].value); Not a big difference, but this doesn't "leak" the struct used only inside the function, doesn't need the sentinel, and I don't see a reason to store pointers to values, instead of just storing the values. Tomi > + return 0; > +} > +DEFINE_SHOW_ATTRIBUTE(rkisp1_debug_counters); > + > +void rkisp1_debug_reset_counters(struct rkisp1_device *rkisp1) > +{ > + struct dentry *debugfs_dir = rkisp1->debug.debugfs_dir; > + memset(&rkisp1->debug, 0, sizeof(rkisp1->debug)); > + rkisp1->debug.debugfs_dir = debugfs_dir; > +} > + > void rkisp1_debug_init(struct rkisp1_device *rkisp1) > { > struct rkisp1_debug *debug = &rkisp1->debug; > @@ -198,31 +240,8 @@ void rkisp1_debug_init(struct rkisp1_device *rkisp1) > > debug->debugfs_dir = debugfs_create_dir(dev_name(rkisp1->dev), NULL); > > - debugfs_create_ulong("data_loss", 0444, debug->debugfs_dir, > - &debug->data_loss); > - debugfs_create_ulong("outform_size_err", 0444, debug->debugfs_dir, > - &debug->outform_size_error); > - debugfs_create_ulong("img_stabilization_size_error", 0444, > - debug->debugfs_dir, > - &debug->img_stabilization_size_error); > - debugfs_create_ulong("inform_size_error", 0444, debug->debugfs_dir, > - &debug->inform_size_error); > - debugfs_create_ulong("irq_delay", 0444, debug->debugfs_dir, > - &debug->irq_delay); > - debugfs_create_ulong("mipi_error", 0444, debug->debugfs_dir, > - &debug->mipi_error); > - debugfs_create_ulong("stats_error", 0444, debug->debugfs_dir, > - &debug->stats_error); > - debugfs_create_ulong("mp_stop_timeout", 0444, debug->debugfs_dir, > - &debug->stop_timeout[RKISP1_MAINPATH]); > - debugfs_create_ulong("sp_stop_timeout", 0444, debug->debugfs_dir, > - &debug->stop_timeout[RKISP1_SELFPATH]); > - debugfs_create_ulong("mp_frame_drop", 0444, debug->debugfs_dir, > - &debug->frame_drop[RKISP1_MAINPATH]); > - debugfs_create_ulong("sp_frame_drop", 0444, debug->debugfs_dir, > - &debug->frame_drop[RKISP1_SELFPATH]); > - debugfs_create_ulong("complete_frames", 0444, debug->debugfs_dir, > - &debug->complete_frames); > + debugfs_create_file("counters", 0444, debug->debugfs_dir, rkisp1, > + &rkisp1_debug_counters_fops); > debugfs_create_file("input_status", 0444, debug->debugfs_dir, rkisp1, > &rkisp1_debug_input_status_fops); >