Commit d0fe3f47 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'rproc-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc

Pull remoteproc updates from Bjorn Andersson:
 "This adds support for controlling the PRU and R5F clusters on the TI
  AM64x, the remote processor in i.MX7ULP, i.MX8MN/P and i.MX8ULP NXP
  and the audio, compute and modem remoteprocs in the Qualcomm SC8180x
  platform.

  It fixes improper ordering of cdev and device creation of the
  remoteproc control interface and it fixes resource leaks in the error
  handling path of rproc_add() and the Qualcomm modem and wifi
  remoteproc drivers.

  Lastly it fixes a few build warnings and replace the dummy parameter
  passed in the mailbox api of the stm32 driver to something not living
  on the stack"

* tag 'rproc-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc: (32 commits)
  remoteproc: qcom: pas: Add SC8180X adsp, cdsp and mpss
  dt-bindings: remoteproc: qcom: pas: Add SC8180X adsp, cdsp and mpss
  remoteproc: imx_rproc: support i.MX8ULP
  dt-bindings: remoteproc: imx_rproc: support i.MX8ULP
  remoteproc: stm32: fix mbox_send_message call
  remoteproc: core: Cleanup device in case of failure
  remoteproc: core: Fix cdev remove and rproc del
  remoteproc: core: Move validate before device add
  remoteproc: core: Move cdev add before device add
  remoteproc: pru: Add support for various PRU cores on K3 AM64x SoCs
  dt-bindings: remoteproc: pru: Update bindings for K3 AM64x SoCs
  remoteproc: qcom_wcnss: Use devm_qcom_smem_state_get()
  remoteproc: qcom_q6v5: Use devm_qcom_smem_state_get() to fix missing put()
  soc: qcom: smem_state: Add devm_qcom_smem_state_get()
  dt-bindings: remoteproc: qcom: pas: Fix indentation warnings
  remoteproc: imx-rproc: Fix IMX_REMOTEPROC configuration
  remoteproc: imx_rproc: support i.MX8MN/P
  remoteproc: imx_rproc: support i.MX7ULP
  remoteproc: imx_rproc: make clk optional
  remoteproc: imx_rproc: initial support for mutilple start/stop method
  ...
