Skip to content

Commit dcf9ee9

Browse files
committed
Merge tag 'rproc-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux
Pull remoteproc updates from Bjorn Andersson: - Fix resource cleanup in the remoteproc attach error handling code paths - Refactor the various TI K3 drivers to extract and reuse common code between them - Add support in the i.MX remoteproc driver for determining from the firmware if Linux should wait on a "firmware ready" signal at startup - Improve the Xilinx R5F power down mechanism to handle use cases where this is shared with other entities in the system * tag 'rproc-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux: (46 commits) remoteproc: k3: Refactor release_tsp() functions into common driver remoteproc: k3: Refactor reserved_mem_init() functions into common driver remoteproc: k3: Refactor mem_release() functions into common driver remoteproc: k3: Refactor of_get_memories() functions into common driver remoteproc: k3: Refactor .da_to_va rproc ops into common driver remoteproc: k3: Refactor .get_loaded_rsc_table ops into common driver remoteproc: k3: Refactor .detach rproc ops into common driver remoteproc: k3: Refactor .attach rproc ops into common driver remoteproc: k3: Refactor .stop rproc ops into common driver remoteproc: k3: Refactor .start rproc ops into common driver remoteproc: k3: Refactor .unprepare rproc ops into common driver remoteproc: k3: Refactor .prepare rproc ops into common driver remoteproc: k3-dsp: Assert local reset during .prepare callback remoteproc: k3-dsp: Don't override rproc ops in IPC-only mode remoteproc: k3: Refactor rproc_request_mbox() implementations into common driver remoteproc: k3-m4: Ping the mbox while acquiring the channel remoteproc: k3: Refactor rproc_release() implementation into common driver remoteproc: k3-m4: Introduce central function to release rproc from reset remoteproc: k3-dsp: Correct Reset deassert logic for devices w/o lresets remoteproc: k3: Refactor rproc_reset() implementation into common driver ...
2 parents a060795 + 5779f6f commit dcf9ee9

14 files changed

+1266
-1836
lines changed

Documentation/devicetree/bindings/remoteproc/qcom,sm8150-pas.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ description:
1616
properties:
1717
compatible:
1818
enum:
19+
- qcom,sc8180x-adsp-pas
20+
- qcom,sc8180x-cdsp-pas
21+
- qcom,sc8180x-slpi-pas
1922
- qcom,sm8150-adsp-pas
2023
- qcom,sm8150-cdsp-pas
2124
- qcom,sm8150-mpss-pas

Documentation/devicetree/bindings/remoteproc/qcom,sm8350-pas.yaml

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ description:
1515

1616
properties:
1717
compatible:
18-
enum:
19-
- qcom,sar2130p-adsp-pas
20-
- qcom,sm8350-adsp-pas
21-
- qcom,sm8350-cdsp-pas
22-
- qcom,sm8350-slpi-pas
23-
- qcom,sm8350-mpss-pas
24-
- qcom,sm8450-adsp-pas
25-
- qcom,sm8450-cdsp-pas
26-
- qcom,sm8450-mpss-pas
27-
- qcom,sm8450-slpi-pas
18+
oneOf:
19+
- enum:
20+
- qcom,sar2130p-adsp-pas
21+
- qcom,sm8350-adsp-pas
22+
- qcom,sm8350-cdsp-pas
23+
- qcom,sm8350-slpi-pas
24+
- qcom,sm8350-mpss-pas
25+
- qcom,sm8450-adsp-pas
26+
- qcom,sm8450-cdsp-pas
27+
- qcom,sm8450-mpss-pas
28+
- qcom,sm8450-slpi-pas
29+
- items:
30+
- const: qcom,sc8280xp-slpi-pas
31+
- const: qcom,sm8350-slpi-pas
2832

