Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp409689ybi; Mon, 15 Jul 2019 23:07:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2K+a+713fOawowTb8FRBns0ErZwgF8kMyeszgMoA1MaTzF5O/wPgVc8s6K/Lff30Z3gdD X-Received: by 2002:a17:902:724:: with SMTP id 33mr32387848pli.49.1563257260997; Mon, 15 Jul 2019 23:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563257260; cv=none; d=google.com; s=arc-20160816; b=HPQLj9eA4lzjc1ypFa/fHauYLAyFejagqApEbaceVmB1MLXKXBL1E/E3+Q9Bl2SEZB rIzGqRf5gs09HnLU+BbPxXG2+gyWYDwLGzOxu5JTWVDiwHG7xBCg2ukPrC6kyMkIsK7f LwDWRlWJiNDXpLQpqehh2JKHQkvvTUykGY00xBftL/WSUlr/lGM4ElhXMLjo19x2YFZ6 ohMMuax7ced2xQQYQlIgMDafRNwV3tmtK3OWRmGquBz+KphtEh5Ifpwg2lhaUkScFuZf ybhCyqakV09jZDNwl7zA0JERhql1r2dQOj+RSwwAOruHDKvYZxSVsJei5zwKBXKlcRdU Ylaw== 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=sn7YvGfZnvb439fzD9EZXehVhmvG0nNCW8Sn4wNK/ps=; b=kS5x8SfGasAYGNUpEvlRWROb2tsYSgURaXr9pFzyHOCXi7uXvDcF3kXkbyHTJCnYBT w/fw/dR6Oozwwr6DFF9UjqJwUbrSU1BciNq9HMIDRdNALZxL3axqKoQE0beLG9+rYHcw 7XsDFRlwS+JboyI/R+cy0T47THQdgPiC7CHqC/9hcRceHpUavskItBiiOeJWTAhvff3x UkgwHDk8AN4t0O9ipWuFhrCbMsuZdAIvqVkWgFFpP1yzdP0kKk5MBKDAydd7BQi7HqAW rEug63aoZmURk7tOwW1apMcC+m03JgMJxoTeVYg5EPhpdCZP728yX6TsdJAsRJkPwgol JN7w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si220882pgo.355.2019.07.15.23.07.24; Mon, 15 Jul 2019 23:07:40 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731771AbfGPGG1 (ORCPT + 99 others); Tue, 16 Jul 2019 02:06:27 -0400 Received: from verein.lst.de ([213.95.11.211]:38924 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726315AbfGPGG1 (ORCPT ); Tue, 16 Jul 2019 02:06:27 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 8965568C65; Tue, 16 Jul 2019 08:06:24 +0200 (CEST) Date: Tue, 16 Jul 2019 08:06:23 +0200 From: Christoph Hellwig To: Benjamin Herrenschmidt Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Jens Axboe , Keith Busch , Christoph Hellwig , Paul Pawlowski Subject: Re: [PATCH 3/3] nvme: Add support for Apple 2018+ models Message-ID: <20190716060623.GC29414@lst.de> References: <20190716004649.17799-1-benh@kernel.crashing.org> <20190716004649.17799-3-benh@kernel.crashing.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190716004649.17799-3-benh@kernel.crashing.org> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 16, 2019 at 10:46:49AM +1000, Benjamin Herrenschmidt wrote: > Based on reverse engineering and original patch by > > Paul Pawlowski > > This adds support for Apple weird implementation of NVME in their > 2018 or later machines. It accounts for the twice-as-big SQ entries > for the IO queues, and the fact that only interrupt vector 0 appears > to function properly. > > Signed-off-by: Benjamin Herrenschmidt > --- > drivers/nvme/host/core.c | 5 ++++- > drivers/nvme/host/nvme.h | 10 ++++++++++ > drivers/nvme/host/pci.c | 6 ++++++ > 3 files changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > index 716ebe87a2b8..480ea24d8cf4 100644 > --- a/drivers/nvme/host/core.c > +++ b/drivers/nvme/host/core.c > @@ -2701,7 +2701,10 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) > ctrl->hmmaxd = le16_to_cpu(id->hmmaxd); > > /* Grab required IO queue size */ > - ctrl->iosqes = id->sqes & 0xf; > + if (ctrl->quirks & NVME_QUIRK_128_BYTES_SQES) > + ctrl->iosqes = 7; > + else > + ctrl->iosqes = id->sqes & 0xf; > if (ctrl->iosqes < NVME_NVM_IOSQES) { > dev_err(ctrl->device, > "unsupported required IO queue size %d\n", ctrl->iosqes); > diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h > index 34ef35fcd8a5..b2a78d08b984 100644 > --- a/drivers/nvme/host/nvme.h > +++ b/drivers/nvme/host/nvme.h > @@ -92,6 +92,16 @@ enum nvme_quirks { > * Broken Write Zeroes. > */ > NVME_QUIRK_DISABLE_WRITE_ZEROES = (1 << 9), > + > + /* > + * Use only one interrupt vector for all queues > + */ > + NVME_QUIRK_SINGLE_VECTOR = (1 << 10), > + > + /* > + * Use non-standard 128 bytes SQEs. > + */ > + NVME_QUIRK_128_BYTES_SQES = (1 << 11), > }; > > /* > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index 54b35ea4af88..ab2358137419 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -2080,6 +2080,9 @@ static int nvme_setup_irqs(struct nvme_dev *dev, unsigned int nr_io_queues) > dev->io_queues[HCTX_TYPE_DEFAULT] = 1; > dev->io_queues[HCTX_TYPE_READ] = 0; > > + if (dev->ctrl.quirks & NVME_QUIRK_SINGLE_VECTOR) > + irq_queues = 1; > + > return pci_alloc_irq_vectors_affinity(pdev, 1, irq_queues, > PCI_IRQ_ALL_TYPES | PCI_IRQ_AFFINITY, &affd); Callin pci_alloc_irq_vectors_affinity in this case seems a bit pointless, but if this works for you I'd rather keep it as-is for now if this works for you.