Re: [PATCH v2] soc: qcom: geni-se: Use HW PROG_RAM_DEPTH to validate firmware size

From: Mukesh Savaliya

Date: Thu Jul 02 2026 - 01:50:08 EST




On 7/1/2026 9:51 AM, Viken Dadhaniya wrote:
The hardcoded MAX_GENI_CFG_RAMn_CNT limit is not accurate for all SoCs:
SOCs ?
some targets have less CFG RAM than the constant implies, while others
like QCS615 need more entries than the old limit of 455 allowed, causing
valid firmware to be rejected at load time.

Rather than hardcoding a constant, read PROG_RAM_DEPTH from SE_HW_PARAM_2
at runtime to get the actual CFG RAM depth of the hardware instance and
use that as the upper bound for firmware size validation.

Fixes: d4bf06592ad6 ("soc: qcom: geni-se: Add support to load QUP SE Firmware via Linux subsystem")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Viken Dadhaniya <viken.dadhaniya@xxxxxxxxxxxxxxxx>
---
Changes in v2:
- Replace hardcoded MAX_GENI_CFG_RAMn_CNT with runtime read of
PROG_RAM_DEPTH from SE_HW_PARAM_2 for per-SoC accuracy
- Link to v1: https://patch.msgid.link/20260522-qup-se-increase-ram-cnt-v1-1-71854d0b2ef0@xxxxxxxxxxxxxxxx
---
drivers/soc/qcom/qcom-geni-se.c | 23 +++++++++++++----------
include/linux/soc/qcom/geni-se.h | 4 ++++
2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index cd1779b6a91a..87907f559bd4 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c

[...]

@@ -1066,10 +1067,12 @@ static struct se_fw_hdr *geni_find_protocol_fw(struct device *dev, const struct
sefw->fw_size_in_items = cpu_to_le16(fw_size);
}
- if (fw_size >= MAX_GENI_CFG_RAMn_CNT) {
+ prog_ram_depth = FIELD_GET(PROG_RAM_DEPTH_MSK,
+ readl_relaxed(se->base + SE_HW_PARAM_2));
+ if (fw_size >= prog_ram_depth) {
dev_err(dev,
- "Firmware size (%u) exceeds max allowed RAMn count (%u)\n",
- fw_size, MAX_GENI_CFG_RAMn_CNT);
+ "Firmware size (%u) exceeds HW PROG_RAM_DEPTH (%u)\n",
Actual programmable FW memory ? something which is readable instead of same macro.
+ fw_size, prog_ram_depth);
continue;
}

[...]