Skip to content
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: Move power module #980

Merged
merged 2 commits into from
May 28, 2015
Merged

BCM270x: Move power module #980

merged 2 commits into from
May 28, 2015

Conversation

notro
Copy link
Contributor

@notro notro commented May 23, 2015

This makes it possible to boot ARCH_BCM2835 directly from the VideoCore bootloader.
The power module turns on USB power, so u-boot is not strictly necessary anymore.

Tested on Pi1 and Pi2 regular kernel + ARCH_BCM2835.

On ARCH_BCM2835 add dtb to /boot/config.txt

device_tree=bcm2835-rpi-b-plus.dtb
or
device_tree=bcm2835-rpi-b.dtb

notro added 2 commits May 23, 2015 23:30
Make the power module available on ARCH_BCM2835 by moving it.
The module turns on USB power making it possible to boot
ARCH_BCM2835 directly with the VC bootloader.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
The VideoCore bootloader concatenates the bootargs property together
with /boot/cmdline.txt and includes it's own set of options.
Set bootargs to an empty string to behave like BCM270x.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
@notro
Copy link
Contributor Author

notro commented May 23, 2015

@pelwell It would have been nice if mkknlimg could tag the ARCH_BCM2835 kernel specially so the firmware can set device_tree= automatically for us.

@popcornmix
Copy link
Collaborator

It's okay by me.

@pelwell
Copy link
Contributor

pelwell commented May 24, 2015

I can arrange for the tagging and DTB selection, but I'm not available until Wednesday.

@pelwell
Copy link
Contributor

pelwell commented May 28, 2015

@notro My proposal is to put an "architecture" prefix into the trailer, where the default is bcm2708 or bcm2709, and then arrange that mkknlimg adds bcm2835/bcm2836 for you (either automatically or as a command line option). For this to work, the bcm2835/bcm2836 .dtbs will have to maintain the same filename structure as the bcm2708/bcm2709 equivalents, e.g. bcm2836-rpi-2-b.dtb.

@notro
Copy link
Contributor Author

notro commented May 28, 2015

For this to work, the bcm2835/bcm2836 .dtbs will have to maintain the same filename structure as the bcm2708/bcm2709 equivalents, e.g. bcm2836-rpi-2-b.dtb.

That seems to be the case. From [PATCH 3/9] ARM: Make a copy of the 2835 dts for the 2836.:

This is not hooked up to anything yet, but it means that our later
2836-specific changes will be more obvious.  The bcm2836-rpi-2-b.dts
actually comes from bcm2835-rpi-2-b-plus, which apparently is the
closest.

Signed-off-by: Eric Anholt <eric at anholt.net>
---
 arch/arm/boot/dts/bcm2836-rpi-2-b.dts | 30 +++++++++++++++++++++

I don't know what filenames Warren refers to in his follow up:

Eventually, I'd like to get around to revamping the bcm283x DTs so
there's a DT for each separate board model, which would match the DT
filenames that U-Boot is looking for. Still, that's separate from these
patches.

But anyway, I believe dts files will be the last bit to match mainline (if ever), so even if we end up diverging here it's no big deal.

@pelwell
Copy link
Contributor

pelwell commented May 28, 2015

Tested on a Pi 1 and Pi 2, with and without DT. Merging.

pelwell added a commit that referenced this pull request May 28, 2015
BCM270x: Move power module
@pelwell pelwell merged commit 886477a into raspberrypi:rpi-4.0.y May 28, 2015
@notro notro deleted the power branch May 28, 2015 13:31
@pelwell
Copy link
Contributor

pelwell commented May 28, 2015

@notro How are you booting ARCH_BCM2835 builds? Are you using kernel_old with custom startup code? I get a boot failure because the machine ID isn't supported:

Error: unrecognized/unsupported machine ID (r1 = 0x00000c42).

Available machine support:

ID (hex)        NAME
ffffffff        Generic DT based system
ffffffff        BCM2835

Please check your kernel config and/or bootloader.

@notro
Copy link
Contributor Author

notro commented May 28, 2015

I just add this to /boot/config.txt:

device_tree=bcm2835-rpi-b-plus.dtb

@pelwell
Copy link
Contributor

pelwell commented May 28, 2015

