From: Will Deacon <will@kernel.org> To: John Stultz <john.stultz@linaro.org> Cc: linux-arm-kernel <linux-arm-kernel@lists.infradead.org>, Amit Pundir <amit.pundir@linaro.org>, Florian Fainelli <f.fainelli@gmail.com>, mbrugger@suse.com, Marc Zyngier <marc.zyngier@arm.com>, Catalin Marinas <catalin.marinas@arm.com>, lkml <linux-kernel@vger.kernel.org>, Bjorn Andersson <bjorn.andersson@linaro.org>, linux-mm <linux-mm@kvack.org>, Rob Herring <robh+dt@kernel.org>, wahrenst@gmx.net, Nicolas Dechense <nicolas.dechesne@linaro.org>, Marek Szyprowski <m.szyprowski@samsung.com>, Robin Murphy <robin.murphy@arm.com>, Christoph Hellwig <hch@lst.de>, Nicolas Saenz Julienne <nsaenzjulienne@suse.de>, linux-rpi-kernel@lists.infradead.org Subject: Re: [PATCH v6 3/4] arm64: use both ZONE_DMA and ZONE_DMA32 Date: Tue, 3 Dec 2019 10:12:50 +0000 Message-ID: <20191203101249.GC6815@willie-the-truck> (raw) In-Reply-To: <CALAqxLW7RTif_NPxFXnxfTm2_ST+6aNmE6X=3v4XsuojKH2mtg@mail.gmail.com> Hi John, On Mon, Dec 02, 2019 at 10:03:17PM -0800, John Stultz wrote: > Ok, narrowing it down further, it seems its the following bit from the > patch: > > > @@ -201,13 +212,18 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) > > struct memblock_region *reg; > > unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; > > unsigned long max_dma32 = min; > > + unsigned long max_dma = min; > > > > memset(zone_size, 0, sizeof(zone_size)); > > > > - /* 4GB maximum for 32-bit only capable devices */ > > +#ifdef CONFIG_ZONE_DMA > > + max_dma = PFN_DOWN(arm64_dma_phys_limit); > > + zone_size[ZONE_DMA] = max_dma - min; > > + max_dma32 = max_dma; > > +#endif > > #ifdef CONFIG_ZONE_DMA32 > > max_dma32 = PFN_DOWN(arm64_dma32_phys_limit); > > - zone_size[ZONE_DMA32] = max_dma32 - min; > > + zone_size[ZONE_DMA32] = max_dma32 - max_dma; > > #endif > > zone_size[ZONE_NORMAL] = max - max_dma32; > > > > @@ -219,11 +235,17 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) > > > > if (start >= max) > > continue; > > - > > +#ifdef CONFIG_ZONE_DMA > > + if (start < max_dma) { > > + unsigned long dma_end = min_not_zero(end, max_dma); > > + zhole_size[ZONE_DMA] -= dma_end - start; > > + } > > +#endif > > #ifdef CONFIG_ZONE_DMA32 > > if (start < max_dma32) { > > - unsigned long dma_end = min(end, max_dma32); > > - zhole_size[ZONE_DMA32] -= dma_end - start; > > + unsigned long dma32_end = min(end, max_dma32); > > + unsigned long dma32_start = max(start, max_dma); > > + zhole_size[ZONE_DMA32] -= dma32_end - dma32_start; > > } > > #endif > > if (end > max_dma32) { > > The zhole_sizes end up being: > zhole_size: DMA: 67671, DMA32: 1145664 NORMAL: 0 > > This seems to be due to dma32_start being calculated as 786432 each > time - I'm guessing that's the max_dma value. > Where dma32_end is around 548800, but changes each iteration (so we > end up subtracting a negative value each pass, growing the size). Yeah, this logic looks utterly buggered to me so I'm surprised that nobody else has seen the problem. In particlar, kernelci is reporting success on the same SoC :/ https://kernelci.org/boot/sdm845-db845c/ The logs also don't seem to match up with the trees either. For example, looking at the boot logs for: https://kernelci.org/boot/id/5de5fc60b1ed6e2d46960f08/ It claims that the kernel is "next-2019-12-30" but the dmesg says: [ 0.000000] Linux version 5.4.0 (KernelCI@b19b74fe311d) (gcc version 8.3.0 (Debian 8.3.0-2)) #1 SMP PREEMPT Tue Dec 3 03:14:07 UTC 2019 Which isn't great. Anyway, I've had a go at fixing it below but it's 100% untested. I think the issue is that your SoC has memblocks contained entirely within the ZONE_DMA region and we don't cater for that at all when processing the ZONE_DMA32 region. Will --->8 diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index be9481cdf3b9..af365ce59ed6 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -242,19 +242,19 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) if (start < max_dma) { unsigned long dma_end = min_not_zero(end, max_dma); zhole_size[ZONE_DMA] -= dma_end - start; + start = dma_end; } #endif #ifdef CONFIG_ZONE_DMA32 - if (start < max_dma32) { + if (start >= max_dma && start < max_dma32) { unsigned long dma32_end = min(end, max_dma32); - unsigned long dma32_start = max(start, max_dma); - zhole_size[ZONE_DMA32] -= dma32_end - dma32_start; + zhole_size[ZONE_DMA32] -= dma32_end - start; + start = dma32_end; } #endif - if (end > max_dma32) { + if (start >= max_dma32) { unsigned long normal_end = min(end, max); - unsigned long normal_start = max(start, max_dma32); - zhole_size[ZONE_NORMAL] -= normal_end - normal_start; + zhole_size[ZONE_NORMAL] -= normal_end - start; } } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply index Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-09-11 18:25 [PATCH v6 0/4] Raspberry Pi 4 DMA addressing support Nicolas Saenz Julienne 2019-09-11 18:25 ` [PATCH v6 1/4] arm64: mm: use arm64_dma_phys_limit instead of calling max_zone_dma_phys() Nicolas Saenz Julienne 2019-09-11 18:25 ` [PATCH v6 2/4] arm64: rename variables used to calculate ZONE_DMA32's size Nicolas Saenz Julienne 2019-09-11 18:25 ` [PATCH v6 3/4] arm64: use both ZONE_DMA and ZONE_DMA32 Nicolas Saenz Julienne 2019-10-21 14:15 ` Qian Cai 2019-10-21 14:34 ` Nicolas Saenz Julienne 2019-10-21 14:46 ` Qian Cai 2019-10-21 17:01 ` Nicolas Saenz Julienne 2019-10-21 17:25 ` Qian Cai 2019-10-21 17:55 ` Nicolas Saenz Julienne 2019-10-21 20:36 ` Qian Cai 2019-10-22 11:23 ` Nicolas Saenz Julienne 2019-10-23 7:11 ` Matthias Brugger 2019-10-31 15:51 ` Catalin Marinas 2019-10-31 16:04 ` Nicolas Saenz Julienne 2019-10-31 18:02 ` Catalin Marinas 2019-10-31 18:11 ` Nicolas Saenz Julienne 2019-10-31 18:13 ` Catalin Marinas 2019-12-03 5:08 ` John Stultz 2019-12-03 5:38 ` John Stultz 2019-12-03 6:03 ` John Stultz 2019-12-03 10:12 ` Will Deacon [this message] 2019-12-03 11:19 ` Catalin Marinas 2019-09-11 18:25 ` [PATCH v6 4/4] mm: refresh ZONE_DMA and ZONE_DMA32 comments in 'enum zone_type' Nicolas Saenz Julienne 2019-10-01 16:05 ` [PATCH v6 0/4] Raspberry Pi 4 DMA addressing support Catalin Marinas
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191203101249.GC6815@willie-the-truck \ --to=will@kernel.org \ --cc=amit.pundir@linaro.org \ --cc=bjorn.andersson@linaro.org \ --cc=catalin.marinas@arm.com \ --cc=f.fainelli@gmail.com \ --cc=hch@lst.de \ --cc=john.stultz@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-rpi-kernel@lists.infradead.org \ --cc=m.szyprowski@samsung.com \ --cc=marc.zyngier@arm.com \ --cc=mbrugger@suse.com \ --cc=nicolas.dechesne@linaro.org \ --cc=nsaenzjulienne@suse.de \ --cc=robh+dt@kernel.org \ --cc=robin.murphy@arm.com \ --cc=wahrenst@gmx.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-ARM-Kernel Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \ linux-arm-kernel@lists.infradead.org public-inbox-index linux-arm-kernel Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git