Skip to content
Draft
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
34 changes: 21 additions & 13 deletions drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,13 @@ static void dcp_queue_typec_reconnect_locked(struct apple_dcp *dcp,
return;
dcp->typec_reconnect_session = dcp_session_locked(dcp);
}
/*
* Every request gets the whole budget of attempts: it comes from an
* event (an attach, a power-on, a bind, a port or tunnel coming up,
* the bounded display retry). The work arms its own retries directly,
* so they count against the request that started them.
*/
dcp->typec_reconnect_tries = 0;
mod_delayed_work(system_freezable_wq, &dcp->typec_reconnect_wq, delay);
}

Expand Down Expand Up @@ -2740,7 +2747,6 @@ void dcp_external_ready(struct apple_dcp *dcp)
{
if (READ_ONCE(dcp->typec_cable_connected)) {
guard(mutex)(&dcp->hpd_mutex);
dcp->typec_reconnect_tries = 0;
dcp_queue_typec_reconnect_locked(dcp, 0);
} else if (dcp->hdmi_hpd && dcp->active &&
gpiod_get_value_cansleep(dcp->hdmi_hpd)) {
Expand Down Expand Up @@ -2873,7 +2879,6 @@ void dcp_external_retry_work(struct work_struct *work)
if (ret)
return;
}
dcp->typec_reconnect_tries = 0;
}
guard(mutex)(&dcp->hpd_mutex);
dcp_queue_typec_reconnect_locked(dcp, 0);
Expand Down Expand Up @@ -3473,6 +3478,7 @@ static void dcp_typec_reconnect_work(struct work_struct *work)
container_of(to_delayed_work(work), struct apple_dcp,
typec_reconnect_wq);
struct dcp_fabric_session session;
unsigned int tries, limit;
int ret;

/*
Expand Down Expand Up @@ -3509,25 +3515,27 @@ static void dcp_typec_reconnect_work(struct work_struct *work)
return;
}
}
if (!ret) {
dcp->typec_reconnect_tries = 0;
if (!ret)
return;
}
/* A display held for this link will not get ready. */
if (READ_ONCE(dcp->external_error))
dcp_announce_kick(dcp);

/* A T8132 dcpext connects once per tunnel. */
if (++dcp->typec_reconnect_tries <
(dcp_uses_t6020_tunnel_flow(dcp) || dcp_is_t8132_ext(dcp) ?
1 : DPTX_RECONNECT_RETRIES)) {
mod_delayed_work(system_freezable_wq, &dcp->typec_reconnect_wq,
DPTX_RECONNECT_DELAY);
return;
limit = dcp_uses_t6020_tunnel_flow(dcp) || dcp_is_t8132_ext(dcp) ?
1 : DPTX_RECONNECT_RETRIES;
/* Counted under the lock a new request resets it with. */
scoped_guard(mutex, &dcp->hpd_mutex) {
tries = ++dcp->typec_reconnect_tries;
if (tries < limit) {
mod_delayed_work(system_freezable_wq, &dcp->typec_reconnect_wq,
DPTX_RECONNECT_DELAY);
return;
}
}

dev_err(dcp->dev, "Type-C DPTX reconnect failed after %u retries: %d\n",
dcp->typec_reconnect_tries, ret);
dev_err(dcp->dev, "Type-C DPTX reconnect failed after %u attempts: %d\n",
tries, ret);
}

/**
Expand Down
Loading