Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp920280imj; Sat, 9 Feb 2019 10:48:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IZzAuTa+5URaU1aYLGiB9FND8J5htH6IrIib7c5p4OwSaWdth7VrxERyA2ThUC21Dnx/H0A X-Received: by 2002:a62:5486:: with SMTP id i128mr28250454pfb.215.1549738125463; Sat, 09 Feb 2019 10:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549738125; cv=none; d=google.com; s=arc-20160816; b=qKMrItlBEkeUwg77hxJyi7zc7mrR0o8DkSN/aV4t4bn6QRuTvWqWVjdmoGaJrA6OsP FRjd4H/MhfKx4vzzGnGnGC/K0leFqIk1kMS5RAXmvtSIDLM6ul4siqxefyRBcBgUuOfv FzZMn3N7zACXZC8AezvliJ2rlyv1gVCJRyRJq0y7EnXzmIs3iCR+EaRJkQJ2udwjJqws A5snoQ3p+1EeMZGrBT9RXsEcGl6jAVfIxaBJJ11MknSadqVpiMJrI6cRNelUvIqqS83V soXby+35YhR+SPpgZFkwsmqnxETWOHK/RLO3heall+1PWn1QYDhmuWaOwi+Xvwp+28di M82g== 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=oJ3H+I9h/x5qkvFEZwyvJuooX5RjWjcSUgMPbAZXv3s=; b=W2IlAL1DD4VftHXtXiJKqZJ2K+688DwP4RmVRqKWwCzZ9jvrCQqWmgUY+Tiown3QT1 j+SJYl74Y0qJ/cahzCs1Deb0xqUDr4Dlei8G8SDyNxNbfOwvFFrq6o/ysVmFWnySsTqW hjn/WTsZYSC74J+70tHGK1kprHr+mNix2if1XA9jIc2eFQMXDxg7/fP+xWS8iIXRgYJl 0tlWDoSMa99zdi5Z4XxWwYuPkJU/J34j45shOqitp4b53uxu28cV1wIXTHTtQoez08vh 3GXSNinCnoyWhn+aAdO399FMh/IA15N7fTdnRyZA725yM+ruNWE+x9oj2yJz+ZwFv5rf lhww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZkUkMXlW; 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 38si5697977pgx.460.2019.02.09.10.48.29; Sat, 09 Feb 2019 10:48:45 -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=ZkUkMXlW; 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 S1727551AbfBISsF (ORCPT + 99 others); Sat, 9 Feb 2019 13:48:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:60938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727478AbfBISsD (ORCPT ); Sat, 9 Feb 2019 13:48:03 -0500 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 19D0921916; Sat, 9 Feb 2019 18:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549738082; bh=3w/TlQ//xRWYnpDfJVfrrkeTYwjK0ZZ0UUtN1F24KTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZkUkMXlWNHMSh5Ge7YYqCq/GyXGHdO3raw/U4SqunmbIWBwiGcEgiMsVM5u1jVUcG 2JM94AfBEHwKA5JQ4L53bGHykTIlI0LtDv8Y1M2GlhNiwElz4usgAOuDoF+GcQKeaa WB19pivX8KWSjxsyFX/Nna9P76/cAWoJE8S+kzc0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: James Dingwall , Christoph Hellwig , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 4.20 25/42] nvme: introduce NVME_QUIRK_IGNORE_DEV_SUBNQN Date: Sat, 9 Feb 2019 13:47:17 -0500 Message-Id: <20190209184734.125935-25-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190209184734.125935-1-sashal@kernel.org> References: <20190209184734.125935-1-sashal@kernel.org> MIME-Version: 1.0 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: James Dingwall [ Upstream commit 6299358d198a0635da2dd3c4b3ec37789e811e44 ] If a device provides an NQN it is expected to be globally unique. Unfortunately some firmware revisions for Intel 760p/Pro 7600p devices did not satisfy this requirement. In these circumstances if a system has >1 affected device then only one device is enabled. If this quirk is enabled then the device supplied subnqn is ignored and we fallback to generating one as if the field was empty. In this case we also suppress the version check so we don't print a warning when the quirk is enabled. Reviewed-by: Keith Busch Signed-off-by: James Dingwall Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 16 +++++++++------- drivers/nvme/host/nvme.h | 5 +++++ drivers/nvme/host/pci.c | 2 ++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 971ca6754959..5f9a5ef93969 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2084,14 +2084,16 @@ static void nvme_init_subnqn(struct nvme_subsystem *subsys, struct nvme_ctrl *ct size_t nqnlen; int off; - nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE); - if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) { - strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE); - return; - } + if(!(ctrl->quirks & NVME_QUIRK_IGNORE_DEV_SUBNQN)) { + nqnlen = strnlen(id->subnqn, NVMF_NQN_SIZE); + if (nqnlen > 0 && nqnlen < NVMF_NQN_SIZE) { + strlcpy(subsys->subnqn, id->subnqn, NVMF_NQN_SIZE); + return; + } - if (ctrl->vs >= NVME_VS(1, 2, 1)) - dev_warn(ctrl->device, "missing or invalid SUBNQN field.\n"); + if (ctrl->vs >= NVME_VS(1, 2, 1)) + dev_warn(ctrl->device, "missing or invalid SUBNQN field.\n"); + } /* Generate a "fake" NQN per Figure 254 in NVMe 1.3 + ECN 001 */ off = snprintf(subsys->subnqn, NVMF_NQN_SIZE, diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 081cbdcce880..6ffa99a10a60 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -90,6 +90,11 @@ enum nvme_quirks { * Set MEDIUM priority on SQ creation */ NVME_QUIRK_MEDIUM_PRIO_SQ = (1 << 7), + + /* + * Ignore device provided subnqn. + */ + NVME_QUIRK_IGNORE_DEV_SUBNQN = (1 << 8), }; /* diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 47597046c14f..c0d01048ce4d 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2700,6 +2700,8 @@ static const struct pci_device_id nvme_id_table[] = { { PCI_VDEVICE(INTEL, 0xf1a5), /* Intel 600P/P3100 */ .driver_data = NVME_QUIRK_NO_DEEPEST_PS | NVME_QUIRK_MEDIUM_PRIO_SQ }, + { PCI_VDEVICE(INTEL, 0xf1a6), /* Intel 760p/Pro 7600p */ + .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, }, { PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */ .driver_data = NVME_QUIRK_IDENTIFY_CNS, }, { PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */ -- 2.19.1