Skip to content
Open
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
12 changes: 11 additions & 1 deletion arch/arm64/boot/dts/apple/t8122-j504.dts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@
&dcp {
panel: panel {
compatible = "apple,panel-j504", "apple,panel-mini-led", "apple,panel";
/*
* The J514S panel: 3024x1964 at 254 ppi; 189 mm high without the
* 74 notch rows. The J504 boot framebuffer is 3024x1890 below them.
*/
width-mm = <302>;
height-mm = <196>;
adj-height-mm = <189>;
apple,max-brightness = <600>;
apple,max-brightness = <500>;
};
};

/* The boot framebuffer is the same panel, as on the J613 (HiDPI scale for simpledrm). */
&framebuffer0 {
panel = <&panel>;
post-init-providers = <&panel>;
};

&wifi0 {
brcm,board-type = "apple,tresco";
};
Expand Down
29 changes: 28 additions & 1 deletion drivers/gpu/drm/apple/iomfb_v14_7.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,31 @@ static const struct dcp_v14_board dcp_v14_board_j615 = {
.ctm_get = A(420),
};

/*
* J504 (MacBook Pro 14", M3): the J613 DCP image on the same T8122 DCP (the
* J504 ADT names it), driving the 14" mini-LED panel of the J514S: 3024x1964
* with 74 notch rows above the 3024x1890 boot framebuffer, at 60 or 120 Hz.
* The colour matrix methods are this image's, and so is the panel level
* block the J613 qualified (brightness in nits, 500 at most here). Its swaps
* keep zero timestamps as on the Airs. Every panel timing and the
* display clock are logged for the first boots.
*/
static const struct dcp_v14_board dcp_v14_board_j504 = {
.name = "J504",
.debugfs = "dcp-j504",
.dcp_compatible = "apple,t8122-dcp",
.machine = "apple,j504",
.firmware_uuid = DCP_V14_J613_FIRMWARE_UUID,
.handoff = "apple,t8122-handoff",
.panel_width = 3024,
.panel_height = 1964,
.promotion = true,
.log_bringup = true,
.panel_nits = true,
.ctm_set = A(421),
.ctm_get = A(420),
};

