From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 BC8BA376BD9 for ; Fri, 17 Jul 2026 07:50:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784274640; cv=none; b=nvzBt2itmIVtrTYHq7QCdlJp86XBeddG5ogxrvfue7eUdQYvLcIr5vKmHKjYpTIaJCPPaElaoN0rEadByRhIa4v/CUuc2Q3ua+DE34vlj46BqgfzPGU/oAKtkaMWy4MSt+qqkMLyyTugz1wFgrPK5c15x2kWBbPavmbmm90VZHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784274640; c=relaxed/simple; bh=RNrrExDB0crs+KWWfJaxcH+5XUSGEwzrOWOOZER1RgU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eYsf+5i9T4LWI9s2C2dbOYzJVbNAJkc7vpMGFge3pCXv+u4sHf4M7g4VjZ1zuxdEpUP5wXDW1x4yxfNszIAiYRbylyum/W2wmHNBQrlNTQx43bWtml/NRdEbQHD7tGIaR8RG2z2lwqOLYIcb0iu/GnqlGLJ9ZdtZnQY2scHNdMA= 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=Im3Ln7yl; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=GNa97OmJ; arc=none smtp.client-ip=205.220.180.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="Im3Ln7yl"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="GNa97OmJ" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66H6ciI91093126 for ; Fri, 17 Jul 2026 07:50:33 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= Z9ahLJd24WetNOKn8K9LuXS+j/spyO79ug8RcOxvsHI=; b=Im3Ln7ylHwcRdawX hVJjE5BaLEjbJD6XkHBvi4aoqmUQS2LzWqcBgJwi9Or3yYdEW44E/6tJsJh4hn/C eGj1hhD+nKCTZxZ0RXD5OBUc2/MyrKYCR7xzxQ7/P4aytgRB/mPprGzfFIktVeRq KP5SBLgmfspiKg9tYeWM2PaweLq/waomyHVASK1cgVH+907Mj76db5qPcywCQ/Ks Z5I9AVFvRwAc/eDAP9/EvaR6fAvTIuvl+j+IY9wI/2vAoTVg47OngUDeywesyzNx cnwSo8hoE7bnF9pj6b7u5NCtPzOGw2/QH0OkWWfgsr+RzjOZK6B5+fESgbLyTzQv R+/W1w== Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ffe0urk5r-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 17 Jul 2026 07:50:33 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-c8924f4d0a4so10793665a12.2 for ; Fri, 17 Jul 2026 00:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784274632; x=1784879432; 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=Z9ahLJd24WetNOKn8K9LuXS+j/spyO79ug8RcOxvsHI=; b=GNa97OmJq2GSS9lhS1LWjnjMgbRKH8Z0o/AIyGvNwU9Wu9rDGIXqU89M/gvtgg7VPA XQha5E4an5jy3z+tb4RbEEm87t1qtzUAwK+5FNqgABZuK4jMzMZd67Ol3phg7lrY10lZ UI3sgBBjGKO0WDZ9A7tGa/Qds2Pw50rC35AFny6V04nKyzf/GddUmMHBWVBUaKeLVZs5 PGzx6YKQvJHgHIidrXT2eGwBUA/+y4zwW/ezLzK9YcaN7iIdd0XgMYPFztzqL8kUxkQJ +zsPxS0Ce9NJ2lMkE/vxxIrKIexyxTjO/CetGsuyn2QPuz2oQEIMYkPoWW2Q4y6cBXV+ yy8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784274632; x=1784879432; 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=Z9ahLJd24WetNOKn8K9LuXS+j/spyO79ug8RcOxvsHI=; b=XewCoh5z5uQyIqiYysev8IV9TNHiDnZAxdFb88q5BjRDYRlu6kAkK1TSAf5H8ghJwz mTCTK9cHerEmUPYe5zdNLq/qiNF4Ijq1X/Wbn95w3fBoQL1Na9+L7OGhn7f+n7FUaXeJ wZUBvaGy1RogLI4YfrHPzp6TuhsHyQwOymNx8nhSANqCaAFr/Q8vVCjDO9yWpHNzYuz3 h2m1b9s4FqQ/g5ZrcaFQe6P8YCmy9XLjxLDhl2p5B/Z1P6yyAzSD7OfC8j0qrY1tF3ZP c+wr0dLPZSRagDWykJEJO+JMfFOGUJ9VHm5bXorTjD8FNq6TwQwXHe6nn7uFJEGgE356 aRlQ== X-Forwarded-Encrypted: i=1; AHgh+RpEHs353LsCfU1CarQEmHbi2zZlBEnmXYhh+oNeXWNlpVxz/asl0+eaEGBPRDQrdeHWOyTXFj5mxfoqrNk=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1EjR+ITIrq9UnkvdQk7OSPfsDpZ3+xxOcDSFcR5ktIfNT0sad zsHLdzaulXc/5x3SmJhmd/slnv1cvocGmgehtBkdFpspTjwkTMJFlcLmtFN+E6o3iq2mnf/UFed BDVzshFqHEF8YQoRlV5hqZNR8MpHcr3X9sBHGYooTQceS7Bvg5Aowlz9TLYRGH4k4ti1UPLYh0I s= X-Gm-Gg: AfdE7ckOZo9I2wKlqWWHoDNr2iF+BfCs0ErCvvqe7dyLgctkLu3AP5dVY8xJvT2xpsA xR7JkYykkVRU3s8mXBHfrF7TyddDvMrDzUAvvU9E52xX9FAi9z9IckoU4oMBS1I3i9G3yabpSJe z2eQ/fbid0hCMMchnTfceuPlu+htVIQn4YeXpjVDNN6bKNVc0qyuPhsf9Ac2GP5gMOVZ9A8XO0B cEydex1YlUHl0NUODAOPns8/a9Li5Ai5HQ7hKtOqO+Ert/FPhcv53l9cRGr7dr62POearRF3TR1 A9MHdoMc87n9bzSGe8dsderyMLH20ya8yb8N5iZNcdZtWlURAPCzLzGwpgksVJ8yQWhjPzCqux2 mzXuwwWC4dHpjV0GPhlwBo4yu7GtE X-Received: by 2002:a05:6a20:9397:b0:3bf:6c08:fb94 with SMTP id adf61e73a8af0-3c3ada37416mr1635799637.54.1784274632172; Fri, 17 Jul 2026 00:50:32 -0700 (PDT) X-Received: by 2002:a05:6a20:9397:b0:3bf:6c08:fb94 with SMTP id adf61e73a8af0-3c3ada37416mr1635768637.54.1784274631685; Fri, 17 Jul 2026 00:50:31 -0700 (PDT) Received: from hu-mkshah-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cb517f8f223sm449323a12.9.2026.07.17.00.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2026 00:50:31 -0700 (PDT) From: Maulik Shah Date: Fri, 17 Jul 2026 13:19:43 +0530 Subject: [PATCH v2 2/3] soc: qcom: cmd-db: add reverse address-to-name lookup Precedence: bulk X-Mailing-List: linux-kernel@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: <20260717-rpmh-timeout-debug-v1-v2-2-81ade4fcdb49@oss.qualcomm.com> References: <20260717-rpmh-timeout-debug-v1-v2-0-81ade4fcdb49@oss.qualcomm.com> In-Reply-To: <20260717-rpmh-timeout-debug-v1-v2-0-81ade4fcdb49@oss.qualcomm.com> To: Bjorn Andersson , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Maulik Shah X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784274624; l=3945; i=maulik.shah@oss.qualcomm.com; s=20240109; h=from:subject:message-id; bh=RNrrExDB0crs+KWWfJaxcH+5XUSGEwzrOWOOZER1RgU=; b=irz6cUlYq/G1EhiVAhtIkb7QKbkMRxvSwCNYQK/+r9ATKC6bj+sCcnQIWd6ak2ktDhbLkqS1s qmpef3WCBPzBd4+HbaLC3IGLosM5B/6imcb/P5xJpkTkkMe/Yilwdac X-Developer-Key: i=maulik.shah@oss.qualcomm.com; a=ed25519; pk=bd9h5FIIliUddIk8p3BlQWBlzKEQ/YW5V+fe759hTWQ= X-Authority-Analysis: v=2.4 cv=deWwG3Xe c=1 sm=1 tr=0 ts=6a59dec9 cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=1a8ZsbFLG5WLaQwJOl4A:9 a=QEXdDO2ut3YA:10 a=bFCP_H2QrGi7Okbo017w:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE3MDA3NiBTYWx0ZWRfX2MauMhW1SdfY 0TikEpipENrf0LNEmtZyD8dLJu6tbOBnm9Jh6Sd4WrXbHT171al4DK/DQCv64pQldqv0Bw6NEpT P6YG9cUlwT4E+v4IB7ugTJKAnwW+1DzDttDQ6yKiSFwH69iKqLwjYEmdNO+FJJA0E8cY5Nk+GRs dKVrxGnv9BfH0Do5sK+ehA2gUwoTTGHg0N6h/zGwSE2RsilS9+21CiCi1U/qlTB50pnGiGPCkJV i25xsZ73iDICKACGsqkDtoxX+bPwFJck2VowAOre/GafgC3oyOL5z4QtPewGDbmwwd4f2+haxgB b6ilvEN7EcufQV7O9JGo+0HKI8AUtzEnm6qseIEHpIJ8KUL8kMVyPnpbWpZf+lWY5hGCWGt3rQp 7dn5G6wj6jBo9UJ+POTPO0ooRfJIGnRuwAcflcVeWg4B0lpsCyz5JwHucOmWho3gOgSts1HI9QE WoqzxQulPOhtKuza+vQ== X-Proofpoint-ORIG-GUID: kT2lyvgXqudHrKIYjlhjzP0kOF1BCQUk X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE3MDA3NiBTYWx0ZWRfX87mp3UBZVit9 6s9aN3kHXHyFy+k8uGsZRWZ7Xfwg45TFWC+D+TpL1UZxCtSsMNoCvFi/QlEiwYAjKYdmFtcWlle acUdUDlDeYQ0YvWp97MDROEoffftHCg= X-Proofpoint-GUID: kT2lyvgXqudHrKIYjlhjzP0kOF1BCQUk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-17_02,2026-07-15_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 adultscore=0 phishscore=0 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607170076 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 --- 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