-
Notifications
You must be signed in to change notification settings - Fork 5k
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
bcm270x: Convert to ARCH_MULTIPLATFORM #1699
Conversation
This isn't used anymore now that the watchdog driver does restart/poweroff. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
NEED_MACH_IO_H isn't necessary since we don't have PC card/PCI/ISA IO space. The __io macro is only used in the {in,out}[bwl] macros. arch/arm/include/asm/io.h will give these defaults now: define __io(a) __typesafe_io((a) & IO_SPACE_LIMIT) define IO_SPACE_LIMIT ((resource_size_t)0) This is the same as ARCH_BCM2835. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
This makes it possible to get the bus address from Device Tree. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
This makes it possible to get the bus address from Device Tree. At the same time move the call to log_init() after getting the clock to avoid allocating twice due to deferred probing. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Drop NEED_MACH_MEMORY_H and use dma-ranges from the Device Tree to get the bus address, like ARCH_BCM2835 does. This means that we go from this: arch/arm/mach-bcm270x/include/mach/memory.h: define __virt_to_bus(x) ((x) + (BUS_OFFSET - PAGE_OFFSET)) define __bus_to_virt(x) ((x) - (BUS_OFFSET - PAGE_OFFSET)) define __pfn_to_bus(x) (__pfn_to_phys(x) + BUS_OFFSET) define __bus_to_pfn(x) __phys_to_pfn((x) - BUS_OFFSET To this: arch/arm/include/asm/memory.h: define __virt_to_bus __virt_to_phys define __bus_to_virt __phys_to_virt define __pfn_to_bus(x) __pfn_to_phys(x) define __bus_to_pfn(x) __phys_to_pfn(x) Drivers now have to use the DMA API to get to the bus address. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
This file doesn't build anymore and isn't used so remove it. It was added as part of my ARCH_BCM2835 work last year, but the future didn't pan out as expected. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Convert to multi platform and base it on ARCH_BCM2835. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Convert to multi platform and base it on ARCH_BCM2835. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
ARCH_BCM2708 and ARCH_BCM2709 selects ARCH_BCM2835 now, so the dependencies can be simplified. Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Unified kernel image It is now possible to build a kernel image that can/should boot on Pi1 and Pi2.
It seems to work on Pi1 except that On Pi2 it isn't good. Tagging the kernel from a network driver always fails like this:
And every other boot drops me into emergency console (eventually):
I had this problem last year also when I tried this, and I haven't figured out the cause. Oh well, I wasn't able to make that unified image, but hopefully this PR survives review and testing, with the result that downstream for all pratical purposes will be using ARCH_BCM2835! |
Looks good. |
One interesting aspect of having 270x and 283x support in the same image is that the mkknlimg trailer (if you add one) sets both flags. The firmware currently sees the 283x flag and chooses to load bcm283x dtb files. If they aren't there, as is the case with my (remote) Pi, it won't boot (not falling back to the bcm270x variants). Omitting the trailer should get it working again. |
I see now that there are two flags: 283x and 283X. But in my case it loads the right dtb:
|
That was a false alarm - "283x" is the old single-platform tag, and if set will result in the bcm283x DTBs being loaded . "283X" says the image includes upstream support, but not to use it automatically because it also includes "270X" support ("283x" means "283X && !270X"). On a Pi 2 I get complaints about timer interrupts:
My Pi was failing to boot because it's a Pi3, and both USB and the UART seem to be hosed with this build. More digging required. |
#1669 has info about the warnings. |
vchiq isn't connecting. Still digging. |
I have the same problem. Build with bcm2709_defconfig works on Pi2. |
I see no issues with the dwc_otg changes. |
See: raspberrypi#1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
The problem was caused by the lack of a dma-ranges property in the bcm2710 dtb. I've added a patch that includes it, and the |
@@ -160,6 +160,20 @@ config ARCH_BCM2835 | |||
This enables support for the Broadcom BCM2835 and BCM2836 SoCs. | |||
This SoC is used in the Raspberry Pi and Roku 2 devices. | |||
|
|||
config MACH_BCM2708 | |||
bool "Enable optimized __copy_to_user and __copy_from_user" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text doesn't seem to match the config name. A c/p error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was tired and didn't know what to call it, so I just kept the name.
The only place CONFIG_MACH_BCM2708 is used is in the optimization code: 5fb515e
Thanks for fixing that up @pelwell, I've been down so many rabbit holes with this, that I forgot about 2710. |
FYI I've updated 4.9 tree with these changes, rebasing them into original commits. |
@pelwell okay to merge? |
Yes the Main bcm2708/bcm2709 linux port commit is significantly smaller now! I have some i2c-bcm2835 patches that awaits i2c maintainer review. With those in place, I hope we can switch to use i2c-bcm2835 by default. AFAIK that's the last of the mainline drivers which has a downstream 2708 version. |
@notro great - we always look forward to your PR's - keep them coming! |
As a Raspberry Pi enthusiast I love threads like this, despite understanding only the most general aspects. Thanks to all involved, and please keep up the great work. |
@notro Don't forget the bcm2708-usb - we'll be holding on to that for a while, I think. And thank you for another significant contribution. Yes - merge away. |
Yes you're right of course, I forgot that one. I had a look at the dwc_otg patch and it touches core files for the fiq support, so it will probably stay a long time. IIRC there was a comment in an arm64 thread about dwc_otg outperforming dwc2 even without fiq. |
I chuckled earlier today, when I came across this from Dec 2012.... #170 |
BTW, I've been using "coherent_pool=1M" on the 2x Zero's, 4x 2B's and 3x 3B's, that I've now got running 4.8.y HEAD with ARCH_MULTIPLATFORM config. Perhaps that is a sensible compromise between 256k and 4M? |
@popcornmix Yes.... Understand..... I just chuckled at the headline, "256 KiB atomic DMA coherent pool is too small!", 4 years ago, rather than what was causing it to be too small or where it fits in terms of timelines of what happened, when, and other commits. |
OK, silly question here. I'm new to this whole thing.... Isn't ALL the ram on the RPI DMA coherent? It's just a matter of getting the mappings correct, right? |
I mean, couldn't the memory be allocated with kmalloc or friends, then mapped into DMA space with dma_map_single/dma_map_sg/friends when it's actually sent to the USB controller? |
I'll leave the technical discussion to the experts..... |
Coherent mappings require no explicit cache flushing between hardware changing values in RAM and the CPU reading them and vice versa. Bits are set in the page entries that effectively bypass cache on these pages. dwc_otg is suboptimal in that regard - an unaligned memcpy from coherent memory is going to be a bit slow, but the majority of transfers that fall into the "unaligned" bucket are of the order of 16 bytes. dwc2 upstream allocates an aligned buffer and overwrites urb->transfer_buffer to allow the usb-related DMA map-unmap functions to work, but frees/allocates on submission and retire of each URB with unaligned buffers. I don't know which would be slower on a Pi 1 - the coherent unaligned memcpy or the allocate/deallocate for each URB. |
@clivem can you identify the USB device that results in the dwc_otg allocations? |
@popcornmix Only USB device plugged into that board (which generated the earlier log I posted) is an Edimax wifi dongle using the mt7601u kernel module.
|
Okay, I've bumped default coherent size to 1M and added a WARN_ON to failure path when allocating a coherent buffer from dwc_otg, so we might catch users with multiple USB devices that use unaligned transfers. |
@popcornmix Cool! Any chance of rebase 4.8.4 -> 4.8.5 before I run another local build. ;) |
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
Rebased. 4.8.6 now. |
@popcornmix Ta. |
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: #1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
See: raspberrypi/linux#1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org> [Xulin: Original patch taken from https://github.com/raspberrypi/linux.git branch rpi-4.8.y] Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
See: raspberrypi/linux#1699 Signed-off-by: Phil Elwell <phil@raspberrypi.org> [Xulin: Original patch taken from https://github.com/raspberrypi/linux.git branch rpi-4.8.y] Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
This PR converts ARCH_BCM2708 and ARCH_BCM2709 to ARCH_MULTIPLATFORM.
Both ARCH_BCM2708 and ARCH_BCM2709 are now based on ARCH_BCM2835, removing the need for the mach-bcm2708 and mach-bcm2709 directories. In addition to that it removes the need to patch many Kconfig files just to add
depends ARCH_BCM2708 || ARCH_BCM2708 || ...
.Using ARCH_BCM2835 means that the 2835 dtb's are also built, but they won't work with this config.
And scripts/mkknlimg will add the tag:
283x: y
Tested on Pi1 and Pi2.
@popcornmix please check with the GPU debugger to make sure that this doesn't give
L2 bad address exception
like it did when I tried this last year: #1178 (comment)Here's the .config diff introduced by this PR:
Of all the PR's I have submitted, this is the one I have the least confidence in. I have had so much problems and lockups working with this ARCH_MULTIPLATFORM convertion, both now and last year, that I started to think that I just couldn't do it.
That being said, I haven't had any issues with this particular PR, just with all my efforts to try and build a stable kernel that can boot on both Pi1 and Pi2.