/*
* J516C (MacBook Pro 16", M3 Max): the J516S panel, 3456x2234 with 74 notch
* rows above the 3456x2160 boot framebuffer, at 60 or 120 Hz, on the T6031
Expand Down Expand Up @@ -193,6 +218,7 @@ static const struct dcp_v14_board *const dcp_v14_boards[] = {
&dcp_v14_board_t6030,
&dcp_v14_board_j613,
&dcp_v14_board_j615,
&dcp_v14_board_j504,
&dcp_v14_board_j516c,
&dcp_v14_board_j514c,
};
Expand Down Expand Up @@ -1694,7 +1720,8 @@ static bool dcp_v14_panel_nits_admit(const struct dcp_v14_board *board,
{
return board && board->panel_nits &&
(machine_is(ctx, "apple,j514s") || machine_is(ctx, "apple,j516s") ||
machine_is(ctx, "apple,j516c") || machine_is(ctx, "apple,j613"));
machine_is(ctx, "apple,j516c") || machine_is(ctx, "apple,j613") ||
machine_is(ctx, "apple,j504"));
}

const char *iomfb_v14_7_board_name(const struct dcp_v14_board *board)
Expand Down
8 changes: 7 additions & 1 deletion drivers/gpu/drm/apple/iomfb_v14_7_backlight_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,14 @@ static bool v14_bl_ctx_machine_is(const void *ctx, const char *compat)
return !strcmp(((const char *const *)ctx)[1], compat);
}

/* Only admitted T6030, J516C and J613 internal panels carry levels. */
/* Only admitted T6030, J516C, J613 and J504 internal panels carry levels. */
static void v14_bl_boards(struct kunit *test)
{
static const char *const t6030_j516s[] = { "apple,t6030-dcp", "apple,j516s" };
static const char *const t6030_j514s[] = { "apple,t6030-dcp", "apple,j514s" };
static const char *const j613[] = { "apple,t8122-dcp", "apple,j613" };
static const char *const j615[] = { "apple,t8122-dcp", "apple,j615" };
static const char *const j504[] = { "apple,t8122-dcp", "apple,j504" };
static const char *const j516c[] = { "apple,t6031-dcp", "apple,j516c" };
static const char *const other_t6030[] = { "apple,t6030-dcp", "apple,other" };
const struct dcp_v14_board *board;
Expand Down Expand Up @@ -156,6 +157,11 @@ static void v14_bl_boards(struct kunit *test)
board = dcp_v14_board_select(v14_bl_ctx_dcp_is, v14_bl_ctx_machine_is, j615, &known);
KUNIT_ASSERT_NOT_NULL(test, board);
KUNIT_EXPECT_FALSE(test, board->panel_nits);
board = dcp_v14_board_select(v14_bl_ctx_dcp_is, v14_bl_ctx_machine_is, j504, &known);
KUNIT_ASSERT_NOT_NULL(test, board);
KUNIT_EXPECT_TRUE(test, board->panel_nits);
KUNIT_EXPECT_TRUE(test, dcp_v14_panel_nits_admit(board, v14_bl_ctx_machine_is, j504));
KUNIT_EXPECT_FALSE(test, dcp_v14_panel_nits_admit(board, v14_bl_ctx_machine_is, j615));
board = dcp_v14_board_select(v14_bl_ctx_dcp_is, v14_bl_ctx_machine_is, j516c, &known);
KUNIT_ASSERT_NOT_NULL(test, board);
KUNIT_EXPECT_TRUE(test, board->panel_nits);
Expand Down
41 changes: 41 additions & 0 deletions drivers/gpu/drm/apple/v14-board-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ static const char *const j514c[] = { "apple,j514c", "apple,t6031", "apple,arm-pl
static const char *const j516m[] = { "apple,j516m", "apple,t6034", "apple,arm-platform", NULL };
static const char *const j516s[] = { "apple,j516s", "apple,t6030", "apple,arm-platform", NULL };
static const char *const j613[] = { "apple,j613", "apple,t8122", "apple,arm-platform", NULL };
static const char *const j504[] = { "apple,j504", "apple,t8122", "apple,arm-platform", NULL };
static const char *const j433[] = { "apple,j433", "apple,t8122", "apple,arm-platform", NULL };

static void v14_board_j516c(struct kunit *test)
{
Expand Down Expand Up @@ -247,7 +249,46 @@ static void v14_swap_timestamps_encoding(struct kunit *test)
}
}

/*
* J504 (14" M3 MacBook Pro): the J613 image on the T8122 DCP, its own 3024x1964
* ProMotion panel, the qualified level block (brightness) and unstamped swaps. The other T8122
* Macs (J433, J434) have no record.
*/
static void v14_board_j504(struct kunit *test)
{
const struct dcp_v14_board *b, *air;
bool known;

b = board_for("apple,t8122-dcp", j504, &known);
KUNIT_ASSERT_NOT_NULL(test, b);
air = board_for("apple,t8122-dcp", j613, &known);
KUNIT_ASSERT_NOT_NULL(test, air);
KUNIT_EXPECT_PTR_NE(test, b, air);
KUNIT_EXPECT_STREQ(test, b->name, "J504");
KUNIT_EXPECT_STREQ(test, b->machine, "apple,j504");
KUNIT_EXPECT_STREQ(test, b->handoff, "apple,t8122-handoff");
KUNIT_EXPECT_STREQ(test, b->firmware_uuid, J613_DCP_IMAGE);
KUNIT_EXPECT_EQ(test, b->panel_width, 3024);
KUNIT_EXPECT_EQ(test, b->panel_height, 1964);
KUNIT_EXPECT_TRUE(test, b->promotion);
KUNIT_EXPECT_TRUE(test, b->log_bringup);
KUNIT_EXPECT_TRUE(test, b->panel_nits);
KUNIT_EXPECT_FALSE(test, b->base_edid);
KUNIT_EXPECT_EQ(test, b->ctm_set, air->ctm_set);
KUNIT_EXPECT_EQ(test, b->ctm_get, air->ctm_get);
KUNIT_EXPECT_TRUE(test, dcp_v14_board_admits(b, J613_DCP_IMAGE));
KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, T6030_DCP_IMAGE));
KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, J516C_DCP_IMAGE));
KUNIT_EXPECT_FALSE(test, dcp_v14_board_stamps_swaps(b, false));

