Commit fdcec004 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'rproc-v5.3' of git://github.com/andersson/remoteproc

Pull remoteproc updates from Bjorn Andersson:
 "This adds support for the STM32 remoteproc, additional i.MX platforms
  with Cortex M4 remoteprocs and Qualcomm's QCS404 Compute DSP.

  Also initial support for vendor specific resource table entries and
  support for unprocessed Qualcomm firmware files"

* tag 'rproc-v5.3' of git://github.com/andersson/remoteproc:
  remoteproc: stm32: fix building without ARM SMCC
  remoteproc: qcom: q6v5-mss: Fix build error without QCOM_MDT_LOADER
  remoteproc: copy parent dma_pfn_offset for vdev
  remoteproc: qcom: q6v5-mss: Support loading non-split images
  soc: qcom: mdt_loader: Support loading non-split images
  remoteproc: stm32: add an ST stm32_rproc driver
  dt-bindings: remoteproc: add bindings for stm32 remote processor driver
  dt-bindings: stm32: add bindings for ML-AHB interconnect
  remoteproc: Use struct_size() helper
  remoteproc: add vendor resources handling
  remoteproc: imx: Fix typo in "failed"
  remoteproc: imx: Broaden the Kconfig selection logic
  remoteproc,rpmsg: add missing MAINTAINERS file entries
  remoteproc: qcom: qdsp6-adsp: Add support for QCS404 CDSP
  dt-bindings: remoteproc: Rename and amend Hexagon v56 binding
