mbox series

[v6,00/8] Qualcomm AOSS QMP driver and modem dts

Message ID 20190206051335.23799-1-bjorn.andersson@linaro.org
Headers show
Series Qualcomm AOSS QMP driver and modem dts | expand

Message

Bjorn Andersson Feb. 6, 2019, 5:13 a.m. UTC
Update the reserved memory map for SDM845, add the ADSP and CDSP nodes,
introduce a communication driver for the AOSS and a PD driver for this and
finally add the modem remoteproc driver.

Bjorn Andersson (7):
  arm64: dts: qcom: sdm845: Update reserved memory map
  arm64: dts: qcom: sdm845: Define rmtfs memory
  arm64: dts: sdm845: Introduce ADSP and CDSP PAS nodes
  dt-bindings: soc: qcom: Add AOSS QMP binding
  soc: qcom: Add AOSS QMP communication driver
  soc: qcom: Add AOSS QMP genpd provider
  arm64: dts: qcom: Add AOSS QMP node

Sibi Sankar (1):
  arm64: dts: qcom: sdm845: Add Q6V5 MSS node

 .../bindings/soc/qcom/qcom,aoss-qmp.txt       |  76 ++++
 arch/arm64/boot/dts/qcom/sdm845-mtp.dts       |   8 +
 arch/arm64/boot/dts/qcom/sdm845.dtsi          | 209 ++++++++++-
 drivers/soc/qcom/Kconfig                      |  18 +
 drivers/soc/qcom/Makefile                     |   2 +
 drivers/soc/qcom/aoss-qmp-pd.c                | 158 +++++++++
 drivers/soc/qcom/aoss-qmp.c                   | 326 ++++++++++++++++++
 include/dt-bindings/power/qcom-aoss-qmp.h     |  15 +
 include/linux/soc/qcom/aoss-qmp.h             |  14 +
 9 files changed, 819 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,aoss-qmp.txt
 create mode 100644 drivers/soc/qcom/aoss-qmp-pd.c
 create mode 100644 drivers/soc/qcom/aoss-qmp.c
 create mode 100644 include/dt-bindings/power/qcom-aoss-qmp.h
 create mode 100644 include/linux/soc/qcom/aoss-qmp.h

-- 
2.18.0

Comments

Doug Anderson Feb. 11, 2019, 10:15 p.m. UTC | #1
Hi,

On Tue, Feb 5, 2019 at 9:13 PM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> +static int qmp_pd_image_toggle(struct qmp_pd *res, bool enable)

> +{

> +       char buf[AOSS_QMP_PD_MSG_LEN];

> +

> +       memset(buf, 0, sizeof(buf));


Personally I find it safer/cleaner to do something like:

char buf[AOSS_QMP_PD_MSG_LEN] = { };

...but I won't insist.  If you change this, change in qmp_pd_clock_toggle() too.


> +static int qmp_pd_probe(struct platform_device *pdev)

> +{

> +       struct genpd_onecell_data *data;

> +       struct device *parent = pdev->dev.parent;

> +       struct qmp_pd *res;

> +       struct qmp *qmp;

> +       size_t num = ARRAY_SIZE(sdm845_resources);

> +       int ret;

> +       int i;

> +

> +       qmp = dev_get_drvdata(pdev->dev.parent);

> +       if (!qmp)

> +               return -EINVAL;

> +

> +       res = devm_kcalloc(&pdev->dev, num, sizeof(*res), GFP_KERNEL);

> +       if (!res)

> +               return -ENOMEM;

> +

> +       data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);

> +       if (!data)

> +               return -ENOMEM;

> +

> +       data->domains = devm_kcalloc(&pdev->dev, num, sizeof(*data->domains),

> +                                    GFP_KERNEL);

> +       if (!data->domains)

> +               return -ENOMEM;

> +

> +       for (i = 0; i < num; i++) {

> +               res[i].qmp = qmp;

> +               res[i].pd.name = sdm845_resources[i].name;

> +               res[i].pd.power_on = sdm845_resources[i].on;

> +               res[i].pd.power_off = sdm845_resources[i].off;

> +

> +               ret = pm_genpd_init(&res[i].pd, NULL, true);

> +               if (ret < 0) {

> +                       dev_err(&pdev->dev, "failed to init genpd\n");


It's often nice to print the error number (ret) in the message.


> +                       goto unroll_genpds;

> +               }

> +

> +               data->domains[i] = &res[i].pd;

> +       }

> +

> +       data->num_domains = i;

> +

> +       platform_set_drvdata(pdev, data);

> +

> +       return of_genpd_add_provider_onecell(parent->of_node, data);


Now that you have error handling (the calls to "pm_genpd_remove"), you
can't just do this.  You need:

ret = of_genpd_add_provider_onecell(parent->of_node, data);
if (!ret)
  return 0;


> +unroll_genpds:

> +       for (i--; i >= 0; i--)

> +               pm_genpd_remove(data->domains[i]);

> +

> +       return ret;

> +}

> +

> +static int qmp_pd_remove(struct platform_device *pdev)

> +{

> +       struct device *parent = pdev->dev.parent;

> +       struct genpd_onecell_data *data = platform_get_drvdata(pdev);

> +       int i;

> +

> +       of_genpd_del_provider(parent->of_node);

> +

> +       for (i = 0; i < data->num_domains; i++)

> +               pm_genpd_remove(data->domains[i]);


I presume it doesn't matter, but if you truly want to be the inverse
of the "probe" then you'd want to iterate starting at "num_domains -
1" and go to 0.


-Doug
Doug Anderson Feb. 11, 2019, 10:30 p.m. UTC | #2
Hi,

On Tue, Feb 5, 2019 at 9:13 PM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> +       if (of_property_read_bool(pdev->dev.of_node, "#power-domain-cells")) {

> +               qmp->pd_pdev = platform_device_register_data(&pdev->dev,

> +                                                            "aoss_qmp_pd",

> +                                                            PLATFORM_DEVID_NONE,

> +                                                            NULL, 0);

> +               if (IS_ERR(qmp->pd_pdev)) {

> +                       dev_err(&pdev->dev, "failed to register AOSS PD\n");


nit: not worth spinning just for this, but if you happen to spin you
could print the error number in your message.


> +                       ret = PTR_ERR(qmp->pd_pdev);

> +                       goto err_close_qmp;

> +               }

> +       }


As discussed in v5 I wonder if the complexity of a separate driver is
really worth it or if everything would be a lot easier to just link
the two ".c" files together.  Now that it's a full error case if
"aoss_qmp_pd" doesn't probe I'd vote for linking the two ".c" files
together, but part of that is because I don't really want to dig into
all the details of how you're supposed to call
platform_device_register_data() for sub-devices and double-checking
that you've got all the corner cases correct.

...NOTE: presumably if you just change it to a straight-up function
call then you can also get rid of the above "dev_err" since
(presumably) you'll know that the init code of aoss_qmp_pd will print
any relevant errors?


-Doug