From: Hector Martin <marcan@marcan.st>
To: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>
Cc: Sven Peter <sven@svenpeter.dev>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Janne Grunau <j@jannau.net>, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
devicetree@vger.kernel.org, iommu@lists.linux.dev,
asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Hector Martin <marcan@marcan.st>
Subject: [PATCH 4/7] iommu: dart: Support a variable number of TTBRs per stream
Date: Wed, 4 Jan 2023 20:00:10 +0900 [thread overview]
Message-ID: <20230104110013.24738-5-marcan@marcan.st> (raw)
In-Reply-To: <20230104110013.24738-1-marcan@marcan.st>
T8110 only has one TTBR per stream, so un-hardcode that.
Signed-off-by: Hector Martin <marcan@marcan.st>
---
drivers/iommu/apple-dart.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index 48743bcd5b9d..189487c1d978 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -77,15 +77,21 @@
#define DART_TCR_BYPASS0_ENABLE BIT(8)
#define DART_TCR_BYPASS1_ENABLE BIT(12)
-#define DART_TTBR(sid, idx) (0x200 + 16 * (sid) + 4 * (idx))
#define DART_TTBR_VALID BIT(31)
#define DART_TTBR_SHIFT 12
+#define DART_TTBR(dart, sid, idx) (0x200 + \
+ (((dart)->hw->ttbr_count * (sid)) << 2) + \
+ ((idx) << 2))
+
+
struct apple_dart_hw {
u32 oas;
enum io_pgtable_fmt fmt;
int max_sid_count;
+
+ int ttbr_count;
};
/*
@@ -245,7 +251,7 @@ static void apple_dart_hw_set_ttbr(struct apple_dart_stream_map *stream_map,
WARN_ON(paddr & ((1 << DART_TTBR_SHIFT) - 1));
for_each_set_bit(sid, stream_map->sidmap, dart->num_streams)
writel(DART_TTBR_VALID | (paddr >> DART_TTBR_SHIFT),
- dart->regs + DART_TTBR(sid, idx));
+ dart->regs + DART_TTBR(dart, sid, idx));
}
static void apple_dart_hw_clear_ttbr(struct apple_dart_stream_map *stream_map,
@@ -255,7 +261,7 @@ static void apple_dart_hw_clear_ttbr(struct apple_dart_stream_map *stream_map,
int sid;
for_each_set_bit(sid, stream_map->sidmap, dart->num_streams)
- writel(0, dart->regs + DART_TTBR(sid, idx));
+ writel(0, dart->regs + DART_TTBR(dart, sid, idx));
}
static void
@@ -263,7 +269,7 @@ apple_dart_hw_clear_all_ttbrs(struct apple_dart_stream_map *stream_map)
{
int i;
- for (i = 0; i < DART_MAX_TTBR; ++i)
+ for (i = 0; i < stream_map->dart->hw->ttbr_count; ++i)
apple_dart_hw_clear_ttbr(stream_map, i);
}
@@ -415,7 +421,7 @@ apple_dart_setup_translation(struct apple_dart_domain *domain,
for (i = 0; i < pgtbl_cfg->apple_dart_cfg.n_ttbrs; ++i)
apple_dart_hw_set_ttbr(stream_map, i,
pgtbl_cfg->apple_dart_cfg.ttbr[i]);
- for (; i < DART_MAX_TTBR; ++i)
+ for (; i < stream_map->dart->hw->ttbr_count; ++i)
apple_dart_hw_clear_ttbr(stream_map, i);
apple_dart_hw_enable_translation(stream_map);
@@ -956,11 +962,15 @@ static const struct apple_dart_hw apple_dart_hw_t8103 = {
.oas = 36,
.fmt = APPLE_DART,
.max_sid_count = 16,
+
+ .ttbr_count = 4,
};
static const struct apple_dart_hw apple_dart_hw_t6000 = {
.oas = 42,
.fmt = APPLE_DART2,
.max_sid_count = 16,
+
+ .ttbr_count = 4,
};
static __maybe_unused int apple_dart_suspend(struct device *dev)
@@ -970,9 +980,9 @@ static __maybe_unused int apple_dart_suspend(struct device *dev)
for (sid = 0; sid < dart->num_streams; sid++) {
dart->save_tcr[sid] = readl_relaxed(dart->regs + DART_TCR(sid));
- for (idx = 0; idx < DART_MAX_TTBR; idx++)
+ for (idx = 0; idx < dart->hw->ttbr_count; idx++)
dart->save_ttbr[sid][idx] =
- readl(dart->regs + DART_TTBR(sid, idx));
+ readl(dart->regs + DART_TTBR(dart, sid, idx));
}
return 0;
@@ -993,7 +1003,7 @@ static __maybe_unused int apple_dart_resume(struct device *dev)
for (sid = 0; sid < dart->num_streams; sid++) {
for (idx = 0; idx < DART_MAX_TTBR; idx++)
writel(dart->save_ttbr[sid][idx],
- dart->regs + DART_TTBR(sid, idx));
+ dart->regs + DART_TTBR(dart, sid, idx));
writel(dart->save_tcr[sid], dart->regs + DART_TCR(sid));
}
--
2.35.1
next prev parent reply other threads:[~2023-01-04 11:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-04 11:00 [PATCH 0/7] iommu: dart: Apple t8110 DART support Hector Martin
2023-01-04 11:00 ` [PATCH 1/7] dt-bindings: iommu: dart: add t8110 compatible Hector Martin
2023-01-04 13:08 ` Sven Peter
2023-01-06 12:54 ` Krzysztof Kozlowski
2023-01-04 11:00 ` [PATCH 2/7] iommu: dart: Add suspend/resume support Hector Martin
2023-01-04 11:00 ` [PATCH 3/7] iommu: dart: Support >64 stream IDs Hector Martin
2023-01-04 13:37 ` Sven Peter
2023-01-05 4:43 ` Hector Martin
2023-01-05 9:47 ` Sven Peter
2023-01-04 11:00 ` Hector Martin [this message]
2023-01-04 13:18 ` [PATCH 4/7] iommu: dart: Support a variable number of TTBRs per stream Sven Peter
2023-01-05 4:51 ` Hector Martin
2023-01-04 11:00 ` [PATCH 5/7] iommu: dart: Fix DART_PARAMS1/2 bit define names Hector Martin
2023-01-04 13:23 ` Sven Peter
2023-01-04 11:00 ` [PATCH 6/7] iommu: dart: Support different variants with different registers Hector Martin
2023-01-04 13:43 ` Sven Peter
2023-01-05 5:16 ` Hector Martin
2023-01-05 9:46 ` Sven Peter
2023-01-04 11:00 ` [PATCH 7/7] iommu: dart: Add t8110 DART support Hector Martin
2023-01-04 13:50 ` Sven Peter
2023-01-05 5:19 ` Hector Martin
2023-01-05 9:45 ` Sven Peter
2023-01-13 10:50 [PATCH 0/7] iommu: dart: Apple " Hector Martin
2023-01-13 10:50 ` [PATCH 4/7] iommu: dart: Support a variable number of TTBRs per stream Hector Martin
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=20230104110013.24738-5-marcan@marcan.st \
--to=marcan@marcan.st \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=devicetree@vger.kernel.org \
--cc=iommu@lists.linux.dev \
--cc=j@jannau.net \
--cc=joro@8bytes.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sven@svenpeter.dev \
--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).