Commit dcf9ee9a authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
  ...
parents a0607951 5779f6f9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@ description:
properties:
  compatible:
    enum:
      - qcom,sc8180x-adsp-pas
      - qcom,sc8180x-cdsp-pas
      - qcom,sc8180x-slpi-pas
      - qcom,sm8150-adsp-pas
      - qcom,sm8150-cdsp-pas
      - qcom,sm8150-mpss-pas
+30 −24
Original line number Diff line number Diff line
@@ -15,7 +15,8 @@ description:

properties:
  compatible:
    enum:
    oneOf:
      - enum:
          - qcom,sar2130p-adsp-pas
          - qcom,sm8350-adsp-pas
          - qcom,sm8350-cdsp-pas
@@ -25,6 +26,9 @@ properties:
          - qcom,sm8450-cdsp-pas
          - qcom,sm8450-mpss-pas
          - qcom,sm8450-slpi-pas
      - items:
          - const: qcom,sc8280xp-slpi-pas
          - const: qcom,sm8350-slpi-pas

  reg:
    maxItems: 1
@@ -61,6 +65,7 @@ allOf:
  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,sar2130p-adsp-pas
              - qcom,sm8350-adsp-pas
@@ -102,6 +107,7 @@ allOf:
  - if:
      properties:
        compatible:
          contains:
            enum:
              - qcom,sar2130p-adsp-pas
              - qcom,sm8350-adsp-pas
+4 −0
Original line number Diff line number Diff line
@@ -139,6 +139,10 @@ properties:
      If defined, when remoteproc is probed, it loads the default firmware and
      starts the remote processor.

  firmware-name:
    maxItems: 1
    description: Default name of the remote processor firmware.

required:
  - compatible
  - reg
+3 −3
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC) += rcar_rproc.o
obj-$(CONFIG_ST_REMOTEPROC)		+= st_remoteproc.o
obj-$(CONFIG_ST_SLIM_REMOTEPROC)	+= st_slim_rproc.o
obj-$(CONFIG_STM32_RPROC)		+= stm32_rproc.o
obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)	+= ti_k3_dsp_remoteproc.o
obj-$(CONFIG_TI_K3_M4_REMOTEPROC)	+= ti_k3_m4_remoteproc.o
obj-$(CONFIG_TI_K3_R5_REMOTEPROC)	+= ti_k3_r5_remoteproc.o
obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)	+= ti_k3_dsp_remoteproc.o ti_k3_common.o
obj-$(CONFIG_TI_K3_M4_REMOTEPROC)	+= ti_k3_m4_remoteproc.o ti_k3_common.o
obj-$(CONFIG_TI_K3_R5_REMOTEPROC)	+= ti_k3_r5_remoteproc.o ti_k3_common.o
obj-$(CONFIG_XLNX_R5_REMOTEPROC)	+= xlnx_r5_remoteproc.o
+96 −2
Original line number Diff line number Diff line
@@ -36,9 +36,18 @@ module_param_named(no_mailboxes, no_mailboxes, int, 0644);
MODULE_PARM_DESC(no_mailboxes,
		 "There is no mailbox between cores, so ignore remote proc reply after start, default is 0 (off).");

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

/*
 * This flag is set in the DSP resource table's features field to indicate
 * that the firmware requires the host NOT to wait for a FW_READY response.
 */
#define FEATURE_DONT_WAIT_FW_READY		BIT(0)

/* att flags */
/* DSP own area */
#define ATT_OWN					BIT(31)
@@ -73,6 +82,10 @@ MODULE_PARM_DESC(no_mailboxes,

#define IMX8ULP_SIP_HIFI_XRDC			0xc200000e

#define FW_RSC_NXP_S_MAGIC			((uint32_t)'n' << 24 |	\
						 (uint32_t)'x' << 16 |	\
						 (uint32_t)'p' << 8 |	\
						 (uint32_t)'s')
/*
 * enum - Predefined Mailbox Messages
 *
@@ -139,6 +152,24 @@ struct imx_dsp_rproc_dcfg {
	int (*reset)(struct imx_dsp_rproc *priv);
};

/**
 * struct fw_rsc_imx_dsp - i.MX DSP specific info
 *
 * @len: length of the resource entry
 * @magic_num: 32-bit magic number
 * @version: version of data structure
 * @features: feature flags supported by the i.MX DSP firmware
 *
 * This represents a DSP-specific resource in the firmware's
 * resource table, providing information on supported features.
 */