2933
reg:
3034
maxItems: 1
@@ -61,14 +65,15 @@ allOf:
6165
- if:
6266
properties:
6367
compatible:
64-
enum:
65-
- qcom,sar2130p-adsp-pas
66-
- qcom,sm8350-adsp-pas
67-
- qcom,sm8350-cdsp-pas
68-
- qcom,sm8350-slpi-pas
69-
- qcom,sm8450-adsp-pas
70-
- qcom,sm8450-cdsp-pas
71-
- qcom,sm8450-slpi-pas
68+
contains:
69+
enum:
70+
- qcom,sar2130p-adsp-pas
71+
- qcom,sm8350-adsp-pas
72+
- qcom,sm8350-cdsp-pas
73+
- qcom,sm8350-slpi-pas
74+
- qcom,sm8450-adsp-pas
75+
- qcom,sm8450-cdsp-pas
76+
- qcom,sm8450-slpi-pas
7277
then:
7378
properties:
7479
interrupts:
@@ -102,12 +107,13 @@ allOf:
102107
- if:
103108
properties:
104109
compatible:
105-
enum:
106-
- qcom,sar2130p-adsp-pas
107-
- qcom,sm8350-adsp-pas
108-
- qcom,sm8350-slpi-pas
109-
- qcom,sm8450-adsp-pas
110-
- qcom,sm8450-slpi-pas
110+
contains:
111+
enum:
112+
- qcom,sar2130p-adsp-pas
113+
- qcom,sm8350-adsp-pas
114+
- qcom,sm8350-slpi-pas
115+
- qcom,sm8450-adsp-pas
116+
- qcom,sm8450-slpi-pas
111117
then:
112118
properties:
113119
power-domains:

Documentation/devicetree/bindings/remoteproc/st,stm32-rproc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ properties:
139139
If defined, when remoteproc is probed, it loads the default firmware and
140140
starts the remote processor.
141141

142+
firmware-name:
143+
maxItems: 1
144+
description: Default name of the remote processor firmware.
145+
142146
required:
143147
- compatible
144148
- reg

drivers/remoteproc/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC) += rcar_rproc.o
3636
obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o
3737
obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o
3838
obj-$(CONFIG_STM32_RPROC) += stm32_rproc.o
39-
obj-$(CONFIG_TI_K3_DSP_REMOTEPROC) += ti_k3_dsp_remoteproc.o
40-
obj-$(CONFIG_TI_K3_M4_REMOTEPROC) += ti_k3_m4_remoteproc.o
41-
obj-$(CONFIG_TI_K3_R5_REMOTEPROC) += ti_k3_r5_remoteproc.o
39+
obj-$(CONFIG_TI_K3_DSP_REMOTEPROC) += ti_k3_dsp_remoteproc.o ti_k3_common.o
40+
obj-$(CONFIG_TI_K3_M4_REMOTEPROC) += ti_k3_m4_remoteproc.o ti_k3_common.o
41+
obj-$(CONFIG_TI_K3_R5_REMOTEPROC) += ti_k3_r5_remoteproc.o ti_k3_common.o
4242
obj-$(CONFIG_XLNX_R5_REMOTEPROC) += xlnx_r5_remoteproc.o

drivers/remoteproc/imx_dsp_rproc.c

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@ module_param_named(no_mailboxes, no_mailboxes, int, 0644);
3636
MODULE_PARM_DESC(no_mailboxes,
3737
"There is no mailbox between cores, so ignore remote proc reply after start, default is 0 (off).");
3838

39+
/* Flag indicating that the remote is up and running */
3940
#define REMOTE_IS_READY BIT(0)
41+
/* Flag indicating that the host should wait for a firmware-ready response */
42+
#define WAIT_FW_READY BIT(1)
4043
#define REMOTE_READY_WAIT_MAX_RETRIES 500
4144

