From: Stephen Boyd <sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
To: Rob Clark <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>,
Stanimir Varbanov
<stanimir.varbanov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH 6/9] iommu: qcom: initialize secure page table
Date: Wed, 1 Mar 2017 14:14:29 -0800 [thread overview]
Message-ID: <3ee2b1b2-ffd8-a1e8-0c14-b5d764a742c0@codeaurora.org> (raw)
In-Reply-To: <20170301174258.14618-7-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On 03/01/2017 09:42 AM, Rob Clark wrote:
> From: Stanimir Varbanov <stanimir.varbanov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> This bassicaly get the secure page table size, allocate memory
s/bassicaly/basically/
s/get/gets/
s/allocate/allocates/
Heh, bass.
> and return back the physical address to the trusted zone.
s/return/returns/
>
> Signed-off-by: Stanimir Varbanov <stanimir.varbanov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Signed-off-by: Rob Clark <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> drivers/iommu/qcom_iommu.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 64 insertions(+)
>
> diff --git a/drivers/iommu/qcom_iommu.c b/drivers/iommu/qcom_iommu.c
> index 5d3bb63..082ece7 100644
> --- a/drivers/iommu/qcom_iommu.c
> +++ b/drivers/iommu/qcom_iommu.c
> @@ -608,6 +608,51 @@ static void qcom_iommu_disable_clocks(struct qcom_iommu_dev *qcom_iommu)
> clk_disable_unprepare(qcom_iommu->iface_clk);
> }
>
> +static int qcom_iommu_sec_ptbl_init(struct device *dev)
> +{
> + size_t psize = 0;
> + unsigned int spare = 0;
Why not just pass 0 where it's used?
> + void *cpu_addr;
> + dma_addr_t paddr;
> + unsigned long attrs;
> + static bool allocated = false;
> + int ret;
> +
> + if (allocated)
> + return 0;
> +
> + ret = qcom_scm_iommu_secure_ptbl_size(spare, &psize);
> + if (ret) {
> + dev_err(dev, "failed to get iommu secure pgtable size (%d)\n",
> + ret);
> + return ret;
> + }
> +
> + dev_info(dev, "iommu sec: pgtable size: %zu\n", psize);
Debug?
> +
> + attrs = DMA_ATTR_NO_KERNEL_MAPPING;
> +
> + cpu_addr = dma_alloc_attrs(dev, psize, &paddr, GFP_KERNEL, attrs);
> + if (!cpu_addr) {
> + dev_err(dev, "failed to allocate %zu bytes for pgtable\n",
> + psize);
> + return -ENOMEM;
> + }
> +
> + ret = qcom_scm_iommu_secure_ptbl_init(paddr, psize, spare);
> + if (ret) {
> + dev_err(dev, "failed to init iommu pgtable (%d)\n", ret);
> + goto free_mem;
> + }
> +
> + allocated = true;
> + return 0;
> +
> +free_mem:
> + dma_free_attrs(dev, psize, cpu_addr, paddr, attrs);
> + return ret;
> +}
> +
> static int qcom_iommu_ctx_probe(struct platform_device *pdev)
> {
> struct qcom_iommu_ctx *ctx;
> @@ -693,6 +738,17 @@ static struct platform_driver qcom_iommu_ctx_driver = {
> };
> module_platform_driver(qcom_iommu_ctx_driver);
>
> +static bool qcom_iommu_has_secure_context(struct qcom_iommu_dev *qcom_iommu)
> +{
> + struct device_node *child;
> +
> + for_each_child_of_node(qcom_iommu->dev->of_node, child)
> + if (of_device_is_compatible(child, "qcom,msm-iommu-v1-sec"))
> + return true;
Missing an of_node_put(child) here?
> +
> + return false;
> +}
> +
> static int qcom_iommu_device_probe(struct platform_device *pdev)
> {
> struct qcom_iommu_dev *qcom_iommu;
> @@ -731,6 +787,14 @@ static int qcom_iommu_device_probe(struct platform_device *pdev)
> return -ENODEV;
> }
>
> + if (qcom_iommu_has_secure_context(qcom_iommu)) {
> + ret = qcom_iommu_sec_ptbl_init(dev);
Is dev the same dev that's passed to qcom_iommu_has_secure_context()?
Perhaps we can pass dev to has_secure_context instead to make things
clearer.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2017-03-01 22:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-01 17:42 [PATCH 0/9] iommu: add qcom_iommu for early "B" family devices Rob Clark
[not found] ` <20170301174258.14618-1-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-01 17:42 ` [PATCH 1/9] firmware/qcom: add qcom_scm_restore_sec_cfg() Rob Clark
2017-03-01 17:42 ` [PATCH 2/9] firmware: qcom_scm: add two scm calls for iommu secure page table Rob Clark
2017-03-01 17:42 ` [PATCH 3/9] Docs: dt: document qcom iommu bindings Rob Clark
[not found] ` <20170301174258.14618-4-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-03 6:21 ` Rob Herring
2017-03-03 16:04 ` Rob Clark
2017-03-01 17:42 ` [PATCH 4/9] iommu: arm-smmu: split out register defines Rob Clark
2017-03-01 17:42 ` [PATCH 5/9] iommu: add qcom_iommu Rob Clark
[not found] ` <20170301174258.14618-6-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-01 23:54 ` Stephen Boyd
[not found] ` <3d0d6fc9-f8dd-933d-eda2-9a76c95bb70b-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-03-02 3:30 ` Rob Clark
2017-03-07 17:48 ` Robin Murphy
[not found] ` <e82dbbc8-c81f-13ea-6ffc-d67204afb748-5wv7dgnIgG8@public.gmane.org>
2017-03-07 22:44 ` Rob Clark
[not found] ` <CAF6AEGuH_PZsVCBKeh_=Ev39UZcdgN1Xpn5ekPbC9yr1z_ONQA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-09 10:14 ` sricharan
2017-03-13 13:38 ` sricharan
2017-03-13 18:19 ` Rob Clark
[not found] ` <CAF6AEGsoHwDRR02nxz_fkeSPrXBRmG_38xvkF6f0=m+Ucj_soA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-20 14:21 ` Sricharan R
[not found] ` <6398dcd5-812d-f746-5bd8-2288b0cc501d-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2017-03-20 15:11 ` Rob Clark
2017-03-01 17:42 ` [PATCH 6/9] iommu: qcom: initialize secure page table Rob Clark
[not found] ` <20170301174258.14618-7-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-03-01 22:14 ` Stephen Boyd [this message]
2017-03-01 17:42 ` [PATCH 7/9] ARM64: DT: add gpu for msm8916 Rob Clark
2017-03-01 17:42 ` [PATCH 8/9] ARM64: DT: add video codec devicetree node Rob Clark
2017-03-01 17:42 ` [PATCH 9/9] ARM64: DT: add iommu for msm8916 Rob Clark
-- strict thread matches above, loose matches on Subject: below --
2017-03-14 15:18 [PATCH 0/9] iommu: add qcom_iommu for early "B" family devices (v2) Rob Clark
2017-03-14 15:18 ` [PATCH 6/9] iommu: qcom: initialize secure page table Rob Clark
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=3ee2b1b2-ffd8-a1e8-0c14-b5d764a742c0@codeaurora.org \
--to=sboyd-sgv2jx0feol9jmxxk+q4oq@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=stanimir.varbanov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=will.deacon-5wv7dgnIgG8@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).