Merge tag 'net-next-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev...
[platform/kernel/linux-starfive.git] / drivers / net / wireless / ath / ath11k / qmi.c
index 26b252e..d4eaf7d 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: BSD-3-Clause-Clear
 /*
  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
- * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/elf.h>
@@ -1755,7 +1755,7 @@ static int ath11k_qmi_host_cap_send(struct ath11k_base *ab)
 
        req.nm_modem |= PLATFORM_CAP_PCIE_PME_D3COLD;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi host cap request\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "host cap request\n");
 
        ret = qmi_txn_init(&ab->qmi.handle, &txn,
                           qmi_wlanfw_host_cap_resp_msg_v01_ei, &resp);
@@ -1833,7 +1833,7 @@ static int ath11k_qmi_fw_ind_register_send(struct ath11k_base *ab)
        if (ret < 0)
                goto out;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi indication register request\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "indication register request\n");
 
        ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
                               QMI_WLANFW_IND_REGISTER_REQ_V01,
@@ -1889,7 +1889,7 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
              test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags)) &&
              ab->qmi.target_mem_delayed) {
                delayed = true;
-               ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi delays mem_request %d\n",
+               ath11k_dbg(ab, ATH11K_DBG_QMI, "delays mem_request %d\n",
                           ab->qmi.mem_seg_count);
                memset(req, 0, sizeof(*req));
        } else {
@@ -1901,7 +1901,7 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
                        req->mem_seg[i].size = ab->qmi.target_mem[i].size;
                        req->mem_seg[i].type = ab->qmi.target_mem[i].type;
                        ath11k_dbg(ab, ATH11K_DBG_QMI,
-                                  "qmi req mem_seg[%d] %pad %u %u\n", i,
+                                  "req mem_seg[%d] %pad %u %u\n", i,
                                    &ab->qmi.target_mem[i].paddr,
                                    ab->qmi.target_mem[i].size,
                                    ab->qmi.target_mem[i].type);
@@ -1913,7 +1913,7 @@ static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
        if (ret < 0)
                goto out;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi respond memory request delayed %i\n",
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "respond memory request delayed %i\n",
                   delayed);
 
        ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
@@ -2002,7 +2002,7 @@ static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab)
                if (!chunk->vaddr) {
                        if (ab->qmi.mem_seg_count <= ATH11K_QMI_FW_MEM_REQ_SEGMENT_CNT) {
                                ath11k_dbg(ab, ATH11K_DBG_QMI,
-                                          "qmi dma allocation failed (%d B type %u), will try later with small size\n",
+                                          "dma allocation failed (%d B type %u), will try later with small size\n",
                                            chunk->size,
                                            chunk->type);
                                ath11k_qmi_free_target_mem_chunk(ab);
@@ -2036,7 +2036,7 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
                        hremote_node = of_parse_phandle(dev->of_node, "memory-region", 0);
                        if (!hremote_node) {
                                ath11k_dbg(ab, ATH11K_DBG_QMI,
-                                          "qmi fail to get hremote_node\n");
+                                          "fail to get hremote_node\n");
                                return -ENODEV;
                        }
 
@@ -2044,13 +2044,13 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
                        of_node_put(hremote_node);
                        if (ret) {
                                ath11k_dbg(ab, ATH11K_DBG_QMI,
-                                          "qmi fail to get reg from hremote\n");
+                                          "fail to get reg from hremote\n");
                                return ret;
                        }
 
                        if (res.end - res.start + 1 < ab->qmi.target_mem[i].size) {
                                ath11k_dbg(ab, ATH11K_DBG_QMI,
-                                          "qmi fail to assign memory of sz\n");
+                                          "fail to assign memory of sz\n");
                                return -EINVAL;
                        }
 
@@ -2058,6 +2058,9 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
                        ab->qmi.target_mem[idx].iaddr =
                                ioremap(ab->qmi.target_mem[idx].paddr,
                                        ab->qmi.target_mem[i].size);
+                       if (!ab->qmi.target_mem[idx].iaddr)
+                               return -EIO;
+
                        ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size;
                        host_ddr_sz = ab->qmi.target_mem[i].size;
                        ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type;
@@ -2083,6 +2086,8 @@ static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
                                        ab->qmi.target_mem[idx].iaddr =
                                                ioremap(ab->qmi.target_mem[idx].paddr,
                                                        ab->qmi.target_mem[i].size);
+                                       if (!ab->qmi.target_mem[idx].iaddr)
+                                               return -EIO;
                                } else {
                                        ab->qmi.target_mem[idx].paddr =
                                                ATH11K_QMI_CALDB_ADDRESS;
@@ -2198,7 +2203,7 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab)
        if (ret < 0)
                goto out;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi target cap request\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "target cap request\n");
 
        ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
                               QMI_WLANFW_CAP_REQ_V01,
@@ -2251,7 +2256,7 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab)
        if (resp.eeprom_read_timeout_valid) {
                ab->qmi.target.eeprom_caldata =
                                        resp.eeprom_read_timeout;
-               ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi cal data supported from eeprom\n");
+               ath11k_dbg(ab, ATH11K_DBG_QMI, "cal data supported from eeprom\n");
        }
 
        fw_build_id = ab->qmi.target.fw_build_id;
@@ -2348,7 +2353,7 @@ static int ath11k_qmi_load_file_target_mem(struct ath11k_base *ab,
                if (ret < 0)
                        goto err_iounmap;
 
-               ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi bdf download req fixed addr type %d\n",
+               ath11k_dbg(ab, ATH11K_DBG_QMI, "bdf download req fixed addr type %d\n",
                           type);
 
                ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
@@ -2381,7 +2386,7 @@ static int ath11k_qmi_load_file_target_mem(struct ath11k_base *ab,
                        remaining -= req->data_len;
                        temp += req->data_len;
                        req->seg_id++;
-                       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi bdf download request remaining %i\n",
+                       ath11k_dbg(ab, ATH11K_DBG_QMI, "bdf download request remaining %i\n",
                                   remaining);
                }
        }
@@ -2427,7 +2432,7 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab,
        else
                bdf_type = ATH11K_QMI_BDF_TYPE_BIN;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi bdf_type %d\n", bdf_type);
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "bdf_type %d\n", bdf_type);
 
        fw_size = min_t(u32, ab->hw_params.fw.board_size, bd.len);
 
@@ -2457,6 +2462,14 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab,
 
                fw_entry = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_CAL_FILE);
                if (IS_ERR(fw_entry)) {
+                       /* Caldata may not be present during first time calibration in
+                        * factory hence allow to boot without loading caldata in ftm mode
+                        */
+                       if (ath11k_ftm_mode) {
+                               ath11k_info(ab,
+                                           "Booting without cal data file in factory test mode\n");
+                               return 0;
+                       }
                        ret = PTR_ERR(fw_entry);
                        ath11k_warn(ab,
                                    "qmi failed to load CAL data file:%s\n",
@@ -2474,14 +2487,14 @@ success:
                goto out_qmi_cal;
        }
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi caldata type: %u\n", file_type);
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "caldata type: %u\n", file_type);
 
 out_qmi_cal:
        if (!ab->qmi.target.eeprom_caldata)
                release_firmware(fw_entry);
 out:
        ath11k_core_free_bdf(ab, &bd);
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi BDF download sequence completed\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "BDF download sequence completed\n");
 
        return ret;
 }
