From patchwork Tue Feb 18 18:41:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11389277 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C138C13A4 for ; Tue, 18 Feb 2020 18:42:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FB3321D56 for ; Tue, 18 Feb 2020 18:42:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UZlglxzQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FB3321D56 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lOtJaMIs7MmvQUHyuk80MrWcw68NLw9gZQnDiYyLxnE=; b=UZlglxzQE3J+DX ADwqkD+94FjWf6A+wU10B7szkcDA/6jBxhRe2EA0k8mNhKKeRsuDAAWa0PcR/NMbgHqHVSfhrXxg3 Wv6icZY377E9ZLNDTFuF/kijwIke2TZTi6WnwxMEyGkwr07tuUYgy4yqe2Yvk/lfrRAiRvqqXWKuG 4UCjlcxiL9gP7QdB/ZmuvISimOCccUltvAe1OXmLQMXYCS/6K2yNU4JZaQtPqAp2zRWop6Bgi0Fe3 Hw4N9h38tSUA97eXwF1qr59jJfk0iWKFjJyO8pCQjUYKSrAE15H/bv57PwhOGNz0V/3RWT4a9t+NQ Bu9SRY4ZMl0z72zqjwdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j47oo-00034e-C1; Tue, 18 Feb 2020 18:42:02 +0000 Received: from [199.255.44.128] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1j47oh-0002xO-K7; Tue, 18 Feb 2020 18:41:55 +0000 From: Christoph Hellwig To: Russell King Subject: [PATCH 2/3] ARM/dma-mapping: take the bus limit into account in __dma_alloc Date: Tue, 18 Feb 2020 10:41:02 -0800 Message-Id: <20200218184103.35932-3-hch@lst.de> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200218184103.35932-1-hch@lst.de> References: <20200218184103.35932-1-hch@lst.de> MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Peter Ujfalusi , iommu@lists.linux-foundation.org, Robin Murphy , linux-arm-kernel@lists.infradead.org, Roger Quadros Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The DMA coherent allocator needs to take bus limits into account for picking the zone that the memory is allocated from. Reported-by: Roger Quadros Signed-off-by: Christoph Hellwig Tested-by: Peter Ujfalusi Tested-by: Roger Quadros --- arch/arm/mm/dma-mapping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 72ddc3d0f5eb..87aba505554a 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -658,7 +658,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp, pgprot_t prot, bool is_coherent, unsigned long attrs, const void *caller) { - u64 mask = dev->coherent_dma_mask; + u64 mask = min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit); struct page *page = NULL; void *addr; bool allowblock, cma;