Skip to content

Commit fbc821c

Browse files
committed
drm/mst: Support simultaneous down replies
Currently we have one down reply message servicing the mst manager, so we need to serialize all tx msgs to ensure we only have one message in flight at a time. For obvious reasons this is suboptimal (but less suboptimal than the free-for-all we had before serialization). This patch removes the single down_rep_recv message from manager and adds 2 replies in the branch structure. The 2 replies mirrors the tx_slots which we use to rate-limit outgoing messages and correspond to seqno in the packet headers. Cc: Wayne Lin <Wayne.Lin@amd.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Wayne Lin <waynelin@amd.com> Signed-off-by: Sean Paul <seanpaul@chromium.org> Link: https://patchwork.freedesktop.org/patch/msgid/20200213211523.156998-3-sean@poorly.run
1 parent 21a729d commit fbc821c

2 files changed

Lines changed: 78 additions & 61 deletions

File tree

‎drivers/gpu/drm/drm_dp_mst_topology.c‎

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3696,7 +3696,8 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr,
36963696
}
36973697
EXPORT_SYMBOL(drm_dp_mst_topology_mgr_resume);
36983698

3699-
static bool drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up)
3699+
static bool drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up,
3700+
struct drm_dp_mst_branch **mstb, int *seqno)
37003701
{
37013702
int len;
37023703
u8 replyblock[32];
@@ -3708,7 +3709,8 @@ static bool drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up)
37083709
int basereg = up ? DP_SIDEBAND_MSG_UP_REQ_BASE :
37093710
DP_SIDEBAND_MSG_DOWN_REP_BASE;
37103711

3711-
msg = up ? &mgr->up_req_recv : &mgr->down_rep_recv;
3712+
*mstb = NULL;
3713+
*seqno = -1;
37123714

37133715
len = min(mgr->max_dpcd_transaction_bytes, 16);
37143716
ret = drm_dp_dpcd_read(mgr->aux, basereg, replyblock, len);
@@ -3725,6 +3727,21 @@ static bool drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up)
37253727
return false;
37263728
}
37273729

3730+
*seqno = hdr.seqno;
3731+
3732+
if (up) {
3733+
msg = &mgr->up_req_recv;
3734+
} else {
3735+
/* Caller is responsible for giving back this reference */
3736+
*mstb = drm_dp_get_mst_branch_device(mgr, hdr.lct, hdr.rad);
3737+
if (!*mstb) {
3738+
DRM_DEBUG_KMS("Got MST reply from unknown device %d\n",
3739+
hdr.lct);
3740+
return false;
3741+
}
3742+
msg = &(*mstb)->down_rep_recv[hdr.seqno];
3743+
}
3744+
37283745
if (!drm_dp_sideband_msg_set_header(msg, &hdr, hdrlen)) {
37293746
DRM_DEBUG_KMS("sideband msg set header failed %d\n",
37303747
replyblock[0]);
@@ -3765,67 +3782,68 @@ static bool drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up)
37653782
static int drm_dp_mst_handle_down_rep(struct drm_dp_mst_topology_mgr *mgr)
37663783
{
37673784
struct drm_dp_sideband_msg_tx *txmsg;
3768-
struct drm_dp_mst_branch *mstb;
3769-
struct drm_dp_sideband_msg_hdr *hdr = &mgr->down_rep_recv.initial_hdr;
3770-
int slot = -1;
3785+
struct drm_dp_mst_branch *mstb = NULL;
3786+
struct drm_dp_sideband_msg_rx *msg = NULL;
3787+
int seqno = -1;
37713788

3772-
if (!drm_dp_get_one_sb_msg(mgr, false))
3773-
goto clear_down_rep_recv;
3789+
if (!drm_dp_get_one_sb_msg(mgr, false, &mstb, &seqno))
3790+
goto out_clear_reply;
37743791

3775-
if (!mgr->down_rep_recv.have_eomt)
3776-
return 0;
3792+
msg = &mstb->down_rep_recv[seqno];
37773793

3778-
mstb = drm_dp_get_mst_branch_device(mgr, hdr->lct, hdr->rad);
3779-
if (!mstb) {
3780-
DRM_DEBUG_KMS("Got MST reply from unknown device %d\n",
3781-
hdr->lct);
3782-
goto clear_down_rep_recv;
3783-
}
3794+
/* Multi-packet message transmission, don't clear the reply */
3795+
if (!msg->have_eomt)
3796+
goto out;
37843797

37853798
/* find the message */
3786-
slot = hdr->seqno;
37873799
mutex_lock(&mgr->qlock);
3788-
txmsg = mstb->tx_slots[slot];
3800+
txmsg = mstb->tx_slots[seqno];
37893801
/* remove from slots */
37903802
mutex_unlock(&mgr->qlock);
37913803

37923804
if (!txmsg) {
3805+
struct drm_dp_sideband_msg_hdr *hdr;
3806+
hdr = &msg->initial_hdr;
37933807
DRM_DEBUG_KMS("Got MST reply with no msg %p %d %d %02x %02x\n",
37943808
mstb, hdr->seqno, hdr->lct, hdr->rad[0],
3795-
mgr->down_rep_recv.msg[0]);
3796-
goto no_msg;
3809+
msg->msg[0]);
3810+
goto out_clear_reply;
37973811
}
37983812

