Commit f634b63d authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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*
  ...
parents 129bdb30 bb489b96
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -15,14 +15,15 @@ maintainers:
properties:
  compatible:
    enum:
      - fsl,imx8mq-cm4
      - fsl,imx6sx-cm4
      - fsl,imx7d-cm4
      - fsl,imx7ulp-cm4
      - fsl,imx8mm-cm4
      - fsl,imx8mn-cm7
      - fsl,imx8mp-cm7
      - fsl,imx8mq-cm4
      - fsl,imx8ulp-cm33
      - fsl,imx7d-cm4
      - fsl,imx7ulp-cm4
      - fsl,imx6sx-cm4
      - fsl,imx93-cm33

  clocks:
    maxItems: 1
+43 −14
Original line number Diff line number Diff line
@@ -23,11 +23,13 @@ properties:

  reg:
    description:
      Should contain the address ranges for memory regions SRAM, CFG, and
      L1TCM.
      Should contain the address ranges for memory regions SRAM, CFG, and,
      on some platforms, L1TCM.
    minItems: 2
    maxItems: 3

  reg-names:
    minItems: 2
    items:
      - const: sram
      - const: cfg
@@ -42,12 +44,26 @@ properties:
  clock-names:
    const: main

  interrupts:
    maxItems: 1

  firmware-name:
    $ref: /schemas/types.yaml#/definitions/string
    description:
      If present, name (or relative path) of the file within the
      firmware search path containing the firmware image used when
      initializing SCP.

  memory-region:
    maxItems: 1

required:
  - compatible
  - reg
  - reg-names

if:
allOf:
  - if:
      properties:
        compatible:
          enum:
@@ -58,6 +74,19 @@ then:
        - clocks
        - clock-names

  - if:
      properties:
        compatible:
          enum:
            - mediatek,mt8183-scp
            - mediatek,mt8186-scp
    then:
      properties:
        reg:
          maxItems: 2
        reg-names:
          maxItems: 2

additionalProperties:
  type: object
  description:
@@ -76,10 +105,10 @@ additionalProperties:

examples:
  - |
    #include <dt-bindings/clock/mt8183-clk.h>
    #include <dt-bindings/clock/mt8192-clk.h>

    scp@10500000 {
        compatible = "mediatek,mt8183-scp";
        compatible = "mediatek,mt8192-scp";
        reg = <0x10500000 0x80000>,
              <0x10700000 0x8000>,
              <0x10720000 0xe0000>;
+31 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ description:
properties:
  compatible:
    enum:
      - qcom,msm8226-adsp-pil
      - qcom,msm8974-adsp-pil
      - qcom,msm8996-adsp-pil
      - qcom,msm8996-slpi-pil
@@ -29,6 +30,9 @@ properties:
      - qcom,sc8180x-adsp-pas
      - qcom,sc8180x-cdsp-pas
      - qcom,sc8180x-mpss-pas
      - qcom,sc8280xp-adsp-pas
      - qcom,sc8280xp-nsp0-pas
      - qcom,sc8280xp-nsp1-pas
      - qcom,sdm660-adsp-pas
      - qcom,sdm845-adsp-pas
      - qcom,sdm845-cdsp-pas
@@ -159,6 +163,7 @@ allOf:
        compatible:
          contains:
            enum:
              - qcom,msm8226-adsp-pil
              - qcom,msm8974-adsp-pil
              - qcom,msm8996-adsp-pil
              - qcom,msm8996-slpi-pil
@@ -169,6 +174,9 @@ allOf:
              - qcom,sc8180x-adsp-pas
              - qcom,sc8180x-cdsp-pas
              - qcom,sc8180x-mpss-pas
              - qcom,sc8280xp-adsp-pas
              - qcom,sc8280xp-nsp0-pas
              - qcom,sc8280xp-nsp1-pas
              - qcom,sdm845-adsp-pas
              - qcom,sdm845-cdsp-pas
              - qcom,sm6350-adsp-pas
@@ -274,6 +282,7 @@ allOf:
        compatible:
          contains:
            enum:
              - qcom,msm8226-adsp-pil
              - qcom,msm8974-adsp-pil
              - qcom,msm8996-adsp-pil
              - qcom,msm8996-slpi-pil
@@ -284,6 +293,9 @@ allOf:
              - qcom,qcs404-wcss-pas
              - qcom,sc8180x-adsp-pas
              - qcom,sc8180x-cdsp-pas
              - qcom,sc8280xp-adsp-pas
              - qcom,sc8280xp-nsp0-pas
              - qcom,sc8280xp-nsp1-pas
              - qcom,sdm845-adsp-pas
              - qcom,sdm845-cdsp-pas
              - qcom,sm6350-adsp-pas
@@ -364,6 +376,7 @@ allOf:
        compatible:
          contains:
            enum:
              - qcom,msm8226-adsp-pil
              - qcom,msm8996-adsp-pil
              - qcom,msm8998-adsp-pas
    then:
@@ -471,6 +484,7 @@ allOf:
            enum:
              - qcom,sc8180x-adsp-pas
              - qcom,sc8180x-cdsp-pas
              - qcom,sc8280xp-adsp-pas
              - qcom,sm6350-adsp-pas
              - qcom,sm8150-slpi-pas
              - qcom,sm8250-adsp-pas
@@ -508,6 +522,22 @@ allOf:
            - const: cx
            - const: mxc

  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,sc8280xp-nsp0-pas
              - qcom,sc8280xp-nsp1-pas
    then:
      properties:
        power-domains:
          items:
            - description: NSP power domain
        power-domain-names:
          items:
            - const: nsp

  - if:
      properties:
        compatible:
@@ -546,6 +576,7 @@ allOf:
        compatible:
          contains:
            enum:
              - qcom,msm8226-adsp-pil
              - qcom,msm8974-adsp-pil
              - qcom,msm8996-adsp-pil
              - qcom,msm8996-slpi-pil
+8 −8
Original line number Diff line number Diff line
@@ -43,8 +43,8 @@ properties:
    items:
      - items:
          - description: Phandle of syscon block
          - description: FIXME
          - description: FIXME
          - description: The offset of the trust zone setting register
          - description: The field mask of the trust zone state

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

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

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

  st,auto-boot:
    $ref: /schemas/types.yaml#/definitions/flag
+10 −95
Original line number Diff line number Diff line
@@ -649,99 +649,6 @@ static int imx_dsp_rproc_add_carveout(struct imx_dsp_rproc *priv)
	return 0;
}

