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
10 changes: 6 additions & 4 deletions drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ static int dcp_peer_probe_power(struct apple_dcp *dcp, struct apple_dcp *peer,
bool on)
{
struct dcp_peer_video_wait *wait;
struct dcp_method_entry method = { .name = "peer_power_test",
.tag = {'A', '4', '8', '4'} };
struct dcp_method_entry method = { .name = "peer_power_test" };
u8 power[16] = {}, response[8];
int ret;

iomfb_v27_tag(dcp->v27_methods, "A484", method.tag);

wait = kzalloc(sizeof(*wait), GFP_KERNEL);
if (!wait)
return -ENOMEM;
Expand Down Expand Up @@ -134,13 +135,14 @@ static int dcp_peer_probe_modeset(struct apple_dcp *dcp, struct apple_dcp *peer,
bool firmware_requires_merge)
{
struct dcp_peer_video_wait *wait;
struct dcp_method_entry method = { .name = "peer_modeset_test",
.tag = {'A', '4', '1', '3'} };
struct dcp_method_entry method = { .name = "peer_modeset_test" };
__le32 mode[2] = {video->color_id, video->timing_id};
u32 primary_id, peer_id, phase, status;
unsigned long deadline;
int ret;

iomfb_v27_tag(dcp->v27_methods, "A413", method.tag);

{
guard(mutex)(&dcp_peer_lock);
if (dcp->peer_reserved != peer || peer->peer_owner != dcp ||
Expand Down
8 changes: 6 additions & 2 deletions drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ static void dcp_peer_background_start(struct apple_dcp *dcp,
{
struct dcp_peer_background *background =
container_of(transaction, struct dcp_peer_background, transaction);
struct dcp_method_entry method = { .name = "peer_background_test",
.tag = {'A', '4', '0', '8'} };
struct dcp_method_entry method = { .name = "peer_background_test" };
struct dcp_swap_submit_resp_v27 failed = { .ret = ~0U };

iomfb_v27_tag(dcp->v27_methods, "A408", method.tag);

background->sent = true;
if (!dcp_present_begin_h17p(&dcp->present_state_h17p,
background->wire.swap.swap_id)) {
Expand Down Expand Up @@ -185,6 +186,7 @@ static void dcp_peer_a407_background_start(struct apple_dcp *dcp,
{
struct dcp_peer_a407_background *background =
container_of(transaction, struct dcp_peer_a407_background, transaction);
/* The J714s's 27.0 swap form, whose table names A407 (iomfb_v27_methods_j714s()). */
struct dcp_method_entry method = { .name = "peer_background_test",
.tag = {'A', '4', '0', '7'} };
struct dcp_swap_submit_resp_v27 failed = { .ret = ~0U };
Expand Down Expand Up @@ -345,6 +347,8 @@ static ssize_t peer_swap_test_store(struct device *dev,
dcp->crtc->base.state->active || peer->crtc->base.state->active ||
dcp->fw_compat != DCP_FIRMWARE_V_27_0 ||
peer->fw_compat != DCP_FIRMWARE_V_27_0 ||
/* Both engines must take the swap form the owner sends. */
dcp->v27_a407 != peer->v27_a407 ||
!device_trylock(peer->dev)) {
ret = -EBUSY;
goto out;
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ static int dcp_peer_video_call_stream(struct apple_dcp *dcp, bool independent,
wait = kzalloc(sizeof(*wait), GFP_KERNEL);
if (!wait)
return -ENOMEM;
memcpy(method.tag, tag, sizeof(method.tag));
/* The calls name 27.0 IDs: this engine's build may number them differently. */
iomfb_v27_tag(dcp->v27_methods, tag, method.tag);
wait->size = out_size;
init_completion(&wait->done);
kref_init(&wait->refs);
Expand Down
7 changes: 5 additions & 2 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5797,9 +5797,12 @@ static bool dcp_v27_sleep_transport_supported(struct apple_dcp *dcp)
dcp->fw_compat != DCP_FIRMWARE_V_27_0)
return false;

/* The enum also covers later 27.x method tables. */
/*
* The enum also covers later 27.x method tables. 27.2 keeps the endpoint
* transport; its renumbered IOMFB calls go through iomfb_v27_tag().
*/
return dcp_read_fw_version(dev, "apple,firmware-compat", compat) >= 0 &&
!strcmp(compat, "27.0.0");
(!strcmp(compat, "27.0.0") || !strcmp(compat, "27.2.0"));
}

static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev)
Expand Down
10 changes: 5 additions & 5 deletions drivers/gpu/drm/apple/iomfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,11 +892,11 @@ static void iomfb_v27_sleep_start(struct apple_dcp *dcp,
rpc->data, iomfb_v27_sleep_done, rpc);
dcp->push_out_prefill = NULL;
if ((rpc->a442 || rpc->a442_key) && !rpc->oob) {
static const struct dcp_method_entry a442 = {
.name = "v27_a442", .tag = { 'A', '4', '4', '2' },
};
struct dcp_method_entry a442 = { .name = "v27_a442" };
u8 in[92];

iomfb_v27_tag(dcp->v27_methods, "A442", a442.tag);

memset(in, 0xaa, sizeof(in));
memset(in, 0, 16);
in[8] = rpc->a442_key ?: 0x41;
Expand Down Expand Up @@ -1002,7 +1002,7 @@ static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags)
rpc->method = (struct dcp_method_entry) {
.name = a500 ? "v27_sleep_500" : "v27_sleep_power",
};
memcpy(rpc->method.tag, a500 ? "A500" : "A484", 4);
iomfb_v27_tag(dcp->v27_methods, a500 ? "A500" : "A484", rpc->method.tag);
/*
* Off, before each DCP's and DCPEXT's sleep idle: A484 with the sleep's flags, then
* A500's sleep form. On, after the wake: A500's wake form, then A484 with the flags.
Expand Down Expand Up @@ -1091,7 +1091,7 @@ static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in
rpc->transaction.start = iomfb_v27_sleep_start;
rpc->transaction.release = iomfb_v27_sleep_release;
rpc->method = (struct dcp_method_entry) { .name = "v27_display_stage" };
memcpy(rpc->method.tag, tag, 4);
iomfb_v27_tag(dcp->v27_methods, tag, rpc->method.tag);
rpc->input = in_len;
rpc->output = out_len;
rpc->inout = inout;
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/apple/iomfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ struct dcp_method_entry {

/* The IOMFB method table of a firmware 27.x build, by its compat string; NULL if unknown. */
const struct dcp_method_entry *iomfb_v27_methods(const char *compat);
bool iomfb_v27_methods_renumbered(const struct dcp_method_entry *methods);
void iomfb_v27_tag(const struct dcp_method_entry *methods, const char *tag, char *out);
const struct dcp_method_entry *iomfb_v27_methods_j714s(struct device *dev,
const struct dcp_method_entry *methods);
/* The first method of a firmware 27.x table that has no ID, NULL if none. */
Expand Down
42 changes: 42 additions & 0 deletions drivers/gpu/drm/apple/iomfb_v27.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* Copyright The Asahi Linux Contributors */
/* Copyright 2026 Aurora Silicon */

#include <linux/ctype.h>
#include <linux/unaligned.h>
#include <linux/spinlock.h>

Expand Down Expand Up @@ -269,6 +270,47 @@ const struct dcp_method_entry *iomfb_v27_methods(const char *compat)
return NULL;
}

/*
* @tag, a 27.0 ID the paired-mode calls name directly, in the build of @methods
* (into @out, 4 bytes). A method the tables name takes this build's ID; on 27.2,
* which moved IOMobileFramebufferAP up by 50, another A4xx ID (and A500) does too.
* Anything else keeps its 27.0 ID.
*/
void iomfb_v27_tag(const struct dcp_method_entry *methods, const char *tag, char *out)
{
unsigned int i, id;
char in[4];

memcpy(in, tag, 4);
tag = in;
memcpy(out, tag, 4);
if (!iomfb_v27_methods_renumbered(methods))
return;
for (i = 0; i < dcpep_num_methods; i++) {
if (dcp_methods_27_0[i].tag[0] && !memcmp(dcp_methods_27_0[i].tag, tag, 4) &&
methods[i].tag[0]) {
memcpy(out, methods[i].tag, 4);
return;
}
}
if (methods != dcp_methods_27_2 || tag[0] != 'A' || !isdigit(tag[1]) ||
!isdigit(tag[2]) || !isdigit(tag[3]))
return;
id = (tag[1] - '0') * 100 + (tag[2] - '0') * 10 + (tag[3] - '0');
if (id < 400 || id > 500)
return;
id += 50;
out[1] = '0' + id / 100;
out[2] = '0' + id / 10 % 10;
out[3] = '0' + id % 10;
}

/* Whether @methods is a build's table whose AP method IDs differ from 27.0's. */
bool iomfb_v27_methods_renumbered(const struct dcp_method_entry *methods)
{
return methods && (methods == dcp_methods_27_2 || methods == dcp_methods_27_3);
}

/*
* The 27.0 table for the J714s, the board the firmware 27 sleep has run on (dcp->v27_j714s): a
* copy with the sleep's A500 added. The shared table keeps the methods it had, so every other
Expand Down
Loading