From: Robin Murphy <robin.murphy@arm.com>
To: Will Deacon <will@kernel.org>
Cc: bjorn.andersson@linaro.org, iommu@lists.linux-foundation.org,
gregory.clement@bootlin.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 08/15] iommu/arm-smmu: Abstract context bank accesses
Date: Thu, 15 Aug 2019 12:41:49 +0100 [thread overview]
Message-ID: <721e3f61-89f2-174a-da30-7aacc8c8865f@arm.com> (raw)
In-Reply-To: <20190815105611.fk7ouis2cs3uzvew@willie-the-truck>
On 15/08/2019 11:56, Will Deacon wrote:
> On Fri, Aug 09, 2019 at 06:07:45PM +0100, Robin Murphy wrote:
>> Context bank accesses are fiddly enough to deserve a number of extra
>> helpers to keep the callsites looking sane, even though there are only
>> one or two of each.
>>
>> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
>> ---
>> drivers/iommu/arm-smmu.c | 137 ++++++++++++++++++++-------------------
>> 1 file changed, 72 insertions(+), 65 deletions(-)
>>
>> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
>> index 72505647b77d..abdcc3f52e2e 100644
>> --- a/drivers/iommu/arm-smmu.c
>> +++ b/drivers/iommu/arm-smmu.c
>> @@ -82,9 +82,6 @@
>> ((smmu->options & ARM_SMMU_OPT_SECURE_CFG_ACCESS) \
>> ? 0x400 : 0))
>>
>> -/* Translation context bank */
>> -#define ARM_SMMU_CB(smmu, n) ((smmu)->base + (((smmu)->cb_base + (n)) << (smmu)->pgshift))
>> -
>> #define MSI_IOVA_BASE 0x8000000
>> #define MSI_IOVA_LENGTH 0x100000
>>
>> @@ -265,9 +262,29 @@ static void arm_smmu_writel(struct arm_smmu_device *smmu, int page, int offset,
>> writel_relaxed(val, arm_smmu_page(smmu, page) + offset);
>> }
>>
>> +static u64 arm_smmu_readq(struct arm_smmu_device *smmu, int page, int offset)
>> +{
>> + return readq_relaxed(arm_smmu_page(smmu, page) + offset);
>> +}
>> +
>> +static void arm_smmu_writeq(struct arm_smmu_device *smmu, int page, int offset,
>> + u64 val)
>> +{
>> + writeq_relaxed(val, arm_smmu_page(smmu, page) + offset);
>> +}
>> +
>> #define arm_smmu_read_gr1(s, r) arm_smmu_readl((s), 1, (r))
>> #define arm_smmu_write_gr1(s, r, v) arm_smmu_writel((s), 1, (r), (v))
>>
>> +#define arm_smmu_read_cb(s, n, r) \
>> + arm_smmu_readl((s), (s)->cb_base + (n), (r))
>> +#define arm_smmu_write_cb(s, n, r, v) \
>> + arm_smmu_writel((s), (s)->cb_base + (n), (r), (v))
>> +#define arm_smmu_read_cb_q(s, n, r) \
>> + arm_smmu_readq((s), (s)->cb_base + (n), (r))
>> +#define arm_smmu_write_cb_q(s, n, r, v) \
>> + arm_smmu_writeq((s), (s)->cb_base + (n), (r), (v))
>
> 'r' for 'offset'? (maybe just rename offset => register in the helpers).
I think this all represents the mangled remains of an underlying notion
of 'register offset' ;)
>> struct arm_smmu_option_prop {
>> u32 opt;
>> const char *prop;
>> @@ -423,15 +440,17 @@ static void __arm_smmu_free_bitmap(unsigned long *map, int idx)
>> }
>>
>> /* Wait for any pending TLB invalidations to complete */
>> -static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu,
>> - void __iomem *sync, void __iomem *status)
>> +static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu, int page,
>> + int sync, int status)
>> {
>> unsigned int spin_cnt, delay;
>> + u32 reg;
>>
>> - writel_relaxed(QCOM_DUMMY_VAL, sync);
>> + arm_smmu_writel(smmu, page, sync, QCOM_DUMMY_VAL);
>> for (delay = 1; delay < TLB_LOOP_TIMEOUT; delay *= 2) {
>> for (spin_cnt = TLB_SPIN_COUNT; spin_cnt > 0; spin_cnt--) {
>> - if (!(readl_relaxed(status) & sTLBGSTATUS_GSACTIVE))
>> + reg = arm_smmu_readl(smmu, page, status);
>> + if (!(reg & sTLBGSTATUS_GSACTIVE))
>> return;
>> cpu_relax();
>> }
>> @@ -443,12 +462,11 @@ static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu,
>>
>> static void arm_smmu_tlb_sync_global(struct arm_smmu_device *smmu)
>> {
>> - void __iomem *base = ARM_SMMU_GR0(smmu);
>> unsigned long flags;
>>
>> spin_lock_irqsave(&smmu->global_sync_lock, flags);
>> - __arm_smmu_tlb_sync(smmu, base + ARM_SMMU_GR0_sTLBGSYNC,
>> - base + ARM_SMMU_GR0_sTLBGSTATUS);
>> + __arm_smmu_tlb_sync(smmu, 0, ARM_SMMU_GR0_sTLBGSYNC,
>
> Can we have a #define for page zero, please?
Again, now I recall pondering the exact same thought, so clearly I don't
have any grounds to object. I guess it's worth reworking the previous
ARM_SMMU_{GR0,GR1,CB()} macros into the page number scheme rather than
just killing them off - let me give that a try.
Robin.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2019-08-15 11:41 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-09 17:07 [PATCH 00/15] Arm SMMU refactoring Robin Murphy
2019-08-09 17:07 ` [PATCH 01/15] iommu/arm-smmu: Convert GR0 registers to bitfields Robin Murphy
2019-08-14 17:20 ` Will Deacon
2019-08-14 17:35 ` Robin Murphy
2019-08-09 17:07 ` [PATCH 02/15] iommu/arm-smmu: Convert GR1 " Robin Murphy
2019-08-09 17:07 ` [PATCH 03/15] iommu/arm-smmu: Convert context bank " Robin Murphy
2019-08-09 17:07 ` [PATCH 04/15] iommu/arm-smmu: Rework cb_base handling Robin Murphy
2019-08-14 18:05 ` Will Deacon
2019-08-15 11:14 ` Robin Murphy
2019-08-09 17:07 ` [PATCH 05/15] iommu/arm-smmu: Split arm_smmu_tlb_inv_range_nosync() Robin Murphy
2019-08-15 10:56 ` Will Deacon
2019-08-15 11:22 ` Robin Murphy
2019-08-09 17:07 ` [PATCH 06/15] iommu/arm-smmu: Get rid of weird "atomic" write Robin Murphy
2019-08-09 17:07 ` [PATCH 07/15] iommu/arm-smmu: Abstract GR1 accesses Robin Murphy
2019-08-09 17:07 ` [PATCH 08/15] iommu/arm-smmu: Abstract context bank accesses Robin Murphy
2019-08-15 10:56 ` Will Deacon
2019-08-15 11:41 ` Robin Murphy [this message]
2019-08-09 17:07 ` [PATCH 09/15] iommu/arm-smmu: Abstract GR0 accesses Robin Murphy
2019-08-09 17:07 ` [PATCH 10/15] iommu/arm-smmu: Rename arm-smmu-regs.h Robin Murphy
2019-08-09 17:07 ` [PATCH 11/15] iommu/arm-smmu: Add implementation infrastructure Robin Murphy
2019-08-09 17:07 ` [PATCH 12/15] iommu/arm-smmu: Move Secure access quirk to implementation Robin Murphy
2019-08-09 17:07 ` [PATCH 13/15] iommu/arm-smmu: Add configuration implementation hook Robin Murphy
2019-08-09 17:07 ` [PATCH 14/15] iommu/arm-smmu: Add reset " Robin Murphy
2019-08-09 17:07 ` [PATCH 15/15] iommu/arm-smmu: Add context init " Robin Murphy
2019-08-13 19:11 ` Krishna Reddy
2019-08-15 10:56 ` Will Deacon
2019-08-15 12:09 ` Robin Murphy
2019-08-15 15:09 ` Jordan Crouse
2019-08-09 17:11 ` [PATCH 00/15] Arm SMMU refactoring Robin Murphy
2019-08-15 10:55 ` 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=721e3f61-89f2-174a-da30-7aacc8c8865f@arm.com \
--to=robin.murphy@arm.com \
--cc=bjorn.andersson@linaro.org \
--cc=gregory.clement@bootlin.com \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=will@kernel.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).