Skip to content

Commit da9e6b1

Browse files
unnathi84andersson
authored andcommitted
firmware: qcom_scm: Add API to get waitqueue IRQ info
Bootloader and firmware for SM8650 and older chipsets expect node name as "qcom_scm", in order to patch the wait queue IRQ information. However, DeviceTree uses node name "scm" and this mismatch prevents firmware from correctly identifying waitqueue IRQ information. Waitqueue IRQ is used for signaling between secure and non-secure worlds. To resolve this, introduce qcom_scm_get_waitq_irq() that'll get the hardware IRQ number to be used from firmware instead of relying on data provided by devicetree, thereby bypassing the DeviceTree node name mismatch. This hardware IRQ number is converted to a Linux IRQ number using newly qcom_scm_fill_irq_fwspec_params(). This Linux IRQ number is then supplied to the threaded_irq call. Reviewed-by: Bartosz Golaszewski <brgl@kernel.org> Signed-off-by: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com> Reviewed-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Link: https://lore.kernel.org/r/20251217-multi_waitq_scm-v11-1-f21e50e792b8@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent 380f8a4 commit da9e6b1

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

drivers/firmware/qcom/qcom_scm.c

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,18 @@
3030
#include <linux/sizes.h>
3131
#include <linux/types.h>
3232

33+
#include <dt-bindings/interrupt-controller/arm-gic.h>
34+
3335
#include "qcom_scm.h"
3436
#include "qcom_tzmem.h"
3537

3638
static u32 download_mode;
3739

40+
#define GIC_SPI_BASE 32
41+
#define GIC_MAX_SPI 1019 // SPIs in GICv3 spec range from 32..1019
42+
#define GIC_ESPI_BASE 4096
43+
#define GIC_MAX_ESPI 5119 // ESPIs in GICv3 spec range from 4096..5119
44+
3845
struct qcom_scm {
3946
struct device *dev;
4047
struct clk *core_clk;
@@ -2209,6 +2216,56 @@ bool qcom_scm_is_available(void)
22092216
}
22102217
EXPORT_SYMBOL_GPL(qcom_scm_is_available);
22112218

2219+
static int qcom_scm_fill_irq_fwspec_params(struct irq_fwspec *fwspec, u32 hwirq)
2220+
{
2221+
if (hwirq >= GIC_SPI_BASE && hwirq <= GIC_MAX_SPI) {
2222+
fwspec->param[0] = GIC_SPI;
2223+
fwspec->param[1] = hwirq - GIC_SPI_BASE;
2224+
} else if (hwirq >= GIC_ESPI_BASE && hwirq <= GIC_MAX_ESPI) {
2225+
fwspec->param[0] = GIC_ESPI;
2226+
fwspec->param[1] = hwirq - GIC_ESPI_BASE;
2227+
} else {
2228+
WARN(1, "Unexpected hwirq: %d\n", hwirq);
2229+
return -ENXIO;
2230+
}
2231+
2232+
fwspec->param[2] = IRQ_TYPE_EDGE_RISING;
2233+
fwspec->param_count = 3;
2234+
2235+
return 0;
2236+
}
2237+
2238+
static int qcom_scm_get_waitq_irq(struct qcom_scm *scm)
2239+
{
2240+
struct qcom_scm_desc desc = {
2241+
.svc = QCOM_SCM_SVC_WAITQ,
2242+
.cmd = QCOM_SCM_WAITQ_GET_INFO,
2243+
.owner = ARM_SMCCC_OWNER_SIP
2244+
};
2245+
struct device_node *parent_irq_node;
2246+
struct irq_fwspec fwspec;
2247+
struct qcom_scm_res res;
2248+
u32 hwirq;
2249+
int ret;
2250+
2251+
ret = qcom_scm_call_atomic(scm->dev, &desc, &res);
2252+
if (ret)
2253+
return ret;
2254+
2255+
hwirq = res.result[1] & GENMASK(15, 0);
2256+
ret = qcom_scm_fill_irq_fwspec_params(&fwspec, hwirq);
2257+
if (ret)
2258+
return ret;
2259+
2260+
parent_irq_node = of_irq_find_parent(scm->dev->of_node);
2261+
if (!parent_irq_node)
2262+
return -ENODEV;
2263+
2264+
fwspec.fwnode = of_fwnode_handle(parent_irq_node);
2265+
2266+
return irq_create_fwspec_mapping(&fwspec);
2267+
}
2268+
22122269
static int qcom_scm_assert_valid_wq_ctx(u32 wq_ctx)
22132270
{
22142271
/* FW currently only supports a single wq_ctx (zero).
@@ -2382,7 +2439,10 @@ static int qcom_scm_probe(struct platform_device *pdev)
23822439
return dev_err_probe(scm->dev, PTR_ERR(scm->mempool),
23832440
"Failed to create the SCM memory pool\n");
23842441

2385-
irq = platform_get_irq_optional(pdev, 0);
2442+
irq = qcom_scm_get_waitq_irq(scm);
2443+
if (irq < 0)
2444+
irq = platform_get_irq_optional(pdev, 0);
2445+
23862446
if (irq < 0) {
23872447
if (irq != -ENXIO)
23882448
return irq;

drivers/firmware/qcom/qcom_scm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ int qcom_scm_shm_bridge_enable(struct device *scm_dev);
152152
#define QCOM_SCM_SVC_WAITQ 0x24
153153
#define QCOM_SCM_WAITQ_RESUME 0x02
154154
#define QCOM_SCM_WAITQ_GET_WQ_CTX 0x03
155+
#define QCOM_SCM_WAITQ_GET_INFO 0x04
155156

156157
#define QCOM_SCM_SVC_GPU 0x28
157158
#define QCOM_SCM_SVC_GPU_INIT_REGS 0x01

0 commit comments

Comments
 (0)