Skip to content

Commit f634b63

Browse files
committed
Merge tag 'rproc-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux
Pull remoteproc updates from Bjorn Andersson: "This fixes a race condition in the user space interface for starting and stopping remote processors, it makes the ELF loader properly skip zero memsz segments and it cleans up the debugfs tracefile code a bit by not checking for errors. It introduces support for controlling the audio DSP on Qualcomm MSM8226, as well as audio and compute DSPs on Qualcomm SC8280XP. It makes it possible to specify the firmware path for Mediatek's remote processors, fixes a double free in the SCP driver and addresses an issue with the SRAM initialization on MT8195. Lastly it deprecates the custom ELF loader in the iMX remoteproc driver, in favor of using the shared one" * tag 'rproc-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux: (21 commits) dt-bindings: remoteproc: mediatek: Add optional memory-region to mtk,scp dt-bindings: remoteproc: mediatek: Make l1tcm reg exclusive to mt819x dt-bindings: remoteproc: st,stm32-rproc: Fix phandle-array parameters description remoteproc: imx_rproc: Support i.MX93 dt-bindings: remoteproc: imx_rproc: Support i.MX93 remoteproc: qcom: pas: Add MSM8226 ADSP support dt-bindings: remoteproc: qcom: pas: Add MSM8226 adsp remoteproc: mediatek: Allow reading firmware-name from DT dt-bindings: remoteproc: mediatek: Add firmware-name property remoteproc: qcom: pas: Add sc8280xp remoteprocs dt-bindings: remoteproc: qcom: pas: Add sc8280xp adsp and nsp pair dt-bindings: remoteproc: mediatek: Add interrupts property to mtk,scp remoteproc: imx_rproc: Ignore create mem entry for resource table remoteproc: core: Move state checking to remoteproc_core remoteproc: core: Remove state checking before calling rproc_boot() remoteproc: imx_dsp_rproc: Make rsc_table optional remoteproc: imx_dsp_rproc: use common rproc_elf_load_segments remoteproc: elf_loader: skip segment with memsz as zero remoteproc: mtk_scp: Fix a potential double free remoteproc: Don't bother checking the return value of debugfs_create* ...
2 parents 129bdb3 + bb489b9 commit f634b63

File tree

14 files changed

+240
-182
lines changed

14 files changed

+240
-182
lines changed

Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ maintainers:
1515
properties:
1616
compatible:
1717
enum:
18-
- fsl,imx8mq-cm4
18+
- fsl,imx6sx-cm4
19+
- fsl,imx7d-cm4
20+
- fsl,imx7ulp-cm4
1921
- fsl,imx8mm-cm4
2022
- fsl,imx8mn-cm7
2123
- fsl,imx8mp-cm7
24+
- fsl,imx8mq-cm4
2225
- fsl,imx8ulp-cm33
23-
- fsl,imx7d-cm4
24-
- fsl,imx7ulp-cm4
25-
- fsl,imx6sx-cm4
26+
- fsl,imx93-cm33
2627

2728
clocks:
2829
maxItems: 1

Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ properties:
2323

2424
reg:
2525
description:
26-
Should contain the address ranges for memory regions SRAM, CFG, and
27-
L1TCM.
26+
Should contain the address ranges for memory regions SRAM, CFG, and,
27+
on some platforms, L1TCM.
28+
minItems: 2
2829
maxItems: 3
2930

3031
reg-names:
32+
minItems: 2
3133
items:
3234
- const: sram
3335
- const: cfg
@@ -42,21 +44,48 @@ properties:
4244
clock-names:
4345
const: main
4446

47+
interrupts:
48+
maxItems: 1
49+
50+
firmware-name:
51+
$ref: /schemas/types.yaml#/definitions/string
52+
description:
53+
If present, name (or relative path) of the file within the
54+
firmware search path containing the firmware image used when
55+
initializing SCP.
56+
57+
memory-region:
58+
maxItems: 1
59+
4560
required:
4661
- compatible
4762
- reg
4863
- reg-names
4964