KUNIT_EXPECT_NULL(test, board_for("apple,t8122-dcp", j433, &known));
KUNIT_EXPECT_TRUE(test, known);
/* A J504 root with another SoC's DCP gets no J504 record. */
KUNIT_EXPECT_NULL(test, board_for("apple,t6031-dcp", j504, &known));
}

static struct kunit_case v14_board_cases[] = {
KUNIT_CASE(v14_board_j504),
KUNIT_CASE(v14_board_j516c),
KUNIT_CASE(v14_board_j514c),
KUNIT_CASE(v14_board_t6031_other_boards),
Expand Down
15 changes: 13 additions & 2 deletions drivers/gpu/drm/asahi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,21 @@ config DRM_ASAHI_DEBUG_ALLOCATOR
Say N unless you are debugging firmware structures or porting to a
new firmware version.

config DRM_ASAHI_UAT_ADOPTION
bool
help
The firmware UAT handoff adoption shared by the G15 backend and the
T8122 runtime (g15/uat.rs, g15/regs.rs).

config DRM_ASAHI_M3_T8122
bool "M3 MacBook Air GPU runtime (T8122, 14.8.3 firmware)"
depends on DRM_ASAHI
# The runtime adopts the firmware's UAT through the G15 backend's handoff helpers.
depends on DRM_ASAHI_G15
# The runtime adopts the firmware's UAT as the G15 backend does, without
# needing that backend: M3 Pro/Max keep their own setting.
# Its PMP votes call apple-pmp directly (m3_device.rs).
depends on APPLE_PMP=y || (APPLE_PMP=m && DRM_ASAHI=m)
select DRM_ASAHI_UAT_ADOPTION
select APPLE_T8122_GPU_PMP_LINK
select CRYPTO_LIB_SHA256
default n
help
Expand All @@ -101,6 +111,7 @@ config DRM_ASAHI_G15
depends on DRM_APPLE=y || (DRM_APPLE=m && DRM_ASAHI=m)
select APPLE_T6030_GPU_PMP_LINK
select CRYPTO_LIB_SHA256
select DRM_ASAHI_UAT_ADOPTION
default y
help
Backend for the M3 Pro (T6030) and M3 Max (T6031) GPUs on the
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/asahi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ aurora-y := asahi_core.o fwid.o legacy_sched.o sysfs.o g17/sync_input.o g17/sync
CFLAGS_g17/trace.o := -I$(src)/g17

aurora-$(CONFIG_DRM_ASAHI_G15) += g15/glue.o
aurora-$(CONFIG_DRM_ASAHI_UAT_ADOPTION) += g15/uat_glue.o

aurora-$(CONFIG_DRM_ASAHI_G16) += g16/glue.o

Expand Down
4 changes: 4 additions & 0 deletions drivers/gpu/drm/asahi/asahi_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ mod fw;
mod fwid;
#[cfg(CONFIG_DRM_ASAHI_G15)]
mod g15;
// Without the G15 backend, only the UAT adoption the T8122 runtime shares with it.
#[cfg(all(CONFIG_DRM_ASAHI_UAT_ADOPTION, not(CONFIG_DRM_ASAHI_G15)))]
#[path = "g15/adopt.rs"]
mod g15;
mod g17;
mod gem;

Expand Down
32 changes: 32 additions & 0 deletions drivers/gpu/drm/asahi/g15/adopt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-2.0-only OR MIT

//! Without the G15 backend (`CONFIG_DRM_ASAHI_G15=n`), the parts of it the T8122 runtime uses to
//! adopt the firmware's UAT: the handoff window ([`uat`]), its mappings ([`regs`]) and the
//! hardware constants they name ([`hw`]). Nothing here probes a device.

// Only the adoption is used; the rest of these files serves the G15 backend.
#![allow(dead_code)]

// hw.rs's `t6031` submodule is cfg-gated on G15; were it built here, a #[path]-loaded file
// would look for it at g15/t6031.rs, not g15/hw/t6031.rs.
#[path = "hw.rs"]
pub(crate) mod hw;
#[path = "regs.rs"]
pub(crate) mod regs;
#[path = "uat.rs"]
pub(crate) mod uat;

use kernel::prelude::*;

extern "C" {
fn asahi_g15_memory_mode(start: u64, size: u64) -> u32;
}

/// WB for complete reserved RAM, WC for aligned non-RAM carveouts; reject everything else.
pub(crate) fn memory_mode(start: u64, size: u64) -> Result<u32> {
// SAFETY: Only queries resources and page metadata; it does not create a mapping.
match unsafe { asahi_g15_memory_mode(start, size) } {
0 => Err(EINVAL),
mode => Ok(mode),
}
}
46 changes: 0 additions & 46 deletions drivers/gpu/drm/asahi/g15/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ void asahi_g15_release_power(struct device *dev);
void asahi_g15_reprobe(void);
void asahi_g15_report_loader_gpu(void);
int asahi_g15_adt_phram(u64 *start, u64 *size);
bool asahi_g15_ram_disjoint(u64 start, u64 size);
bool asahi_g15_ram_within(u64 start, u64 size);
unsigned int asahi_g15_memory_mode(u64 start, u64 size);
void __iomem *asahi_g15_ioremap_wc(u64 start, size_t size);
bool asahi_g15_dma_coherent(struct device *dev);
int asahi_g15_pmp_prepare(struct device *dev);
Expand Down Expand Up @@ -275,13 +272,6 @@ int asahi_g15_adt_phram(u64 *start, u64 *size)
return 0;
}

