Re: [PATCH v3 3/5] firmware: arm_scmi: Track basic SCMI statistics
From: Cristian Marussi
Date: Wed Jul 24 2024 - 10:21:54 EST
On Mon, Jul 15, 2024 at 02:37:49PM +0100, Luke Parkin wrote:
> Add tracking of initial statistics
>
> Signed-off-by: Luke Parkin <luke.parkin@xxxxxxx>
> ---
> V2->V3
> Add more statistics
> Use new log_stats method.
> V1->V2
> Drop unneccesary atomic_set's
> Use new 'scmi_log_stats' to simplify incrementing of atomics
> Move scmi_log_stats to locations which mean no extra conditionals
> are needed
> ---
> drivers/firmware/arm_scmi/driver.c | 39 ++++++++++++++++++++++++++----
> 1 file changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 6edec6ec912d..b22f104cda36 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -126,6 +126,20 @@ struct scmi_debug_info {
> };
>
> enum debug_stat_counters {
> + SENT_OK,
> + SENT_FAIL,
> + SENT_FAIL_POLLING_UNSUPPORTED,
> + SENT_FAIL_CHANNEL_NOT_FOUND,
> + RESPONSE_OK,
> + NOTIF_OK,
> + DLYD_RESPONSE_OK,
> + XFERS_RESPONSE_TIMEOUT,
> + XFERS_RESPONSE_POLLED_TIMEOUT,
> + RESPONSE_POLLED_OK,
> + ERR_MSG_UNEXPECTED,
> + ERR_MSG_INVALID,
> + ERR_MSG_NOMEM,
> + ERR_PROTOCOL,
> LAST
> };
>
> @@ -994,6 +1008,7 @@ scmi_xfer_command_acquire(struct scmi_chan_info *cinfo, u32 msg_hdr)
> spin_unlock_irqrestore(&minfo->xfer_lock, flags);
>
> scmi_bad_message_trace(cinfo, msg_hdr, MSG_UNEXPECTED);
> + scmi_log_stats(info->dbg_stats, ERR_MSG_UNEXPECTED);
I'd be tempted to say why dont you wrap these scmi_log_stats() inside the
scmi_bad_message_trace() ... BUT in order to avoid an additional
conditional inside the scmi_bad_message_trace() you will need to somehow
remap the MSG_UNEXPECTED to ERR_MSG_UNEXPECTED inside scmi_bad_message_trace (lets say
with a local onstack array indexed by -err)...AND that would mean committing to keep
such mapping in-sync with the the above enum, so as to avoid that adding
a new definition into scmi_bad_msg BUT not to debug_stat_counters will
end up in a buffer overflow....so at the end probably better/safer to keep it
this way...
Thanks,
Cristian