parents 77d34a46 aef6a521
...@@ -17,7 +17,11 @@ properties: ...@@ -17,7 +17,11 @@ properties:
enum: enum:
- fsl,imx8mq-cm4 - fsl,imx8mq-cm4
- fsl,imx8mm-cm4 - fsl,imx8mm-cm4
- fsl,imx8mn-cm7
- fsl,imx8mp-cm7
- fsl,imx8ulp-cm33
- fsl,imx7d-cm4 - fsl,imx7d-cm4
- fsl,imx7ulp-cm4
- fsl,imx6sx-cm4 - fsl,imx6sx-cm4
clocks: clocks:
...@@ -49,10 +53,14 @@ properties: ...@@ -49,10 +53,14 @@ properties:
minItems: 1 minItems: 1
maxItems: 32 maxItems: 32
fsl,auto-boot:
$ref: /schemas/types.yaml#/definitions/flag
description:
Indicate whether need to load the default firmware and start the remote
processor automatically.
required: required:
- compatible - compatible
- clocks
- syscon
additionalProperties: false additionalProperties: false
......
Qualcomm ADSP Peripheral Image Loader
This document defines the binding for a component that loads and boots firmware
on the Qualcomm ADSP Hexagon core.
- compatible:
Usage: required
Value type: <string>
Definition: must be one of:
"qcom,msm8974-adsp-pil"
"qcom,msm8996-adsp-pil"
"qcom,msm8996-slpi-pil"
"qcom,msm8998-adsp-pas"
"qcom,msm8998-slpi-pas"
"qcom,qcs404-adsp-pas"
"qcom,qcs404-cdsp-pas"
"qcom,qcs404-wcss-pas"
"qcom,sc7180-mpss-pas"
"qcom,sdm845-adsp-pas"
"qcom,sdm845-cdsp-pas"
"qcom,sdx55-mpss-pas"
"qcom,sm8150-adsp-pas"
"qcom,sm8150-cdsp-pas"
"qcom,sm8150-mpss-pas"
"qcom,sm8150-slpi-pas"
"qcom,sm8250-adsp-pas"
"qcom,sm8250-cdsp-pas"
"qcom,sm8250-slpi-pas"
"qcom,sm8350-adsp-pas"
"qcom,sm8350-cdsp-pas"
"qcom,sm8350-slpi-pas"
"qcom,sm8350-mpss-pas"
- interrupts-extended:
Usage: required
Value type: <prop-encoded-array>
Definition: reference to the interrupts that match interrupt-names
- interrupt-names:
Usage: required
Value type: <stringlist>
Definition: The interrupts needed depends on the compatible
string:
qcom,msm8974-adsp-pil:
qcom,msm8996-adsp-pil:
qcom,msm8996-slpi-pil:
qcom,msm8998-adsp-pas:
qcom,msm8998-slpi-pas:
qcom,qcs404-adsp-pas:
qcom,qcs404-cdsp-pas:
qcom,sdm845-adsp-pas:
qcom,sdm845-cdsp-pas:
qcom,sm8150-adsp-pas:
qcom,sm8150-cdsp-pas:
qcom,sm8150-slpi-pas:
qcom,sm8250-adsp-pas:
qcom,sm8250-cdsp-pas:
qcom,sm8250-slpi-pas:
qcom,sm8350-adsp-pas:
qcom,sm8350-cdsp-pas:
qcom,sm8350-slpi-pas:
must be "wdog", "fatal", "ready", "handover", "stop-ack"
qcom,qcs404-wcss-pas:
qcom,sc7180-mpss-pas:
qcom,sdx55-mpss-pas:
qcom,sm8150-mpss-pas:
qcom,sm8350-mpss-pas:
must be "wdog", "fatal", "ready", "handover", "stop-ack",
"shutdown-ack"
- firmware-name:
Usage: optional
Value type: <string>
Definition: must list the relative firmware image path for the
Hexagon Core.
- clocks:
Usage: required
Value type: <prop-encoded-array>
Definition: reference to the xo clock and optionally aggre2 clock to be
held on behalf of the booting Hexagon core
- clock-names:
Usage: required
Value type: <stringlist>
Definition: must be "xo" and optionally include "aggre2"
- cx-supply:
Usage: required
Value type: <phandle>
Definition: reference to the regulator to be held on behalf of the
booting Hexagon core
- px-supply:
Usage: required
Value type: <phandle>
Definition: reference to the px regulator to be held on behalf of the
booting Hexagon core
- power-domains:
Usage: required
Value type: <phandle>
Definition: reference to power-domains that match the power-domain-names
- power-domain-names:
Usage: required
Value type: <stringlist>
Definition: The power-domains needed depend on the compatible string:
qcom,msm8974-adsp-pil:
qcom,msm8996-adsp-pil:
qcom,msm8998-adsp-pas:
must be "cx"
qcom,msm8996-slpi-pil:
must be "ss_cx"
qcom,msm8998-slpi-pas:
must be "ssc_cx"
qcom,qcs404-adsp-pas:
must be "lpi_cx"
qcom,qcs404-cdsp-pas:
qcom,qcs404-wcss-pas:
must be "mx"
qcom,sdm845-adsp-pas:
qcom,sdm845-cdsp-pas:
qcom,sm8150-adsp-pas:
qcom,sm8150-cdsp-pas:
qcom,sm8250-cdsp-pas:
qcom,sm8350-cdsp-pas:
must be "cx", "load_state"
qcom,sc7180-mpss-pas:
qcom,sm8150-mpss-pas:
qcom,sm8350-mpss-pas:
must be "cx", "load_state", "mss"
qcom,sdx55-mpss-pas:
must be "cx", "mss"
qcom,sm8250-adsp-pas:
qcom,sm8350-adsp-pas:
qcom,sm8150-slpi-pas:
qcom,sm8250-slpi-pas:
qcom,sm8350-slpi-pas:
must be "lcx", "lmx", "load_state"
- memory-region:
Usage: required
Value type: <phandle>
Definition: reference to the reserved-memory for the ADSP
- qcom,smem-states:
Usage: required
Value type: <phandle>
Definition: reference to the smem state for requesting the ADSP to
shut down
- qcom,smem-state-names:
Usage: required
Value type: <stringlist>
Definition: must be "stop"
= SUBNODES
The adsp node may have an subnode named either "smd-edge" or "glink-edge" that
describes the communication edge, channels and devices related to the ADSP.
See ../soc/qcom/qcom,smd.txt and ../soc/qcom/qcom,glink.txt for details on how
to describe these.
= EXAMPLE
The following example describes the resources needed to boot control the
ADSP, as it is found on MSM8974 boards.
adsp {
compatible = "qcom,msm8974-adsp-pil";
interrupts-extended = <&intc 0 162 IRQ_TYPE_EDGE_RISING>,
<&adsp_smp2p_in 0 IRQ_TYPE_EDGE_RISING>,
<&adsp_smp2p_in 1 IRQ_TYPE_EDGE_RISING>,
<&adsp_smp2p_in 2 IRQ_TYPE_EDGE_RISING>,
<&adsp_smp2p_in 3 IRQ_TYPE_EDGE_RISING>;
interrupt-names = "wdog",
"fatal",
"ready",
"handover",
"stop-ack";
clocks = <&rpmcc RPM_CXO_CLK>;
clock-names = "xo";
cx-supply = <&pm8841_s2>;
memory-region = <&adsp_region>;
qcom,smem-states = <&adsp_smp2p_out 0>;
qcom,smem-state-names = "stop";
smd-edge {
interrupts = <0 156 IRQ_TYPE_EDGE_RISING>;
qcom,ipc = <&apcs 8 8>;
qcom,smd-edge = <1>;
};
};
The following example describes the resources needed to boot control the
SLPI, as it is found on MSM8996 boards.
slpi {
compatible = "qcom,msm8996-slpi-pil";
interrupts-extended = <&intc 0 390 IRQ_TYPE_EDGE_RISING>,
<&slpi_smp2p_in 0 IRQ_TYPE_EDGE_RISING>,
<&slpi_smp2p_in 1 IRQ_TYPE_EDGE_RISING>,
<&slpi_smp2p_in 2 IRQ_TYPE_EDGE_RISING>,
<&slpi_smp2p_in 3 IRQ_TYPE_EDGE_RISING>;
interrupt-names = "wdog",
"fatal",
"ready",
"handover",
"stop-ack";
clocks = <&rpmcc MSM8996_RPM_SMD_XO_CLK_SRC>,
<&rpmcc MSM8996_RPM_SMD_AGGR2_NOC_CLK>;
clock-names = "xo", "aggre2";
cx-supply = <&pm8994_l26>;
px-supply = <&pm8994_lvs2>;
memory-region = <&slpi_region>;
qcom,smem-states = <&slpi_smp2p_out 0>;
qcom,smem-state-names = "stop";
};
This diff is collapsed.
...@@ -14,8 +14,12 @@ description: | ...@@ -14,8 +14,12 @@ description: |
processor subsystems/clusters (R5FSS). The dual core cluster can be used processor subsystems/clusters (R5FSS). The dual core cluster can be used
either in a LockStep mode providing safety/fault tolerance features or in a either in a LockStep mode providing safety/fault tolerance features or in a
Split mode providing two individual compute cores for doubling the compute Split mode providing two individual compute cores for doubling the compute
capacity. These are used together with other processors present on the SoC capacity on most SoCs. These are used together with other processors present
to achieve various system level goals. on the SoC to achieve various system level goals.
AM64x SoCs do not support LockStep mode, but rather a new non-safety mode
called "Single-CPU" mode, where only Core0 is used, but with ability to use
Core1's TCMs as well.
Each Dual-Core R5F sub-system is represented as a single DTS node Each Dual-Core R5F sub-system is represented as a single DTS node
representing the cluster, with a pair of child DT nodes representing representing the cluster, with a pair of child DT nodes representing
...@@ -33,6 +37,7 @@ properties: ...@@ -33,6 +37,7 @@ properties:
- ti,am654-r5fss - ti,am654-r5fss
- ti,j721e-r5fss - ti,j721e-r5fss
- ti,j7200-r5fss - ti,j7200-r5fss
- ti,am64-r5fss
power-domains: power-domains:
description: | description: |
...@@ -56,11 +61,12 @@ properties: ...@@ -56,11 +61,12 @@ properties:
ti,cluster-mode: ti,cluster-mode:
$ref: /schemas/types.yaml#/definitions/uint32 $ref: /schemas/types.yaml#/definitions/uint32
enum: [0, 1]
description: | description: |
Configuration Mode for the Dual R5F cores within the R5F cluster. Configuration Mode for the Dual R5F cores within the R5F cluster.
Should be either a value of 1 (LockStep mode) or 0 (Split mode), Should be either a value of 1 (LockStep mode) or 0 (Split mode) on
default is LockStep mode if omitted. most SoCs (AM65x, J721E, J7200), default is LockStep mode if omitted;
and should be either a value of 0 (Split mode) or 2 (Single-CPU mode)
on AM64x SoCs, default is Split mode if omitted.
# R5F Processor Child Nodes: # R5F Processor Child Nodes:
# ========================== # ==========================
...@@ -97,6 +103,7 @@ patternProperties: ...@@ -97,6 +103,7 @@ patternProperties:
- ti,am654-r5f - ti,am654-r5f
- ti,j721e-r5f - ti,j721e-r5f
- ti,j7200-r5f - ti,j7200-r5f
- ti,am64-r5f
reg: reg:
items: items:
...@@ -198,6 +205,20 @@ patternProperties: ...@@ -198,6 +205,20 @@ patternProperties:
unevaluatedProperties: false unevaluatedProperties: false
if:
properties:
compatible:
enum:
- ti,am64-r5fss
then:
properties:
ti,cluster-mode:
enum: [0, 2]
else:
properties:
ti,cluster-mode:
enum: [0, 1]
required: required:
- compatible - compatible
- power-domains - power-domains
......
...@@ -36,6 +36,9 @@ properties: ...@@ -36,6 +36,9 @@ properties:
enum: enum:
- ti,am3356-pru # for AM335x SoC family (AM3356+ SoCs only) - ti,am3356-pru # for AM335x SoC family (AM3356+ SoCs only)
- ti,am4376-pru # for AM437x SoC family (AM4376+ SoCs only) - ti,am4376-pru # for AM437x SoC family (AM4376+ SoCs only)
- ti,am642-pru # for PRUs in K3 AM64x SoC family
- ti,am642-rtu # for RTUs in K3 AM64x SoC family
- ti,am642-tx-pru # for Tx_PRUs in K3 AM64x SoC family
- ti,am5728-pru # for AM57xx SoC family - ti,am5728-pru # for AM57xx SoC family
- ti,k2g-pru # for 66AK2G SoC family - ti,k2g-pru # for 66AK2G SoC family
- ti,am654-pru # for PRUs in K3 AM65x SoC family - ti,am654-pru # for PRUs in K3 AM65x SoC family
...@@ -68,6 +71,7 @@ if: ...@@ -68,6 +71,7 @@ if:
enum: enum:
- ti,am654-rtu - ti,am654-rtu
- ti,j721e-rtu - ti,j721e-rtu
- ti,am642-rtu
then: then:
properties: properties:
$nodename: $nodename:
...@@ -79,6 +83,7 @@ else: ...@@ -79,6 +83,7 @@ else:
enum: enum:
- ti,am654-tx-pru - ti,am654-tx-pru
- ti,j721e-tx-pru - ti,j721e-tx-pru
- ti,am642-tx-pru
then: then:
properties: properties:
$nodename: $nodename:
......
...@@ -26,6 +26,7 @@ config REMOTEPROC_CDEV ...@@ -26,6 +26,7 @@ config REMOTEPROC_CDEV
config IMX_REMOTEPROC config IMX_REMOTEPROC
tristate "i.MX remoteproc support" tristate "i.MX remoteproc support"
depends on ARCH_MXC depends on ARCH_MXC
depends on HAVE_ARM_SMCCC
select MAILBOX select MAILBOX
help help
Say y here to support iMX's remote processors via the remote Say y here to support iMX's remote processors via the remote
......
This diff is collapsed.
...@@ -887,6 +887,9 @@ static const struct of_device_id pru_rproc_match[] = { ...@@ -887,6 +887,9 @@ static const struct of_device_id pru_rproc_match[] = {
{ .compatible = "ti,am3356-pru", .data = &pru_data }, { .compatible = "ti,am3356-pru", .data = &pru_data },
{ .compatible = "ti,am4376-pru", .data = &pru_data }, { .compatible = "ti,am4376-pru", .data = &pru_data },
{ .compatible = "ti,am5728-pru", .data = &pru_data }, { .compatible = "ti,am5728-pru", .data = &pru_data },
{ .compatible = "ti,am642-pru", .data = &k3_pru_data },
{ .compatible = "ti,am642-rtu", .data = &k3_rtu_data },
{ .compatible = "ti,am642-tx-pru", .data = &k3_tx_pru_data },
{ .compatible = "ti,k2g-pru", .data = &pru_data }, { .compatible = "ti,k2g-pru", .data = &pru_data },
{ .compatible = "ti,am654-pru", .data = &k3_pru_data }, { .compatible = "ti,am654-pru", .data = &k3_pru_data },
{ .compatible = "ti,am654-rtu", .data = &k3_rtu_data }, { .compatible = "ti,am654-rtu", .data = &k3_rtu_data },
......
...@@ -280,7 +280,7 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct platform_device *pdev, ...@@ -280,7 +280,7 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct platform_device *pdev,
return ret; return ret;
} }
q6v5->state = qcom_smem_state_get(&pdev->dev, "stop", &q6v5->stop_bit); q6v5->state = devm_qcom_smem_state_get(&pdev->dev, "stop", &q6v5->stop_bit);
if (IS_ERR(q6v5->state)) { if (IS_ERR(q6v5->state)) {
dev_err(&pdev->dev, "failed to acquire stop state\n"); dev_err(&pdev->dev, "failed to acquire stop state\n");
return PTR_ERR(q6v5->state); return PTR_ERR(q6v5->state);
......
...@@ -689,6 +689,25 @@ static const struct adsp_data mpss_resource_init = { ...@@ -689,6 +689,25 @@ static const struct adsp_data mpss_resource_init = {
.ssctl_id = 0x12, .ssctl_id = 0x12,
}; };
static const struct adsp_data sc8180x_mpss_resource = {
.crash_reason_smem = 421,
.firmware_name = "modem.mdt",
.pas_id = 4,
.has_aggre2_clk = false,
.auto_boot = false,
.active_pd_names = (char*[]){
"load_state",
NULL
},
.proxy_pd_names = (char*[]){
"cx",
NULL
},
.ssr_name = "mpss",
.sysmon_name = "modem",
.ssctl_id = 0x12,
};
static const struct adsp_data slpi_resource_init = { static const struct adsp_data slpi_resource_init = {
.crash_reason_smem = 424, .crash_reason_smem = 424,
.firmware_name = "slpi.mdt", .firmware_name = "slpi.mdt",
...@@ -811,6 +830,9 @@ static const struct of_device_id adsp_of_match[] = { ...@@ -811,6 +830,9 @@ static const struct of_device_id adsp_of_match[] = {
{ .compatible = "qcom,qcs404-cdsp-pas", .data = &cdsp_resource_init }, { .compatible = "qcom,qcs404-cdsp-pas", .data = &cdsp_resource_init },
{ .compatible = "qcom,qcs404-wcss-pas", .data = &wcss_resource_init }, { .compatible = "qcom,qcs404-wcss-pas", .data = &wcss_resource_init },
{ .compatible = "qcom,sc7180-mpss-pas", .data = &mpss_resource_init}, { .compatible = "qcom,sc7180-mpss-pas", .data = &mpss_resource_init},
{ .compatible = "qcom,sc8180x-adsp-pas", .data = &sm8150_adsp_resource},
{ .compatible = "qcom,sc8180x-cdsp-pas", .data = &sm8150_cdsp_resource},
{ .compatible = "qcom,sc8180x-mpss-pas", .data = &sc8180x_mpss_resource},
{ .compatible = "qcom,sdm845-adsp-pas", .data = &adsp_resource_init}, { .compatible = "qcom,sdm845-adsp-pas", .data = &adsp_resource_init},
{ .compatible = "qcom,sdm845-cdsp-pas", .data = &cdsp_resource_init}, { .compatible = "qcom,sdm845-cdsp-pas", .data = &cdsp_resource_init},
{ .compatible = "qcom,sdx55-mpss-pas", .data = &sdx55_mpss_resource}, { .compatible = "qcom,sdx55-mpss-pas", .data = &sdx55_mpss_resource},
......
...@@ -624,8 +624,8 @@ static int wcnss_probe(struct platform_device *pdev) ...@@ -624,8 +624,8 @@ static int wcnss_probe(struct platform_device *pdev)
wcnss->stop_ack_irq = ret; wcnss->stop_ack_irq = ret;
if (wcnss->stop_ack_irq) { if (wcnss->stop_ack_irq) {
wcnss->state = qcom_smem_state_get(&pdev->dev, "stop", wcnss->state = devm_qcom_smem_state_get(&pdev->dev, "stop",
&wcnss->stop_bit); &wcnss->stop_bit);
if (IS_ERR(wcnss->state)) { if (IS_ERR(wcnss->state)) {
ret = PTR_ERR(wcnss->state); ret = PTR_ERR(wcnss->state);
goto detach_pds; goto detach_pds;
...@@ -659,7 +659,6 @@ static int wcnss_remove(struct platform_device *pdev) ...@@ -659,7 +659,6 @@ static int wcnss_remove(struct platform_device *pdev)
of_platform_depopulate(&pdev->dev); of_platform_depopulate(&pdev->dev);
qcom_smem_state_put(wcnss->state);
rproc_del(wcnss->rproc); rproc_del(wcnss->rproc);
qcom_remove_sysmon_subdev(wcnss->sysmon); qcom_remove_sysmon_subdev(wcnss->sysmon);
......
...@@ -124,7 +124,7 @@ int rproc_char_device_add(struct rproc *rproc) ...@@ -124,7 +124,7 @@ int rproc_char_device_add(struct rproc *rproc)
void rproc_char_device_remove(struct rproc *rproc) void rproc_char_device_remove(struct rproc *rproc)
{ {
__unregister_chrdev(MAJOR(rproc->dev.devt), rproc->index, 1, "remoteproc"); cdev_del(&rproc->cdev);
} }
void __init rproc_init_cdev(void) void __init rproc_init_cdev(void)
......
...@@ -166,6 +166,7 @@ EXPORT_SYMBOL(rproc_va_to_pa); ...@@ -166,6 +166,7 @@ EXPORT_SYMBOL(rproc_va_to_pa);
* @rproc: handle of a remote processor * @rproc: handle of a remote processor
* @da: remoteproc device address to translate * @da: remoteproc device address to translate
* @len: length of the memory region @da is pointing to * @len: length of the memory region @da is pointing to
* @is_iomem: optional pointer filled in to indicate if @da is iomapped memory
* *
* Some remote processors will ask us to allocate them physically contiguous * Some remote processors will ask us to allocate them physically contiguous
* memory regions (which we call "carveouts"), and map them to specific * memory regions (which we call "carveouts"), and map them to specific
...@@ -183,12 +184,12 @@ EXPORT_SYMBOL(rproc_va_to_pa); ...@@ -183,12 +184,12 @@ EXPORT_SYMBOL(rproc_va_to_pa);
* translations on the internal remoteproc memory regions through a platform * translations on the internal remoteproc memory regions through a platform
* implementation specific da_to_va ops, if present. * implementation specific da_to_va ops, if present.
* *
* The function returns a valid kernel address on success or NULL on failure.
*
* Note: phys_to_virt(iommu_iova_to_phys(rproc->domain, da)) will work too, * Note: phys_to_virt(iommu_iova_to_phys(rproc->domain, da)) will work too,
* but only on kernel direct mapped RAM memory. Instead, we're just using * but only on kernel direct mapped RAM memory. Instead, we're just using
* here the output of the DMA API for the carveouts, which should be more * here the output of the DMA API for the carveouts, which should be more
* correct. * correct.
*
* Return: a valid kernel address on success or NULL on failure
*/ */
void *rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) void *rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
{ {
...@@ -509,7 +510,7 @@ static int copy_dma_range_map(struct device *to, struct device *from) ...@@ -509,7 +510,7 @@ static int copy_dma_range_map(struct device *to, struct device *from)
* use RSC_DEVMEM resource entries to map their required @da to the physical * use RSC_DEVMEM resource entries to map their required @da to the physical
* address of their base CMA region (ouch, hacky!). * address of their base CMA region (ouch, hacky!).
* *
* Returns 0 on success, or an appropriate error code otherwise * Return: 0 on success, or an appropriate error code otherwise
*/ */
static int rproc_handle_vdev(struct rproc *rproc, void *ptr, static int rproc_handle_vdev(struct rproc *rproc, void *ptr,
int offset, int avail) int offset, int avail)
...@@ -644,7 +645,7 @@ void rproc_vdev_release(struct kref *ref) ...@@ -644,7 +645,7 @@ void rproc_vdev_release(struct kref *ref)
* support dynamically allocating this address using the generic * support dynamically allocating this address using the generic
* DMA API (but currently there isn't a use case for that). * DMA API (but currently there isn't a use case for that).
* *
* Returns 0 on success, or an appropriate error code otherwise * Return: 0 on success, or an appropriate error code otherwise
*/ */
static int rproc_handle_trace(struct rproc *rproc, void *ptr, static int rproc_handle_trace(struct rproc *rproc, void *ptr,
int offset, int avail) int offset, int avail)
...@@ -721,6 +722,8 @@ static int rproc_handle_trace(struct rproc *rproc, void *ptr, ...@@ -721,6 +722,8 @@ static int rproc_handle_trace(struct rproc *rproc, void *ptr,
* tell us ranges of physical addresses the firmware is allowed to request, * tell us ranges of physical addresses the firmware is allowed to request,
* and not allow firmwares to request access to physical addresses that * and not allow firmwares to request access to physical addresses that
* are outside those ranges. * are outside those ranges.
*
* Return: 0 on success, or an appropriate error code otherwise
*/ */
static int rproc_handle_devmem(struct rproc *rproc, void *ptr, static int rproc_handle_devmem(struct rproc *rproc, void *ptr,
int offset, int avail) int offset, int avail)
...@@ -783,6 +786,8 @@ static int rproc_handle_devmem(struct rproc *rproc, void *ptr, ...@@ -783,6 +786,8 @@ static int rproc_handle_devmem(struct rproc *rproc, void *ptr,
* *
* This function allocate specified memory entry @mem using * This function allocate specified memory entry @mem using
* dma_alloc_coherent() as default allocator * dma_alloc_coherent() as default allocator
*
* Return: 0 on success, or an appropriate error code otherwise
*/ */
static int rproc_alloc_carveout(struct rproc *rproc, static int rproc_alloc_carveout(struct rproc *rproc,
struct rproc_mem_entry *mem) struct rproc_mem_entry *mem)
...@@ -889,6 +894,8 @@ static int rproc_alloc_carveout(struct rproc *rproc, ...@@ -889,6 +894,8 @@ static int rproc_alloc_carveout(struct rproc *rproc,
* *
* This function releases specified memory entry @mem allocated via * This function releases specified memory entry @mem allocated via
* rproc_alloc_carveout() function by @rproc. * rproc_alloc_carveout() function by @rproc.
*
* Return: 0 on success, or an appropriate error code otherwise
*/ */
static int rproc_release_carveout(struct rproc *rproc, static int rproc_release_carveout(struct rproc *rproc,
struct rproc_mem_entry *mem) struct rproc_mem_entry *mem)
...@@ -918,6 +925,8 @@ static int rproc_release_carveout(struct rproc *rproc, ...@@ -918,6 +925,8 @@ static int rproc_release_carveout(struct rproc *rproc,
* (e.g. CMA) more efficiently, and also minimizes the number of TLB entries * (e.g. CMA) more efficiently, and also minimizes the number of TLB entries
* needed to map it (in case @rproc is using an IOMMU). Reducing the TLB * needed to map it (in case @rproc is using an IOMMU). Reducing the TLB
* pressure is important; it may have a substantial impact on performance. * pressure is important; it may have a substantial impact on performance.
*
* Return: 0 on success, or an appropriate error code otherwise
*/ */
static int rproc_handle_carveout(struct rproc *rproc, static int rproc_handle_carveout(struct rproc *rproc,
void *ptr, int offset, int avail) void *ptr, int offset, int avail)
...@@ -1006,6 +1015,8 @@ EXPORT_SYMBOL(rproc_add_carveout); ...@@ -1006,6 +1015,8 @@ EXPORT_SYMBOL(rproc_add_carveout);
* *
* This function allocates a rproc_mem_entry struct and fill it with parameters * This function allocates a rproc_mem_entry struct and fill it with parameters
* provided by client. * provided by client.
*
* Return: a valid pointer on success, or NULL on failure
*/ */
__printf(8, 9) __printf(8, 9)
struct rproc_mem_entry * struct rproc_mem_entry *
...@@ -1050,6 +1061,8 @@ EXPORT_SYMBOL(rproc_mem_entry_init); ...@@ -1050,6 +1061,8 @@ EXPORT_SYMBOL(rproc_mem_entry_init);
* *
* This function allocates a rproc_mem_entry struct and fill it with parameters * This function allocates a rproc_mem_entry struct and fill it with parameters
* provided by client. * provided by client.
*
* Return: a valid pointer on success, or NULL on failure
*/ */
__printf(5, 6) __printf(5, 6)
struct rproc_mem_entry * struct rproc_mem_entry *
...@@ -1881,6 +1894,8 @@ static int __rproc_detach(struct rproc *rproc) ...@@ -1881,6 +1894,8 @@ static int __rproc_detach(struct rproc *rproc)
* remoteproc functional again. * remoteproc functional again.
* *
* This function can sleep, so it cannot be called from atomic context. * This function can sleep, so it cannot be called from atomic context.
*
* Return: 0 on success or a negative value upon failure
*/ */
int rproc_trigger_recovery(struct rproc *rproc) int rproc_trigger_recovery(struct rproc *rproc)
{ {
...@@ -1965,7 +1980,7 @@ static void rproc_crash_handler_work(struct work_struct *work) ...@@ -1965,7 +1980,7 @@ static void rproc_crash_handler_work(struct work_struct *work)
* If the remote processor is already powered on, this function immediately * If the remote processor is already powered on, this function immediately
* returns (successfully). * returns (successfully).
* *
* Returns 0 on success, and an appropriate error value otherwise. * Return: 0 on success, and an appropriate error value otherwise
*/ */
int rproc_boot(struct rproc *rproc) int rproc_boot(struct rproc *rproc)
{ {
...@@ -2100,6 +2115,8 @@ EXPORT_SYMBOL(rproc_shutdown); ...@@ -2100,6 +2115,8 @@ EXPORT_SYMBOL(rproc_shutdown);
* no longer available. From there it should be possible to remove the * no longer available. From there it should be possible to remove the
* platform driver and even power cycle the application processor (if the HW * platform driver and even power cycle the application processor (if the HW
* supports it) without needing to switch off the remote processor. * supports it) without needing to switch off the remote processor.
*
* Return: 0 on success, and an appropriate error value otherwise
*/ */
int rproc_detach(struct rproc *rproc) int rproc_detach(struct rproc *rproc)
{ {
...@@ -2152,7 +2169,7 @@ EXPORT_SYMBOL(rproc_detach); ...@@ -2152,7 +2169,7 @@ EXPORT_SYMBOL(rproc_detach);
* This function increments the remote processor's refcount, so always * This function increments the remote processor's refcount, so always
* use rproc_put() to decrement it back once rproc isn't needed anymore. * use rproc_put() to decrement it back once rproc isn't needed anymore.
* *
* Returns the rproc handle on success, and NULL on failure. * Return: rproc handle on success, and NULL on failure
*/ */
#ifdef CONFIG_OF #ifdef CONFIG_OF
struct rproc *rproc_get_by_phandle(phandle phandle) struct rproc *rproc_get_by_phandle(phandle phandle)
...@@ -2302,8 +2319,6 @@ static int rproc_validate(struct rproc *rproc) ...@@ -2302,8 +2319,6 @@ static int rproc_validate(struct rproc *rproc)
* This is called by the platform-specific rproc implementation, whenever * This is called by the platform-specific rproc implementation, whenever
* a new remote processor device is probed. * a new remote processor device is probed.
* *
* Returns 0 on success and an appropriate error code otherwise.
*
* Note: this function initiates an asynchronous firmware loading * Note: this function initiates an asynchronous firmware loading
* context, which will look for virtio devices supported by the rproc's * context, which will look for virtio devices supported by the rproc's
* firmware. * firmware.
...@@ -2311,35 +2326,39 @@ static int rproc_validate(struct rproc *rproc) ...@@ -2311,35 +2326,39 @@ static int rproc_validate(struct rproc *rproc)
* If found, those virtio devices will be created and added, so as a result * If found, those virtio devices will be created and added, so as a result
* of registering this remote processor, additional virtio drivers might be * of registering this remote processor, additional virtio drivers might be
* probed. * probed.
*
* Return: 0 on success and an appropriate error code otherwise
*/ */
int rproc_add(struct rproc *rproc) int rproc_add(struct rproc *rproc)
{ {
struct device *dev = &rproc->dev; struct device *dev = &rproc->dev;
int ret; int ret;
ret = device_add(dev); ret = rproc_validate(rproc);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = rproc_validate(rproc); /* add char device for this remoteproc */
ret = rproc_char_device_add(rproc);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = device_add(dev);
if (ret < 0) {
put_device(dev);
goto rproc_remove_cdev;
}
dev_info(dev, "%s is available\n", rproc->name); dev_info(dev, "%s is available\n", rproc->name);
/* create debugfs entries */ /* create debugfs entries */
rproc_create_debug_dir(rproc); rproc_create_debug_dir(rproc);
/* add char device for this remoteproc */
ret = rproc_char_device_add(rproc);
if (ret < 0)
return ret;
/* if rproc is marked always-on, request it to boot */ /* if rproc is marked always-on, request it to boot */
if (rproc->auto_boot) { if (rproc->auto_boot) {
ret = rproc_trigger_auto_boot(rproc); ret = rproc_trigger_auto_boot(rproc);
if (ret < 0) if (ret < 0)
return ret; goto rproc_remove_dev;
} }
/* expose to rproc_get_by_phandle users */ /* expose to rproc_get_by_phandle users */
...@@ -2348,6 +2367,13 @@ int rproc_add(struct rproc *rproc) ...@@ -2348,6 +2367,13 @@ int rproc_add(struct rproc *rproc)
mutex_unlock(&rproc_list_mutex); mutex_unlock(&rproc_list_mutex);
return 0; return 0;
rproc_remove_dev:
rproc_delete_debug_dir(rproc);
device_del(dev);
rproc_remove_cdev:
rproc_char_device_remove(rproc);
return ret;
} }
EXPORT_SYMBOL(rproc_add); EXPORT_SYMBOL(rproc_add);
...@@ -2364,7 +2390,7 @@ static void devm_rproc_remove(void *rproc) ...@@ -2364,7 +2390,7 @@ static void devm_rproc_remove(void *rproc)
* This function performs like rproc_add() but the registered rproc device will * This function performs like rproc_add() but the registered rproc device will
* automatically be removed on driver detach. * automatically be removed on driver detach.
* *
* Returns: 0 on success, negative errno on failure * Return: 0 on success, negative errno on failure
*/ */
int devm_rproc_add(struct device *dev, struct rproc *rproc) int devm_rproc_add(struct device *dev, struct rproc *rproc)
{ {
...@@ -2472,10 +2498,10 @@ static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops) ...@@ -2472,10 +2498,10 @@ static int rproc_alloc_ops(struct rproc *rproc, const struct rproc_ops *ops)
* implementations should then call rproc_add() to complete * implementations should then call rproc_add() to complete
* the registration of the remote processor. * the registration of the remote processor.
* *
* On success the new rproc is returned, and on failure, NULL.
*
* Note: _never_ directly deallocate @rproc, even if it was not registered * Note: _never_ directly deallocate @rproc, even if it was not registered
* yet. Instead, when you need to unroll rproc_alloc(), use rproc_free(). * yet. Instead, when you need to unroll rproc_alloc(), use rproc_free().
*
* Return: new rproc pointer on success, and NULL on failure
*/ */
struct rproc *rproc_alloc(struct device *dev, const char *name, struct rproc *rproc_alloc(struct device *dev, const char *name,
const struct rproc_ops *ops, const struct rproc_ops *ops,
...@@ -2588,7 +2614,7 @@ EXPORT_SYMBOL(rproc_put); ...@@ -2588,7 +2614,7 @@ EXPORT_SYMBOL(rproc_put);
* of the outstanding reference created by rproc_alloc. To decrement that * of the outstanding reference created by rproc_alloc. To decrement that
* one last refcount, one still needs to call rproc_free(). * one last refcount, one still needs to call rproc_free().
* *
* Returns 0 on success and -EINVAL if @rproc isn't valid. * Return: 0 on success and -EINVAL if @rproc isn't valid
*/ */
int rproc_del(struct rproc *rproc) int rproc_del(struct rproc *rproc)
{ {
...@@ -2603,7 +2629,6 @@ int rproc_del(struct rproc *rproc) ...@@ -2603,7 +2629,6 @@ int rproc_del(struct rproc *rproc)
mutex_unlock(&rproc->lock); mutex_unlock(&rproc->lock);
rproc_delete_debug_dir(rproc); rproc_delete_debug_dir(rproc);
rproc_char_device_remove(rproc);
/* the rproc is downref'ed as soon as it's removed from the klist */ /* the rproc is downref'ed as soon as it's removed from the klist */
mutex_lock(&rproc_list_mutex); mutex_lock(&rproc_list_mutex);
...@@ -2614,6 +2639,7 @@ int rproc_del(struct rproc *rproc) ...@@ -2614,6 +2639,7 @@ int rproc_del(struct rproc *rproc)
synchronize_rcu(); synchronize_rcu();
device_del(&rproc->dev); device_del(&rproc->dev);
rproc_char_device_remove(rproc);
return 0; return 0;
} }
...@@ -2635,7 +2661,7 @@ static void devm_rproc_free(struct device *dev, void *res) ...@@ -2635,7 +2661,7 @@ static void devm_rproc_free(struct device *dev, void *res)
* This function performs like rproc_alloc() but the acquired rproc device will * This function performs like rproc_alloc() but the acquired rproc device will
* automatically be released on driver detach. * automatically be released on driver detach.
* *
* Returns: new rproc instance, or NULL on failure * Return: new rproc instance, or NULL on failure
*/ */
struct rproc *devm_rproc_alloc(struct device *dev, const char *name, struct rproc *devm_rproc_alloc(struct device *dev, const char *name,
const struct rproc_ops *ops, const struct rproc_ops *ops,
...@@ -2687,7 +2713,7 @@ EXPORT_SYMBOL(rproc_remove_subdev); ...@@ -2687,7 +2713,7 @@ EXPORT_SYMBOL(rproc_remove_subdev);
* rproc_get_by_child() - acquire rproc handle of @dev's ancestor * rproc_get_by_child() - acquire rproc handle of @dev's ancestor
* @dev: child device to find ancestor of * @dev: child device to find ancestor of
* *
* Returns the ancestor rproc instance, or NULL if not found. * Return: the ancestor rproc instance, or NULL if not found
*/ */
struct rproc *rproc_get_by_child(struct device *dev) struct rproc *rproc_get_by_child(struct device *dev)
{ {
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
* @fw: the ELF firmware image * @fw: the ELF firmware image
* *
* Make sure this fw image is sane (ie a correct ELF32/ELF64 file). * Make sure this fw image is sane (ie a correct ELF32/ELF64 file).
*
* Return: 0 on success and -EINVAL upon any failure
*/ */
int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw) int rproc_elf_sanity_check(struct rproc *rproc, const struct firmware *fw)
{ {
...@@ -117,11 +119,11 @@ EXPORT_SYMBOL(rproc_elf_sanity_check); ...@@ -117,11 +119,11 @@ EXPORT_SYMBOL(rproc_elf_sanity_check);
* @rproc: the remote processor handle * @rproc: the remote processor handle
* @fw: the ELF firmware image * @fw: the ELF firmware image
* *
* This function returns the entry point address of the ELF
* image.
*
* Note that the boot address is not a configurable property of all remote * Note that the boot address is not a configurable property of all remote
* processors. Some will always boot at a specific hard-coded address. * processors. Some will always boot at a specific hard-coded address.
*
* Return: entry point address of the ELF image
*
*/ */
u64 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw) u64 rproc_elf_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
{ {
...@@ -152,6 +154,8 @@ EXPORT_SYMBOL(rproc_elf_get_boot_addr); ...@@ -152,6 +154,8 @@ EXPORT_SYMBOL(rproc_elf_get_boot_addr);
* might be different: they might not have iommus, and would prefer to * might be different: they might not have iommus, and would prefer to
* directly allocate memory for every segment/resource. This is not yet * directly allocate memory for every segment/resource. This is not yet
* supported, though. * supported, though.
*
* Return: 0 on success and an appropriate error code otherwise
*/ */
int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
{ {
...@@ -362,7 +366,7 @@ EXPORT_SYMBOL(rproc_elf_load_rsc_table); ...@@ -362,7 +366,7 @@ EXPORT_SYMBOL(rproc_elf_load_rsc_table);
* This function finds the location of the loaded resource table. Don't * This function finds the location of the loaded resource table. Don't
* call this function if the table wasn't loaded yet - it's a bug if you do. * call this function if the table wasn't loaded yet - it's a bug if you do.
* *
* Returns the pointer to the resource table if it is found or NULL otherwise. * Return: pointer to the resource table if it is found or NULL otherwise.
* If the table wasn't loaded yet the result is unspecified. * If the table wasn't loaded yet the result is unspecified.
*/ */
struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc,
......
...@@ -45,7 +45,7 @@ static bool rproc_virtio_notify(struct virtqueue *vq) ...@@ -45,7 +45,7 @@ static bool rproc_virtio_notify(struct virtqueue *vq)
* when the remote processor signals that a specific virtqueue has pending * when the remote processor signals that a specific virtqueue has pending
* messages available. * messages available.
* *
* Returns IRQ_NONE if no message was found in the @notifyid virtqueue, * Return: IRQ_NONE if no message was found in the @notifyid virtqueue,
* and otherwise returns IRQ_HANDLED. * and otherwise returns IRQ_HANDLED.
*/ */
irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int notifyid) irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int notifyid)
...@@ -325,7 +325,7 @@ static void rproc_virtio_dev_release(struct device *dev) ...@@ -325,7 +325,7 @@ static void rproc_virtio_dev_release(struct device *dev)
* This function registers a virtio device. This vdev's partent is * This function registers a virtio device. This vdev's partent is
* the rproc device. * the rproc device.
* *
* Returns 0 on success or an appropriate error value otherwise. * Return: 0 on success or an appropriate error value otherwise
*/ */
int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
{ {
...@@ -432,6 +432,8 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) ...@@ -432,6 +432,8 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id)
* @data: must be null * @data: must be null
* *
* This function unregisters an existing virtio device. * This function unregisters an existing virtio device.
*
* Return: 0
*/ */
int rproc_remove_virtio_dev(struct device *dev, void *data) int rproc_remove_virtio_dev(struct device *dev, void *data)
{ {
......
...@@ -474,14 +474,12 @@ static int stm32_rproc_attach(struct rproc *rproc) ...@@ -474,14 +474,12 @@ static int stm32_rproc_attach(struct rproc *rproc)
static int stm32_rproc_detach(struct rproc *rproc) static int stm32_rproc_detach(struct rproc *rproc)
{ {
struct stm32_rproc *ddata = rproc->priv; struct stm32_rproc *ddata = rproc->priv;
int err, dummy_data, idx; int err, idx;
/* Inform the remote processor of the detach */ /* Inform the remote processor of the detach */
idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_DETACH); idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_DETACH);
if (idx >= 0 && ddata->mb[idx].chan) { if (idx >= 0 && ddata->mb[idx].chan) {
/* A dummy data is sent to allow to block on transmit */ err = mbox_send_message(ddata->mb[idx].chan, "stop");
err = mbox_send_message(ddata->mb[idx].chan,
&dummy_data);
if (err < 0) if (err < 0)
dev_warn(&rproc->dev, "warning: remote FW detach without ack\n"); dev_warn(&rproc->dev, "warning: remote FW detach without ack\n");
} }
...@@ -493,15 +491,13 @@ static int stm32_rproc_detach(struct rproc *rproc) ...@@ -493,15 +491,13 @@ static int stm32_rproc_detach(struct rproc *rproc)
static int stm32_rproc_stop(struct rproc *rproc) static int stm32_rproc_stop(struct rproc *rproc)
{ {
struct stm32_rproc *ddata = rproc->priv; struct stm32_rproc *ddata = rproc->priv;
int err, dummy_data, idx; int err, idx;
/* request shutdown of the remote processor */ /* request shutdown of the remote processor */
if (rproc->state != RPROC_OFFLINE) { if (rproc->state != RPROC_OFFLINE) {
idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_SHUTDOWN); idx = stm32_rproc_mbox_idx(rproc, STM32_MBX_SHUTDOWN);
if (idx >= 0 && ddata->mb[idx].chan) { if (idx >= 0 && ddata->mb[idx].chan) {
/* a dummy data is sent to allow to block on transmit */ err = mbox_send_message(ddata->mb[idx].chan, "detach");
err = mbox_send_message(ddata->mb[idx].chan,
&dummy_data);
if (err < 0) if (err < 0)
dev_warn(&rproc->dev, "warning: remote FW shutdown without ack\n"); dev_warn(&rproc->dev, "warning: remote FW shutdown without ack\n");
} }
...@@ -556,7 +552,7 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid) ...@@ -556,7 +552,7 @@ static void stm32_rproc_kick(struct rproc *rproc, int vqid)
continue; continue;
if (!ddata->mb[i].chan) if (!ddata->mb[i].chan)
return; return;
err = mbox_send_message(ddata->mb[i].chan, (void *)(long)vqid); err = mbox_send_message(ddata->mb[i].chan, "kick");
if (err < 0) if (err < 0)
dev_err(&rproc->dev, "%s: failed (%s, err:%d)\n", dev_err(&rproc->dev, "%s: failed (%s, err:%d)\n",
__func__, ddata->mb[i].name, err); __func__, ddata->mb[i].name, err);
...@@ -580,7 +576,7 @@ static int stm32_rproc_da_to_pa(struct rproc *rproc, ...@@ -580,7 +576,7 @@ static int stm32_rproc_da_to_pa(struct rproc *rproc,
continue; continue;
*pa = da - p_mem->dev_addr + p_mem->bus_addr; *pa = da - p_mem->dev_addr + p_mem->bus_addr;
dev_dbg(dev, "da %llx to pa %#x\n", da, *pa); dev_dbg(dev, "da %llx to pa %pap\n", da, pa);
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -151,6 +151,42 @@ void qcom_smem_state_put(struct qcom_smem_state *state) ...@@ -151,6 +151,42 @@ void qcom_smem_state_put(struct qcom_smem_state *state)
} }
EXPORT_SYMBOL_GPL(qcom_smem_state_put); EXPORT_SYMBOL_GPL(qcom_smem_state_put);
static void devm_qcom_smem_state_release(struct device *dev, void *res)
{
qcom_smem_state_put(*(struct qcom_smem_state **)res);
}
/**
* devm_qcom_smem_state_get() - acquire handle to a devres managed state
* @dev: client device pointer
* @con_id: name of the state to lookup
* @bit: flags from the state reference, indicating which bit's affected
*
* Returns handle to the state, or ERR_PTR(). qcom_smem_state_put() is called
* automatically when @dev is removed.
*/
struct qcom_smem_state *devm_qcom_smem_state_get(struct device *dev,
const char *con_id,
unsigned *bit)
{
struct qcom_smem_state **ptr, *state;
ptr = devres_alloc(devm_qcom_smem_state_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
state = qcom_smem_state_get(dev, con_id, bit);
if (!IS_ERR(state)) {
*ptr = state;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return state;
}
EXPORT_SYMBOL_GPL(devm_qcom_smem_state_get);
/** /**
* qcom_smem_state_register() - register a new state * qcom_smem_state_register() - register a new state
* @of_node: of_node used for matching client lookups * @of_node: of_node used for matching client lookups
......
...@@ -243,7 +243,7 @@ struct fw_rsc_trace { ...@@ -243,7 +243,7 @@ struct fw_rsc_trace {
* @da: device address * @da: device address
* @align: the alignment between the consumer and producer parts of the vring * @align: the alignment between the consumer and producer parts of the vring
* @num: num of buffers supported by this vring (must be power of two) * @num: num of buffers supported by this vring (must be power of two)
* @notifyid is a unique rproc-wide notify index for this vring. This notify * @notifyid: a unique rproc-wide notify index for this vring. This notify
* index is used when kicking a remote processor, to let it know that this * index is used when kicking a remote processor, to let it know that this
* vring is triggered. * vring is triggered.
* @pa: physical address * @pa: physical address
...@@ -266,18 +266,18 @@ struct fw_rsc_vdev_vring { ...@@ -266,18 +266,18 @@ struct fw_rsc_vdev_vring {
/** /**
* struct fw_rsc_vdev - virtio device header * struct fw_rsc_vdev - virtio device header
* @id: virtio device id (as in virtio_ids.h) * @id: virtio device id (as in virtio_ids.h)
* @notifyid is a unique rproc-wide notify index for this vdev. This notify * @notifyid: a unique rproc-wide notify index for this vdev. This notify
* index is used when kicking a remote processor, to let it know that the * index is used when kicking a remote processor, to let it know that the
* status/features of this vdev have changes. * status/features of this vdev have changes.
* @dfeatures specifies the virtio device features supported by the firmware * @dfeatures: specifies the virtio device features supported by the firmware
* @gfeatures is a place holder used by the host to write back the * @gfeatures: a place holder used by the host to write back the
* negotiated features that are supported by both sides. * negotiated features that are supported by both sides.
* @config_len is the size of the virtio config space of this vdev. The config * @config_len: the size of the virtio config space of this vdev. The config
* space lies in the resource table immediate after this vdev header. * space lies in the resource table immediate after this vdev header.
* @status is a place holder where the host will indicate its virtio progress. * @status: a place holder where the host will indicate its virtio progress.
* @num_of_vrings indicates how many vrings are described in this vdev header * @num_of_vrings: indicates how many vrings are described in this vdev header
* @reserved: reserved (must be zero) * @reserved: reserved (must be zero)
* @vring is an array of @num_of_vrings entries of 'struct fw_rsc_vdev_vring'. * @vring: an array of @num_of_vrings entries of 'struct fw_rsc_vdev_vring'.
* *
* This resource is a virtio device header: it provides information about * This resource is a virtio device header: it provides information about
* the vdev, and is then used by the host and its peer remote processors * the vdev, and is then used by the host and its peer remote processors
...@@ -287,16 +287,17 @@ struct fw_rsc_vdev_vring { ...@@ -287,16 +287,17 @@ struct fw_rsc_vdev_vring {
* to statically allocate a vdev upon registration of the rproc (dynamic vdev * to statically allocate a vdev upon registration of the rproc (dynamic vdev
* allocation is not yet supported). * allocation is not yet supported).
* *
* Note: unlike virtualization systems, the term 'host' here means * Note:
* the Linux side which is running remoteproc to control the remote * 1. unlike virtualization systems, the term 'host' here means
* processors. We use the name 'gfeatures' to comply with virtio's terms, * the Linux side which is running remoteproc to control the remote
* though there isn't really any virtualized guest OS here: it's the host * processors. We use the name 'gfeatures' to comply with virtio's terms,
* which is responsible for negotiating the final features. * though there isn't really any virtualized guest OS here: it's the host
* Yeah, it's a bit confusing. * which is responsible for negotiating the final features.
* * Yeah, it's a bit confusing.
* Note: immediately following this structure is the virtio config space for *
* this vdev (which is specific to the vdev; for more info, read the virtio * 2. immediately following this structure is the virtio config space for
* spec). the size of the config space is specified by @config_len. * this vdev (which is specific to the vdev; for more info, read the virtio
* spec). The size of the config space is specified by @config_len.
*/ */
struct fw_rsc_vdev { struct fw_rsc_vdev {
u32 id; u32 id;
...@@ -440,7 +441,7 @@ enum rproc_state { ...@@ -440,7 +441,7 @@ enum rproc_state {
* enum rproc_crash_type - remote processor crash types * enum rproc_crash_type - remote processor crash types
* @RPROC_MMUFAULT: iommu fault * @RPROC_MMUFAULT: iommu fault
* @RPROC_WATCHDOG: watchdog bite * @RPROC_WATCHDOG: watchdog bite
* @RPROC_FATAL_ERROR fatal error * @RPROC_FATAL_ERROR: fatal error
* *
* Each element of the enum is used as an array index. So that, the value of * Each element of the enum is used as an array index. So that, the value of
* the elements should be always something sane. * the elements should be always something sane.
...@@ -457,9 +458,9 @@ enum rproc_crash_type { ...@@ -457,9 +458,9 @@ enum rproc_crash_type {
* enum rproc_dump_mechanism - Coredump options for core * enum rproc_dump_mechanism - Coredump options for core
* @RPROC_COREDUMP_DISABLED: Don't perform any dump * @RPROC_COREDUMP_DISABLED: Don't perform any dump
* @RPROC_COREDUMP_ENABLED: Copy dump to separate buffer and carry on with * @RPROC_COREDUMP_ENABLED: Copy dump to separate buffer and carry on with
recovery * recovery
* @RPROC_COREDUMP_INLINE: Read segments directly from device memory. Stall * @RPROC_COREDUMP_INLINE: Read segments directly from device memory. Stall
recovery until all segments are read * recovery until all segments are read
*/ */
enum rproc_dump_mechanism { enum rproc_dump_mechanism {
RPROC_COREDUMP_DISABLED, RPROC_COREDUMP_DISABLED,
...@@ -475,6 +476,7 @@ enum rproc_dump_mechanism { ...@@ -475,6 +476,7 @@ enum rproc_dump_mechanism {
* @priv: private data associated with the dump_segment * @priv: private data associated with the dump_segment
* @dump: custom dump function to fill device memory segment associated * @dump: custom dump function to fill device memory segment associated
* with coredump * with coredump
* @offset: offset of the segment
*/ */
struct rproc_dump_segment { struct rproc_dump_segment {
struct list_head node; struct list_head node;
...@@ -524,7 +526,9 @@ struct rproc_dump_segment { ...@@ -524,7 +526,9 @@ struct rproc_dump_segment {
* @auto_boot: flag to indicate if remote processor should be auto-started * @auto_boot: flag to indicate if remote processor should be auto-started
* @dump_segments: list of segments in the firmware * @dump_segments: list of segments in the firmware
* @nb_vdev: number of vdev currently handled by rproc * @nb_vdev: number of vdev currently handled by rproc
* @char_dev: character device of the rproc * @elf_class: firmware ELF class
* @elf_machine: firmware ELF machine
* @cdev: character device of the rproc
* @cdev_put_on_release: flag to indicate if remoteproc should be shutdown on @char_dev release * @cdev_put_on_release: flag to indicate if remoteproc should be shutdown on @char_dev release
*/ */
struct rproc { struct rproc {
...@@ -613,10 +617,10 @@ struct rproc_vring { ...@@ -613,10 +617,10 @@ struct rproc_vring {
* struct rproc_vdev - remoteproc state for a supported virtio device * struct rproc_vdev - remoteproc state for a supported virtio device
* @refcount: reference counter for the vdev and vring allocations * @refcount: reference counter for the vdev and vring allocations
* @subdev: handle for registering the vdev as a rproc subdevice * @subdev: handle for registering the vdev as a rproc subdevice
* @dev: device struct used for reference count semantics
* @id: virtio device id (as in virtio_ids.h) * @id: virtio device id (as in virtio_ids.h)
* @node: list node * @node: list node
* @rproc: the rproc handle * @rproc: the rproc handle
* @vdev: the virio device
* @vring: the vrings for this vdev * @vring: the vrings for this vdev
* @rsc_offset: offset of the vdev's resource entry * @rsc_offset: offset of the vdev's resource entry
* @index: vdev position versus other vdev declared in resource table * @index: vdev position versus other vdev declared in resource table
......
...@@ -14,6 +14,7 @@ struct qcom_smem_state_ops { ...@@ -14,6 +14,7 @@ struct qcom_smem_state_ops {
#ifdef CONFIG_QCOM_SMEM_STATE #ifdef CONFIG_QCOM_SMEM_STATE
struct qcom_smem_state *qcom_smem_state_get(struct device *dev, const char *con_id, unsigned *bit); struct qcom_smem_state *qcom_smem_state_get(struct device *dev, const char *con_id, unsigned *bit);
struct qcom_smem_state *devm_qcom_smem_state_get(struct device *dev, const char *con_id, unsigned *bit);
void qcom_smem_state_put(struct qcom_smem_state *); void qcom_smem_state_put(struct qcom_smem_state *);
int qcom_smem_state_update_bits(struct qcom_smem_state *state, u32 mask, u32 value); int qcom_smem_state_update_bits(struct qcom_smem_state *state, u32 mask, u32 value);
...@@ -29,6 +30,13 @@ static inline struct qcom_smem_state *qcom_smem_state_get(struct device *dev, ...@@ -29,6 +30,13 @@ static inline struct qcom_smem_state *qcom_smem_state_get(struct device *dev,
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
static inline struct qcom_smem_state *devm_qcom_smem_state_get(struct device *dev,
const char *con_id,
unsigned *bit)
{
return ERR_PTR(-EINVAL);
}
static inline void qcom_smem_state_put(struct qcom_smem_state *state) static inline void qcom_smem_state_put(struct qcom_smem_state *state)
{ {
} }
......
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