Are you building with an unmodified bcm2835_defconfig?

@notro
Copy link
Contributor Author

notro commented May 28, 2015

Yes.

If you want onboard audio you currently have to manually enable: CONFIG_SOUND, CONFIG_SND, CONFIG_SND_BCM2835

I look forward to having an ARCH_BCM2835 tagged kernel, because I frequently forget to toggle the device_tree= setting when I switch between kernels, ending up with a system that doesn't boot.

@pelwell
Copy link
Contributor

pelwell commented May 28, 2015

Unless you are using either a custom kernel header (or u-boot) and kernel_old, or a modified bcm2835 build that expects the 0xc42/3138 magic number, then I don't understand how it is working for you.

Can you upload your kernel image somewhere and briefly outline your build steps?

@notro
Copy link
Contributor Author

notro commented May 28, 2015

Are you tagging your kernel with the --dtok option?

sudo ~/work/tools/mkimage/mkknlimg --dtok ~/work/notro-raspberrypi-linux/workdir.bcm2708/linux/arch/arm/boot/zImage /boot/kernel.img

@pelwell
Copy link
Contributor

pelwell commented May 28, 2015

Yes - the problem isn't DT support, it's the machine ID, which the firmware sets to 0xc42 for all Pi's.

@notro
Copy link
Contributor Author

notro commented May 28, 2015

@pelwell
Copy link
Contributor

pelwell commented May 28, 2015

Thanks.

@notro
Copy link
Contributor Author

notro commented May 28, 2015

The error you get indicates that the kernel doesn't find a matching Device Tree, because the error you get is the atags fallback.
AFAIK machine id is not used with Device Tree, the compatible property fills that role.

