diff --git a/drivers/gpu/drm/apple/afk.c b/drivers/gpu/drm/apple/afk.c index 7ad9bb7d1fc58..c23ee21f4dcc6 100644 --- a/drivers/gpu/drm/apple/afk.c +++ b/drivers/gpu/drm/apple/afk.c @@ -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); diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index b11eb205801df..3010357fb409c 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -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); @@ -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)) { @@ -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; @@ -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) {