The QSPI controller has two interconnect paths:
1. qspi-config: CPU to QSPI controller for register access
2. qspi-memory: QSPI controller to memory for DMA operations
Currently, the driver only manages the qspi-config path. Add support for
the qspi-memory path to ensure proper bandwidth allocation for QSPI data
transfers to/from memory. Enable and disable both paths during runtime PM
transitions.
Signed-off-by: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>
---
drivers/spi/spi-qcom-qspi.c | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/drivers/spi/spi-qcom-qspi.c b/drivers/spi/spi-qcom-qspi.c
index 7e39038160e0..624b3a7b6291 100644
--- a/drivers/spi/spi-qcom-qspi.c
+++ b/drivers/spi/spi-qcom-qspi.c
@@ -174,6 +174,7 @@ struct qcom_qspi {
void *virt_cmd_desc[QSPI_MAX_SG];
unsigned int n_cmd_desc;
struct icc_path *icc_path_cpu_to_qspi;
+ struct icc_path *icc_path_mem;
unsigned long last_speed;
/* Lock to protect data accessed by IRQs */
spinlock_t lock;
@@ -272,7 +273,7 @@ static void qcom_qspi_handle_err(struct spi_controller *host,
static int qcom_qspi_set_speed(struct qcom_qspi *ctrl, unsigned long speed_hz)
{
int ret;
- unsigned int avg_bw_cpu;
+ unsigned int avg_bw_cpu, avg_bw_mem;
if (speed_hz == ctrl->last_speed)
return 0;
@@ -285,7 +286,7 @@ static int qcom_qspi_set_speed(struct qcom_qspi *ctrl, unsigned long speed_hz)
}
/*
- * Set BW quota for CPU.
+ * Set BW quota for CPU and memory paths.
* We don't have explicit peak requirement so keep it equal to avg_bw.
*/
avg_bw_cpu = Bps_to_icc(speed_hz);
@@ -296,6 +297,13 @@ static int qcom_qspi_set_speed(struct qcom_qspi *ctrl, unsigned long speed_hz)
return ret;
}
+ avg_bw_mem = Bps_to_icc(speed_hz);
+ ret = icc_set_bw(ctrl->icc_path_mem, avg_bw_mem, avg_bw_mem);
+ if (ret) {
+ dev_err(ctrl->dev, "ICC BW voting failed for memory: %d\n", ret);
+ return ret;
+ }
+
ctrl->last_speed = speed_hz;
return 0;
@@ -729,6 +737,11 @@ static int qcom_qspi_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(ctrl->icc_path_cpu_to_qspi),
"Failed to get cpu path\n");
+ ctrl->icc_path_mem = devm_of_icc_get(dev, "qspi-memory");
+ if (IS_ERR(ctrl->icc_path_mem))
+ return dev_err_probe(dev, PTR_ERR(ctrl->icc_path_mem),
+ "Failed to get memory path\n");
+
/* Set BW vote for register access */
ret = icc_set_bw(ctrl->icc_path_cpu_to_qspi, Bps_to_icc(1000),
Bps_to_icc(1000));
@@ -829,6 +842,13 @@ static int __maybe_unused qcom_qspi_runtime_suspend(struct device *dev)
return ret;
}
+ ret = icc_disable(ctrl->icc_path_mem);
+ if (ret) {
+ dev_err_ratelimited(ctrl->dev, "ICC disable failed for memory: %d\n", ret);
+ icc_enable(ctrl->icc_path_cpu_to_qspi);
+ return ret;
+ }
+
pinctrl_pm_select_sleep_state(dev);
return 0;
@@ -849,9 +869,19 @@ static int __maybe_unused qcom_qspi_runtime_resume(struct device *dev)
return ret;
}
+ ret = icc_enable(ctrl->icc_path_mem);
+ if (ret) {
+ dev_err_ratelimited(ctrl->dev, "ICC enable failed for memory: %d\n", ret);
+ icc_disable(ctrl->icc_path_cpu_to_qspi);
+ return ret;
+ }
+
ret = clk_bulk_prepare_enable(QSPI_NUM_CLKS, ctrl->clks);
- if (ret)
+ if (ret) {
+ icc_disable(ctrl->icc_path_cpu_to_qspi);
+ icc_disable(ctrl->icc_path_mem);
return ret;
+ }
return dev_pm_opp_set_rate(dev, ctrl->last_speed * 4);
}
--
2.34.1
On Tue, Mar 24, 2026 at 06:43:19PM +0530, Viken Dadhaniya wrote:
> @@ -829,6 +842,13 @@ static int __maybe_unused qcom_qspi_runtime_suspend(struct device *dev)
> return ret;
> }
>
> + ret = icc_disable(ctrl->icc_path_mem);
> + if (ret) {
> + dev_err_ratelimited(ctrl->dev, "ICC disable failed for memory: %d\n", ret);
> + icc_enable(ctrl->icc_path_cpu_to_qspi);
> + return ret;
> + }
> +
This reenables the ICC but not the clocks on error (which is a
preexisting bug with the error handling if the other ICC fails but
still...).
On 3/24/2026 9:54 PM, Mark Brown wrote:
> On Tue, Mar 24, 2026 at 06:43:19PM +0530, Viken Dadhaniya wrote:
>
>> @@ -829,6 +842,13 @@ static int __maybe_unused qcom_qspi_runtime_suspend(struct device *dev)
>> return ret;
>> }
>>
>> + ret = icc_disable(ctrl->icc_path_mem);
>> + if (ret) {
>> + dev_err_ratelimited(ctrl->dev, "ICC disable failed for memory: %d\n", ret);
>> + icc_enable(ctrl->icc_path_cpu_to_qspi);
>> + return ret;
>> + }
>> +
>
> This reenables the ICC but not the clocks on error (which is a
> preexisting bug with the error handling if the other ICC fails but
> still...).
I will add proper error handling in the runtime PM path in v2.
© 2016 - 2026 Red Hat, Inc.