/**
 * imx_dsp_rproc_elf_load_segments() - load firmware segments to memory
 * @rproc: remote processor which will be booted using these fw segments
 * @fw: the ELF firmware image
 *
 * This function specially checks if memsz is zero or not, otherwise it
 * is mostly same as rproc_elf_load_segments().
 */
static int imx_dsp_rproc_elf_load_segments(struct rproc *rproc,
					   const struct firmware *fw)
{
	struct device *dev = &rproc->dev;
	u8 class = fw_elf_get_class(fw);
	u32 elf_phdr_get_size = elf_size_of_phdr(class);
	const u8 *elf_data = fw->data;
	const void *ehdr, *phdr;
	int i, ret = 0;
	u16 phnum;

	ehdr = elf_data;
	phnum = elf_hdr_get_e_phnum(class, ehdr);
	phdr = elf_data + elf_hdr_get_e_phoff(class, ehdr);

	/* go through the available ELF segments */
	for (i = 0; i < phnum; i++, phdr += elf_phdr_get_size) {
		u64 da = elf_phdr_get_p_paddr(class, phdr);
		u64 memsz = elf_phdr_get_p_memsz(class, phdr);
		u64 filesz = elf_phdr_get_p_filesz(class, phdr);
		u64 offset = elf_phdr_get_p_offset(class, phdr);
		u32 type = elf_phdr_get_p_type(class, phdr);
		void *ptr;

		/*
		 *  There is a case that with PT_LOAD type, the
		 *  filesz = memsz = 0. If memsz = 0, rproc_da_to_va
		 *  should return NULL ptr, then error is returned.
		 *  So this case should be skipped from the loop.
		 *  Add !memsz checking here.
		 */
		if (type != PT_LOAD || !memsz)
			continue;

		dev_dbg(dev, "phdr: type %d da 0x%llx memsz 0x%llx filesz 0x%llx\n",
			type, da, memsz, filesz);

		if (filesz > memsz) {
			dev_err(dev, "bad phdr filesz 0x%llx memsz 0x%llx\n",
				filesz, memsz);
			ret = -EINVAL;
			break;
		}

		if (offset + filesz > fw->size) {
			dev_err(dev, "truncated fw: need 0x%llx avail 0x%zx\n",
				offset + filesz, fw->size);
			ret = -EINVAL;
			break;
		}

		if (!rproc_u64_fit_in_size_t(memsz)) {
			dev_err(dev, "size (%llx) does not fit in size_t type\n",
				memsz);
			ret = -EOVERFLOW;
			break;
		}

		/* grab the kernel address for this device address */
		ptr = rproc_da_to_va(rproc, da, memsz, NULL);
		if (!ptr) {
			dev_err(dev, "bad phdr da 0x%llx mem 0x%llx\n", da,
				memsz);
			ret = -EINVAL;
			break;
		}

		/* put the segment where the remote processor expects it */
		if (filesz)
			memcpy(ptr, elf_data + offset, filesz);

		/*
		 * Zero out remaining memory for this segment.
		 *
		 * This isn't strictly required since dma_alloc_coherent already
		 * did this for us. albeit harmless, we may consider removing
		 * this.
		 */
		if (memsz > filesz)
			memset(ptr + filesz, 0, memsz - filesz);
	}

	return ret;
}

/* Prepare function for rproc_ops */
static int imx_dsp_rproc_prepare(struct rproc *rproc)
{
@@ -802,14 +709,22 @@ static void imx_dsp_rproc_kick(struct rproc *rproc, int vqid)
		dev_err(dev, "%s: failed (%d, err:%d)\n", __func__, vqid, err);
}

static int imx_dsp_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
{
	if (rproc_elf_load_rsc_table(rproc, fw))
		dev_warn(&rproc->dev, "no resource table found for this firmware\n");

	return 0;
}

static const struct rproc_ops imx_dsp_rproc_ops = {
	.prepare	= imx_dsp_rproc_prepare,
	.unprepare	= imx_dsp_rproc_unprepare,
	.start		= imx_dsp_rproc_start,
	.stop		= imx_dsp_rproc_stop,
	.kick		= imx_dsp_rproc_kick,
	.load		= imx_dsp_rproc_elf_load_segments,
	.parse_fw	= rproc_elf_load_rsc_table,
	.load		= rproc_elf_load_segments,
	.parse_fw	= imx_dsp_rproc_parse_fw,
	.sanity_check	= rproc_elf_sanity_check,
	.get_boot_addr	= rproc_elf_get_boot_addr,
};
Loading