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
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
85 changes: 77 additions & 8 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/module.h>
#include <linux/mux/driver.h>
#include <linux/soc/apple/dart.h>
#include <linux/soc/apple/display.h>
#include <linux/soc/apple/dp-tunnel.h>
#include <linux/moduleparam.h>
#include <linux/of.h>
Expand Down Expand Up @@ -5853,9 +5854,10 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev)
ret = dcp_read_fw_version(dev, "apple,firmware-version", fw_str);

/*
* T6041 (M4 Pro/Max) is driven only with the 26.5.2 and 26.6.2 firmware
* its desktop IOMFB instance was written for: the boot firmware and its
* compatibility version must both be exactly the same one of those.
* T6041 (M4 Pro/Max) uses its desktop IOMFB instance on 26.5.2 and
* 26.6.2 firmware, where boot firmware and compatibility versions must
* match. J616c on 27.2 (26B123) uses the firmware-27 backend on its
* internal and external display processors.
*/
if (of_device_is_compatible(dev->of_node, "apple,t6041-dcp") ||
of_device_is_compatible(dev->of_node, "apple,t6041-dcpext")) {
Expand All @@ -5865,7 +5867,23 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev)
if (ret >= 0 && compat_ret >= 0 && !strcmp(fw_str, compat_str) &&
(!strcmp(fw_str, "26.5.2") || !strcmp(fw_str, "26.6.2")))
return DCP_FIRMWARE_V_26_6_DESKTOP;
dev_err(dev, "T6041 display not started: DCP firmware %s (compat %s) is not 26.5.2 or 26.6.2\n",
if (apple_t6041_j616c_dcp_v27_2(dev->of_node) ||
apple_t6041_j616c_dcpext_v27_2(dev->of_node)) {
if (!iomfb_v27_methods(compat_str)) {
dev_err(dev, "DCP firmware-compat %s has no 27.x method table\n",
compat_str);
return DCP_FIRMWARE_UNKNOWN;
}
missing = iomfb_v27_missing_method(iomfb_v27_methods(compat_str),
&num_missing);
if (missing) {
dev_err(dev, "DCP firmware-compat %s not started: no ID known for %u methods (first: %s)\n",
compat_str, num_missing, missing);
return DCP_FIRMWARE_UNKNOWN;
}
return DCP_FIRMWARE_V_27_0;
}
dev_err(dev, "T6041 display not started: unsupported DCP firmware %s (compat %s)\n",
ret >= 0 ? fw_str : "missing",
compat_ret >= 0 ? compat_str : "missing");
return DCP_FIRMWARE_UNKNOWN;
Expand Down Expand Up @@ -6088,6 +6106,32 @@ static int dcp_firmware_metadata_v27(struct apple_dcp *dcp)
return -EINVAL;

clocks:
/*
* T6041 device trees carry the single 712 MHz disp0 clock unless the
* boot loader publishes the two /arm-io/disp0 provider clocks
* (376 at 712 MHz and 460 at 0 Hz). Expose the same two-entry table
* when apple,clock-ids is absent so getClockFrequency(0/1) matches.
*/
if (!of_property_present(dev->of_node, "apple,clock-ids") &&
of_device_is_compatible(dev->of_node, "apple,t6041-dcp")) {
struct clk *clk = devm_clk_get_optional(dev, NULL);

if (IS_ERR(clk))
return PTR_ERR(clk);
if (!clk)
return 0;
dcp->firmware_clocks = devm_kcalloc(dev, 2,
sizeof(*dcp->firmware_clocks),
GFP_KERNEL);
if (!dcp->firmware_clocks)
return -ENOMEM;
dcp->firmware_clocks[0].clk = clk;
dcp->num_firmware_clocks = 2;
return 0;
}
if (!of_property_present(dev->of_node, "apple,clock-ids") &&
of_device_is_compatible(dev->of_node, "apple,t6041-dcpext"))
return 0;
clocks = of_property_count_u32_elems(dev->of_node, "apple,clock-ids");
if (clocks == -ENODATA &&
of_property_present(dev->of_node, "apple,clock-ids"))
Expand Down Expand Up @@ -6794,10 +6838,13 @@ VISIBLE_IF_KUNIT void dcp_comp_unbind(struct device *dev, struct device *main, v
cancel_work_sync(&dcp->bl_register_wq);
cancel_work_sync(&dcp->bl_update_wq);
}
devm_clk_put(dev, dcp->clk);
if (dcp->clk)
devm_clk_put(dev, dcp->clk);
dcp->clk = NULL;
/* optional and possibly NULL, released with the bind's devres group */
dcp->clk_194 = NULL;
dcp->firmware_clocks = NULL;
dcp->num_firmware_clocks = 0;
}

