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
15 changes: 9 additions & 6 deletions Documentation/accel/apple-ane.rst
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,10 @@ stage that has not run yet, up to the one written, for diagnosis.
A stage at or below the completed one is refused with ``-EALREADY``. There
is no module parameter and no H14 boot parameter changes the H16 path. H17 still refuses ownership and registration.
All build-dependent boot values and ordered masked updates belong to the
H16 27.0 (26A428) match-data profile. The existing preload validator must
accept the resident image before that profile can run. Live mutable patchbay
and firmware tunable values are preserved, with no disk firmware owner.
H16 27.0 (26A428) match-data build shared by the supported H16 profiles
(27.0 26A428, 27.2 26B123, 26.6.2 25G83, and 26.5.2 25F84). The preload
validator must accept the resident image before a profile can run. Live mutable
patchbay and firmware tunable values are preserved, with no disk firmware owner.

``preflight`` raises the five real domains through genpd, in DT order, and
checks every requested/ACTUAL low byte twice before reading the engine.
Expand All @@ -702,7 +703,8 @@ three DART fault status/address words, version/protect/lock headers and four
DAPF records per instance against ``apple,dapf-ranges``. The ANE backend
writes no engine, DART or DAPF register at this rung. Genpd owns power writes.

``map`` claims an exclusive, singleton IOMMU group and an unmanaged domain
``map`` verifies that none of the three DARTs has TTBR/TCR protection (bit 0)
set before claiming an exclusive, singleton IOMMU group and an unmanaged domain
covering the three SID-0 DART instances. Private surfaces currently require
a DMA-coherent client; noncoherent clients refuse pool allocation before RUN. No
unexported architecture cache helper is called from the module. It checks
Expand Down Expand Up @@ -822,8 +824,9 @@ The ``ane-h16-boot`` KUnit suite uses a simulated engine, scratch cells,
mailbox polling and rings. It covers startup including allocation service,
missing READY, wrong/stale table publication, oversized IPC/heap requests,
channel bounds, locked DAPF differences, nonzero acks, scratch-3 timeout,
zero tick, default refusal and quarantine after RUN. It also covers matching
locked DAPF, heap/shared overlap, native FREE, foreign FREE and control refusal.
zero tick, default refusal and quarantine after RUN. It also covers DART
protection refusal, matching locked DAPF, heap/shared overlap, native FREE,
foreign FREE and control refusal.

H16 program stage
-----------------
Expand Down
6 changes: 6 additions & 0 deletions drivers/accel/ane/ane_h16_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,10 @@ static int ane_h16_map(void *ctx)
unsigned int count = 0, i;
int ret;

/* Unmanaged domains can otherwise attach retained, firmware-owned roots. */
ret = ane_h16_dart_protection(b, true);
if (ret)
return ret;
if (of_count_phandle_with_args(h->dev->of_node, "iommus", "#iommu-cells") != 3) {
dev_err(h->dev, "H16 map requires only SID 0 on three DARTs; refusing extra streams\n");
return -EOPNOTSUPP;
Expand Down Expand Up @@ -1527,6 +1531,8 @@ static void ane_h16_release(struct ane_h16_device *h)
dev_pm_domain_detach(pd, true);
}
h->acquired = false;
vfree(h->pristine_data);
h->pristine_data = NULL;
dev_info(h->dev, "H16 pre-RUN rollback complete; no CPU release\n");
}

Expand Down
22 changes: 22 additions & 0 deletions drivers/accel/ane/ane_h16_boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,25 @@ static inline int ane_h16_select_mmio(struct ane_h16_boot *b)
return -ENODEV;
}

/* TTBR/TCR protection is bit 0, separate from the DAPF lock at +0x208. */
static inline int ane_h16_dart_protection(struct ane_h16_boot *b, bool require_unlocked)
{
unsigned int i;
u32 protected = 0;

if (!b->mmio)
return -ENODEV;
for (i = 0; i < 3; i++) {
u32 value = b->ops->read32(b->ctx, ANE_H16_DART0 + i,
b->mmio->dart_protect);

b->ops->log(b->ctx, require_unlocked ? "DART map protect" :
"DART preflight protect", i, value);
protected |= value & BIT(0);
}
return require_unlocked && protected ? -EPERM : 0;
}

