From patchwork Tue Sep 13 21:11:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Faltesek X-Patchwork-Id: 9329963 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B1566077F for ; Tue, 13 Sep 2016 21:12:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8818329744 for ; Tue, 13 Sep 2016 21:12:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CA9429765; Tue, 13 Sep 2016 21:12:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1A89A29744 for ; Tue, 13 Sep 2016 21:12:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bjv0Z-0008F5-9O; Tue, 13 Sep 2016 21:12:47 +0000 Received: from mail-qk0-x233.google.com ([2607:f8b0:400d:c09::233]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bjv0W-0008EX-4L for ath10k@lists.infradead.org; Tue, 13 Sep 2016 21:12:45 +0000 Received: by mail-qk0-x233.google.com with SMTP id w204so189444325qka.0 for ; Tue, 13 Sep 2016 14:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Z39XFLx8jWeGqKb7ytGAcggSeouEU0E0/1Vrn1z6Mzg=; b=BgUqYR2WXVD2w/Rh92PtsZ4UqqfhaPD4+u0F18mF4B0R6oKBHC2xUyAHVqCDuG25RJ 467iPCNCRJ9CBpUEknlhSeWs+JB2nVoA0BguTLVTb+LcbeNuz0ZKhCy+Kvsxon8FOM65 m8JxO7/oK4XZ/TtlX3OcgAjKTAxpMZWziWccNmrFjGMVjUgudW0xM2ef533pcAAiFbRh aSlpAmjIkz+fsuQG+iH/5EPh7Jo/Qi1YU5r8Ni3Kv4ZaIy+B5rcVrYqXdO7kFwqIHMIe 7qhCifW91Y7mo6v8yANcZhFYCAZU+P9goQAAyTQHRd3WUwVPWMizHXHITQBmNbSoWwZL 2tDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Z39XFLx8jWeGqKb7ytGAcggSeouEU0E0/1Vrn1z6Mzg=; b=Ud9DOY4uQ3zQ1IHMNTsxJCCVXW0x9O7pacxNIxCHD518oL+FnUM9+MoeyXRTgmEOUA 1LCzAI3iEV8GYW9Y1t7V92YErVsZwS3FyYTkabJhFX2bNzIqh0E1x6kzdkbXn2SmtR4q 3Ps8lzuBBZ/rJ41LX0wGU4GaeJe8xbc8qB7MqLhRAnVee6AJNjb65SyQA2C1h/dwKMM+ W2TtEwKfZIE5rE2ty8ACKOenvsSNzO1p6uU6rDbpdfX7cTXR+lAZlvATYPZBl6wufpOk XG3GAU1TwreTQYDHD89NYnyQwX8ZXojrJim6K2j71vccNmhdfjul2PiIZ4AOv5Rcmrby BBIQ== X-Gm-Message-State: AE9vXwOaa654YWydyWvVyhtbLgA6ZKTiTqzTae9B1EeZBW5D3jaOUNWjQ9Ra3PdxsyE6h8wW X-Received: by 10.55.21.13 with SMTP id f13mr3899890qkh.244.1473801139031; Tue, 13 Sep 2016 14:12:19 -0700 (PDT) Received: from mfaltesek01.nyc.corp.google.com ([172.26.80.27]) by smtp.googlemail.com with ESMTPSA id m201sm379173qke.46.2016.09.13.14.12.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Sep 2016 14:12:18 -0700 (PDT) From: Marty Faltesek To: ath10k@lists.infradead.org Subject: [PATCH] ath10k: cache calibration data when the core is stopped. Date: Tue, 13 Sep 2016 17:11:58 -0400 Message-Id: <1473801118-103112-1-git-send-email-mfaltesek@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160913_141244_295360_073B3017 X-CRM114-Status: GOOD ( 16.40 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Caching calibration data allows it to be accessed when the device is not active. Signed-off-by: Marty Faltesek --- drivers/net/wireless/ath/ath10k/core.c | 47 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/core.h | 2 ++ drivers/net/wireless/ath/ath10k/debug.c | 51 +++++++++------------------------ drivers/net/wireless/ath/ath10k/debug.h | 1 + drivers/net/wireless/ath/ath10k/mac.c | 1 + 5 files changed, 65 insertions(+), 37 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index c0b9797..c99ad9e 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -1227,6 +1227,42 @@ success: return 0; } +int +ath10k_cal_data_alloc(struct ath10k *ar, void **buf) +{ + u32 hi_addr; + __le32 addr; + int ret; + + vfree(*buf); + *buf = vmalloc(QCA988X_CAL_DATA_LEN); + if (!*buf) { + return -EAGAIN; + } + + hi_addr = host_interest_item_address(HI_ITEM(hi_board_data)); + + ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr)); + + if (ret) { + ath10k_warn(ar, "failed to read hi_board_data address: %d\n", ret); + } else { + ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), *buf, + QCA988X_CAL_DATA_LEN); + if (ret) { + ath10k_warn(ar, "failed to read calibration data: %d\n", ret); + } + } + + if (ret) { + vfree(*buf); + *buf = NULL; + } + + return ret; +} + + static int ath10k_download_cal_data(struct ath10k *ar) { int ret; @@ -1714,6 +1750,12 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode) INIT_LIST_HEAD(&ar->arvifs); + /* + * We are up now, so no need to cache calibration data. + */ + vfree(ar->cal_data); + ar->cal_data = NULL; + return 0; err_hif_stop: @@ -1757,6 +1799,11 @@ void ath10k_core_stop(struct ath10k *ar) lockdep_assert_held(&ar->conf_mutex); ath10k_debug_stop(ar); + /* + * Cache caclibration data while stopped. + */ + ath10k_cal_data_alloc(ar, &ar->cal_data); + /* try to suspend target */ if (ar->state != ATH10K_STATE_RESTARTING && ar->state != ATH10K_STATE_UTF) diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 4d3f002..cce61c1 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -635,6 +635,8 @@ struct ath10k { struct ath10k_htc htc; struct ath10k_htt htt; + void *cal_data; + struct ath10k_hw_params { u32 id; u16 dev_id; diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index 8b01e3e..7de0eb4 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -1427,53 +1427,26 @@ static const struct file_operations fops_fw_dbglog = { static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file) { struct ath10k *ar = inode->i_private; - void *buf; - u32 hi_addr; - __le32 addr; int ret; mutex_lock(&ar->conf_mutex); if (ar->state != ATH10K_STATE_ON && - ar->state != ATH10K_STATE_UTF) { - ret = -ENETDOWN; - goto err; - } - - buf = vmalloc(QCA988X_CAL_DATA_LEN); - if (!buf) { - ret = -ENOMEM; - goto err; + ar->state != ATH10K_STATE_UTF && ! ar->cal_data) { + mutex_unlock(&ar->conf_mutex); + return (-ENETDOWN); } - hi_addr = host_interest_item_address(HI_ITEM(hi_board_data)); - - ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr)); - if (ret) { - ath10k_warn(ar, "failed to read hi_board_data address: %d\n", ret); - goto err_vfree; - } - - ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), buf, - QCA988X_CAL_DATA_LEN); - if (ret) { - ath10k_warn(ar, "failed to read calibration data: %d\n", ret); - goto err_vfree; + if (ar->cal_data) { + file->private_data = ar->cal_data; + mutex_unlock(&ar->conf_mutex); + return 0; } - file->private_data = buf; - - mutex_unlock(&ar->conf_mutex); - - return 0; - -err_vfree: - vfree(buf); - -err: + ret = ath10k_cal_data_alloc(ar, &file->private_data); mutex_unlock(&ar->conf_mutex); - return ret; + return (ret); } static ssize_t ath10k_debug_cal_data_read(struct file *file, @@ -1489,7 +1462,11 @@ static ssize_t ath10k_debug_cal_data_read(struct file *file, static int ath10k_debug_cal_data_release(struct inode *inode, struct file *file) { - vfree(file->private_data); + struct ath10k *ar = inode->i_private; + + /* Free if it's not the cached version */ + if (ar->cal_data != file->private_data) + vfree(file->private_data); return 0; } diff --git a/drivers/net/wireless/ath/ath10k/debug.h b/drivers/net/wireless/ath/ath10k/debug.h index 3900934..1ae757c 100644 --- a/drivers/net/wireless/ath/ath10k/debug.h +++ b/drivers/net/wireless/ath/ath10k/debug.h @@ -59,6 +59,7 @@ enum ath10k_dbg_aggr_mode { #define ATH10K_FW_STATS_BUF_SIZE (1024*1024) extern unsigned int ath10k_debug_mask; +extern int ath10k_cal_data_alloc(struct ath10k *ar, void **buf); __printf(2, 3) void ath10k_info(struct ath10k *ar, const char *fmt, ...); __printf(2, 3) void ath10k_err(struct ath10k *ar, const char *fmt, ...); diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index eb36859..88fb27f 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -6924,6 +6924,7 @@ struct ath10k *ath10k_mac_create(size_t priv_size) void ath10k_mac_destroy(struct ath10k *ar) { + vfree(ar->cal_data); ieee80211_free_hw(ar->hw); }