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
18 changes: 14 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,16 @@ 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];
char peer_tag[4];
int ret;

ret = iomfb_v27_tag(dcp->v27_methods, "A484", method.tag) ?:
iomfb_v27_tag(peer->v27_methods, "A484", peer_tag);
if (ret)
return ret;

wait = kzalloc(sizeof(*wait), GFP_KERNEL);
if (!wait)
return -ENOMEM;
Expand Down Expand Up @@ -134,13 +139,18 @@ 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;
char peer_tag[4];
int ret;

ret = iomfb_v27_tag(dcp->v27_methods, "A413", method.tag) ?:
iomfb_v27_tag(peer->v27_methods, "A413", peer_tag);
if (ret)
return ret;

{
guard(mutex)(&dcp_peer_lock);
if (dcp->peer_reserved != peer || peer->peer_owner != dcp ||
Expand Down
9 changes: 6 additions & 3 deletions drivers/gpu/drm/apple/dcp-peer-probe-v27.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ static ssize_t peer_setup_test_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
static const struct dcp_method_entry method = {
.name = "setup_peer_dcp", .tag = {'A', '3', '6', '6'},
};
struct dcp_method_entry method = { .name = "setup_peer_dcp" };
struct apple_dcp *dcp = dev_get_drvdata(dev);
struct dcp_peer_probe_wait *wait;
__le32 enabled = cpu_to_le32(1);
Expand Down Expand Up @@ -55,6 +53,11 @@ static ssize_t peer_setup_test_store(struct device *dev,
kref_put(&wait->refs, dcp_peer_probe_free);
return -EBUSY;
}
ret = iomfb_v27_tag(dcp->v27_methods, "A366", method.tag);
if (ret) {
kref_put(&wait->refs, dcp_peer_probe_free);
return ret;
}
kref_get(&wait->refs);
/* Peer-DCP setup (one bool argument): four input
* bytes (boolean followed by zero padding), no output.
Expand Down
14 changes: 12 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 @@ -6,6 +6,7 @@ struct dcp_peer_background {
struct iomfb_transaction transaction;
struct dcp_peer_video_wait *wait;
struct dcp_swap_submit_req_v27 wire;
char tag[4];
bool sent;
};

Expand All @@ -26,10 +27,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 };

memcpy(method.tag, background->tag, sizeof(method.tag));

background->sent = true;
if (!dcp_present_begin_h17p(&dcp->present_state_h17p,
background->wire.swap.swap_id)) {
Expand All @@ -55,13 +57,18 @@ static int dcp_peer_queue_background(struct apple_dcp *dcp,
struct dcp_peer_video_wait *wait)
{
struct dcp_peer_background *background;
char tag[4];
int ret;

ret = iomfb_v27_tag(dcp->v27_methods, "A408", tag);
if (ret)
return ret;
background = kzalloc_obj(*background);
if (!background)
return -ENOMEM;
background->wire = *wire;
background->wait = wait;
memcpy(background->tag, tag, sizeof(background->tag));
kref_get(&wait->refs);
background->transaction.start = dcp_peer_background_start;
background->transaction.release = dcp_peer_background_release;
Expand Down Expand Up @@ -185,6 +192,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 +353,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
5 changes: 4 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 @@ -37,6 +37,10 @@ static int dcp_peer_video_call_stream(struct apple_dcp *dcp, bool independent,

if (out_size > sizeof(wait->reply))
return -EINVAL;
/* The calls name 27.0 IDs: this engine's build may number them differently. */
ret = iomfb_v27_tag(dcp->v27_methods, tag, method.tag);
if (ret)
return ret;
/* An unrelated AP thread gets its own firmware stream. A369/A367/etc.
* must not be mistaken for nested callbacks of the pending A413.
* Stream1 (the driver's OOB context) is independent of stream0.
Expand All @@ -46,7 +50,6 @@ 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));
wait->size = out_size;
init_completion(&wait->done);
kref_init(&wait->refs);
Expand Down
18 changes: 6 additions & 12 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5926,31 +5926,25 @@ static bool dcp_ext26_admitted(struct device_node *np)
}

/*
* J716c shares the 27.0 endpoint-control wire format, not the J714s normal
* IOMFB method or panel profile. Establish this before RTKit can receive any
* application traffic, including traffic that invalidates a later inventory.
* Firmware 27 (T6050) sleep endpoint-control transport. Establish this before
* RTKit can receive any application traffic, including traffic that invalidates
* a later inventory. Admitted for a T6050 DCP/DCPEXT whose firmware 27 method
* table has an ID for every call the sleep sends.
*/
static bool dcp_v27_sleep_transport_supported(struct apple_dcp *dcp)
{
struct device *dev = dcp->dev;
char compat[DCP_FW_VERSION_STR_LEN];

if (!IS_ENABLED(CONFIG_APPLE_SOC_SLEEP))
return false;
if (dcp->v27_j714s)
return true;
if (!of_machine_is_compatible("apple,j716c") ||
!of_machine_is_compatible("apple,t6050") ||
!(of_device_is_compatible(dev->of_node, "apple,t6050-dcp") ||
if (!(of_device_is_compatible(dev->of_node, "apple,t6050-dcp") ||
of_device_is_compatible(dev->of_node, "apple,t6050-dcpext")) ||
!dcp->hw.adopt_live_session ||
dcp->hw.iomfb_method_profile != DCP_IOMFB_METHODS_DEFAULT ||
dcp->fw_compat != DCP_FIRMWARE_V_27_0)
return false;

/* The enum also covers later 27.x method tables. */
return dcp_read_fw_version(dev, "apple,firmware-compat", compat) >= 0 &&
!strcmp(compat, "27.0.0");
return iomfb_v27_sleep_methods_complete(dcp->v27_methods);
}

/*
Expand Down
30 changes: 21 additions & 9 deletions drivers/gpu/drm/apple/iomfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,18 +899,24 @@ 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];

if (iomfb_v27_tag(dcp->v27_methods, "A442", a442.tag)) {
dev_warn_once(dcp->dev, "skipping v27 wake A442: unmapped method tag\n");
return;
}

memset(in, 0xaa, sizeof(in));
memset(in, 0, 16);
in[8] = rpc->a442_key ?: 0x41;
/* An external processor's wake: no indexes, and the block's size word. */
if (rpc->a442_key) {
memset(in + 80, 0, 12);
in[84] = 0x20;
} else if (iomfb_v27_methods_renumbered(dcp->v27_methods)) {
/* 27.2 reads the filler as an index count and a block size. */
memset(in + 16, 0, sizeof(in) - 16);
}
dcp_push(dcp, true, &a442, sizeof(in), 4100, in, iomfb_v27_a442_done, NULL);
}
Expand Down Expand Up @@ -988,6 +994,9 @@ int iomfb_v27_sleep_plain(struct apple_dcp *dcp, bool on)

static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags)
{
struct dcp_method_entry method = {
.name = a500 ? "v27_sleep_500" : "v27_sleep_power",
};
struct iomfb_v27_sleep_rpc *rpc;
u8 args[IOMFB_V27_SLEEP_ARGS];
int ret;
Expand All @@ -998,6 +1007,9 @@ static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags)
(a500 || flags ? iomfb_v27_sleep_args(dcp, a500, args) :
iomfb_v27_display_args(dcp, false, args)))
return -EOPNOTSUPP;
ret = iomfb_v27_tag(dcp->v27_methods, a500 ? "A500" : "A484", method.tag);
if (ret)
return ret;
rpc = kzalloc_obj(*rpc);
if (!rpc)
return -ENOMEM;
Expand All @@ -1006,10 +1018,7 @@ static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags)
rpc->status = ~0U;
rpc->transaction.start = iomfb_v27_sleep_start;
rpc->transaction.release = iomfb_v27_sleep_release;
rpc->method = (struct dcp_method_entry) {
.name = a500 ? "v27_sleep_500" : "v27_sleep_power",
};
memcpy(rpc->method.tag, a500 ? "A500" : "A484", 4);
rpc->method = method;
/*
* 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 @@ -1081,13 +1090,17 @@ int iomfb_v27_sleep_a115(struct apple_dcp *dcp, bool awake)
static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in,
u32 in_len, u32 out_len, bool inout, u8 a442_key)
{
struct dcp_method_entry method = { .name = "v27_display_stage" };
struct iomfb_v27_sleep_rpc *rpc;
int ret;

if (!IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) ||
dcp->fw_compat != DCP_FIRMWARE_V_27_0 || in_len > sizeof(rpc->data) ||
(inout && out_len > sizeof(rpc->data)))
return -EOPNOTSUPP;
ret = iomfb_v27_tag(dcp->v27_methods, tag, method.tag);
if (ret)
return ret;
rpc = kzalloc_obj(*rpc);
if (!rpc)
return -ENOMEM;
Expand All @@ -1097,8 +1110,7 @@ static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in
rpc->any_reply = true;
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);
rpc->method = method;
rpc->input = in_len;
rpc->output = out_len;
rpc->inout = inout;
Expand Down
25 changes: 25 additions & 0 deletions drivers/gpu/drm/apple/iomfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,28 @@ enum dcpep_method {
dcpep_pipe_set_476,
dcpep_unnamed_500,
iomfbep_set_brightness_correction,
/*
* Firmware 27.x sleep and paired-mode calls named by their 27.0 ID.
* Optional for single-engine boot (iomfb_v27_missing_method() skips
* them); iomfb_v27_tag() refuses any call missing from a renumbered
* table.
*/
dcpep_v27_sleep_a115,
dcpep_v27_wake_a442,
dcpep_v27_peer_a360,
dcpep_v27_peer_a361,
dcpep_v27_peer_a362,
dcpep_v27_peer_a364,
dcpep_v27_peer_a365,
dcpep_v27_peer_a366,
dcpep_v27_peer_a367,
dcpep_v27_peer_a368,
dcpep_v27_peer_a369,
dcpep_v27_peer_a370,
dcpep_v27_peer_a371,
dcpep_v27_peer_a372,
dcpep_v27_peer_a373,
dcpep_v27_peer_a449,
dcpep_num_methods
};

Expand All @@ -220,6 +242,9 @@ 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);
int iomfb_v27_tag(const struct dcp_method_entry *methods, const char *tag, char *out);
bool iomfb_v27_sleep_methods_complete(const struct dcp_method_entry *methods);
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
Loading
Loading