Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp959389pxb; Tue, 9 Feb 2021 18:02:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwa2/epVDjGnOYaf4IFBjWjQTi4+07tqjhbPg/dvIcdtTv8KgdYJ/oSEUt2Ly/q9SA92ju0 X-Received: by 2002:a05:6402:10c8:: with SMTP id p8mr991423edu.144.1612922574740; Tue, 09 Feb 2021 18:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612922574; cv=none; d=google.com; s=arc-20160816; b=FBwDELmj3RSgFEuEvdD1LYFz4vTSwk0ysheg/bt8j6MKw/FUAFOCpEgYb2aZtD/7W2 lWEritCWC1GyNmzh/5zeTUhimJcWSLBcGDuidCuxAChAXbfAavMoPiFvKfDlH80jv4sf pzs/I4m46mmGAUMs7eMMNWhxfzkr3ePPGq4aUA6nUWqHi2FkyiO4ZNXb8g5spqVsNoJY f/h2VvSbEEDxrEofDe19lOhODBXsrdgjLvfQxepgA63BprKVp48YwUS6lwK/MktSAjUW CwmOrARMcauA2uTk/rc9oQ0doPoluTOafOt9U2N9sNuGawN8vzHQtX6s5CI6IsRlfn8D 2kKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nankUMrNk1jmGMTceQpek9gK36swyK5+qE/O39IiF20=; b=ZzMmBQ+6bt1b93G467TmZFvtbnTGvLTp8U3kYZezpZ6Vh92qt7qwLYAl4pnfWFX/50 htgG1DyLw3Gbk6V/zw28gBiXkipC4VW+Yff+8MQ7IXUZ2YTUVncfdhLitaNWb84/mQYF 14ppIq24qM/FRdYWbkoRxCOvb4l59/gQAlQjnFCDq2iyQQ2pTLAoED74PArR2HjDAcqD 02eehfJ54QnddnJLVPv5VJyRmgbloy9GbmPwuQpFL2KrDQU2j3NaN3tBHKA/DKBjOvVr +I6izZGRT+BzrOf2baMtguJI+d3Ien9vA8QUFP52IetZh+GaoBhFhbK/75f7wdxy1SKp woGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=mBlp92p4; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si443470edv.363.2021.02.09.18.02.30; Tue, 09 Feb 2021 18:02:54 -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=@amazon.de header.s=amazon201209 header.b=mBlp92p4; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234724AbhBJCBS (ORCPT + 99 others); Tue, 9 Feb 2021 21:01:18 -0500 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:57300 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234530AbhBJAk7 (ORCPT ); Tue, 9 Feb 2021 19:40:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1612917658; x=1644453658; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=nankUMrNk1jmGMTceQpek9gK36swyK5+qE/O39IiF20=; b=mBlp92p4UWqZlCPuVz9aROaea/vf2LAXfJ5VqGN5uIpr2nU4afMZRrb4 yshlGJNTL+5H1ga9vryKL0yJW9Vto+b9nn8Ig84BqI9rKyHcLKW94QgYA LT+8w2hHIc+0VxLJRdjlYOPpzN2oJ37QRp6q2NaED8PoOWZKtsQge/h8I A=; X-IronPort-AV: E=Sophos;i="5.81,166,1610409600"; d="scan'208";a="81114973" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 10 Feb 2021 00:40:06 +0000 Received: from EX13D02EUC001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-1d-474bcd9f.us-east-1.amazon.com (Postfix) with ESMTPS id 86061A1DA9; Wed, 10 Feb 2021 00:40:04 +0000 (UTC) Received: from u2196cf9297dc59.ant.amazon.com (10.43.161.87) by EX13D02EUC001.ant.amazon.com (10.43.164.92) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 10 Feb 2021 00:39:59 +0000 From: Filippo Sironi To: , , , , , , CC: , , Filippo Sironi Subject: [PATCH v2] nvme: Add 48-bit DMA address quirk for Amazon NVMe controllers Date: Wed, 10 Feb 2021 01:39:42 +0100 Message-ID: <20210210003942.25700-1-sironi@amazon.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210203094338.19473-1-sironi@amazon.de> References: <20210203094338.19473-1-sironi@amazon.de> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.87] X-ClientProxiedBy: EX13D43UWA001.ant.amazon.com (10.43.160.44) To EX13D02EUC001.ant.amazon.com (10.43.164.92) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Amazon NVMe controllers do not support 64-bit DMA addresses; they are limited to 48-bit DMA addresses. Let's add a quirk to ensure that we make use of 48-bit DMA addresses to avoid misbehavior. This affects all Amazon NVMe controllers that expose EBS volumes (0x0061, 0x0065, 0x8061) and local instance storage (0xcd00, 0xcd01, 0xcd02). Signed-off-by: Filippo Sironi --- drivers/nvme/host/nvme.h | 5 +++++ drivers/nvme/host/pci.c | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 88a6b97247f5..dae747b4ac35 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -144,6 +144,11 @@ enum nvme_quirks { * NVMe 1.3 compliance. */ NVME_QUIRK_NO_NS_DESC_LIST = (1 << 15), + + /* + * The controller supports up to 48-bit DMA address. + */ + NVME_QUIRK_DMA_ADDRESS_BITS_48 = (1 << 16), }; /* diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 6bad4d4dcdf0..e7001f5ed6e4 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2362,13 +2362,16 @@ static int nvme_pci_enable(struct nvme_dev *dev) { int result = -ENOMEM; struct pci_dev *pdev = to_pci_dev(dev->dev); + int dma_address_bits = 64; if (pci_enable_device_mem(pdev)) return result; pci_set_master(pdev); - if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64))) + if (dev->ctrl.quirks & NVME_QUIRK_DMA_ADDRESS_BITS_48) + dma_address_bits = 48; + if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(dma_address_bits))) goto disable; if (readl(dev->bar + NVME_REG_CSTS) == -1) { @@ -3263,6 +3266,18 @@ static const struct pci_device_id nvme_id_table[] = { .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, { PCI_DEVICE(0x2646, 0x2263), /* KINGSTON A2000 NVMe SSD */ .driver_data = NVME_QUIRK_NO_DEEPEST_PS, }, + { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0x0061), + .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, }, + { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0x0065), + .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, }, + { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0x8061), + .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, }, + { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0xcd00), + .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, }, + { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0xcd01), + .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, }, + { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, 0xcd02), + .driver_data = NVME_QUIRK_DMA_ADDRESS_BITS_48, }, { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2001), .driver_data = NVME_QUIRK_SINGLE_VECTOR }, { PCI_DEVICE(PCI_VENDOR_ID_APPLE, 0x2003) }, -- 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879