Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4876988ybi; Tue, 30 Jul 2019 09:40:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwl+7jHqAn48zQ9PWrm+NYCoEI9QWCQUOB8507FVPqbVbL01DDwU6wOfj6s06VJl4WJ0dU X-Received: by 2002:a63:f941:: with SMTP id q1mr110493653pgk.350.1564504813443; Tue, 30 Jul 2019 09:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564504813; cv=none; d=google.com; s=arc-20160816; b=eExUrzTUo+4+VyJFlBfX82O7PYSrAC+YVjhv2Tjcev6LNhW/mlrJ9Nlhm6hphH6/zK guqDr81nfV84P8XD1wfEDz+glnpihIckVYQRa+o78C/iGYPYvcbsrMa5jpf9i2shFaVa 38zRxylZc123eHl/5O8UjbBxMBYP9GtNz7KuxUbD6xHqJd2Kni4jalnwJm4qKMFGmH7x qrnICTRXUVYURUCpd9TS/SgTnQAsCZpGIijgxxeWPFsPCuChWBqEjBFpejhqVdlH+U5o xq2gPzQWrpu+XlfC+j9kcetMfYl5QQbBbj2Bd5vNSHVMY7ITTC3DeWk06TqMChfwy6TJ GZoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=pOBj2Z9Sh5v7Gi07Ppm/qKG42PCwHajj0EsFuqXz8g4=; b=aff5nTfIX8lbT7hLrq6bFKO3RU4DVtVA9V53P7HsbF9LIqsGSSI4bhL4gWg7eR6Fa5 TEF+JgEzc35eV9p6qP/m82MEApCYxdX8myCLFRb7752g9D50x7HnaKvkbBoegoLlqs6P eCvKGkb6UrUt+9N+R7Kp6tna3Z4evRgs4p8FseBh/TlyT6OQZMrB3R6V+KR12ify7zFf JuCJt4dylAgEXKrvfOBNvAyPjtKvsv4XUq+ubWpKDTNSSeVC2IdmqfzjG3HgiAPvjbj3 TnR5RHM86363fANf0mPxW/vLxB+oHPu0jyrOkCTJQmIuoyun4hzJco2PHobdz5eUdtJm x10g== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si29170038pge.395.2019.07.30.09.39.58; Tue, 30 Jul 2019 09:40:13 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732258AbfG3Pd3 (ORCPT + 99 others); Tue, 30 Jul 2019 11:33:29 -0400 Received: from mga04.intel.com ([192.55.52.120]:58257 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731791AbfG3Pd3 (ORCPT ); Tue, 30 Jul 2019 11:33:29 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2019 08:33:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,327,1559545200"; d="scan'208";a="255640802" Received: from unknown (HELO localhost.localdomain) ([10.232.112.69]) by orsmga001.jf.intel.com with ESMTP; 30 Jul 2019 08:33:27 -0700 Date: Tue, 30 Jul 2019 09:30:44 -0600 From: Keith Busch To: Benjamin Herrenschmidt Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Paul Pawlowski , Jens Axboe , Christoph Hellwig , Minwoo Im , Damien Le Moal Subject: Re: [PATCH v3] nvme-pci: Support shared tags across queues for Apple 2018 controllers Message-ID: <20190730153044.GA13948@localhost.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 19, 2019 at 03:31:02PM +1000, Benjamin Herrenschmidt wrote: > From 8dcba2ef5b1466b023b88b4eca463b30de78d9eb Mon Sep 17 00:00:00 2001 > From: Benjamin Herrenschmidt > Date: Fri, 19 Jul 2019 15:03:06 +1000 > Subject: > > Another issue with the Apple T2 based 2018 controllers seem to be > that they blow up (and shut the machine down) if there's a tag > collision between the IO queue and the Admin queue. > > My suspicion is that they use our tags for their internal tracking > and don't mix them with the queue id. They also seem to not like > when tags go beyond the IO queue depth, ie 128 tags. > > This adds a quirk that marks tags 0..31 of the IO queue reserved > > Signed-off-by: Benjamin Herrenschmidt > --- One problem is that we've an nvme parameter, io_queue_depth, that a user could set to something less than 32, and then you won't be able to do any IO. I'd recommend enforce the admin queue to QD1 for this device so that you have more potential IO tags. > Thanks Damien, reserved tags work and make this a lot simpler ! > > drivers/nvme/host/nvme.h | 5 +++++ > drivers/nvme/host/pci.c | 19 ++++++++++++++++++- > 2 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h > index ced0e0a7e039..8732da6df555 100644 > --- a/drivers/nvme/host/nvme.h > +++ b/drivers/nvme/host/nvme.h > @@ -102,6 +102,11 @@ enum nvme_quirks { > * Use non-standard 128 bytes SQEs. > */ > NVME_QUIRK_128_BYTES_SQES = (1 << 11), > + > + /* > + * Prevent tag overlap between queues > + */ > + NVME_QUIRK_SHARED_TAGS = (1 << 12), > }; > > /* > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index 7088971d4c42..fc74395a028b 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -2106,6 +2106,14 @@ static int nvme_setup_io_queues(struct nvme_dev *dev) > unsigned long size; > > nr_io_queues = max_io_queues(); > + > + /* > + * If tags are shared with admin queue (Apple bug), then > + * make sure we only use one IO queue. > + */ > + if (dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS) > + nr_io_queues = 1; > + > result = nvme_set_queue_count(&dev->ctrl, &nr_io_queues); > if (result < 0) > return result; > @@ -2278,6 +2286,14 @@ static int nvme_dev_add(struct nvme_dev *dev) > dev->tagset.flags = BLK_MQ_F_SHOULD_MERGE; > dev->tagset.driver_data = dev; > > + /* > + * Some Apple controllers requires tags to be unique > + * across admin and IO queue, so reserve the first 32 > + * tags of the IO queue. > + */ > + if (dev->ctrl.quirks & NVME_QUIRK_SHARED_TAGS) > + dev->tagset.reserved_tags = NVME_AQ_DEPTH; > + > ret = blk_mq_alloc_tag_set(&dev->tagset); > if (ret) { > dev_warn(dev->ctrl.device, > @@ -3057,7 +3073,8 @@ static const struct pci_device_id nvme_id_table[] = { > { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2003) }, > { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2005), > .driver_data = NVME_QUIRK_SINGLE_VECTOR | > - NVME_QUIRK_128_BYTES_SQES }, > + NVME_QUIRK_128_BYTES_SQES | > + NVME_QUIRK_SHARED_TAGS }, > { 0, } > }; > MODULE_DEVICE_TABLE(pci, nvme_id_table); > >