From patchwork Fri Apr 24 00:49:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 11506891 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4ED9881 for ; Fri, 24 Apr 2020 00:49:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36B0620CC7 for ; Fri, 24 Apr 2020 00:49:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ivfmR3fx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728397AbgDXAti (ORCPT ); Thu, 23 Apr 2020 20:49:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728052AbgDXAti (ORCPT ); Thu, 23 Apr 2020 20:49:38 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B91D5C09B042 for ; Thu, 23 Apr 2020 17:49:37 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id u6so8182928ljl.6 for ; Thu, 23 Apr 2020 17:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=la2G1HCrrxK1MLNy6dIeXCgUDsqvGwugG5O298GMJH0=; b=ivfmR3fxwtTtJZ7Kps8x3n0DD5etjSZuYFLSIBl+FzwgZWpQt53VX+7HgnQB6k0bXl qwNvpya5UywSba9PVKj3CCJmLRwujWaVjPnUgEOzKnUeljPDQnZQ5ByNYxycRTY6Tm9T 4DPmcBlZTX/ZjssCSqolhpt3g4/nd5wov8O+a4TNPlyLU49SG23E7gQU4Ri6e9Bmb56V gv+DMSkBCEnDQz+ijyaJSa63YlJiliQPa8G6ZvBTo1hmpElsuFWynOy+CrTqGIYY6fyl j6smX9YiOtCmJHnG7tqAzXAj7TeZ+NFMoO8L5er+Hze7eVV619Jn6FAv47VZGe1vf+nY cvUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=la2G1HCrrxK1MLNy6dIeXCgUDsqvGwugG5O298GMJH0=; b=g0w3669QFwjUIebHoHEPVuw8y/d4DcHsKp5VmkQyKmKWNE6wOaZG3SCmPMBZIcLj+x 7z9cLQdsOd3DypdLlc2E8/Or1YURS2SDKqD9pLfJGOThhi8GXFTBrSk+urxcEQUZvZad 3tZJgPpiOzQ1F9OlVbNkLzkVl8FttDJfzO9s4fp9H0kfHGZJqWA0HzPER1TWe3rRSzOy vSZgCE4jqzWGfjTyQU/FpFYA4S7V0/QfnqqxtQkrI9rGFmASSvtjJ/ABgGobGx4nBFBs FCSTmd/IHkfF9koBchm3fElthsn+i12aMwSWqoKIwU0kChwgoTTw0epTFBoRq/yZZ4MO q04A== X-Gm-Message-State: AGi0PuZEuKZQQZPtlFlul55vxZvGqGhsrazxnl5bgtB1XWfasI7lYjFl 3uwqCDXwNsvPKTzVOeplIb95IzHW X-Google-Smtp-Source: APiQypLOQn7S7ljmLV9Rd91S7f06hsLdK2yHiRPxjwAP+WbP/PX1VlbZJwMjJWMThpjb1nzJfB8Bzg== X-Received: by 2002:a05:651c:403:: with SMTP id 3mr3944631lja.231.1587689376268; Thu, 23 Apr 2020 17:49:36 -0700 (PDT) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id r12sm1555056ljc.12.2020.04.23.17.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 17:49:35 -0700 (PDT) From: Sergey Ryazanov To: Kalle Valo Cc: QCA ath9k Development , linux-wireless@vger.kernel.org Subject: [PATCH 1/6] ath9k: fix AR9002 ADC and NF calibrations Date: Fri, 24 Apr 2020 03:49:18 +0300 Message-Id: <20200424004923.17129-2-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200424004923.17129-1-ryazanov.s.a@gmail.com> References: <20200424004923.17129-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org ADC calibration is only required for a 80 MHz sampling rate (i.e. for 40 MHz channels), when the chip utilizes the pair of ADCs in interleved mode. Calibration on a 20 MHz channel will never be completed. Previous channel check is trying to exclude all channels where the calibration will get stuck. It effectively blocks the calibration run for HT20 channels, but fails to exclude 20 MHz channels without HT (e.g. legacy mode channels). Fix this issue by reworking the channel check to explicitly allow ADCs gain & DC offset calibrations for HT40 channels only. Also update the complicated comment to make it clear that these calibrations are for multi-ADC mode only. Stuck ADCs calibration blocks the NF calibration, what could make it impossible to work in a noisy evironment: too big Rx attentuation, invalid RSSI value, etc. So this change is actually more of a NF calibration fix rather then the ADC calibration fix. Run tested with AR9220. Signed-off-by: Sergey Ryazanov --- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c index fd9db8ca99d7..14eee06744ed 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c @@ -37,9 +37,8 @@ static bool ar9002_hw_is_cal_supported(struct ath_hw *ah, break; case ADC_GAIN_CAL: case ADC_DC_CAL: - /* Run ADC Gain Cal for non-CCK & non 2GHz-HT20 only */ - if (!((IS_CHAN_2GHZ(chan) || IS_CHAN_A_FAST_CLOCK(ah, chan)) && - IS_CHAN_HT20(chan))) + /* Run even/odd ADCs calibrations for HT40 channels only */ + if (IS_CHAN_HT40(chan)) supported = true; break; } From patchwork Fri Apr 24 00:49:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 11506893 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7AFC92A for ; Fri, 24 Apr 2020 00:49:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF60520CC7 for ; Fri, 24 Apr 2020 00:49:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DfVDRkxB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728350AbgDXAtj (ORCPT ); Thu, 23 Apr 2020 20:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728052AbgDXAtj (ORCPT ); Thu, 23 Apr 2020 20:49:39 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E88CDC09B042 for ; Thu, 23 Apr 2020 17:49:38 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id r17so6291862lff.2 for ; Thu, 23 Apr 2020 17:49:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/b3npb6pWEyc/rTWSDgsuwKjZh16aTlDyhMtdfaza4g=; b=DfVDRkxB5o1unqMkdwVEHWkdoydfqEGK3DqscgzZshy3J7HBQzXdmdS1N3GsdRJprK BeByShk0tDM9eRz6+GNclRIjsEx83p4Lo9FrRBQSeFbZO7Oxo5ZXwXgKS1/cl8+2eA4p NfzIZ/jzCaZR/z/x/3cQfN4o7VkQ8OIccI1JQ+KnhZMAkv9wxMtNULCmnz9Gp5DLcn5J umeWpQfRTnGbPrZAx8H3qq2a7V2NJNhoN7BxYaiBHutDzXogc+Z1bsiKT6lNzL+a+g/6 RyYoOAGpszd/5c3ZEgrYtOnmM2gSTYYyxk+9/nwlRs4PoOXCkL+U1oStY4XzYrAI1CEU ohxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/b3npb6pWEyc/rTWSDgsuwKjZh16aTlDyhMtdfaza4g=; b=V8Epfr2jHAU0aODWnaTPPlNEWZBkzA/xYiP7eUnVBxXEssc8zi2mZwvCdHP47rOxIX FbK8uLlHnBeW9MKb4MKVEwFMQVKn3UBcz4eWjoS0Z0yfQBO1yK5PZzmCmSINcZI5lFNr s+KxrOxozCPdv0Sa0g41yoZG+4macLvlcjfLlMO4yFO/0A5DrPCO8L6kja5660BqrSAO 20OpUpfUeaF7/hhXnjTKAHl7kcVQyO3o5DxhiZ5Gu3LFtt372JISRmb98SBDN7SO30Xt YBNetQ7q/8ZU70PnFW2910pU+H3tnrDABxEov94kBHJY3IGQ+JEDtOxZ+DPVuBcS//Sl pZKA== X-Gm-Message-State: AGi0PuZJZqO1ODDQ3dvHPUSqeWGdesopAA2RhRgwSSGvB/Yow/nnUAMm ZxlnhPw2aB5aVyb1fovhPBw= X-Google-Smtp-Source: APiQypJ1oR8r2M0seiVpQ9Qw7z98IuiVt34JVAyGFGzWYISlwpY7u+OFvhXkrjcb8qmqK4lwRiznwQ== X-Received: by 2002:a05:6512:3189:: with SMTP id i9mr4220250lfe.178.1587689377419; Thu, 23 Apr 2020 17:49:37 -0700 (PDT) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id r12sm1555056ljc.12.2020.04.23.17.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 17:49:36 -0700 (PDT) From: Sergey Ryazanov To: Kalle Valo Cc: QCA ath9k Development , linux-wireless@vger.kernel.org Subject: [PATCH 2/6] ath9k: remove needless NFCAL_PENDING flag setting Date: Fri, 24 Apr 2020 03:49:19 +0300 Message-Id: <20200424004923.17129-3-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200424004923.17129-1-ryazanov.s.a@gmail.com> References: <20200424004923.17129-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The NFCAL_PENDING flag is set by the ath9k_hw_start_nfcal() routine, so there is no reason to set it manually after calling it during the AR9002 calibrations initialization. Signed-off-by: Sergey Ryazanov --- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c index 14eee06744ed..0f7c5812e5c2 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c @@ -857,9 +857,6 @@ static bool ar9002_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan) ath9k_hw_loadnf(ah, chan); ath9k_hw_start_nfcal(ah, true); - if (ah->caldata) - set_bit(NFCAL_PENDING, &ah->caldata->cal_flags); - ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; /* Enable IQ, ADC Gain and ADC DC offset CALs */ From patchwork Fri Apr 24 00:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 11506895 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F408C81 for ; Fri, 24 Apr 2020 00:49:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC86520CC7 for ; Fri, 24 Apr 2020 00:49:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MaoIKNM6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728458AbgDXAtl (ORCPT ); Thu, 23 Apr 2020 20:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728426AbgDXAtk (ORCPT ); Thu, 23 Apr 2020 20:49:40 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE83CC09B042 for ; Thu, 23 Apr 2020 17:49:39 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id u10so6274599lfo.8 for ; Thu, 23 Apr 2020 17:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W2VxuGgPQg0BX0NNuAgyx42HRNt4gO8knSgu6spqd9A=; b=MaoIKNM6qLCqVN74eZUoO8dQIaXg1wRugqSkdOM+P6/NJ9HeG6KjEDuUu2rNpAYgKe 7vtXLFhDSFebmqI1oUOQV0zkJG0kz1NXZvGZzOmT5O37G+OzzYkqbtj7apSV7QpYBCiG 62HsbPMYBwyK31frmAjFX7u/6m+o7Fr7caoZ7BiopfGhmCFDJ8OSsyhicSZgLDaeXxnL HkyqaKEOmwRN8kAdX38s+HYwHQt+oUb1zDjbTWI/qWdpz+Dneh2S25ANezzjgr045k74 1Yy6p+dkWHQu8CSBr9YZXEhM+cazLdHRyNdsw6puxgz5t/ToIaZSRVpxxBGNKb4j2N8Y Eweg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W2VxuGgPQg0BX0NNuAgyx42HRNt4gO8knSgu6spqd9A=; b=pN+qWnBXWLoIoENh98qyhHPdO6jP2kTGFF7dXizS+fJL9WT+u/VqqD0rkAwbGfIlZt 9G6SEahlC0XU43z6+WVH3YfLcNgXXHRkK9bpCf7t3ONtJOMQrMN0zYxMs4kJSiaHauwI Gk0G9/xPJWypOYdntPhFB1tZ3H3D/HqVjgKeoYukLnAQ7x8ZkFKvq1UYLNwmcWJ/nr7f izgM+4AGrgemZfkQxhbTVSuOahJ5RCJJd3GlpvQUkTnLcnH0wXID8vesQW6dAy0h47R0 3rhFngVPQy40pgx1odr69UjGBo6zroPjSn+E4Jj5AMw5j4cT/G2LXxNBFTpsqGe7drOM Rr3g== X-Gm-Message-State: AGi0PuaPZUlTzKYLtcN7W8eJ3UABdsII40SjGzsrbyKo7A2HFEvUNExU PF+mF/93O8qkhqJM+3BS8q32RkWu X-Google-Smtp-Source: APiQypJW5v/1Q/Pnnlzy2KvZR94Jg9TObRBcqwOno7MSdmS817egr+/NIdI9Qj1e0/91BceROZWbKg== X-Received: by 2002:a19:c78d:: with SMTP id x135mr4096890lff.151.1587689378419; Thu, 23 Apr 2020 17:49:38 -0700 (PDT) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id r12sm1555056ljc.12.2020.04.23.17.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 17:49:37 -0700 (PDT) From: Sergey Ryazanov To: Kalle Valo Cc: QCA ath9k Development , linux-wireless@vger.kernel.org Subject: [PATCH 3/6] ath9k: do not miss longcal on AR9002 Date: Fri, 24 Apr 2020 03:49:20 +0300 Message-Id: <20200424004923.17129-4-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200424004923.17129-1-ryazanov.s.a@gmail.com> References: <20200424004923.17129-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Each of AGC & I/Q calibrations can take a long time. Long calibration and NF calibration in particular are forbiden for parallel run with ADC & I/Q calibrations. So, the chip could not be ready to perform the long calibration at the time of request. And a request to perform the long calibration may be lost. In order to fix this, preserve the long calibration request as a calibration state flag and restore the long calibration request each time the calibration function is called again (i.e. on each subsequent ivocation of the short calibration). This feature will be twice useful after the next change, which will make it possible to start the long calibration before all ADCs & I/Q calibrations are completed. Run tested with AR9220. Signed-off-by: Sergey Ryazanov --- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 10 +++++++++- drivers/net/wireless/ath/ath9k/hw.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c index 0f7c5812e5c2..ad8db7720993 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c @@ -663,8 +663,13 @@ static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan, int ret; nfcal = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF); - if (ah->caldata) + if (ah->caldata) { nfcal_pending = test_bit(NFCAL_PENDING, &ah->caldata->cal_flags); + if (longcal) /* Remember to not miss */ + set_bit(LONGCAL_PENDING, &ah->caldata->cal_flags); + else if (test_bit(LONGCAL_PENDING, &ah->caldata->cal_flags)) + longcal = true; /* Respin a previous one */ + } percal_pending = (currCal && (currCal->calState == CAL_RUNNING || @@ -700,6 +705,9 @@ static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan, } if (longcal) { + if (ah->caldata) + clear_bit(LONGCAL_PENDING, + &ah->caldata->cal_flags); ath9k_hw_start_nfcal(ah, false); /* Do periodic PAOffset Cal */ ar9002_hw_pa_cal(ah, false); diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 2e4489700a85..c99f3c77c823 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -427,6 +427,7 @@ enum ath9k_cal_flags { TXIQCAL_DONE, TXCLCAL_DONE, SW_PKDET_DONE, + LONGCAL_PENDING, }; struct ath9k_hw_cal_data { From patchwork Fri Apr 24 00:49:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 11506897 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C0EA1667 for ; Fri, 24 Apr 2020 00:49:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8554D20CC7 for ; Fri, 24 Apr 2020 00:49:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C+J3ouXS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728472AbgDXAtm (ORCPT ); Thu, 23 Apr 2020 20:49:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728426AbgDXAtl (ORCPT ); Thu, 23 Apr 2020 20:49:41 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 389A6C09B042 for ; Thu, 23 Apr 2020 17:49:41 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id l19so8182269lje.10 for ; Thu, 23 Apr 2020 17:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kg1MYGykeGuf+7Gz3LdVBhQeks/GyQjLKM5JDMAttCM=; b=C+J3ouXSWVgccWyf9TxWafuiNHh/gYr9hRY2jo6Y0uACWCSxH8EpqRteAdvzlG/EAy IBHsM2fwGxg8sUx+HKyDwRHFe9DdiuLR9LlbSy1IR5KSmNhBaCiMXQ++cF8eltDM4d7g p2a10haqFonJAgne3PHA1o0PksPR6zuG9E9bR3kOQcF6/I3BIYh0CUHJ99VxWQT7O+aB NRm8i7mgnzkgbwkkeW12m7m7iujDx2UdePo6Lqj2sHzULYsg79R4TQ519sNFKIYCsXu+ CxpQT/OMhQ8qqxK/tcna5q1zrD75SXpYLM+Kn+hKbCsv4GjhE7U3E8Ol75AYRv4V7ZAu PbsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kg1MYGykeGuf+7Gz3LdVBhQeks/GyQjLKM5JDMAttCM=; b=UsiEq9BjrsewFAMhoUVkLuPeskG5X1jNNYitH+WwIX09NVLK/Mx5OIqMf2MdAA0NDr tqgBMEPmc/4Cc7SpgAuRBJ+Et2MxwDOINrE9okSsm1J8O15xsGhicvj+BTxabfs393p1 weHKJKLAoXHxitdGdbvhSWyh4ue95DxqQdcujfZxJCUtAXC+9Hd1z7I7TcgbZeyImhH6 K20SGCuwW5vgIT0DO9rfoWFEn7W1NeNvSqEwYb6mZ27m7TbR6Hx5dzpdvanC8Oe8yJ/Y V5U+BmkDr+F3zr2/x2x1D2e4ALJWaW10HT/7KzZhRJlVO7VOthTpFO8n3qsd7Y5ZgVu5 AhWw== X-Gm-Message-State: AGi0PubqwO7ugUliBoq3VH4byCv/zTXwmMClmouZCV6at11X3NNlviD5 tJ8sLE2xpHHSACCLvkZNqR8Hk8Q5 X-Google-Smtp-Source: APiQypIets4EKKLv624XORnpouUh0Fc0YKXq5VGdiirMQrqutGIr0UISbwIekMOTQ73o0snMdFK1Pg== X-Received: by 2002:a2e:571a:: with SMTP id l26mr4020399ljb.12.1587689379660; Thu, 23 Apr 2020 17:49:39 -0700 (PDT) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id r12sm1555056ljc.12.2020.04.23.17.49.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 17:49:39 -0700 (PDT) From: Sergey Ryazanov To: Kalle Valo Cc: QCA ath9k Development , linux-wireless@vger.kernel.org Subject: [PATCH 4/6] ath9k: interleaved NF calibration on AR9002 Date: Fri, 24 Apr 2020 03:49:21 +0300 Message-Id: <20200424004923.17129-5-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200424004923.17129-1-ryazanov.s.a@gmail.com> References: <20200424004923.17129-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org NF calibration and other elements of long calibration are usually faster than ADCs & I/Q calibrations due to independence of receiption of the OFDM signal. Moreover sometime I/Q calibration can not be completed at all without preceding NF calibration. This is due to AGC, which has a habit to block a weak signal without regular NF calibration. Thus, we do not need to deferr the long calibration forever. So, if the long calibration is requested, then deferr the ADCs & I/Q calibration(s) and run the longcal (the NF calibration in particular) to obtain fresh noise data. Run tested with AR9220. Signed-off-by: Sergey Ryazanov --- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c index ad8db7720993..68188f500949 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c @@ -680,8 +680,12 @@ static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan, return 0; ah->cal_list_curr = currCal = currCal->calNext; - if (currCal->calState == CAL_WAITING) - ath9k_hw_reset_calibration(ah, currCal); + percal_pending = currCal->calState == CAL_WAITING; + } + + /* Do not start a next calibration if the longcal is in action */ + if (percal_pending && !nfcal && !longcal) { + ath9k_hw_reset_calibration(ah, currCal); return 0; } From patchwork Fri Apr 24 00:49:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 11506899 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA11192A for ; Fri, 24 Apr 2020 00:49:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D15EE2087E for ; Fri, 24 Apr 2020 00:49:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CiEOTicG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728342AbgDXAto (ORCPT ); Thu, 23 Apr 2020 20:49:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728480AbgDXAtm (ORCPT ); Thu, 23 Apr 2020 20:49:42 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20CDAC09B042 for ; Thu, 23 Apr 2020 17:49:42 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id u10so6274631lfo.8 for ; Thu, 23 Apr 2020 17:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=enNVEIEyKc8khXu44plNNu16PsTEyKATqm81c6KZKDE=; b=CiEOTicGRsNjS1GnPyZExyFEMCK2xzGmbDVwBzRPoBXZ+g81nfMTy0nS9Pu3GrPKpK HXEfnTnCrqAEWpLtTXfx2GYwZZRDQUQqs3xswmW2aOS56RAS8oZSxql+2+uhwLkGIgHy rY+7XXOupwPqPTVrhLb0xJoclaw3CLYN/IS64hVGUI2/pM76PIHDHmZ3D9keqEfS+bsn bV/TNfYO7RgnrWiwUnsEW3xXnOx77/DcP3JOtETGd2qs7+DKcW2QSSD/Nh6PUo33Qid0 LhkBeIiMip8MQpBiWfPuwJN0dM2p0md11jxFth2QU63uNTOPy+gOtECjrYEAVlMF4GR4 vaQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=enNVEIEyKc8khXu44plNNu16PsTEyKATqm81c6KZKDE=; b=JHqgaYgrC/r0v7gZxdNW9EB4XNvL8vgdYEN0VifOeHkc9hOQDNuw+/cb7jiBlVO+oe NDAuLzItMrLk+ZVSEglXp1zPxfBnXPpcE/kQ6Knr5b7MiyU8rFiVxpijZinm1oNzu/DK rJrZpeQ4KeprKjrxrdXxuZyAEqqpNLUnXYVfjP9TRuwweMPpVIqbffSElQvUNqUdhLb5 6qqfn3DrnT7mih2Hcdk88O019dhmOMZUj++RfAiiXEbHgS6fPFd+qOVMTF5RRrEmE/ql 2vQCY9QFmx5Uh+3qyPjocKVksIGTNmodOaPuBvzeSWLcWC6NY5klbksXkvBqtiYBfwBt dUjw== X-Gm-Message-State: AGi0PuYy1arsYRZ4x1Wuzz3y6Cdjti3ugTENI+Xk1BMjjQ3gz07FIXZE lqC5ospqWqM0m8B2MSI/kEU= X-Google-Smtp-Source: APiQypIqPLV0zJLFr5z1nqP9RFhCm3+3lTcHomAYsnYqXkLZTna1dg93yMhYj3oKAfZG/83+9I3jwA== X-Received: by 2002:a19:c895:: with SMTP id y143mr4007457lff.123.1587689380652; Thu, 23 Apr 2020 17:49:40 -0700 (PDT) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id r12sm1555056ljc.12.2020.04.23.17.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 17:49:40 -0700 (PDT) From: Sergey Ryazanov To: Kalle Valo Cc: QCA ath9k Development , linux-wireless@vger.kernel.org Subject: [PATCH 5/6] ath9k: invalidate all calibrations at once Date: Fri, 24 Apr 2020 03:49:22 +0300 Message-Id: <20200424004923.17129-6-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200424004923.17129-1-ryazanov.s.a@gmail.com> References: <20200424004923.17129-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Previously after the calibration validity period is over, calibrations are invalidated in a one at time manner. So, for AR9002 family, which has three calibrations, the full recalibration interval becomes 3 x ATH_RESTART_CALINTERVAL. And each next calibration will be separated by the ATH_RESTART_CALINTERVAL time from a previous one. It seems like it is better to do whole recalibration at once. Also, this change makes the driver behaviour a little simpler. So, invalidate all calibrations at once at the end of the calibration validity interval. This change affects only AR9002 chips family, since the AR9003 utilize only a single calibration. Signed-off-by: Sergey Ryazanov --- drivers/net/wireless/ath/ath9k/calib.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c index 695c779ae8cf..2ac3eefd3851 100644 --- a/drivers/net/wireless/ath/ath9k/calib.c +++ b/drivers/net/wireless/ath/ath9k/calib.c @@ -209,14 +209,17 @@ bool ath9k_hw_reset_calvalid(struct ath_hw *ah) return true; } - if (!(ah->supp_cals & currCal->calData->calType)) - return true; + currCal = ah->cal_list; + do { + ath_dbg(common, CALIBRATE, "Resetting Cal %d state for channel %u\n", + currCal->calData->calType, + ah->curchan->chan->center_freq); - ath_dbg(common, CALIBRATE, "Resetting Cal %d state for channel %u\n", - currCal->calData->calType, ah->curchan->chan->center_freq); + ah->caldata->CalValid &= ~currCal->calData->calType; + currCal->calState = CAL_WAITING; - ah->caldata->CalValid &= ~currCal->calData->calType; - currCal->calState = CAL_WAITING; + currCal = currCal->calNext; + } while (currCal != ah->cal_list); return false; } From patchwork Fri Apr 24 00:49:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 11506901 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 948531667 for ; Fri, 24 Apr 2020 00:49:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D26E20CC7 for ; Fri, 24 Apr 2020 00:49:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hb7n9dPd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728490AbgDXAto (ORCPT ); Thu, 23 Apr 2020 20:49:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728426AbgDXAtn (ORCPT ); Thu, 23 Apr 2020 20:49:43 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31F19C09B042 for ; Thu, 23 Apr 2020 17:49:43 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id 131so6248387lfh.11 for ; Thu, 23 Apr 2020 17:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ibCU6yGuhLZYeWcolU23X1L8peHTgnL1gQpl7z0+cJU=; b=Hb7n9dPdcCj8dvRB3hyPNe4e/JwRDMgJIQxC9QHn7UcG+7NpMp1enYCwZ9HnWkRYuC 1NTUrdCczB1Hvd0605aRTHBOhOYAwfvYIFosQ3zSWmJP3y0yYGUj65Sie05ueTFLYRrq bny6bAMwEDI7H/K+ClGp7Db4juVEf3Ku0gUqNrT5hemjnVEIL263tC8xHjM+u653d3QT VVN/OJoSx/aP3MFSfJWcJw5ANvom1e9rKrEdk/lvw7Ib4a1nj3Cd6D2uKAbqNSV4aIu3 4ddVSRlRiDh+xrg4tAbplRRZu8LRTQauBqkw4YVQX2X13RY3KLOkEFIxzMproK6ghN7X OryA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ibCU6yGuhLZYeWcolU23X1L8peHTgnL1gQpl7z0+cJU=; b=Q3p7QLF1gEt81hww0uTUipNqleNgCdo+fzHUAfDPAu6uqQRGNIH23QkbHS4gLBNycD 7VtBxI7r4MVcYe8hxmG+u5J6eCn07+2+VH4UNzqPB3r2fBFAmZBQp2qeZr3o5Vu+XmrJ 910ZoPCOCUIFNNHhaSSd4KTc68YMPaKhEfRDk07Ao1q4yn4YgaaDvVJVmK5gX0pk5s30 CoPSSCZNNBKx6xel0KZneRiXisP9mFQJHvUrbYbsW+xixmQgydgs/kJ/0pqn0hvDYNt7 BZtWI4pps85nK9VwwF//eTgujvLasxaB+edcgrc7QiF1U5UV/B8Xw5BCbO7g+2fq3F99 qS4Q== X-Gm-Message-State: AGi0Pubu9oUrbp0QOk4ZvvwlYKRi1bCR4wqGUouEmV7DHH5s3DylY1fx zfWpLaA1K0y9a4c8fCOUeG8WXM/E X-Google-Smtp-Source: APiQypLxEhLGTV9+Tpy5W3eJdHYq0eBwScHTl9OFTZ098wuMsJcjcyq5cm5LN9Hh8fYzzMnOTmvDXg== X-Received: by 2002:a05:6512:304e:: with SMTP id b14mr3963898lfb.119.1587689381690; Thu, 23 Apr 2020 17:49:41 -0700 (PDT) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id r12sm1555056ljc.12.2020.04.23.17.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 17:49:41 -0700 (PDT) From: Sergey Ryazanov To: Kalle Valo Cc: QCA ath9k Development , linux-wireless@vger.kernel.org Subject: [PATCH 6/6] ath9k: add calibration timeout for AR9002 Date: Fri, 24 Apr 2020 03:49:23 +0300 Message-Id: <20200424004923.17129-7-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200424004923.17129-1-ryazanov.s.a@gmail.com> References: <20200424004923.17129-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org ADC & I/Q calibrations could take infinite time to comple, since they depend on received frames. In particular the I/Q mismatch calibration requires receiving of OFDM frames for completion. But in the 2.4GHz band, a station could receive only CCK frames for a very long time. And while we wait for the completion of one of the mentioned calibrations, the NF calibration is blocked. Moreover, in some environments, I/Q calibration is unable to complete until a correct noise calibration will be performed due to AGC behaviour. In order to avoid delaying NF calibration on forever, limit the maximum duration of ADCs & I/Q calibrations. If the calibration is not completed within the maximum time, it will be interrupted and a next calibration will be performed. The code that selects the next calibration has been reworked to the loop so incompleted calibration will be respinned later. А maximum calibration time of 30 seconds was selected to give the calibration enough time to complete and to not interfere with the long (NF) calibration. Run tested with AR9220. Signed-off-by: Sergey Ryazanov --- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 25 +++++++++++++++++-- drivers/net/wireless/ath/ath9k/calib.c | 1 + drivers/net/wireless/ath/ath9k/hw.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c index 68188f500949..fd53b5f9e9b5 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c @@ -19,6 +19,8 @@ #include "ar9002_phy.h" #define AR9285_CLCAL_REDO_THRESH 1 +/* AGC & I/Q calibrations time limit, ms */ +#define AR9002_CAL_MAX_TIME 30000 enum ar9002_cal_types { ADC_GAIN_CAL = BIT(0), @@ -104,6 +106,14 @@ static bool ar9002_hw_per_calibration(struct ath_hw *ah, } else { ar9002_hw_setup_calibration(ah, currCal); } + } else if (time_after(jiffies, ah->cal_start_time + + msecs_to_jiffies(AR9002_CAL_MAX_TIME))) { + REG_CLR_BIT(ah, AR_PHY_TIMING_CTRL4(0), + AR_PHY_TIMING_CTRL4_DO_CAL); + ath_dbg(ath9k_hw_common(ah), CALIBRATE, + "calibration timeout\n"); + currCal->calState = CAL_WAITING; /* Try later */ + iscaldone = true; } } else if (!(caldata->CalValid & currCal->calData->calType)) { ath9k_hw_reset_calibration(ah, currCal); @@ -679,8 +689,19 @@ static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan, if (!ar9002_hw_per_calibration(ah, chan, rxchainmask, currCal)) return 0; - ah->cal_list_curr = currCal = currCal->calNext; - percal_pending = currCal->calState == CAL_WAITING; + /* Looking for next waiting calibration if any */ + for (currCal = currCal->calNext; currCal != ah->cal_list_curr; + currCal = currCal->calNext) { + if (currCal->calState == CAL_WAITING) + break; + } + if (currCal->calState == CAL_WAITING) { + percal_pending = true; + ah->cal_list_curr = currCal; + } else { + percal_pending = false; + ah->cal_list_curr = ah->cal_list; + } } /* Do not start a next calibration if the longcal is in action */ diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c index 2ac3eefd3851..0422a33395b7 100644 --- a/drivers/net/wireless/ath/ath9k/calib.c +++ b/drivers/net/wireless/ath/ath9k/calib.c @@ -176,6 +176,7 @@ void ath9k_hw_reset_calibration(struct ath_hw *ah, ath9k_hw_setup_calibration(ah, currCal); + ah->cal_start_time = jiffies; currCal->calState = CAL_RUNNING; for (i = 0; i < AR5416_MAX_CHAINS; i++) { diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index c99f3c77c823..023599e10dd5 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -834,6 +834,7 @@ struct ath_hw { /* Calibration */ u32 supp_cals; + unsigned long cal_start_time; struct ath9k_cal_list iq_caldata; struct ath9k_cal_list adcgain_caldata; struct ath9k_cal_list adcdc_caldata;