static inline int ane_h16_preflight(struct ane_h16_boot *b)
{
const struct ane_h16_build *f = b->build;
Expand All @@ -300,6 +319,9 @@ static inline int ane_h16_preflight(struct ane_h16_boot *b)
if (control || rvbar != f->expected_rvbar)
return -EBUSY;
ret = ane_h16_select_mmio(b);
if (ret)
return ret;
ret = ane_h16_dart_protection(b, false);
if (ret)
return ret;
ret = ane_h16_faults(b, true);
Expand Down
19 changes: 19 additions & 0 deletions drivers/accel/ane/ane_h16_boot_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,32 @@ static const struct ane_h16_profile ane_t8132_profiles[] __maybe_unused = {
},
};

/* 27.2 (26B123) preload on T6041 (J616c): 26A428 DATA layout and zeroed range. */
static const struct ane_h16_preload_rule ane_h16_preload_26b123 = {
.cells = ane_h16_patchbay_26a428,
.cell_count = ARRAY_SIZE(ane_h16_patchbay_26a428),
.zero_start = 0x17c80,
.zero_end = 0x18320,
.digest = {
0xd1, 0xbd, 0xb9, 0xd0, 0x4d, 0x6e, 0x35, 0xa7,
0x31, 0x71, 0xc2, 0xa8, 0xa9, 0x66, 0x38, 0xfe,
0xc2, 0x6c, 0x4c, 0xed, 0x7a, 0x0e, 0xfd, 0xc4,
0xb9, 0xde, 0x58, 0x5f, 0x70, 0x92, 0x33, 0x16,
},
};

