Skip to content

Commit

Permalink
drm: apple: dptx: Rework/document get_max_lane_count()
Browse files Browse the repository at this point in the history
phy_validate() on the DP only ATC phy returns 0 lanes if it happens
before the phy_set_mode(PHY_MODE_DP). Since this is the only known case
default to 4 lanes as the phy is used exclusively for DP.

Fixes: #367
Signed-off-by: Janne Grunau <[email protected]>
  • Loading branch information
jannau committed Jan 21, 2025
1 parent d853329 commit b9ec224
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions drivers/gpu/drm/apple/dptxep.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,26 +250,31 @@ static int dptxport_call_get_max_lane_count(struct apple_epic_service *service,
{
struct dptxport_apcall_lane_count *reply = reply_;
struct dptx_port *dptx = service->cookie;
struct apple_dcp *dcp = service->ep->dcp;
union phy_configure_opts phy_ops;
int ret;

if (reply_size < sizeof(*reply))
return -EINVAL;

reply->retcode = cpu_to_le32(0);
reply->lane_count = cpu_to_le64(2);

ret = phy_validate(dptx->atcphy, PHY_MODE_DP, 0, &phy_ops);
if (ret < 0 || phy_ops.dp.lanes < 2) {
// phy_validate might return 0 lines if atc-phy is not yet
// switched to DP alt mode
dev_dbg(service->ep->dcp->dev, "get_max_lane_count: "
"phy_validate ret:%d lanes:%d\n", ret, phy_ops.dp.lanes);
dptx->lane_count = 0;
if (ret < 0) {
dev_err(dcp->dev, "phy_validate failed: %d\n", ret);
reply->retcode = cpu_to_le32(1);
reply->lane_count = cpu_to_le64(0);
} else {
if (phy_ops.dp.lanes < 2) {
// phy_validate might return 0 lanes if atc phy is not
// yet switched to DP mode
dev_dbg(dcp->dev, "get_max_lane_count: phy lanes: %d\n",
phy_ops.dp.lanes);
// default to 4 lanes
dptx->lane_count = 4;
} else {
dptx->lane_count = phy_ops.dp.lanes;
}
reply->retcode = cpu_to_le32(0);
reply->lane_count = cpu_to_le64(phy_ops.dp.lanes);
dptx->lane_count = phy_ops.dp.lanes;
reply->lane_count = cpu_to_le64(dptx->lane_count);
}

return 0;
Expand Down

0 comments on commit b9ec224

Please sign in to comment.