From: Gokul Sriram P <quic_gokulsri@quicinc.com>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: <andersson@kernel.org>, <krzk+dt@kernel.org>,
<linux-arm-msm@vger.kernel.org>,
<linux-remoteproc@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <quic_viswanat@quicinc.com>,
<quic_mmanikan@quicinc.com>, <quic_varada@quicinc.com>,
<quic_srichara@quicinc.com>
Subject: Re: [PATCH 2/2] remoteproc: qcom: add hexagon based WCSS secure PIL driver
Date: Thu, 22 Aug 2024 14:31:39 +0530 [thread overview]
Message-ID: <c7f24af9-c43f-4d8b-b5c1-e34c34de4d44@quicinc.com> (raw)
In-Reply-To: <4y37wrg7gi3unpqw5ukgd6jrwuqmuofcabhmtwzlgfpgtiighw@74abrhmpzktv>
On 8/20/2024 4:55 PM, Krzysztof Kozlowski wrote:
> On Tue, Aug 20, 2024 at 02:25:15PM +0530, Gokul Sriram Palanisamy wrote:
>> From: Vignesh Viswanathan <quic_viswanat@quicinc.com>
>>
>> Add support to bring up hexagon based WCSS secure PIL remoteproc.
>> IPQ5332, IPQ9574 supports secure PIL remoteproc.
>>
>> Signed-off-by: Vignesh Viswanathan <quic_viswanat@quicinc.com>
>> Signed-off-by: Manikanta Mylavarapu <quic_mmanikan@quicinc.com>
>> Signed-off-by: Gokul Sriram Palanisamy <quic_gokulsri@quicinc.com>
>> +static int wcss_sec_dump_segments(struct rproc *rproc,
>> + const struct firmware *fw)
>> +{
>> + struct device *dev = rproc->dev.parent;
>> + struct reserved_mem *rmem = NULL;
>> + struct device_node *node;
>> + int num_segs, index = 0;
>> + int ret;
>> +
>> + /* Parse through additional reserved memory regions for the rproc
>> + * and add them to the coredump segments
>> + */
>> + num_segs = of_count_phandle_with_args(dev->of_node,
>> + "memory-region", NULL);
>> + while (index < num_segs) {
>> + node = of_parse_phandle(dev->of_node,
>> + "memory-region", index);
>> + if (!node)
>> + return -EINVAL;
>> +
>> + rmem = of_reserved_mem_lookup(node);
>> + if (!rmem) {
>> + dev_err(dev, "unable to acquire memory-region index %d num_segs %d\n",
>> + index, num_segs);
> Leaking refcnt.
Got it. Will update. Thank you.
>> + return -EINVAL;
>> + }
>> +
>> + of_node_put(node);
>> +
>> + dev_dbg(dev, "Adding segment 0x%pa size 0x%pa",
>> + &rmem->base, &rmem->size);
>> + ret = rproc_coredump_add_custom_segment(rproc,
>> + rmem->base,
>> + rmem->size,
>> + wcss_sec_copy_segment,
>> + NULL);
>> + if (ret)
>> + return ret;
>> +
>> + index++;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static const struct rproc_ops wcss_sec_ops = {
>> + .start = wcss_sec_start,
>> + .stop = wcss_sec_stop,
>> + .da_to_va = wcss_sec_da_to_va,
>> + .load = wcss_sec_load,
>> + .get_boot_addr = rproc_elf_get_boot_addr,
>> + .panic = wcss_sec_panic,
>> + .parse_fw = wcss_sec_dump_segments,
>> +};
>> +
>> +static int wcss_sec_alloc_memory_region(struct wcss_sec *wcss)
>> +{
>> + struct reserved_mem *rmem = NULL;
>> + struct device_node *node;
>> + struct device *dev = wcss->dev;
>> +
>> + node = of_parse_phandle(dev->of_node, "memory-region", 0);
>> + if (node) {
>> + rmem = of_reserved_mem_lookup(node);
>> + } else {
> No, that's over complicated.
>
> Just if (!node) { error handling }.
Ok. Will update.
>> + dev_err(dev, "can't find phandle memory-region\n");
>> + return -EINVAL;
>> + }
>> +
>> + of_node_put(node);
>> +
>> + if (!rmem) {
>> + dev_err(dev, "unable to acquire memory-region\n");
>> + return -EINVAL;
>> + }
>> +
>> + wcss->mem_phys = rmem->base;
>> + wcss->mem_reloc = rmem->base;
>> + wcss->mem_size = rmem->size;
>> + wcss->mem_region = devm_ioremap_wc(dev, wcss->mem_phys, wcss->mem_size);
>> + if (!wcss->mem_region) {
>> + dev_err(dev, "unable to map memory region: %pa+%pa\n",
>> + &rmem->base, &rmem->size);
>> + return -ENOMEM;
>> + }
>> +
>> + return 0;
>> +}
>> +
> ...
>
>> +static int wcss_sec_ipq5332_init_clk(struct wcss_sec *wcss)
>> +{
>> + int ret;
>> + struct device *dev = wcss->dev;
>> +
>> + wcss->im_sleep = devm_clk_get(wcss->dev, "im_sleep");
>> + if (IS_ERR(wcss->im_sleep)) {
>> + ret = PTR_ERR(wcss->im_sleep);
>> + if (ret != -EPROBE_DEFER)
>> + dev_err(dev, "failed to get im_sleep clock");
> Syntax is return dev_err_probe.
Thanks. Will update.
>> + return ret;
>> + }
>> +
>> + ret = clk_prepare_enable(wcss->im_sleep);
>> + if (ret) {
>> + dev_err(dev, "could not enable im_sleep clk\n");
>> + return ret;
> Just use devm_clk_get_enabled.
Will update.
>> + }
>> +
>> + return 0;
> Best regards,
> Krzysztof
>
next prev parent reply other threads:[~2024-08-22 9:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 8:55 [PATCH 0/4] Add new driver for WCSS secure PIL loading Gokul Sriram Palanisamy
2024-08-20 8:55 ` [PATCH 1/2] dt-bindings: remoteproc: qcom: document hexagon based WCSS secure PIL Gokul Sriram Palanisamy
2024-08-20 11:20 ` Krzysztof Kozlowski
2024-08-22 10:47 ` Gokul Sriram P
2024-08-22 11:30 ` Krzysztof Kozlowski
[not found] ` <982ca02e-a0b0-4dac-9294-ae2c2fb3463f@quicinc.com>
2024-08-23 13:47 ` Krzysztof Kozlowski
2024-08-20 8:55 ` [PATCH 2/2] remoteproc: qcom: add hexagon based WCSS secure PIL driver Gokul Sriram Palanisamy
2024-08-20 11:25 ` Krzysztof Kozlowski
2024-08-22 9:01 ` Gokul Sriram P [this message]
2024-08-20 8:55 ` [PATCH 3/4] arm64: dts: qcom: ipq5332: add nodes to bringup q6 Gokul Sriram Palanisamy
2024-08-20 11:21 ` Krzysztof Kozlowski
2024-08-22 10:38 ` Gokul Sriram P
2024-08-20 8:55 ` [PATCH 4/4] arm64: dts: qcom: ipq9574: add nodes to bring up q6 Gokul Sriram Palanisamy
2024-08-20 11:12 ` [PATCH 0/4] Add new driver for WCSS secure PIL loading Krzysztof Kozlowski
2024-08-22 10:43 ` Gokul Sriram P
2024-08-22 11:28 ` Krzysztof Kozlowski
2024-08-23 9:49 ` Gokul Sriram P
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c7f24af9-c43f-4d8b-b5c1-e34c34de4d44@quicinc.com \
--to=quic_gokulsri@quicinc.com \
--cc=andersson@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=quic_mmanikan@quicinc.com \
--cc=quic_srichara@quicinc.com \
--cc=quic_varada@quicinc.com \
--cc=quic_viswanat@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®