From patchwork Wed Nov 2 02:24:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinming Hu X-Patchwork-Id: 9408403 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.web.codeaurora.org (Postfix) with ESMTP id 0F60560721 for ; Wed, 2 Nov 2016 02:26:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F04F629D2A for ; Wed, 2 Nov 2016 02:26:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4F7329D2C; Wed, 2 Nov 2016 02:26: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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 1260629D2B for ; Wed, 2 Nov 2016 02:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755249AbcKBCZ4 (ORCPT ); Tue, 1 Nov 2016 22:25:56 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33880 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755059AbcKBCZz (ORCPT ); Tue, 1 Nov 2016 22:25:55 -0400 Received: by mail-pf0-f194.google.com with SMTP id y68so272837pfb.1 for ; Tue, 01 Nov 2016 19:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PctHecBNBU4oRFaOdPRp96inUGf/5bDjSdkiZMtBU18=; b=dqrnAD1t8LF0JMRZexszn0SqTubgRa7c81wHnFY8kW5reiTdV0hdN31boTOYbT8le1 rh2JLaqrStJ2IwgkIv4gKz+6v6T6VCt4l5AiMzGDEaQFcqdXD1M6mpXsYk7aIGEGcuxC Tl70p0pRHlglemfyRVaYrWDaNtaQIN2lBn1BPwZdJjrOptS6fjSNrHu54gzQvKYJNBiZ O6gEtE1H63NgOhsLk55X9Q0IHqu8mI6MclBD9Y+gTncvXp9GhhIJ5lBA6OQKAVzMaRav 4onQmqvxGjP2hlY/OvPK0HyALuUqQD1z9/cFpt7sfgWsGkAqgxCBpp8wNWG9tEwSk1eT wIEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PctHecBNBU4oRFaOdPRp96inUGf/5bDjSdkiZMtBU18=; b=X0JYFm5pWU3uOv9xQWjyjz5ymdDRYkZ5a6Y3uVo04l3E/EX2/3b6MNwqqrKGjJ9GJ8 QVa21SIo5G7j2MYESTpVLNaali3koOlhAfhnMdeklkfokhcTEf2Q7YzbT+wJK3k123tT r9zQRrUzc83DM506/+ekG6IBI+R9DQXWyP+0GPNa/JALo7J9yKFl2uN5/vSeQu5FTTjF OoqzDbpABwbFpQohIjPHMRDKgsAzIno0BKp5MWXMLI++mOBtz3Sfc/zY7M/gj0mh3/CN t7WmVSJsdzpRG+VPHZ0aykjJOtvtvUiKcvJ97mP2cBkivg1Op8aGrr1AFK1VkcZ7sEtu 4pSQ== X-Gm-Message-State: ABUngvf38ws22TjUwn0gegOC/SnCzyz+U58+POfilvHnKstsao4aFN3j0ptO73lWjY+CDg== X-Received: by 10.99.171.3 with SMTP id p3mr1906515pgf.119.1478053554326; Tue, 01 Nov 2016 19:25:54 -0700 (PDT) Received: from localhost.localdomain ([216.207.47.6]) by smtp.gmail.com with ESMTPSA id tx10sm36409076pab.40.2016.11.01.19.25.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Nov 2016 19:25:53 -0700 (PDT) From: Xinming Hu X-Google-Original-From: Xinming Hu To: Linux Wireless Cc: Kalle Valo , Brian Norris , Dmitry Torokhov , Amitkumar Karwar , Cathy Luo , Brian Norris Subject: [PATCH v2 07/12] mwifiex: resolve suspend() race with async FW init failure Date: Wed, 2 Nov 2016 10:24:43 +0800 Message-Id: <1478053488-16042-5-git-send-email-huxinming820@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1478053488-16042-1-git-send-email-huxinming820@marvell.com> References: <1478053488-16042-1-git-send-email-huxinming820@marvell.com> 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 From: Brian Norris --- v2: Same as v1 --- Signed-off-by: Brian Norris --- drivers/net/wireless/marvell/mwifiex/pcie.c | 11 +++++++++-- drivers/net/wireless/marvell/mwifiex/sdio.c | 11 +++++++++-- drivers/net/wireless/marvell/mwifiex/usb.c | 12 ++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 32fbb91..b635563 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -102,12 +102,19 @@ static int mwifiex_pcie_suspend(struct device *dev) struct pci_dev *pdev = to_pci_dev(dev); card = pci_get_drvdata(pdev); - if (!card || !card->adapter) { - pr_err("Card or adapter structure is not valid\n"); + if (!card) { + dev_err(dev, "adapter structure is not valid\n"); return 0; } + /* Might still be loading firmware */ + wait_for_completion(&card->fw_done); + adapter = card->adapter; + if (!adapter) { + dev_err(dev, "card is not valid\n"); + return 0; + } /* Enable the Host Sleep */ if (!mwifiex_enable_hs(adapter)) { diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index a750edb..4d314c1 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c @@ -331,8 +331,8 @@ static int mwifiex_sdio_suspend(struct device *dev) } card = sdio_get_drvdata(func); - if (!card || !card->adapter) { - pr_err("suspend: invalid card or adapter\n"); + if (!card) { + dev_err(dev, "suspend: invalid card\n"); return 0; } } else { @@ -340,7 +340,14 @@ static int mwifiex_sdio_suspend(struct device *dev) return 0; } + /* Might still be loading firmware */ + wait_for_completion(&card->fw_done); + adapter = card->adapter; + if (!adapter) { + dev_err(dev, "card is not valid\n"); + return 0; + } /* Enable platform specific wakeup interrupt */ if (card->plt_wake_cfg && card->plt_wake_cfg->irq_wifi >= 0) { diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c index a61455c..70126c3 100644 --- a/drivers/net/wireless/marvell/mwifiex/usb.c +++ b/drivers/net/wireless/marvell/mwifiex/usb.c @@ -503,11 +503,19 @@ static int mwifiex_usb_suspend(struct usb_interface *intf, pm_message_t message) struct usb_tx_data_port *port; int i, j; - if (!card || !card->adapter) { - pr_err("%s: card or card->adapter is NULL\n", __func__); + if (!card) { + dev_err(&intf->dev, "%s: card is NULL\n", __func__); return 0; } + + /* Might still be loading firmware */ + wait_for_completion(&card->fw_done); + adapter = card->adapter; + if (!adapter) { + dev_err(&intf->dev, "card is not valid\n"); + return 0; + } if (unlikely(adapter->is_suspended)) mwifiex_dbg(adapter, WARN,