3799-
drm_dp_sideband_parse_reply(&mgr->down_rep_recv, &txmsg->reply);
3813+
drm_dp_sideband_parse_reply(msg, &txmsg->reply);
38003814

3801-
if (txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK)
3815+
if (txmsg->reply.reply_type == DP_SIDEBAND_REPLY_NAK) {
38023816
DRM_DEBUG_KMS("Got NAK reply: req 0x%02x (%s), reason 0x%02x (%s), nak data 0x%02x\n",
38033817
txmsg->reply.req_type,
38043818
drm_dp_mst_req_type_str(txmsg->reply.req_type),
38053819
txmsg->reply.u.nak.reason,
38063820
drm_dp_mst_nak_reason_str(txmsg->reply.u.nak.reason),
38073821
txmsg->reply.u.nak.nak_data);
3822+
goto out_clear_reply;
3823+
}
38083824

3809-
memset(&mgr->down_rep_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
3825+
memset(msg, 0, sizeof(struct drm_dp_sideband_msg_rx));
38103826
drm_dp_mst_topology_put_mstb(mstb);
38113827

38123828
mutex_lock(&mgr->qlock);
38133829
txmsg->state = DRM_DP_SIDEBAND_TX_RX;
3814-
mstb->tx_slots[slot] = NULL;
3830+
mstb->tx_slots[seqno] = NULL;
38153831
mgr->is_waiting_for_dwn_reply = false;
38163832
mutex_unlock(&mgr->qlock);
38173833

38183834
wake_up_all(&mgr->tx_waitq);
38193835

38203836
return 0;
38213837

3822-
no_msg:
3823-
drm_dp_mst_topology_put_mstb(mstb);
3824-
clear_down_rep_recv:
3838+
out_clear_reply:
38253839
mutex_lock(&mgr->qlock);
38263840
mgr->is_waiting_for_dwn_reply = false;
38273841
mutex_unlock(&mgr->qlock);
3828-
memset(&mgr->down_rep_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
3842+
if (msg)
3843+
memset(msg, 0, sizeof(struct drm_dp_sideband_msg_rx));
3844+
out:
3845+
if (mstb)
3846+
drm_dp_mst_topology_put_mstb(mstb);
38293847

38303848
return 0;
38313849
}
@@ -3901,11 +3919,10 @@ static void drm_dp_mst_up_req_work(struct work_struct *work)
39013919

39023920
static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
39033921
{
3904-
struct drm_dp_sideband_msg_hdr *hdr = &mgr->up_req_recv.initial_hdr;
39053922
struct drm_dp_pending_up_req *up_req;
3906-
bool seqno;
3923+
int seqno;
39073924

3908-
if (!drm_dp_get_one_sb_msg(mgr, true))
3925+
if (!drm_dp_get_one_sb_msg(mgr, true, NULL, &seqno))
39093926
goto out;
39103927

39113928
if (!mgr->up_req_recv.have_eomt)
@@ -3918,7 +3935,6 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
39183935
}
39193936
INIT_LIST_HEAD(&up_req->next);
39203937

3921-
seqno = hdr->seqno;
39223938
drm_dp_sideband_parse_req(&mgr->up_req_recv, &up_req->msg);
39233939

39243940
if (up_req->msg.req_type != DP_CONNECTION_STATUS_NOTIFY &&
@@ -3952,7 +3968,7 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
39523968
res_stat->available_pbn);
39533969
}
39543970

