Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1705423rdb; Thu, 7 Dec 2023 06:50:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgQUFmwMcPM5kSAKMUHbfpFqsBvkxfjx7gPXM+J2O1W0WtNIpF2VD3YOHJWCsAANTah6NW X-Received: by 2002:a05:6a20:840e:b0:18f:c861:a2e6 with SMTP id c14-20020a056a20840e00b0018fc861a2e6mr2943829pzd.11.1701960622941; Thu, 07 Dec 2023 06:50:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701960622; cv=none; d=google.com; s=arc-20160816; b=K8kcStkVYvtvnYybJr3ukFGHTfHDScfjDN4W8OOEjU0M1P11VOKMxsv/xGlTHMHSAI aAjhYf+G5IRlRlC5aZdL2xNro4aAcP1GfCOHI+MImz0NXKedhBHi+PWAXVO6yw1bY0oz 8W4tumxkIOiKAwzrbp8HQSu3qAaf8UxRtqMztuBnrWYlMysqLCJq8mzSHvcQQhyEYz9z THIuewIMMEaIab/4V3N4szeARsmwj0FH5BadD/Kp9cpdVDV2okcqsJsWnhZNvERJPvPc yk+AIMd+GlvEfiGStVBmsGNChAHd7PdBFSaSdsOj/h3NSeGP1NX3QFZafl4OvB2VCFbY +m7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3KCUaM/OyAYSi7SI9KR2C8Pnv5DLKz1ypRtq0WCdL4w=; fh=CKny6b6uyBGlJD+tM0fjZMQ+tgctOFCOfgQwArBZACY=; b=nL+GPGijQsl5uW+7+TEoHP8/F7hqcgcEA3mn1XtbOmPPwXSrcpVE2k2zIJiP9qRHDT AsrCe16R28AsHlgJ2cxwe8nH2HNyeM6uE/OW5mx2omY6Arm9lLyt8cuHl9s8wcsk5DII ci91MDwI5gW91RMfQRX9BLOmosULNFConoFNyI758x+zuqgr3cTdI6Ur0tdnmQ4j89Td 06avieMswfMM103CZKeozaoknAJx9AxiHIDn8zYwIJSyXg6yzr/Y7exSwXlCG0cutYUt 9gZajgRYd4KXXmrUeVW0AbC3TWTV+yJfz8ajGc/BNJbrwXdj88qfCIfTRyrFy+uh9Z4V uzTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="gzn/ktV8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x1-20020a654541000000b005c660017567si1335483pgr.575.2023.12.07.06.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 06:50:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="gzn/ktV8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id AD2D8805ECC8; Thu, 7 Dec 2023 06:50:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443411AbjLGOuL (ORCPT + 99 others); Thu, 7 Dec 2023 09:50:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443322AbjLGOuK (ORCPT ); Thu, 7 Dec 2023 09:50:10 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C334A3; Thu, 7 Dec 2023 06:50:16 -0800 (PST) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C1A2E669; Thu, 7 Dec 2023 15:49:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1701960573; bh=QfL+DyjnH2mbd8VhT7qHNaAo5w/cbC+KvSpbO0ms4X0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gzn/ktV8n8uDqghsnJFY8NR5nRWuw1ONK6jr5GHs9hfwnpNUx0fUOGMroyxLkJG/Q l7JkhJhNGL3wxPgj7x7NQgJWLyBroOCVasgl/93zEKVXWV6xaB16QbRk5szWgm4JSo I66kml3giqg7k3UnXRnfOVbTJCfxwRxMMZ+yV3JU= Date: Thu, 7 Dec 2023 16:50:20 +0200 From: Laurent Pinchart To: Tomi Valkeinen Cc: Paul Elder , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, kieran.bingham@ideasonboard.com, umang.jain@ideasonboard.com, Dafna Hirschfeld , Mauro Carvalho Chehab , Heiko Stuebner , "moderated list:ARM/Rockchip SoC support" , open list Subject: Re: [PATCH v2 4/4] media: rkisp1: debug: Consolidate counter debugfs files Message-ID: <20231207145020.GA17373@pendragon.ideasonboard.com> References: <20231201140433.2126011-1-paul.elder@ideasonboard.com> <20231201140433.2126011-5-paul.elder@ideasonboard.com> <212f4a89-7135-41ca-9638-b36a474b1bfa@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <212f4a89-7135-41ca-9638-b36a474b1bfa@ideasonboard.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 06:50:21 -0800 (PST) On Tue, Dec 05, 2023 at 10:22:47AM +0200, Tomi Valkeinen wrote: > 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. Wouldn't it be nicer to avoid constructing this on the stack for every call ? We could store the counters in an array: enum rkisp1_debug_counter { RKISP1_DBG_COUNT_DATA_LOSS, ... RKISP1_DBG_COUNT_FRAME_DROP_MP, RKISP1_DBG_COUNT_FRAME_DROP_SP, RKISP1_DBG_COUNT_MAX, }; struct rksisp1_debug { struct dentry *debugfs_dir; unsigned long counters[RKISP1_DBG_COUNT_MAX]; }; The counters[] array above would become a static const char * const counter_names[] = { [RKISP1_DBG_COUNT_DATA_LOSS] = "data_loss", ... }; > > + 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); > > -- Regards, Laurent Pinchart