From patchwork Wed Jul 17 15:31:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 11048061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CF661398 for ; Wed, 17 Jul 2019 15:31:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69298208C2 for ; Wed, 17 Jul 2019 15:31:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CB4E28754; Wed, 17 Jul 2019 15:31:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 17F33208C2 for ; Wed, 17 Jul 2019 15:31:52 +0000 (UTC) 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=l+8zgw5KPmInzJv2AfZXAyMhRibLtPQUdVSWzsoqkr0=; b=jx9I2iTZeDmWaq lrj9SKmBUfAVmy9Js5ACB6zhWqG+YzPk5JRkkq/5b/A0Tzb0Z1r+saSll9ySspFkXi/72q2/vxlhc 9lOQVl5zD6dmBPyqCIn53mcIPwkKlIyCLFm0VZ5Q9grNb5rp01oKLqsxc9HpxB+7YWvSftamMawOT JQQ02ILO7kvDkeMIX5SA9qkBdpBQG/CWiQ/QAf8hNk4ngXeByatgCZ+AlKJgVn9dT/Pzluo53iWwW 7YujvZ+veczdwuVItslN36hSL27+O0atRIKLNh0k9eOWAiFmBO9F/4dDRBNYeKUijg1R0SZHCSN7n TmYadz9IcdjtX6WbzDwA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hnluI-0003mo-Ud; Wed, 17 Jul 2019 15:31:50 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hnluG-0003jm-8m for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2019 15:31:49 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EABE4B033; Wed, 17 Jul 2019 15:31:44 +0000 (UTC) From: Nicolas Saenz Julienne To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC 1/4] arm64: mm: use arm64_dma_phys_limit instead of calling max_zone_dma_phys() Date: Wed, 17 Jul 2019 17:31:32 +0200 Message-Id: <20190717153135.15507-2-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717153135.15507-1-nsaenzjulienne@suse.de> References: <20190717153135.15507-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190717_083148_465365_E045B5D0 X-CRM114-Status: GOOD ( 10.22 ) 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: stefan.wahren@i2se.com, f.fainelli@gmail.com, catalin.marinas@arm.com, phil@raspberrypi.org, robin.murphy@arm.com, Jisheng.Zhang@synaptics.com, mbrugger@suse.com, will@kernel.org, hch@lst.de, Nicolas Saenz Julienne , m.szyprowski@samsung.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP By the time we call zones_sizes_init() arm64_dma_phys_limit already contains the result of max_zone_dma_phys(). We use the variable instead of calling the function directly to save some precious cpu time. Signed-off-by: Nicolas Saenz Julienne --- arch/arm64/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index f3c795278def..6112d6c90fa8 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -181,7 +181,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) unsigned long max_zone_pfns[MAX_NR_ZONES] = {0}; #ifdef CONFIG_ZONE_DMA32 - max_zone_pfns[ZONE_DMA32] = PFN_DOWN(max_zone_dma_phys()); + max_zone_pfns[ZONE_DMA32] = PFN_DOWN(arm64_dma_phys_limit); #endif max_zone_pfns[ZONE_NORMAL] = max; From patchwork Wed Jul 17 15:31:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 11048065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE9F31398 for ; Wed, 17 Jul 2019 15:32:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C938228754 for ; Wed, 17 Jul 2019 15:32:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBFF528750; Wed, 17 Jul 2019 15:32:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 58A1628750 for ; Wed, 17 Jul 2019 15:32:22 +0000 (UTC) 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=EYPZq+zNrLhshy9rqSqH6fsCNQWcQtzcvFAbxK2uHlw=; b=B77UwBkhvclfNx RziII+bZiQUxOE7Y1A1vQd43RpJUGf4GvbchSadHFeS2SKui0MDBV2gxsZAcO6bi0Byq+6GZ5zza4 ygSLz5xGWdzb4IJo2MOvvigfTJ3ebHVfN7dLHbL51O9s1xM3sz07EV/cx+r3Xe0jnDLK/Mn29mhU1 1tl4998fa9jsapFYQA/206mN93N6Z8jfzOtcOfsfekl6PvJceNkfAc2TBoAiEoHG/wGAA9o3sPagu LNdEw4yWM7NbBXIgvYbWvdjDACwIOb+OUM9wfFcr6Botu9QzuVephFSbkp8umfBfu7A0kL6boaPzW O4nVfb6xgmbshgyq3tXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hnlum-0004I7-LT; Wed, 17 Jul 2019 15:32:20 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hnluG-0003jn-HG for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2019 15:31:51 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DEE36B039; Wed, 17 Jul 2019 15:31:45 +0000 (UTC) From: Nicolas Saenz Julienne To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC 2/4] arm64: mm: parse dma-ranges in order to better estimate arm64_dma_phys_limit Date: Wed, 17 Jul 2019 17:31:33 +0200 Message-Id: <20190717153135.15507-3-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717153135.15507-1-nsaenzjulienne@suse.de> References: <20190717153135.15507-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190717_083148_864991_03F6D060 X-CRM114-Status: GOOD ( 17.10 ) 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: stefan.wahren@i2se.com, f.fainelli@gmail.com, catalin.marinas@arm.com, phil@raspberrypi.org, robin.murphy@arm.com, Jisheng.Zhang@synaptics.com, mbrugger@suse.com, will@kernel.org, hch@lst.de, Nicolas Saenz Julienne , m.szyprowski@samsung.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The dma physical limit has so far been calculated based on the memory size and the assumption that dma would be at least able to address the first 4 GB. This turned out no to be true with the Raspberry Pi 4 which, on it's main interconnect, can only address the first GB of memory, even though it might have up to 4 GB. With the current miscalculated dma physical limit the contiguous memory reserve is located in an inaccessible area for most of the board's devices. To solve this we now scan the device tree for the 'dma-ranges' property on the root or interconnect nodes, which allows us to calculate the lowest common denominator dma physical limit. If no dma-ranges is available, we'll default to the old scheme. Signed-off-by: Nicolas Saenz Julienne --- arch/arm64/mm/init.c | 61 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 6112d6c90fa8..5708adf0db52 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -163,14 +163,67 @@ static void __init reserve_elfcorehdr(void) { } #endif /* CONFIG_CRASH_DUMP */ + +static int __init early_init_dt_scan_dma_ranges(unsigned long node, + const char *uname, int depth, void *data) +{ + phys_addr_t *dma_phys_limit = data; + u64 phys_addr, dma_addr, size; + int dma_addr_cells; + const __be32 *reg; + const void *prop; + int len; + + /* We keep looking if this isn't the root node or an interconnect */ + if (!(depth == 0 || + (depth == 1 && of_flat_dt_is_compatible(node, "simple-bus")))) + return 0; + + prop = of_get_flat_dt_prop(node, "#address-cells", NULL); + if (prop) + dma_addr_cells = be32_to_cpup(prop); + else + dma_addr_cells = 1; /* arm64's default addr_cell size */ + + reg = of_get_flat_dt_prop(node, "dma-ranges", &len); + if (!reg || + len < (dma_addr_cells + dt_root_addr_cells + dt_root_size_cells)) + return 0; + + dma_addr = dt_mem_next_cell(dma_addr_cells, ®); + phys_addr = dt_mem_next_cell(dt_root_addr_cells, ®); + size = dt_mem_next_cell(dt_root_size_cells, ®); + + /* We're in ZONE_DMA32 */ + if (size > (1ULL << 32)) + size = 1ULL << 32; + + if (*dma_phys_limit > (phys_addr + size)) + *dma_phys_limit = phys_addr + size; + + return 0; +} + /* - * Return the maximum physical address for ZONE_DMA32 (DMA_BIT_MASK(32)). It - * currently assumes that for memory starting above 4G, 32-bit devices will - * use a DMA offset. + * Return the maximum physical address for ZONE_DMA32. It currently assumes + * that for memory starting above 4G, 32-bit devices will use a DMA offset. */ static phys_addr_t __init max_zone_dma_phys(void) { - phys_addr_t offset = memblock_start_of_DRAM() & GENMASK_ULL(63, 32); + phys_addr_t dma_phys_limit = ~0; + phys_addr_t offset; + + /* + * We walk the whole fdt looking for nodes with dma-ranges, calculate + * the max_zone_dma_phys for them and keep going. We end-up getting the + * lowest common denominator of all the matches. + */ + of_scan_flat_dt(early_init_dt_scan_dma_ranges, &dma_phys_limit); + if (dma_phys_limit != ~0) + return dma_phys_limit; + + /* If no dma-ranges property was found we try to infer the value */ + offset = memblock_start_of_DRAM() & GENMASK_ULL(63, 32); return min(offset + (1ULL << 32), memblock_end_of_DRAM()); } From patchwork Wed Jul 17 15:31:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 11048069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 202251510 for ; Wed, 17 Jul 2019 15:32:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C766208C2 for ; Wed, 17 Jul 2019 15:32:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3FB128757; Wed, 17 Jul 2019 15:32:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A6900208C2 for ; Wed, 17 Jul 2019 15:32:52 +0000 (UTC) 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=l34bmHBCxdlT+6HMQ3rvmGe5rGzODx1CGGb0d0H3zzo=; b=aGEX9xEnDWn9Gq YntetBWb/WUQUfN4D/tLMBvMqJbtlJqLo55xXX8luV7z3YECroXy/b03oS7cAo7JhVGG3lqLd98Va g8tpXY8AOe1l++Xj1jXLQvCxm7coGRTTUZofoA+GuLMbqV2rMQCPQufmYH675dNOyDiIKjxzoFydI EFVYxHAoNHRzzu7zfrmxmWM8DSChN2/vA6btkMD34KlG/nRS91SX2E6vxD1Cugrcy5+mJvG4i74ye 8GR7M1VEJgbSjzw0g4wJ2G47MPC22yzFNhco/2oFngJGjOuPuj0mV2i218jovi0Z5XCVy3ix8sQcZ ie1yuuYg488OC3D6tBlQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hnlvG-0004pc-9p; Wed, 17 Jul 2019 15:32:50 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hnluH-0003k1-IJ for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2019 15:31:51 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EB414B048; Wed, 17 Jul 2019 15:31:46 +0000 (UTC) From: Nicolas Saenz Julienne To: linux-arm-kernel@lists.infradead.org, Christoph Hellwig , Marek Szyprowski , Robin Murphy Subject: [RFC 3/4] dma-direct: add dma_direct_min_mask Date: Wed, 17 Jul 2019 17:31:34 +0200 Message-Id: <20190717153135.15507-4-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717153135.15507-1-nsaenzjulienne@suse.de> References: <20190717153135.15507-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190717_083149_755004_F4482673 X-CRM114-Status: GOOD ( 11.02 ) 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: stefan.wahren@i2se.com, f.fainelli@gmail.com, catalin.marinas@arm.com, phil@raspberrypi.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Jisheng.Zhang@synaptics.com, mbrugger@suse.com, will@kernel.org, Nicolas Saenz Julienne Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Historically devices with ZONE_DMA32 have been assumed to be able to address at least the lower 4GB of ram for DMA. This is still the defualt behavior yet the Raspberry Pi 4 is limited to the first GB of memory. This has been observed to trigger failures in dma_direct_supported() as the 'min_mask' isn't properly set. We create 'dma_direct_min_mask' in order for the arch init code to be able to fine-tune dma direct's 'min_dma' mask. Signed-off-by: Nicolas Saenz Julienne --- kernel/dma/direct.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index b90e1aede743..3c8cd730648b 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -23,6 +23,8 @@ #define ARCH_ZONE_DMA_BITS 24 #endif +u64 dma_direct_min_mask __ro_after_init = DMA_BIT_MASK(32); + /* * For AMD SEV all DMA must be to unencrypted addresses. */ @@ -393,7 +395,7 @@ int dma_direct_supported(struct device *dev, u64 mask) if (IS_ENABLED(CONFIG_ZONE_DMA)) min_mask = DMA_BIT_MASK(ARCH_ZONE_DMA_BITS); else - min_mask = DMA_BIT_MASK(32); + min_mask = dma_direct_min_mask; min_mask = min_t(u64, min_mask, (max_pfn - 1) << PAGE_SHIFT); From patchwork Wed Jul 17 15:31:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 11048067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB15C1510 for ; Wed, 17 Jul 2019 15:32:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A838028750 for ; Wed, 17 Jul 2019 15:32:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BDE728754; Wed, 17 Jul 2019 15:32:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 38B34208C2 for ; Wed, 17 Jul 2019 15:32:35 +0000 (UTC) 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=WMqa8UUrw+NTdpJn7tHWZn+8s3S2idQQHcxk2rF5Z98=; b=QizmSkuIdWZPjR d16NzYsWf1n9a7lEuMUAVDFH6LHR1N1x1j2h80JLc1YoidMKbckB82fcB/hok4iX6nVbIYWK0fHh3 MH8do/4sPSKH+iioF8VUki76sNKpNjmoCW9Yx1yYhEGsUKac5PI47jwA75z4T6zpyZfboRSe90iX8 L4RpnM6FevWH9k2/ZkMXc8e//TckkNVuzyukeNjMMQjZQTltWqSbLxjjyYqKwgdbSObZrsLTKeHjf 9vMxlqTaoYqJC3/YRnIzDdCstGLjLzltTetfInO9cUqttGdrqqukaceGVGFhiMt3N80f6g+eH8BXC Gh2P26uFqj+dTzS/tYrg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hnlv0-0004Zb-Il; Wed, 17 Jul 2019 15:32:34 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hnluH-0003k3-67 for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2019 15:31:51 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E2425AF95; Wed, 17 Jul 2019 15:31:47 +0000 (UTC) From: Nicolas Saenz Julienne To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC 4/4] arm64: mm: set direct_dma_min_mask according to dma-ranges Date: Wed, 17 Jul 2019 17:31:35 +0200 Message-Id: <20190717153135.15507-5-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190717153135.15507-1-nsaenzjulienne@suse.de> References: <20190717153135.15507-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190717_083149_367937_BDEEF529 X-CRM114-Status: GOOD ( 12.39 ) 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: stefan.wahren@i2se.com, f.fainelli@gmail.com, catalin.marinas@arm.com, phil@raspberrypi.org, robin.murphy@arm.com, Jisheng.Zhang@synaptics.com, mbrugger@suse.com, will@kernel.org, hch@lst.de, Nicolas Saenz Julienne , m.szyprowski@samsung.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we parse the dma-ranges during initialization we can fine-tune the DMA mask used by the direct DMA implementation. We set the mask based on the size of the DMA addressable memory, and if bigger than 4GB we force it to DMA_BIT_MASK(32) as it's always been. Signed-off-by: Nicolas Saenz Julienne --- arch/arm64/mm/init.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 5708adf0db52..f8af2c99667c 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -52,6 +52,8 @@ EXPORT_SYMBOL(memstart_addr); phys_addr_t arm64_dma_phys_limit __ro_after_init; +extern u64 dma_direct_min_mask; + #ifdef CONFIG_KEXEC_CORE /* * reserve_crashkernel() - reserves memory for crash kernel @@ -198,8 +200,12 @@ static int __init early_init_dt_scan_dma_ranges(unsigned long node, if (size > (1ULL << 32)) size = 1ULL << 32; - if (*dma_phys_limit > (phys_addr + size)) + if (*dma_phys_limit > (phys_addr + size)) { + /* Set min DMA mask in case is was smaller than 32 */ + dma_direct_min_mask = size - 1; + *dma_phys_limit = phys_addr + size; + } return 0; }