45+
/*
46+
* This flag is set in the DSP resource table's features field to indicate
47+
* that the firmware requires the host NOT to wait for a FW_READY response.
48+
*/
49+
#define FEATURE_DONT_WAIT_FW_READY BIT(0)
50+
4251
/* att flags */
4352
/* DSP own area */
4453
#define ATT_OWN BIT(31)
@@ -73,6 +82,10 @@ MODULE_PARM_DESC(no_mailboxes,
7382

7483
#define IMX8ULP_SIP_HIFI_XRDC 0xc200000e
7584

85+
#define FW_RSC_NXP_S_MAGIC ((uint32_t)'n' << 24 | \
86+
(uint32_t)'x' << 16 | \
87+
(uint32_t)'p' << 8 | \
88+
(uint32_t)'s')
7689
/*
7790
* enum - Predefined Mailbox Messages
7891
*
@@ -139,6 +152,24 @@ struct imx_dsp_rproc_dcfg {
139152
int (*reset)(struct imx_dsp_rproc *priv);
140153
};
141154

155+
/**
156+
* struct fw_rsc_imx_dsp - i.MX DSP specific info
157+
*
158+
* @len: length of the resource entry
159+
* @magic_num: 32-bit magic number
160+
* @version: version of data structure
161+
* @features: feature flags supported by the i.MX DSP firmware
162+
*
163+
* This represents a DSP-specific resource in the firmware's
164+
* resource table, providing information on supported features.
165+
*/
166+
struct fw_rsc_imx_dsp {
167+
uint32_t len;
168+
uint32_t magic_num;
169+
uint32_t version;
170+
uint32_t features;
171+
} __packed;
172+
142173
static const struct imx_rproc_att imx_dsp_rproc_att_imx8qm[] = {
143174
/* dev addr , sys addr , size , flags */
144175
{ 0x596e8000, 0x556e8000, 0x00008000, ATT_OWN },
@@ -297,6 +328,66 @@ static int imx_dsp_rproc_ready(struct rproc *rproc)
297328
return -ETIMEDOUT;
298329
}
299330

331+
/**
332+
* imx_dsp_rproc_handle_rsc() - Handle DSP-specific resource table entries
333+
* @rproc: remote processor instance
334+
* @rsc_type: resource type identifier
335+
* @rsc: pointer to the resource entry
336+
* @offset: offset of the resource entry
337+
* @avail: available space in the resource table
338+
*
339+
* Parse the DSP-specific resource entry and update flags accordingly.
340+
* If the WAIT_FW_READY feature is set, the host must wait for the firmware
341+
* to signal readiness before proceeding with execution.
342+
*
343+
* Return: RSC_HANDLED if processed successfully, RSC_IGNORED otherwise.
344+
*/
345+
static int imx_dsp_rproc_handle_rsc(struct rproc *rproc, u32 rsc_type,
346+
void *rsc, int offset, int avail)
347+
{
348+
struct imx_dsp_rproc *priv = rproc->priv;
349+
struct fw_rsc_imx_dsp *imx_dsp_rsc = rsc;
350+
struct device *dev = rproc->dev.parent;
351+
352+
if (!imx_dsp_rsc) {
353+
dev_dbg(dev, "Invalid fw_rsc_imx_dsp.\n");
354+
return RSC_IGNORED;
355+
}
356+
357+
/* Make sure resource isn't truncated */
358+
if (sizeof(struct fw_rsc_imx_dsp) > avail ||
359+
sizeof(struct fw_rsc_imx_dsp) != imx_dsp_rsc->len) {
360+
dev_dbg(dev, "Resource fw_rsc_imx_dsp is truncated.\n");
361+
return RSC_IGNORED;
362+
}
363+
364+
/*
365+
* If FW_RSC_NXP_S_MAGIC number is not found then
366+
* wait for fw_ready reply (default work flow)
367+
*/
368+
if (imx_dsp_rsc->magic_num != FW_RSC_NXP_S_MAGIC) {
369+
dev_dbg(dev, "Invalid resource table magic number.\n");
370+
return RSC_IGNORED;
371+
}
372+
373+
/*
374+
* For now, in struct fw_rsc_imx_dsp, version 0,
375+
* only FEATURE_DONT_WAIT_FW_READY is valid.
376+
*
377+
* When adding new features, please upgrade version.
378+
*/
379+
if (imx_dsp_rsc->version > 0) {
380+
dev_warn(dev, "Unexpected fw_rsc_imx_dsp version %d.\n",
381+
imx_dsp_rsc->version);
382+
return RSC_IGNORED;
383+
}
384+
385+
if (imx_dsp_rsc->features & FEATURE_DONT_WAIT_FW_READY)
386+
priv->flags &= ~WAIT_FW_READY;
387+
388+
return RSC_HANDLED;
389+
}
390+
300391
/*
301392
* Start function for rproc_ops
302393
*
@@ -335,8 +426,8 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
335426

336427
if (ret)
337428
dev_err(dev, "Failed to enable remote core!\n");
338-
else
339-
ret = imx_dsp_rproc_ready(rproc);
429+
else if (priv->flags & WAIT_FW_READY)
430+
return imx_dsp_rproc_ready(rproc);
340431

341432
return ret;
342433
}
@@ -939,6 +1030,7 @@ static const struct rproc_ops imx_dsp_rproc_ops = {
9391030
.kick = imx_dsp_rproc_kick,
9401031
.load = imx_dsp_rproc_elf_load_segments,
9411032
.parse_fw = imx_dsp_rproc_parse_fw,
1033+
.handle_rsc = imx_dsp_rproc_handle_rsc,
9421034
.find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
9431035
.sanity_check = rproc_elf_sanity_check,
9441036
.get_boot_addr = rproc_elf_get_boot_addr,
@@ -1058,6 +1150,8 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
10581150
priv = rproc->priv;
10591151
priv->rproc = rproc;
10601152
priv->dsp_dcfg = dsp_dcfg;
1153+
/* By default, host waits for fw_ready reply */
1154+
priv->flags |= WAIT_FW_READY;
10611155

