public inbox for linux-rockchip@lists.infradead.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Paul Elder <paul.elder@ideasonboard.com>,
	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 <dafna@fastmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	"moderated list:ARM/Rockchip SoC support"
	<linux-arm-kernel@lists.infradead.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 4/4] media: rkisp1: debug: Consolidate counter debugfs files
Date: Tue, 5 Dec 2023 10:22:47 +0200	[thread overview]
Message-ID: <212f4a89-7135-41ca-9638-b36a474b1bfa@ideasonboard.com> (raw)
In-Reply-To: <20231201140433.2126011-5-paul.elder@ideasonboard.com>

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 <paul.elder@ideasonboard.com>
> 
> ---
> 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);
>   


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

  parent reply	other threads:[~2023-12-05  8:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01 14:04 [PATCH v2 0/4] media: rkisp1: Misc fixes and debug Paul Elder
2023-12-01 14:04 ` [PATCH v2 1/4] media: rkisp1: regs: Consolidate MI interrupt wrap fields Paul Elder
2023-12-01 14:04 ` [PATCH v2 2/4] media: rkisp1: debug: Add register dump for IS Paul Elder
2023-12-01 14:04 ` [PATCH v2 3/4] media: rkisp1: debug: Count completed frame interrupts Paul Elder
2023-12-01 14:04 ` [PATCH v2 4/4] media: rkisp1: debug: Consolidate counter debugfs files Paul Elder
2023-12-01 15:30   ` Kieran Bingham
2023-12-05  8:22   ` Tomi Valkeinen [this message]
2023-12-07 14:50     ` Laurent Pinchart
2023-12-05  8:23 ` [PATCH v2 0/4] media: rkisp1: Misc fixes and debug Tomi Valkeinen
2023-12-07 14:51 ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=212f4a89-7135-41ca-9638-b36a474b1bfa@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=dafna@fastmail.com \
    --cc=heiko@sntech.de \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=paul.elder@ideasonboard.com \
    --cc=umang.jain@ideasonboard.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox