Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp193481pxb; Thu, 27 Jan 2022 18:57:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdmD8aspCJWSyDs7rH1HEvKaSXZb2p8/hV9JlAOT7/UgWimH5maVgHIWvE88PlTz/cjHAF X-Received: by 2002:a17:907:2d0e:: with SMTP id gs14mr5070303ejc.225.1643338635716; Thu, 27 Jan 2022 18:57:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643338635; cv=none; d=google.com; s=arc-20160816; b=lbBwSTFdVYlYC8mBtjwP3zEBlWH/9/cHLpHIA2eaAl2AAI+W8dibV9jcJKELO7jxYI BcQsv5hRtvmAgSvxMl2u9tqsZz54d3Frv18FboBTJj0Lnyn97OMQisG1oaAzhPVNbIMY CJjUyiiYv/8EVEWFxGjjA2Tfbve2HV7esbC+nVwIc69DbJGQvowNy0ev3T5kaPOk+5Px dGuK90eq0rM6dYkGb5BqcfAmpGxHqjMD/69UIHiY5PwgINQROPqnjuq/qXtTm3DLOdZw p6hYBP7C+xUeNLNB0dT6u0e4EH6E9pDmZoMYUoQyBPwbK6GPKukQketTivw+yiyv4NUB AuXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=O9QO+GuOwuNfCQAL5X6kgAbs9JlqPuUL4SKyZ4gCtFk=; b=L4mL71RgVYuzCDsW23lJMcOaZ0bg46Kg194O5u9A/SKnqPQSWI8iW0bxJVPeZFdXnC L9yBtp45kZWhVVT42ESdOrJxflMyk/37IMCIzGxXMarVVpkihCC/lsbtxJOC8RSETXIE Beq7OYKIlW+0Ux4AKnOiwlKC4xSbEVXXMjgOvug7dWrt3GqB5/62ywKQLuqMy5f8bvD5 Ue4fSEhrbnHkSWLqWBICTC/djomsQTTRcD6U2FTi9Fg03wuhWfte9mcJoO0qltpMxosP TVHUGG8kyYvknPcRdtXPkItPEqRUxwo7qtOjtjZvosjevt+kszqSzbSczlLA+0aF2RF6 33vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=QYaek997; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=3V+c1YSB; 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=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp34si2656684ejc.917.2022.01.27.18.56.51; Thu, 27 Jan 2022 18:57:15 -0800 (PST) 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=@suse.de header.s=susede2_rsa header.b=QYaek997; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=3V+c1YSB; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242029AbiA0Ni1 (ORCPT + 99 others); Thu, 27 Jan 2022 08:38:27 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:56354 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242143AbiA0Ngv (ORCPT ); Thu, 27 Jan 2022 08:36:51 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8443B218CE; Thu, 27 Jan 2022 13:36:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1643290610; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=O9QO+GuOwuNfCQAL5X6kgAbs9JlqPuUL4SKyZ4gCtFk=; b=QYaek997c5pGHBy5TBaos7w+eHs4u2gf+NndfKaQg7gz0kxFgI7c20g95O2H6lMYGycnav wqcGuiYiIE/ZwgBeUkLfNLPGXk1Pr0LkQ+JtatlDrIRKCy2C8BPX3n8IMchjdR0KtkSeEq dQqF8sbwlmPZVKVwFculCR5fkIiGKEA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1643290610; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=O9QO+GuOwuNfCQAL5X6kgAbs9JlqPuUL4SKyZ4gCtFk=; b=3V+c1YSBRZbizUpOK3QrjutsbkQU/u64evuTAIMS6QJD4OjohwAG0NVNIRtZxdPt8Niax+ zM2EEuaCTBVXTzDQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 7DFC6A3B87; Thu, 27 Jan 2022 13:36:50 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 17828) id 71F435192D56; Thu, 27 Jan 2022 14:36:50 +0100 (CET) From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Daniel Wagner Subject: [RFC] nvme: Do not reject dynamic controller cntlid Date: Thu, 27 Jan 2022 14:36:48 +0100 Message-Id: <20220127133648.8201-1-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The NVME spec states in 3.1.1 Controller Model there are two types controllers: dynamic and static. The nvme_validate_cntlid() check ensures that the newly discovered controller does not have the same cntlid as a known controller. For the dynamic controller model this check doesn't make sense as all cntlid will be 0xffff. In this case ignore this check. Signed-off-by: Daniel Wagner --- I got a bug report with this: nvme nvme10: pci function 0000:00:19.0 nvme 0000:00:19.0: enabling device (0000 -> 0002) nvme nvme10: Duplicate cntlid 65535 with nvme7, rejecting nvme nvme10: Removing after probe failure status: -22 From reading the spec I got the impression that it should be enough to ignore the cntlid check if the cntlid is 0xffff. Though I might be completely wrong here. drivers/nvme/host/core.c | 2 +- drivers/nvme/host/nvme.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index dd18861f77c0..918abb54771c 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2701,7 +2701,7 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys, if (nvme_state_terminal(tmp)) continue; - if (tmp->cntlid == ctrl->cntlid) { + if (!nvme_ctrl_dynamic(tmp) && tmp->cntlid == ctrl->cntlid) { dev_err(ctrl->device, "Duplicate cntlid %u with %s, subsys %s, rejecting\n", ctrl->cntlid, dev_name(tmp->device), diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index a162f6c6da6e..ed75245263f5 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -539,6 +539,11 @@ static inline struct request *nvme_cid_to_rq(struct blk_mq_tags *tags, return blk_mq_tag_to_rq(tags, nvme_tag_from_cid(command_id)); } +static inline bool nvme_ctrl_dynamic(struct nvme_ctrl *ctrl) +{ + return ctrl->cntlid == 0xffff; +} + #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj, const char *dev_name); -- 2.29.2