mbox series

[00/14] Add dedicated device tree node for RPM processor/subsystem

Message ID 20230531-rpm-rproc-v1-0-e0a3b6de1f14@gerhold.net
Headers show
Series Add dedicated device tree node for RPM processor/subsystem | expand

Message

Stephan Gerhold June 5, 2023, 7:08 a.m. UTC
The Resource Power Manager (RPM) currently does not have a dedicated 
device tree node that represents the remoteproc/subsystem. The 
functionality exposed through the SMD/GLINK channels is described in 
top-level nodes of the device tree. This makes it hard to group other 
functionality provided by the RPM together in the device tree. This 
series adds a single top-level remoteproc-rpm/rpm-proc device tree node 
that groups all RPM functionality together.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
Stephan Gerhold (14):
      dt-bindings  soc: qcom: smd-rpm: Fix sort order
      dt-bindings: soc: qcom: smd-rpm: Add MSM8909 to qcom,smd-channels
      dt-bindings: soc: qcom: smd-rpm: Add some more compatibles
      soc: qcom: smd-rpm: Match rpmsg channel instead of compatible
      dt-bindings: remoteproc: Add Qualcomm RPM processor/subsystem
      dt-bindings: soc: qcom: smd-rpm: Use qcom,rpm-proc in example
      dt-bindings: qcom: smd: Mark as deprecated
      soc: qcom: smem: Add qcom_smem_is_available()
      rpmsg: qcom_smd: Use qcom_smem_is_available()
      soc: qcom: Add RPM processor/subsystem driver
      arm64: dts: qcom: Add rpm-proc node for SMD platforms
      arm64: dts: qcom: Add rpm-proc node for GLINK gplatforms
      ARM: dts: qcom: Add rpm-proc node for SMD platforms
      ARM: dts: qcom: apq8064: Drop redundant /smd node

 .../bindings/remoteproc/qcom,rpm-proc.yaml         | 125 +++++++++++++++++
 .../devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml |  23 +++-
 .../devicetree/bindings/soc/qcom/qcom,smd.yaml     |   7 +
 arch/arm/boot/dts/qcom-apq8064.dtsi                |  40 ------
 arch/arm/boot/dts/qcom-apq8084.dtsi                |   6 +-
 arch/arm/boot/dts/qcom-msm8226.dtsi                |  38 +++---
 arch/arm/boot/dts/qcom-msm8974.dtsi                |  44 +++---
 arch/arm64/boot/dts/qcom/ipq6018.dtsi              |  48 ++++---
 arch/arm64/boot/dts/qcom/ipq9574.dtsi              |  28 ++--
 arch/arm64/boot/dts/qcom/msm8916.dtsi              |   6 +-
 arch/arm64/boot/dts/qcom/msm8939.dtsi              | 112 +++++++--------
 arch/arm64/boot/dts/qcom/msm8953.dtsi              | 136 +++++++++---------
 arch/arm64/boot/dts/qcom/msm8976.dtsi              | 152 ++++++++++-----------
 arch/arm64/boot/dts/qcom/msm8994.dtsi              |  99 +++++++-------
 arch/arm64/boot/dts/qcom/msm8996.dtsi              | 113 +++++++--------
 arch/arm64/boot/dts/qcom/msm8998.dtsi              |  98 ++++++-------
 arch/arm64/boot/dts/qcom/qcm2290.dtsi              | 126 ++++++++---------
 arch/arm64/boot/dts/qcom/qcs404.dtsi               | 152 +++++++++++----------
 arch/arm64/boot/dts/qcom/sdm630.dtsi               | 132 +++++++++---------
 arch/arm64/boot/dts/qcom/sm6115.dtsi               | 128 ++++++++---------
 arch/arm64/boot/dts/qcom/sm6125.dtsi               | 140 ++++++++++---------
 arch/arm64/boot/dts/qcom/sm6375.dtsi               | 126 ++++++++---------
 drivers/rpmsg/qcom_smd.c                           |  10 +-
 drivers/soc/qcom/Makefile                          |   2 +-
 drivers/soc/qcom/rpm-proc.c                        |  76 +++++++++++
 drivers/soc/qcom/smd-rpm.c                         |  35 ++---
 drivers/soc/qcom/smem.c                            |   9 ++
 include/linux/soc/qcom/smem.h                      |   1 +
 28 files changed, 1111 insertions(+), 901 deletions(-)
---
base-commit: 8d5a57ea6a0b1722725170e32e511701ca7c454c
change-id: 20230531-rpm-rproc-758364839cdd

Best regards,

Comments

