Commit a29d8818 authored by Lyude Paul's avatar Lyude Paul

drm/dp_mst: Refactor drm_dp_mst_handle_up_req()

There's a couple of changes here, so to summarize:

* Remove the big ugly mgr->up_req_recv.have_eomt conditional to save on
  indenting
* Store &mgr->up_req_recv.initial_hdr in a variable so we don't keep
  going over 80 character long lines
* De-duplicate code for calling drm_dp_send_up_ack_reply() and getting
  the MSTB via it's GUID
* Remove all of the duplicate calls to memset() and just use a goto
  instead
* Actually do line wrapping
* Remove the unnecessary if (mstb) check before calling
  drm_dp_mst_topology_put_mstb() - we are guaranteed to always have
  mstb != NULL at that point in the function

Cc: Juston Li <juston.li@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Harry Wentland <hwentlan@amd.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190903204645.25487-13-lyude@redhat.com
parent fde61a7a
...@@ -3272,68 +3272,69 @@ static int drm_dp_mst_handle_down_rep(struct drm_dp_mst_topology_mgr *mgr) ...@@ -3272,68 +3272,69 @@ static int drm_dp_mst_handle_down_rep(struct drm_dp_mst_topology_mgr *mgr)
static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr) static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
{ {
struct drm_dp_sideband_msg_req_body msg; struct drm_dp_sideband_msg_req_body msg;
struct drm_dp_sideband_msg_hdr *hdr = &mgr->up_req_recv.initial_hdr;
struct drm_dp_mst_branch *mstb = NULL; struct drm_dp_mst_branch *mstb = NULL;
const u8 *guid;
bool seqno; bool seqno;
if (!drm_dp_get_one_sb_msg(mgr, true)) { if (!drm_dp_get_one_sb_msg(mgr, true))
memset(&mgr->up_req_recv, 0, goto out;
sizeof(struct drm_dp_sideband_msg_rx));
return 0;
}
if (!mgr->up_req_recv.have_eomt) if (!mgr->up_req_recv.have_eomt)
return 0; return 0;
if (!mgr->up_req_recv.initial_hdr.broadcast) { if (!hdr->broadcast) {
mstb = drm_dp_get_mst_branch_device(mgr, mstb = drm_dp_get_mst_branch_device(mgr, hdr->lct, hdr->rad);
mgr->up_req_recv.initial_hdr.lct,
mgr->up_req_recv.initial_hdr.rad);
if (!mstb) { if (!mstb) {
DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct); DRM_DEBUG_KMS("Got MST reply from unknown device %d\n",
memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx)); hdr->lct);
return 0; goto out;
} }
} }
seqno = mgr->up_req_recv.initial_hdr.seqno; seqno = hdr->seqno;
drm_dp_sideband_parse_req(&mgr->up_req_recv, &msg); drm_dp_sideband_parse_req(&mgr->up_req_recv, &msg);
if (msg.req_type == DP_CONNECTION_STATUS_NOTIFY) { if (msg.req_type == DP_CONNECTION_STATUS_NOTIFY)
drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno, false); guid = msg.u.conn_stat.guid;
else if (msg.req_type == DP_RESOURCE_STATUS_NOTIFY)
guid = msg.u.resource_stat.guid;
else
goto out;
if (!mstb) drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno,
mstb = drm_dp_get_mst_branch_device_by_guid(mgr, msg.u.conn_stat.guid); false);
if (!mstb) { if (!mstb) {
DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct); mstb = drm_dp_get_mst_branch_device_by_guid(mgr, guid);
memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx)); if (!mstb) {
return 0; DRM_DEBUG_KMS("Got MST reply from unknown device %d\n",
hdr->lct);
goto out;
}
} }
if (msg.req_type == DP_CONNECTION_STATUS_NOTIFY) {
drm_dp_update_port(mstb, &msg.u.conn_stat); drm_dp_update_port(mstb, &msg.u.conn_stat);
DRM_DEBUG_KMS("Got CSN: pn: %d ldps:%d ddps: %d mcs: %d ip: %d pdt: %d\n", msg.u.conn_stat.port_number, msg.u.conn_stat.legacy_device_plug_status, msg.u.conn_stat.displayport_device_plug_status, msg.u.conn_stat.message_capability_status, msg.u.conn_stat.input_port, msg.u.conn_stat.peer_device_type); DRM_DEBUG_KMS("Got CSN: pn: %d ldps:%d ddps: %d mcs: %d ip: %d pdt: %d\n",
drm_kms_helper_hotplug_event(mgr->dev); msg.u.conn_stat.port_number,
msg.u.conn_stat.legacy_device_plug_status,
msg.u.conn_stat.displayport_device_plug_status,
msg.u.conn_stat.message_capability_status,
msg.u.conn_stat.input_port,
msg.u.conn_stat.peer_device_type);
drm_kms_helper_hotplug_event(mgr->dev);
} else if (msg.req_type == DP_RESOURCE_STATUS_NOTIFY) { } else if (msg.req_type == DP_RESOURCE_STATUS_NOTIFY) {
drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno, false); DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn %d\n",
if (!mstb) msg.u.resource_stat.port_number,
mstb = drm_dp_get_mst_branch_device_by_guid(mgr, msg.u.resource_stat.guid); msg.u.resource_stat.available_pbn);
if (!mstb) {
DRM_DEBUG_KMS("Got MST reply from unknown device %d\n", mgr->up_req_recv.initial_hdr.lct);
memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
return 0;
}
DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn %d\n", msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn);
} }
if (mstb)
drm_dp_mst_topology_put_mstb(mstb); drm_dp_mst_topology_put_mstb(mstb);
out:
memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx)); memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment