Skip to content

Commit b28bc9f

Browse files
jannaumarcan
authored andcommitted
drm: apple: dptx: Wait for completion of dptx_connect.
Makes connects more reliable. Signed-off-by: Janne Grunau <[email protected]>
1 parent a9a37de commit b28bc9f

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

drivers/gpu/drm/apple/dcp.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ EXPORT_SYMBOL_GPL(dcp_get_connector_type);
257257

258258
static int dcp_dptx_connect(struct apple_dcp *dcp, u32 port)
259259
{
260+
int ret = 0;
261+
260262
if (!dcp->phy) {
261263
dev_warn(dcp->dev, "dcp_dptx_connect: missing phy\n");
262264
return -ENODEV;
@@ -265,22 +267,27 @@ static int dcp_dptx_connect(struct apple_dcp *dcp, u32 port)
265267
mutex_lock(&dcp->hpd_mutex);
266268
if (!dcp->dptxport[port].enabled) {
267269
dev_warn(dcp->dev, "dcp_dptx_connect: dptx service for port %d not enabled\n", port);
268-
mutex_unlock(&dcp->hpd_mutex);
269-
return -ENODEV;
270+
ret = -ENODEV;
271+
goto out_unlock;
270272
}
271273

272274
if (dcp->dptxport[port].connected)
273-
goto ret;
275+
goto out_unlock;
274276

277+
reinit_completion(&dcp->dptxport[port].linkcfg_completion);
275278
dcp->dptxport[port].atcphy = dcp->phy;
276279
dptxport_connect(dcp->dptxport[port].service, 0, dcp->dptx_phy, dcp->dptx_die);
277280
dptxport_request_display(dcp->dptxport[port].service);
278281
dcp->dptxport[port].connected = true;
279282

280-
ret:
281283
mutex_unlock(&dcp->hpd_mutex);
282-
284+
wait_for_completion_timeout(&dcp->dptxport[port].linkcfg_completion,
285+
msecs_to_jiffies(1000));
283286
return 0;
287+
288+
out_unlock:
289+
mutex_unlock(&dcp->hpd_mutex);
290+
return ret;
284291
}
285292

286293
static int dcp_dptx_disconnect(struct apple_dcp *dcp, u32 port)

drivers/gpu/drm/apple/dptxep.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,10 @@ dptxport_call_will_change_link_config(struct apple_epic_service *service)
329329
static int
330330
dptxport_call_did_change_link_config(struct apple_epic_service *service)
331331
{
332+
struct dptx_port *dptx = service->cookie;
332333
/* assume the link config did change and wait a little bit */
333334
mdelay(10);
335+
complete(&dptx->linkcfg_completion);
334336
return 0;
335337
}
336338

@@ -572,6 +574,8 @@ int dptxep_init(struct apple_dcp *dcp)
572574

573575
init_completion(&dcp->dptxport[0].enable_completion);
574576
init_completion(&dcp->dptxport[1].enable_completion);
577+
init_completion(&dcp->dptxport[0].linkcfg_completion);
578+
init_completion(&dcp->dptxport[1].linkcfg_completion);
575579

576580
dcp->dptxep = afk_init(dcp, DPTX_ENDPOINT, dptxep_ops);
577581
if (IS_ERR(dcp->dptxep))

drivers/gpu/drm/apple/dptxep.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct apple_epic_service;
4949
struct dptx_port {
5050
bool enabled, connected;
5151
struct completion enable_completion;
52+
struct completion linkcfg_completion;
5253
u32 unit;
5354
struct apple_epic_service *service;
5455
union phy_configure_opts phy_ops;

0 commit comments

Comments
 (0)