U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/3] ARM: bcm283x: Implement EFI RTS reset_system
Date: Wed, 9 Nov 2016 08:50:10 -0700	[thread overview]
Message-ID: <f66ebfeb-e7a6-add8-25aa-10d8772d5496@wwwdotorg.org> (raw)
In-Reply-To: <d2741f75-5f1e-2a11-1d8d-927a2d4b0990@suse.de>

On 11/09/2016 04:43 AM, Alexander Graf wrote:
>
>
> On 07/11/2016 22:26, Stephen Warren wrote:
>> On 11/06/2016 03:24 AM, Alexander Graf wrote:
>>>
>>>
>>> On 05/11/2016 23:01, Stephen Warren wrote:
>>>> On 11/02/2016 03:36 AM, Alexander Graf wrote:
>>>>> The rpi has a pretty simple way of resetting the whole system. All it
>>>>> takes
>>>>> is to poke a few registers at a well defined location in MMIO space.
>>>>>
>>>>> This patch adds support for the EFI loader implementation to allow an
>>>>> OS to
>>>>> reset and power off the system when we're outside of boot time.
>>>>
>>>> (As an aside, I'm not sure why someone wanting EFI wouldn't just use a
>>>> complete EFI implementation such as TianoCore.)
>>>>
>>>>> diff --git a/arch/arm/mach-bcm283x/reset.c
>>>>> b/arch/arm/mach-bcm283x/reset.c
>>>>
>>>>> +__efi_runtime_data struct bcm2835_wdog_regs *wdog_regs =
>>>>> +    (struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR;
>>>>> +
>>>>> +void __efi_runtime reset_cpu(ulong addr)
>>>>>  {
>>>>> -    struct bcm2835_wdog_regs *regs =
>>>>> -        (struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR;
>>>>
>>>> I'm not sure why that change is required. The value of the variable is
>>>> the same in both cases?
>>>
>>> Take a look a few lines down in the patch:
>>>
>>>> +void efi_reset_system_init(void)
>>>> +{
>>>> +    efi_add_runtime_mmio(&wdog_regs, sizeof(*wdog_regs));
>>>> +}
>>>
>>> What this does is register a *pointer* as run time service pointer. What
>>> does that mean?
>>>
>>> When we enter RTS, Linux can map any region in the EFI memory map into a
>>> different place in its own virtual memory map. So any pointers we use
>>> inside RTS have to be relocated to the new locations.
>>>
>>> For normal relocations, we move the relocations from linker time to run
>>> time, so that we can relocate ourselves when Linux does the switch-over
>>> to a new address space.
>>>
>>> However, for MMIO that's trickier. That's where the
>>> efi_add_runtime_mmio() function comes into play. It takes care of adding
>>> the page around the references address to the EFI memory map as RTS MMIO
>>> and relocates the pointer when Linux switches us into the new address
>>> space.
>>>
>>> Does that explain why we need to move from an inline address to an
>>> address stored in a memory location?
>>
>> So EFI RTS runs in the same exception level as the rich OS, and not in
>> EL3? I would have expected EFI to run in EL3 with a completely separate
>> MMU configuration. If that's not the case, then this part of the patch
>> does make sense.
>
> Right, it runs in EL2/EL1 with a virtual memory layout that is provided
> by the OS.
>
>>
>>>> Perhaps it's trying to ensure that if this gets compiled into an ldr
>>>> instruction, the referenced data value is in a linker section that's
>>>> still around when EFI runs? If so fine, but how is that ensured for all
>>>> the other constants that this code uses, and if that happens
>>>> automatically due to the __efi_runtime marker above, why doesn't it
>>>> work
>>>> for this one constant?
>>>>
>>>> Does U-Boot have a halt/poweroff/shutdown shell command? If so, it
>>>> might
>>>> be nice to enable it as part of this series, since the code to perform
>>>> that operation is now present.
>>>
>>> That's what I originally wanted, yes :). Unfortunately due to the
>>> relocation explained above, it's basically impossible for any reset
>>> function that calls into MMIO space.
>>>
>>> However, we do have it now for PSCI. If you have a PSCI enabled system,
>>> we don't need to call into MMIO space and thus make the common reset
>>> function available as RTS.
>>
>> Can't the same U-Boot function be called both (a) during U-Boot runtime,
>> where wdog_regs are pre-initialized to match U-Boot's MMU configuration,
>> and (b) once the OS has booted, where wdog_regs has been modified
>> according to the new memory map?
>
> That's exactly what this patch does, no?

I assume not, since you said just a few lines above that doing so was 
impossible, hence why it doesn't implement any halt/poweroff/shutdown 
shell commands.

  reply	other threads:[~2016-11-09 15:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02  9:36 [U-Boot] [PATCH v3 0/3] Raspberry Pi EFI enablement Alexander Graf
2016-11-02  9:36 ` [U-Boot] [PATCH v3 1/3] ARM: bcm283x: Implement EFI RTS reset_system Alexander Graf
2016-11-06  3:01   ` Stephen Warren
2016-11-06 10:24     ` Alexander Graf
2016-11-08  3:26       ` Stephen Warren
2016-11-09 11:43         ` Alexander Graf
2016-11-09 15:50           ` Stephen Warren [this message]
2016-11-09 18:09             ` Alexander Graf
2016-11-06 10:32     ` Alexander Graf
2016-11-29 17:38   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-11-02  9:36 ` [U-Boot] [PATCH v3 2/3] bcm2835 video: Map frame buffer as 32bpp Alexander Graf
2016-11-06  3:04   ` Stephen Warren
2016-11-29 17:39   ` [U-Boot] [U-Boot, v3, " Tom Rini
2016-11-02  9:36 ` [U-Boot] [PATCH v3 3/3] bcm2835: Reserve the spin table in efi memory map Alexander Graf
2016-11-06  3:07   ` Stephen Warren
2016-11-06 10:27     ` Alexander Graf
2016-11-29 18:01   ` [U-Boot] [U-Boot, v3, " Tom Rini

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=f66ebfeb-e7a6-add8-25aa-10d8772d5496@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox