From: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
To: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
Cc: "laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org"
<laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
"linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org"
<linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>,
"iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org"
<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: Re: [PATCH 2/5] iommu/arm-smmu: Sort out coherency
Date: Tue, 28 Jul 2015 16:17:48 +0100 [thread overview]
Message-ID: <55B79D1C.7030507@arm.com> (raw)
In-Reply-To: <20150728094349.GE29209-5wv7dgnIgG8@public.gmane.org>
Hi Will,
On 28/07/15 10:43, Will Deacon wrote:
> Hi Robin,
>
> Cheers for doing this. Just a few comments (mainly in relation to being
> consistent with SMMUv3).
Thanks!
> On Mon, Jul 27, 2015 at 07:18:09PM +0100, Robin Murphy wrote:
>> Currently we detect the whether the SMMU has coherent page table walk
>
> "we detect the whether"?
Er, yeah, looks like rain tomorrow afternoon :P
>> capability from the IDR0.CTTW field, and base our cache maintenance
>> decisions on that. In preparation for fixing the bogus DMA API usage,
>> however, we need to ensure that the DMA API agrees about this, which
>> necessitates deferring to the dma-coherent property in the device tree
>> for the final say.
>>
>> As an added bonus, since systems exist where an external CTTW signal
>> has been tied off incorrectly at integration, allowing DT to override
>> it offers a neat workaround for coherency issues with such SMMUs.
>>
>> Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
>> ---
>> Documentation/devicetree/bindings/iommu/arm,smmu.txt | 4 ++++
>> drivers/iommu/arm-smmu.c | 17 ++++++++++++++---
>> 2 files changed, 18 insertions(+), 3 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu.txt b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
>> index 0676050..04724fc 100644
>> --- a/Documentation/devicetree/bindings/iommu/arm,smmu.txt
>> +++ b/Documentation/devicetree/bindings/iommu/arm,smmu.txt
>> @@ -43,6 +43,10 @@ conditions.
>>
>> ** System MMU optional properties:
>>
>> +- dma-coherent : Presence or absence should correctly reflect whether
>> + the SMMU translation table walk interface is
>> + cache-coherent with the CPU.
>> +
>
> Please copy the text from:
> Documentation/devicetree/bindings/iommu/arm,smmu-v3.txt#
> and remove the bit about stream table accesses.
Done, although since the resulting "...DMA operations made by the SMMU
(page table walks)..." is both redundant and horribly clunky it gets
rewritten as "...page table walks made by the SMMU..."
>> - calxeda,smmu-secure-config-access : Enable proper handling of buggy
>> implementations that always use secure access to
>> SMMU configuration registers. In this case non-secure
>> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
>> index 4cd0c29..9a59bef 100644
>> --- a/drivers/iommu/arm-smmu.c
>> +++ b/drivers/iommu/arm-smmu.c
>> @@ -1532,6 +1532,7 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
>> unsigned long size;
>> void __iomem *gr0_base = ARM_SMMU_GR0(smmu);
>> u32 id;
>> + bool cttw_dt, cttw_reg;
>>
>> dev_notice(smmu->dev, "probing hardware configuration...\n");
>> dev_notice(smmu->dev, "SMMUv%d with:\n", smmu->version);
>> @@ -1571,10 +1572,20 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
>> dev_notice(smmu->dev, "\taddress translation ops\n");
>> }
>>
>> - if (id & ID0_CTTW) {
>> + /*
>> + * In order for DMA API calls to work properly, we must defer to what
>> + * the DT says about coherency, regardless of what the hardware claims.
>> + * Fortunately, this also opens up a workaround for systems where the
>> + * ID register value has ended up configured incorrectly.
>> + */
>> + cttw_dt = of_property_read_bool(smmu->dev->of_node, "dma-coherent");
>
> Use of_dma_is_coherent(smmu->dev->of_node)
*facepalm*
>> + if (cttw_dt)
>> smmu->features |= ARM_SMMU_FEAT_COHERENT_WALK;
>> - dev_notice(smmu->dev, "\tcoherent table walk\n");
>> - }
>> + cttw_reg = !!(id & ID0_CTTW);
>> + if (cttw_dt || cttw_reg)
>> + dev_notice(smmu->dev, "\t%scoherent table walk%s\n",
>> + cttw_dt ? "" : "no ",
>> + (cttw_dt == cttw_reg) ? "" : " (overridden by DT)");
>
> Similarly here; I think we should just follow the message printed by the
> SMMUv3 driver but s/IDR0.COHACC/ID0.CTTW/.
I note that the v3 driver stays silent as long as the DT and hardware
agree - I'm reticent to entirely remove the original message here as
it's proved rather useful (especially in debugging-over-email exchanges)
to see at a glance from a boot log whether the driver thinks a
particular SMMU is coherent or not (particularly with my SMMUv1
many-instances-in-the-same-system hat on). I can certainly make the
override message more consistent, though.
Robin
next prev parent reply other threads:[~2015-07-28 15:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-27 18:18 [PATCH 1/5] iommu/io-pgtable-arm: Allow appropriate DMA API use Robin Murphy
[not found] ` <c8cc82fea26044e393ff857014d4146faac5ec1e.1438019069.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2015-07-27 18:18 ` [PATCH 2/5] iommu/arm-smmu: Sort out coherency Robin Murphy
[not found] ` <4d5880f2131854bc59107ccc917993136e511341.1438019069.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2015-07-28 9:43 ` Will Deacon
[not found] ` <20150728094349.GE29209-5wv7dgnIgG8@public.gmane.org>
2015-07-28 15:17 ` Robin Murphy [this message]
2015-07-27 18:18 ` [PATCH 3/5] iommu/arm-smmu: Clean up DMA API usage Robin Murphy
[not found] ` <921980a38ec7d35610c68e8e94235c55318ba80c.1438019069.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2015-07-28 10:18 ` Will Deacon
[not found] ` <20150728101810.GG29209-5wv7dgnIgG8@public.gmane.org>
2015-07-28 15:48 ` Robin Murphy
[not found] ` <55B7A439.3000007-5wv7dgnIgG8@public.gmane.org>
2015-07-28 16:06 ` Will Deacon
2015-07-27 18:18 ` [PATCH 4/5] iommu/arm-smmu-v3: " Robin Murphy
2015-07-27 18:18 ` [PATCH 5/5] iommu/ipmmu-vmsa: " Robin Murphy
2015-07-28 10:17 ` [PATCH 1/5] iommu/io-pgtable-arm: Allow appropriate DMA API use Will Deacon
[not found] ` <20150728101722.GF29209-5wv7dgnIgG8@public.gmane.org>
2015-07-28 15:39 ` Robin Murphy
[not found] ` <55B7A22B.6010608-5wv7dgnIgG8@public.gmane.org>
2015-07-28 15:52 ` Will Deacon
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=55B79D1C.7030507@arm.com \
--to=robin.murphy-5wv7dgnigg8@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \
--cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@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