/* Every supported H16 firmware build, matched against the live preload. */
static const struct ane_h16_profile ane_h16_profiles[] __maybe_unused = {
{
.identity = "H16 27.0 26A428",
.preload = &ane_h16_preload_26a428,
.build = &ane_h16_build_26a428,
},
{
.identity = "H16 27.2 26B123",
.preload = &ane_h16_preload_26b123,
.build = &ane_h16_build_26a428,
},
{
.identity = "H16 26.6.2 25G83",
.preload = &ane_h16_preload_25g83,
Expand Down
37 changes: 35 additions & 2 deletions drivers/accel/ane/ane_h16_boot_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ struct ane_h16_sim {
u32 timeout_scratch;
u64 timeout_head;
u32 lock;
u32 protect[3];
u32 protect_reads;
u32 fault;
u32 fault_address_reads;
u32 channel_request;
Expand Down Expand Up @@ -89,8 +91,10 @@ static void sim_check_dart(struct ane_h16_sim *s, enum ane_h16_window w, u32 off
KUNIT_ASSERT_NOT_NULL(s->test, m);
if (off == m->dart_fault || off == m->dart_address_lo || off == m->dart_address_hi)
return;
if (off == m->dart_protect)
return;
KUNIT_EXPECT_EQ(s->test, w, ANE_H16_DART0 + s->soc.dapf_dart);
KUNIT_EXPECT_TRUE(s->test, off == m->dart_protect || off == m->dart_lock);
KUNIT_EXPECT_EQ(s->test, off, m->dart_lock);
}

static void sim_check_dapf(struct ane_h16_sim *s, u32 off, u32 width)
Expand All @@ -114,7 +118,11 @@ static u32 sim_read32(void *ctx, enum ane_h16_window w, u32 off)
sim_check_dart(s, w, off);
if (off == s->soc.dart_params)
return s->dart_params;
if (off == s->mmio.dart_protect || off == s->mmio.dart_lock)
if (off == s->mmio.dart_protect) {
s->protect_reads |= BIT(w - ANE_H16_DART0);
return s->protect[w - ANE_H16_DART0];
}
if (off == s->mmio.dart_lock)
return s->lock;
if (off == s->mmio.dart_fault)
return s->fault;
Expand Down Expand Up @@ -1128,6 +1136,29 @@ static void ane_h16_map_failure_test(struct kunit *test)
KUNIT_EXPECT_EQ(test, s->pins, 0U);
}

/* Every DART is observed; only bit 0 prevents fresh translation ownership. */
static void ane_h16_dart_protection_test(struct kunit *test)
{
struct ane_h16_sim *s = test->priv;
unsigned int i;

KUNIT_EXPECT_EQ(test, ane_h16_dart_protection(&s->boot, true), -ENODEV);
KUNIT_EXPECT_EQ(test, s->protect_reads, 0U);
KUNIT_ASSERT_EQ(test, ane_h16_select_mmio(&s->boot), 0);
for (i = 0; i < 3; i++) {
s->protect[i] = BIT(0);
s->protect_reads = 0;
KUNIT_EXPECT_EQ(test, ane_h16_dart_protection(&s->boot, true), -EPERM);
KUNIT_EXPECT_EQ(test, s->protect_reads, 7U);
KUNIT_EXPECT_EQ(test, ane_h16_dart_protection(&s->boot, false), 0);
s->protect[i] = BIT(1) | BIT(2);
}
KUNIT_EXPECT_EQ(test, ane_h16_dart_protection(&s->boot, true), 0);
KUNIT_EXPECT_EQ(test, s->dapf_writes, 0U);
KUNIT_EXPECT_EQ(test, s->maps, 0U);
KUNIT_EXPECT_EQ(test, s->scratch_writes, 0U);
}

static void ane_h16_locked_matching_test(struct kunit *test)
{
struct ane_h16_sim *s = test->priv;
Expand All @@ -1146,6 +1177,7 @@ static void ane_h16_dapf_program_test(struct kunit *test)
unsigned int i;

KUNIT_ASSERT_EQ(test, ane_h16_run(&s->boot, ANE_H16_PREFLIGHT), 0);
KUNIT_EXPECT_EQ(test, s->protect_reads, 7U);
KUNIT_EXPECT_EQ(test, s->dapf_writes, 0U);
KUNIT_ASSERT_EQ(test, ane_h16_run(&s->boot, ANE_H16_MAP), 0);
KUNIT_EXPECT_EQ(test, s->dapf_writes, 20U);
Expand Down Expand Up @@ -1319,6 +1351,7 @@ static void ane_h16_t8132_locked_test(struct kunit *test)
static struct kunit_case ane_h16_boot_cases[] = {
KUNIT_CASE(ane_h16_alloc_reuse_test),
KUNIT_CASE(ane_h16_happy_test),
KUNIT_CASE(ane_h16_dart_protection_test),
KUNIT_CASE(ane_h16_locked_matching_test),
KUNIT_CASE(ane_h16_dapf_program_test),
KUNIT_CASE(ane_h16_dapf_partial_test),
Expand Down
19 changes: 19 additions & 0 deletions drivers/accel/ane/ane_h16_preload_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,26 @@ static void preload_profiles_test(struct kunit *test)
}
}

static void preload_26b123_ce_script_test(struct kunit *test)
{
struct preload_fixture *f = test->priv;
u8 baseline[SHA256_DIGEST_SIZE], digest[SHA256_DIGEST_SIZE];
static const u32 positions[] = { 0xb9040, 0xba094, 0xbd03f };
unsigned int i;

f->rule = ane_h16_preload_26b123;
KUNIT_ASSERT_EQ(test, preload_digest(f, baseline), 0);
/* The entire live CE script stays in the identity, including its padding. */
for (i = 0; i < ARRAY_SIZE(positions); i++) {
f->text[positions[i]] ^= 1;
KUNIT_ASSERT_EQ(test, preload_digest(f, digest), 0);
KUNIT_EXPECT_NE(test, memcmp(digest, baseline, sizeof(digest)), 0);
f->text[positions[i]] ^= 1;
}
}

static struct kunit_case preload_cases[] = {
KUNIT_CASE(preload_26b123_ce_script_test),
KUNIT_CASE(preload_identity_test),
KUNIT_CASE(preload_mutable_test),
KUNIT_CASE(preload_framing_test),
Expand Down
30 changes: 21 additions & 9 deletions drivers/gpu/drm/apple/dcp-fabric.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,16 +544,22 @@ static int dcp_dpxbar_tunnel_select_source(struct mux_control *mux, int state)
return ret;
}

static bool dcp_t6041_ext_v27(const struct apple_dcp *dcp)
{
return dcp->fw_compat == DCP_FIRMWARE_V_27_0 && dcp->desktop_external;
}

/*
* Desktop 26.x firmware does not power the DP PHY of a Type-C route itself:
* the route does, once its crossbar points at the pipeline, and gives it
* back before the crossbar is released.
* Desktop 26.x and T6041 firmware-27 external processors do not power the DP
* PHY of a Type-C route themselves: the route does, once its crossbar points at
* the pipeline, and gives it back before the crossbar is released.
*/
static int dcp_typec_route_phy_on(struct apple_dcp_typec_route *route)
{
int ret;

if (route->dcp->fw_compat != DCP_FIRMWARE_V_26_6_DESKTOP ||
if ((route->dcp->fw_compat != DCP_FIRMWARE_V_26_6_DESKTOP &&
!dcp_t6041_ext_v27(route->dcp)) ||
route->phy_powered)
return 0;
ret = phy_init(route->phy);
Expand Down Expand Up @@ -597,7 +603,8 @@ int dcp_typec_phy_on(struct apple_dcp *dcp)
*/
if (route->tunnel)
return 0;
if (dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP &&
if ((dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP ||
dcp_t6041_ext_v27(dcp)) &&
route->deactivate_xbar_done)
return -ENODEV;
return dcp_typec_route_phy_on(route);
Expand Down Expand Up @@ -925,7 +932,8 @@ static int dcp_typec_route_deactivate(struct apple_dcp_typec_route *route)
* attached. Desktop 26.x powers the PHY with the route, so an
* idle pipeline must not point at one.
*/
dcp->phy = dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP ?
dcp->phy = (dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP ||
dcp_t6041_ext_v27(dcp)) ?
NULL : dcp->typec_routes[0].phy;
if (dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP)
WRITE_ONCE(dcp->xbar, NULL);
Expand Down Expand Up @@ -2016,6 +2024,7 @@ static int dcp_typec_route_apply(struct typec_mux_dev *mux,
* when HPD returns.
*/
if (dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP ||
dcp_t6041_ext_v27(dcp) ||
dcp_t8142_ext(dcp)) {
port->preferred_route = port->owner;
port->hpd = false;
Expand Down Expand Up @@ -2142,6 +2151,7 @@ static int dcp_typec_route_apply(struct typec_mux_dev *mux,
*/
if (!port->owner && !hpd &&
(route->dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP ||
dcp_t6041_ext_v27(route->dcp) ||
dcp_t8142_ext(route->dcp))) {
port->applied_valid = true;
return 0;
Expand Down Expand Up @@ -2613,13 +2623,15 @@ int dcp_direct_crossbar_link(struct apple_dcp *dcp, bool up)
struct mux_control *xbar = NULL;
int ret;

if (dcp->fw_compat == DCP_FIRMWARE_V_27_0)
if (dcp->fw_compat == DCP_FIRMWARE_V_27_0 && !dcp_t6041_ext_v27(dcp))
return dcp_direct_crossbar_link_t6050(dcp, up);
/*
* On T6030, a T8132 dcpext and the selected native26 pipeline,
* selecting a crossbar output only routes it; link-up enables clocks.
* On T6030, a T6041 firmware-27 dcpext, a T8132 dcpext and the selected
* native26 pipeline, selecting a crossbar output only routes it;
* link-up enables clocks.
*/
if (!of_machine_is_compatible("apple,t6030") &&
!dcp_t6041_ext_v27(dcp) &&
!dcp_is_t8132_ext(dcp) && !dcp_is_ext26(dcp))
return 0;
guard(mutex)(&dcp->tb_lock);
Expand Down
Loading
Loading