Received: by 10.223.185.116 with SMTP id b49csp1025737wrg; Wed, 21 Feb 2018 10:47:07 -0800 (PST) X-Google-Smtp-Source: AH8x227T5clKpkj9OWNwHqwERJUYReS8k3nR+tmMUrG8xGxe5gkLiTSLIaAa8dsQI3WNKNpLHbA2 X-Received: by 2002:a17:902:8a94:: with SMTP id p20-v6mr3948590plo.373.1519238826982; Wed, 21 Feb 2018 10:47:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238826; cv=none; d=google.com; s=arc-20160816; b=BNG8Z/DFAbeCyBjqlrYJtTlcFkqIKbbW7is/1LBHXmfJTDB/tKaeEkg+V14cUxIB2K h6fXD32qQQbgzjOwyYIynbbsHFT9xiTjDtCNqluEkaUWTmHxgg/Nz6WjIr/Vk+N2K7FN 5xDYyXL3zKUhdjJNvEeHm0nU85TgJua7Rkz1oxr0k61hCbJ+1g6N+9wPwhuqw/hYvWj+ L800pi3aOebL9Uy1Jb6YNS/rxQUeHc6dZ/E7fUGaj0ERoYfDyOxgCthYO0mWDnFBj2KA MtwMg7IdKH78L054IxpEvGUlthHnvz1sJ06MxDGeP51TNh3QVgmJ+7jtvUS9okaUfVxs RhZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mNnhNLganIqW1Dcc+gnYfxMfkri6ACaQVpLrl547akQ=; b=E7+xCH3QRz1TWf5NUXg6w9IDNsa4gUDQCSCzxaV4mqndvX1On2uIFunZfM0CzKma19 mrO/nM81+yF6JEhuWHiuF7MWf11p6OR+wDoUqmh692Zd7L3BO1nM1TaLOC0oSKE37imJ gNt66wT1BuRyJuri2mUc2f1mxXxhO7A9wNitxkyUsjV5GsAQyJfK9OL9TZl9MXRW2nEp PCPyBJDF6cyfVUGQT4JVviT6KHp8Z0ey5+k+YYlxnNCW8AcEF0uQQqI4HtKeXJ2EfosS TEsELmwJly97PkJ9GWhknux3uywCo7tyzhCDTGDs9N9Ry1BMdqTyPzx4RUky0NjXEBUw GHrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12-v6si146000plk.60.2018.02.21.10.46.52; Wed, 21 Feb 2018 10:47:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936749AbeBUNsS (ORCPT + 99 others); Wed, 21 Feb 2018 08:48:18 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40578 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964974AbeBUNGK (ORCPT ); Wed, 21 Feb 2018 08:06:10 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D801111CE; Wed, 21 Feb 2018 13:06:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xinming Hu , Brian Norris , Kalle Valo Subject: [PATCH 4.15 016/163] mwifiex: resolve reset vs. remove()/shutdown() deadlocks Date: Wed, 21 Feb 2018 13:47:25 +0100 Message-Id: <20180221124531.017523032@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Brian Norris commit a64e7a79dd6030479caad603c8d78e6c9c14904f upstream. Commit b014e96d1abb ("PCI: Protect pci_error_handlers->reset_notify() usage with device_lock()") resolves races between driver reset and removal, but it introduces some new deadlock problems. If we see a timeout while we've already started suspending, removing, or shutting down the driver, we might see: (a) a worker thread, running mwifiex_pcie_work() -> mwifiex_pcie_card_reset_work() -> pci_reset_function() (b) a removal thread, running mwifiex_pcie_remove() -> mwifiex_free_adapter() -> mwifiex_unregister() -> mwifiex_cleanup_pcie() -> cancel_work_sync(&card->work) Unfortunately, mwifiex_pcie_remove() already holds the device lock that pci_reset_function() is now requesting, and so we see a deadlock. It's necessary to cancel and synchronize our outstanding work before tearing down the driver, so we can't have this work wait indefinitely for the lock. It's reasonable to only "try" to reset here, since this will mostly happen for cases where it's already difficult to reset the firmware anyway (e.g., while we're suspending or powering off the system). And if reset *really* needs to happen, we can always try again later. Fixes: b014e96d1abb ("PCI: Protect pci_error_handlers->reset_notify() usage with device_lock()") Cc: Cc: Xinming Hu Signed-off-by: Brian Norris Signed-off-by: Kalle Valo Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/marvell/mwifiex/pcie.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -2781,7 +2781,10 @@ static void mwifiex_pcie_card_reset_work { struct pcie_service_card *card = adapter->card; - pci_reset_function(card->dev); + /* We can't afford to wait here; remove() might be waiting on us. If we + * can't grab the device lock, maybe we'll get another chance later. + */ + pci_try_reset_function(card->dev); } static void mwifiex_pcie_work(struct work_struct *work)