3955-
up_req->hdr = *hdr;
3971+
up_req->hdr = mgr->up_req_recv.initial_hdr;
39563972
mutex_lock(&mgr->up_req_lock);
39573973
list_add_tail(&up_req->next, &mgr->up_req_list);
39583974
mutex_unlock(&mgr->up_req_lock);

‎include/drm/drm_dp_mst_helper.h‎

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,31 @@ struct drm_dp_mst_port {
160160
bool fec_capable;
161161
};
162162

163+
/* sideband msg header - not bit struct */
164+
struct drm_dp_sideband_msg_hdr {
165+
u8 lct;
166+
u8 lcr;
167+
u8 rad[8];
168+
bool broadcast;
169+
bool path_msg;
170+
u8 msg_len;
171+
bool somt;
172+
bool eomt;
173+
bool seqno;
174+
};
175+
176+
struct drm_dp_sideband_msg_rx {
177+
u8 chunk[48];
178+
u8 msg[256];
179+
u8 curchunk_len;
180+
u8 curchunk_idx; /* chunk we are parsing now */
181+
u8 curchunk_hdrlen;
182+
u8 curlen; /* total length of the msg */
183+
bool have_somt;
184+
bool have_eomt;
185+
struct drm_dp_sideband_msg_hdr initial_hdr;
186+
};
187+
163188
/**
164189
* struct drm_dp_mst_branch - MST branch device.
165190
* @rad: Relative Address to talk to this branch device.
@@ -232,24 +257,16 @@ struct drm_dp_mst_branch {
232257
int last_seqno;
233258
bool link_address_sent;
234259

260+
/**
261+
* @down_rep_recv: Message receiver state for down replies.
262+
*/
263+
struct drm_dp_sideband_msg_rx down_rep_recv[2];
264+
235265
/* global unique identifier to identify branch devices */
236266
u8 guid[16];
237267
};
238268

239269

240-
/* sideband msg header - not bit struct */
241-
struct drm_dp_sideband_msg_hdr {
242-
u8 lct;
243-
u8 lcr;
244-
u8 rad[8];
245-
bool broadcast;
246-
bool path_msg;
247-
u8 msg_len;
248-
bool somt;
249-
bool eomt;
250-
bool seqno;
251-
};
252-
253270
struct drm_dp_nak_reply {
254271
u8 guid[16];
255272
u8 reason;
@@ -306,18 +323,6 @@ struct drm_dp_remote_i2c_write_ack_reply {
306323
};
307324

308325

309-
struct drm_dp_sideband_msg_rx {
310-
u8 chunk[48];
311-
u8 msg[256];
312-
u8 curchunk_len;
313-
u8 curchunk_idx; /* chunk we are parsing now */
314-
u8 curchunk_hdrlen;
315-
u8 curlen; /* total length of the msg */
316-
bool have_somt;
317-
bool have_eomt;
318-
struct drm_dp_sideband_msg_hdr initial_hdr;
319-
};
320-
321326
#define DRM_DP_MAX_SDP_STREAMS 16
322327
struct drm_dp_allocate_payload {
323328
u8 port_number;
@@ -555,10 +560,6 @@ struct drm_dp_mst_topology_mgr {
555560
*/
556561
int conn_base_id;
557562

558-
/**
559-
* @down_rep_recv: Message receiver state for down replies.
560-
*/
561-
struct drm_dp_sideband_msg_rx down_rep_recv;
562563
/**
563564
* @up_req_recv: Message receiver state for up requests.
564565
*/

0 commit comments

Comments
 (0)