@@ -2566,7 +2579,7 @@ static int ath11k_qmi_wlanfw_m3_info_send(struct ath11k_base *ab)
        if (ret < 0)
                goto out;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi m3 info req\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "m3 info req\n");
 
        ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
                               QMI_WLANFW_M3_INFO_REQ_V01,
@@ -2615,7 +2628,7 @@ static int ath11k_qmi_wlanfw_mode_send(struct ath11k_base *ab,
        if (ret < 0)
                goto out;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wlan mode req mode %d\n", mode);
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "wlan mode req mode %d\n", mode);
 
        ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
                               QMI_WLANFW_WLAN_MODE_REQ_V01,
@@ -2710,7 +2723,7 @@ static int ath11k_qmi_wlanfw_wlan_cfg_send(struct ath11k_base *ab)
        if (ret < 0)
                goto out;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wlan cfg req\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "wlan cfg req\n");
 
        ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
                               QMI_WLANFW_WLAN_CFG_REQ_V01,
@@ -2787,7 +2800,7 @@ void ath11k_qmi_firmware_stop(struct ath11k_base *ab)
 {
        int ret;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware stop\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware stop\n");
 
        ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_OFF);
        if (ret < 0) {
@@ -2801,7 +2814,7 @@ int ath11k_qmi_firmware_start(struct ath11k_base *ab,
 {
        int ret;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware start\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware start\n");
 
        if (ab->hw_params.fw_wmi_diag_event) {
                ret = ath11k_qmi_wlanfw_wlan_ini_send(ab, true);
@@ -2959,7 +2972,7 @@ static void ath11k_qmi_msg_mem_request_cb(struct qmi_handle *qmi_hdl,
        const struct qmi_wlanfw_request_mem_ind_msg_v01 *msg = data;
        int i, ret;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware request memory request\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware request memory request\n");
 
        if (msg->mem_seg_len == 0 ||
            msg->mem_seg_len > ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01)
@@ -2971,7 +2984,7 @@ static void ath11k_qmi_msg_mem_request_cb(struct qmi_handle *qmi_hdl,
        for (i = 0; i < qmi->mem_seg_count ; i++) {
                ab->qmi.target_mem[i].type = msg->mem_seg[i].type;
                ab->qmi.target_mem[i].size = msg->mem_seg[i].size;
-               ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi mem seg type %d size %d\n",
+               ath11k_dbg(ab, ATH11K_DBG_QMI, "mem seg type %d size %d\n",
                           msg->mem_seg[i].type, msg->mem_seg[i].size);
        }
 
@@ -3003,7 +3016,7 @@ static void ath11k_qmi_msg_mem_ready_cb(struct qmi_handle *qmi_hdl,
        struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);
        struct ath11k_base *ab = qmi->ab;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware memory ready indication\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware memory ready indication\n");
        ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_FW_MEM_READY, NULL);
 }
 
@@ -3015,7 +3028,7 @@ static void ath11k_qmi_msg_fw_ready_cb(struct qmi_handle *qmi_hdl,
        struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);
        struct ath11k_base *ab = qmi->ab;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware ready\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware ready\n");
 
        if (!ab->qmi.cal_done) {
                ab->qmi.cal_done = 1;
@@ -3036,7 +3049,7 @@ static void ath11k_qmi_msg_cold_boot_cal_done_cb(struct qmi_handle *qmi_hdl,
 
        ab->qmi.cal_done = 1;
        wake_up(&ab->qmi.cold_boot_waitq);
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi cold boot calibration done\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "cold boot calibration done\n");
 }
 
 static void ath11k_qmi_msg_fw_init_done_cb(struct qmi_handle *qmi_hdl,
@@ -3049,7 +3062,7 @@ static void ath11k_qmi_msg_fw_init_done_cb(struct qmi_handle *qmi_hdl,
        struct ath11k_base *ab = qmi->ab;
 
        ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_FW_INIT_DONE, NULL);
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware init done\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware init done\n");
 }
 
 static const struct qmi_msg_handler ath11k_qmi_msg_handlers[] = {
@@ -3114,7 +3127,7 @@ static int ath11k_qmi_ops_new_server(struct qmi_handle *qmi_hdl,
                return ret;
        }
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wifi fw qmi service connected\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "wifi fw qmi service connected\n");
        ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_SERVER_ARRIVE, NULL);
 
        return ret;
@@ -3126,7 +3139,7 @@ static void ath11k_qmi_ops_del_server(struct qmi_handle *qmi_hdl,
        struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);
        struct ath11k_base *ab = qmi->ab;
 
-       ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wifi fw del server\n");
+       ath11k_dbg(ab, ATH11K_DBG_QMI, "wifi fw del server\n");
        ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_SERVER_EXIT, NULL);
 }