Konrad Dybcio June 5, 2023, 6:49 p.m. UTC | #1
On 5.06.2023 09:08, Stephan Gerhold wrote:
> There is an ever growing list of compatibles in the smd-rpm.c driver.
> A fallback compatible would help here but would still require keeping
> the current list around for backwards compatibility.
> 
> As an alternative, let's switch the driver to match the rpmsg_device_id
> instead, which is always "rpm_requests" on all platforms. Add a check
> to ensure that there is a device tree node defined for the device since
> otherwise the of_platform_populate() call will operate on the root node (/).
> 
> Similar approaches with matching rpmsg_device_id are already used in
> qcom_sysmon, qcom_glink_ssr, qrtr, and rpmsg_wwan_ctrl.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
Tested-by: Konrad Dybcio <konrad.dybcio@linaro.org> # SM6375 (G-Link)
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
>  drivers/soc/qcom/smd-rpm.c | 35 +++++++++--------------------------
>  1 file changed, 9 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/soc/qcom/smd-rpm.c b/drivers/soc/qcom/smd-rpm.c
> index 0c1aa809cc4e..13d8c52330d0 100644
> --- a/drivers/soc/qcom/smd-rpm.c
> +++ b/drivers/soc/qcom/smd-rpm.c
> @@ -199,6 +199,9 @@ static int qcom_smd_rpm_probe(struct rpmsg_device *rpdev)
>  	struct qcom_smd_rpm *rpm;
>  	int ret;
>  
> +	if (!rpdev->dev.of_node)
> +		return -EINVAL;
> +
>  	rpm = devm_kzalloc(&rpdev->dev, sizeof(*rpm), GFP_KERNEL);
>  	if (!rpm)
>  		return -ENOMEM;
> @@ -230,38 +233,18 @@ static void qcom_smd_rpm_remove(struct rpmsg_device *rpdev)
>  	of_platform_depopulate(&rpdev->dev);
>  }
>  
> -static const struct of_device_id qcom_smd_rpm_of_match[] = {
> -	{ .compatible = "qcom,rpm-apq8084" },
> -	{ .compatible = "qcom,rpm-ipq6018" },
> -	{ .compatible = "qcom,rpm-ipq9574" },
> -	{ .compatible = "qcom,rpm-msm8226" },
> -	{ .compatible = "qcom,rpm-msm8909" },
> -	{ .compatible = "qcom,rpm-msm8916" },
> -	{ .compatible = "qcom,rpm-msm8936" },
> -	{ .compatible = "qcom,rpm-msm8953" },
> -	{ .compatible = "qcom,rpm-msm8974" },
> -	{ .compatible = "qcom,rpm-msm8976" },
> -	{ .compatible = "qcom,rpm-msm8994" },
> -	{ .compatible = "qcom,rpm-msm8996" },
> -	{ .compatible = "qcom,rpm-msm8998" },
> -	{ .compatible = "qcom,rpm-sdm660" },
> -	{ .compatible = "qcom,rpm-sm6115" },
> -	{ .compatible = "qcom,rpm-sm6125" },
> -	{ .compatible = "qcom,rpm-sm6375" },
> -	{ .compatible = "qcom,rpm-qcm2290" },
> -	{ .compatible = "qcom,rpm-qcs404" },
> -	{}
> +static const struct rpmsg_device_id qcom_smd_rpm_id_table[] = {
> +	{ .name = "rpm_requests", },
> +	{ /* sentinel */ }
>  };
> -MODULE_DEVICE_TABLE(of, qcom_smd_rpm_of_match);
> +MODULE_DEVICE_TABLE(rpmsg, qcom_smd_rpm_id_table);
>  
>  static struct rpmsg_driver qcom_smd_rpm_driver = {
>  	.probe = qcom_smd_rpm_probe,
>  	.remove = qcom_smd_rpm_remove,
>  	.callback = qcom_smd_rpm_callback,
> -	.drv  = {
> -		.name  = "qcom_smd_rpm",
> -		.of_match_table = qcom_smd_rpm_of_match,
> -	},
> +	.id_table = qcom_smd_rpm_id_table,
> +	.drv.name = "qcom_smd_rpm",
>  };
>  
>  static int __init qcom_smd_rpm_init(void)
>
Konrad Dybcio June 5, 2023, 6:53 p.m. UTC | #2
On 5.06.2023 09:08, Stephan Gerhold wrote:
> Avoid having to look up a dummy item from SMEM to detect if it is
> already available or if we need to defer probing.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
>  drivers/soc/qcom/smem.c       | 9 +++++++++
>  include/linux/soc/qcom/smem.h | 1 +
>  2 files changed, 10 insertions(+)
> 
> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> index b0d59e815c3b..3d93a6681494 100644
> --- a/drivers/soc/qcom/smem.c
> +++ b/drivers/soc/qcom/smem.c
> @@ -359,6 +359,15 @@ static struct qcom_smem *__smem;
>  /* Timeout (ms) for the trylock of remote spinlocks */
>  #define HWSPINLOCK_TIMEOUT	1000
>  
> +/**
> + * qcom_smem_is_available() - Checks if SMEM is available
> + */
Shouldn't kerneldoc explicitly say "returns x if y else z"?

Modulo that:

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
> +bool qcom_smem_is_available(void)
> +{
> +	return !!__smem;
> +}
> +EXPORT_SYMBOL(qcom_smem_is_available);
> +
>  static int qcom_smem_alloc_private(struct qcom_smem *smem,
>  				   struct smem_partition *part,
>  				   unsigned item,
> diff --git a/include/linux/soc/qcom/smem.h b/include/linux/soc/qcom/smem.h
> index 223db6a9c733..a36a3b9d4929 100644
> --- a/include/linux/soc/qcom/smem.h
> +++ b/include/linux/soc/qcom/smem.h
> @@ -4,6 +4,7 @@
>  
>  #define QCOM_SMEM_HOST_ANY -1
>  
> +bool qcom_smem_is_available(void);
>  int qcom_smem_alloc(unsigned host, unsigned item, size_t size);
>  void *qcom_smem_get(unsigned host, unsigned item, size_t *size);
>  
>
Konrad Dybcio June 5, 2023, 6:56 p.m. UTC | #3
On 5.06.2023 09:08, Stephan Gerhold wrote:
> Rather than looking up a dummy item from SMEM, use the new
> qcom_smem_is_available() function to make the code more clear
> (and reduce the overhead slightly).
> 
> Add the same check to qcom_smd_register_edge() as well to ensure that
> it only succeeds if SMEM is already available - if a driver calls the
> function and SMEM is not available yet then the initial state will be
> read incorrectly and the RPMSG devices might never become available.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
>  drivers/rpmsg/qcom_smd.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
> index 7b9c298aa491..43f601c84b4f 100644
> --- a/drivers/rpmsg/qcom_smd.c
> +++ b/drivers/rpmsg/qcom_smd.c
> @@ -1479,6 +1479,9 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
>  	struct qcom_smd_edge *edge;
>  	int ret;
>  
> +	if (!qcom_smem_is_available())
> +		return ERR_PTR(-EPROBE_DEFER);
> +
>  	edge = kzalloc(sizeof(*edge), GFP_KERNEL);
>  	if (!edge)
>  		return ERR_PTR(-ENOMEM);
> @@ -1553,12 +1556,9 @@ EXPORT_SYMBOL(qcom_smd_unregister_edge);
>  static int qcom_smd_probe(struct platform_device *pdev)
>  {
>  	struct device_node *node;
> -	void *p;
>  
> -	/* Wait for smem */
> -	p = qcom_smem_get(QCOM_SMEM_HOST_ANY, smem_items[0].alloc_tbl_id, NULL);
> -	if (PTR_ERR(p) == -EPROBE_DEFER)
> -		return PTR_ERR(p);
> +	if (!qcom_smem_is_available())
> +		return -EPROBE_DEFER;
>  
>  	for_each_available_child_of_node(pdev->dev.of_node, node)
>  		qcom_smd_register_edge(&pdev->dev, node);
Hm.. we're not checking the return value here, at all.. Perhaps that
could be improved and we could only check for smem presence inside
qcom_smd_register_edge()?

Konrad
>
Konrad Dybcio June 5, 2023, 7 p.m. UTC | #4
On 5.06.2023 09:08, Stephan Gerhold wrote:
> The "smd-edge"s for remote processors are typically specified below the
> remoteproc nodes. For some reason apq8064 also has them all listed in a
> top-level /smd node, disabled by default. None of the boards enable them.
> 
> Right now apq8064 only has support for WCNSS/riva, but there the
> smd-edge is already defined with the same interrupt etc below the
> riva-pil node.
> 
> Drop these redundant definitions since the /smd top-level node is now
> deprecated.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
Hm, 2012 is calling.. it wants it dead code back!

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
>  arch/arm/boot/dts/qcom-apq8064.dtsi | 40 -------------------------------------
>  1 file changed, 40 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi
> index d2289205ff81..e0adf237fc5c 100644
> --- a/arch/arm/boot/dts/qcom-apq8064.dtsi
> +++ b/arch/arm/boot/dts/qcom-apq8064.dtsi
> @@ -226,46 +226,6 @@ smem {
>  		hwlocks = <&sfpb_mutex 3>;
>  	};
>  
> -	smd {
> -		compatible = "qcom,smd";
> -
> -		modem-edge {
> -			interrupts = <0 37 IRQ_TYPE_EDGE_RISING>;
> -
> -			qcom,ipc = <&l2cc 8 3>;
> -			qcom,smd-edge = <0>;
> -
> -			status = "disabled";
> -		};
> -
> -		q6-edge {
> -			interrupts = <0 90 IRQ_TYPE_EDGE_RISING>;
> -
> -			qcom,ipc = <&l2cc 8 15>;
> -			qcom,smd-edge = <1>;
> -
> -			status = "disabled";
> -		};
> -
> -		dsps-edge {
> -			interrupts = <0 138 IRQ_TYPE_EDGE_RISING>;
> -
> -			qcom,ipc = <&sps_sic_non_secure 0x4080 0>;
> -			qcom,smd-edge = <3>;
> -
> -			status = "disabled";
> -		};
> -
> -		riva-edge {
> -			interrupts = <0 198 IRQ_TYPE_EDGE_RISING>;
> -
> -			qcom,ipc = <&l2cc 8 25>;
> -			qcom,smd-edge = <6>;
> -
> -			status = "disabled";
> -		};
> -	};
> -
>  	smsm {
>  		compatible = "qcom,smsm";
>  
>
Konrad Dybcio June 5, 2023, 7:06 p.m. UTC | #5
On 5.06.2023 09:08, Stephan Gerhold wrote:
> Add a simple driver for the qcom,rpm-proc compatible that registers the
> "smd-edge" and populates other children defined in the device tree.
> 
> Note that the DT schema belongs to the remoteproc subsystem while this
> driver is added inside soc/qcom. I argue that the RPM *is* a remoteproc,
> but as an implementation detail in Linux it can currently not benefit
> from anything provided by the remoteproc subsystem. The RPM firmware is
> usually already loaded and started by earlier components in the boot
> chain and is not meant to be ever restarted.
> 
> To avoid breaking existing kernel configurations the driver is always
> built when smd-rpm.c is also built. They belong closely together anyway.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
>  drivers/soc/qcom/Makefile   |  2 +-
>  drivers/soc/qcom/rpm-proc.c | 76 +++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 77 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 99114c71092b..113b9ff2ad43 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -18,7 +18,7 @@ obj-$(CONFIG_QCOM_RPM_MASTER_STATS)	+= rpm_master_stats.o
>  obj-$(CONFIG_QCOM_RPMH)		+= qcom_rpmh.o
>  qcom_rpmh-y			+= rpmh-rsc.o
>  qcom_rpmh-y			+= rpmh.o
> -obj-$(CONFIG_QCOM_SMD_RPM)	+= smd-rpm.o
> +obj-$(CONFIG_QCOM_SMD_RPM)	+= rpm-proc.o smd-rpm.o
>  obj-$(CONFIG_QCOM_SMEM) +=	smem.o
>  obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
>  obj-$(CONFIG_QCOM_SMP2P)	+= smp2p.o
> diff --git a/drivers/soc/qcom/rpm-proc.c b/drivers/soc/qcom/rpm-proc.c
> new file mode 100644
> index 000000000000..0652be7f7895
> --- /dev/null
> +++ b/drivers/soc/qcom/rpm-proc.c
> @@ -0,0 +1,76 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (c) 2021-2023, Stephan Gerhold <stephan@gerhold.net> */
> +
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_platform.h>
> +#include <linux/platform_device.h>
> +#include <linux/rpmsg/qcom_smd.h>
> +
> +static int rpm_proc_probe(struct platform_device *pdev)
> +{
> +	struct qcom_smd_edge *edge = NULL;
> +	struct device *dev = &pdev->dev;
> +	struct device_node *edge_node;
> +	int ret;
> +
> +	edge_node = of_get_child_by_name(dev->of_node, "smd-edge");
> +	if (edge_node) {
> +		edge = qcom_smd_register_edge(dev, edge_node);
> +		if (IS_ERR(edge))
> +			return dev_err_probe(dev, PTR_ERR(edge),
> +					     "Failed to register smd-edge\n");
Need of_node_put in both success and IS_ERR paths

> +	}
> +
> +	ret = devm_of_platform_populate(dev);
> +	if (ret) {
> +		dev_err(dev, "Failed to populate children devices: %d\n", ret);
I may be having a brain lag moment but I think it should be "child"
singular, otherwise it sounds like they're devices for children!

> +		goto err;
> +	}
> +
> +	platform_set_drvdata(pdev, edge);
> +	return 0;
> +err:
> +	if (edge)
> +		qcom_smd_unregister_edge(edge);
> +	return ret;
> +}
> +
> +static void rpm_proc_remove(struct platform_device *pdev)
> +{
> +	struct qcom_smd_edge *edge = platform_get_drvdata(pdev);
> +
> +	if (edge)
> +		qcom_smd_unregister_edge(edge);
> +}
> +
> +static const struct of_device_id rpm_proc_of_match[] = {
> +	{ .compatible = "qcom,rpm-proc", },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, rpm_proc_of_match);
> +
> +static struct platform_driver rpm_proc_driver = {
> +	.probe = rpm_proc_probe,
> +	.remove_new = rpm_proc_remove,
> +	.driver = {
> +		.name = "qcom-rpm-proc",
> +		.of_match_table = rpm_proc_of_match,
> +	},
> +};
> +
> +static int __init rpm_proc_init(void)
> +{
> +	return platform_driver_register(&rpm_proc_driver);
> +}
> +arch_initcall(rpm_proc_init);
Maybe we can go as early as core...

Konrad
> +
> +static void __exit rpm_proc_exit(void)
> +{
> +	platform_driver_unregister(&rpm_proc_driver);
> +}
> +module_exit(rpm_proc_exit);
> +
> +MODULE_DESCRIPTION("Qualcomm RPM processor/subsystem driver");
> +MODULE_AUTHOR("Stephan Gerhold <stephan@gerhold.net>");
> +MODULE_LICENSE("GPL");
>
Konrad Dybcio June 5, 2023, 7:07 p.m. UTC | #6
On 5.06.2023 09:08, Stephan Gerhold wrote:
> Rather than having the RPM SMD channels as the only child of a dummy
> SMD node, switch to representing the RPM as remoteproc like all the
> other remoteprocs (WCNSS, modem DSP).
> 
> This allows assigning additional subdevices to it like the MPM
> interrupt-controller or rpm-master-stats.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
>  arch/arm64/boot/dts/qcom/msm8916.dtsi |   6 +-
>  arch/arm64/boot/dts/qcom/msm8939.dtsi | 112 ++++++++++++-------------
>  arch/arm64/boot/dts/qcom/msm8953.dtsi | 136 +++++++++++++++---------------
>  arch/arm64/boot/dts/qcom/msm8976.dtsi | 152 +++++++++++++++++-----------------
>  arch/arm64/boot/dts/qcom/msm8994.dtsi |  99 +++++++++++-----------
>  5 files changed, 253 insertions(+), 252 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
> index 9494b6512d87..667748612d3e 100644
> --- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
> +++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
> @@ -282,10 +282,10 @@ CLUSTER_PD: power-domain-cluster {
>  		};
>  	};
>  
> -	smd {
> -		compatible = "qcom,smd";
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,msm8916-rpm-proc", "qcom,rpm-proc";
>  
> -		rpm {
> +		smd-edge {
>  			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
>  			qcom,ipc = <&apcs 8 0>;
>  			qcom,smd-edge = <15>;
> diff --git a/arch/arm64/boot/dts/qcom/msm8939.dtsi b/arch/arm64/boot/dts/qcom/msm8939.dtsi
> index 0d9f8b951b66..f11d522586eb 100644
> --- a/arch/arm64/boot/dts/qcom/msm8939.dtsi
> +++ b/arch/arm64/boot/dts/qcom/msm8939.dtsi
> @@ -240,6 +240,62 @@ pmu {
>  		interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>;
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,msm8936-rpm-proc", "qcom,rpm-proc";
> +
> +		smd-edge {
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,ipc = <&apcs1_mbox 8 0>;
> +			qcom,smd-edge = <15>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-msm8936";
> +				qcom,smd-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-msm8936", "qcom,rpmcc";
> +					#clock-cells = <1>;
> +					clock-names = "xo";
> +					clocks = <&xo_board>;
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,msm8939-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_ret: opp1 {
> +							opp-level = <1>;
> +						};
> +
> +						rpmpd_opp_svs_krait: opp2 {
> +							opp-level = <2>;
> +						};
> +
> +						rpmpd_opp_svs_soc: opp3 {
> +							opp-level = <3>;
> +						};
> +
> +						rpmpd_opp_nom: opp4 {
> +							opp-level = <4>;
> +						};
> +
> +						rpmpd_opp_turbo: opp5 {
> +							opp-level = <5>;
> +						};
> +
> +						rpmpd_opp_super_turbo: opp6 {
> +							opp-level = <6>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -308,62 +364,6 @@ mba_mem: mba@8cb00000 {
>  		};
>  	};
>  
> -	smd {
> -		compatible = "qcom,smd";
> -
> -		rpm {
> -			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -			qcom,ipc = <&apcs1_mbox 8 0>;
> -			qcom,smd-edge = <15>;
> -
> -			rpm_requests: rpm-requests {
> -				compatible = "qcom,rpm-msm8936";
> -				qcom,smd-channels = "rpm_requests";
> -
> -				rpmcc: clock-controller {
> -					compatible = "qcom,rpmcc-msm8936", "qcom,rpmcc";
> -					#clock-cells = <1>;
> -					clock-names = "xo";
> -					clocks = <&xo_board>;
> -				};
> -
> -				rpmpd: power-controller {
> -					compatible = "qcom,msm8939-rpmpd";
> -					#power-domain-cells = <1>;
> -					operating-points-v2 = <&rpmpd_opp_table>;
> -
> -					rpmpd_opp_table: opp-table {
> -						compatible = "operating-points-v2";
> -
> -						rpmpd_opp_ret: opp1 {
> -							opp-level = <1>;
> -						};
> -
> -						rpmpd_opp_svs_krait: opp2 {
> -							opp-level = <2>;
> -						};
> -
> -						rpmpd_opp_svs_soc: opp3 {
> -							opp-level = <3>;
> -						};
> -
> -						rpmpd_opp_nom: opp4 {
> -							opp-level = <4>;
> -						};
> -
> -						rpmpd_opp_turbo: opp5 {
> -							opp-level = <5>;
> -						};
> -
> -						rpmpd_opp_super_turbo: opp6 {
> -							opp-level = <6>;
> -						};
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smp2p-hexagon {
>  		compatible = "qcom,smp2p";
>  		qcom,smem = <435>, <428>;
> diff --git a/arch/arm64/boot/dts/qcom/msm8953.dtsi b/arch/arm64/boot/dts/qcom/msm8953.dtsi
> index 7d193a467819..4b2f02850a10 100644
> --- a/arch/arm64/boot/dts/qcom/msm8953.dtsi
> +++ b/arch/arm64/boot/dts/qcom/msm8953.dtsi
> @@ -190,6 +190,74 @@ psci {
>  		method = "smc";
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,msm8953-rpm-proc", "qcom,rpm-proc";
> +
> +		smd-edge {
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,ipc = <&apcs 8 0>;
> +			qcom,smd-edge = <15>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-msm8953";
> +				qcom,smd-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-msm8953", "qcom,rpmcc";
> +					clocks = <&xo_board>;
> +					clock-names = "xo";
> +					#clock-cells = <1>;
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,msm8953-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_ret: opp1 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION>;
> +						};
> +
> +						rpmpd_opp_ret_plus: opp2 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> +						};
> +
> +						rpmpd_opp_min_svs: opp3 {
> +							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> +						};
> +
> +						rpmpd_opp_low_svs: opp4 {
> +							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> +						};
> +
> +						rpmpd_opp_svs: opp5 {
> +							opp-level = <RPM_SMD_LEVEL_SVS>;
> +						};
> +
> +						rpmpd_opp_svs_plus: opp6 {
> +							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> +						};
> +
> +						rpmpd_opp_nom: opp7 {
> +							opp-level = <RPM_SMD_LEVEL_NOM>;
> +						};
> +
> +						rpmpd_opp_nom_plus: opp8 {
> +							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> +						};
> +
> +						rpmpd_opp_turbo: opp9 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -263,74 +331,6 @@ rmtfs@f2d00000 {
>  		};
>  	};
>  
> -	smd {
> -		compatible = "qcom,smd";
> -
> -		rpm {
> -			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -			qcom,ipc = <&apcs 8 0>;
> -			qcom,smd-edge = <15>;
> -
> -			rpm_requests: rpm-requests {
> -				compatible = "qcom,rpm-msm8953";
> -				qcom,smd-channels = "rpm_requests";
> -
> -				rpmcc: clock-controller {
> -					compatible = "qcom,rpmcc-msm8953", "qcom,rpmcc";
> -					clocks = <&xo_board>;
> -					clock-names = "xo";
> -					#clock-cells = <1>;
> -				};
> -
> -				rpmpd: power-controller {
> -					compatible = "qcom,msm8953-rpmpd";
> -					#power-domain-cells = <1>;
> -					operating-points-v2 = <&rpmpd_opp_table>;
> -
> -					rpmpd_opp_table: opp-table {
> -						compatible = "operating-points-v2";
> -
> -						rpmpd_opp_ret: opp1 {
> -							opp-level = <RPM_SMD_LEVEL_RETENTION>;
> -						};
> -
> -						rpmpd_opp_ret_plus: opp2 {
> -							opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> -						};
> -
> -						rpmpd_opp_min_svs: opp3 {
> -							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> -						};
> -
> -						rpmpd_opp_low_svs: opp4 {
> -							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> -						};
> -
> -						rpmpd_opp_svs: opp5 {
> -							opp-level = <RPM_SMD_LEVEL_SVS>;
> -						};
> -
> -						rpmpd_opp_svs_plus: opp6 {
> -							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> -						};
> -
> -						rpmpd_opp_nom: opp7 {
> -							opp-level = <RPM_SMD_LEVEL_NOM>;
> -						};
> -
> -						rpmpd_opp_nom_plus: opp8 {
> -							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> -						};
> -
> -						rpmpd_opp_turbo: opp9 {
> -							opp-level = <RPM_SMD_LEVEL_TURBO>;
> -						};
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smp2p-adsp {
>  		compatible = "qcom,smp2p";
>  		qcom,smem = <443>, <429>;
> diff --git a/arch/arm64/boot/dts/qcom/msm8976.dtsi b/arch/arm64/boot/dts/qcom/msm8976.dtsi
> index 753b9a2105ed..6f856562923f 100644
> --- a/arch/arm64/boot/dts/qcom/msm8976.dtsi
> +++ b/arch/arm64/boot/dts/qcom/msm8976.dtsi
> @@ -232,6 +232,82 @@ psci {
>  		method = "smc";
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,msm8976-rpm-proc", "qcom,rpm-proc";
> +
> +		smd-edge {
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,ipc = <&apcs 8 0>;
> +			qcom,smd-edge = <15>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-msm8976";
> +				qcom,smd-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-msm8976", "qcom,rpmcc";
> +					clocks = <&xo_board>;
> +					clock-names = "xo";
> +					#clock-cells = <1>;
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,msm8976-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_ret: opp1 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION>;
> +						};
> +
> +						rpmpd_opp_ret_plus: opp2 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> +						};
> +
> +						rpmpd_opp_min_svs: opp3 {
> +							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> +						};
> +
> +						rpmpd_opp_low_svs: opp4 {
> +							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> +						};
> +
> +						rpmpd_opp_svs: opp5 {
> +							opp-level = <RPM_SMD_LEVEL_SVS>;
> +						};
> +
> +						rpmpd_opp_svs_plus: opp6 {
> +							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> +						};
> +
> +						rpmpd_opp_nom: opp7 {
> +							opp-level = <RPM_SMD_LEVEL_NOM>;
> +						};
> +
> +						rpmpd_opp_nom_plus: opp8 {
> +							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> +						};
> +
> +						rpmpd_opp_turbo: opp9 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO>;
> +						};
> +
> +						rpmpd_opp_turbo_no_cpr: opp10 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> +						};
> +
> +						rpmpd_opp_turbo_high: opp111 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO_HIGH>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -346,82 +422,6 @@ wcnss_smp2p_in: slave-kernel {
>  		};
>  	};
>  
> -	smd {
> -		compatible = "qcom,smd";
> -
> -		rpm {
> -			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -			qcom,ipc = <&apcs 8 0>;
> -			qcom,smd-edge = <15>;
> -
> -			rpm_requests: rpm-requests {
> -				compatible = "qcom,rpm-msm8976";
> -				qcom,smd-channels = "rpm_requests";
> -
> -				rpmcc: clock-controller {
> -					compatible = "qcom,rpmcc-msm8976", "qcom,rpmcc";
> -					clocks = <&xo_board>;
> -					clock-names = "xo";
> -					#clock-cells = <1>;
> -				};
> -
> -				rpmpd: power-controller {
> -					compatible = "qcom,msm8976-rpmpd";
> -					#power-domain-cells = <1>;
> -					operating-points-v2 = <&rpmpd_opp_table>;
> -
> -					rpmpd_opp_table: opp-table {
> -						compatible = "operating-points-v2";
> -
> -						rpmpd_opp_ret: opp1 {
> -							opp-level = <RPM_SMD_LEVEL_RETENTION>;
> -						};
> -
> -						rpmpd_opp_ret_plus: opp2 {
> -							opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> -						};
> -
> -						rpmpd_opp_min_svs: opp3 {
> -							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> -						};
> -
> -						rpmpd_opp_low_svs: opp4 {
> -							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> -						};
> -
> -						rpmpd_opp_svs: opp5 {
> -							opp-level = <RPM_SMD_LEVEL_SVS>;
> -						};
> -
> -						rpmpd_opp_svs_plus: opp6 {
> -							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> -						};
> -
> -						rpmpd_opp_nom: opp7 {
> -							opp-level = <RPM_SMD_LEVEL_NOM>;
> -						};
> -
> -						rpmpd_opp_nom_plus: opp8 {
> -							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> -						};
> -
> -						rpmpd_opp_turbo: opp9 {
> -							opp-level = <RPM_SMD_LEVEL_TURBO>;
> -						};
> -
> -						rpmpd_opp_turbo_no_cpr: opp10 {
> -							opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> -						};
> -
> -						rpmpd_opp_turbo_high: opp111 {
> -							opp-level = <RPM_SMD_LEVEL_TURBO_HIGH>;
> -						};
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smsm {
>  		compatible = "qcom,smsm";
>  
> diff --git a/arch/arm64/boot/dts/qcom/msm8994.dtsi b/arch/arm64/boot/dts/qcom/msm8994.dtsi
> index 5a7923d7c62a..6168d0aeff57 100644
> --- a/arch/arm64/boot/dts/qcom/msm8994.dtsi
> +++ b/arch/arm64/boot/dts/qcom/msm8994.dtsi
> @@ -178,6 +178,56 @@ psci {
>  		method = "hvc";
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,msm8994-rpm-proc", "qcom,rpm-proc";
> +
> +		smd-edge {
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,ipc = <&apcs 8 0>;
> +			qcom,smd-edge = <15>;
> +			qcom,remote-pid = <6>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-msm8994";
> +				qcom,smd-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-msm8994", "qcom,rpmcc";
> +					#clock-cells = <1>;
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,msm8994-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_ret: opp1 {
> +							opp-level = <1>;
> +						};
> +						rpmpd_opp_svs_krait: opp2 {
> +							opp-level = <2>;
> +						};
> +						rpmpd_opp_svs_soc: opp3 {
> +							opp-level = <3>;
> +						};
> +						rpmpd_opp_nom: opp4 {
> +							opp-level = <4>;
> +						};
> +						rpmpd_opp_turbo: opp5 {
> +							opp-level = <5>;
> +						};
> +						rpmpd_opp_super_turbo: opp6 {
> +							opp-level = <6>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -237,55 +287,6 @@ reserved@6c00000 {
>  		};
>  	};
>  
> -	smd {
> -		compatible = "qcom,smd";
> -		rpm {
> -			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -			qcom,ipc = <&apcs 8 0>;
> -			qcom,smd-edge = <15>;
> -			qcom,remote-pid = <6>;
> -
> -			rpm_requests: rpm-requests {
> -				compatible = "qcom,rpm-msm8994";
> -				qcom,smd-channels = "rpm_requests";
> -
> -				rpmcc: clock-controller {
> -					compatible = "qcom,rpmcc-msm8994", "qcom,rpmcc";
> -					#clock-cells = <1>;
> -				};
> -
> -				rpmpd: power-controller {
> -					compatible = "qcom,msm8994-rpmpd";
> -					#power-domain-cells = <1>;
> -					operating-points-v2 = <&rpmpd_opp_table>;
> -
> -					rpmpd_opp_table: opp-table {
> -						compatible = "operating-points-v2";
> -
> -						rpmpd_opp_ret: opp1 {
> -							opp-level = <1>;
> -						};
> -						rpmpd_opp_svs_krait: opp2 {
> -							opp-level = <2>;
> -						};
> -						rpmpd_opp_svs_soc: opp3 {
> -							opp-level = <3>;
> -						};
> -						rpmpd_opp_nom: opp4 {
> -							opp-level = <4>;
> -						};
> -						rpmpd_opp_turbo: opp5 {
> -							opp-level = <5>;
> -						};
> -						rpmpd_opp_super_turbo: opp6 {
> -							opp-level = <6>;
> -						};
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smem {
>  		compatible = "qcom,smem";
>  		memory-region = <&smem_mem>;
>
Stephan Gerhold June 5, 2023, 7:13 p.m. UTC | #7
On Mon, Jun 05, 2023 at 08:53:21PM +0200, Konrad Dybcio wrote:
> 
> 
> On 5.06.2023 09:08, Stephan Gerhold wrote:
> > Avoid having to look up a dummy item from SMEM to detect if it is
> > already available or if we need to defer probing.
> > 
> > Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> > ---
> >  drivers/soc/qcom/smem.c       | 9 +++++++++
> >  include/linux/soc/qcom/smem.h | 1 +
> >  2 files changed, 10 insertions(+)
> > 
> > diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> > index b0d59e815c3b..3d93a6681494 100644
> > --- a/drivers/soc/qcom/smem.c
> > +++ b/drivers/soc/qcom/smem.c
> > @@ -359,6 +359,15 @@ static struct qcom_smem *__smem;
> >  /* Timeout (ms) for the trylock of remote spinlocks */
> >  #define HWSPINLOCK_TIMEOUT	1000
> >  
> > +/**
> > + * qcom_smem_is_available() - Checks if SMEM is available
> > + */
> Shouldn't kerneldoc explicitly say "returns x if y else z"?
> 

Seems like yes but I copy-pasted from other examples in this file and
there it is always missing. I'll add something simple in v2.

Thanks,
Stephan
Stephan Gerhold June 5, 2023, 7:18 p.m. UTC | #8
On Mon, Jun 05, 2023 at 08:56:44PM +0200, Konrad Dybcio wrote:
> 
> 
> On 5.06.2023 09:08, Stephan Gerhold wrote:
> > Rather than looking up a dummy item from SMEM, use the new
> > qcom_smem_is_available() function to make the code more clear
> > (and reduce the overhead slightly).
> > 
> > Add the same check to qcom_smd_register_edge() as well to ensure that
> > it only succeeds if SMEM is already available - if a driver calls the
> > function and SMEM is not available yet then the initial state will be
> > read incorrectly and the RPMSG devices might never become available.
> > 
> > Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> > ---
> >  drivers/rpmsg/qcom_smd.c | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
> > index 7b9c298aa491..43f601c84b4f 100644
> > --- a/drivers/rpmsg/qcom_smd.c
> > +++ b/drivers/rpmsg/qcom_smd.c
> > @@ -1479,6 +1479,9 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
> >  	struct qcom_smd_edge *edge;
> >  	int ret;
> >  
> > +	if (!qcom_smem_is_available())
> > +		return ERR_PTR(-EPROBE_DEFER);
> > +
> >  	edge = kzalloc(sizeof(*edge), GFP_KERNEL);
> >  	if (!edge)
> >  		return ERR_PTR(-ENOMEM);
> > @@ -1553,12 +1556,9 @@ EXPORT_SYMBOL(qcom_smd_unregister_edge);
> >  static int qcom_smd_probe(struct platform_device *pdev)
> >  {
> >  	struct device_node *node;
> > -	void *p;
> >  
> > -	/* Wait for smem */
> > -	p = qcom_smem_get(QCOM_SMEM_HOST_ANY, smem_items[0].alloc_tbl_id, NULL);
> > -	if (PTR_ERR(p) == -EPROBE_DEFER)
> > -		return PTR_ERR(p);
> > +	if (!qcom_smem_is_available())
> > +		return -EPROBE_DEFER;
> >  
> >  	for_each_available_child_of_node(pdev->dev.of_node, node)
> >  		qcom_smd_register_edge(&pdev->dev, node);
> Hm.. we're not checking the return value here, at all.. Perhaps that
> could be improved and we could only check for smem presence inside
> qcom_smd_register_edge()?
> 

I think the goal here it to register as many of the edges as possible,
so we wouldn't necessarily want to abort if one of them fails. That's
why it's enough to check for only for a possible -EPROBE_DEFER first.

But more importantly after this series this is legacy code that exists
only for backwards compatibility with older DTBs. The probe function
won't be called for DTBs in mainline anymore. So I think it's not worth
to improve it much anymore. ;)

Thanks,
Stephan
Konrad Dybcio June 5, 2023, 7:43 p.m. UTC | #9
On 5.06.2023 09:08, Stephan Gerhold wrote:
> Rather than having the RPM GLINK channels as the only child of a dummy
> top-level rpm-glink node, switch to representing the RPM as remoteproc
> like all the other remoteprocs (modem DSP, ...).
> 
> This allows assigning additional subdevices to it like the MPM
> interrupt-controller or rpm-master-stats.
> 
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> ---
>  arch/arm64/boot/dts/qcom/ipq6018.dtsi |  48 ++++++-----
>  arch/arm64/boot/dts/qcom/ipq9574.dtsi |  28 ++++---
>  arch/arm64/boot/dts/qcom/msm8996.dtsi | 113 ++++++++++++-------------
>  arch/arm64/boot/dts/qcom/msm8998.dtsi |  98 +++++++++++-----------
>  arch/arm64/boot/dts/qcom/qcm2290.dtsi | 126 ++++++++++++++--------------
>  arch/arm64/boot/dts/qcom/qcs404.dtsi  | 152 +++++++++++++++++-----------------
>  arch/arm64/boot/dts/qcom/sdm630.dtsi  | 132 +++++++++++++++--------------
>  arch/arm64/boot/dts/qcom/sm6115.dtsi  | 128 ++++++++++++++--------------
>  arch/arm64/boot/dts/qcom/sm6125.dtsi  | 140 ++++++++++++++++---------------
>  arch/arm64/boot/dts/qcom/sm6375.dtsi  | 126 ++++++++++++++--------------
>  10 files changed, 564 insertions(+), 527 deletions(-)
> 
> diff --git a/arch/arm64/boot/dts/qcom/ipq6018.dtsi b/arch/arm64/boot/dts/qcom/ipq6018.dtsi
> index 7355f266742a..fff4a4014bd8 100644
> --- a/arch/arm64/boot/dts/qcom/ipq6018.dtsi
> +++ b/arch/arm64/boot/dts/qcom/ipq6018.dtsi
> @@ -146,6 +146,32 @@ psci: psci {
>  		method = "smc";
>  	};
>  
> +	rpm: remoteproc-rpm {
Krzysztof, is this fine or should this be just `remoteproc {`?

in any case:
Tested-by: Konrad Dybcio <konrad.dybcio@linaro.org> # SM6375

Konrad
> +		compatible = "qcom,ipq6018-rpm-proc", "qcom,rpm-proc";
> +
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&apcs_glb 0>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-ipq6018";
> +				qcom,glink-channels = "rpm_requests";
> +
> +				regulators {
> +					compatible = "qcom,rpm-mp5496-regulators";
> +
> +					ipq6018_s2: s2 {
> +						regulator-min-microvolt = <725000>;
> +						regulator-max-microvolt = <1062500>;
> +						regulator-always-on;
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -182,28 +208,6 @@ q6_region: memory@4ab00000 {
>  		};
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> -		interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -		mboxes = <&apcs_glb 0>;
> -
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-ipq6018";
> -			qcom,glink-channels = "rpm_requests";
> -
> -			regulators {
> -				compatible = "qcom,rpm-mp5496-regulators";
> -
> -				ipq6018_s2: s2 {
> -					regulator-min-microvolt = <725000>;
> -					regulator-max-microvolt = <1062500>;
> -					regulator-always-on;
> -				};
> -			};
> -		};
> -	};
> -
>  	smem {
>  		compatible = "qcom,smem";
>  		memory-region = <&smem_region>;
> diff --git a/arch/arm64/boot/dts/qcom/ipq9574.dtsi b/arch/arm64/boot/dts/qcom/ipq9574.dtsi
> index 0baeb10bbdae..3222568ac4cf 100644
> --- a/arch/arm64/boot/dts/qcom/ipq9574.dtsi
> +++ b/arch/arm64/boot/dts/qcom/ipq9574.dtsi
> @@ -151,6 +151,22 @@ psci {
>  		method = "smc";
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,ipq9574-rpm-proc", "qcom,rpm-proc";
> +
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&apcs_glb 0>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-ipq9574";
> +				qcom,glink-channels = "rpm_requests";
> +			};
> +		};
> +	};
> +
>  	reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -169,18 +185,6 @@ smem@4aa00000 {
>  		};
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> -		interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -		mboxes = <&apcs_glb 0>;
> -
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-ipq9574";
> -			qcom,glink-channels = "rpm_requests";
> -		};
> -	};
> -
>  	soc: soc@0 {
>  		compatible = "simple-bus";
>  		#address-cells = <1>;
> diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi
> index f75932cc2a30..50ede09d6368 100644
> --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
> +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
> @@ -398,6 +398,63 @@ psci {
>  		method = "smc";
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,msm8996-rpm-proc", "qcom,rpm-proc";
> +
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&apcs_glb 0>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-msm8996";
> +				qcom,glink-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-msm8996", "qcom,rpmcc";
> +					#clock-cells = <1>;
> +					clocks = <&xo_board>;
> +					clock-names = "xo";
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,msm8996-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp1: opp1 {
> +							opp-level = <1>;
> +						};
> +
> +						rpmpd_opp2: opp2 {
> +							opp-level = <2>;
> +						};
> +
> +						rpmpd_opp3: opp3 {
> +							opp-level = <3>;
> +						};
> +
> +						rpmpd_opp4: opp4 {
> +							opp-level = <4>;
> +						};
> +
> +						rpmpd_opp5: opp5 {
> +							opp-level = <5>;
> +						};
> +
> +						rpmpd_opp6: opp6 {
> +							opp-level = <6>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -472,62 +529,6 @@ mdata_mem: mpss-metadata {
>  		};
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> -
> -		interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -
> -		mboxes = <&apcs_glb 0>;
> -
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-msm8996";
> -			qcom,glink-channels = "rpm_requests";
> -
> -			rpmcc: clock-controller {
> -				compatible = "qcom,rpmcc-msm8996", "qcom,rpmcc";
> -				#clock-cells = <1>;
> -				clocks = <&xo_board>;
> -				clock-names = "xo";
> -			};
> -
> -			rpmpd: power-controller {
> -				compatible = "qcom,msm8996-rpmpd";
> -				#power-domain-cells = <1>;
> -				operating-points-v2 = <&rpmpd_opp_table>;
> -
> -				rpmpd_opp_table: opp-table {
> -					compatible = "operating-points-v2";
> -
> -					rpmpd_opp1: opp1 {
> -						opp-level = <1>;
> -					};
> -
> -					rpmpd_opp2: opp2 {
> -						opp-level = <2>;
> -					};
> -
> -					rpmpd_opp3: opp3 {
> -						opp-level = <3>;
> -					};
> -
> -					rpmpd_opp4: opp4 {
> -						opp-level = <4>;
> -					};
> -
> -					rpmpd_opp5: opp5 {
> -						opp-level = <5>;
> -					};
> -
> -					rpmpd_opp6: opp6 {
> -						opp-level = <6>;
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smem {
>  		compatible = "qcom,smem";
>  		memory-region = <&smem_mem>;
> diff --git a/arch/arm64/boot/dts/qcom/msm8998.dtsi b/arch/arm64/boot/dts/qcom/msm8998.dtsi
> index f0e943ff0046..bc51fa6a18aa 100644
> --- a/arch/arm64/boot/dts/qcom/msm8998.dtsi
> +++ b/arch/arm64/boot/dts/qcom/msm8998.dtsi
> @@ -321,68 +321,72 @@ psci {
>  		method = "smc";
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,msm8998-rpm-proc", "qcom,rpm-proc";
>  
> -		interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -		mboxes = <&apcs_glb 0>;
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
>  
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-msm8998";
> -			qcom,glink-channels = "rpm_requests";
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&apcs_glb 0>;
>  
> -			rpmcc: clock-controller {
> -				compatible = "qcom,rpmcc-msm8998", "qcom,rpmcc";
> -				#clock-cells = <1>;
> -			};
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-msm8998";
> +				qcom,glink-channels = "rpm_requests";
>  
> -			rpmpd: power-controller {
> -				compatible = "qcom,msm8998-rpmpd";
> -				#power-domain-cells = <1>;
> -				operating-points-v2 = <&rpmpd_opp_table>;
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-msm8998", "qcom,rpmcc";
> +					#clock-cells = <1>;
> +				};
>  
> -				rpmpd_opp_table: opp-table {
> -					compatible = "operating-points-v2";
> +				rpmpd: power-controller {
> +					compatible = "qcom,msm8998-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
>  
> -					rpmpd_opp_ret: opp1 {
> -						opp-level = <RPM_SMD_LEVEL_RETENTION>;
> -					};
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
>  
> -					rpmpd_opp_ret_plus: opp2 {
> -						opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> -					};
> +						rpmpd_opp_ret: opp1 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION>;
> +						};
>  
> -					rpmpd_opp_min_svs: opp3 {
> -						opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> -					};
> +						rpmpd_opp_ret_plus: opp2 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> +						};
>  
> -					rpmpd_opp_low_svs: opp4 {
> -						opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> -					};
> +						rpmpd_opp_min_svs: opp3 {
> +							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> +						};
>  
> -					rpmpd_opp_svs: opp5 {
> -						opp-level = <RPM_SMD_LEVEL_SVS>;
> -					};
> +						rpmpd_opp_low_svs: opp4 {
> +							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> +						};
>  
> -					rpmpd_opp_svs_plus: opp6 {
> -						opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> -					};
> +						rpmpd_opp_svs: opp5 {
> +							opp-level = <RPM_SMD_LEVEL_SVS>;
> +						};
>  
> -					rpmpd_opp_nom: opp7 {
> -						opp-level = <RPM_SMD_LEVEL_NOM>;
> -					};
> +						rpmpd_opp_svs_plus: opp6 {
> +							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> +						};
>  
> -					rpmpd_opp_nom_plus: opp8 {
> -						opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> -					};
> +						rpmpd_opp_nom: opp7 {
> +							opp-level = <RPM_SMD_LEVEL_NOM>;
> +						};
>  
> -					rpmpd_opp_turbo: opp9 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO>;
> -					};
> +						rpmpd_opp_nom_plus: opp8 {
> +							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> +						};
> +
> +						rpmpd_opp_turbo: opp9 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO>;
> +						};
>  
> -					rpmpd_opp_turbo_plus: opp10 {
> -						opp-level = <RPM_SMD_LEVEL_BINNING>;
> +						rpmpd_opp_turbo_plus: opp10 {
> +							opp-level = <RPM_SMD_LEVEL_BINNING>;
> +						};
>  					};
>  				};
>  			};
> diff --git a/arch/arm64/boot/dts/qcom/qcm2290.dtsi b/arch/arm64/boot/dts/qcom/qcm2290.dtsi
> index b29bc4e4b837..ad1b721d1e1e 100644
> --- a/arch/arm64/boot/dts/qcom/qcm2290.dtsi
> +++ b/arch/arm64/boot/dts/qcom/qcm2290.dtsi
> @@ -137,6 +137,71 @@ psci {
>  		method = "smc";
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,qcm2290-rpm-proc", "qcom,rpm-proc";
> +
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
> +			interrupts = <GIC_SPI 194 IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&apcs_glb 0>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-qcm2290";
> +				qcom,glink-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-qcm2290", "qcom,rpmcc";
> +					clocks = <&xo_board>;
> +					clock-names = "xo";
> +					#clock-cells = <1>;
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,qcm2290-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_min_svs: opp1 {
> +							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> +						};
> +
> +						rpmpd_opp_low_svs: opp2 {
> +							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> +						};
> +
> +						rpmpd_opp_svs: opp3 {
> +							opp-level = <RPM_SMD_LEVEL_SVS>;
> +						};
> +
> +						rpmpd_opp_svs_plus: opp4 {
> +							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> +						};
> +
> +						rpmpd_opp_nom: opp5 {
> +							opp-level = <RPM_SMD_LEVEL_NOM>;
> +						};
> +
> +						rpmpd_opp_nom_plus: opp6 {
> +							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> +						};
> +
> +						rpmpd_opp_turbo: opp7 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO>;
> +						};
> +
> +						rpmpd_opp_turbo_plus: opp8 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved_memory: reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -227,67 +292,6 @@ rmtfs_mem: memory@89b01000 {
>  		};
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> -		interrupts = <GIC_SPI 194 IRQ_TYPE_EDGE_RISING>;
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -		mboxes = <&apcs_glb 0>;
> -
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-qcm2290";
> -			qcom,glink-channels = "rpm_requests";
> -
> -			rpmcc: clock-controller {
> -				compatible = "qcom,rpmcc-qcm2290", "qcom,rpmcc";
> -				clocks = <&xo_board>;
> -				clock-names = "xo";
> -				#clock-cells = <1>;
> -			};
> -
> -			rpmpd: power-controller {
> -				compatible = "qcom,qcm2290-rpmpd";
> -				#power-domain-cells = <1>;
> -				operating-points-v2 = <&rpmpd_opp_table>;
> -
> -				rpmpd_opp_table: opp-table {
> -					compatible = "operating-points-v2";
> -
> -					rpmpd_opp_min_svs: opp1 {
> -						opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> -					};
> -
> -					rpmpd_opp_low_svs: opp2 {
> -						opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> -					};
> -
> -					rpmpd_opp_svs: opp3 {
> -						opp-level = <RPM_SMD_LEVEL_SVS>;
> -					};
> -
> -					rpmpd_opp_svs_plus: opp4 {
> -						opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> -					};
> -
> -					rpmpd_opp_nom: opp5 {
> -						opp-level = <RPM_SMD_LEVEL_NOM>;
> -					};
> -
> -					rpmpd_opp_nom_plus: opp6 {
> -						opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> -					};
> -
> -					rpmpd_opp_turbo: opp7 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO>;
> -					};
> -
> -					rpmpd_opp_turbo_plus: opp8 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smp2p-adsp {
>  		compatible = "qcom,smp2p";
>  		qcom,smem = <443>, <429>;
> diff --git a/arch/arm64/boot/dts/qcom/qcs404.dtsi b/arch/arm64/boot/dts/qcom/qcs404.dtsi
> index 972f753847e1..329363cace5a 100644
> --- a/arch/arm64/boot/dts/qcom/qcs404.dtsi
> +++ b/arch/arm64/boot/dts/qcom/qcs404.dtsi
> @@ -166,6 +166,84 @@ psci {
>  		method = "smc";
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,qcs404-rpm-proc", "qcom,rpm-proc";
> +
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
> +
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&apcs_glb 0>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-qcs404";
> +				qcom,glink-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-qcs404", "qcom,rpmcc";
> +					#clock-cells = <1>;
> +					clocks = <&xo_board>;
> +					clock-names = "xo";
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,qcs404-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_ret: opp1 {
> +							opp-level = <16>;
> +						};
> +
> +						rpmpd_opp_ret_plus: opp2 {
> +							opp-level = <32>;
> +						};
> +
> +						rpmpd_opp_min_svs: opp3 {
> +							opp-level = <48>;
> +						};
> +
> +						rpmpd_opp_low_svs: opp4 {
> +							opp-level = <64>;
> +						};
> +
> +						rpmpd_opp_svs: opp5 {
> +							opp-level = <128>;
> +						};
> +
> +						rpmpd_opp_svs_plus: opp6 {
> +							opp-level = <192>;
> +						};
> +
> +						rpmpd_opp_nom: opp7 {
> +							opp-level = <256>;
> +						};
> +
> +						rpmpd_opp_nom_plus: opp8 {
> +							opp-level = <320>;
> +						};
> +
> +						rpmpd_opp_turbo: opp9 {
> +							opp-level = <384>;
> +						};
> +
> +						rpmpd_opp_turbo_no_cpr: opp10 {
> +							opp-level = <416>;
> +						};
> +
> +						rpmpd_opp_turbo_plus: opp11 {
> +							opp-level = <512>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -217,80 +295,6 @@ uefi_mem: memory@9f800000 {
>  		};
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> -
> -		interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -		mboxes = <&apcs_glb 0>;
> -
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-qcs404";
> -			qcom,glink-channels = "rpm_requests";
> -
> -			rpmcc: clock-controller {
> -				compatible = "qcom,rpmcc-qcs404", "qcom,rpmcc";
> -				#clock-cells = <1>;
> -				clocks = <&xo_board>;
> -				clock-names = "xo";
> -			};
> -
> -			rpmpd: power-controller {
> -				compatible = "qcom,qcs404-rpmpd";
> -				#power-domain-cells = <1>;
> -				operating-points-v2 = <&rpmpd_opp_table>;
> -
> -				rpmpd_opp_table: opp-table {
> -					compatible = "operating-points-v2";
> -
> -					rpmpd_opp_ret: opp1 {
> -						opp-level = <16>;
> -					};
> -
> -					rpmpd_opp_ret_plus: opp2 {
> -						opp-level = <32>;
> -					};
> -
> -					rpmpd_opp_min_svs: opp3 {
> -						opp-level = <48>;
> -					};
> -
> -					rpmpd_opp_low_svs: opp4 {
> -						opp-level = <64>;
> -					};
> -
> -					rpmpd_opp_svs: opp5 {
> -						opp-level = <128>;
> -					};
> -
> -					rpmpd_opp_svs_plus: opp6 {
> -						opp-level = <192>;
> -					};
> -
> -					rpmpd_opp_nom: opp7 {
> -						opp-level = <256>;
> -					};
> -
> -					rpmpd_opp_nom_plus: opp8 {
> -						opp-level = <320>;
> -					};
> -
> -					rpmpd_opp_turbo: opp9 {
> -						opp-level = <384>;
> -					};
> -
> -					rpmpd_opp_turbo_no_cpr: opp10 {
> -						opp-level = <416>;
> -					};
> -
> -					rpmpd_opp_turbo_plus: opp11 {
> -						opp-level = <512>;
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smem {
>  		compatible = "qcom,smem";
>  
> diff --git a/arch/arm64/boot/dts/qcom/sdm630.dtsi b/arch/arm64/boot/dts/qcom/sdm630.dtsi
> index 897f2440c9c8..2dfaec074c24 100644
> --- a/arch/arm64/boot/dts/qcom/sdm630.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm630.dtsi
> @@ -359,6 +359,74 @@ psci {
>  		method = "smc";
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,sdm660-rpm-proc", "qcom,rpm-proc";
> +
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
> +
> +			interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&apcs_glb 0>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-sdm660";
> +				qcom,glink-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-sdm660", "qcom,rpmcc";
> +					#clock-cells = <1>;
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,sdm660-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_ret: opp1 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION>;
> +						};
> +
> +						rpmpd_opp_ret_plus: opp2 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> +						};
> +
> +						rpmpd_opp_min_svs: opp3 {
> +							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> +						};
> +
> +						rpmpd_opp_low_svs: opp4 {
> +							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> +						};
> +
> +						rpmpd_opp_svs: opp5 {
> +							opp-level = <RPM_SMD_LEVEL_SVS>;
> +						};
> +
> +						rpmpd_opp_svs_plus: opp6 {
> +							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> +						};
> +
> +						rpmpd_opp_nom: opp7 {
> +							opp-level = <RPM_SMD_LEVEL_NOM>;
> +						};
> +
> +						rpmpd_opp_nom_plus: opp8 {
> +							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> +						};
> +
> +						rpmpd_opp_turbo: opp9 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -440,70 +508,6 @@ zap_shader_region: gpu@fed00000 {
>  		};
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> -
> -		interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -		mboxes = <&apcs_glb 0>;
> -
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-sdm660";
> -			qcom,glink-channels = "rpm_requests";
> -
> -			rpmcc: clock-controller {
> -				compatible = "qcom,rpmcc-sdm660", "qcom,rpmcc";
> -				#clock-cells = <1>;
> -			};
> -
> -			rpmpd: power-controller {
> -				compatible = "qcom,sdm660-rpmpd";
> -				#power-domain-cells = <1>;
> -				operating-points-v2 = <&rpmpd_opp_table>;
> -
> -				rpmpd_opp_table: opp-table {
> -					compatible = "operating-points-v2";
> -
> -					rpmpd_opp_ret: opp1 {
> -						opp-level = <RPM_SMD_LEVEL_RETENTION>;
> -					};
> -
> -					rpmpd_opp_ret_plus: opp2 {
> -						opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> -					};
> -
> -					rpmpd_opp_min_svs: opp3 {
> -						opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> -					};
> -
> -					rpmpd_opp_low_svs: opp4 {
> -						opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> -					};
> -
> -					rpmpd_opp_svs: opp5 {
> -						opp-level = <RPM_SMD_LEVEL_SVS>;
> -					};
> -
> -					rpmpd_opp_svs_plus: opp6 {
> -						opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> -					};
> -
> -					rpmpd_opp_nom: opp7 {
> -						opp-level = <RPM_SMD_LEVEL_NOM>;
> -					};
> -
> -					rpmpd_opp_nom_plus: opp8 {
> -						opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> -					};
> -
> -					rpmpd_opp_turbo: opp9 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO>;
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smem: smem {
>  		compatible = "qcom,smem";
>  		memory-region = <&smem_region>;
> diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> index 55118577bf92..d3ea67f7563d 100644
> --- a/arch/arm64/boot/dts/qcom/sm6115.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi
> @@ -341,6 +341,72 @@ CLUSTER_1_PD: power-domain-cpu-cluster1 {
>  		};
>  	};
>  
> +	rpm: remoteproc-rpm {
> +		compatible = "qcom,sm6115-rpm-proc", "qcom,rpm-proc";
> +
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
> +
> +			interrupts = <GIC_SPI 194 IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&apcs_glb 0>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-sm6115";
> +				qcom,glink-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-sm6115", "qcom,rpmcc";
> +					clocks = <&xo_board>;
> +					clock-names = "xo";
> +					#clock-cells = <1>;
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,sm6115-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_min_svs: opp1 {
> +							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> +						};
> +
> +						rpmpd_opp_low_svs: opp2 {
> +							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> +						};
> +
> +						rpmpd_opp_svs: opp3 {
> +							opp-level = <RPM_SMD_LEVEL_SVS>;
> +						};
> +
> +						rpmpd_opp_svs_plus: opp4 {
> +							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> +						};
> +
> +						rpmpd_opp_nom: opp5 {
> +							opp-level = <RPM_SMD_LEVEL_NOM>;
> +						};
> +
> +						rpmpd_opp_nom_plus: opp6 {
> +							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> +						};
> +
> +						rpmpd_opp_turbo: opp7 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO>;
> +						};
> +
> +						rpmpd_opp_turbo_plus: opp8 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved_memory: reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -440,68 +506,6 @@ rmtfs_mem: memory@89b01000 {
>  		};
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> -
> -		interrupts = <GIC_SPI 194 IRQ_TYPE_EDGE_RISING>;
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -		mboxes = <&apcs_glb 0>;
> -
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-sm6115";
> -			qcom,glink-channels = "rpm_requests";
> -
> -			rpmcc: clock-controller {
> -				compatible = "qcom,rpmcc-sm6115", "qcom,rpmcc";
> -				clocks = <&xo_board>;
> -				clock-names = "xo";
> -				#clock-cells = <1>;
> -			};
> -
> -			rpmpd: power-controller {
> -				compatible = "qcom,sm6115-rpmpd";
> -				#power-domain-cells = <1>;
> -				operating-points-v2 = <&rpmpd_opp_table>;
> -
> -				rpmpd_opp_table: opp-table {
> -					compatible = "operating-points-v2";
> -
> -					rpmpd_opp_min_svs: opp1 {
> -						opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> -					};
> -
> -					rpmpd_opp_low_svs: opp2 {
> -						opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> -					};
> -
> -					rpmpd_opp_svs: opp3 {
> -						opp-level = <RPM_SMD_LEVEL_SVS>;
> -					};
> -
> -					rpmpd_opp_svs_plus: opp4 {
> -						opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> -					};
> -
> -					rpmpd_opp_nom: opp5 {
> -						opp-level = <RPM_SMD_LEVEL_NOM>;
> -					};
> -
> -					rpmpd_opp_nom_plus: opp6 {
> -						opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> -					};
> -
> -					rpmpd_opp_turbo: opp7 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO>;
> -					};
> -
> -					rpmpd_opp_turbo_plus: opp8 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smp2p-adsp {
>  		compatible = "qcom,smp2p";
>  		qcom,smem = <443>, <429>;
> diff --git a/arch/arm64/boot/dts/qcom/sm6125.dtsi b/arch/arm64/boot/dts/qcom/sm6125.dtsi
> index a596baa6ce3e..1d05ddf35e35 100644
> --- a/arch/arm64/boot/dts/qcom/sm6125.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm6125.dtsi
> @@ -181,6 +181,78 @@ psci {
>  		method = "smc";
>  	};
>  
> +	remoteproc-rpm {
> +		compatible = "qcom,sm6125-rpm-proc", "qcom,rpm-proc";
> +
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
> +
> +			interrupts = <GIC_SPI 194 IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&apcs_glb 0>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-sm6125";
> +				qcom,glink-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-sm6125", "qcom,rpmcc";
> +					#clock-cells = <1>;
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,sm6125-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_ret: opp1 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION>;
> +						};
> +
> +						rpmpd_opp_ret_plus: opp2 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> +						};
> +
> +						rpmpd_opp_min_svs: opp3 {
> +							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> +						};
> +
> +						rpmpd_opp_low_svs: opp4 {
> +							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> +						};
> +
> +						rpmpd_opp_svs: opp5 {
> +							opp-level = <RPM_SMD_LEVEL_SVS>;
> +						};
> +
> +						rpmpd_opp_svs_plus: opp6 {
> +							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> +						};
> +
> +						rpmpd_opp_nom: opp7 {
> +							opp-level = <RPM_SMD_LEVEL_NOM>;
> +						};
> +
> +						rpmpd_opp_nom_plus: opp8 {
> +							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> +						};
> +
> +						rpmpd_opp_turbo: opp9 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO>;
> +						};
> +
> +						rpmpd_opp_turbo_no_cpr: opp10 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> +						};
> +					};
> +				};
> +			};
> +		};
> +	};
> +
>  	reserved_memory: reserved-memory {
>  		#address-cells = <2>;
>  		#size-cells = <2>;
> @@ -292,74 +364,6 @@ qseecom_ta_mem: memory@13fc00000 {
>  		};
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> -
> -		interrupts = <GIC_SPI 194 IRQ_TYPE_EDGE_RISING>;
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -		mboxes = <&apcs_glb 0>;
> -
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-sm6125";
> -			qcom,glink-channels = "rpm_requests";
> -
> -			rpmcc: clock-controller {
> -				compatible = "qcom,rpmcc-sm6125", "qcom,rpmcc";
> -				#clock-cells = <1>;
> -			};
> -
> -			rpmpd: power-controller {
> -				compatible = "qcom,sm6125-rpmpd";
> -				#power-domain-cells = <1>;
> -				operating-points-v2 = <&rpmpd_opp_table>;
> -
> -				rpmpd_opp_table: opp-table {
> -					compatible = "operating-points-v2";
> -
> -					rpmpd_opp_ret: opp1 {
> -						opp-level = <RPM_SMD_LEVEL_RETENTION>;
> -					};
> -
> -					rpmpd_opp_ret_plus: opp2 {
> -						opp-level = <RPM_SMD_LEVEL_RETENTION_PLUS>;
> -					};
> -
> -					rpmpd_opp_min_svs: opp3 {
> -						opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> -					};
> -
> -					rpmpd_opp_low_svs: opp4 {
> -						opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> -					};
> -
> -					rpmpd_opp_svs: opp5 {
> -						opp-level = <RPM_SMD_LEVEL_SVS>;
> -					};
> -
> -					rpmpd_opp_svs_plus: opp6 {
> -						opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> -					};
> -
> -					rpmpd_opp_nom: opp7 {
> -						opp-level = <RPM_SMD_LEVEL_NOM>;
> -					};
> -
> -					rpmpd_opp_nom_plus: opp8 {
> -						opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> -					};
> -
> -					rpmpd_opp_turbo: opp9 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO>;
> -					};
> -
> -					rpmpd_opp_turbo_no_cpr: opp10 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> -					};
> -				};
> -			};
> -		};
> -	};
> -
>  	smem: smem {
>  		compatible = "qcom,smem";
>  		memory-region = <&smem_mem>;
> diff --git a/arch/arm64/boot/dts/qcom/sm6375.dtsi b/arch/arm64/boot/dts/qcom/sm6375.dtsi
> index f8d9c34d3b2f..9834c5089fe8 100644
> --- a/arch/arm64/boot/dts/qcom/sm6375.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sm6375.dtsi
> @@ -493,67 +493,71 @@ cmdline_region: cmdline@ffd00000 {
>  		};
>  	};
>  
> -	rpm-glink {
> -		compatible = "qcom,glink-rpm";
> -		interrupts-extended = <&ipcc IPCC_CLIENT_AOP
> -					     IPCC_MPROC_SIGNAL_GLINK_QMP
> -					     IRQ_TYPE_EDGE_RISING>;
> -		qcom,rpm-msg-ram = <&rpm_msg_ram>;
> -		mboxes = <&ipcc IPCC_CLIENT_AOP IPCC_MPROC_SIGNAL_GLINK_QMP>;
> -
> -		rpm_requests: rpm-requests {
> -			compatible = "qcom,rpm-sm6375";
> -			qcom,glink-channels = "rpm_requests";
> -
> -			rpmcc: clock-controller {
> -				compatible = "qcom,rpmcc-sm6375", "qcom,rpmcc";
> -				clocks = <&xo_board_clk>;
> -				clock-names = "xo";
> -				#clock-cells = <1>;
> -			};
> -
> -			rpmpd: power-controller {
> -				compatible = "qcom,sm6375-rpmpd";
> -				#power-domain-cells = <1>;
> -				operating-points-v2 = <&rpmpd_opp_table>;
> -
> -				rpmpd_opp_table: opp-table {
> -					compatible = "operating-points-v2";
> -
> -					rpmpd_opp_ret: opp1 {
> -						opp-level = <RPM_SMD_LEVEL_RETENTION>;
> -					};
> -
> -					rpmpd_opp_min_svs: opp2 {
> -						opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> -					};
> -
> -					rpmpd_opp_low_svs: opp3 {
> -						opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> -					};
> -
> -					rpmpd_opp_svs: opp4 {
> -						opp-level = <RPM_SMD_LEVEL_SVS>;
> -					};
> -
> -					rpmpd_opp_svs_plus: opp5 {
> -						opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> -					};
> -
> -					rpmpd_opp_nom: opp6 {
> -						opp-level = <RPM_SMD_LEVEL_NOM>;
> -					};
> -
> -					rpmpd_opp_nom_plus: opp7 {
> -						opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> -					};
> -
> -					rpmpd_opp_turbo: opp8 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO>;
> -					};
> -
> -					rpmpd_opp_turbo_no_cpr: opp9 {
> -						opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> +	remoteproc-rpm {
> +		compatible = "qcom,sm6375-rpm-proc", "qcom,rpm-proc";
> +
> +		glink-rpm {
> +			compatible = "qcom,glink-rpm";
> +			interrupts-extended = <&ipcc IPCC_CLIENT_AOP
> +						     IPCC_MPROC_SIGNAL_GLINK_QMP
> +						     IRQ_TYPE_EDGE_RISING>;
> +			qcom,rpm-msg-ram = <&rpm_msg_ram>;
> +			mboxes = <&ipcc IPCC_CLIENT_AOP IPCC_MPROC_SIGNAL_GLINK_QMP>;
> +
> +			rpm_requests: rpm-requests {
> +				compatible = "qcom,rpm-sm6375";
> +				qcom,glink-channels = "rpm_requests";
> +
> +				rpmcc: clock-controller {
> +					compatible = "qcom,rpmcc-sm6375", "qcom,rpmcc";
> +					clocks = <&xo_board_clk>;
> +					clock-names = "xo";
> +					#clock-cells = <1>;
> +				};
> +
> +				rpmpd: power-controller {
> +					compatible = "qcom,sm6375-rpmpd";
> +					#power-domain-cells = <1>;
> +					operating-points-v2 = <&rpmpd_opp_table>;
> +
> +					rpmpd_opp_table: opp-table {
> +						compatible = "operating-points-v2";
> +
> +						rpmpd_opp_ret: opp1 {
> +							opp-level = <RPM_SMD_LEVEL_RETENTION>;
> +						};
> +
> +						rpmpd_opp_min_svs: opp2 {
> +							opp-level = <RPM_SMD_LEVEL_MIN_SVS>;
> +						};
> +
> +						rpmpd_opp_low_svs: opp3 {
> +							opp-level = <RPM_SMD_LEVEL_LOW_SVS>;
> +						};
> +
> +						rpmpd_opp_svs: opp4 {
> +							opp-level = <RPM_SMD_LEVEL_SVS>;
> +						};
> +
> +						rpmpd_opp_svs_plus: opp5 {
> +							opp-level = <RPM_SMD_LEVEL_SVS_PLUS>;
> +						};
> +
> +						rpmpd_opp_nom: opp6 {
> +							opp-level = <RPM_SMD_LEVEL_NOM>;
> +						};
> +
> +						rpmpd_opp_nom_plus: opp7 {
> +							opp-level = <RPM_SMD_LEVEL_NOM_PLUS>;
> +						};
> +
> +						rpmpd_opp_turbo: opp8 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO>;
> +						};
> +
> +						rpmpd_opp_turbo_no_cpr: opp9 {
> +							opp-level = <RPM_SMD_LEVEL_TURBO_NO_CPR>;
> +						};
>  					};
>  				};
>  			};
>
Konrad Dybcio June 5, 2023, 7:45 p.m. UTC | #10
On 5.06.2023 21:18, Stephan Gerhold wrote:
> On Mon, Jun 05, 2023 at 08:56:44PM +0200, Konrad Dybcio wrote:
>>
>>
>> On 5.06.2023 09:08, Stephan Gerhold wrote:
>>> Rather than looking up a dummy item from SMEM, use the new
>>> qcom_smem_is_available() function to make the code more clear
>>> (and reduce the overhead slightly).
>>>
>>> Add the same check to qcom_smd_register_edge() as well to ensure that
>>> it only succeeds if SMEM is already available - if a driver calls the
>>> function and SMEM is not available yet then the initial state will be
>>> read incorrectly and the RPMSG devices might never become available.
>>>
>>> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
>>> ---
>>>  drivers/rpmsg/qcom_smd.c | 10 +++++-----
>>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
>>> index 7b9c298aa491..43f601c84b4f 100644
>>> --- a/drivers/rpmsg/qcom_smd.c
>>> +++ b/drivers/rpmsg/qcom_smd.c
>>> @@ -1479,6 +1479,9 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
>>>  	struct qcom_smd_edge *edge;
>>>  	int ret;
>>>  
>>> +	if (!qcom_smem_is_available())
>>> +		return ERR_PTR(-EPROBE_DEFER);
>>> +
>>>  	edge = kzalloc(sizeof(*edge), GFP_KERNEL);
>>>  	if (!edge)
>>>  		return ERR_PTR(-ENOMEM);
>>> @@ -1553,12 +1556,9 @@ EXPORT_SYMBOL(qcom_smd_unregister_edge);
>>>  static int qcom_smd_probe(struct platform_device *pdev)
>>>  {
>>>  	struct device_node *node;
>>> -	void *p;
>>>  
>>> -	/* Wait for smem */
>>> -	p = qcom_smem_get(QCOM_SMEM_HOST_ANY, smem_items[0].alloc_tbl_id, NULL);
>>> -	if (PTR_ERR(p) == -EPROBE_DEFER)
>>> -		return PTR_ERR(p);
>>> +	if (!qcom_smem_is_available())
>>> +		return -EPROBE_DEFER;
>>>  
>>>  	for_each_available_child_of_node(pdev->dev.of_node, node)
>>>  		qcom_smd_register_edge(&pdev->dev, node);
>> Hm.. we're not checking the return value here, at all.. Perhaps that
>> could be improved and we could only check for smem presence inside
>> qcom_smd_register_edge()?
>>
> 
> I think the goal here it to register as many of the edges as possible,
> so we wouldn't necessarily want to abort if one of them fails. That's
> why it's enough to check for only for a possible -EPROBE_DEFER first.
Hm I guess that's the better option, killing the entire platform (no
rpm = no anything) because one edge failed to register would be not
very user friendly..

> 
> But more importantly after this series this is legacy code that exists
> only for backwards compatibility with older DTBs. The probe function
> won't be called for DTBs in mainline anymore. So I think it's not worth
> to improve it much anymore. ;)
Right!

Konrad
> 
> Thanks,
> Stephan
Stephan Gerhold June 5, 2023, 7:51 p.m. UTC | #11
On Mon, Jun 05, 2023 at 09:06:54PM +0200, Konrad Dybcio wrote:
> 
> 
> On 5.06.2023 09:08, Stephan Gerhold wrote:
> > Add a simple driver for the qcom,rpm-proc compatible that registers the
> > "smd-edge" and populates other children defined in the device tree.
> > 
> > Note that the DT schema belongs to the remoteproc subsystem while this
> > driver is added inside soc/qcom. I argue that the RPM *is* a remoteproc,
> > but as an implementation detail in Linux it can currently not benefit
> > from anything provided by the remoteproc subsystem. The RPM firmware is
> > usually already loaded and started by earlier components in the boot
> > chain and is not meant to be ever restarted.
> > 
> > To avoid breaking existing kernel configurations the driver is always
> > built when smd-rpm.c is also built. They belong closely together anyway.
> > 
> > Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> > ---
> >  drivers/soc/qcom/Makefile   |  2 +-
> >  drivers/soc/qcom/rpm-proc.c | 76 +++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 77 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> > index 99114c71092b..113b9ff2ad43 100644
> > --- a/drivers/soc/qcom/Makefile
> > +++ b/drivers/soc/qcom/Makefile
> > @@ -18,7 +18,7 @@ obj-$(CONFIG_QCOM_RPM_MASTER_STATS)	+= rpm_master_stats.o
> >  obj-$(CONFIG_QCOM_RPMH)		+= qcom_rpmh.o
> >  qcom_rpmh-y			+= rpmh-rsc.o
> >  qcom_rpmh-y			+= rpmh.o
> > -obj-$(CONFIG_QCOM_SMD_RPM)	+= smd-rpm.o
> > +obj-$(CONFIG_QCOM_SMD_RPM)	+= rpm-proc.o smd-rpm.o
> >  obj-$(CONFIG_QCOM_SMEM) +=	smem.o
> >  obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
> >  obj-$(CONFIG_QCOM_SMP2P)	+= smp2p.o
> > diff --git a/drivers/soc/qcom/rpm-proc.c b/drivers/soc/qcom/rpm-proc.c
> > new file mode 100644
> > index 000000000000..0652be7f7895
> > --- /dev/null
> > +++ b/drivers/soc/qcom/rpm-proc.c
> > @@ -0,0 +1,76 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/* Copyright (c) 2021-2023, Stephan Gerhold <stephan@gerhold.net> */
> > +
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +#include <linux/of_platform.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/rpmsg/qcom_smd.h>
> > +
> > +static int rpm_proc_probe(struct platform_device *pdev)
> > +{
> > +	struct qcom_smd_edge *edge = NULL;
> > +	struct device *dev = &pdev->dev;
> > +	struct device_node *edge_node;
> > +	int ret;
> > +
> > +	edge_node = of_get_child_by_name(dev->of_node, "smd-edge");
> > +	if (edge_node) {
> > +		edge = qcom_smd_register_edge(dev, edge_node);
> > +		if (IS_ERR(edge))
> > +			return dev_err_probe(dev, PTR_ERR(edge),
> > +					     "Failed to register smd-edge\n");
> Need of_node_put in both success and IS_ERR paths
> 

Oops. :/

> > +	}
> > +
> > +	ret = devm_of_platform_populate(dev);
> > +	if (ret) {
> > +		dev_err(dev, "Failed to populate children devices: %d\n", ret);
> I may be having a brain lag moment but I think it should be "child"
> singular, otherwise it sounds like they're devices for children!
> 

Uh somehow both sounds fine to me so I'll just change it in v2. :)

> > +		goto err;
> > +	}
> > +
> > +	platform_set_drvdata(pdev, edge);
> > +	return 0;
> > +err:
> > +	if (edge)
> > +		qcom_smd_unregister_edge(edge);
> > +	return ret;
> > +}
> > +
> > +static void rpm_proc_remove(struct platform_device *pdev)
> > +{
> > +	struct qcom_smd_edge *edge = platform_get_drvdata(pdev);
> > +
> > +	if (edge)
> > +		qcom_smd_unregister_edge(edge);
> > +}
> > +
> > +static const struct of_device_id rpm_proc_of_match[] = {
> > +	{ .compatible = "qcom,rpm-proc", },
> > +	{ /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, rpm_proc_of_match);
> > +
> > +static struct platform_driver rpm_proc_driver = {
> > +	.probe = rpm_proc_probe,
> > +	.remove_new = rpm_proc_remove,
> > +	.driver = {
> > +		.name = "qcom-rpm-proc",
> > +		.of_match_table = rpm_proc_of_match,
> > +	},
> > +};
> > +
> > +static int __init rpm_proc_init(void)
> > +{
> > +	return platform_driver_register(&rpm_proc_driver);
> > +}
> > +arch_initcall(rpm_proc_init);
> Maybe we can go as early as core...
> 

SMEM is arch_initcall() so at least for the SMD case it can never
succeed probing in core_initcall() and would likely just cause
unnecessary probe deferrals. That's why I chose arch_initcall().

Are you sure anything will really benefit from core_initcall() here?

I'd just like to avoid making things worse by using a random way too
early initcall level. We have some really weird examples in the tree
currently, e.g.:
  - rpmpd: core_initcall()
  - smd-rpm: arch_initcall()
  - glink-rpm: subsys_initcall()
But they actually need to be loaded in opposite order...

Thanks,
Stephan
Stephan Gerhold June 5, 2023, 7:55 p.m. UTC | #12
On Mon, Jun 05, 2023 at 09:43:50PM +0200, Konrad Dybcio wrote:
> On 5.06.2023 09:08, Stephan Gerhold wrote:
> > Rather than having the RPM GLINK channels as the only child of a dummy
> > top-level rpm-glink node, switch to representing the RPM as remoteproc
> > like all the other remoteprocs (modem DSP, ...).
> > 
> > This allows assigning additional subdevices to it like the MPM
> > interrupt-controller or rpm-master-stats.
> > 
> > Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> > ---
> >  arch/arm64/boot/dts/qcom/ipq6018.dtsi |  48 ++++++-----
> >  arch/arm64/boot/dts/qcom/ipq9574.dtsi |  28 ++++---
> >  arch/arm64/boot/dts/qcom/msm8996.dtsi | 113 ++++++++++++-------------
> >  arch/arm64/boot/dts/qcom/msm8998.dtsi |  98 +++++++++++-----------
> >  arch/arm64/boot/dts/qcom/qcm2290.dtsi | 126 ++++++++++++++--------------
> >  arch/arm64/boot/dts/qcom/qcs404.dtsi  | 152 +++++++++++++++++-----------------
> >  arch/arm64/boot/dts/qcom/sdm630.dtsi  | 132 +++++++++++++++--------------
> >  arch/arm64/boot/dts/qcom/sm6115.dtsi  | 128 ++++++++++++++--------------
> >  arch/arm64/boot/dts/qcom/sm6125.dtsi  | 140 ++++++++++++++++---------------
> >  arch/arm64/boot/dts/qcom/sm6375.dtsi  | 126 ++++++++++++++--------------
> >  10 files changed, 564 insertions(+), 527 deletions(-)
> > 
> > diff --git a/arch/arm64/boot/dts/qcom/ipq6018.dtsi b/arch/arm64/boot/dts/qcom/ipq6018.dtsi
> > index 7355f266742a..fff4a4014bd8 100644
> > --- a/arch/arm64/boot/dts/qcom/ipq6018.dtsi
> > +++ b/arch/arm64/boot/dts/qcom/ipq6018.dtsi
> > @@ -146,6 +146,32 @@ psci: psci {
> >  		method = "smc";
> >  	};
> >  
> > +	rpm: remoteproc-rpm {
> Krzysztof, is this fine or should this be just `remoteproc {`?
> 

What if you have multiple remoteprocs? I took this naming convention
from sdm845.dtsi by the way:

	adsp_pas: remoteproc-adsp {
		compatible = "qcom,sdm845-adsp-pas";
	cdsp_pas: remoteproc-cdsp {
		compatible = "qcom,sdm845-cdsp-pas";

Thanks,
Stephan
Konrad Dybcio June 5, 2023, 7:55 p.m. UTC | #13
On 5.06.2023 21:51, Stephan Gerhold wrote:
> On Mon, Jun 05, 2023 at 09:06:54PM +0200, Konrad Dybcio wrote:
>>
>>
>> On 5.06.2023 09:08, Stephan Gerhold wrote:
>>> Add a simple driver for the qcom,rpm-proc compatible that registers the
>>> "smd-edge" and populates other children defined in the device tree.
>>>
>>> Note that the DT schema belongs to the remoteproc subsystem while this
>>> driver is added inside soc/qcom. I argue that the RPM *is* a remoteproc,
>>> but as an implementation detail in Linux it can currently not benefit
>>> from anything provided by the remoteproc subsystem. The RPM firmware is
>>> usually already loaded and started by earlier components in the boot
>>> chain and is not meant to be ever restarted.
>>>
>>> To avoid breaking existing kernel configurations the driver is always
>>> built when smd-rpm.c is also built. They belong closely together anyway.
>>>
>>> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
>>> ---
[...]

> SMEM is arch_initcall() so at least for the SMD case it can never
> succeed probing in core_initcall() and would likely just cause
> unnecessary probe deferrals. That's why I chose arch_initcall().
> 
> Are you sure anything will really benefit from core_initcall() here?
> 
> I'd just like to avoid making things worse by using a random way too
> early initcall level. We have some really weird examples in the tree
> currently, e.g.:
>   - rpmpd: core_initcall()
>   - smd-rpm: arch_initcall()
>   - glink-rpm: subsys_initcall()
> But they actually need to be loaded in opposite order...
Yes, we should make some sort of dep graph and clean it up..

Konrad
> 
> Thanks,
> Stephan