Re: [PATCH v3 3/5] firmware: arm_scmi: Track basic SCMI statistics

From: Luke Parkin
Date: Wed Jul 24 2024 - 10:40:28 EST


>> @@ -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...

Yeah, I had the same thoughts and came to the same conclusion. As far as I could
determine there weren't enough scmi_bad_message_trace()'s to warrant the extra
complexity (both code and processing) of centralising it.

Thanks,
Luke