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
3 changes: 2 additions & 1 deletion drivers/gpu/drm/apple/afk.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ void afk_shutdown(struct apple_dcp_afkep *afkep)
ret = wait_for_completion_timeout(&afkep->stopped,
msecs_to_jiffies(afk_timeout_ms(afkep)));
if (ret <= 0) {
dev_err(afkep->dcp->dev, "Timed out shutting down AFK endpoint %02x", afkep->endpoint);
dev_err(afkep->dcp->dev, "Timed out shutting down AFK endpoint %02x\n",
afkep->endpoint);
}

spin_lock_irqsave(&afkep->lock, flags);
Expand Down
43 changes: 42 additions & 1 deletion drivers/gpu/drm/apple/dcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7771,6 +7771,29 @@ static void dcp_v27_dpms_handoff(struct apple_dcp *dcp);
static void dcp_v27_dpms_off_locked(struct apple_dcp *dcp);
static int dcp_v27_dpms_on_locked(struct apple_dcp *dcp, bool present);

/*
* Unbind after an S2R-style stop (DPMS off, or a sleep): the firmware no longer runs
* and RTKit refuses every message to it, so asking an endpoint to shut down only waits
* out its timeout. Let each shutdown below find it stopped.
*/
static void dcp_unbind_stopped_fw(struct apple_dcp *dcp)
{
struct apple_dcp_afkep *eps[] = { dcp->avep, dcp->dptx_controller_ep, dcp->ibootep,
dcp->systemep, dcp->dcpavservep };

dev_info(dcp->dev, "unbind: firmware stopped, endpoints not asked to shut down\n");
for (int i = 0; i < ARRAY_SIZE(eps); i++)
if (!IS_ERR_OR_NULL(eps[i]))
complete_all(&eps[i]->stopped);
}

/* Shutdown breadcrumbs, so the console names the step a hang is in. */
static void dcp_unbind_step(struct apple_dcp *dcp, const char *step)
{
if (system_state > SYSTEM_RUNNING)
dev_info(dcp->dev, "unbind: %s\n", step);
}

VISIBLE_IF_KUNIT void dcp_comp_unbind(struct device *dev, struct device *main, void *data)
{
struct apple_dcp *dcp = dev_get_drvdata(dev);
Expand Down Expand Up @@ -7915,12 +7938,16 @@ VISIBLE_IF_KUNIT void dcp_comp_unbind(struct device *dev, struct device *main, v
}
}

if (READ_ONCE(dcp->s2r_fw_down))
dcp_unbind_stopped_fw(dcp);
dcp_unbind_step(dcp, "av");
if (!IS_ERR_OR_NULL(dcp->avep)) {
av_service_disconnect(dcp);
afk_shutdown(dcp->avep);
dcp->avep = NULL;
}

dcp_unbind_step(dcp, "dptx");
dcp_fabric_shutdown_dptx(dcp);

if (!IS_ERR_OR_NULL(dcp->dptx_controller_ep)) {
Expand All @@ -7933,6 +7960,7 @@ VISIBLE_IF_KUNIT void dcp_comp_unbind(struct device *dev, struct device *main, v
dcp->ibootep = NULL;
}

dcp_unbind_step(dcp, "systemep");
if (dcp->systemep) {
afk_shutdown(dcp->systemep);
dcp->systemep = NULL;
Expand All @@ -7957,12 +7985,25 @@ VISIBLE_IF_KUNIT void dcp_comp_unbind(struct device *dev, struct device *main, v
dcp->dcpavservep = NULL;
}

dcp_unbind_step(dcp, "iomfb");
if (dcp->shmem)
iomfb_shutdown(dcp);

iomfb_queue_stop(dcp);
dcp_release_piodma_iommu_dev(dcp);
dcp_unbind_step(dcp, "piodma");
/*
* At shutdown, DPMS off has already stopped the firmware and powered the display
* domains off, display DART included: destroying the piodma device detaches it
* from that DART, whose registers no longer answer, and the restart hangs there.
* The system is going down; leave the device as it is.
*/
if (system_state > SYSTEM_RUNNING && dcp->dpms_powered_off &&
READ_ONCE(dcp->s2r_fw_down))
dev_info(dcp->dev, "unbind: display powered off, piodma DART left for the restart\n");
else
dcp_release_piodma_iommu_dev(dcp);

dcp_unbind_step(dcp, "backlight");
cancel_delayed_work_sync(&dcp->bl_fallback_wq);
dcp_backlight_stop(dcp);
if (dcp->connector_type == DRM_MODE_CONNECTOR_eDP) {
Expand Down
Loading