From patchwork Thu Nov 10 11:57:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinming Hu X-Patchwork-Id: 9420983 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 E7C40601C0 for ; Thu, 10 Nov 2016 11:58:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1BDE2954D for ; Thu, 10 Nov 2016 11:58:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C633B29676; Thu, 10 Nov 2016 11:58:48 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 BFC8E2954D for ; Thu, 10 Nov 2016 11:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755676AbcKJL5z (ORCPT ); Thu, 10 Nov 2016 06:57:55 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34229 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755660AbcKJL5y (ORCPT ); Thu, 10 Nov 2016 06:57:54 -0500 Received: by mail-pf0-f193.google.com with SMTP id y68so3976393pfb.1 for ; Thu, 10 Nov 2016 03:57:54 -0800 (PST) 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=xvg/A1xV106f7iAtYydF/mie+w4GLxgRQvWiRpGEZ+0=; b=KHTVeJ28hCjLE/P5m49LydTfaNMeKSIBUeOLMciRuK6hWcT0sM6nywaEum9h+qH1Ab UUyh1Bgjon8JXOEvVKW6Pcy8BohB8ce+5BoQgyimd+ye5WvyzyHipppn9u8XP7+6mC5I B3jb3IIuY0DSr4+Fq3pGmVyvQgQ4OMrauxsTewD51+c0C2emPTukExT2ySGYHm8bPKyb kN4RJX/yJaty2VE/Dck+6fDQMVYktCfK31kRArglwnSmtBcPq8ia53WEb2g1MznzHi1L ykvEAzjtaBNKOF8tZ8gHaXOe+rscbenACZqbYMk5CmnQ+QRcI3BKkyEuPmuL6Cwnd1WL z6PA== 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=xvg/A1xV106f7iAtYydF/mie+w4GLxgRQvWiRpGEZ+0=; b=T8/z6Yxx6CFWvYXszWEFjmQITPex611TT6IS3kPpFvLFLbSym2tEmR8nb9YcF7Jxck hBqgM24P2foF95pV5w1C9mZhUrz05DiyuOFsNQ8MoQiCrBuAVIiJS9rO9bTmEI6JufCT sdaOwSy4vcaq6GLGpK+Yeo4s2NlUYH5VmDAe9ZuRGsh/vL3DlwNRdJKsMNYIaBCPOiYx jfpf3EvUif+2/IEKiVAPENEmjkQopwYRQvpaIdwhE87d0AqEEWpxnMZOi+a7RXmq1lTv MsFoMSvxxuswk5B4OeaBpx+2CSBiX9G5S2tkbnmtEcw5qIOkKcOn2FbGyD9CbbZMo1ca sweg== X-Gm-Message-State: ABUngvf9yLbIWJzFxMDyL47gEcfIJA2rVJixrRDUwry7ZPyINFZistzoNHiCVdAkqNnxZQ== X-Received: by 10.98.72.81 with SMTP id v78mr9481749pfa.104.1478779073600; Thu, 10 Nov 2016 03:57:53 -0800 (PST) Received: from localhost.localdomain ([216.207.47.6]) by smtp.gmail.com with ESMTPSA id v10sm6740890pag.44.2016.11.10.03.57.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Nov 2016 03:57:53 -0800 (PST) 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 RESEND v2 06/11] mwifiex: resolve suspend() race with async FW init failure Date: Thu, 10 Nov 2016 19:57:07 +0800 Message-Id: <1478779032-5165-6-git-send-email-huxinming820@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1478779032-5165-1-git-send-email-huxinming820@marvell.com> References: <1478779032-5165-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 Signed-off-by: Brian Norris --- v2: Same as v1 --- drivers/net/wireless/marvell/mwifiex/pcie.c | 12 ++++++++++-- drivers/net/wireless/marvell/mwifiex/sdio.c | 12 ++++++++++-- drivers/net/wireless/marvell/mwifiex/usb.c | 12 ++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index a2353f9..4d96683 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -118,12 +118,20 @@ 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, "card 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, "adapter is not valid\n"); + return 0; + } + mwifiex_enable_wake(adapter); /* Enable the Host Sleep */ diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index a2257a4..39ffe7d 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c @@ -285,8 +285,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 { @@ -294,7 +294,15 @@ 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, "adapter is not valid\n"); + return 0; + } + mwifiex_enable_wake(adapter); /* Enable the Host Sleep */ diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c index 558a7f1..671702c 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,