Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp262983yba; Thu, 18 Apr 2019 00:28:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlrGSr5I7gTLHrTbt+Y+Yf5lS5OuNdKxPMy5TvmLQp5FRV4fQTibP6b7ATvFNACPPbw0J9 X-Received: by 2002:a17:902:141:: with SMTP id 59mr57844087plb.132.1555572495532; Thu, 18 Apr 2019 00:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555572495; cv=none; d=google.com; s=arc-20160816; b=CgCHebXQORy8OdqDlD6huP2jgB9V2bONLzf3HsTYlJf6Ew2SJSNAwtoIrChDThpmLY J0buGdRh+qwC5nIGZahvsTfV/D3leFsMYrqGkOICqgd9XsgSiyOUBqKbdURU7Cw9Hca1 W0VFilHsJz7lVSJHpyYwEZ6e9Fe5/ft+DKvldHAgWGuwtITW1IiWHn60bjupT7J48h7f F53Xr0NiXROSzYl9GD1Y4unt2JszFhAn04Ijxk9hXoxrC5zP6qKmxZNjy44nc5zMbE2/ RqCc44d98CKsXCA7Bc3X70EeGpm7PL2GdagflXNjDgkJ6oC5XGYzza4Sj66tuGo+sf3H hyBA== 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:date:to:from:subject:message-id; bh=hQ+VKqa/GISdQwdyBTlOFKdMzFdUh/2B0URnPMY88R0=; b=fs4BG49fWfmVKi8/P//ZlMNsDdeIBQseYicTHtBn+D/tnzt9bxVbN7Xwt8MB9GmNWy Hn9lDl5gMQDKg5eg1JpR03MFx7eUQTL3KmawEA1TYQgZUvfRXZ1MCCwy9qSbd/8x0x8v Uiun3qrUp9WcvXP6EDrExIHB5YTVDHXUv2tx7ykP2kTPpYOVRD0H+rgP3Vu/vyarilOg 49iU3NWxlV4ogtBgsivqWduIgahoFUJBBZ1dbVuD+VFwnJJND2D4hvmIXIB40XsyHeLx sZYcs3VjWX1zpO4EBCZkKqqKEuJt4emJS3+SaR9Zp7xueB1sb3fW7HRxSXwE0wrCnBDW f1AA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j187si1584740pfc.181.2019.04.18.00.28.00; Thu, 18 Apr 2019 00:28:15 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388163AbfDRHZp (ORCPT + 99 others); Thu, 18 Apr 2019 03:25:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47026 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbfDRHZo (ORCPT ); Thu, 18 Apr 2019 03:25:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 451913007426; Thu, 18 Apr 2019 07:25:44 +0000 (UTC) Received: from maximlenovopc.usersys.redhat.com (unknown [10.35.206.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA3DF600C2; Thu, 18 Apr 2019 07:25:42 +0000 (UTC) Message-ID: <25e684a4d347181aa6b6dc1e41d1794203bbae03.camel@redhat.com> Subject: Re: [PATCH] nvme: determine the number of IO queues From: Maxim Levitsky To: Aaron Ma , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, keith.busch@intel.com, axboe@fb.com Date: Thu, 18 Apr 2019 10:25:41 +0300 In-Reply-To: References: <1555510379-20199-1-git-send-email-aaron.ma@canonical.com> <096935354b16662eb481aeda1f48001ba489463c.camel@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 18 Apr 2019 07:25:44 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-04-18 at 14:21 +0800, Aaron Ma wrote: > On 4/18/19 1:33 AM, Maxim Levitsky wrote: > > On Wed, 2019-04-17 at 20:32 +0300, Maxim Levitsky wrote: > > > On Wed, 2019-04-17 at 22:12 +0800, Aaron Ma wrote: > > > > Some controllers support limited IO queues, when over set > > > > the number, it will return invalid field error. > > > > Then NVME will be removed by driver. > > > > > > > > Find the max number of IO queues that controller supports. > > > > When it still got invalid result, set 1 IO queue at least to > > > > bring NVME online. > > > > > > To be honest a spec compliant device should not need this. > > > The spec states: > > > > > > "Number of I/O Completion Queues Requested (NCQR): Indicates the number of > > > I/O > > > Completion > > > Queues requested by software. This number does not include the Admin > > > Completion > > > Queue. A > > > minimum of one queue shall be requested, reflecting that the minimum > > > support > > > is > > > for one I/O > > > Completion Queue. This is a 0’s based value. The maximum value that may be > > > specified is 65,534 > > > (i.e., 65,535 I/O Completion Queues). If the value specified is 65,535, > > > the > > > controller should return > > > an error of Invalid Field in Command." > > > > > > > > > This implies that you can ask for any value and the controller must not > > > respond > > > with an error, but rather indicate how many queues it supports. > > > > > > Maybe its better to add a quirk for the broken device, which needs this? > > Adding quirk only makes the code more complicated. > This patch doesn't change the default behavior. > Only handle the NVME error code. > > Yes the IO queues number is 0's based, but driver would return error and > remove the nvme device as dead. No, no, the spec says that no matter what the number queues you ask for, unless it is 65,535, the controller should not fail with an error, but rather indicate in the return value (in the completion entry) the actual number of queues it allocated which can be larger or smaller that what you asked for. If controller returns an error, that means its firmware has a bug, which is not something unusual but usually those cases are handled with a quirk rather than with general code change. But anyway that is just my opinion, as someone who studied and implemented (hopefully mostly correctly) the spec very recently (I am the author of nvme- mdev device). It doesn't really matter to me if this is implemented this or another way as long as it doesn't break things. Best regards, Maxim Levitsky > > So set it as 1 at least the NVME can be probed properly. > > Regards, > Aaron > > > I forgot to add the relevant paragraph: > > > > "Note: The value allocated may be smaller or larger than the number of > > queues > > requested, often in virtualized > > implementations. The controller may not have as many queues to allocate as > > are > > requested. Alternatively, > > the controller may have an allocation unit of queues (e.g. power of two) and > > may > > supply more queues to > > host software to satisfy its allocation unit." > > > > > > Best regards, > > Maxim Levitsky > >