hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
....@@ -19,11 +19,6 @@
1919 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2020 * General Public License for more details.
2121 *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program; if not, write to the Free Software
24
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
25
- * USA
26
- *
2722 * The full GNU General Public License is included in this distribution
2823 * in the file called COPYING.
2924 *
....@@ -183,8 +178,8 @@
183178 } else {
184179 IWL_DEBUG_EEPROM(mvm->trans->dev,
185180 "NVM access command failed with status %d (device: %s)\n",
186
- ret, mvm->cfg->name);
187
- ret = -EIO;
181
+ ret, mvm->trans->name);
182
+ ret = -ENODATA;
188183 }
189184 goto exit;
190185 }
....@@ -254,7 +249,7 @@
254249 while (ret == length) {
255250 /* Check no memory assumptions fail and cause an overflow */
256251 if ((size_read + offset + length) >
257
- mvm->cfg->base_params->eeprom_size) {
252
+ mvm->trans->trans_cfg->base_params->eeprom_size) {
258253 IWL_ERR(mvm, "EEPROM size is too small for NVM\n");
259254 return -ENOBUFS;
260255 }
....@@ -282,7 +277,6 @@
282277 struct iwl_nvm_section *sections = mvm->nvm_sections;
283278 const __be16 *hw;
284279 const __le16 *sw, *calib, *regulatory, *mac_override, *phy_sku;
285
- bool lar_enabled;
286280 int regulatory_type;
287281
288282 /* Checking for required sections */
....@@ -333,14 +327,9 @@
333327 (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY_SDP].data :
334328 (const __le16 *)sections[NVM_SECTION_TYPE_REGULATORY].data;
335329
336
- lar_enabled = !iwlwifi_mod_params.lar_disable &&
337
- fw_has_capa(&mvm->fw->ucode_capa,
338
- IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
339
-
340
- return iwl_parse_nvm_data(mvm->trans, mvm->cfg, hw, sw, calib,
330
+ return iwl_parse_nvm_data(mvm->trans, mvm->cfg, mvm->fw, hw, sw, calib,
341331 regulatory, mac_override, phy_sku,
342
- mvm->fw->valid_tx_ant, mvm->fw->valid_rx_ant,
343
- lar_enabled);
332
+ mvm->fw->valid_tx_ant, mvm->fw->valid_rx_ant);
344333 }
345334
346335 /* Loads the NVM data stored in mvm->nvm_sections into the NIC */
....@@ -378,7 +367,7 @@
378367 /* Read From FW NVM */
379368 IWL_DEBUG_EEPROM(mvm->trans->dev, "Read from NVM\n");
380369
381
- nvm_buffer = kmalloc(mvm->cfg->base_params->eeprom_size,
370
+ nvm_buffer = kmalloc(mvm->trans->trans_cfg->base_params->eeprom_size,
382371 GFP_KERNEL);
383372 if (!nvm_buffer)
384373 return -ENOMEM;
....@@ -386,8 +375,12 @@
386375 /* we override the constness for initial read */
387376 ret = iwl_nvm_read_section(mvm, section, nvm_buffer,
388377 size_read);
389
- if (ret < 0)
378
+ if (ret == -ENODATA) {
379
+ ret = 0;
390380 continue;
381
+ }
382
+ if (ret < 0)
383
+ break;
391384 size_read += ret;
392385 temp = kmemdup(nvm_buffer, ret, GFP_KERNEL);
393386 if (!temp) {
....@@ -417,6 +410,11 @@
417410 case NVM_SECTION_TYPE_PHY_SKU:
418411 mvm->nvm_phy_sku_blob.data = temp;
419412 mvm->nvm_phy_sku_blob.size = ret;
413
+ break;
414
+ case NVM_SECTION_TYPE_REGULATORY_SDP:
415
+ case NVM_SECTION_TYPE_REGULATORY:
416
+ mvm->nvm_reg_blob.data = temp;
417
+ mvm->nvm_reg_blob.size = ret;
420418 break;
421419 default:
422420 if (section == mvm->cfg->nvm_hw_section_num) {
....@@ -460,7 +458,7 @@
460458 IWL_DEBUG_EEPROM(mvm->trans->dev, "nvm version = %x\n",
461459 mvm->nvm_data->nvm_version);
462460
463
- return 0;
461
+ return ret < 0 ? ret : 0;
464462 }
465463
466464 struct iwl_mcc_update_resp *
....@@ -483,15 +481,11 @@
483481 u32 status;
484482 int resp_len, n_channels;
485483 u16 mcc;
486
- bool resp_v2 = fw_has_capa(&mvm->fw->ucode_capa,
487
- IWL_UCODE_TLV_CAPA_LAR_SUPPORT_V2);
488484
489485 if (WARN_ON_ONCE(!iwl_mvm_is_lar_supported(mvm)))
490486 return ERR_PTR(-EOPNOTSUPP);
491487
492488 cmd.len[0] = sizeof(struct iwl_mcc_update_cmd);
493
- if (!resp_v2)
494
- cmd.len[0] = sizeof(struct iwl_mcc_update_cmd_v1);
495489
496490 IWL_DEBUG_LAR(mvm, "send MCC update to FW with '%c%c' src = %d\n",
497491 alpha2[0], alpha2[1], src_id);
....@@ -503,7 +497,8 @@
503497 pkt = cmd.resp_pkt;
504498
505499 /* Extract MCC response */
506
- if (resp_v2) {
500
+ if (fw_has_capa(&mvm->fw->ucode_capa,
501
+ IWL_UCODE_TLV_CAPA_MCC_UPDATE_11AX_SUPPORT)) {
507502 struct iwl_mcc_update_resp *mcc_resp = (void *)pkt->data;
508503
509504 n_channels = __le32_to_cpu(mcc_resp->n_channels);
....@@ -515,9 +510,9 @@
515510 goto exit;
516511 }
517512 } else {
518
- struct iwl_mcc_update_resp_v1 *mcc_resp_v1 = (void *)pkt->data;
513
+ struct iwl_mcc_update_resp_v3 *mcc_resp_v3 = (void *)pkt->data;
519514
520
- n_channels = __le32_to_cpu(mcc_resp_v1->n_channels);
515
+ n_channels = __le32_to_cpu(mcc_resp_v3->n_channels);
521516 resp_len = sizeof(struct iwl_mcc_update_resp) +
522517 n_channels * sizeof(__le32);
523518 resp_cp = kzalloc(resp_len, GFP_KERNEL);
....@@ -526,12 +521,14 @@
526521 goto exit;
527522 }
528523
529
- resp_cp->status = mcc_resp_v1->status;
530
- resp_cp->mcc = mcc_resp_v1->mcc;
531
- resp_cp->cap = mcc_resp_v1->cap;
532
- resp_cp->source_id = mcc_resp_v1->source_id;
533
- resp_cp->n_channels = mcc_resp_v1->n_channels;
534
- memcpy(resp_cp->channels, mcc_resp_v1->channels,
524
+ resp_cp->status = mcc_resp_v3->status;
525
+ resp_cp->mcc = mcc_resp_v3->mcc;
526
+ resp_cp->cap = cpu_to_le16(mcc_resp_v3->cap);
527
+ resp_cp->source_id = mcc_resp_v3->source_id;
528
+ resp_cp->time = mcc_resp_v3->time;
529
+ resp_cp->geo_info = mcc_resp_v3->geo_info;
530
+ resp_cp->n_channels = mcc_resp_v3->n_channels;
531
+ memcpy(resp_cp->channels, mcc_resp_v3->channels,
535532 n_channels * sizeof(__le32));
536533 }
537534
....@@ -618,6 +615,7 @@
618615 enum iwl_mcc_source src;
619616 char mcc[3];
620617 struct ieee80211_regdomain *regd;
618
+ int wgds_tbl_idx;
621619
622620 lockdep_assert_held(&mvm->mutex);
623621
....@@ -641,6 +639,14 @@
641639 if (IS_ERR_OR_NULL(regd))
642640 return;
643641
642
+ wgds_tbl_idx = iwl_mvm_get_sar_geo_profile(mvm);
643
+ if (wgds_tbl_idx < 0)
644
+ IWL_DEBUG_INFO(mvm, "SAR WGDS is disabled (%d)\n",
645
+ wgds_tbl_idx);
646
+ else
647
+ IWL_DEBUG_INFO(mvm, "SAR WGDS: geo profile %d is configured\n",
648
+ wgds_tbl_idx);
649
+
644650 regulatory_set_wiphy_regd(mvm->hw->wiphy, regd);
645651 kfree(regd);
646652 }