Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85B743E9C12 for ; Sun, 13 Sep 2026 12:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789304114; cv=none; b=I+/t6C+xDskII/IrAggzwEQXqC0MH69JnJJpUu20VG32+t28dTcnOOGCgjMxEYUQIFjMNyI76T9I9yQEQj4RgorAbq7BeP+Y0rqEn3AAFHJQUExwUrDd85J/Kq6ybcI+RS0lWr4iwbxoww0uLX16aUUKB3QugnRY4Q7oECkKfqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789304114; c=relaxed/simple; bh=b4WvXQ0COzU5NuxznFesN5SzpLiS/QR0/NbsHm44HGs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Cj/0p/CJTlxGm+ENjD1KbkQvxJkVNvHLNV1EM1ByIjvkQ3K8Db+WE0+b2LHIiBLF4Gx44yN8qXhbWQGGoFjnF/AyauU5GD8PTny0U3embsdgY/fpF4t+Fr3zaPMQi6M9GS3/7Z/R5M17YQdqKM0zEWzm9Zyvg/n4090F+UGWR5Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=SC2PsqHH; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=YPSLC6sl; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="SC2PsqHH"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="YPSLC6sl" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68DAUXI91005585 for ; Sun, 13 Sep 2026 12:55:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= P0hFYEAWjOWGQHPFsazn/kZWAVEinVYrYfd3wwodbro=; b=SC2PsqHHnLaMuvwf PLmaSh6zSDYpZWaf9obxxFU+qkQlMCbWy37qkvj8pfgZ8sUNC76bCx84R//pAemE bkqh7BafYiQCk7ApDaw1U1bQ0bnF3WmnlSjyOoRHF5aWHtEr8MX7sbfK7EnSJ8HL Wk7IFDdSctVginJEPy35LcyuXjnzJAGzQFgGTb0WMm8Me2HLdTHUzBcAHlY5Xbwi H33k5ruhDsGZjMPFQjc3cdDRvrU67nwEPKMWZt+lahMR5Wfxodr8CpQfjZn79tgl 8qjOtkD8prwBnPG1qJ4xq3/w7df4q+pvlR5/5ayOg+kyaiX62syUzuN9QsrJB/dE OK/ivg== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gmygd39wy-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sun, 13 Sep 2026 12:55:11 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2ccb687f82eso32322585ad.3 for ; Sun, 13 Sep 2026 05:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1789304111; x=1789908911; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=P0hFYEAWjOWGQHPFsazn/kZWAVEinVYrYfd3wwodbro=; b=YPSLC6slC/hk2avEjT+f5avIuDW/iPKymxxev+C5HAKcRQFzWJZUkYvxJP/efp0k73 /h0sdFEgsi3ZdbkJr+D4D4JW+qUKRg0eRHy7DBp6BUeaVLOpT+DNbM1jnZuajtOdsnEK fwx2gB4LR11rcIrazLsF7kH7NsD6MwWgyKy1FR+1pF8NbZHWjXmpuytQF1SzUQi5EEa9 2rXqvbTWSsz9Seu89oMyICbiEZ3g4avLjhoI9dCJvnZOSFm20TF9NL56hEqknVBUJcOE +BDWqXR97ehCISTIm2zBKboaIQhfSvivhxg3XOV3mIJUCucNQJTGkzBzh5KPvvy6K7H/ Nf0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789304111; x=1789908911; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=P0hFYEAWjOWGQHPFsazn/kZWAVEinVYrYfd3wwodbro=; b=Q7uvyF2I/zhkVKUJxVib8k8Jyz9dBPNrOxXfZCvW+zTv/4HnXkERIwhcm9Il3+pkT3 HxhorXbbTYEEaYonvkij8o3R7r01wJqoLSi8YGqte14U/1eNgtVA9xukHLQWHGXziq1E ZFFbvSyOs/HD2X4lzXL6M0WNfDofwnNE282iSZ5ejWo90cG5CAQmlKSHxsyfP0te80ri rSveSPDGjdWlz3B//mvHJl7G+FJwsR2xvW8YRUt+4HagvmBf9A6vGoYHiOkrJDWpmZlc gUafgzIBX+j6vLwZ9RhBNj3TBWS63erGLUx8BDBbztPe32XD1yR33FDmsjydjebpHIiE Q0vA== X-Gm-Message-State: AFuF++moemfp4SD3xvXU4i/WVpu0pVV8NivKNDUzLFT9nYSd8RK24Jv7 Q2Hc35Adbzlk/aFzpRw433s1SmwJcGTalM/m7Uuj/sOeR42FWbfsqbJDdhQXVIEcibg74dJ3SC0 spNZhKGj7svAbTpWnc0KYe4t0ZKR0PuQBP8MPB/mBR1EsKnx+syRqMWimTXIeP0JRsh3EBcLxKr Ya X-Gm-Gg: AYBFou0b26MdHch+zrI9AZpfBdzP/ZqEUujGdjFeHigbWl00nVduNh3srzoBiy2j9rc ONb78wSKizvj/ecKez6Tu+/IAewg+te5QAMG17u/LFUhUhu/Ih2BlxoFH5wuD8+Qbxy79JwmC6a RwKadzKtmdAg9uMxXj85YQMa14opEX0fyHSSQcIBo8RzM7ifvpbzXkG15rfx3BjoKEUlgp5q6pz oZb6CikZQg65VCqMhcfkEpocf4VxltFSpkfknGN1F/I1wAGBuRTtu73IKzRQHcJSj79JCAKtv+K unyfYFvA2h9/B2eK9YeD+Jx+vrYYLYmuzMMfKZQVjEhyfoHHS9NTJotRnECIkE1Jpq2AA4sjJbs 3JPUjTHkEf6JaehRI0Z8Us+qkfBB7 X-Received: by 2002:a17:90b:4b0e:b0:398:bee5:61d6 with SMTP id 98e67ed59e1d1-39dbc725258mr12039427a91.24.1789304111047; Sun, 13 Sep 2026 05:55:11 -0700 (PDT) X-Received: by 2002:a17:90b:4b0e:b0:398:bee5:61d6 with SMTP id 98e67ed59e1d1-39dbc725258mr12039378a91.24.1789304110584; Sun, 13 Sep 2026 05:55:10 -0700 (PDT) Received: from hu-mkshah-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-14365a598aasm18027211c88.1.2026.09.13.05.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Sep 2026 05:55:10 -0700 (PDT) From: Maulik Shah Date: Sun, 13 Sep 2026 18:24:24 +0530 Subject: [PATCH v4 2/3] soc: qcom: cmd-db: add reverse address-to-name lookup Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260913-rpmh-timeout-debug-v1-v4-2-e94d3e416ea1@oss.qualcomm.com> References: <20260913-rpmh-timeout-debug-v1-v4-0-e94d3e416ea1@oss.qualcomm.com> In-Reply-To: <20260913-rpmh-timeout-debug-v1-v4-0-e94d3e416ea1@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio , Abel Vesa Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Maulik Shah , Dmitry Baryshkov , Navya Malempati , Konrad Dybcio X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1789304099; l=4138; i=maulik.shah@oss.qualcomm.com; s=20240109; h=from:subject:message-id; bh=b4WvXQ0COzU5NuxznFesN5SzpLiS/QR0/NbsHm44HGs=; b=Cc5Sja+aTPwWi65l/aZyiEwZjmyztQcVSGwtmcgkx9mRbWt6IXaagbCcjjCvjgIV94TfXpL9H mGFMMVmIgO3BTD/wrsrSop+MJHQzvvoOLhpwezfFvl4JettIP6Sirf+ X-Developer-Key: i=maulik.shah@oss.qualcomm.com; a=ed25519; pk=bd9h5FIIliUddIk8p3BlQWBlzKEQ/YW5V+fe759hTWQ= X-Authority-Analysis: v=2.4 cv=RY0FmFtv c=1 sm=1 tr=0 ts=6aa69d2f cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=7Q9v_upN9S1qH8PsicYA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTEzMDE4NCBTYWx0ZWRfX3JKfFIId0zkY sxH3jX/PALLwmMBDMYtdYqXdgvmIdbchYhxa1/vmWE1e7QEiLnEMickkVwDYmqCRVtOErQEdOKg 2KlfyP5/I67IjdI7eCKako6Zus8Jvn76mrBPBYh1UYbsl5PD16Xm+p4Y2LugvF0Db+WpDxTTIFB 6uU8t++76rBkFU6GdAl5k1T5sQjv4co0lg4K4sd5W9bKn9FMJ7F5PQR+e2gdIg04VdPFrKZOgyW sKABDUoPh4AGbvjoIJ2d/d1lQWX53E3NSnC27/JGTmUzmR0wYWJXorw8aY6+l66kCiQn1Ue7J7G cKnnPHshXJWzxZ9EBwpbYPdwyQUpGDdgBze/HsYAJ1aUEwPplzeGYV7cyYbNwktlEl7acgoLfA6 oC53FrTxmWIXH6STCs2rGevmookjYIUpXU2uIkhqflH2s8MWXg2cUK+rWJCj7tf9kGS7d3vBnMu 0cimNsdJqz2UwgSdPrQ== X-Proofpoint-ORIG-GUID: j9wdI-I-NsxpP3c-dbMolSOaEq1mB2iy X-Proofpoint-Spam-Info: AW1haW4tMjYwOTEzMDE4NCBTYWx0ZWRfX97aMCXjGRgSo 6uO2BQxXkaQShlfw5Bpoz6YbwhYueuQzP1ZhlokJvtAjDgGEXCiNAed9ou3cOKb2L3bka/3EdV+ V/LsL1tUEWgRpynchAP9Bs33luZpjds= X-Proofpoint-GUID: j9wdI-I-NsxpP3c-dbMolSOaEq1mB2iy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-13_04,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 spamscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 malwarescore=0 bulkscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609130184 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 Reviewed-by: Dmitry Baryshkov Reviewed-by: Navya Malempati Reviewed-by: Konrad Dybcio Signed-off-by: Maulik Shah --- drivers/soc/qcom/cmd-db.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/soc/qcom/cmd-db.h | 5 +++++ 2 files changed, 50 insertions(+) diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c index 117f810d5ca4..e1453b194aa3 100644 --- a/drivers/soc/qcom/cmd-db.c +++ b/drivers/soc/qcom/cmd-db.c @@ -287,6 +287,51 @@ const char *cmd_db_hw_type_str(u32 addr) } EXPORT_SYMBOL_GPL(cmd_db_hw_type_str); +/** + * cmd_db_read_name() - Look up the resource name for a given RPMh address. + * @addr: RPMh resource address to reverse-look up. + * @buf: Output buffer to write the resource name into. + * @len: Size of @buf; must be at least CMD_DB_ID_SIZE + 1. + * + * Iterates the command DB to find the entry whose address matches @addr. + * For VRM resources, which have up to 4 contiguous 4-byte-aligned addresses + * per resource, the match is performed on bits [19:4] so that any of the + * sub-addresses resolve to the same resource name. + * + * Return: 0 on success, -ENODEV if not found or DB not ready. + */ +int cmd_db_read_name(u32 addr, char *buf, size_t len) +{ + const struct rsc_hdr *rsc_hdr; + const struct entry_header *ent; + int ret, i, j; + + ret = cmd_db_ready(); + if (ret) + return ret; + + for (i = 0; i < MAX_SLV_ID; i++) { + rsc_hdr = &cmd_db_header->header[i]; + if (!rsc_hdr->slv_id) + break; + + ent = rsc_to_entry_header(rsc_hdr); + for (j = 0; j < le16_to_cpu(rsc_hdr->cnt); j++, ent++) { + u32 ent_addr = le32_to_cpu(ent->addr); + + if (cmd_db_match_resource_addr(ent_addr, addr)) { + snprintf(buf, len, "%.*s", + (int)strnlen(ent->id, sizeof(ent->id)), + ent->id); + return 0; + } + } + } + + return -ENODEV; +} +EXPORT_SYMBOL_GPL(cmd_db_read_name); + #ifdef CONFIG_DEBUG_FS static int cmd_db_debugfs_dump(struct seq_file *seq, void *p) { diff --git a/include/soc/qcom/cmd-db.h b/include/soc/qcom/cmd-db.h index 34adc04eac94..d03d64f3407d 100644 --- a/include/soc/qcom/cmd-db.h +++ b/include/soc/qcom/cmd-db.h @@ -9,6 +9,8 @@ #include +#define CMD_DB_ID_SIZE 8 + enum cmd_db_hw_type { CMD_DB_HW_INVALID = 0, CMD_DB_HW_MIN = 3, @@ -31,6 +33,7 @@ enum cmd_db_hw_type cmd_db_read_slave_id(const char *resource_id); int cmd_db_ready(void); const char *cmd_db_hw_type_str(u32 addr); +int cmd_db_read_name(u32 addr, char *buf, size_t len); #else static inline u32 cmd_db_read_addr(const char *resource_id) { return 0; } @@ -49,5 +52,7 @@ static inline int cmd_db_ready(void) static inline const char *cmd_db_hw_type_str(u32 addr) { return "unknown"; } +static inline int cmd_db_read_name(u32 addr, char *buf, size_t len) +{ return -ENODEV; } #endif /* CONFIG_QCOM_COMMAND_DB */ #endif /* __QCOM_COMMAND_DB_H__ */ -- 2.43.0