10621156
if (no_mailboxes)
10631157
imx_dsp_rproc_mbox_init = imx_dsp_rproc_mbox_no_alloc;

drivers/remoteproc/qcom_wcnss_iris.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ struct qcom_iris *qcom_iris_probe(struct device *parent, bool *use_48mhz_xo)
196196

197197
err_device_del:
198198
device_del(&iris->dev);
199+
put_device(&iris->dev);
199200

200201
return ERR_PTR(ret);
201202
}
202203

203204
void qcom_iris_remove(struct qcom_iris *iris)
204205
{
205206
device_del(&iris->dev);
207+
put_device(&iris->dev);
206208
}

drivers/remoteproc/remoteproc_core.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ static int rproc_attach(struct rproc *rproc)
16171617
ret = rproc_set_rsc_table(rproc);
16181618
if (ret) {
16191619
dev_err(dev, "can't load resource table: %d\n", ret);
1620-
goto unprepare_device;
1620+
goto clean_up_resources;
16211621
}
16221622

16231623
/* reset max_notifyid */
@@ -1634,7 +1634,7 @@ static int rproc_attach(struct rproc *rproc)
16341634
ret = rproc_handle_resources(rproc, rproc_loading_handlers);
16351635
if (ret) {
16361636
dev_err(dev, "Failed to process resources: %d\n", ret);
1637-
goto unprepare_device;
1637+
goto clean_up_resources;
16381638
}
16391639

16401640
/* Allocate carveout resources associated to rproc */
@@ -1653,9 +1653,9 @@ static int rproc_attach(struct rproc *rproc)
16531653

16541654
clean_up_resources:
16551655
rproc_resource_cleanup(rproc);
1656-
unprepare_device:
16571656
/* release HW resources if needed */
16581657
rproc_unprepare_device(rproc);
1658+
kfree(rproc->clean_table);
16591659
disable_iommu:
16601660
rproc_disable_iommu(rproc);
16611661
return ret;
@@ -2025,7 +2025,6 @@ int rproc_shutdown(struct rproc *rproc)
20252025
kfree(rproc->cached_table);
20262026
rproc->cached_table = NULL;
20272027
rproc->table_ptr = NULL;
2028-
rproc->table_sz = 0;
20292028
out:
20302029
mutex_unlock(&rproc->lock);
20312030
return ret;

drivers/remoteproc/stm32_rproc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ static int stm32_rproc_probe(struct platform_device *pdev)
835835
struct device *dev = &pdev->dev;
836836
struct stm32_rproc *ddata;
837837
struct device_node *np = dev->of_node;
838+
const char *fw_name;
838839
struct rproc *rproc;
839840
unsigned int state;
840841
int ret;
@@ -843,7 +844,12 @@ static int stm32_rproc_probe(struct platform_device *pdev)
843844
if (ret)
844845
return ret;
845846

846-
rproc = devm_rproc_alloc(dev, np->name, &st_rproc_ops, NULL, sizeof(*ddata));
847+
/* Look for an optional firmware name */
848+
ret = rproc_of_parse_firmware(dev, 0, &fw_name);
849+
if (ret < 0 && ret != -EINVAL)
850+
return ret;
851+
852+
rproc = devm_rproc_alloc(dev, np->name, &st_rproc_ops, fw_name, sizeof(*ddata));
847853
if (!rproc)
848854
return -ENOMEM;
849855

0 commit comments

Comments
 (0)