50-
if:
51-
properties:
52-
compatible:
53-
enum:
54-
- mediatek,mt8183-scp
55-
- mediatek,mt8192-scp
56-
then:
57-
required:
58-
- clocks
59-
- clock-names
65+
allOf:
66+
- if:
67+
properties:
68+
compatible:
69+
enum:
70+
- mediatek,mt8183-scp
71+
- mediatek,mt8192-scp
72+
then:
73+
required:
74+
- clocks
75+
- clock-names
76+
77+
- if:
78+
properties:
79+
compatible:
80+
enum:
81+
- mediatek,mt8183-scp
82+
- mediatek,mt8186-scp
83+
then:
84+
properties:
85+
reg:
86+
maxItems: 2
87+
reg-names:
88+
maxItems: 2
6089

6190
additionalProperties:
6291
type: object
@@ -76,10 +105,10 @@ additionalProperties:
76105

77106
examples:
78107
- |
79-
#include <dt-bindings/clock/mt8183-clk.h>
108+
#include <dt-bindings/clock/mt8192-clk.h>
80109
81110
scp@10500000 {
82-
compatible = "mediatek,mt8183-scp";
111+
compatible = "mediatek,mt8192-scp";
83112
reg = <0x10500000 0x80000>,
84113
<0x10700000 0x8000>,
85114
<0x10720000 0xe0000>;

Documentation/devicetree/bindings/remoteproc/qcom,adsp.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ description:
1616
properties:
1717
compatible:
1818
enum:
19+
- qcom,msm8226-adsp-pil
1920
- qcom,msm8974-adsp-pil
2021
- qcom,msm8996-adsp-pil
2122
- qcom,msm8996-slpi-pil
@@ -29,6 +30,9 @@ properties:
2930
- qcom,sc8180x-adsp-pas
3031
- qcom,sc8180x-cdsp-pas
3132
- qcom,sc8180x-mpss-pas
33+
- qcom,sc8280xp-adsp-pas
34+
- qcom,sc8280xp-nsp0-pas
35+
- qcom,sc8280xp-nsp1-pas
3236
- qcom,sdm660-adsp-pas
3337
- qcom,sdm845-adsp-pas
3438
- qcom,sdm845-cdsp-pas
@@ -159,6 +163,7 @@ allOf:
159163
compatible:
160164
contains:
161165
enum:
166+
- qcom,msm8226-adsp-pil
162167
- qcom,msm8974-adsp-pil
163168
- qcom,msm8996-adsp-pil
164169
- qcom,msm8996-slpi-pil
@@ -169,6 +174,9 @@ allOf:
169174
- qcom,sc8180x-adsp-pas
170175
- qcom,sc8180x-cdsp-pas
171176
- qcom,sc8180x-mpss-pas
177+
- qcom,sc8280xp-adsp-pas
178+
- qcom,sc8280xp-nsp0-pas
179+
- qcom,sc8280xp-nsp1-pas
172180
- qcom,sdm845-adsp-pas
173181
- qcom,sdm845-cdsp-pas
174182
- qcom,sm6350-adsp-pas
@@ -274,6 +282,7 @@ allOf:
274282
compatible:
275283
contains:
276284
enum:
285+
- qcom,msm8226-adsp-pil
277286
- qcom,msm8974-adsp-pil
278287
- qcom,msm8996-adsp-pil
279288
- qcom,msm8996-slpi-pil
@@ -284,6 +293,9 @@ allOf:
284293
- qcom,qcs404-wcss-pas
285294
- qcom,sc8180x-adsp-pas
286295
- qcom,sc8180x-cdsp-pas
296+
- qcom,sc8280xp-adsp-pas
297+
- qcom,sc8280xp-nsp0-pas
298+
- qcom,sc8280xp-nsp1-pas
287299
- qcom,sdm845-adsp-pas
288300
- qcom,sdm845-cdsp-pas
289301
- qcom,sm6350-adsp-pas
@@ -364,6 +376,7 @@ allOf:
364376
compatible:
365377
contains:
366378
enum:
379+
- qcom,msm8226-adsp-pil
367380
- qcom,msm8996-adsp-pil
368381
- qcom,msm8998-adsp-pas
369382
then:
@@ -471,6 +484,7 @@ allOf:
471484
enum:
472485
- qcom,sc8180x-adsp-pas
473486
- qcom,sc8180x-cdsp-pas
487+
- qcom,sc8280xp-adsp-pas
474488
- qcom,sm6350-adsp-pas
475489
- qcom,sm8150-slpi-pas
476490
- qcom,sm8250-adsp-pas
@@ -508,6 +522,22 @@ allOf:
508522
- const: cx
509523
- const: mxc
510524

525+
- if:
526+
properties:
527+
compatible:
528+
contains:
529+
enum:
530+
- qcom,sc8280xp-nsp0-pas
531+
- qcom,sc8280xp-nsp1-pas
532+
then:
533+
properties:
534+
power-domains:
535+
items:
536+
- description: NSP power domain
537+
power-domain-names:
538+
items:
539+
- const: nsp
540+
511541
- if:
512542
properties:
513543
compatible:
@@ -546,6 +576,7 @@ allOf:
546576
compatible:
547577
contains:
548578
enum:
579+
- qcom,msm8226-adsp-pil
549580
- qcom,msm8974-adsp-pil
550581
- qcom,msm8996-adsp-pil
551582
- qcom,msm8996-slpi-pil

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ properties:
4343
items:
4444
- items:
4545
- description: Phandle of syscon block
46-
- description: FIXME
47-
- description: FIXME
46+
- description: The offset of the trust zone setting register
47+
- description: The field mask of the trust zone state
4848

4949
interrupts:
5050
description: Should contain the WWDG1 watchdog reset interrupt
@@ -101,8 +101,8 @@ properties:
101101
items:
102102
- items:
103103
- description: Phandle of syscon block
104-
- description: FIXME
105-
- description: FIXME
104+
- description: The offset of the power setting register
105+
- description: The field mask of the PDDS selection
106106

107107
st,syscfg-m4-state:
108108
$ref: "/schemas/types.yaml#/definitions/phandle-array"
@@ -111,8 +111,8 @@ properties:
111111
items:
112112
- items:
113113
- description: Phandle of syscon block with the tamp register
114-
- description: FIXME
115-
- description: FIXME
114+
- description: The offset of the tamp register
115+
- description: The field mask of the Cortex-M4 state
116116

117117
st,syscfg-rsc-tbl:
118118
$ref: "/schemas/types.yaml#/definitions/phandle-array"
@@ -122,8 +122,8 @@ properties:
122122
items:
123123
- items:
124124
- description: Phandle of syscon block with the tamp register
125-
- description: FIXME
126-
- description: FIXME
125+
- description: The offset of the tamp register
126+
- description: The field mask of the Cortex-M4 resource table address
127127

128128
st,auto-boot:
129129
$ref: /schemas/types.yaml#/definitions/flag

drivers/remoteproc/imx_dsp_rproc.c

Lines changed: 10 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -649,99 +649,6 @@ static int imx_dsp_rproc_add_carveout(struct imx_dsp_rproc *priv)
649649
return 0;
650650
}
651651

