Re: [PATCH v2 2/3] soc: qcom: cmd-db: add reverse address-to-name lookup
From: Dmitry Baryshkov
Date: Thu Aug 06 2026 - 05:59:13 EST
On Fri, Jul 17, 2026 at 01:19:43PM +0530, Maulik Shah wrote:
> RPMh resource addresses are opaque 32-bit values. While the slave ID
> in bits [19:16] identifies the accelerator type (ARC/VRM/BCM), the
> lower bits encode a resource index that is only meaningful when mapped
> back to the human-readable resource name stored in the command DB
> (e.g. 0x30000 -> cx.lvl).
>
> Add cmd_db_read_name() to perform this reverse lookup by iterating
> the command DB entries and matching on address. Unlike other exported
> cmd-db APIs which go through cmd_db_get_header() (which calls
> cmd_db_ready() internally), this function iterates cmd_db_header
> directly for address matching, so it calls cmd_db_ready() itself.
>
> For VRM resources,
> which have up to 4 contiguous 4-byte-aligned addresses per resource,
> the match uses VRM_ADDR() on bits [19:4] so that any sub-address
> (enable, voltage, mode, headroom) resolves to the same resource name.
>
> Also export CMD_DB_ID_SIZE so callers can size their name buffers
> correctly without open-coding the magic constant 8.
>
> Assisted-by: Claude:claude-sonnet-4-5
> Signed-off-by: Maulik Shah <maulik.shah@xxxxxxxxxxxxxxxx>
> ---
> drivers/soc/qcom/cmd-db.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> include/soc/qcom/cmd-db.h | 5 +++++
> 2 files changed, 50 insertions(+)
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxxxxxxxx>
--
With best wishes
Dmitry