struct fw_rsc_imx_dsp {
	uint32_t len;
	uint32_t magic_num;
	uint32_t version;
	uint32_t features;
} __packed;

static const struct imx_rproc_att imx_dsp_rproc_att_imx8qm[] = {
	/* dev addr , sys addr  , size	    , flags */
	{ 0x596e8000, 0x556e8000, 0x00008000, ATT_OWN },
@@ -297,6 +328,66 @@ static int imx_dsp_rproc_ready(struct rproc *rproc)
	return -ETIMEDOUT;
}

/**
 * imx_dsp_rproc_handle_rsc() - Handle DSP-specific resource table entries
 * @rproc: remote processor instance
 * @rsc_type: resource type identifier
 * @rsc: pointer to the resource entry
 * @offset: offset of the resource entry
 * @avail: available space in the resource table
 *
 * Parse the DSP-specific resource entry and update flags accordingly.
 * If the WAIT_FW_READY feature is set, the host must wait for the firmware
 * to signal readiness before proceeding with execution.
 *
 * Return: RSC_HANDLED if processed successfully, RSC_IGNORED otherwise.
 */
static int imx_dsp_rproc_handle_rsc(struct rproc *rproc, u32 rsc_type,
				    void *rsc, int offset, int avail)
{
	struct imx_dsp_rproc *priv = rproc->priv;
	struct fw_rsc_imx_dsp *imx_dsp_rsc = rsc;
	struct device *dev = rproc->dev.parent;

	if (!imx_dsp_rsc) {
		dev_dbg(dev, "Invalid fw_rsc_imx_dsp.\n");
		return RSC_IGNORED;
	}

	/* Make sure resource isn't truncated */
	if (sizeof(struct fw_rsc_imx_dsp) > avail ||
	    sizeof(struct fw_rsc_imx_dsp) != imx_dsp_rsc->len) {
		dev_dbg(dev, "Resource fw_rsc_imx_dsp is truncated.\n");
		return RSC_IGNORED;
	}

	/*
	 * If FW_RSC_NXP_S_MAGIC number is not found then
	 * wait for fw_ready reply (default work flow)
	 */
	if (imx_dsp_rsc->magic_num != FW_RSC_NXP_S_MAGIC) {
		dev_dbg(dev, "Invalid resource table magic number.\n");
		return RSC_IGNORED;
	}

	/*
	 * For now, in struct fw_rsc_imx_dsp, version 0,
	 * only FEATURE_DONT_WAIT_FW_READY is valid.
	 *
	 * When adding new features, please upgrade version.
	 */
	if (imx_dsp_rsc->version > 0) {
		dev_warn(dev, "Unexpected fw_rsc_imx_dsp version %d.\n",
			 imx_dsp_rsc->version);
		return RSC_IGNORED;
	}

	if (imx_dsp_rsc->features & FEATURE_DONT_WAIT_FW_READY)
		priv->flags &= ~WAIT_FW_READY;

	return RSC_HANDLED;
}

/*
 * Start function for rproc_ops
 *
@@ -335,8 +426,8 @@ static int imx_dsp_rproc_start(struct rproc *rproc)

	if (ret)
		dev_err(dev, "Failed to enable remote core!\n");
	else
		ret = imx_dsp_rproc_ready(rproc);
	else if (priv->flags & WAIT_FW_READY)
		return imx_dsp_rproc_ready(rproc);

	return ret;
}
@@ -939,6 +1030,7 @@ static const struct rproc_ops imx_dsp_rproc_ops = {
	.kick		= imx_dsp_rproc_kick,
	.load		= imx_dsp_rproc_elf_load_segments,
	.parse_fw	= imx_dsp_rproc_parse_fw,
	.handle_rsc	= imx_dsp_rproc_handle_rsc,
	.find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
	.sanity_check	= rproc_elf_sanity_check,
	.get_boot_addr	= rproc_elf_get_boot_addr,
@@ -1058,6 +1150,8 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
	priv = rproc->priv;
	priv->rproc = rproc;
	priv->dsp_dcfg = dsp_dcfg;
	/* By default, host waits for fw_ready reply */
	priv->flags |= WAIT_FW_READY;

	if (no_mailboxes)
		imx_dsp_rproc_mbox_init = imx_dsp_rproc_mbox_no_alloc;
Loading