Snap for 6875707 from 64b90636241aa48d0b720d86552e491e4f2cd089 to rvc-qpr1-release
Change-Id: If9a622629102bbfbee126f45d7f48bb97d3f4bfc
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index b0bea61..2f4682e 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -5961,8 +5961,31 @@
} else {
if (os_get_random((u8 *) &r, sizeof(r)) < 0)
return -1;
- freq = 5180 + (r % 4) * 20;
- if (!p2p_supported_freq_go(wpa_s->global->p2p, freq)) {
+
+ /*
+ * most of 5G channels are DFS, only operating class 115 and 124
+ * are available possibly, randomly pick a start to check them.
+ */
+ int possible_5g_freqs[] = {
+ /* operating class 115 */
+ 5180, 5200, 5220, 5240,
+ /* operating class 124 */
+ 5745, 5765, 5785, 5805,
+ };
+ int possible_5g_freqs_num =
+ sizeof(possible_5g_freqs)/sizeof(possible_5g_freqs[0]);
+
+ int i;
+ for (i = 0; i < possible_5g_freqs_num; i++, r++) {
+ if (p2p_supported_freq_go(
+ wpa_s->global->p2p,
+ possible_5g_freqs[r % possible_5g_freqs_num])) {
+ freq = possible_5g_freqs[r % possible_5g_freqs_num];
+ break;
+ }
+ }
+
+ if (i >= possible_5g_freqs_num) {
wpa_printf(MSG_DEBUG, "P2P: Could not select "
"5 GHz channel for P2P group");
return -1;