652-
/**
653-
* imx_dsp_rproc_elf_load_segments() - load firmware segments to memory
654-
* @rproc: remote processor which will be booted using these fw segments
655-
* @fw: the ELF firmware image
656-
*
657-
* This function specially checks if memsz is zero or not, otherwise it
658-
* is mostly same as rproc_elf_load_segments().
659-
*/
660-
static int imx_dsp_rproc_elf_load_segments(struct rproc *rproc,
661-
const struct firmware *fw)
662-
{
663-
struct device *dev = &rproc->dev;
664-
u8 class = fw_elf_get_class(fw);
665-
u32 elf_phdr_get_size = elf_size_of_phdr(class);
666-
const u8 *elf_data = fw->data;
667-
const void *ehdr, *phdr;
668-
int i, ret = 0;
669-
u16 phnum;
670-
671-
ehdr = elf_data;
672-
phnum = elf_hdr_get_e_phnum(class, ehdr);
673-
phdr = elf_data + elf_hdr_get_e_phoff(class, ehdr);
674-
675-
/* go through the available ELF segments */
676-
for (i = 0; i < phnum; i++, phdr += elf_phdr_get_size) {
677-
u64 da = elf_phdr_get_p_paddr(class, phdr);
678-
u64 memsz = elf_phdr_get_p_memsz(class, phdr);
679-
u64 filesz = elf_phdr_get_p_filesz(class, phdr);
680-
u64 offset = elf_phdr_get_p_offset(class, phdr);
681-
u32 type = elf_phdr_get_p_type(class, phdr);
682-
void *ptr;
683-
684-
/*
685-
* There is a case that with PT_LOAD type, the
686-
* filesz = memsz = 0. If memsz = 0, rproc_da_to_va
687-
* should return NULL ptr, then error is returned.
688-
* So this case should be skipped from the loop.
689-
* Add !memsz checking here.
690-
*/
691-
if (type != PT_LOAD || !memsz)
692-
continue;
693-
694-
dev_dbg(dev, "phdr: type %d da 0x%llx memsz 0x%llx filesz 0x%llx\n",
695-
type, da, memsz, filesz);
696-
697-
if (filesz > memsz) {
698-
dev_err(dev, "bad phdr filesz 0x%llx memsz 0x%llx\n",
699-
filesz, memsz);
700-
ret = -EINVAL;
701-
break;
702-
}
703-
704-
if (offset + filesz > fw->size) {
705-
dev_err(dev, "truncated fw: need 0x%llx avail 0x%zx\n",
706-
offset + filesz, fw->size);
707-
ret = -EINVAL;
708-
break;
709-
}
710-
711-
if (!rproc_u64_fit_in_size_t(memsz)) {
712-
dev_err(dev, "size (%llx) does not fit in size_t type\n",
713-
memsz);
714-
ret = -EOVERFLOW;
715-
break;
716-
}
717-
718-
/* grab the kernel address for this device address */
719-
ptr = rproc_da_to_va(rproc, da, memsz, NULL);
720-
if (!ptr) {
721-
dev_err(dev, "bad phdr da 0x%llx mem 0x%llx\n", da,
722-
memsz);
723-
ret = -EINVAL;
724-
break;
725-
}
726-
727-
/* put the segment where the remote processor expects it */
728-
if (filesz)
729-
memcpy(ptr, elf_data + offset, filesz);
730-
731-
/*
732-
* Zero out remaining memory for this segment.
733-
*
734-
* This isn't strictly required since dma_alloc_coherent already
735-
* did this for us. albeit harmless, we may consider removing
736-
* this.
737-
*/
738-
if (memsz > filesz)
739-
memset(ptr + filesz, 0, memsz - filesz);
740-
}
741-
742-
return ret;
743-
}
744-
745652
/* Prepare function for rproc_ops */
746653
static int imx_dsp_rproc_prepare(struct rproc *rproc)
747654
{
@@ -802,14 +709,22 @@ static void imx_dsp_rproc_kick(struct rproc *rproc, int vqid)
802709
dev_err(dev, "%s: failed (%d, err:%d)\n", __func__, vqid, err);
803710
}
804711

712+
static int imx_dsp_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
713+
{
714+
if (rproc_elf_load_rsc_table(rproc, fw))
715+
dev_warn(&rproc->dev, "no resource table found for this firmware\n");
716+
717+
return 0;
718+
}
719+
805720
static const struct rproc_ops imx_dsp_rproc_ops = {
806721
.prepare = imx_dsp_rproc_prepare,
807722
.unprepare = imx_dsp_rproc_unprepare,
808723
.start = imx_dsp_rproc_start,
809724
.stop = imx_dsp_rproc_stop,
810725
.kick = imx_dsp_rproc_kick,
811-
.load = imx_dsp_rproc_elf_load_segments,
812-
.parse_fw = rproc_elf_load_rsc_table,
726+
.load = rproc_elf_load_segments,
727+
.parse_fw = imx_dsp_rproc_parse_fw,
813728
.sanity_check = rproc_elf_sanity_check,
814729
.get_boot_addr = rproc_elf_get_boot_addr,
815730
};

0 commit comments

Comments
 (0)