Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp732003ybc; Sat, 16 Nov 2019 07:44:19 -0800 (PST) X-Google-Smtp-Source: APXvYqy4LB4bWAGJZvkB6RtLQnE7Cn5r80y6BgBnSuRp+2AgfBjnaz1Ro+JOR5F9xnStGqLLcQNW X-Received: by 2002:a17:906:4e48:: with SMTP id g8mr10504066ejw.67.1573919059011; Sat, 16 Nov 2019 07:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573919059; cv=none; d=google.com; s=arc-20160816; b=isZsWXsHYF1ZUeuftLx8I7JPYtc2O3JVOns8+AJWLKdEJZXJKZ8NtauX6tMO2nl57f gebwiwgwsiwhdqD/P36BPXbNIVa2YsDdQWAncBNRMiygTzXof/D4J3QeOZoo+tVkx2Gc /XkrfiFmpbzFgfzDb8vOQB8BiUZF0dJeDbAudEPmqk4SKPBRF6uux8RXJ3FaVN4iLy+6 KqgkDspeA2OdY1PUJo1e/c42JMNGU1oNs0fcnk1ikkVZh3hu4pzOYw5rL7I+/btsaab2 P+KllXwduPhXdgoQXyUu7VzaZ6357ErLALTiouT+8Osm5Km/U9etF9UpjgZa0Hq3tjzp GIcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=po1HK7+BoDmdPMXS3BeVvUfREuNnyOitubrfsZL0Wgw=; b=quolP96FYF70O9ucvPEjVVDMNggwTxQz84VnFGi5jZRRyYcLk6HU5v6/ToKGqRkla8 Rqk5AEj5QUNOnAG0iYk+GSU+/tCEN9ijui7k1h0JafBRRuoGqDhSMa8i6v4AyX8/ztzI nUzj4oB8CyPH70rX6mGxEhv1V2ISRkob3uHuEQrtlywjGI0KhRw56uBo32hedMSvCA/h Xm0YM0oaV3T9TsWw3AL41eVIwSfYCqDjEHeVMeyWi0p1uGKcbr/YCq+t+vrRNYJWqlR6 GrDa4LkfAY2V5lbXJfwSAsTBeukY+awd9fSikIusSe19/85A7q40IUobuL74ZzvS8/d1 KsWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P1RKbQTj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s4si7820337ejf.166.2019.11.16.07.43.54; Sat, 16 Nov 2019 07:44:18 -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; dkim=pass header.i=@kernel.org header.s=default header.b=P1RKbQTj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728245AbfKPPmQ (ORCPT + 99 others); Sat, 16 Nov 2019 10:42:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:45730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728197AbfKPPmL (ORCPT ); Sat, 16 Nov 2019 10:42:11 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC51D2082E; Sat, 16 Nov 2019 15:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918931; bh=+5WDG++5xSQuxpiwkJ1J9wYvQqH+k4jLnKBFQ/nlJIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P1RKbQTjvb6I2NNQ9JWoQftmIXz7VOXPmr7gbrRJk4XNNzHssLYpUx8arqVWUBxzI 6FObe5xmC4M8kM/QzG+ldb3fvmGsLg3+lS6qQQJ6Xlp4d/7TvXAfNI7b7zfqOQaW0O WDlROR09eGAGA2Eh/eoqpc17GgnoAHR3GqYvaR+M= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Keith Busch , Sagi Grimberg , Christoph Hellwig , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 058/237] nvme-pci: fix hot removal during error handling Date: Sat, 16 Nov 2019 10:38:13 -0500 Message-Id: <20191116154113.7417-58-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Keith Busch [ Upstream commit cb4bfda62afa25b4eee3d635d33fccdd9485dd7c ] A removal waits for the reset_work to complete. If a surprise removal occurs around the same time as an error triggered controller reset, and reset work happened to dispatch a command to the removed controller, the command won't be recovered since the timeout work doesn't do anything during error recovery. We wouldn't want to wait for timeout handling anyway, so this patch fixes this by disabling the controller and killing admin queues prior to syncing with the reset_work. Signed-off-by: Keith Busch Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index a64a8bca0d5b9..9479c0db08f62 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2583,13 +2583,12 @@ static void nvme_remove(struct pci_dev *pdev) struct nvme_dev *dev = pci_get_drvdata(pdev); nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING); - - cancel_work_sync(&dev->ctrl.reset_work); pci_set_drvdata(pdev, NULL); if (!pci_device_is_present(pdev)) { nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DEAD); nvme_dev_disable(dev, true); + nvme_dev_remove_admin(dev); } flush_work(&dev->ctrl.reset_work); -- 2.20.1