Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Documentation/devicetree/bindings/iommu/apple,dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ properties:
- apple,t8152-acio-dart
- apple,t8152-pciec-dart
- apple,t8152-avd-dart
- apple,t8152-ane-dart
- apple,t8152-disp-isoc-dart
- items:
- const: apple,t8140-ane-dart
Expand Down Expand Up @@ -390,6 +391,7 @@ allOf:
- apple,t8152-acio-dart
- apple,t8152-pciec-dart
- apple,t8152-avd-dart
- apple,t8152-ane-dart
- apple,t8152-disp-isoc-dart
then:
description:
Expand All @@ -404,6 +406,9 @@ allOf:
inactive streams and are initialized by the operating system.
The T8152 AVD instance uses the same aperture, starts unlocked with
inactive streams and is initialized after its PSD domain is on.
The T8152 ANE instances (four per engine) use the same aperture,
start unlocked with inactive streams, and initialize stream 0 with
four-level 42-bit tables after their PSD power domain is on.
properties:
reg:
minItems: 2
Expand All @@ -425,7 +430,9 @@ allOf:
properties:
compatible:
contains:
const: apple,t8152-avd-dart
enum:
- apple,t8152-avd-dart
- apple,t8152-ane-dart
then:
required:
- power-domains
Expand Down
40 changes: 37 additions & 3 deletions drivers/iommu/apple-dart.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ struct apple_dart {
bool cold_gen3;
u32 cold_gen3_sids;
bool cold_gen3_pcie;
bool cold_gen3_4level;
struct device *dev;
const struct apple_dart_hw *hw;

Expand Down Expand Up @@ -3764,7 +3765,7 @@ static int __apple_dart_finalize_domain(struct apple_dart_domain *dart_domain,
.iommu_dev = dart->dev,
};

if (dart->cold_gen3) {
if (dart->cold_gen3 && !dart->cold_gen3_4level) {
if ((dma_min ^ dma_max) & ~DMA_BIT_MASK(36)) {
ret = -ERANGE;
goto done;
Expand Down Expand Up @@ -6231,6 +6232,7 @@ static int apple_dart_probe(struct platform_device *pdev)
"usb4-pcie-tunnel-");
bool j713_display, j713_dcpext, j713_dispext, j713_radio, t8132_dcp = false;
bool cold_avd = of_device_is_compatible(dev->of_node, "apple,t8152-avd-dart");
bool cold_ane_gen3 = of_device_is_compatible(dev->of_node, "apple,t8152-ane-dart");
bool cold_isoc = of_device_is_compatible(dev->of_node, "apple,t8152-disp-isoc-dart");
bool t8132_dcpext = false;

Expand Down Expand Up @@ -6363,6 +6365,12 @@ static int apple_dart_probe(struct platform_device *pdev)
dart->cold_gen3 = true;
dart->cold_gen3_sids = 0x7;
}
/* Stream 0 of each T8152 ANE Gen3 instance (four-level 42-bit tables). */
if (cold_ane_gen3) {
dart->cold_gen3 = true;
dart->cold_gen3_sids = BIT(0);
dart->cold_gen3_4level = true;
}
if (cold_isoc) {
dart->cold_gen3 = true;
dart->cold_gen3_sids = BIT(30);
Expand Down Expand Up @@ -6508,7 +6516,8 @@ static int apple_dart_probe(struct platform_device *pdev)
if (IS_ERR(dart->dapf))
return PTR_ERR(dart->dapf);
}
dart->restore_on_power_up = of_property_read_bool(dev->of_node,
dart->restore_on_power_up = cold_ane_gen3 ||
of_property_read_bool(dev->of_node,
"apple,restore-on-power-up");
if (tunneled) {
dart->tunables = devm_apple_tunable_parse(dev, dev->of_node,
Expand Down Expand Up @@ -6852,10 +6861,11 @@ static int apple_dart_probe(struct platform_device *pdev)
(dart->locked || dart->version != 0x300 ||
(!cold_isoc && !dart->tunables) ||
(dart->cold_gen3_pcie ? (!tunneled || !dev->pm_domain) :
cold_avd ? (dart->num_streams != 16 || !dev->pm_domain) :
(cold_avd || cold_ane_gen3) ? (dart->num_streams != 16 || !dev->pm_domain) :
cold_isoc ? (dart->num_streams < 31 || dart->num_streams > 32 ||
!dev->pm_domain) :
dart->num_streams != 32) ||
(dart->cold_gen3_4level && !dart->four_level) ||
(apple_dart_readl(dart, dart->hw->enable_streams) & dart->cold_gen3_sids))) {
ret = -EINVAL;
goto err_clk_disable;
Expand Down Expand Up @@ -7501,6 +7511,9 @@ static void apple_dart_save_state(struct apple_dart *dart)
unsigned int sid, idx;

for (sid = 0; sid < dart->num_streams; sid++) {
if (dart->cold_gen3_4level &&
(sid >= 32 || !(dart->cold_gen3_sids & BIT(sid))))
continue;
dart->save_tcr[sid] = apple_dart_readl(dart,
DART_TCR(dart, sid));
for (idx = 0; idx < dart->hw->ttbr_count; idx++)
Expand Down Expand Up @@ -8169,6 +8182,26 @@ static __maybe_unused int apple_dart_resume(struct device *dev)
return ret;
}

if (dart->cold_gen3_4level) {
struct apple_dart_stream_map stream_map = { .dart = dart };
unsigned int limit = min_t(unsigned int, dart->num_streams, 32);

ret = apple_dart_hw_reset(dart);
for (sid = 0; sid < limit; sid++) {
if (!(dart->cold_gen3_sids & BIT(sid)))
continue;
for (idx = 0; idx < dart->hw->ttbr_count; idx++)
apple_dart_writel(dart, dart->save_ttbr[sid][idx],
DART_TTBR(dart, sid, idx));
apple_dart_writel(dart, dart->save_tcr[sid],
DART_TCR(dart, sid));
__set_bit(sid, stream_map.sidmap);
}
ret = dart->hw->invalidate_tlb(&stream_map) ?: ret;
dart->reset_incomplete = ret;
return ret;
}

ret = apple_dart_hw_reset(dart);

/*
Expand Down Expand Up @@ -8434,6 +8467,7 @@ static const struct dev_pm_ops apple_dart_pm_ops = {
static const struct of_device_id apple_dart_of_match[] = {
{ .compatible = "apple,t8152-dart-gen3", .data = &apple_dart_hw_gen3 },
{ .compatible = "apple,t8152-avd-dart", .data = &apple_dart_hw_gen3 },
{ .compatible = "apple,t8152-ane-dart", .data = &apple_dart_hw_gen3 },
{ .compatible = "apple,t8152-disp-isoc-dart", .data = &apple_dart_hw_gen3 },
{ .compatible = "apple,t8152-acio-dart", .data = &apple_dart_hw_gen3 },
{ .compatible = "apple,t8152-pciec-dart", .data = &apple_dart_hw_gen3 },
Expand Down
2 changes: 2 additions & 0 deletions tools/asahi/apple-dart-isp-host-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ def extract_function(source, name):
bool isp_host;
bool isp_sleep_lost;
bool full_errors;
bool cold_gen3_4level;
u32 cold_gen3_sids;
u32 save_err_irq_enable;
u32 save_tcr[256];
u32 save_ttbr[256][4];
Expand Down