@@ -89,7 +89,7 @@ static int drm_dp_send_enum_path_resources(struct drm_dp_mst_topology_mgr *mgr,
89
89
struct drm_dp_mst_branch * mstb ,
90
90
struct drm_dp_mst_port * port );
91
91
static bool drm_dp_validate_guid (struct drm_dp_mst_topology_mgr * mgr ,
92
- u8 * guid );
92
+ guid_t * guid );
93
93
94
94
static int drm_dp_mst_register_i2c_bus (struct drm_dp_mst_port * port );
95
95
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
801
int idx = 1 ;
802
802
int i ;
803
803
804
- memcpy ( repmsg -> u .link_addr .guid , & raw -> msg [idx ], 16 );
804
+ import_guid ( & repmsg -> u .link_addr .guid , & raw -> msg [idx ]);
805
805
idx += 16 ;
806
806
repmsg -> u .link_addr .nports = raw -> msg [idx ] & 0xf ;
807
807
idx ++ ;
@@ -829,7 +829,7 @@ static bool drm_dp_sideband_parse_link_address(const struct drm_dp_mst_topology_
829
829
idx ++ ;
830
830
if (idx > raw -> curlen )
831
831
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 ]);
833
833
idx += 16 ;
834
834
if (idx > raw -> curlen )
835
835
goto fail_len ;
@@ -1029,7 +1029,7 @@ static bool drm_dp_sideband_parse_reply(const struct drm_dp_mst_topology_mgr *mg
1029
1029
msg -> req_type = (raw -> msg [0 ] & 0x7f );
1030
1030
1031
1031
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 ]);
1033
1033
msg -> u .nak .reason = raw -> msg [17 ];
1034
1034
msg -> u .nak .nak_data = raw -> msg [18 ];
1035
1035
return false;
@@ -1078,7 +1078,7 @@ drm_dp_sideband_parse_connection_status_notify(const struct drm_dp_mst_topology_
1078
1078
if (idx > raw -> curlen )
1079
1079
goto fail_len ;
1080
1080
1081
- memcpy ( msg -> u .conn_stat .guid , & raw -> msg [idx ], 16 );
1081
+ import_guid ( & msg -> u .conn_stat .guid , & raw -> msg [idx ]);
1082
1082
idx += 16 ;
1083
1083
if (idx > raw -> curlen )
1084
1084
goto fail_len ;
@@ -1107,7 +1107,7 @@ static bool drm_dp_sideband_parse_resource_status_notify(const struct drm_dp_mst
1107
1107
if (idx > raw -> curlen )
1108
1108
goto fail_len ;
1109
1109
1110
- memcpy ( msg -> u .resource_stat .guid , & raw -> msg [idx ], 16 );
1110
+ import_guid ( & msg -> u .resource_stat .guid , & raw -> msg [idx ]);
1111
1111
idx += 16 ;
1112
1112
if (idx > raw -> curlen )
1113
1113
goto fail_len ;
@@ -2174,20 +2174,24 @@ ssize_t drm_dp_mst_dpcd_write(struct drm_dp_aux *aux,
2174
2174
offset , size , buffer );
2175
2175
}
2176
2176
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 )
2178
2178
{
2179
2179
int ret = 0 ;
2180
2180
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 );
2182
2187
2183
- if (!drm_dp_validate_guid (mstb -> mgr , mstb -> guid )) {
2184
2188
if (mstb -> port_parent ) {
2185
2189
ret = drm_dp_send_dpcd_write (mstb -> mgr ,
2186
2190
mstb -> port_parent ,
2187
- DP_GUID , 16 , mstb -> guid );
2191
+ DP_GUID , sizeof ( buf ), buf );
2188
2192
} else {
2189
2193
ret = drm_dp_dpcd_write (mstb -> mgr -> aux ,
2190
- DP_GUID , mstb -> guid , 16 );
2194
+ DP_GUID , buf , sizeof ( buf ) );
2191
2195
}
2192
2196
}
2193
2197
@@ -2570,20 +2574,19 @@ static struct drm_dp_mst_branch *drm_dp_get_mst_branch_device(struct drm_dp_mst_
2570
2574
return mstb ;
2571
2575
}
2572
2576
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 )
2576
2580
{
2577
2581
struct drm_dp_mst_branch * found_mstb ;
2578
2582
struct drm_dp_mst_port * port ;
2579
2583
2580
2584
if (!mstb )
2581
2585
return NULL ;
2582
2586
2583
- if (memcmp ( mstb -> guid , guid , 16 ) == 0 )
2587
+ if (guid_equal ( & mstb -> guid , guid ) )
2584
2588
return mstb ;
2585
2589
2586
-
2587
2590
list_for_each_entry (port , & mstb -> ports , next ) {
2588
2591
found_mstb = get_mst_branch_device_by_guid_helper (port -> mstb , guid );
2589
2592
@@ -2596,7 +2599,7 @@ static struct drm_dp_mst_branch *get_mst_branch_device_by_guid_helper(
2596
2599
2597
2600
static struct drm_dp_mst_branch *
2598
2601
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 )
2600
2603
{
2601
2604
struct drm_dp_mst_branch * mstb ;
2602
2605
int ret ;
@@ -2693,17 +2696,20 @@ static void drm_dp_mst_link_probe_work(struct work_struct *work)
2693
2696
}
2694
2697
2695
2698
static bool drm_dp_validate_guid (struct drm_dp_mst_topology_mgr * mgr ,
2696
- u8 * guid )
2699
+ guid_t * guid )
2697
2700
{
2698
2701
u64 salt ;
2702
+ u8 buf [UUID_SIZE ];
2699
2703
2700
- if (memchr_inv (guid , 0 , 16 ))
2704
+ if (! guid_is_null (guid ))
2701
2705
return true;
2702
2706
2703
2707
salt = get_jiffies_64 ();
2704
2708
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 );
2707
2713
2708
2714
return false;
2709
2715
}
@@ -2943,7 +2949,7 @@ static int drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
2943
2949
drm_dbg_kms (mgr -> dev , "link address reply: %d\n" , reply -> nports );
2944
2950
drm_dp_dump_link_address (mgr , reply );
2945
2951
2946
- ret = drm_dp_check_mstb_guid (mstb , reply -> guid );
2952
+ ret = drm_dp_check_mstb_guid (mstb , & reply -> guid );
2947
2953
if (ret ) {
2948
2954
char buf [64 ];
2949
2955
@@ -3770,8 +3776,9 @@ EXPORT_SYMBOL(drm_dp_mst_topology_mgr_suspend);
3770
3776
int drm_dp_mst_topology_mgr_resume (struct drm_dp_mst_topology_mgr * mgr ,
3771
3777
bool sync )
3772
3778
{
3779
+ u8 buf [UUID_SIZE ];
3780
+ guid_t guid ;
3773
3781
int ret ;
3774
- u8 guid [16 ];
3775
3782
3776
3783
mutex_lock (& mgr -> lock );
3777
3784
if (!mgr -> mst_primary )
@@ -3792,13 +3799,15 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr,
3792
3799
}
3793
3800
3794
3801
/* 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 ) ) {
3797
3804
drm_dbg_kms (mgr -> dev , "dpcd read failed - undocked during suspend?\n" );
3798
3805
goto out_fail ;
3799
3806
}
3800
3807
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 );
3802
3811
if (ret ) {
3803
3812
drm_dbg_kms (mgr -> dev , "check mstb failed - undocked during suspend?\n" );
3804
3813
goto out_fail ;
@@ -3976,12 +3985,12 @@ drm_dp_mst_process_up_req(struct drm_dp_mst_topology_mgr *mgr,
3976
3985
bool hotplug = false, dowork = false;
3977
3986
3978
3987
if (hdr -> broadcast ) {
3979
- const u8 * guid = NULL ;
3988
+ const guid_t * guid = NULL ;
3980
3989
3981
3990
if (msg -> req_type == DP_CONNECTION_STATUS_NOTIFY )
3982
- guid = msg -> u .conn_stat .guid ;
3991
+ guid = & msg -> u .conn_stat .guid ;
3983
3992
else if (msg -> req_type == DP_RESOURCE_STATUS_NOTIFY )
3984
- guid = msg -> u .resource_stat .guid ;
3993
+ guid = & msg -> u .resource_stat .guid ;
3985
3994
3986
3995
if (guid )
3987
3996
mstb = drm_dp_get_mst_branch_device_by_guid (mgr , guid );
0 commit comments