Skip to content

Commit 1d26b13

Browse files
jannaumarcan
authored andcommitted
drm: apple: dptx: Wait for link config on connect
Should make connect more reliable by avoiding hardcoded waits which are either to long or too short. In the second case the display can't be brought up since dcp fails to report any modes during start. Signed-off-by: Janne Grunau <[email protected]>
1 parent 5bfd508 commit 1d26b13

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

drivers/gpu/drm/apple/dcp.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/dma-mapping.h>
1212
#include <linux/gpio/consumer.h>
1313
#include <linux/iommu.h>
14+
#include <linux/jiffies.h>
1415
#include <linux/kernel.h>
1516
#include <linux/module.h>
1617
#include <linux/moduleparam.h>
@@ -255,6 +256,8 @@ int dcp_get_connector_type(struct platform_device *pdev)
255256
}
256257
EXPORT_SYMBOL_GPL(dcp_get_connector_type);
257258

259+
#define DPTX_CONNECT_TIMEOUT msecs_to_jiffies(1000)
260+
258261
static int dcp_dptx_connect(struct apple_dcp *dcp, u32 port)
259262
{
260263
int ret = 0;
@@ -282,8 +285,17 @@ static int dcp_dptx_connect(struct apple_dcp *dcp, u32 port)
282285
dcp->dptxport[port].connected = true;
283286

284287
mutex_unlock(&dcp->hpd_mutex);
285-
wait_for_completion_timeout(&dcp->dptxport[port].linkcfg_completion,
286-
msecs_to_jiffies(1000));
288+
ret = wait_for_completion_timeout(&dcp->dptxport[port].linkcfg_completion,
289+
DPTX_CONNECT_TIMEOUT);
290+
if (ret < 0)
291+
dev_warn(dcp->dev, "dcp_dptx_connect: port %d link complete failed:%d\n",
292+
port, ret);
293+
else
294+
dev_dbg(dcp->dev, "dcp_dptx_connect: waited %d ms for link\n",
295+
jiffies_to_msecs(DPTX_CONNECT_TIMEOUT - ret));
296+
297+
usleep_range(5, 10);
298+
287299
return 0;
288300

289301
out_unlock:
@@ -371,12 +383,6 @@ int dcp_start(struct platform_device *pdev)
371383
// necessary on j473/j474 but not on j314c
372384
if (connected)
373385
dcp_dptx_connect(dcp, 0);
374-
/*
375-
* Long sleep necessary to ensure dcp delivers timing
376-
* modes with matched color modes.
377-
* 400ms was sufficient on j473
378-
*/
379-
msleep(500);
380386
}
381387
} else if (dcp->phy)
382388
dev_warn(dcp->dev, "OS firmware incompatible with dptxport EP\n");

drivers/gpu/drm/apple/dptxep.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,14 @@ static int dptxport_call_set_active_lane_count(struct apple_epic_service *servic
293293
dptx->phy_ops.dp.set_lanes = 0;
294294
}
295295

296+
dptx->lane_count = lane_count;
297+
296298
reply->retcode = cpu_to_le32(retcode);
297299
reply->lane_count = cpu_to_le64(lane_count);
298300

301+
if (dptx->lane_count > 0)
302+
complete(&dptx->linkcfg_completion);
303+
299304
return ret;
300305
}
301306

@@ -329,10 +334,9 @@ dptxport_call_will_change_link_config(struct apple_epic_service *service)
329334
static int
330335
dptxport_call_did_change_link_config(struct apple_epic_service *service)
331336
{
332-
struct dptx_port *dptx = service->cookie;
333337
/* assume the link config did change and wait a little bit */
334338
mdelay(10);
335-
complete(&dptx->linkcfg_completion);
339+
336340
return 0;
337341
}
338342

drivers/gpu/drm/apple/dptxep.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct dptx_port {
5555
union phy_configure_opts phy_ops;
5656
struct phy *atcphy;
5757
struct mux_control *mux;
58+
u32 lane_count;
5859
u32 link_rate, pending_link_rate;
5960
u32 drive_settings[2];
6061
};

0 commit comments

Comments
 (0)