Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3800490ybi; Mon, 29 Jul 2019 12:53:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjssNPGHwdp5Nf8a9XzBf8WoDV/2jjw5EpCjuVSq/icYRzhFC1IuUtNLJXqJ1tqKcNhny9 X-Received: by 2002:a63:484a:: with SMTP id x10mr47520354pgk.430.1564430004684; Mon, 29 Jul 2019 12:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430004; cv=none; d=google.com; s=arc-20160816; b=DK1vbZofel9i9P/O0t+5ugD6ybwEsInuf14z7UHYPe1moW9bA3X+dGv8CPuTNhLGwF ybB8LwwH2+Yu30OsnRCBqK3Vh9+yQavToSBo0nLWH8u7Qmw99n+3pMeUd5lNnJdV3x7U ANd52zCxZRW+vjHjxV1y3yPE8x8oQEygHP+2fHQiWRvcOpC9r2Yh0JEQvqCksYUloTuv eiGW75stoQ+oe44xtpjdvXdtJqo+a2FlaEjkiHxRc7uGv9m2cmxW3ZLctcc+6bzYpBxg P2RXz9Aam5CVSTQahEBVY3MC7UCaaE1D2xhtQR0mQRVOwi1lT2icBDq/WnHJZbocjPbf b/jA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=i5IrhaCMnLYGUzdLdDmaBI9KHsduSb15GMfhNnOu/Co=; b=UDbEJAl9Er/ipcLZPnJKPdPLX+8VgRHwNWzLuiN9G10R2tr9+ERLKAgSFFOzXBH0XY spgHI9rBnDmlvk/DdEesPkCQrB9AemwJAiINz8+eZWmvdrzpDpP+emIjoDqtuJWD6o0X ifNqGkCOifS3RqM1+wlQOCZXQJ2DcctPZL549SjKqRJKSrkbGlsXFcJF675/bl4JUEu6 D9vuaBElBhaodUYZGIukvKOZ8KHsx6Wax4jiStqkzzF8YYJI0vCKPHy7vNxrw7kPnlLz eitsGO3RypyKzEOUzisyeA+Qy6RwaquU7ZenYNXSKDQTtt4tCIkIrS3YSroVqBDwQP9/ S5EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JMFS8mKF; 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 m68si31998840pfb.75.2019.07.29.12.53.09; Mon, 29 Jul 2019 12:53:24 -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; dkim=pass header.i=@kernel.org header.s=default header.b=JMFS8mKF; 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 S2403880AbfG2Tvq (ORCPT + 99 others); Mon, 29 Jul 2019 15:51:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:43260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390808AbfG2Tvl (ORCPT ); Mon, 29 Jul 2019 15:51:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 04448217D4; Mon, 29 Jul 2019 19:51:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429901; bh=1T9ReUJnk6XnIwjSgiM7I75GocWQu1OTYIVqyvK0xPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JMFS8mKFiI3AXXyIcr2sY2i8yyuy+9N36/o180YDRu9KZIR6bqMIshinq/fVcKeF8 Dojjc2kDNLxG+d4f2uuh8XCzzlGv4orYqHlBw3SS7cTdfaiAKvP7qB3BCl53W9F6L7 mtLui0xSxeFMO6RMSEtK7CHRAIa3ymu1gJHNnSoI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Atish Patra , Sagi Grimberg , Sasha Levin Subject: [PATCH 5.2 133/215] nvme-pci: limit max_hw_sectors based on the DMA max mapping size Date: Mon, 29 Jul 2019 21:22:09 +0200 Message-Id: <20190729190802.565753706@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 7637de311bd2124b298a072852448b940d8a34b9 ] When running a NVMe device that is attached to a addressing challenged PCIe root port that requires bounce buffering, our request sizes can easily overflow the swiotlb bounce buffer size. Limit the maximum I/O size to the limit exposed by the DMA mapping subsystem. Signed-off-by: Christoph Hellwig Reported-by: Atish Patra Tested-by: Atish Patra Reviewed-by: Sagi Grimberg Signed-off-by: Sasha Levin --- drivers/nvme/host/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 245b6e2151c1..7fbcd72c438f 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2521,7 +2521,8 @@ static void nvme_reset_work(struct work_struct *work) * Limit the max command size to prevent iod->sg allocations going * over a single page. */ - dev->ctrl.max_hw_sectors = NVME_MAX_KB_SZ << 1; + dev->ctrl.max_hw_sectors = min_t(u32, + NVME_MAX_KB_SZ << 1, dma_max_mapping_size(dev->dev) >> 9); dev->ctrl.max_segments = NVME_MAX_SEGS; /* -- 2.20.1