/* The range is disjoint from System RAM (ADT region admission). */
bool asahi_g15_ram_disjoint(u64 start, u64 size)
{
return region_intersects(start, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) ==
REGION_DISJOINT;
}

/*
* Whether DMA mappings of the device skip cache maintenance. The G15 firmware
* objects rely on the DMA mapping cleaning their pages to the point of
Expand All @@ -292,42 +282,6 @@ bool asahi_g15_dma_coherent(struct device *dev)
return dev_is_dma_coherent(dev);
}

/*
* Every page must be valid, System RAM and still reserved from the allocator.
* REGION_INTERSECTS alone also accepts RAM mixed with undefined memory holes.
*/
bool asahi_g15_ram_within(u64 start, u64 size)
{
u64 end, pa;

if (!size || !IS_ALIGNED(start, PAGE_SIZE) ||
!IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end))
return false;
for (pa = start; pa < end; pa += PAGE_SIZE) {
unsigned long pfn = PHYS_PFN(pa);

if (!pfn_valid(pfn) || !page_is_ram(pfn) ||
!PageReserved(pfn_to_page(pfn)))
return false;
}
return true;
}

/* One classification for every adopted-UAT and firmware-region CPU mapping. */
unsigned int asahi_g15_memory_mode(u64 start, u64 size)
{
u64 end;

if (!size || !IS_ALIGNED(start, PAGE_SIZE) ||
!IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end))
return 0;
if (asahi_g15_ram_within(start, size))
return MEMREMAP_WB;
if (asahi_g15_ram_disjoint(start, size))
return MEMREMAP_WC;
return 0;
}

