Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp111766ybg; Mon, 8 Jun 2020 17:56:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxx9xsztfsYIIiyKLTT+9Cd28DwV+k2KKkaZQqm7+iAokmqT8rsccRXmY42aU3DfH9iQlF X-Received: by 2002:aa7:d698:: with SMTP id d24mr24951693edr.56.1591664188940; Mon, 08 Jun 2020 17:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664188; cv=none; d=google.com; s=arc-20160816; b=ED9Y215GedRKzKZzAmNqRnYZ5W+c5wlGCLFJhuwNxZ2q+HnkwwvOqVNsmEZvu9m66C IutDYKq2XPRET9h0uTVsxdyN+91fwsttU7LgnkFqmZKD8APm8a0PPORxT5QpnzDCwaqi neJxnj7D4r3igE823VrMTi0zJlYWfHPbKro/J1c77WVlSZACWzjs0wTEKOemWNyA9xS1 6lAOAAUNL3C6Mbg4lQja/O5SdfbOcthflme5qvb4+cIw2kW7FYgPvTnr3IOOPsSWMi3x Y+lcCtQoMMHJK+CwaAC1GVoYZlGEoBofjc2/e1qyuNgCxIC6lQuM9vZW09DbuZ6jtj9S yoPg== 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=9wEj3/Ii9GLLfkUvJ60Jq7Vjy/YxUVcR7MUk67Tguz0=; b=KW7NwCl5iwNLqOIxH/2N1WrI2/U1buCKIy8MnG/DZ/8bSau5P+wL2XJOUlhXPsxCwZ 5b3IyAJoHOJezPeRLQscD5VZBvvpQLw1LLRsnbPrvmXLeFoGpgzm1Gajyxgmm/0OGodG JZPhK0xqPFG6+3DWky7/xozpuETrrXArID8mcwWfDZEr3LCfQxpGxgEohYLwAftvjSKc A6gROcD73M79oB/1dnS2TsVETLQUfdc2x6VfZaLSQgZUNuVX+znIpo2G5mdyKfo/rkPc crlXFbGvdo92B34qMGZzOZbUuEGWymd+B0qF6Avv92Z3bNVhdWRLTVCsA4Soj0aY3UUj f8EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G12F+Yl3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id oy12si9573369ejb.654.2020.06.08.17.56.06; Mon, 08 Jun 2020 17:56:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G12F+Yl3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729084AbgFIAwY (ORCPT + 99 others); Mon, 8 Jun 2020 20:52:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:56062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728554AbgFHXKD (ORCPT ); Mon, 8 Jun 2020 19:10:03 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 3FEEE208B6; Mon, 8 Jun 2020 23:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657803; bh=NAWFmJaqPTO6s8ykfHcmdQDQDkRrYwzWBoRtKlQOBI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G12F+Yl3HcUV86WgNQViawDBWWLqUoZwxUu5FtcBivjrYXVkY6AD7wJvqUl8KqH+h z8VB64oqBaloQMLR1dGlGA/DidouxnPSMHKR77ZTK0nc6+3nH/w+KbFnpMd/qSTCkE yvxKn66SaO9PSK5q3M1OuZ8Ho4YHqsLl+f7Vvq8I= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christoph Hellwig , Keith Busch , Sagi Grimberg , Jens Axboe , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 5.7 180/274] nvme: refine the Qemu Identify CNS quirk Date: Mon, 8 Jun 2020 19:04:33 -0400 Message-Id: <20200608230607.3361041-180-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-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: Christoph Hellwig [ Upstream commit b9a5c3d4c34d8bd9fd75f7f28d18a57cb68da237 ] Add a helper to check if we can use Identify CNS values > 1, and refine the Qemu quirk to not apply to reported versions larger than 1.1, as the Qemu implementation had been fixed by then. Signed-off-by: Christoph Hellwig Reviewed-by: Keith Busch Reviewed-by: Sagi Grimberg Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index f3c037f5a9ba..7b4cbe2c6954 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1027,6 +1027,19 @@ void nvme_stop_keep_alive(struct nvme_ctrl *ctrl) } EXPORT_SYMBOL_GPL(nvme_stop_keep_alive); +/* + * In NVMe 1.0 the CNS field was just a binary controller or namespace + * flag, thus sending any new CNS opcodes has a big chance of not working. + * Qemu unfortunately had that bug after reporting a 1.1 version compliance + * (but not for any later version). + */ +static bool nvme_ctrl_limited_cns(struct nvme_ctrl *ctrl) +{ + if (ctrl->quirks & NVME_QUIRK_IDENTIFY_CNS) + return ctrl->vs < NVME_VS(1, 2, 0); + return ctrl->vs < NVME_VS(1, 1, 0); +} + static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id) { struct nvme_command c = { }; @@ -3815,8 +3828,7 @@ static void nvme_scan_work(struct work_struct *work) mutex_lock(&ctrl->scan_lock); nn = le32_to_cpu(id->nn); - if (ctrl->vs >= NVME_VS(1, 1, 0) && - !(ctrl->quirks & NVME_QUIRK_IDENTIFY_CNS)) { + if (!nvme_ctrl_limited_cns(ctrl)) { if (!nvme_scan_ns_list(ctrl, nn)) goto out_free_id; } -- 2.25.1