Commit 33929707 authored by Jani Nikula's avatar Jani Nikula

drm/mst: switch to guid_t type for GUID

The kernel has a guid_t type for GUIDs. Switch to using it, but avoid
any functional changes here.
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: default avatarHarry Wentland <harry.wentland@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Acked-by: default avatarHamza Mahfooz <hamza.mahfooz@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240812122312.1567046-1-jani.nikula@intel.comSigned-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent b290af05
...@@ -2610,7 +2610,7 @@ static void resume_mst_branch_status(struct drm_dp_mst_topology_mgr *mgr) ...@@ -2610,7 +2610,7 @@ static void resume_mst_branch_status(struct drm_dp_mst_topology_mgr *mgr)
} }
} }
memcpy(mgr->mst_primary->guid, guid, 16); import_guid(&mgr->mst_primary->guid, guid);
out_fail: out_fail:
mutex_unlock(&mgr->lock); mutex_unlock(&mgr->lock);
......
...@@ -89,7 +89,7 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr, ...@@ -89,7 +89,7 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
struct drm_dp_mst_branch *mstb, struct drm_dp_mst_branch *mstb,
struct drm_dp_mst_port *port); struct drm_dp_mst_port *port);
static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr, static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
u8 *guid); guid_t *guid);
static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port); static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port);
static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port); static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port);
...@@ -801,7 +801,7 @@ static bool drm_dp_sideband_parse_link_address(const struct drm_dp_mst_topology_ ...@@ -801,7 +801,7 @@ static bool drm_dp_sideband_parse_link_address(const struct drm_dp_mst_topology_
int idx = 1; int idx = 1;
int i; int i;
memcpy(repmsg->u.link_addr.guid, &raw->msg[idx], 16); import_guid(&repmsg->u.link_addr.guid, &raw->msg[idx]);
idx += 16; idx += 16;
repmsg->u.link_addr.nports = raw->msg[idx] & 0xf; repmsg->u.link_addr.nports = raw->msg[idx] & 0xf;
idx++; idx++;
...@@ -829,7 +829,7 @@ static bool drm_dp_sideband_parse_link_address(const struct drm_dp_mst_topology_ ...@@ -829,7 +829,7 @@ static bool drm_dp_sideband_parse_link_address(const struct drm_dp_mst_topology_
idx++; idx++;
if (idx > raw->curlen) if (idx > raw->curlen)
goto fail_len; goto fail_len;
memcpy(repmsg->u.link_addr.ports[i].peer_guid, &raw->msg[idx], 16); import_guid(&repmsg->u.link_addr.ports[i].peer_guid, &raw->msg[idx]);
idx += 16; idx += 16;
if (idx > raw->curlen) if (idx > raw->curlen)
goto fail_len; goto fail_len;
...@@ -1029,7 +1029,7 @@ static bool drm_dp_sideband_parse_reply(const struct drm_dp_mst_topology_mgr *mg ...@@ -1029,7 +1029,7 @@ static bool drm_dp_sideband_parse_reply(const struct drm_dp_mst_topology_mgr *mg
msg->req_type = (raw->msg[0] & 0x7f); msg->req_type = (raw->msg[0] & 0x7f);
if (msg->reply_type == DP_SIDEBAND_REPLY_NAK) { if (msg->reply_type == DP_SIDEBAND_REPLY_NAK) {
memcpy(msg->u.nak.guid, &raw->msg[1], 16); import_guid(&msg->u.nak.guid, &raw->msg[1]);
msg->u.nak.reason = raw->msg[17]; msg->u.nak.reason = raw->msg[17];
msg->u.nak.nak_data = raw->msg[18]; msg->u.nak.nak_data = raw->msg[18];
return false; return false;
...@@ -1078,7 +1078,7 @@ drm_dp_sideband_parse_connection_status_notify(const struct drm_dp_mst_topology_ ...@@ -1078,7 +1078,7 @@ drm_dp_sideband_parse_connection_status_notify(const struct drm_dp_mst_topology_
if (idx > raw->curlen) if (idx > raw->curlen)
goto fail_len; goto fail_len;
memcpy(msg->u.conn_stat.guid, &raw->msg[idx], 16); import_guid(&msg->u.conn_stat.guid, &raw->msg[idx]);
idx += 16; idx += 16;
if (idx > raw->curlen) if (idx > raw->curlen)
goto fail_len; goto fail_len;
...@@ -1107,7 +1107,7 @@ static bool drm_dp_sideband_parse_resource_status_notify(const struct drm_dp_mst ...@@ -1107,7 +1107,7 @@ static bool drm_dp_sideband_parse_resource_status_notify(const struct drm_dp_mst
if (idx > raw->curlen) if (idx > raw->curlen)
goto fail_len; goto fail_len;
memcpy(msg->u.resource_stat.guid, &raw->msg[idx], 16); import_guid(&msg->u.resource_stat.guid, &raw->msg[idx]);
idx += 16; idx += 16;
if (idx > raw->curlen) if (idx > raw->curlen)
goto fail_len; goto fail_len;
...@@ -2174,20 +2174,24 @@ ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux, ...@@ -2174,20 +2174,24 @@ ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux,
offset, size, buffer); offset, size, buffer);
} }
static int drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8 *guid) static int drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, guid_t *guid)
{ {
int ret = 0; int ret = 0;
memcpy(mstb->guid, guid, 16); guid_copy(&mstb->guid, guid);
if (!drm_dp_validate_guid(mstb->mgr, &mstb->guid)) {
u8 buf[UUID_SIZE];
export_guid(buf, &mstb->guid);
if (!drm_dp_validate_guid(mstb->mgr, mstb->guid)) {
if (mstb->port_parent) { if (mstb->port_parent) {
ret = drm_dp_send_dpcd_write(mstb->mgr, ret = drm_dp_send_dpcd_write(mstb->mgr,
mstb->port_parent, mstb->port_parent,
DP_GUID, 16, mstb->guid); DP_GUID, sizeof(buf), buf);
} else { } else {
ret = drm_dp_dpcd_write(mstb->mgr->aux, ret = drm_dp_dpcd_write(mstb->mgr->aux,
DP_GUID, mstb->guid, 16); DP_GUID, buf, sizeof(buf));
} }
} }
...@@ -2570,9 +2574,9 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_ ...@@ -2570,9 +2574,9 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
return mstb; return mstb;
} }
static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper( static struct drm_dp_mst_branch *
struct drm_dp_mst_branch *mstb, get_mst_branch_device_by_guid_helper(struct drm_dp_mst_branch *mstb,
const uint8_t *guid) const guid_t *guid)
{ {
struct drm_dp_mst_branch *found_mstb; struct drm_dp_mst_branch *found_mstb;
struct drm_dp_mst_port *port; struct drm_dp_mst_port *port;
...@@ -2580,10 +2584,9 @@ static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper( ...@@ -2580,10 +2584,9 @@ static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper(
if (!mstb) if (!mstb)
return NULL; return NULL;
if (memcmp(mstb->guid, guid, 16) == 0) if (guid_equal(&mstb->guid, guid))
return mstb; return mstb;
list_for_each_entry(port, &mstb->ports, next) { list_for_each_entry(port, &mstb->ports, next) {
found_mstb = get_mst_branch_device_by_guid_helper(port->mstb, guid); found_mstb = get_mst_branch_device_by_guid_helper(port->mstb, guid);
...@@ -2596,7 +2599,7 @@ static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper( ...@@ -2596,7 +2599,7 @@ static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper(
static struct drm_dp_mst_branch * static struct drm_dp_mst_branch *
drm_dp_get_mst_branch_device_by_guid(struct drm_dp_mst_topology_mgr *mgr, drm_dp_get_mst_branch_device_by_guid(struct drm_dp_mst_topology_mgr *mgr,
const uint8_t *guid) const guid_t *guid)
{ {
struct drm_dp_mst_branch *mstb; struct drm_dp_mst_branch *mstb;
int ret; int ret;
...@@ -2693,17 +2696,20 @@ static void drm_dp_mst_link_probe_work(struct work_struct *work) ...@@ -2693,17 +2696,20 @@ static void drm_dp_mst_link_probe_work(struct work_struct *work)
} }
static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr, static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
u8 *guid) guid_t *guid)
{ {
u64 salt; u64 salt;
u8 buf[UUID_SIZE];
if (memchr_inv(guid, 0, 16)) if (!guid_is_null(guid))
return true; return true;
salt = get_jiffies_64(); salt = get_jiffies_64();
memcpy(&guid[0], &salt, sizeof(u64)); memcpy(&buf[0], &salt, sizeof(u64));
memcpy(&guid[8], &salt, sizeof(u64)); memcpy(&buf[8], &salt, sizeof(u64));
import_guid(guid, buf);
return false; return false;
} }
...@@ -2943,7 +2949,7 @@ static int drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr, ...@@ -2943,7 +2949,7 @@ static int drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
drm_dbg_kms(mgr->dev, "link address reply: %d\n", reply->nports); drm_dbg_kms(mgr->dev, "link address reply: %d\n", reply->nports);
drm_dp_dump_link_address(mgr, reply); drm_dp_dump_link_address(mgr, reply);
ret = drm_dp_check_mstb_guid(mstb, reply->guid); ret = drm_dp_check_mstb_guid(mstb, &reply->guid);
if (ret) { if (ret) {
char buf[64]; char buf[64];
...@@ -3770,8 +3776,9 @@ EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend); ...@@ -3770,8 +3776,9 @@ EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend);
int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr, int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr,
bool sync) bool sync)
{ {
u8 buf[UUID_SIZE];
guid_t guid;
int ret; int ret;
u8 guid[16];
mutex_lock(&mgr->lock); mutex_lock(&mgr->lock);
if (!mgr->mst_primary) if (!mgr->mst_primary)
...@@ -3792,13 +3799,15 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr, ...@@ -3792,13 +3799,15 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr,
} }
/* Some hubs forget their guids after they resume */ /* Some hubs forget their guids after they resume */
ret = drm_dp_dpcd_read(mgr->aux, DP_GUID, guid, 16); ret = drm_dp_dpcd_read(mgr->aux, DP_GUID, buf, sizeof(buf));
if (ret != 16) { if (ret != sizeof(buf)) {
drm_dbg_kms(mgr->dev, "dpcd read failed - undocked during suspend?\n"); drm_dbg_kms(mgr->dev, "dpcd read failed - undocked during suspend?\n");
goto out_fail; goto out_fail;
} }
ret = drm_dp_check_mstb_guid(mgr->mst_primary, guid); import_guid(&guid, buf);
ret = drm_dp_check_mstb_guid(mgr->mst_primary, &guid);
if (ret) { if (ret) {
drm_dbg_kms(mgr->dev, "check mstb failed - undocked during suspend?\n"); drm_dbg_kms(mgr->dev, "check mstb failed - undocked during suspend?\n");
goto out_fail; goto out_fail;
...@@ -3976,12 +3985,12 @@ drm_dp_mst_process_up_req(struct drm_dp_mst_topology_mgr *mgr, ...@@ -3976,12 +3985,12 @@ drm_dp_mst_process_up_req(struct drm_dp_mst_topology_mgr *mgr,
bool hotplug = false, dowork = false; bool hotplug = false, dowork = false;
if (hdr->broadcast) { if (hdr->broadcast) {
const u8 *guid = NULL; const guid_t *guid = NULL;
if (msg->req_type == DP_CONNECTION_STATUS_NOTIFY) if (msg->req_type == DP_CONNECTION_STATUS_NOTIFY)
guid = msg->u.conn_stat.guid; guid = &msg->u.conn_stat.guid;
else if (msg->req_type == DP_RESOURCE_STATUS_NOTIFY) else if (msg->req_type == DP_RESOURCE_STATUS_NOTIFY)
guid = msg->u.resource_stat.guid; guid = &msg->u.resource_stat.guid;
if (guid) if (guid)
mstb = drm_dp_get_mst_branch_device_by_guid(mgr, guid); mstb = drm_dp_get_mst_branch_device_by_guid(mgr, guid);
......
...@@ -244,18 +244,18 @@ struct drm_dp_mst_branch { ...@@ -244,18 +244,18 @@ struct drm_dp_mst_branch {
bool link_address_sent; bool link_address_sent;
/* global unique identifier to identify branch devices */ /* global unique identifier to identify branch devices */
u8 guid[16]; guid_t guid;
}; };
struct drm_dp_nak_reply { struct drm_dp_nak_reply {
u8 guid[16]; guid_t guid;
u8 reason; u8 reason;
u8 nak_data; u8 nak_data;
}; };
struct drm_dp_link_address_ack_reply { struct drm_dp_link_address_ack_reply {
u8 guid[16]; guid_t guid;
u8 nports; u8 nports;
struct drm_dp_link_addr_reply_port { struct drm_dp_link_addr_reply_port {
bool input_port; bool input_port;
...@@ -265,7 +265,7 @@ struct drm_dp_link_address_ack_reply { ...@@ -265,7 +265,7 @@ struct drm_dp_link_address_ack_reply {
bool ddps; bool ddps;
bool legacy_device_plug_status; bool legacy_device_plug_status;
u8 dpcd_revision; u8 dpcd_revision;
u8 peer_guid[16]; guid_t peer_guid;
u8 num_sdp_streams; u8 num_sdp_streams;
u8 num_sdp_stream_sinks; u8 num_sdp_stream_sinks;
} ports[16]; } ports[16];
...@@ -348,7 +348,7 @@ struct drm_dp_allocate_payload_ack_reply { ...@@ -348,7 +348,7 @@ struct drm_dp_allocate_payload_ack_reply {
}; };
struct drm_dp_connection_status_notify { struct drm_dp_connection_status_notify {
u8 guid[16]; guid_t guid;
u8 port_number; u8 port_number;
bool legacy_device_plug_status; bool legacy_device_plug_status;
bool displayport_device_plug_status; bool displayport_device_plug_status;
...@@ -425,7 +425,7 @@ struct drm_dp_query_payload { ...@@ -425,7 +425,7 @@ struct drm_dp_query_payload {
struct drm_dp_resource_status_notify { struct drm_dp_resource_status_notify {
u8 port_number; u8 port_number;
u8 guid[16]; guid_t guid;
u16 available_pbn; u16 available_pbn;
}; };
......
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