parents 7636b758 93f1d3e4
ML-AHB interconnect bindings
These bindings describe the STM32 SoCs ML-AHB interconnect bus which connects
a Cortex-M subsystem with dedicated memories.
The MCU SRAM and RETRAM memory parts can be accessed through different addresses
(see "RAM aliases" in [1]) using different buses (see [2]) : balancing the
Cortex-M firmware accesses among those ports allows to tune the system
performance.
[1]: https://www.st.com/resource/en/reference_manual/dm00327659.pdf
[2]: https://wiki.st.com/stm32mpu/wiki/STM32MP15_RAM_mapping
Required properties:
- compatible: should be "simple-bus"
- dma-ranges: describes memory addresses translation between the local CPU and
the remote Cortex-M processor. Each memory region, is declared with
3 parameters:
- param 1: device base address (Cortex-M processor address)
- param 2: physical base address (local CPU address)
- param 3: size of the memory region.
The Cortex-M remote processor accessed via the mlahb interconnect is described
by a child node.
Example:
mlahb {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
dma-ranges = <0x00000000 0x38000000 0x10000>,
<0x10000000 0x10000000 0x60000>,
<0x30000000 0x30000000 0x60000>;
m4_rproc: m4@10000000 {
...
};
};
Qualcomm Technology Inc. ADSP Peripheral Image Loader Qualcomm Technology Inc. Hexagon v56 Peripheral Image Loader
This document defines the binding for a component that loads and boots firmware This document defines the binding for a component that loads and boots firmware
on the Qualcomm Technology Inc. ADSP Hexagon core. on the Qualcomm Technology Inc. Hexagon v56 core.
- compatible: - compatible:
Usage: required Usage: required
Value type: <string> Value type: <string>
Definition: must be one of: Definition: must be one of:
"qcom,qcs404-cdsp-pil",
"qcom,sdm845-adsp-pil" "qcom,sdm845-adsp-pil"
- reg: - reg:
...@@ -28,10 +29,11 @@ on the Qualcomm Technology Inc. ADSP Hexagon core. ...@@ -28,10 +29,11 @@ on the Qualcomm Technology Inc. ADSP Hexagon core.
- clocks: - clocks:
Usage: required Usage: required
Value type: <prop-encoded-array> Value type: <prop-encoded-array>
Definition: List of 8 phandle and clock specifier pairs for the adsp. Definition: List of phandles and clock specifier pairs for the Hexagon,
per clock-names below.
- clock-names: - clock-names:
Usage: required Usage: required for SDM845 ADSP
Value type: <stringlist> Value type: <stringlist>
Definition: List of clock input name strings sorted in the same Definition: List of clock input name strings sorted in the same
order as the clocks property. Definition must have order as the clocks property. Definition must have
...@@ -39,6 +41,14 @@ on the Qualcomm Technology Inc. ADSP Hexagon core. ...@@ -39,6 +41,14 @@ on the Qualcomm Technology Inc. ADSP Hexagon core.
"lpass_ahbm_aon_cbcr", "qdsp6ss_xo", "qdsp6ss_sleep" "lpass_ahbm_aon_cbcr", "qdsp6ss_xo", "qdsp6ss_sleep"
and "qdsp6ss_core". and "qdsp6ss_core".
- clock-names:
Usage: required for QCS404 CDSP
Value type: <stringlist>
Definition: List of clock input name strings sorted in the same
order as the clocks property. Definition must have
"xo", "sway", "tbu", "bimc", "ahb_aon", "q6ss_slave",
"q6ss_master", "q6_axim".
- power-domains: - power-domains:
Usage: required Usage: required
Value type: <phandle> Value type: <phandle>
...@@ -47,28 +57,33 @@ on the Qualcomm Technology Inc. ADSP Hexagon core. ...@@ -47,28 +57,33 @@ on the Qualcomm Technology Inc. ADSP Hexagon core.
- resets: - resets:
Usage: required Usage: required
Value type: <phandle> Value type: <phandle>
Definition: reference to the list of 2 reset-controller for the adsp. Definition: reference to the list of resets for the Hexagon.
- reset-names: - reset-names:
Usage: required Usage: required for SDM845 ADSP
Value type: <stringlist> Value type: <stringlist>
Definition: must be "pdc_sync" and "cc_lpass" Definition: must be "pdc_sync" and "cc_lpass"
- reset-names:
Usage: required for QCS404 CDSP
Value type: <stringlist>
Definition: must be "restart"
- qcom,halt-regs: - qcom,halt-regs:
Usage: required Usage: required
Value type: <prop-encoded-array> Value type: <prop-encoded-array>
Definition: a phandle reference to a syscon representing TCSR followed Definition: a phandle reference to a syscon representing TCSR followed
by the offset within syscon for lpass halt register. by the offset within syscon for Hexagon halt register.
- memory-region: - memory-region:
Usage: required Usage: required
Value type: <phandle> Value type: <phandle>
Definition: reference to the reserved-memory for the ADSP Definition: reference to the reserved-memory for the firmware
- qcom,smem-states: - qcom,smem-states:
Usage: required Usage: required
Value type: <phandle> Value type: <phandle>
Definition: reference to the smem state for requesting the ADSP to Definition: reference to the smem state for requesting the Hexagon to
shut down shut down
- qcom,smem-state-names: - qcom,smem-state-names:
...@@ -79,7 +94,7 @@ on the Qualcomm Technology Inc. ADSP Hexagon core. ...@@ -79,7 +94,7 @@ on the Qualcomm Technology Inc. ADSP Hexagon core.
= SUBNODES = SUBNODES
The adsp node may have an subnode named "glink-edge" that describes the The adsp node may have an subnode named "glink-edge" that describes the
communication edge, channels and devices related to the ADSP. communication edge, channels and devices related to the Hexagon.
See ../soc/qcom/qcom,glink.txt for details on how to describe these. See ../soc/qcom/qcom,glink.txt for details on how to describe these.
= EXAMPLE = EXAMPLE
......
STMicroelectronics STM32 Remoteproc
-----------------------------------
This document defines the binding for the remoteproc component that loads and
boots firmwares on the ST32MP family chipset.
Required properties:
- compatible: Must be "st,stm32mp1-m4"
- reg: Address ranges of the RETRAM and MCU SRAM memories used by the
remote processor.
- resets: Reference to a reset controller asserting the remote processor.
- st,syscfg-holdboot: Reference to the system configuration which holds the
remote processor reset hold boot
1st cell: phandle of syscon block
2nd cell: register offset containing the hold boot setting
3rd cell: register bitmask for the hold boot field
- st,syscfg-tz: Reference to the system configuration which holds the RCC trust
zone mode
1st cell: phandle to syscon block
2nd cell: register offset containing the RCC trust zone mode setting
3rd cell: register bitmask for the RCC trust zone mode bit
Optional properties:
- interrupts: Should contain the watchdog interrupt
- mboxes: This property is required only if the rpmsg/virtio functionality
is used. List of phandle and mailbox channel specifiers:
- a channel (a) used to communicate through virtqueues with the
remote proc.
Bi-directional channel:
- from local to remote = send message
- from remote to local = send message ack
- a channel (b) working the opposite direction of channel (a)
- a channel (c) used by the local proc to notify the remote proc
that it is about to be shut down.
Unidirectional channel:
- from local to remote, where ACK from the remote means
that it is ready for shutdown
- mbox-names: This property is required if the mboxes property is used.
- must be "vq0" for channel (a)
- must be "vq1" for channel (b)
- must be "shutdown" for channel (c)
- memory-region: List of phandles to the reserved memory regions associated with
the remoteproc device. This is variable and describes the
memories shared with the remote processor (eg: remoteproc
firmware and carveouts, rpmsg vrings, ...).
(see ../reserved-memory/reserved-memory.txt)
- st,syscfg-pdds: Reference to the system configuration which holds the remote
processor deep sleep setting
1st cell: phandle to syscon block
2nd cell: register offset containing the deep sleep setting
3rd cell: register bitmask for the deep sleep bit
- st,auto-boot: If defined, when remoteproc is probed, it loads the default
firmware and starts the remote processor.
Example:
m4_rproc: m4@10000000 {
compatible = "st,stm32mp1-m4";
reg = <0x10000000 0x40000>,
<0x30000000 0x40000>,
<0x38000000 0x10000>;
resets = <&rcc MCU_R>;
st,syscfg-holdboot = <&rcc 0x10C 0x1>;
st,syscfg-tz = <&rcc 0x000 0x1>;
};
...@@ -314,6 +314,8 @@ Here are the various resource types that are currently supported:: ...@@ -314,6 +314,8 @@ Here are the various resource types that are currently supported::
* @RSC_VDEV: declare support for a virtio device, and serve as its * @RSC_VDEV: declare support for a virtio device, and serve as its
* virtio header. * virtio header.
* @RSC_LAST: just keep this one at the end * @RSC_LAST: just keep this one at the end
* @RSC_VENDOR_START: start of the vendor specific resource types range
* @RSC_VENDOR_END: end of the vendor specific resource types range
* *
* Please note that these values are used as indices to the rproc_handle_rsc * Please note that these values are used as indices to the rproc_handle_rsc
* lookup table, so please keep them sane. Moreover, @RSC_LAST is used to * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
...@@ -326,6 +328,8 @@ Here are the various resource types that are currently supported:: ...@@ -326,6 +328,8 @@ Here are the various resource types that are currently supported::
RSC_TRACE = 2, RSC_TRACE = 2,
RSC_VDEV = 3, RSC_VDEV = 3,
RSC_LAST = 4, RSC_LAST = 4,
RSC_VENDOR_START = 128,
RSC_VENDOR_END = 512,
}; };
For more details regarding a specific resource type, please see its For more details regarding a specific resource type, please see its
......
...@@ -13590,9 +13590,11 @@ L: linux-remoteproc@vger.kernel.org ...@@ -13590,9 +13590,11 @@ L: linux-remoteproc@vger.kernel.org
T: git git://git.kernel.org/pub/scm/linux/kernel/git/ohad/remoteproc.git T: git git://git.kernel.org/pub/scm/linux/kernel/git/ohad/remoteproc.git
S: Maintained S: Maintained
F: Documentation/devicetree/bindings/remoteproc/ F: Documentation/devicetree/bindings/remoteproc/
F: Documentation/ABI/testing/sysfs-class-remoteproc
F: Documentation/remoteproc.txt F: Documentation/remoteproc.txt
F: drivers/remoteproc/ F: drivers/remoteproc/
F: include/linux/remoteproc.h F: include/linux/remoteproc.h
F: include/linux/remoteproc/
REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM
M: Ohad Ben-Cohen <ohad@wizery.com> M: Ohad Ben-Cohen <ohad@wizery.com>
...@@ -13602,8 +13604,11 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/ohad/rpmsg.git ...@@ -13602,8 +13604,11 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/ohad/rpmsg.git
S: Maintained S: Maintained
F: drivers/rpmsg/ F: drivers/rpmsg/
F: Documentation/rpmsg.txt F: Documentation/rpmsg.txt
F: Documentation/ABI/testing/sysfs-bus-rpmsg
F: include/linux/rpmsg.h F: include/linux/rpmsg.h
F: include/linux/rpmsg/ F: include/linux/rpmsg/
F: include/uapi/linux/rpmsg.h
F: samples/rpmsg/
RENESAS CLOCK DRIVERS RENESAS CLOCK DRIVERS
M: Geert Uytterhoeven <geert+renesas@glider.be> M: Geert Uytterhoeven <geert+renesas@glider.be>
......
...@@ -16,7 +16,7 @@ if REMOTEPROC ...@@ -16,7 +16,7 @@ if REMOTEPROC
config IMX_REMOTEPROC config IMX_REMOTEPROC
tristate "IMX6/7 remoteproc support" tristate "IMX6/7 remoteproc support"
depends on SOC_IMX6SX || SOC_IMX7D depends on ARCH_MXC
help help
Say y here to support iMX's remote processors (Cortex M4 Say y here to support iMX's remote processors (Cortex M4
on iMX7D) via the remote processor framework. on iMX7D) via the remote processor framework.
...@@ -116,6 +116,7 @@ config QCOM_Q6V5_MSS ...@@ -116,6 +116,7 @@ config QCOM_Q6V5_MSS
depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
depends on QCOM_SYSMON || QCOM_SYSMON=n depends on QCOM_SYSMON || QCOM_SYSMON=n
select MFD_SYSCON select MFD_SYSCON
select QCOM_MDT_LOADER
select QCOM_Q6V5_COMMON select QCOM_Q6V5_COMMON
select QCOM_RPROC_COMMON select QCOM_RPROC_COMMON
select QCOM_SCM select QCOM_SCM
...@@ -198,6 +199,21 @@ config ST_REMOTEPROC ...@@ -198,6 +199,21 @@ config ST_REMOTEPROC
config ST_SLIM_REMOTEPROC config ST_SLIM_REMOTEPROC
tristate tristate
config STM32_RPROC
tristate "STM32 remoteproc support"
depends on ARCH_STM32
depends on REMOTEPROC
select MAILBOX
help
Say y here to support STM32 MCU processors via the
remote processor framework.
You want to say y here in order to enable AMP
use-cases to run on your platform (dedicated firmware could be
offloaded to remote MCU processors using this framework).
This can be either built-in or a loadable module.
endif # REMOTEPROC endif # REMOTEPROC
endmenu endmenu
...@@ -26,3 +26,4 @@ qcom_wcnss_pil-y += qcom_wcnss.o ...@@ -26,3 +26,4 @@ qcom_wcnss_pil-y += qcom_wcnss.o
qcom_wcnss_pil-y += qcom_wcnss_iris.o qcom_wcnss_pil-y += qcom_wcnss_iris.o
obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o
obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o
obj-$(CONFIG_STM32_RPROC) += stm32_rproc.o
...@@ -165,7 +165,7 @@ static int imx_rproc_start(struct rproc *rproc) ...@@ -165,7 +165,7 @@ static int imx_rproc_start(struct rproc *rproc)
ret = regmap_update_bits(priv->regmap, dcfg->src_reg, ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
dcfg->src_mask, dcfg->src_start); dcfg->src_mask, dcfg->src_start);
if (ret) if (ret)
dev_err(dev, "Filed to enable M4!\n"); dev_err(dev, "Failed to enable M4!\n");
return ret; return ret;
} }
...@@ -180,7 +180,7 @@ static int imx_rproc_stop(struct rproc *rproc) ...@@ -180,7 +180,7 @@ static int imx_rproc_stop(struct rproc *rproc)
ret = regmap_update_bits(priv->regmap, dcfg->src_reg, ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
dcfg->src_mask, dcfg->src_stop); dcfg->src_mask, dcfg->src_stop);
if (ret) if (ret)
dev_err(dev, "Filed to stop M4!\n"); dev_err(dev, "Failed to stop M4!\n");
return ret; return ret;
} }
...@@ -203,7 +203,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da, ...@@ -203,7 +203,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,
} }
} }
dev_warn(priv->dev, "Translation filed: da = 0x%llx len = 0x%x\n", dev_warn(priv->dev, "Translation failed: da = 0x%llx len = 0x%x\n",
da, len); da, len);
return -ENOENT; return -ENOENT;
} }
...@@ -349,7 +349,7 @@ static int imx_rproc_probe(struct platform_device *pdev) ...@@ -349,7 +349,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
ret = imx_rproc_addr_init(priv, pdev); ret = imx_rproc_addr_init(priv, pdev);
if (ret) { if (ret) {
dev_err(dev, "filed on imx_rproc_addr_init\n"); dev_err(dev, "failed on imx_rproc_addr_init\n");
goto err_put_rproc; goto err_put_rproc;
} }
......
...@@ -46,11 +46,9 @@ ...@@ -46,11 +46,9 @@
#define LPASS_PWR_ON_REG 0x10 #define LPASS_PWR_ON_REG 0x10
#define LPASS_HALTREQ_REG 0x0 #define LPASS_HALTREQ_REG 0x0
/* list of clocks required by ADSP PIL */ #define QDSP6SS_XO_CBCR 0x38
static const char * const adsp_clk_id[] = { #define QDSP6SS_CORE_CBCR 0x20
"sway_cbcr", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr", #define QDSP6SS_SLEEP_CBCR 0x3c
"qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core",
};
struct adsp_pil_data { struct adsp_pil_data {
int crash_reason_smem; int crash_reason_smem;
...@@ -59,6 +57,9 @@ struct adsp_pil_data { ...@@ -59,6 +57,9 @@ struct adsp_pil_data {
const char *ssr_name; const char *ssr_name;
const char *sysmon_name; const char *sysmon_name;
int ssctl_id; int ssctl_id;
const char **clk_ids;
int num_clks;
}; };
struct qcom_adsp { struct qcom_adsp {
...@@ -75,7 +76,7 @@ struct qcom_adsp { ...@@ -75,7 +76,7 @@ struct qcom_adsp {
void __iomem *qdsp6ss_base; void __iomem *qdsp6ss_base;
struct reset_control *pdc_sync_reset; struct reset_control *pdc_sync_reset;
struct reset_control *cc_lpass_restart; struct reset_control *restart;
struct regmap *halt_map; struct regmap *halt_map;
unsigned int halt_lpass; unsigned int halt_lpass;
...@@ -143,7 +144,7 @@ static int qcom_adsp_shutdown(struct qcom_adsp *adsp) ...@@ -143,7 +144,7 @@ static int qcom_adsp_shutdown(struct qcom_adsp *adsp)
/* Assert the LPASS PDC Reset */ /* Assert the LPASS PDC Reset */
reset_control_assert(adsp->pdc_sync_reset); reset_control_assert(adsp->pdc_sync_reset);
/* Place the LPASS processor into reset */ /* Place the LPASS processor into reset */
reset_control_assert(adsp->cc_lpass_restart); reset_control_assert(adsp->restart);
/* wait after asserting subsystem restart from AOSS */ /* wait after asserting subsystem restart from AOSS */
usleep_range(200, 300); usleep_range(200, 300);
...@@ -153,7 +154,7 @@ static int qcom_adsp_shutdown(struct qcom_adsp *adsp) ...@@ -153,7 +154,7 @@ static int qcom_adsp_shutdown(struct qcom_adsp *adsp)
/* De-assert the LPASS PDC Reset */ /* De-assert the LPASS PDC Reset */
reset_control_deassert(adsp->pdc_sync_reset); reset_control_deassert(adsp->pdc_sync_reset);
/* Remove the LPASS reset */ /* Remove the LPASS reset */
reset_control_deassert(adsp->cc_lpass_restart); reset_control_deassert(adsp->restart);
/* wait after de-asserting subsystem restart from AOSS */ /* wait after de-asserting subsystem restart from AOSS */
usleep_range(200, 300); usleep_range(200, 300);
...@@ -192,6 +193,15 @@ static int adsp_start(struct rproc *rproc) ...@@ -192,6 +193,15 @@ static int adsp_start(struct rproc *rproc)
goto disable_power_domain; goto disable_power_domain;
} }
/* Enable the XO clock */
writel(1, adsp->qdsp6ss_base + QDSP6SS_XO_CBCR);
/* Enable the QDSP6SS sleep clock */
writel(1, adsp->qdsp6ss_base + QDSP6SS_SLEEP_CBCR);
/* Enable the QDSP6 core clock */
writel(1, adsp->qdsp6ss_base + QDSP6SS_CORE_CBCR);
/* Program boot address */ /* Program boot address */
writel(adsp->mem_phys >> 4, adsp->qdsp6ss_base + RST_EVB_REG); writel(adsp->mem_phys >> 4, adsp->qdsp6ss_base + RST_EVB_REG);
...@@ -280,8 +290,9 @@ static const struct rproc_ops adsp_ops = { ...@@ -280,8 +290,9 @@ static const struct rproc_ops adsp_ops = {
.load = adsp_load, .load = adsp_load,
}; };
static int adsp_init_clock(struct qcom_adsp *adsp) static int adsp_init_clock(struct qcom_adsp *adsp, const char **clk_ids)
{ {
int num_clks = 0;
int i, ret; int i, ret;
adsp->xo = devm_clk_get(adsp->dev, "xo"); adsp->xo = devm_clk_get(adsp->dev, "xo");
...@@ -292,32 +303,39 @@ static int adsp_init_clock(struct qcom_adsp *adsp) ...@@ -292,32 +303,39 @@ static int adsp_init_clock(struct qcom_adsp *adsp)
return ret; return ret;
} }
adsp->num_clks = ARRAY_SIZE(adsp_clk_id); for (i = 0; clk_ids[i]; i++)
num_clks++;
adsp->num_clks = num_clks;
adsp->clks = devm_kcalloc(adsp->dev, adsp->num_clks, adsp->clks = devm_kcalloc(adsp->dev, adsp->num_clks,
sizeof(*adsp->clks), GFP_KERNEL); sizeof(*adsp->clks), GFP_KERNEL);
if (!adsp->clks) if (!adsp->clks)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < adsp->num_clks; i++) for (i = 0; i < adsp->num_clks; i++)
adsp->clks[i].id = adsp_clk_id[i]; adsp->clks[i].id = clk_ids[i];
return devm_clk_bulk_get(adsp->dev, adsp->num_clks, adsp->clks); return devm_clk_bulk_get(adsp->dev, adsp->num_clks, adsp->clks);
} }
static int adsp_init_reset(struct qcom_adsp *adsp) static int adsp_init_reset(struct qcom_adsp *adsp)
{ {
adsp->pdc_sync_reset = devm_reset_control_get_exclusive(adsp->dev, adsp->pdc_sync_reset = devm_reset_control_get_optional_exclusive(adsp->dev,
"pdc_sync"); "pdc_sync");
if (IS_ERR(adsp->pdc_sync_reset)) { if (IS_ERR(adsp->pdc_sync_reset)) {
dev_err(adsp->dev, "failed to acquire pdc_sync reset\n"); dev_err(adsp->dev, "failed to acquire pdc_sync reset\n");
return PTR_ERR(adsp->pdc_sync_reset); return PTR_ERR(adsp->pdc_sync_reset);
} }
adsp->cc_lpass_restart = devm_reset_control_get_exclusive(adsp->dev, adsp->restart = devm_reset_control_get_optional_exclusive(adsp->dev, "restart");
"cc_lpass");
if (IS_ERR(adsp->cc_lpass_restart)) { /* Fall back to the old "cc_lpass" if "restart" is absent */
dev_err(adsp->dev, "failed to acquire cc_lpass restart\n"); if (!adsp->restart)
return PTR_ERR(adsp->cc_lpass_restart); adsp->restart = devm_reset_control_get_exclusive(adsp->dev, "cc_lpass");
if (IS_ERR(adsp->restart)) {
dev_err(adsp->dev, "failed to acquire restart\n");
return PTR_ERR(adsp->restart);
} }
return 0; return 0;
...@@ -415,7 +433,7 @@ static int adsp_probe(struct platform_device *pdev) ...@@ -415,7 +433,7 @@ static int adsp_probe(struct platform_device *pdev)
if (ret) if (ret)
goto free_rproc; goto free_rproc;
ret = adsp_init_clock(adsp); ret = adsp_init_clock(adsp, desc->clk_ids);
if (ret) if (ret)
goto free_rproc; goto free_rproc;
...@@ -479,9 +497,28 @@ static const struct adsp_pil_data adsp_resource_init = { ...@@ -479,9 +497,28 @@ static const struct adsp_pil_data adsp_resource_init = {
.ssr_name = "lpass", .ssr_name = "lpass",
.sysmon_name = "adsp", .sysmon_name = "adsp",
.ssctl_id = 0x14, .ssctl_id = 0x14,
.clk_ids = (const char*[]) {
"sway_cbcr", "lpass_ahbs_aon_cbcr", "lpass_ahbm_aon_cbcr",
"qdsp6ss_xo", "qdsp6ss_sleep", "qdsp6ss_core", NULL
},
.num_clks = 7,
};
static const struct adsp_pil_data cdsp_resource_init = {
.crash_reason_smem = 601,
.firmware_name = "cdsp.mdt",
.ssr_name = "cdsp",
.sysmon_name = "cdsp",
.ssctl_id = 0x17,
.clk_ids = (const char*[]) {
"sway", "tbu", "bimc", "ahb_aon", "q6ss_slave", "q6ss_master",
"q6_axim", NULL
},
.num_clks = 7,
}; };
static const struct of_device_id adsp_of_match[] = { static const struct of_device_id adsp_of_match[] = {
{ .compatible = "qcom,qcs404-cdsp-pil", .data = &cdsp_resource_init },
{ .compatible = "qcom,sdm845-adsp-pil", .data = &adsp_resource_init }, { .compatible = "qcom,sdm845-adsp-pil", .data = &adsp_resource_init },
{ }, { },
}; };
......
...@@ -659,23 +659,29 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw) ...@@ -659,23 +659,29 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw)
{ {
unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS; unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS;
dma_addr_t phys; dma_addr_t phys;
void *metadata;
int mdata_perm; int mdata_perm;
int xferop_ret; int xferop_ret;
size_t size;
void *ptr; void *ptr;
int ret; int ret;
ptr = dma_alloc_attrs(qproc->dev, fw->size, &phys, GFP_KERNEL, dma_attrs); metadata = qcom_mdt_read_metadata(fw, &size);
if (IS_ERR(metadata))
return PTR_ERR(metadata);
ptr = dma_alloc_attrs(qproc->dev, size, &phys, GFP_KERNEL, dma_attrs);
if (!ptr) { if (!ptr) {
kfree(metadata);
dev_err(qproc->dev, "failed to allocate mdt buffer\n"); dev_err(qproc->dev, "failed to allocate mdt buffer\n");
return -ENOMEM; return -ENOMEM;
} }
memcpy(ptr, fw->data, fw->size); memcpy(ptr, metadata, size);
/* Hypervisor mapping to access metadata by modem */ /* Hypervisor mapping to access metadata by modem */
mdata_perm = BIT(QCOM_SCM_VMID_HLOS); mdata_perm = BIT(QCOM_SCM_VMID_HLOS);
ret = q6v5_xfer_mem_ownership(qproc, &mdata_perm, ret = q6v5_xfer_mem_ownership(qproc, &mdata_perm, true, phys, size);
true, phys, fw->size);
if (ret) { if (ret) {
dev_err(qproc->dev, dev_err(qproc->dev,
"assigning Q6 access to metadata failed: %d\n", ret); "assigning Q6 access to metadata failed: %d\n", ret);
...@@ -693,14 +699,14 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw) ...@@ -693,14 +699,14 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw)
dev_err(qproc->dev, "MPSS header authentication failed: %d\n", ret); dev_err(qproc->dev, "MPSS header authentication failed: %d\n", ret);
/* Metadata authentication done, remove modem access */ /* Metadata authentication done, remove modem access */
xferop_ret = q6v5_xfer_mem_ownership(qproc, &mdata_perm, xferop_ret = q6v5_xfer_mem_ownership(qproc, &mdata_perm, false, phys, size);
false, phys, fw->size);
if (xferop_ret) if (xferop_ret)
dev_warn(qproc->dev, dev_warn(qproc->dev,
"mdt buffer not reclaimed system may become unstable\n"); "mdt buffer not reclaimed system may become unstable\n");
free_dma_attrs: free_dma_attrs:
dma_free_attrs(qproc->dev, fw->size, ptr, phys, dma_attrs); dma_free_attrs(qproc->dev, size, ptr, phys, dma_attrs);
kfree(metadata);
return ret < 0 ? ret : 0; return ret < 0 ? ret : 0;
} }
...@@ -981,7 +987,18 @@ static int q6v5_mpss_load(struct q6v5 *qproc) ...@@ -981,7 +987,18 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
ptr = qproc->mpss_region + offset; ptr = qproc->mpss_region + offset;
if (phdr->p_filesz) { if (phdr->p_filesz && phdr->p_offset < fw->size) {
/* Firmware is large enough to be non-split */
if (phdr->p_offset + phdr->p_filesz > fw->size) {
dev_err(qproc->dev,
"failed to load segment %d from truncated file %s\n",
i, fw_name);
ret = -EINVAL;
goto release_firmware;
}
memcpy(ptr, fw->data + phdr->p_offset, phdr->p_filesz);
} else if (phdr->p_filesz) {
/* Replace "xxx.xxx" with "xxx.bxx" */ /* Replace "xxx.xxx" with "xxx.bxx" */
sprintf(fw_name + fw_name_len - 3, "b%02d", i); sprintf(fw_name + fw_name_len - 3, "b%02d", i);
ret = request_firmware(&seg_fw, fw_name, qproc->dev); ret = request_firmware(&seg_fw, fw_name, qproc->dev);
......
...@@ -512,6 +512,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, ...@@ -512,6 +512,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc,
/* Initialise vdev subdevice */ /* Initialise vdev subdevice */
snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index);
rvdev->dev.parent = rproc->dev.parent; rvdev->dev.parent = rproc->dev.parent;
rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset;
rvdev->dev.release = rproc_rvdev_release; rvdev->dev.release = rproc_rvdev_release;
dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name); dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name);
dev_set_drvdata(&rvdev->dev, rvdev); dev_set_drvdata(&rvdev->dev, rvdev);
...@@ -1058,6 +1059,20 @@ static int rproc_handle_resources(struct rproc *rproc, ...@@ -1058,6 +1059,20 @@ static int rproc_handle_resources(struct rproc *rproc,
dev_dbg(dev, "rsc: type %d\n", hdr->type); dev_dbg(dev, "rsc: type %d\n", hdr->type);
if (hdr->type >= RSC_VENDOR_START &&
hdr->type <= RSC_VENDOR_END) {
ret = rproc_handle_rsc(rproc, hdr->type, rsc,
offset + sizeof(*hdr), avail);
if (ret == RSC_HANDLED)
continue;
else if (ret < 0)
break;
dev_warn(dev, "unsupported vendor resource %d\n",
hdr->type);
continue;
}
if (hdr->type >= RSC_LAST) { if (hdr->type >= RSC_LAST) {
dev_warn(dev, "unsupported resource %d\n", hdr->type); dev_warn(dev, "unsupported resource %d\n", hdr->type);
continue; continue;
......
...@@ -247,8 +247,7 @@ find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size) ...@@ -247,8 +247,7 @@ find_table(struct device *dev, struct elf32_hdr *ehdr, size_t fw_size)
} }
/* make sure the offsets array isn't truncated */ /* make sure the offsets array isn't truncated */
if (table->num * sizeof(table->offset[0]) + if (struct_size(table, offset, table->num) > size) {
sizeof(struct resource_table) > size) {
dev_err(dev, "resource table incomplete\n"); dev_err(dev, "resource table incomplete\n");
return NULL; return NULL;
} }
......
...@@ -98,6 +98,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw) ...@@ -98,6 +98,17 @@ static inline int rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
return 0; return 0;
} }
static inline
int rproc_handle_rsc(struct rproc *rproc, u32 rsc_type, void *rsc, int offset,
int avail)
{
if (rproc->ops->handle_rsc)
return rproc->ops->handle_rsc(rproc, rsc_type, rsc, offset,
avail);
return RSC_IGNORED;
}
static inline static inline
struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc, struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
const struct firmware *fw) const struct firmware *fw)
......
This diff is collapsed.
...@@ -66,6 +66,66 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw) ...@@ -66,6 +66,66 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)
} }
EXPORT_SYMBOL_GPL(qcom_mdt_get_size); EXPORT_SYMBOL_GPL(qcom_mdt_get_size);
/**
* qcom_mdt_read_metadata() - read header and metadata from mdt or mbn
* @fw: firmware of mdt header or mbn
* @data_len: length of the read metadata blob
*
* The mechanism that performs the authentication of the loading firmware
* expects an ELF header directly followed by the segment of hashes, with no
* padding inbetween. This function allocates a chunk of memory for this pair
* and copy the two pieces into the buffer.
*
* In the case of split firmware the hash is found directly following the ELF
* header, rather than at p_offset described by the second program header.
*
* The caller is responsible to free (kfree()) the returned pointer.
*
* Return: pointer to data, or ERR_PTR()
*/
void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len)
{
const struct elf32_phdr *phdrs;
const struct elf32_hdr *ehdr;
size_t hash_offset;
size_t hash_size;
size_t ehdr_size;
void *data;
ehdr = (struct elf32_hdr *)fw->data;
phdrs = (struct elf32_phdr *)(ehdr + 1);
if (ehdr->e_phnum < 2)
return ERR_PTR(-EINVAL);
if (phdrs[0].p_type == PT_LOAD || phdrs[1].p_type == PT_LOAD)
return ERR_PTR(-EINVAL);
if ((phdrs[1].p_flags & QCOM_MDT_TYPE_MASK) != QCOM_MDT_TYPE_HASH)
return ERR_PTR(-EINVAL);
ehdr_size = phdrs[0].p_filesz;
hash_size = phdrs[1].p_filesz;
data = kmalloc(ehdr_size + hash_size, GFP_KERNEL);
if (!data)
return ERR_PTR(-ENOMEM);
/* Is the header and hash already packed */
if (ehdr_size + hash_size == fw->size)
hash_offset = phdrs[0].p_filesz;
else
hash_offset = phdrs[1].p_offset;
memcpy(data, fw->data, ehdr_size);
memcpy(data + ehdr_size, fw->data + hash_offset, hash_size);
*data_len = ehdr_size + hash_size;
return data;
}
EXPORT_SYMBOL_GPL(qcom_mdt_read_metadata);
static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
const char *firmware, int pas_id, void *mem_region, const char *firmware, int pas_id, void *mem_region,
phys_addr_t mem_phys, size_t mem_size, phys_addr_t mem_phys, size_t mem_size,
...@@ -78,12 +138,14 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, ...@@ -78,12 +138,14 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
phys_addr_t mem_reloc; phys_addr_t mem_reloc;
phys_addr_t min_addr = PHYS_ADDR_MAX; phys_addr_t min_addr = PHYS_ADDR_MAX;
phys_addr_t max_addr = 0; phys_addr_t max_addr = 0;
size_t metadata_len;
size_t fw_name_len; size_t fw_name_len;
ssize_t offset; ssize_t offset;
void *metadata;
char *fw_name; char *fw_name;
bool relocate = false; bool relocate = false;
void *ptr; void *ptr;
int ret; int ret = 0;
int i; int i;
if (!fw || !mem_region || !mem_phys || !mem_size) if (!fw || !mem_region || !mem_phys || !mem_size)
...@@ -101,7 +163,15 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, ...@@ -101,7 +163,15 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
return -ENOMEM; return -ENOMEM;
if (pas_init) { if (pas_init) {
ret = qcom_scm_pas_init_image(pas_id, fw->data, fw->size); metadata = qcom_mdt_read_metadata(fw, &metadata_len);
if (IS_ERR(metadata)) {
ret = PTR_ERR(metadata);
goto out;
}
ret = qcom_scm_pas_init_image(pas_id, metadata, metadata_len);
kfree(metadata);
if (ret) { if (ret) {
dev_err(dev, "invalid firmware metadata\n"); dev_err(dev, "invalid firmware metadata\n");
goto out; goto out;
...@@ -162,7 +232,19 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, ...@@ -162,7 +232,19 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
ptr = mem_region + offset; ptr = mem_region + offset;
if (phdr->p_filesz) { if (phdr->p_filesz && phdr->p_offset < fw->size) {
/* Firmware is large enough to be non-split */
if (phdr->p_offset + phdr->p_filesz > fw->size) {
dev_err(dev,
"failed to load segment %d from truncated file %s\n",
i, firmware);
ret = -EINVAL;
break;
}
memcpy(ptr, fw->data + phdr->p_offset, phdr->p_filesz);
} else if (phdr->p_filesz) {
/* Firmware not large enough, load split-out segments */
sprintf(fw_name + fw_name_len - 3, "b%02d", i); sprintf(fw_name + fw_name_len - 3, "b%02d", i);
ret = request_firmware_into_buf(&seg_fw, fw_name, dev, ret = request_firmware_into_buf(&seg_fw, fw_name, dev,
ptr, phdr->p_filesz); ptr, phdr->p_filesz);
......
...@@ -100,7 +100,9 @@ struct fw_rsc_hdr { ...@@ -100,7 +100,9 @@ struct fw_rsc_hdr {
* the remote processor will be writing logs. * the remote processor will be writing logs.
* @RSC_VDEV: declare support for a virtio device, and serve as its * @RSC_VDEV: declare support for a virtio device, and serve as its
* virtio header. * virtio header.
* @RSC_LAST: just keep this one at the end * @RSC_LAST: just keep this one at the end of standard resources
* @RSC_VENDOR_START: start of the vendor specific resource types range
* @RSC_VENDOR_END: end of the vendor specific resource types range
* *
* For more details regarding a specific resource type, please see its * For more details regarding a specific resource type, please see its
* dedicated structure below. * dedicated structure below.
...@@ -116,6 +118,8 @@ enum fw_resource_type { ...@@ -116,6 +118,8 @@ enum fw_resource_type {
RSC_TRACE = 2, RSC_TRACE = 2,
RSC_VDEV = 3, RSC_VDEV = 3,
RSC_LAST = 4, RSC_LAST = 4,
RSC_VENDOR_START = 128,
RSC_VENDOR_END = 512,
}; };
#define FW_RSC_ADDR_ANY (-1) #define FW_RSC_ADDR_ANY (-1)
...@@ -339,6 +343,16 @@ struct rproc_mem_entry { ...@@ -339,6 +343,16 @@ struct rproc_mem_entry {
struct firmware; struct firmware;
/**
* enum rsc_handling_status - return status of rproc_ops handle_rsc hook
* @RSC_HANDLED: resource was handled
* @RSC_IGNORED: resource was ignored
*/
enum rsc_handling_status {
RSC_HANDLED = 0,
RSC_IGNORED = 1,
};
/** /**
* struct rproc_ops - platform-specific device handlers * struct rproc_ops - platform-specific device handlers
* @start: power on the device and boot it * @start: power on the device and boot it
...@@ -346,6 +360,10 @@ struct firmware; ...@@ -346,6 +360,10 @@ struct firmware;
* @kick: kick a virtqueue (virtqueue id given as a parameter) * @kick: kick a virtqueue (virtqueue id given as a parameter)
* @da_to_va: optional platform hook to perform address translations * @da_to_va: optional platform hook to perform address translations
* @parse_fw: parse firmware to extract information (e.g. resource table) * @parse_fw: parse firmware to extract information (e.g. resource table)
* @handle_rsc: optional platform hook to handle vendor resources. Should return
* RSC_HANDLED if resource was handled, RSC_IGNORED if not handled and a
* negative value on error
* @load_rsc_table: load resource table from firmware image
* @find_loaded_rsc_table: find the loaded resouce table * @find_loaded_rsc_table: find the loaded resouce table
* @load: load firmware to memory, where the remote processor * @load: load firmware to memory, where the remote processor
* expects to find it * expects to find it
...@@ -358,6 +376,8 @@ struct rproc_ops { ...@@ -358,6 +376,8 @@ struct rproc_ops {
void (*kick)(struct rproc *rproc, int vqid); void (*kick)(struct rproc *rproc, int vqid);
void * (*da_to_va)(struct rproc *rproc, u64 da, int len); void * (*da_to_va)(struct rproc *rproc, u64 da, int len);
int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw);
int (*handle_rsc)(struct rproc *rproc, u32 rsc_type, void *rsc,
int offset, int avail);
struct resource_table *(*find_loaded_rsc_table)( struct resource_table *(*find_loaded_rsc_table)(
struct rproc *rproc, const struct firmware *fw); struct rproc *rproc, const struct firmware *fw);
int (*load)(struct rproc *rproc, const struct firmware *fw); int (*load)(struct rproc *rproc, const struct firmware *fw);
......
...@@ -21,4 +21,6 @@ int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw, ...@@ -21,4 +21,6 @@ int qcom_mdt_load_no_init(struct device *dev, const struct firmware *fw,
const char *fw_name, int pas_id, void *mem_region, const char *fw_name, int pas_id, void *mem_region,
phys_addr_t mem_phys, size_t mem_size, phys_addr_t mem_phys, size_t mem_size,
phys_addr_t *reloc_base); phys_addr_t *reloc_base);
void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment