Skip to content

Commit 3392970

Browse files
committed
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: Daniel Vetter <[email protected]> Acked-by: Harry Wentland <[email protected]> Acked-by: Alex Deucher <[email protected]> Acked-by: Hamza Mahfooz <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Jani Nikula <[email protected]>
1 parent b290af0 commit 3392970

File tree

3 files changed

+45
-36
lines changed

3 files changed

+45
-36
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@ static void resume_mst_branch_status(struct drm_dp_mst_topology_mgr *mgr)
26102610
}
26112611
}
26122612

2613-
memcpy(mgr->mst_primary->guid, guid, 16);
2613+
import_guid(&mgr->mst_primary->guid, guid);
26142614

26152615
out_fail:
26162616
mutex_unlock(&mgr->lock);

drivers/gpu/drm/display/drm_dp_mst_topology.c

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
8989
struct drm_dp_mst_branch *mstb,
9090
struct drm_dp_mst_port *port);
9191
static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
92-
u8 *guid);
92+
guid_t *guid);
9393

9494
static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port);
9595
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_
801801
int idx = 1;
802802
int i;
803803

804-
memcpy(repmsg->u.link_addr.guid, &raw->msg[idx], 16);
804+
import_guid(&repmsg->u.link_addr.guid, &raw->msg[idx]);
805805
idx += 16;
806806
repmsg->u.link_addr.nports = raw->msg[idx] & 0xf;
807807
idx++;
@@ -829,7 +829,7 @@ static bool drm_dp_sideband_parse_link_address(const struct drm_dp_mst_topology_
829829
idx++;
830830
if (idx > raw->curlen)
831831
goto fail_len;
832-
memcpy(repmsg->u.link_addr.ports[i].peer_guid, &raw->msg[idx], 16);
832+
import_guid(&repmsg->u.link_addr.ports[i].peer_guid, &raw->msg[idx]);
833833
idx += 16;
834834
if (idx > raw->curlen)
835835
goto fail_len;
@@ -1029,7 +1029,7 @@ static bool drm_dp_sideband_parse_reply(const struct drm_dp_mst_topology_mgr *mg
10291029
msg->req_type = (raw->msg[0] & 0x7f);
10301030

10311031
if (msg->reply_type == DP_SIDEBAND_REPLY_NAK) {
1032-
memcpy(msg->u.nak.guid, &raw->msg[1], 16);
1032+
import_guid(&msg->u.nak.guid, &raw->msg[1]);
10331033
msg->u.nak.reason = raw->msg[17];
10341034
msg->u.nak.nak_data = raw->msg[18];
10351035
return false;
@@ -1078,7 +1078,7 @@ drm_dp_sideband_parse_connection_status_notify(const struct drm_dp_mst_topology_
10781078
if (idx > raw->curlen)
10791079
goto fail_len;
10801080

1081-
memcpy(msg->u.conn_stat.guid, &raw->msg[idx], 16);
1081+
import_guid(&msg->u.conn_stat.guid, &raw->msg[idx]);
10821082
idx += 16;
10831083
if (idx > raw->curlen)
10841084
goto fail_len;
@@ -1107,7 +1107,7 @@ static bool drm_dp_sideband_parse_resource_status_notify(const struct drm_dp_mst
11071107
if (idx > raw->curlen)
11081108
goto fail_len;
11091109

1110-
memcpy(msg->u.resource_stat.guid, &raw->msg[idx], 16);
1110+
import_guid(&msg->u.resource_stat.guid, &raw->msg[idx]);
11111111
idx += 16;
11121112
if (idx > raw->curlen)
11131113
goto fail_len;
@@ -2174,20 +2174,24 @@ ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux,
21742174
offset, size, buffer);
21752175
}
21762176

2177-
static int drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, u8 *guid)
2177+
static int drm_dp_check_mstb_guid(struct drm_dp_mst_branch *mstb, guid_t *guid)
21782178
{
21792179
int ret = 0;
21802180

2181-
memcpy(mstb->guid, guid, 16);
2181+
guid_copy(&mstb->guid, guid);
2182+
2183+
if (!drm_dp_validate_guid(mstb->mgr, &mstb->guid)) {
2184+
u8 buf[UUID_SIZE];
2185+
2186+
export_guid(buf, &mstb->guid);
21822187

2183-
if (!drm_dp_validate_guid(mstb->mgr, mstb->guid)) {
21842188
if (mstb->port_parent) {
21852189
ret = drm_dp_send_dpcd_write(mstb->mgr,
21862190
mstb->port_parent,
2187-
DP_GUID, 16, mstb->guid);
2191+
DP_GUID, sizeof(buf), buf);
21882192
} else {
21892193
ret = drm_dp_dpcd_write(mstb->mgr->aux,
2190-
DP_GUID, mstb->guid, 16);
2194+
DP_GUID, buf, sizeof(buf));
21912195
}
21922196
}
21932197

@@ -2570,20 +2574,19 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
25702574
return mstb;
25712575
}
25722576

2573-
static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper(
2574-
struct drm_dp_mst_branch *mstb,
2575-
const uint8_t *guid)
2577+
static struct drm_dp_mst_branch *
2578+
get_mst_branch_device_by_guid_helper(struct drm_dp_mst_branch *mstb,
2579+
const guid_t *guid)
25762580
{
25772581
struct drm_dp_mst_branch *found_mstb;
25782582
struct drm_dp_mst_port *port;
25792583

25802584
if (!mstb)
25812585
return NULL;
25822586

2583-
if (memcmp(mstb->guid, guid, 16) == 0)
2587+
if (guid_equal(&mstb->guid, guid))
25842588
return mstb;
25852589

2586-
25872590
list_for_each_entry(port, &mstb->ports, next) {
25882591
found_mstb = get_mst_branch_device_by_guid_helper(port->mstb, guid);
25892592

@@ -2596,7 +2599,7 @@ static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper(
25962599

25972600
static struct drm_dp_mst_branch *
25982601
drm_dp_get_mst_branch_device_by_guid(struct drm_dp_mst_topology_mgr *mgr,
2599-
const uint8_t *guid)
2602+
const guid_t *guid)
26002603
{
26012604
struct drm_dp_mst_branch *mstb;
26022605
int ret;
@@ -2693,17 +2696,20 @@ static void drm_dp_mst_link_probe_work(struct work_struct *work)
26932696
}
26942697

26952698
static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
2696-
u8 *guid)
2699+
guid_t *guid)
26972700
{
26982701
u64 salt;
2702+
u8 buf[UUID_SIZE];
26992703

2700-
if (memchr_inv(guid, 0, 16))
2704+
if (!guid_is_null(guid))
27012705
return true;
27022706

27032707
salt = get_jiffies_64();
27042708

2705-
memcpy(&guid[0], &salt, sizeof(u64));
2706-
memcpy(&guid[8], &salt, sizeof(u64));
2709+
memcpy(&buf[0], &salt, sizeof(u64));
2710+
memcpy(&buf[8], &salt, sizeof(u64));
2711+
2712+
import_guid(guid, buf);
27072713

27082714
return false;
27092715
}
@@ -2943,7 +2949,7 @@ static int drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
29432949
drm_dbg_kms(mgr->dev, "link address reply: %d\n", reply->nports);
29442950
drm_dp_dump_link_address(mgr, reply);
29452951

2946-
ret = drm_dp_check_mstb_guid(mstb, reply->guid);
2952+
ret = drm_dp_check_mstb_guid(mstb, &reply->guid);
29472953
if (ret) {
29482954
char buf[64];
29492955

@@ -3770,8 +3776,9 @@ EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend);
37703776
int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr,
37713777
bool sync)
37723778
{
3779+
u8 buf[UUID_SIZE];
3780+
guid_t guid;
37733781
int ret;
3774-
u8 guid[16];
37753782

37763783
mutex_lock(&mgr->lock);
37773784
if (!mgr->mst_primary)
@@ -3792,13 +3799,15 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr,
37923799
}
37933800

