Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3131035ybi; Thu, 18 Jul 2019 21:38:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxYMkte8zdus6qn3WMguLtVp/DLTis6ZCuvEEGrqOBBNE4UfAk8X/UHmfxh1j4DAhpGwu8 X-Received: by 2002:a17:90b:94:: with SMTP id bb20mr56188711pjb.16.1563511086515; Thu, 18 Jul 2019 21:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511086; cv=none; d=google.com; s=arc-20160816; b=Laqh07NjiQ16mMBrjFNQic8+jDpwjUOpW+NglqvIm9PbePBhez+17rFyq3JOnaIJUK 5brx3rJOu56k1I6ttw5i9vOIj7tJR1UZlD5ut9nNIB2wUhDi2EBbXSL9TiGIvzhW+JGJ qiV568wvQCGppUSx7To44HQWLGI4IcZdf80Zv1mBUhVAELcdVxL6rYxySIJ3a/26kyXp sZs6z9aD/ayK2ihzFfjP7JKAjpyW+7U+wNOAntpkw2NIgawK3oy0JLknMVbydVAJFMth ixr1qPXtBrMdkOUPgw+5mvdExs8+kgmxnfVvm9c1uoZcLyplkqoGK0oTpQgYRW/UmHcQ fXlQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wckQQWxU7aKsIbWqmfnRKpbytg7MkeEEW1dYsvmIQXA=; b=R4179HMNSixm5hJxAUMZUrsl9DwvON3pySARtnvM0zK6lv7MoyPjnaPLZEDvDDMzH2 oJRRyhQn7MZJ3cwhOahnQ3606bK2X6975UyQiiSkxOIn+tg4MKYr/y1jProPVj0DTbU3 aY9VDn/FcxXTtUn1ruo1trg14k6/Imu8SRxg5THUZoheF4j7+2037euF30ead30sYi3s rE97LoB2hm2DKvbW0Uh5BiYlcV3UjmD3fYu5goCfZS1XPwhVgTwGtdoxOCWmnq6OVY+X 8IVJcNV32YOcLv6S1LFncyeHOEyn1GHAnr7s37RUaMkytXH6CYVzlzTg+PtfxOfhyj61 b6MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WMEAuy8V; 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=pass (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 d18si107447pfn.202.2019.07.18.21.37.50; Thu, 18 Jul 2019 21:38:06 -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=WMEAuy8V; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387418AbfGSEfc (ORCPT + 99 others); Fri, 19 Jul 2019 00:35:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:33164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729420AbfGSEBZ (ORCPT ); Fri, 19 Jul 2019 00:01:25 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 76D4621897; Fri, 19 Jul 2019 04:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508885; bh=GN/OsSNmdwC+UYwQNWTMkfKny8MRTFWFNFlzyHs3pjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WMEAuy8V//91E5PQd2XeRLl4PVexfPXla+SWGqb5z7oK6TIVz3H1vpZkilABDcSNm J61XkELg2knGNKgO9ST3JymR0md63u64QZ3x8+GsAqs1NWF3YPr4u7aGxGD+UmjAmr RE/EQSxX8QtX9LLBWL2IgsRLqKp3F+xORmQA+djA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christoph Hellwig , Atish Patra , Sagi Grimberg , Sasha Levin , linux-nvme@lists.infradead.org Subject: [PATCH AUTOSEL 5.2 136/171] nvme-pci: limit max_hw_sectors based on the DMA max mapping size Date: Thu, 18 Jul 2019 23:56:07 -0400 Message-Id: <20190719035643.14300-136-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig [ 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 5dfa067f6506..5c45f4cab060 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -2515,7 +2515,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