static const struct component_ops dcp_comp_ops = {
Expand Down Expand Up @@ -6966,7 +7013,9 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev)
fw_compat = dcp_check_firmware_version(dev);
if (fw_compat == DCP_FIRMWARE_UNKNOWN)
return -ENODEV;
if (fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP) {
if (fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP ||
(fw_compat == DCP_FIRMWARE_V_27_0 &&
of_device_is_compatible(dev->of_node, "apple,t6041-dcp"))) {
ret = dcp_validate_t6041_dt(dev);
if (ret)
return ret;
Expand Down Expand Up @@ -7086,6 +7135,24 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev)
if (fw_compat == DCP_FIRMWARE_V_27_0 &&
of_device_is_compatible(dev->of_node, "apple,t8142-dcp"))
dcp->hw.iomfb_method_profile = DCP_IOMFB_METHODS_DEFAULT;
/*
* T6041 internal panel on firmware 27 adopts the running DCP session
* with 41-bit firmware DMA addressing and no DPTX port services,
* matching the H17-generation internal-panel profile.
*/
if (fw_compat == DCP_FIRMWARE_V_27_0 &&
of_device_is_compatible(dev->of_node, "apple,t6041-dcp")) {
dcp->hw.firmware_dma_bits = 41;
dcp->hw.num_dptx_ports = 0;
dcp->hw.adopt_live_session = true;
}
if (fw_compat == DCP_FIRMWARE_V_27_0 &&
of_device_is_compatible(dev->of_node, "apple,t6041-dcpext")) {
dcp->hw.firmware_dma_bits = 41;
dcp->hw.num_dptx_ports = 2;
dcp->hw.adopt_live_session = true;
dcp->hw.sink_metadata_edid = true;
}
/*
* A SoC with derived power words is offered the stop only when asked for, and only on
* firmware 27.0, whose calls are the ones that ran with them.
Expand Down Expand Up @@ -7235,7 +7302,8 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev)
}
dcp->fixed_phy = dcp->phy;

if (fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP) {
if (fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP ||
(fw_compat == DCP_FIRMWARE_V_27_0 && dcp->desktop_external)) {
ret = dcp_desktop_probe_routes(dcp);
if (ret)
return ret;
Expand Down Expand Up @@ -7357,7 +7425,8 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev)
if (IS_ERR(dcp->dp2hdmi_pwren))
return PTR_ERR(dcp->dp2hdmi_pwren);
/* The converter rails must be stable before DCP requests the link. */
if (fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP &&
if ((fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP ||
(fw_compat == DCP_FIRMWARE_V_27_0 && dcp->desktop_external)) &&
(dcp->hdmi_pwren || dcp->dp2hdmi_pwren))
msleep(100);

Expand Down
24 changes: 21 additions & 3 deletions drivers/gpu/drm/asahi/fwid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ mod tests {
else {
panic!("T6041 must identify its loaded firmware");
};
assert_eq!(builds.len(), 3);
// The last two admit the 25G83 images, with the 40- and the 32-core configuration.
assert_eq!(builds.len(), 4);
// Builds 1 and 2 admit the 25G83 images, with the 40- and the 32-core configuration.
assert_eq!(builds[1].images.len(), builds[2].images.len());
for (a, b) in builds[1].images.iter().zip(builds[2].images) {
assert_eq!((a.entropy, a.text_sha256), (b.entropy, b.text_sha256));
Expand All @@ -489,11 +489,29 @@ mod tests {
let found = measured(build.images, image.data_size, entropy, digest);
assert!(core::ptr::eq(found.unwrap(), image));
assert!(measured(other.images, image.data_size, entropy, digest).is_none());
assert!(measured(builds[3].images, image.data_size, entropy, digest).is_none());
assert!(measured(build.images, 0x13c000, entropy, digest).is_none());
}
}
// Only the 25G83 build runs its own configuration: the 25G83 register map, 40 cores.
for image in builds[3].images {
let digest = image.text_sha256;
let found = lookup(builds[3].images, image.text_size, image.data_size, |_| {
Some(digest)
});
assert!(core::ptr::eq(found.unwrap(), image));
assert!(
lookup(builds[0].images, image.text_size, image.data_size, |_| Some(digest))
.is_none()
);
assert!(
lookup(builds[1].images, image.text_size, image.data_size, |_| Some(digest))
.is_none()
);
assert!(lookup(builds[3].images, 0x60000, image.data_size, |_| Some(digest)).is_none());
}
// Only the 25G83 builds run their own configurations; 25F84 and 26B123 use BASE.
assert!(builds[0].config.is_none());
assert!(builds[3].config.is_none());
let g83 = builds[1].config.unwrap();
let map = &crate::hw::t6041::REGISTER_WINDOWS_25G83;
assert_eq!(g83.windows.len(), map.len());
Expand Down
24 changes: 22 additions & 2 deletions drivers/gpu/drm/asahi/g17/fw/channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ pub(crate) enum DeviceControlOp {
IdlePowerOff = 0x0a,
/// Release a logical queue's scheduler state ([`SchedulerStateRelease`]).
SchedulerStateRelease = 0x14,
/// M5 encoding of the same scheduler-state release.
/// M5 and 26B123 encoding of the same scheduler-state release.
M5SchedulerStateRelease = 0x13,
/// Release a free list's buffer slot ([`FreeListRelease`]).
FreeListRelease = 0x2e,
Expand All @@ -363,7 +363,7 @@ impl DeviceControlOp {
/// records it has drained and keeps the GPU cores powered while they
/// differ.
pub(crate) const fn asserts_gpu_power(self) -> bool {
!matches!(self, Self::FreeListRelease)
!matches!(self, Self::FreeListRelease | Self::M5SchedulerStateRelease)
}
}

Expand Down Expand Up @@ -675,6 +675,26 @@ mod tests {
assert!(bytes[24..].iter().all(|byte| *byte == 0));
}

#[test]
fn scheduler_state_release_opcodes_and_power() {
let legacy = ControlRecord::SchedulerStateRelease(SchedulerStateRelease::new(
0x70_0420_0000,
*b"Q001",
));
assert_eq!(legacy.opcode(), DeviceControlOp::SchedulerStateRelease);
assert!(legacy.opcode().asserts_gpu_power());

let mut rel27 = SchedulerStateRelease::new(0x70_0420_0000, *b"Q001");
rel27.opcode = DeviceControlOp::M5SchedulerStateRelease as u32;
let record27 = ControlRecord::SchedulerStateRelease(rel27);
assert_eq!(record27.opcode(), DeviceControlOp::M5SchedulerStateRelease);
assert!(!record27.opcode().asserts_gpu_power());
assert_eq!(
u32::from_le_bytes(record27.bytes()[..4].try_into().unwrap()),
0x13
);
}

#[test]
fn an_unrecognized_type_7_layout_stays_unknown() {
assert_eq!(record(&[7, 1, 2, 128, 0x300]).decode(), Ok(Event::Unknown(7)));
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/asahi/g17/fw/initdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use kernel::prelude::*;
use super::clear;

pub(crate) mod v25g83;
pub(crate) mod v26b123;

/// Interface version at root `+0x00`; the firmware rejects any other.
pub(crate) const INTERFACE_VERSION: [u16; 4] = [0x04c0, 0x0396, 0xa322, 0x0c8a];
Expand Down
Loading