/* The inherited RTKit buffer inside firmware DATA. */
void __iomem *asahi_g15_ioremap_wc(u64 start, size_t size)
{
Expand Down
65 changes: 65 additions & 0 deletions drivers/gpu/drm/asahi/g15/hw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use core::ops::Range;

#[cfg(CONFIG_DRM_ASAHI_G15)]
pub(crate) mod t6031;

/// Identification register values of a qualified G15S.
Expand Down Expand Up @@ -91,6 +92,7 @@ pub(crate) struct ComputeRegs {
}

/// The T6030 configuration.
#[cfg(CONFIG_DRM_ASAHI_G15)]
pub(crate) mod t6030 {
use super::super::Config;
use super::{ComputeRegs, FirmwareBuild, HwId, Layout};
Expand Down Expand Up @@ -175,6 +177,69 @@ pub(crate) mod t6030 {
0xe7, 0x9b, 0xb9, 0xb0, 0x22, 0x09, 0xdb, 0x53,
],
},
// J514S firmware measured on the 14.7 boot chain; desktop rendering
// was verified with the bring-up prefix override (issue #247).
FirmwareBuild {
name: "J514S cd05 firmware (14.7 boot chain)",
machine: Some(kernel::c_str!("apple,j514s")),
text_size: 0x5c000,
data_size: 0x114000,
marker: 0x58e88,
text_sha256: [
0xcd, 0x05, 0xaf, 0x6a, 0x82, 0x8b, 0x52, 0xe4,
0xc2, 0xfe, 0xd2, 0x00, 0x86, 0xd3, 0xd1, 0x8a,
0x7d, 0xb4, 0x2e, 0x03, 0xa8, 0xfd, 0x6f, 0x83,
0x54, 0xf9, 0xf0, 0x6e, 0x0a, 0x61, 0x36, 0x3e,
],
},
// Some J516S units on the same 14.7 boot chain load a different B0
// TEXT image with identical sizes and marker. Pin its complete
// measured digest for the J516S only.
FirmwareBuild {
name: "J516S cd05 firmware (14.7 boot chain)",
machine: Some(kernel::c_str!("apple,j516s")),
text_size: 0x5c000,
data_size: 0x114000,
marker: 0x58e88,
text_sha256: [
0xcd, 0x05, 0xaf, 0x6a, 0x82, 0x8b, 0x52, 0xe4,
0xc2, 0xfe, 0xd2, 0x00, 0x86, 0xd3, 0xd1, 0x8a,
0x7d, 0xb4, 0x2e, 0x03, 0xa8, 0xfd, 0x6f, 0x83,
0x54, 0xf9, 0xf0, 0x6e, 0x0a, 0x61, 0x36, 0x3e,
],
},
// J514S (14-inch) firmware measured on the 14.7 boot chain with
// system firmware 26.6.2; the GPU reached READY with the bring-up
// prefix override (issue #247).
FirmwareBuild {
name: "J514S 4118 firmware (14.7 boot chain)",
machine: Some(kernel::c_str!("apple,j514s")),
text_size: 0x5c000,
data_size: 0x114000,
marker: 0x58e88,
text_sha256: [
0x41, 0x18, 0x33, 0xa7, 0xde, 0xd7, 0x73, 0xfe,
0xea, 0xc4, 0xa1, 0x81, 0x55, 0x2e, 0x3f, 0xf5,
0x58, 0x2e, 0xaf, 0x44, 0x35, 0xf2, 0xdd, 0x8f,
0x62, 0x0c, 0x1e, 0xd0, 0xb3, 0x1d, 0xf1, 0xb0,
],
},
// J516S (16-inch) firmware measured on the 14.7 boot chain with
// system firmware 26.6.2; the GPU reached READY with the bring-up
// prefix override (issue #247).
FirmwareBuild {
name: "J516S 4118 firmware (14.7 boot chain)",
machine: Some(kernel::c_str!("apple,j516s")),
text_size: 0x5c000,
data_size: 0x114000,
marker: 0x58e88,
text_sha256: [
0x41, 0x18, 0x33, 0xa7, 0xde, 0xd7, 0x73, 0xfe,
0xea, 0xc4, 0xa1, 0x81, 0x55, 0x2e, 0x3f, 0xf5,
0x58, 0x2e, 0xaf, 0x44, 0x35, 0xf2, 0xdd, 0x8f,
0x62, 0x0c, 0x1e, 0xd0, 0xb3, 0x1d, 0xf1, 0xb0,
],
},
],
machine: kernel::c_str!("apple,t6030"),
platform: super::Platform::AdtWithPmp,
Expand Down
Loading
Loading