Skip to content

Commit 4b02100

Browse files
committed
drm: apple: dptx: Wait for completion of dptx_connect.
Makes connects more reliable. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 06e13b1 commit 4b02100

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
@@ -256,6 +256,8 @@ EXPORT_SYMBOL_GPL(dcp_get_connector_type);
256256

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

271273
if (dcp->dptxport[port].connected)
272-
goto ret;
274+
goto out_unlock;
273275

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

279-
ret:
280282
mutex_unlock(&dcp->hpd_mutex);
281-
283+
wait_for_completion_timeout(&dcp->dptxport[port].linkcfg_completion,
284+
msecs_to_jiffies(1000));
282285
return 0;
286+
287+
out_unlock:
288+
mutex_unlock(&dcp->hpd_mutex);
289+
return ret;
283290
}
284291

285292
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
@@ -330,8 +330,10 @@ dptxport_call_will_change_link_config(struct apple_epic_service *service)
330330
static int
331331
dptxport_call_did_change_link_config(struct apple_epic_service *service)
332332
{
333+
struct dptx_port *dptx = service->cookie;
333334
/* assume the link config did change and wait a little bit */
334335
mdelay(10);
336+
complete(&dptx->linkcfg_completion);
335337
return 0;
336338
}
337339

@@ -573,6 +575,8 @@ int dptxep_init(struct apple_dcp *dcp)
573575

574576
init_completion(&dcp->dptxport[0].enable_completion);
575577
init_completion(&dcp->dptxport[1].enable_completion);
578+
init_completion(&dcp->dptxport[0].linkcfg_completion);
579+
init_completion(&dcp->dptxport[1].linkcfg_completion);
576580

577581
dcp->dptxep = afk_init(dcp, DPTX_ENDPOINT, dptxep_ops);
578582
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)