Skip to content

Commit a160666

Browse files
committed
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 <j@jannau.net>
1 parent ec7635e commit a160666

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
@@ -10,6 +10,7 @@
1010
#include <linux/dma-mapping.h>
1111
#include <linux/gpio/consumer.h>
1212
#include <linux/iommu.h>
13+
#include <linux/jiffies.h>
1314
#include <linux/kernel.h>
1415
#include <linux/module.h>
1516
#include <linux/moduleparam.h>
@@ -254,6 +255,8 @@ int dcp_get_connector_type(struct platform_device *pdev)
254255
}
255256
EXPORT_SYMBOL_GPL(dcp_get_connector_type);
256257

258+
#define DPTX_CONNECT_TIMEOUT msecs_to_jiffies(1000)
259+
257260
static int dcp_dptx_connect(struct apple_dcp *dcp, u32 port)
258261
{
259262
int ret = 0;
@@ -281,8 +284,17 @@ static int dcp_dptx_connect(struct apple_dcp *dcp, u32 port)
281284
dcp->dptxport[port].connected = true;
282285

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

288300
out_unlock:
@@ -370,12 +382,6 @@ int dcp_start(struct platform_device *pdev)
370382
// necessary on j473/j474 but not on j314c
371383
if (connected)
372384
dcp_dptx_connect(dcp, 0);
373-
/*
374-
* Long sleep necessary to ensure dcp delivers timing
375-
* modes with matched color modes.
376-
* 400ms was sufficient on j473
377-
*/
378-
msleep(500);
379385
}
380386
} else if (dcp->phy)
381387
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
@@ -294,9 +294,14 @@ static int dptxport_call_set_active_lane_count(struct apple_epic_service *servic
294294
dptx->phy_ops.dp.set_lanes = 0;
295295
}
296296

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

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

@@ -330,10 +335,9 @@ dptxport_call_will_change_link_config(struct apple_epic_service *service)
330335
static int
331336
dptxport_call_did_change_link_config(struct apple_epic_service *service)
332337
{
333-
struct dptx_port *dptx = service->cookie;
334338
/* assume the link config did change and wait a little bit */
335339
mdelay(10);
336-
complete(&dptx->linkcfg_completion);
340+
337341
return 0;
338342
}
339343

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)