From patchwork Tue Jan 15 15:04:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10764707 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 A175D184E for ; Tue, 15 Jan 2019 15:04:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91BFE2AC3D for ; Tue, 15 Jan 2019 15:04:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E9C42CD65; Tue, 15 Jan 2019 15:04:47 +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 3563A2AD9E for ; Tue, 15 Jan 2019 15:04:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730612AbfAOPEp (ORCPT ); Tue, 15 Jan 2019 10:04:45 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:47021 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726077AbfAOPEl (ORCPT ); Tue, 15 Jan 2019 10:04:41 -0500 Received: by mail-lf1-f68.google.com with SMTP id y14so2241815lfg.13 for ; Tue, 15 Jan 2019 07:04:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=KB+g7eKeJjC3ka4b3nc5CCCT6CKjA+7sv61OrWFHims=; b=DwDltzljmC67hvozDhb8jEP6SLD+qIaP/sF4hn0phWOQJD0VVCmz8aUvbHgs2SOueu PnSnS5Zpjfuw3f0EuMOgYECYM/IAtw3dyv4nTDprKV3E8tPh0eXIuY18qRLfrEArNkPT QaeMPZp3t3io8jRRX52xb4yZMzINQPB+U2IWI= 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; bh=KB+g7eKeJjC3ka4b3nc5CCCT6CKjA+7sv61OrWFHims=; b=rqlj9+Fdr2+hI0PBDY0dEn7pfhZW2LmyMMvYyJEE6E1kxOatAUpCxH5CzTXIc064n1 XVvuDA0Ta1vm3HYM6Tk130TYyuicPE6uBS3MJwxxTka8Aqi8pzwEcsk+E9aROVOynvSN HBJP9uku7DZG95yqBVSxBoEHQs/mMydFrACXWiBS+0/cQMNCu7d8CgLOrSN5fI2ei90L XKb1F8ZsGy19gvohEzwABesQX4kdOIedLcLPJVSMKyhd2UTxTqPgWhjUrrLRJ5zPIfFB jD+dv+oaUi2Z7+KvHjN/qb7Ozb9p8Qty0wR8DYt3NCTNu2FW34w9sHt0pREI2NlUxV/p TaTg== X-Gm-Message-State: AJcUukeKqD/CMaT4iDv82eg6b+5BAYHaW5Oys8t+/ZklqhFUCeCc+oP+ bLtvaNov7rSKMyg4HALd2fFtcw== X-Google-Smtp-Source: ALg8bN7WOKqCa3IrpISaplME60JVrWY0qDoHtpu1vYYn//J/nwaFnqgY2GVIhr6CVQOWvDLW6YuMdQ== X-Received: by 2002:a19:c995:: with SMTP id z143mr2907187lff.79.1547564679112; Tue, 15 Jan 2019 07:04:39 -0800 (PST) Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id p23sm667304lfh.47.2019.01.15.07.04.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 07:04:38 -0800 (PST) From: Ulf Hansson To: Kalle Valo , Tony Lindgren , Eyal Reizer , linux-wireless@vger.kernel.org Cc: Ricardo Salveti , Kishon Vijay Abraham I , Anders Roxell , John Stultz , Jan Kiszka , Ulf Hansson , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH] wlcore: sdio: Fixup power on/off sequence Date: Tue, 15 Jan 2019 16:04:33 +0100 Message-Id: <20190115150433.12558-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 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 During "wlan-up", we are programming the FW into the WiFi-chip. However, re-programming the FW doesn't work, unless a power cycle of the WiFi-chip is made in-between the programmings. To conform to this requirement and to fix the regression in a simple way, let's start by allowing that the SDIO card (WiFi-chip) may stay powered on (runtime resumed) when wl12xx_sdio_power_off() returns. The intent with the current code is to treat this scenario as an error, but unfortunate this doesn't work as expected, so let's fix this. The other part is to guarantee that a power cycle of the SDIO card has been completed when wl12xx_sdio_power_on() returns, as to allow the FW programming to succeed. However, relying solely on runtime PM to deal with this isn't sufficient. For example, userspace may prevent runtime suspend via sysfs for the device that represents the SDIO card, leading to that the mmc core also keeps it powered on. For this reason, let's instead do a brute force power cycle in wl12xx_sdio_power_on(). Signed-off-by: Ulf Hansson --- drivers/net/wireless/ti/wlcore/sdio.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ti/wlcore/sdio.c b/drivers/net/wireless/ti/wlcore/sdio.c index bd10165d7eec..bc73085fe806 100644 --- a/drivers/net/wireless/ti/wlcore/sdio.c +++ b/drivers/net/wireless/ti/wlcore/sdio.c @@ -163,6 +163,12 @@ static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) return ret; } + /* + * To guarantee that the SDIO card is power cycled, as required to make + * the FW programming to succeed, let's do a brute force HW reset. + */ + mmc_hw_reset(card->host); + sdio_claim_host(func); sdio_enable_func(func); sdio_release_host(func); @@ -174,20 +180,13 @@ 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; sdio_claim_host(func); sdio_disable_func(func); sdio_release_host(func); /* Let runtime PM know the card is powered off */ - error = pm_runtime_put(&card->dev); - if (error < 0 && error != -EBUSY) { - dev_err(&card->dev, "%s failed: %i\n", __func__, error); - - return error; - } - + pm_runtime_put(&card->dev); return 0; }