From patchwork Fri Jun 7 22:37:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10982889 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-2.web.codeaurora.org (Postfix) with ESMTP id DA9FC14C0 for ; Fri, 7 Jun 2019 22:38:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCD28288B9 for ; Fri, 7 Jun 2019 22:38:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF9B428BDA; Fri, 7 Jun 2019 22:38:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A683288B9 for ; Fri, 7 Jun 2019 22:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731550AbfFGWhn (ORCPT ); Fri, 7 Jun 2019 18:37:43 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36579 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731460AbfFGWhm (ORCPT ); Fri, 7 Jun 2019 18:37:42 -0400 Received: by mail-pl1-f196.google.com with SMTP id d21so1343256plr.3 for ; Fri, 07 Jun 2019 15:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=npqZn7jrWknLiP6RpPMO0pPj6O8NQ9dRH7/VI2Vhthk=; b=hdMt7Tp8R3E0DReUmZ60ezy4X6bTQmVNpN9Xob9TjfIVuVL+nrVX7wdG3Y2lEjkEoe w7yjBbWqqH3/q7tBbdW4khMsRF5Fm+s4GofU3zrlvE3jW8r+me40NCIVGSVFt5KL9VVA g2YydiHRvFDQXquQIEaNZ1shPB2elvhqoQdmI= 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=npqZn7jrWknLiP6RpPMO0pPj6O8NQ9dRH7/VI2Vhthk=; b=iA/KgJDMblWZudiHtIBSixy4OTZHWK4s/j2ZAlSRJ9kve2X+4JM9vLFRr7e4yHMkWx J7iiwsRvn18YkrdYEJnVSQ1C8LbZvtvpQam4zjvO8KGdOCbUFWQzuQL9CqW1tDrGKUIF exiSAXLfJYS0kgUMJtHk83qlE3SQLO2mfIEQPAagNfgO8u5Tb+WzlUseiYeyWQtfcsHY dGLirqq8kMAe3byP4+15r2B8sWMZJKDqB6+dWhy1wCAwpuzclhRcFO8YQjrOhO8QvFm2 OW5XyBqXtDlaJS50WM117AqiotoOA8UTAlYQS52z/kygfUiw9LWzFAlLaCCO34B5e2cT LvjQ== X-Gm-Message-State: APjAAAVfsfyTJYT2q/8pQnXp1Q9SS/t2ETrITavW/OQHtgojbsmPDvkc uFdxfeyCio57/Rb5l7PHRflZjg== X-Google-Smtp-Source: APXvYqxe0jRoHVjH0j4kVqEfBP2PUF3gAe9VxHlJqI7LH0UKRSF8v7zzb19mCum1XWxKY7vDj7csbg== X-Received: by 2002:a17:902:522:: with SMTP id 31mr55340726plf.296.1559947061581; Fri, 07 Jun 2019 15:37:41 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id j23sm4185193pgb.63.2019.06.07.15.37.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 15:37:41 -0700 (PDT) From: Douglas Anderson To: Ulf Hansson , Kalle Valo , Adrian Hunter , Arend van Spriel Cc: brcm80211-dev-list.pdl@broadcom.com, linux-rockchip@lists.infradead.org, Double Lo , briannorris@chromium.org, linux-wireless@vger.kernel.org, Naveen Gupta , Madhan Mohan R , mka@chromium.org, Wright Feng , Chi-Hsien Lin , netdev@vger.kernel.org, brcm80211-dev-list@cypress.com, Douglas Anderson , "David S. Miller" , Franky Lin , linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Hante Meuleman , YueHaibing , Michael Trimarchi Subject: [PATCH v3 1/5] Revert "brcmfmac: disable command decode in sdio_aos" Date: Fri, 7 Jun 2019 15:37:12 -0700 Message-Id: <20190607223716.119277-2-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog In-Reply-To: <20190607223716.119277-1-dianders@chromium.org> References: <20190607223716.119277-1-dianders@chromium.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit 29f6589140a10ece8c1d73f58043ea5b3473ab3e. After that patch landed I find that my kernel log on rk3288-veyron-minnie and rk3288-veyron-speedy is filled with: brcmfmac: brcmf_sdio_bus_sleep: error while changing bus sleep state -110 This seems to happen every time the Broadcom WiFi transitions out of sleep mode. Reverting the commit fixes the problem for me, so that's what this patch does. Note that, in general, the justification in the original commit seemed a little weak. It looked like someone was testing on a SD card controller that would sometimes die if there were CRC errors on the bus. This used to happen back in early days of dw_mmc (the controller on my boards), but we fixed it. Disabling a feature on all boards just because one SD card controller is broken seems bad. Fixes: 29f6589140a1 ("brcmfmac: disable command decode in sdio_aos") Cc: Wright Feng Cc: Double Lo Cc: Madhan Mohan R Cc: Chi-Hsien Lin Signed-off-by: Douglas Anderson --- As far as I know this patch can land anytime. Changes in v3: None Changes in v2: - A full revert, not just a partial one (Arend). ...with explicit Cc. drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index 4e15ea57d4f5..4a750838d8cd 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -3364,11 +3364,7 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus, static bool brcmf_sdio_aos_no_decode(struct brcmf_sdio *bus) { - if (bus->ci->chip == CY_CC_43012_CHIP_ID || - bus->ci->chip == CY_CC_4373_CHIP_ID || - bus->ci->chip == BRCM_CC_4339_CHIP_ID || - bus->ci->chip == BRCM_CC_4345_CHIP_ID || - bus->ci->chip == BRCM_CC_4354_CHIP_ID) + if (bus->ci->chip == CY_CC_43012_CHIP_ID) return true; else return false; From patchwork Fri Jun 7 22:37:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10982891 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE20615E6 for ; Fri, 7 Jun 2019 22:38:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE330288B9 for ; Fri, 7 Jun 2019 22:38:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEEFA28BDA; Fri, 7 Jun 2019 22:38:14 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DEAB288B9 for ; Fri, 7 Jun 2019 22:38:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731736AbfFGWiN (ORCPT ); Fri, 7 Jun 2019 18:38:13 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:47093 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731508AbfFGWhn (ORCPT ); Fri, 7 Jun 2019 18:37:43 -0400 Received: by mail-pl1-f194.google.com with SMTP id e5so1326769pls.13 for ; Fri, 07 Jun 2019 15:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U1Ebpn5sqJxVeDjM8NV6sp+M7Ulx/T6T1ihRForNiZk=; b=Fi4fr1iKul90yPOJYhRoZAs0JfmWDCdK83HoFAtKwI0sa5Hmq71Np5w+DUGRnvlKSA b2NFI2LFjgVQ90kWVGfFESnSRwT8+RuSbO0c7JI9vT7zJDfnv5W98nxlOQtdT3otquGX P6fGnDg2wLxeP+LllQUHw0fUUVAlmkG5hWQSI= 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=U1Ebpn5sqJxVeDjM8NV6sp+M7Ulx/T6T1ihRForNiZk=; b=cw+RnIU9sVHrYjRrBuiH1M4XYo1agHJsL7u2neGj3BoQifIyZEbHYFtJLetY0/ibNz xKzMiC5RNKqDbhwLCp268pPQjfRCMC/g/bF8n6W84t4xgqRKh0lwIniaBseuht8ulb9x 97hOH6Hu7J/a0pHTXNd/f2wQck0L448F322KBkU0LlsdbMGtUuLzXNMjMLjetZ9QCW9p CgUhahus81nn5+S+tc0XEkLORnJR+7BJUeTo7lA5CbFwm75/Op7OzTKujdEgUmhNQC0R o4PcYfGnbL/QM3jQzRIUHxap3GIPE6GC30SgivHi/cAI2lvdRPvPymsRRUbx49GSCw0v P62Q== X-Gm-Message-State: APjAAAWb7EsC0FyYhkmwFkWFu0ZoaJknR6uzZv0hPNyvGS0EYHZU5jNK OPiM87SqE4LR14vI2+d/qZf7PQ== X-Google-Smtp-Source: APXvYqx6fo8W+foYQLpakl+ecnh//DcmwJfox7qyAVeK0zqYD9gJhLmGN07/cvV+AvtMzg3L3jRNdA== X-Received: by 2002:a17:902:42e2:: with SMTP id h89mr58422930pld.332.1559947062929; Fri, 07 Jun 2019 15:37:42 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id j23sm4185193pgb.63.2019.06.07.15.37.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 15:37:42 -0700 (PDT) From: Douglas Anderson To: Ulf Hansson , Kalle Valo , Adrian Hunter , Arend van Spriel Cc: brcm80211-dev-list.pdl@broadcom.com, linux-rockchip@lists.infradead.org, Double Lo , briannorris@chromium.org, linux-wireless@vger.kernel.org, Naveen Gupta , Madhan Mohan R , mka@chromium.org, Wright Feng , Chi-Hsien Lin , netdev@vger.kernel.org, brcm80211-dev-list@cypress.com, Douglas Anderson , Jiong Wu , Ritesh Harjani , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Shawn Lin , Wolfram Sang , Avri Altman Subject: [PATCH v3 2/5] mmc: core: API for temporarily disabling auto-retuning due to errors Date: Fri, 7 Jun 2019 15:37:13 -0700 Message-Id: <20190607223716.119277-3-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog In-Reply-To: <20190607223716.119277-1-dianders@chromium.org> References: <20190607223716.119277-1-dianders@chromium.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Normally when the MMC core sees an "-EILSEQ" error returned by a host controller then it will trigger a retuning of the card. This is generally a good idea. However, if a command is expected to sometimes cause transfer errors then these transfer errors shouldn't cause a re-tuning. This re-tuning will be a needless waste of time. One example case where a transfer is expected to cause errors is when transitioning between idle (sometimes referred to as "sleep" in Broadcom code) and active state on certain Broadcom WiFi cards. Specifically if the card was already transitioning between states when the command was sent it could cause an error on the SDIO bus. Let's add an API that the SDIO card drivers can call that will temporarily disable the auto-tuning functionality. Then we can add a call to this in the Broadcom WiFi driver and any other driver that might have similar needs. NOTE: this makes the assumption that the card is already tuned well enough that it's OK to disable the auto-retuning during one of these error-prone situations. Presumably the driver code performing the error-prone transfer knows how to recover / retry from errors. ...and after we can get back to a state where transfers are no longer error-prone then we can enable the auto-retuning again. If we truly find ourselves in a case where the card needs to be retuned sometimes to handle one of these error-prone transfers then we can always try a few transfers first without auto-retuning and then re-try with auto-retuning if the first few fail. Without this change on rk3288-veyron-minnie I periodically see this in the logs of a machine just sitting there idle: dwmmc_rockchip ff0d0000.dwmmc: Successfully tuned phase to XYZ Fixes: bd11e8bd03ca ("mmc: core: Flag re-tuning is needed on CRC errors") Signed-off-by: Douglas Anderson --- Note that are are a whole boatload of different ways that we could provide an API for the Broadcom WiFi SDIO driver. This patch illustrates one way but if maintainers feel strongly that this is too ugly and have a better idea then I can give it a shot too. From a purist point of view I kinda felt that the "expect errors" really belonged as part of the mmc_request structure, but getting it into there meant changing a whole pile of core SD/MMC APIs. Simply adding it to the host seemed to match the current style better and was a less intrusive change. Changes in v3: - Took out the spinlock since I believe this is all in one context. Changes in v2: - Updated commit message to clarify based on discussion of v1. drivers/mmc/core/core.c | 19 +++++++++++++++++-- include/linux/mmc/core.h | 2 ++ include/linux/mmc/host.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 6db36dc870b5..bc109ec49406 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -144,8 +144,9 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) int err = cmd->error; /* Flag re-tuning needed on CRC errors */ - if ((cmd->opcode != MMC_SEND_TUNING_BLOCK && - cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200) && + if (cmd->opcode != MMC_SEND_TUNING_BLOCK && + cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200 && + !host->expect_errors && (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) || (mrq->data && mrq->data->error == -EILSEQ) || (mrq->stop && mrq->stop->error == -EILSEQ))) @@ -2163,6 +2164,20 @@ int mmc_sw_reset(struct mmc_host *host) } EXPORT_SYMBOL(mmc_sw_reset); +void mmc_expect_errors_begin(struct mmc_host *host) +{ + WARN_ON(host->expect_errors); + host->expect_errors = true; +} +EXPORT_SYMBOL_GPL(mmc_expect_errors_begin); + +void mmc_expect_errors_end(struct mmc_host *host) +{ + WARN_ON(!host->expect_errors); + host->expect_errors = false; +} +EXPORT_SYMBOL_GPL(mmc_expect_errors_end); + static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) { host->f_init = freq; diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 134a6483347a..02a13abf0cda 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -178,6 +178,8 @@ int mmc_wait_for_cmd(struct mmc_host *host, struct mmc_command *cmd, int mmc_hw_reset(struct mmc_host *host); int mmc_sw_reset(struct mmc_host *host); +void mmc_expect_errors_begin(struct mmc_host *host); +void mmc_expect_errors_end(struct mmc_host *host); void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card); #endif /* LINUX_MMC_CORE_H */ diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 43d0f0c496f6..8d553fb8c834 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -398,6 +398,7 @@ struct mmc_host { unsigned int retune_now:1; /* do re-tuning at next req */ unsigned int retune_paused:1; /* re-tuning is temporarily disabled */ unsigned int use_blk_mq:1; /* use blk-mq */ + unsigned int expect_errors:1; /* don't trigger retune upon errors */ int rescan_disable; /* disable card detection */ int rescan_entered; /* used with nonremovable devices */ From patchwork Fri Jun 7 22:37:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10982885 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-2.web.codeaurora.org (Postfix) with ESMTP id C424815E6 for ; Fri, 7 Jun 2019 22:38:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3F3128BB8 for ; Fri, 7 Jun 2019 22:38:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7B2628BE0; Fri, 7 Jun 2019 22:38:01 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FE4E28BB8 for ; Fri, 7 Jun 2019 22:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731726AbfFGWiA (ORCPT ); Fri, 7 Jun 2019 18:38:00 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45006 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729629AbfFGWho (ORCPT ); Fri, 7 Jun 2019 18:37:44 -0400 Received: by mail-pl1-f194.google.com with SMTP id c5so1331515pll.11 for ; Fri, 07 Jun 2019 15:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z/Emr8zkD81f/RoFF2bpt9vXXmYuPgcPH/tJJB2TNkM=; b=oQQs34ffYiXMPOR36xOya64Dt1KgLnf9z1SV0HDmj0CMof30gz507FOLOXiwLZF9vI 1D4A3r35LVnz+omcfO1khnEJ5B5cf2uWoH3JxkZrIVrFp+vmy6UzYUj2ueHLGx4vpf7/ 59wQukIGshja6mS/TY/bI/w1srMb5f0chSNZ8= 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=Z/Emr8zkD81f/RoFF2bpt9vXXmYuPgcPH/tJJB2TNkM=; b=qgZ6LEzYW86NIEAZbXRUX4dVH6h4c2/e/X8uj8wpnN0jNL6Sm/sXgOWDQc5441xBg6 kC3ZVd1LlawjA1OxtHm6kr53Sz8km//KvawVR9mqLUzIkE+cu0OYfGGzqB0a0jwAFx/w it3BnASNsr3F3gI6u/+iJaRSXr/nTceufHnA5i0arHgnhdRZU10T8SkPk1sLoaHlS0Ow qLljLaukCZsxxyJ2HZQYmvMVAl/JOYOYvHvKSW7d2vRVSqXwQ1cy/GteMU1qA/ae5Ftt TR3KPnhCeCb9M5kTkIB9O8vkmm+PcyNpLPjdkqPlD6SsATmWw7do2IKDo4wANJN2qS4v llRw== X-Gm-Message-State: APjAAAVmRRsij5BMXzVSSdMIKceIQ8wGxy0/EmNl4yALd/jdet96A4YL XmcqVSYoCO455yS3wMXiH2tHhg== X-Google-Smtp-Source: APXvYqyNw/yZY/ZbD9VOj7XTh2VyqbwOrp6QXWwuAPrgMHCzudlnfDTuWjve7w8tswOe88lOZPL0rQ== X-Received: by 2002:a17:902:290b:: with SMTP id g11mr57474438plb.26.1559947064218; Fri, 07 Jun 2019 15:37:44 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id j23sm4185193pgb.63.2019.06.07.15.37.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 15:37:43 -0700 (PDT) From: Douglas Anderson To: Ulf Hansson , Kalle Valo , Adrian Hunter , Arend van Spriel Cc: brcm80211-dev-list.pdl@broadcom.com, linux-rockchip@lists.infradead.org, Double Lo , briannorris@chromium.org, linux-wireless@vger.kernel.org, Naveen Gupta , Madhan Mohan R , mka@chromium.org, Wright Feng , Chi-Hsien Lin , netdev@vger.kernel.org, brcm80211-dev-list@cypress.com, Douglas Anderson , Franky Lin , linux-kernel@vger.kernel.org, Madhan Mohan R , Hante Meuleman , YueHaibing , "David S. Miller" Subject: [PATCH v3 3/5] brcmfmac: sdio: Disable auto-tuning around commands expected to fail Date: Fri, 7 Jun 2019 15:37:14 -0700 Message-Id: <20190607223716.119277-4-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog In-Reply-To: <20190607223716.119277-1-dianders@chromium.org> References: <20190607223716.119277-1-dianders@chromium.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are certain cases, notably when transitioning between sleep and active state, when Broadcom SDIO WiFi cards will produce errors on the SDIO bus. This is evident from the source code where you can see that we try commands in a loop until we either get success or we've tried too many times. The comment in the code reinforces this by saying "just one write attempt may fail" Unfortunately these failures sometimes end up causing an "-EILSEQ" back to the core which triggers a retuning of the SDIO card and that blocks all traffic to the card until it's done. Let's disable retuning around the commands we expect might fail. Fixes: bd11e8bd03ca ("mmc: core: Flag re-tuning is needed on CRC errors") Signed-off-by: Douglas Anderson --- Changes in v3: - Expect errors for all of brcmf_sdio_kso_control() (Adrian). Changes in v2: None drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index 4a750838d8cd..4040aae1f9ed 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -667,6 +668,8 @@ brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on) brcmf_dbg(TRACE, "Enter: on=%d\n", on); + mmc_expect_errors_begin(bus->sdiodev->func1->card->host); + wr_val = (on << SBSDIO_FUNC1_SLEEPCSR_KSO_SHIFT); /* 1st KSO write goes to AOS wake up core if device is asleep */ brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err); @@ -727,6 +730,8 @@ brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on) if (try_cnt > MAX_KSO_ATTEMPTS) brcmf_err("max tries: rd_val=0x%x err=%d\n", rd_val, err); + mmc_expect_errors_end(bus->sdiodev->func1->card->host); + return err; } From patchwork Fri Jun 7 22:37:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10982883 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4727C15E6 for ; Fri, 7 Jun 2019 22:37:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38F51288B9 for ; Fri, 7 Jun 2019 22:37:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CA8028BDA; Fri, 7 Jun 2019 22:37:59 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4095288B9 for ; Fri, 7 Jun 2019 22:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731660AbfFGWhr (ORCPT ); Fri, 7 Jun 2019 18:37:47 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40455 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731574AbfFGWhq (ORCPT ); Fri, 7 Jun 2019 18:37:46 -0400 Received: by mail-pl1-f195.google.com with SMTP id a93so1340210pla.7 for ; Fri, 07 Jun 2019 15:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8sTKn+NeNGftSNd5KJGe8Yb4ykjEmhycPSYA44kfjJY=; b=Ucg5J6CS84kZYZtbBhATrQIknzmFCKsyZ7LYk+YHEeYL4wOxQCtCRSkS3wIsUeuHkJ /LQxRvlY2IWw8HHiKuSX9ALH8ZzfyZEB4BNOJKcdMs2xn7gjThq+DFjBPyJ8y52VaHrx 2MH6k6VP9dROiEtG//1pGg4RL1jTW6bsCQPgg= 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=8sTKn+NeNGftSNd5KJGe8Yb4ykjEmhycPSYA44kfjJY=; b=eYZEYdQgDN/Pf7YStlsTjihYUSgQh6ZrNxwCmAo+fhjwdBqZZ0ZONTRYwYMDUgPgXi dhqXZtmi17cC4YIDB10VoCS2DfZWqjrc/KxMLo6q9MHNgYgytRQ9GhL5DKFL3cc+jhws o8O90A+y8xZL8pUzgjQ15vcM1Qy5pFSdX0V6PR7a/YocikD8nlHPPQ6JT+epWjgK1Bd2 6gEbX6nYTHuplcKscQEBikMYvod/IR24uhhC61rgDVSHcDNhQdOTWQT9cICziCZNNlka q/vIy4GnKzFZVg7eQ7qK6GNyrVus/40swDX4CeNOG+Dc8CcG+rushxfh1BPnRno5xCj6 J35g== X-Gm-Message-State: APjAAAXhZlHGfTVbgisticNtVGLHHiG158BH6/Za/9N2kcioOX2LJqMg 7W3/5G9C0LcFLLcO/VwomLpzJg== X-Google-Smtp-Source: APXvYqw1I/ZttnUQ8QkMd/Js4RpLH7dJjGMdXXIuPwxR4ePJkKWsj+UjjyQqqvZzmUs8Y7lbo3jcBw== X-Received: by 2002:a17:902:d88e:: with SMTP id b14mr7328462plz.153.1559947065437; Fri, 07 Jun 2019 15:37:45 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id j23sm4185193pgb.63.2019.06.07.15.37.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 15:37:44 -0700 (PDT) From: Douglas Anderson To: Ulf Hansson , Kalle Valo , Adrian Hunter , Arend van Spriel Cc: brcm80211-dev-list.pdl@broadcom.com, linux-rockchip@lists.infradead.org, Double Lo , briannorris@chromium.org, linux-wireless@vger.kernel.org, Naveen Gupta , Madhan Mohan R , mka@chromium.org, Wright Feng , Chi-Hsien Lin , netdev@vger.kernel.org, brcm80211-dev-list@cypress.com, Douglas Anderson , Martin Blumenstingl , Pan Bian , Linus Walleij , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Tony Lindgren , Mathieu Malaterre , Pavel Machek Subject: [PATCH v3 4/5] mmc: core: Export mmc_retune_hold_now() mmc_retune_release() Date: Fri, 7 Jun 2019 15:37:15 -0700 Message-Id: <20190607223716.119277-5-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog In-Reply-To: <20190607223716.119277-1-dianders@chromium.org> References: <20190607223716.119277-1-dianders@chromium.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We want SDIO drivers to be able to temporarily stop retuning when the driver knows that the SDIO card is not in a state where retuning will work (maybe because the card is asleep). We'll move the relevant functions to a place where drivers can call them. NOTE: We'll leave the calls with a mmc_ prefix following the lead of the API call mmc_hw_reset(), which is also expected to be called directly by SDIO cards. Signed-off-by: Douglas Anderson --- Changes in v3: - ("mmc: core: Export mmc_retune_hold_now() mmc_retune_release()") new for v3. Changes in v2: None drivers/mmc/core/host.c | 7 +++++++ drivers/mmc/core/host.h | 7 ------- include/linux/mmc/core.h | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 6a51f7a06ce7..361f4d151d20 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -111,6 +111,13 @@ void mmc_retune_hold(struct mmc_host *host) host->hold_retune += 1; } +void mmc_retune_hold_now(struct mmc_host *host) +{ + host->retune_now = 0; + host->hold_retune += 1; +} +EXPORT_SYMBOL(mmc_retune_hold_now); + void mmc_retune_release(struct mmc_host *host) { if (host->hold_retune) diff --git a/drivers/mmc/core/host.h b/drivers/mmc/core/host.h index 4805438c02ff..3212afc6c9fe 100644 --- a/drivers/mmc/core/host.h +++ b/drivers/mmc/core/host.h @@ -19,17 +19,10 @@ void mmc_unregister_host_class(void); void mmc_retune_enable(struct mmc_host *host); void mmc_retune_disable(struct mmc_host *host); void mmc_retune_hold(struct mmc_host *host); -void mmc_retune_release(struct mmc_host *host); int mmc_retune(struct mmc_host *host); void mmc_retune_pause(struct mmc_host *host); void mmc_retune_unpause(struct mmc_host *host); -static inline void mmc_retune_hold_now(struct mmc_host *host) -{ - host->retune_now = 0; - host->hold_retune += 1; -} - static inline void mmc_retune_recheck(struct mmc_host *host) { if (host->hold_retune <= 1) diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 02a13abf0cda..53085245383c 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -181,5 +181,7 @@ int mmc_sw_reset(struct mmc_host *host); void mmc_expect_errors_begin(struct mmc_host *host); void mmc_expect_errors_end(struct mmc_host *host); void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card); +void mmc_retune_release(struct mmc_host *host); +void mmc_retune_hold_now(struct mmc_host *host); #endif /* LINUX_MMC_CORE_H */ From patchwork Fri Jun 7 22:37:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10982887 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-2.web.codeaurora.org (Postfix) with ESMTP id 3BC3014C0 for ; Fri, 7 Jun 2019 22:38:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CBB6288B9 for ; Fri, 7 Jun 2019 22:38:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2074928BDA; Fri, 7 Jun 2019 22:38:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB25B288B9 for ; Fri, 7 Jun 2019 22:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731711AbfFGWh7 (ORCPT ); Fri, 7 Jun 2019 18:37:59 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:32905 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731591AbfFGWhr (ORCPT ); Fri, 7 Jun 2019 18:37:47 -0400 Received: by mail-pg1-f195.google.com with SMTP id k187so1375790pga.0 for ; Fri, 07 Jun 2019 15:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z4uQcLhxDEep9Dd0+N4T4ar1lYZLNVNOCQMZpRaAcgQ=; b=Wu5ODvnEgN+Dz3rZXFZGppPRarqh2wkcmSq/jdU0lxIYcSNaG6l9SM/cQ7rqNOQ+cx zxBOamHsP0cMwIo+6syFyWFHtQZ64LbEArNImhJSma0pDWnZQVdsP77XNYh/mmK0Dm2q qWYduKxF+F5spTIpgm3Rypp+nRk8xG2J2D5aM= 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=z4uQcLhxDEep9Dd0+N4T4ar1lYZLNVNOCQMZpRaAcgQ=; b=VLFIyR8pUdVIxgNKYKFTZ4tatutVNcr8ZzUBiHOLNR1j8bg4Moq9Dmc39av7dMyOe0 ntgpRsVhDySvX9UAMqkVPJA41GlCFpi5ND4VyYCKhJ1N19eShNVrlBeB/e5MpS1enNAt Thm6T+85JbnfkZ82+nw52XVVIDXp2f+9yH3+IkXorgk0/cLJm9aVhddyRO+7cuMUQrW5 s5iF7eIyKSdvwR5BseCQ8fOYoNbYKB7SKnNqprzWaazvEFw+2Yn7Ow71hxlYJ5+35ngc oq+xV2wr5m+e0X5/+3rALNV0LmpxHkLLYmAb5ujd2hArbNGzw2czQg+9osPWw7BJMCJu n6eQ== X-Gm-Message-State: APjAAAVu5ZEgqYnW8X+vjuvsS7YT7TafBvemIztxY9CmSGB3eZfOpyCK 3akVD2Z4IAhnl97+uQe1sDeRqw== X-Google-Smtp-Source: APXvYqxs31BYhnz3CuDYoW0F6K1ef/NQQc4dhUPxacP60w15cFP3tld8eeafi1pEevxCtCS+7gK93A== X-Received: by 2002:a17:90a:9504:: with SMTP id t4mr8420374pjo.100.1559947066689; Fri, 07 Jun 2019 15:37:46 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id j23sm4185193pgb.63.2019.06.07.15.37.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 15:37:46 -0700 (PDT) From: Douglas Anderson To: Ulf Hansson , Kalle Valo , Adrian Hunter , Arend van Spriel Cc: brcm80211-dev-list.pdl@broadcom.com, linux-rockchip@lists.infradead.org, Double Lo , briannorris@chromium.org, linux-wireless@vger.kernel.org, Naveen Gupta , Madhan Mohan R , mka@chromium.org, Wright Feng , Chi-Hsien Lin , netdev@vger.kernel.org, brcm80211-dev-list@cypress.com, Douglas Anderson , Franky Lin , linux-kernel@vger.kernel.org, Hante Meuleman , Ondrej Jirman , YueHaibing , "David S. Miller" Subject: [PATCH v3 5/5] brcmfmac: sdio: Don't tune while the card is off Date: Fri, 7 Jun 2019 15:37:16 -0700 Message-Id: <20190607223716.119277-6-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog In-Reply-To: <20190607223716.119277-1-dianders@chromium.org> References: <20190607223716.119277-1-dianders@chromium.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When Broadcom SDIO cards are idled they go to sleep and a whole separate subsystem takes over their SDIO communication. This is the Always-On-Subsystem (AOS) and it can't handle tuning requests. Specifically, as tested on rk3288-veyron-minnie (which reports having BCM4354/1 in dmesg), if I force a retune in brcmf_sdio_kso_control() when "on = 1" (aka we're transition from sleep to wake) by whacking: bus->sdiodev->func1->card->host->need_retune = 1 ...then I can often see tuning fail. In this case dw_mmc reports "All phases bad!"). Note that I don't get 100% failure, presumably because sometimes the card itself has already transitioned away from the AOS itself by the time we try to wake it up. If I force retuning when "on = 0" (AKA force retuning right before sending the command to go to sleep) then retuning is always OK. NOTE: we need _both_ this patch and the patch to avoid triggering tuning due to CRC errors in the sleep/wake transition, AKA ("brcmfmac: sdio: Disable auto-tuning around commands expected to fail"). Though both patches handle issues with Broadcom's AOS, the problems are distinct: 1. We want to defer (but not ignore) asynchronous (like timer-requested) tuning requests till the card is awake. However, we want to ignore CRC errors during the transition, we don't want to queue deferred tuning request. 2. You could imagine that the AOS could implement retuning but we could still get errors while transitioning in and out of the AOS. Similarly you could imagine a seamless transition into and out of the AOS (with no CRC errors) even if the AOS couldn't handle tuning. ALSO NOTE: presumably there is never a desperate need to retune in order to wake up the card, since doing so is impossible. Luckily the only way the card can get into sleep state is if we had a good enough tuning to send it a sleep command, so presumably that "good enough" tuning is enough to wake us up, at least with a few retries. Signed-off-by: Douglas Anderson --- Changes in v3: - ("brcmfmac: sdio: Don't tune while the card is off") new for v3. Changes in v2: None drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index 4040aae1f9ed..98ffb4e90e15 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -670,6 +670,10 @@ brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on) mmc_expect_errors_begin(bus->sdiodev->func1->card->host); + /* Cannot re-tune if device is asleep; defer till we're awake */ + if (on) + mmc_retune_hold_now(bus->sdiodev->func1->card->host); + wr_val = (on << SBSDIO_FUNC1_SLEEPCSR_KSO_SHIFT); /* 1st KSO write goes to AOS wake up core if device is asleep */ brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err); @@ -730,6 +734,9 @@ brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on) if (try_cnt > MAX_KSO_ATTEMPTS) brcmf_err("max tries: rd_val=0x%x err=%d\n", rd_val, err); + if (on) + mmc_retune_release(bus->sdiodev->func1->card->host); + mmc_expect_errors_end(bus->sdiodev->func1->card->host); return err;