-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Configure CMA using DT #3536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure CMA using DT #3536
Conversation
1343386 to
6a5dde2
Compare
|
@HiassofT I think I've got this working now - can you give it a try? |
|
@pelwell thanks a lot! testing on RPi4 worked fine, tested the cma-size parameter both of cma and c4-kms-v3d-pi4 overlays (32bit kernel only though, haven't checked 64bit) |
commit bff3b04 upstream. With the introduction of ZONE_DMA in arm64 we moved the default CMA and crashkernel reservation into that area. This caused a regression on big machines that need big CMA and crashkernel reservations. Note that ZONE_DMA is only 1GB big. Restore the previous behavior as the wide majority of devices are OK with reserving these in ZONE_DMA32. The ones that need them in ZONE_DMA will configure it explicitly. Fixes: 1a8e1ce ("arm64: use both ZONE_DMA and ZONE_DMA32") Reported-by: Qian Cai <cai@lca.pw> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
commit 93b9041 upstream. John reports that the recently merged commit 1a8e1ce ("arm64: use both ZONE_DMA and ZONE_DMA32") breaks the boot on his DB845C board: | Booting Linux on physical CPU 0x0000000000 [0x517f803c] | Linux version 5.4.0-mainline-10675-g957a03b9e38f | Machine model: Thundercomm Dragonboard 845c | [...] | Built 1 zonelists, mobility grouping on. Total pages: -188245 | Kernel command line: earlycon | firmware_class.path=/vendor/firmware/ androidboot.hardware=db845c | init=/init androidboot.boot_devices=soc/1d84000.ufshc | printk.devkmsg=on buildvariant=userdebug root=/dev/sda2 | androidboot.bootdevice=1d84000.ufshc androidboot.serialno=c4e1189c | androidboot.baseband=sda | msm_drm.dsi_display0=dsi_lt9611_1080_video_display: | androidboot.slot_suffix=_a skip_initramfs rootwait ro init=/init | | <hangs indefinitely here> This is because, when CONFIG_NUMA=n, zone_sizes_init() fails to handle memblocks that fall entirely within the ZONE_DMA region and erroneously ends up trying to add a negatively-sized region into the following ZONE_DMA32, which is later interpreted as a large unsigned region by the core MM code. Rework the non-NUMA implementation of zone_sizes_init() so that the start address of the memblock being processed is adjusted according to the end of the previous zone, which is then range-checked before updating the hole information of subsequent zones. Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Cc: Christoph Hellwig <hch@lst.de> Cc: Bjorn Andersson <bjorn.andersson@linaro.org> Link: https://lore.kernel.org/lkml/CALAqxLVVcsmFrDKLRGRq7GewcW405yTOxG=KR3csVzQ6bXutkA@mail.gmail.com Fixes: 1a8e1ce ("arm64: use both ZONE_DMA and ZONE_DMA32") Reported-by: John Stultz <john.stultz@linaro.org> Tested-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
commit c5a1e53 upstream. With the introduction of the Raspberry Pi 4 we were forced to explicitly configure CMA's location, since arm64 defaults it into the ZONE_DMA32 memory area, which is not good enough to perform DMA operations on that device. To bypass this limitation a dedicated CMA DT node was created, explicitly indicating the acceptable memory range and size. That said, compatibility between boards is a must on the Raspberry Pi ecosystem so this creates a common CMA DT node so as for DT overlays to be able to update CMA's properties regardless of the board being used. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Phil Elwell <phil@raspberrypi.org> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
commit 8c8c5a4 upstream. Although the device tree might contain a reserved-memory DT node dedicated as the default CMA pool, users might want to change CMA's parameters using the kernel command line for debugging purposes and whatnot. Honor this by bypassing the reserved memory CMA setup, which will ultimately end up freeing the memblock and allow the command line CMA configuration routine to run. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Phil Elwell <phil@raspberrypi.org> Signed-off-by: Christoph Hellwig <hch@lst.de>
Now that the kernel command line has precedence over the device tree, we can use the upstream CMA setup without breaking backward compatibility. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Now that we don't have to abuse the kernel command line to change CMA's size we can clean-up and centralize CMA usage in overlays. A new file, cma-overlay.dts is created to be used as a standalone overlay or included on other overlays. All CMA users are converted to this scheme. Ultimately upstream-overlay.dts is also updated to use the default CMA size provided by upstream. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
|
FYI, I had to revert this patch set for a while because of an issue causing 32-bit boot failures with the CMA allocation set to 192MB - it was being created at a location that overlapped the HIGHMEM space at 0x30000000, which killed the CMA activation. The downstream file bcm2711-rpi.dtsi now patches the alloc-ranges to restrict CMA to the first 768MB, and I've not had any problems since. |
|
@pelwell, are you forward porting that change to rpi-5.6.y? |
|
Yes - I'm just (gasp) testing it first! |
|
Done. |
kernel: Configure CMA using DT See: raspberrypi/linux#3536 kernel: Rpi 5.4.y add the audioinjector.net isolated sound card See: raspberrypi/linux#3533 kernel: spi: Force CS_HIGH if GPIO descriptors are used
kernel: Configure CMA using DT See: raspberrypi/linux#3536 kernel: Rpi 5.4.y add the audioinjector.net isolated sound card See: raspberrypi/linux#3533 kernel: spi: Force CS_HIGH if GPIO descriptors are used
This is an attempt at a back-port of @vianpl's PR (#3529), which targets rpi-5.6.y.
It appears to work on 32-bit builds, but 64-bit looks like DMA address mapping is wrong.