37943801
/* Some hubs forget their guids after they resume */
3795-
ret = drm_dp_dpcd_read(mgr->aux, DP_GUID, guid, 16);
3796-
if (ret != 16) {
3802+
ret = drm_dp_dpcd_read(mgr->aux, DP_GUID, buf, sizeof(buf));
3803+
if (ret != sizeof(buf)) {
37973804
drm_dbg_kms(mgr->dev, "dpcd read failed - undocked during suspend?\n");
37983805
goto out_fail;
37993806
}
38003807

3801-
ret = drm_dp_check_mstb_guid(mgr->mst_primary, guid);
3808+
import_guid(&guid, buf);
3809+
3810+
ret = drm_dp_check_mstb_guid(mgr->mst_primary, &guid);
38023811
if (ret) {
38033812
drm_dbg_kms(mgr->dev, "check mstb failed - undocked during suspend?\n");
38043813
goto out_fail;
@@ -3976,12 +3985,12 @@ drm_dp_mst_process_up_req(struct drm_dp_mst_topology_mgr *mgr,
39763985
bool hotplug = false, dowork = false;
39773986

39783987
if (hdr->broadcast) {
3979-
const u8 *guid = NULL;
3988+
const guid_t *guid = NULL;
39803989

39813990
if (msg->req_type == DP_CONNECTION_STATUS_NOTIFY)
3982-
guid = msg->u.conn_stat.guid;
3991+
guid = &msg->u.conn_stat.guid;
39833992
else if (msg->req_type == DP_RESOURCE_STATUS_NOTIFY)
3984-
guid = msg->u.resource_stat.guid;
3993+
guid = &msg->u.resource_stat.guid;
39853994

39863995
if (guid)
39873996
mstb = drm_dp_get_mst_branch_device_by_guid(mgr, guid);

include/drm/display/drm_dp_mst_helper.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,18 @@ struct drm_dp_mst_branch {
244244
bool link_address_sent;
245245

246246
/* global unique identifier to identify branch devices */
247-
u8 guid[16];
247+
guid_t guid;
248248
};
249249

250250

251251
struct drm_dp_nak_reply {
252-
u8 guid[16];
252+
guid_t guid;
253253
u8 reason;
254254
u8 nak_data;
255255
};
256256

257257
struct drm_dp_link_address_ack_reply {
258-
u8 guid[16];
258+
guid_t guid;
259259
u8 nports;
260260
struct drm_dp_link_addr_reply_port {
261261
bool input_port;
@@ -265,7 +265,7 @@ struct drm_dp_link_address_ack_reply {
265265
bool ddps;
266266
bool legacy_device_plug_status;
267267
u8 dpcd_revision;
268-
u8 peer_guid[16];
268+
guid_t peer_guid;
269269
u8 num_sdp_streams;
270270
u8 num_sdp_stream_sinks;
271271
} ports[16];
@@ -348,7 +348,7 @@ struct drm_dp_allocate_payload_ack_reply {
348348
};
349349

350350
struct drm_dp_connection_status_notify {
351-
u8 guid[16];
351+
guid_t guid;
352352
u8 port_number;
353353
bool legacy_device_plug_status;
354354
bool displayport_device_plug_status;
@@ -425,7 +425,7 @@ struct drm_dp_query_payload {
425425

426426
struct drm_dp_resource_status_notify {
427427
u8 port_number;
428-
u8 guid[16];
428+
guid_t guid;
429429
u16 available_pbn;
430430
};
431431

0 commit comments

Comments
 (0)