From patchwork Mon Jul 22 19:39:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11053365 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 829A914F6 for ; Mon, 22 Jul 2019 19:42:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AF2727C2D for ; Mon, 22 Jul 2019 19:42:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EA9A28496; Mon, 22 Jul 2019 19:42:19 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D205327C2D for ; Mon, 22 Jul 2019 19:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=T+UJDhS5c/f809QFwWUQ4R/+/9KnLbcClcdyqlJ/7FM=; b=C2ZyVKcJ/3w/bl tntm90nlJvZOS/q9lYbR2DVwljwyaLzi6O4OlKj56NqAVLUcg0wBKTZ9+jrn3yK4cDkUV61ojrEks fCaIfen3ukR/EYa9I5bt3jtFn3ZAnsT14hd9Wn8KHnYTUdsVeoU8e3izygUWIdjVTzEGqx7+3H0pJ 7WMljnPkEE384MlGVfLhilhuUZjSbROi1eNhtRpmpaHjNVsFOPhHWFAbRKx+WzEQLgN5UhrigiQmH s66F4MZO45pCYXwbwzmR3LY57y4OmJ+FDLcAWno9lha0vDy9DKqatEqKUdaA3pwyQ/8JPqMJ8bmdb uVbCkRZ63kTBTOOtfDDA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hpeCN-0000cs-Ac; Mon, 22 Jul 2019 19:42:15 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hpeBe-00007G-Ow for linux-rockchip@lists.infradead.org; Mon, 22 Jul 2019 19:41:32 +0000 Received: by mail-pf1-x444.google.com with SMTP id m30so17873055pff.8 for ; Mon, 22 Jul 2019 12:41:30 -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=i2ydHyx146Gpo6F/4Mk5APlIfYtwAqU9vRc87LHJBOg=; b=AfWp26av7d1R0GVQBZqmVDo36nl/ONdvumK8cBMcUztafl3YzMOQbj4/Ut6lsbwQYy 2IDNfw3efcHERFPIOzf68rMcvJlkJCPORgBDyZvs+wnOumbE/nmtn788576/X8Nxv7Ms Q04HPAwn45lcvNsj0GEKx81i8tmNcG+fCQ1vI= 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=i2ydHyx146Gpo6F/4Mk5APlIfYtwAqU9vRc87LHJBOg=; b=q4vZU+xL4q9zagN/lWFTE1xms+9Y3LpjW1lSm4jVbxk2wrxnpUr237NDlmGO1eeewF NQX11RqOEo4hFVLldzxOhEEvNOfeB6QwxkXdzrJxkMtj5j40iswuqTDyNCU0l9GbqE4F IWN4PXJK1AXAPTkv05qCCogACVBC8Z7VB0CqVHLIOOLTVuYQmPmEux3i0gJ0CC82QpxG Qr4q+Tk4qT0eJttuILWg2St1FSEQovsqi/4J63++7yo+YcHYK2AcHP8EWsxvloO5ZYYf UYSrtcWQ5X7twUtYQAuWKoLp8OOvLs2FaVMzSGP7XSLDBYyhQsv9YRXtSDANqCZLRgni Irww== X-Gm-Message-State: APjAAAXXe+C6NPzGwFaks0dAljKLYfwm+oC6r1yC+GaLU8SRx4KWHUms va3l2m0XEaIgmstT2DrGXEM1wQ== X-Google-Smtp-Source: APXvYqxRbyCKEUMoA0Ph44+At0UA78EhAjWJ+Hp3Q5G6AQTNXv8xUqU98puubWwzR/JltKnz8oH/pQ== X-Received: by 2002:a63:1020:: with SMTP id f32mr43080141pgl.203.1563824490156; Mon, 22 Jul 2019 12:41:30 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id z4sm29838803pgp.80.2019.07.22.12.41.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 12:41:29 -0700 (PDT) From: Douglas Anderson To: Ulf Hansson , Kalle Valo , Adrian Hunter Subject: [PATCH v2 1/2] mmc: core: Add sdio_trigger_replug() API Date: Mon, 22 Jul 2019 12:39:38 -0700 Message-Id: <20190722193939.125578-2-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.657.g960e92d24f-goog In-Reply-To: <20190722193939.125578-1-dianders@chromium.org> References: <20190722193939.125578-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190722_124130_910859_7CCD6670 X-CRM114-Status: GOOD ( 23.10 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kate Stewart , Ganapathi Bhat , Brian Norris , Wolfram Sang , Xinming Hu , netdev@vger.kernel.org, Andreas Fenkart , linux-wireless@vger.kernel.org, Douglas Anderson , Amitkumar Karwar , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Nishant Sarmukadam , Matthias Kaehlcke , Avri Altman , linux-mmc@vger.kernel.org, Thomas Gleixner , davem@davemloft.net Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When using Marvell WiFi SDIO cards, it is not uncommon for Linux WiFi driver to fully lose the communication channel to the firmware running on the card. Presumably the firmware on the card has a bug or two in it and occasionally crashes. The Marvell WiFi driver attempts to recover from this problem. Specifically the driver has the function mwifiex_sdio_card_reset() which is called when communcation problems are found. That function attempts to reset the state of things by utilizing the mmc_hw_reset() function. The current solution is a bit complex because the Marvell WiFi driver needs to manually deinit and reinit the WiFi driver around the reset call. This means it's going through a bunch of code paths that aren't normally tested. However, complexity isn't our only problem. The other (bigger) problem is that Marvell WiFi cards are often combo WiFi/Bluetooth cards and Bluetooth runs on a second SDIO func. While the WiFi driver knows that it should re-init its own state around the mmc_hw_reset() call there is no good way to inform the Bluetooth driver. That means that in Linux today when you reset the Marvell WiFi driver you lose all Bluetooth communication. Doh! One way to fix the above problems is to leverage a more standard way to reset the Marvell WiFi card where we go through the same code paths as card unplug and the card plug. In this patch we introduce a new API call for doing just that: sdio_trigger_replug(). This API call will trigger an unplug of the SDIO card followed by a plug of the card. As part of this the card will be nicely reset. Signed-off-by: Douglas Anderson Reviewed-by: Matthias Kaehlcke --- Changes in v2: - s/routnine/routine (Brian Norris, Matthias Kaehlcke). - s/contining/containing (Matthias Kaehlcke). - Add Matthias Reviewed-by tag. drivers/mmc/core/core.c | 28 ++++++++++++++++++++++++++-- drivers/mmc/core/sdio_io.c | 20 ++++++++++++++++++++ include/linux/mmc/host.h | 15 ++++++++++++++- include/linux/mmc/sdio_func.h | 2 ++ 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 221127324709..5da365b1fdb4 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2161,6 +2161,12 @@ int mmc_sw_reset(struct mmc_host *host) } EXPORT_SYMBOL(mmc_sw_reset); +void mmc_trigger_replug(struct mmc_host *host) +{ + host->trigger_replug_state = MMC_REPLUG_STATE_UNPLUG; + _mmc_detect_change(host, 0, false); +} + static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) { host->f_init = freq; @@ -2214,6 +2220,11 @@ int _mmc_detect_card_removed(struct mmc_host *host) if (!host->card || mmc_card_removed(host->card)) return 1; + if (host->trigger_replug_state == MMC_REPLUG_STATE_UNPLUG) { + mmc_card_set_removed(host->card); + return 1; + } + ret = host->bus_ops->alive(host); /* @@ -2326,8 +2337,21 @@ void mmc_rescan(struct work_struct *work) mmc_bus_put(host); mmc_claim_host(host); - if (mmc_card_is_removable(host) && host->ops->get_cd && - host->ops->get_cd(host) == 0) { + + /* + * Move through the state machine if we're triggering an unplug + * followed by a re-plug. + */ + if (host->trigger_replug_state == MMC_REPLUG_STATE_UNPLUG) { + host->trigger_replug_state = MMC_REPLUG_STATE_PLUG; + _mmc_detect_change(host, 0, false); + } else if (host->trigger_replug_state == MMC_REPLUG_STATE_PLUG) { + host->trigger_replug_state = MMC_REPLUG_STATE_NONE; + } + + if (host->trigger_replug_state == MMC_REPLUG_STATE_PLUG || + (mmc_card_is_removable(host) && host->ops->get_cd && + host->ops->get_cd(host) == 0)) { mmc_power_off(host); mmc_release_host(host); goto out; diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c index 2ba00acf64e6..9b96267ac855 100644 --- a/drivers/mmc/core/sdio_io.c +++ b/drivers/mmc/core/sdio_io.c @@ -811,3 +811,23 @@ void sdio_retune_release(struct sdio_func *func) mmc_retune_release(func->card->host); } EXPORT_SYMBOL_GPL(sdio_retune_release); + +/** + * sdio_trigger_replug - trigger an "unplug" + "plug" of the card + * @func: SDIO function attached to host + * + * When you call this function we will schedule events that will + * make it look like the card containing the given SDIO func was + * unplugged and then re-plugged-in. This is as close as possible + * to a full reset of the card that can be achieved. + * + * NOTE: routine will temporarily make the card look as if it is + * removable even if it is marked non-removable. + * + * This function should be called while the host is claimed. + */ +void sdio_trigger_replug(struct sdio_func *func) +{ + mmc_trigger_replug(func->card->host); +} +EXPORT_SYMBOL(sdio_trigger_replug); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 4a351cb7f20f..40f21b3e6aaf 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -407,6 +407,12 @@ struct mmc_host { bool trigger_card_event; /* card_event necessary */ + /* state machine for triggering unplug/replug */ +#define MMC_REPLUG_STATE_NONE 0 /* not doing unplug/replug */ +#define MMC_REPLUG_STATE_UNPLUG 1 /* do unplug next */ +#define MMC_REPLUG_STATE_PLUG 2 /* do plug next */ + u8 trigger_replug_state; + struct mmc_card *card; /* device attached to this host */ wait_queue_head_t wq; @@ -527,7 +533,12 @@ int mmc_regulator_get_supply(struct mmc_host *mmc); static inline int mmc_card_is_removable(struct mmc_host *host) { - return !(host->caps & MMC_CAP_NONREMOVABLE); + /* + * A non-removable card briefly looks removable if code has forced + * a re-plug of the card. + */ + return host->trigger_replug_state != MMC_REPLUG_STATE_NONE || + !(host->caps & MMC_CAP_NONREMOVABLE); } static inline int mmc_card_keep_power(struct mmc_host *host) @@ -580,4 +591,6 @@ static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data) int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error); int mmc_abort_tuning(struct mmc_host *host, u32 opcode); +void mmc_trigger_replug(struct mmc_host *host); + #endif /* LINUX_MMC_HOST_H */ diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h index 5a177f7a83c3..0d6c73768ae3 100644 --- a/include/linux/mmc/sdio_func.h +++ b/include/linux/mmc/sdio_func.h @@ -173,4 +173,6 @@ extern void sdio_retune_crc_enable(struct sdio_func *func); extern void sdio_retune_hold_now(struct sdio_func *func); extern void sdio_retune_release(struct sdio_func *func); +extern void sdio_trigger_replug(struct sdio_func *func); + #endif /* LINUX_MMC_SDIO_FUNC_H */ From patchwork Mon Jul 22 19:39:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11053367 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 8970914F6 for ; Mon, 22 Jul 2019 19:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7863D27C2D for ; Mon, 22 Jul 2019 19:42:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C5E128496; Mon, 22 Jul 2019 19:42:21 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D55D27C2D for ; Mon, 22 Jul 2019 19:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VWG3kyeWo9/pNBZJEI8wk36ArZjhK+8X+zFmZ6JeZIo=; b=VzTxH7Nvv0l6GG zqxrf3NmaR6LujJzatqtMzqgOR7F6mVCIo/ORx2pARZ+5mzXj7aLFTyrad3HHodpp2gbqazAc4GA5 NFEoOoiXXXYOEZy26t9w2G/Dsq/th7m70FWPIqZ1t9WwFCIO+uT4EUNbU2fCK4pNMimmdK+C1937F G+FmPwPYACrqRok+h/z6kdQ2I0yVI6YnF0UlDV/NZKqBame6D9PtfhkIfQyY4XJNX6quu7+iJWrnB xccAGhErC3vMlTk4QEdJ6BhHN9G8rCXzuyWtqcvondUWxaWmlTG9nU/Twg2oh9uWNypmHJLIJr6Wd ySfszRVh1Dk40o4f7c1Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hpeCQ-0000fO-Qr; Mon, 22 Jul 2019 19:42:18 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hpeBg-00008P-Bs for linux-rockchip@lists.infradead.org; Mon, 22 Jul 2019 19:41:34 +0000 Received: by mail-pf1-x442.google.com with SMTP id y15so17868653pfn.5 for ; Mon, 22 Jul 2019 12:41:32 -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=ATbFy1aIdbWHFM03S3oai17NaO/neBJFfQYViTxrNMs=; b=fLXr6gDQl11kx/gfLPu/pKAYQ3oWpeGmz6q8QFeSzDdvzyBV3Jixq5ya13oHO5dqfo Nt5xcerqY4a9O3JWvuPb94Tyrayne1SI5T6+UGeut3CsFAKBfhZw9yU7Q5/RHukXvoYY cqcqRPZNeTl+YDf2PzrHdCfdrC3TgIUq6fJSI= 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=ATbFy1aIdbWHFM03S3oai17NaO/neBJFfQYViTxrNMs=; b=imjQaNv+UhUdf/fuVfMeGT9lyOKWxe2xWDClzmpgDuNVyPukvoe57kR6DolorIHFSy VUkrwWIIh247BwWyOKnwu47Oj621SmmAd59eg6dLFhbLcpvGEHs00rIoRKaVkV+zgnHc pn64Ip7BBh1J/ugXVqef9xn8S2l+TL+i7c6as4z9uDmjP2GVHQo0DSdFihPDNnS0CZqB RPykkGGZk4gDktLspe8niVyqZgylIxY1ErQ0phQDbmV4Menf5GlWqmynslu9UG7w40G3 6mBrTBHOi3q8NUkBDxmN911EoimuvozxX7+v/LP6vIYulcRdsmNLe9DyVsoLatkYz1h1 WqBQ== X-Gm-Message-State: APjAAAX9BTw7WD1Ds6ciexgz1rZ+FhlQ1DeM9YRZheYVuh5DyIc8NRXb rnZdS5Et8aG+9R3yRgB3cOgFGGyLM4M= X-Google-Smtp-Source: APXvYqxe3jk2Td0NZ3MiOAVs4zOozU2NCyEe4BhAwMABU222PrrTzeC4C4T+vjjW5dwEp508Pc+S0A== X-Received: by 2002:a17:90a:ba93:: with SMTP id t19mr77532204pjr.139.1563824491627; Mon, 22 Jul 2019 12:41:31 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id z4sm29838803pgp.80.2019.07.22.12.41.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 22 Jul 2019 12:41:31 -0700 (PDT) From: Douglas Anderson To: Ulf Hansson , Kalle Valo , Adrian Hunter Subject: [PATCH v2 2/2] mwifiex: Make use of the new sdio_trigger_replug() API to reset Date: Mon, 22 Jul 2019 12:39:39 -0700 Message-Id: <20190722193939.125578-3-dianders@chromium.org> X-Mailer: git-send-email 2.22.0.657.g960e92d24f-goog In-Reply-To: <20190722193939.125578-1-dianders@chromium.org> References: <20190722193939.125578-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190722_124132_580498_41155A25 X-CRM114-Status: GOOD ( 14.48 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ganapathi Bhat , Brian Norris , Wolfram Sang , Xinming Hu , netdev@vger.kernel.org, Andreas Fenkart , linux-wireless@vger.kernel.org, Douglas Anderson , Amitkumar Karwar , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Nishant Sarmukadam , Avri Altman , linux-mmc@vger.kernel.org, davem@davemloft.net Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP As described in the patch ("mmc: core: Add sdio_trigger_replug() API"), the current mwifiex_sdio_card_reset() is broken in the cases where we're running Bluetooth on a second SDIO func on the same card as WiFi. The problem goes away if we just use the sdio_trigger_replug() API call. NOTE: Even though with this new solution there is less of a reason to do our work from a workqueue (the unplug / plug mechanism we're using is possible for a human to perform at any time so the stack is supposed to handle it without it needing to be called from a special context), we still need a workqueue because the Marvell reset function could called from a context where sleeping is invalid and thus we can't claim the host. One example is Marvell's wakeup_timer_fn(). Cc: Andreas Fenkart Cc: Brian Norris Fixes: b4336a282db8 ("mwifiex: sdio: reset adapter using mmc_hw_reset") Signed-off-by: Douglas Anderson Reviewed-by: Brian Norris Acked-by: Kalle Valo --- Changes in v2: - Removed clear_bit() calls and old comment (Brian Norris). - Explicit CC of Andreas Fenkart. - Explicit CC of Brian Norris. - Add "Fixes" pointing at the commit Brian talked about. - Add Brian's Reviewed-by tag. drivers/net/wireless/marvell/mwifiex/sdio.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index 24c041dad9f6..7ec5068f6ffd 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c @@ -2218,24 +2218,10 @@ static void mwifiex_sdio_card_reset_work(struct mwifiex_adapter *adapter) { struct sdio_mmc_card *card = adapter->card; struct sdio_func *func = card->func; - int ret; - - mwifiex_shutdown_sw(adapter); - /* power cycle the adapter */ sdio_claim_host(func); - mmc_hw_reset(func->card->host); + sdio_trigger_replug(func); sdio_release_host(func); - - /* Previous save_adapter won't be valid after this. We will cancel - * pending work requests. - */ - clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags); - clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags); - - ret = mwifiex_reinit_sw(adapter); - if (ret) - dev_err(&func->dev, "reinit failed: %d\n", ret); } /* This function read/write firmware */