Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3178077ybi; Thu, 18 Jul 2019 22:33:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/1O1j25Fy/OAKs2w3LqidsgdTlqQyD76KcgMo9Jg+qnEg+TLFV0yKRKBdkTBu2P9EvN5y X-Received: by 2002:a63:6fc9:: with SMTP id k192mr51422699pgc.20.1563514387995; Thu, 18 Jul 2019 22:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563514387; cv=none; d=google.com; s=arc-20160816; b=sudoQ59NNUPaMsnS2/7iPt/1F/gy5RTzEcOaxMMZB1vbra9j9nbAmCJkXVxowNxmN+ 6B9QylruXA7BkZeEk5K6LZ25UYZ8VquVuZeX2Ourqp0tz3HBj59vOXlcTLI9k7rufsif r4acGbqODFvjXoPQFNJABH8PiSEtczb4gxjJCNih8pRG9H7243nG/9neIfWa2T9RgF4m EujOAErbNdrwAfCev2uoA20n9e1ivpNXTn45Py1V41enXwCzJBcTzCkprPynxaL5Pnbc d7Nua7HDhFSPvFfhXp6c34bn+b528MESVVSgjHZ+9FDO9M9nu+tWgC0lL9Ry376NsTKH /vdQ== 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 :date:cc:to:from:subject:message-id; bh=CBxLtkJ+F+RgCbyqwb/DWB9ljJifAl1AI45aBonh+80=; b=MZJcHU2cVssXjX0GE8eUgTpLiQH4nQxs/kh7GSpO7W/Z4F1rBQu2fq+HFaqJn138t+ 88p92SsiGbuy9SxgeD0XYQDnfzMqA2u0gDWry6danMf2uf6Ahk4ltyKBMsAhhOPKsN5V YmFOAP0W06V+rmO6kZvOW+XFbhnp/luXSoLhrVcJK3QWZGoYH0sHEyy1y9tq9HZkOkd+ uYocwIX542xBzbF8hV/0sWmyeWwbyVJ47LtMF8C5+JddHngq1SNDCntEBNwda1c7DH0c UeGY9EOR69DToG8HNfvoVdKdbi3uUwoaqJX9MUw4Tq337jgn3I8aMbbBYKIL9ST432D6 +Vfw== 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 o1si1163436pja.67.2019.07.18.22.32.52; Thu, 18 Jul 2019 22:33:07 -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 S1726789AbfGSFbT (ORCPT + 99 others); Fri, 19 Jul 2019 01:31:19 -0400 Received: from gate.crashing.org ([63.228.1.57]:53042 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbfGSFbT (ORCPT ); Fri, 19 Jul 2019 01:31:19 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id x6J5V2e4001121; Fri, 19 Jul 2019 00:31:03 -0500 Message-ID: Subject: [PATCH v3] nvme-pci: Support shared tags across queues for Apple 2018 controllers From: Benjamin Herrenschmidt To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Paul Pawlowski , Jens Axboe , Keith Busch , Christoph Hellwig , Minwoo Im , Damien Le Moal Date: Fri, 19 Jul 2019 15:31:02 +1000 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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);