From patchwork Mon Dec 17 16:42:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 10734021 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 D682713AD for ; Mon, 17 Dec 2018 16:42:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C77FA2A22F for ; Mon, 17 Dec 2018 16:42:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6C3A2A228; Mon, 17 Dec 2018 16:42:32 +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=-7.9 required=2.0 tests=BAYES_00,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 769E82A22D for ; Mon, 17 Dec 2018 16:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388279AbeLQQma (ORCPT ); Mon, 17 Dec 2018 11:42:30 -0500 Received: from muru.com ([72.249.23.125]:58570 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388011AbeLQQma (ORCPT ); Mon, 17 Dec 2018 11:42:30 -0500 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 5FF4E80DB; Mon, 17 Dec 2018 16:42:33 +0000 (UTC) From: Tony Lindgren To: Kalle Valo Cc: Eyal Reizer , Kishon Vijay Abraham I , Guy Mishol , linux-wireless@vger.kernel.org, linux-omap@vger.kernel.org, Anders Roxell , John Stultz , Ricardo Salveti , Ulf Hansson Subject: [PATCH] wlcore: Fix bringing up wlan0 again if powered down briefly Date: Mon, 17 Dec 2018 08:42:07 -0800 Message-Id: <20181217164207.20081-1-tony@atomide.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP At least HiKey board can fail to bring up wireless interface again if the interface is brought down and up with no delay inbetween. This can be done tested with: # while true; do ifconfig wlan0 down; ifconfig wlan0 up; done According to Ricardo Salveti , we need to wait between 30 - 40 ms on HiKey. This seems to happen when we get -EBUSY returned by pm_runtime_put() basedon the check in rpm_check_suspend_allowed(). But as it still unclear if part of the delay needed is because of capacitance, let's always do a at least 50 ms msleep even if no -EBUSY is returned. Cc: Anders Roxell Cc: Eyal Reizer Cc: John Stultz Cc: Ricardo Salveti Cc: Ulf Hansson Reported-by: Ricardo Salveti Fixes: 60f36637bbbd ("wlcore: sdio: allow pm to handle sdio power") Signed-off-by: Tony Lindgren Tested-by: Ricardo Salveti --- Uffe, do you have some better ideas on how to fix this issue? --- drivers/net/wireless/ti/wlcore/sdio.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c --- a/drivers/net/wireless/ti/wlcore/sdio.c +++ b/drivers/net/wireless/ti/wlcore/sdio.c @@ -174,7 +174,7 @@ static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) { struct sdio_func *func = dev_to_sdio_func(glue->dev); struct mmc_card *card = func->card; - int error; + int error, retries = 5; sdio_claim_host(func); sdio_disable_func(func); @@ -188,6 +188,17 @@ static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) return error; } + /* Wait a bit to ensure the card gets power off. Otherwise + * bringing interface down and up again may not power off the + * card inbetween. And then firmware load will fail on trying + * to bring the card up again. We need to wait between 30 - 40 + * ms for this based on measurements on HiKey board. + */ + do { + msleep(50); + } while (error == -EBUSY && !pm_runtime_suspended(&card->dev) && + retries--); + return 0; }