void __init setup_arch(char **cmdline_p)
{
        const struct machine_desc *mdesc;

        setup_processor();
        mdesc = setup_machine_fdt(__atags_pointer);
        if (!mdesc)
                mdesc = setup_machine_tags(__atags_pointer, __machine_arch_type);

http://lxr.free-electrons.com/source/arch/arm/kernel/setup.c#L895

const struct machine_desc * __init
setup_machine_tags(phys_addr_t __atags_pointer, unsigned int machine_nr)
{
...
        if (!mdesc) {
                early_print("\nError: unrecognized/unsupported machine ID"
                            " (r1 = 0x%08x).\n\n", machine_nr);
                dump_machine_table(); /* does not return */
        }

http://lxr.free-electrons.com/source/arch/arm/kernel/atags_parse.c#L182

@pelwell
Copy link
Contributor

pelwell commented May 28, 2015

I'd just reached the same conclusion. A stray dtoverlay was failing because of missing labels and aborting the DT support.

With an empty config.txt it boots.

@pelwell
Copy link
Contributor

pelwell commented May 28, 2015

The firmware patch that implements this feature depends on a more complex patch to the loader. Once we're happy that both patches are good they will appear in a future release.

@notro
Copy link
Contributor Author

notro commented May 28, 2015

Thank you.

popcornmix added a commit to raspberrypi/firmware that referenced this pull request May 30, 2015
See: raspberrypi/linux#985

firmware: MMAL queue: extra protection on the sanity check
firmware: MMAL: reset buffer recommended values on switching back to raw pixels
firmware: OV5647: Remove readback of I2C writes
firmware: MMAL: Add rawcam component and required framework changes
firmware: Add MMAL to IL mapping for rawcam parameters
firmware: Image_encode: Add support or YUYV input source
firmware: OV5647 tuning: Add the fixed ISO preview modes

firmware: Replacing board rev functions with board_info library

firmware: arm_loader: Add support for ARCH_BCM2835 builds
See: raspberrypi/linux#980 (comment)
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this pull request May 30, 2015
See: raspberrypi/linux#985

firmware: MMAL queue: extra protection on the sanity check
firmware: MMAL: reset buffer recommended values on switching back to raw pixels
firmware: OV5647: Remove readback of I2C writes
firmware: MMAL: Add rawcam component and required framework changes
firmware: Add MMAL to IL mapping for rawcam parameters
firmware: Image_encode: Add support or YUYV input source
firmware: OV5647 tuning: Add the fixed ISO preview modes

firmware: Replacing board rev functions with board_info library

firmware: arm_loader: Add support for ARCH_BCM2835 builds
See: raspberrypi/linux#980 (comment)
@pelwell
Copy link
Contributor

pelwell commented May 30, 2015

@popcornmix has pushed the updated firmware.

@notro
Copy link
Contributor Author

notro commented May 30, 2015

That worked just fine, thank you!

@notro
Copy link
Contributor Author

notro commented Jun 4, 2015

@pelwell Booting ARCH_BCM2835 with an overlay that references an unknown label prevents the kernel from booting:

Uncompressing Linux... done, booting the kernel.

Error: unrecognized/unsupported machine ID (r1 = 0x00000c42).

Available machine support:

ID (hex)        NAME
ffffffff        Generic DT based system
ffffffff        BCM2835

Please check your kernel config and/or bootloader.

I guess the loader falls back to atags when there is a problem with the overlay, but this is not good on ARCH_BCM2835. Better drop the overlay(s) and use the DT as-is.
This is probably what you experienced when you tested earlier.

@pelwell
Copy link
Contributor

pelwell commented Jun 4, 2015

@popcornmix already has a firmware patch from me to make the loader much more resilient when faced with errors like that.

@pelwell
Copy link
Contributor

pelwell commented Jun 8, 2015

The latest firmware (released yesterday) includes the patch.

neuschaefer pushed a commit to neuschaefer/raspi-binary-firmware that referenced this pull request Feb 27, 2017
See: raspberrypi/linux#985

firmware: MMAL queue: extra protection on the sanity check
firmware: MMAL: reset buffer recommended values on switching back to raw pixels
firmware: OV5647: Remove readback of I2C writes
firmware: MMAL: Add rawcam component and required framework changes
firmware: Add MMAL to IL mapping for rawcam parameters
firmware: Image_encode: Add support or YUYV input source
firmware: OV5647 tuning: Add the fixed ISO preview modes

firmware: Replacing board rev functions with board_info library

firmware: arm_loader: Add support for ARCH_BCM2835 builds
See: raspberrypi/linux#980 (comment)
pfpacket pushed a commit to pfpacket/linux-rpi-rust that referenced this pull request Apr 7, 2023
popcornmix pushed a commit that referenced this pull request Feb 6, 2024
commit a2ccf46 upstream.

rcutree_report_cpu_starting() must be called before cpu_probe() to avoid
the following lockdep splat that triggered by calling __alloc_pages() when
CONFIG_PROVE_RCU_LIST=y:

 =============================
 WARNING: suspicious RCU usage
 6.6.0+ #980 Not tainted
 -----------------------------
 kernel/locking/lockdep.c:3761 RCU-list traversed in non-reader section!!
 other info that might help us debug this:
 RCU used illegally from offline CPU!
 rcu_scheduler_active = 1, debug_locks = 1
 1 lock held by swapper/1/0:
  #0: 900000000c82ef98 (&pcp->lock){+.+.}-{2:2}, at: get_page_from_freelist+0x894/0x1790
 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.6.0+ #980
 Stack : 0000000000000001 9000000004f79508 9000000004893670 9000000100310000
         90000001003137d0 0000000000000000 90000001003137d8 9000000004f79508
         0000000000000000 0000000000000001 0000000000000000 90000000048a3384
         203a656d616e2065 ca43677b3687e616 90000001002c3480 0000000000000008
         000000000000009d 0000000000000000 0000000000000001 80000000ffffe0b8
         000000000000000d 0000000000000033 0000000007ec0000 13bbf50562dad831
         9000000005140748 0000000000000000 9000000004f79508 0000000000000004
         0000000000000000 9000000005140748 90000001002bad40 0000000000000000
         90000001002ba400 0000000000000000 9000000003573ec8 0000000000000000
         00000000000000b0 0000000000000004 0000000000000000 0000000000070000
         ...
 Call Trace:
 [<9000000003573ec8>] show_stack+0x38/0x150
 [<9000000004893670>] dump_stack_lvl+0x74/0xa8
 [<900000000360d2bc>] lockdep_rcu_suspicious+0x14c/0x190
 [<900000000361235c>] __lock_acquire+0xd0c/0x2740
 [<90000000036146f4>] lock_acquire+0x104/0x2c0
 [<90000000048a955c>] _raw_spin_lock_irqsave+0x5c/0x90
 [<900000000381cd5c>] rmqueue_bulk+0x6c/0x950
 [<900000000381fc0c>] get_page_from_freelist+0xd4c/0x1790
 [<9000000003821c6c>] __alloc_pages+0x1bc/0x3e0
 [<9000000003583b40>] tlb_init+0x150/0x2a0
 [<90000000035742a0>] per_cpu_trap_init+0xf0/0x110
 [<90000000035712fc>] cpu_probe+0x3dc/0x7a0
 [<900000000357ed20>] start_secondary+0x40/0xb0
 [<9000000004897138>] smpboot_entry+0x54/0x58

raw_smp_processor_id() is required in order to avoid calling into lockdep
before RCU has declared the CPU to be watched for readers.

See also commit 29368e0 ("x86/smpboot: Move rcu_cpu_starting() earlier"),
commit de5d9da ("s390/smp: move rcu_cpu_starting() earlier") and commit
99f070b ("powerpc/smp: Call rcu_cpu_starting() earlier").

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
popcornmix pushed a commit that referenced this pull request Feb 8, 2024
commit a2ccf46 upstream.

rcutree_report_cpu_starting() must be called before cpu_probe() to avoid
the following lockdep splat that triggered by calling __alloc_pages() when
CONFIG_PROVE_RCU_LIST=y:

 =============================
 WARNING: suspicious RCU usage
 6.6.0+ #980 Not tainted
 -----------------------------
 kernel/locking/lockdep.c:3761 RCU-list traversed in non-reader section!!
 other info that might help us debug this:
 RCU used illegally from offline CPU!
 rcu_scheduler_active = 1, debug_locks = 1
 1 lock held by swapper/1/0:
  #0: 900000000c82ef98 (&pcp->lock){+.+.}-{2:2}, at: get_page_from_freelist+0x894/0x1790
 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.6.0+ #980
 Stack : 0000000000000001 9000000004f79508 9000000004893670 9000000100310000
         90000001003137d0 0000000000000000 90000001003137d8 9000000004f79508
         0000000000000000 0000000000000001 0000000000000000 90000000048a3384
         203a656d616e2065 ca43677b3687e616 90000001002c3480 0000000000000008
         000000000000009d 0000000000000000 0000000000000001 80000000ffffe0b8
         000000000000000d 0000000000000033 0000000007ec0000 13bbf50562dad831
         9000000005140748 0000000000000000 9000000004f79508 0000000000000004
         0000000000000000 9000000005140748 90000001002bad40 0000000000000000
         90000001002ba400 0000000000000000 9000000003573ec8 0000000000000000
         00000000000000b0 0000000000000004 0000000000000000 0000000000070000
         ...
 Call Trace:
 [<9000000003573ec8>] show_stack+0x38/0x150
 [<9000000004893670>] dump_stack_lvl+0x74/0xa8
 [<900000000360d2bc>] lockdep_rcu_suspicious+0x14c/0x190
 [<900000000361235c>] __lock_acquire+0xd0c/0x2740
 [<90000000036146f4>] lock_acquire+0x104/0x2c0
 [<90000000048a955c>] _raw_spin_lock_irqsave+0x5c/0x90
 [<900000000381cd5c>] rmqueue_bulk+0x6c/0x950
 [<900000000381fc0c>] get_page_from_freelist+0xd4c/0x1790
 [<9000000003821c6c>] __alloc_pages+0x1bc/0x3e0
 [<9000000003583b40>] tlb_init+0x150/0x2a0
 [<90000000035742a0>] per_cpu_trap_init+0xf0/0x110
 [<90000000035712fc>] cpu_probe+0x3dc/0x7a0
 [<900000000357ed20>] start_secondary+0x40/0xb0
 [<9000000004897138>] smpboot_entry+0x54/0x58

raw_smp_processor_id() is required in order to avoid calling into lockdep
before RCU has declared the CPU to be watched for readers.

See also commit 29368e0 ("x86/smpboot: Move rcu_cpu_starting() earlier"),
commit de5d9da ("s390/smp: move rcu_cpu_starting() earlier") and commit
99f070b ("powerpc/smp: Call rcu_cpu_starting() earlier").

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants