Skip to content

Commit 92400b7

Browse files
hoshinolinajannau
authored andcommitted
drm/apple: Explicitly stop AFK endpoints on shutdown
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent 6451d63 commit 92400b7

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

drivers/gpu/drm/apple/afk.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ struct apple_dcp_afkep *afk_init(struct apple_dcp *dcp, u32 endpoint,
8686
return ERR_PTR(ret);
8787
}
8888

89+
void afk_shutdown(struct apple_dcp_afkep *afkep)
90+
{
91+
afk_send(afkep, FIELD_PREP(RBEP_TYPE, RBEP_SHUTDOWN));
92+
int ret;
93+
94+
ret = wait_for_completion_timeout(&afkep->stopped, msecs_to_jiffies(1000));
95+
if (ret <= 0) {
96+
dev_err(afkep->dcp->dev, "Timed out shutting down AFK endpoint %02x", afkep->endpoint);
97+
}
98+
99+
destroy_workqueue(afkep->wq);
100+
}
101+
89102
int afk_start(struct apple_dcp_afkep *ep)
90103
{
91104
int ret;

drivers/gpu/drm/apple/afk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ struct apple_dcp_afkep {
187187
struct apple_dcp_afkep *afk_init(struct apple_dcp *dcp, u32 endpoint,
188188
const struct apple_epic_service_ops *ops);
189189
int afk_start(struct apple_dcp_afkep *ep);
190+
void afk_shutdown(struct apple_dcp_afkep *ep);
190191
int afk_receive_message(struct apple_dcp_afkep *ep, u64 message);
191192
int afk_send_epic(struct apple_dcp_afkep *ep, u32 channel, u16 tag,
192193
enum epic_type etype, enum epic_category ecat, u8 stype,

drivers/gpu/drm/apple/dcp.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,10 +1022,33 @@ static void dcp_comp_unbind(struct device *dev, struct device *main, void *data)
10221022
{
10231023
struct apple_dcp *dcp = dev_get_drvdata(dev);
10241024

1025+
if (!dcp)
1026+
return;
1027+
10251028
if (dcp->hdmi_hpd_irq)
10261029
disable_irq(dcp->hdmi_hpd_irq);
10271030

1028-
if (dcp && dcp->shmem)
1031+
if (dcp->avep) {
1032+
afk_shutdown(dcp->avep);
1033+
dcp->avep = NULL;
1034+
}
1035+
1036+
if (dcp->dptxep) {
1037+
afk_shutdown(dcp->dptxep);
1038+
dcp->dptxep = NULL;
1039+
}
1040+
1041+
if (dcp->ibootep) {
1042+
afk_shutdown(dcp->ibootep);
1043+
dcp->ibootep = NULL;
1044+
}
1045+
1046+
if (dcp->systemep) {
1047+
afk_shutdown(dcp->systemep);
1048+
dcp->systemep = NULL;
1049+
}
1050+
1051+
if (dcp->shmem)
10291052
iomfb_shutdown(dcp);
10301053

10311054
if (dcp->piodma) {
@@ -1038,6 +1061,12 @@ static void dcp_comp_unbind(struct device *dev, struct device *main, void *data)
10381061
dcp->piodma = NULL;
10391062
}
10401063

1064+
if (dcp->connector_type == DRM_MODE_CONNECTOR_eDP) {
1065+
cancel_work_sync(&dcp->bl_register_wq);
1066+
cancel_work_sync(&dcp->bl_update_wq);
1067+
}
1068+
cancel_work_sync(&dcp->vblank_wq);
1069+
10411070
devm_clk_put(dev, dcp->clk);
10421071
dcp->clk = NULL;
10431072
}

0 commit comments

Comments
 (0)