diff mbox series

[v6,1/6] tree: Rework set-chosen-cpu and store /chosen ihandle and phandle

Message ID 20171024013153.28200-2-aik@ozlabs.ru
State Accepted
Headers show
Series fdt: Pass the resulting device tree to QEMU + related fixes | expand

Commit Message

Alexey Kardashevskiy Oct. 24, 2017, 1:31 a.m. UTC
This replaces current set-chosen-cpu with a cleaner and faster
implementation which does not clobber the current node and stores
the chosen CPU phandle/ihandle.

This adds a helper to get the chosen CPU unit address.

This moves chosen cpu words to root.fs as otherwise it is quite hard
to maintain dependencies.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
 board-qemu/slof/tree.fs |  6 ------
 slof/fs/root.fs         | 11 +++++++++++
 2 files changed, 11 insertions(+), 6 deletions(-)

Comments

Segher Boessenkool Oct. 25, 2017, 11:43 a.m. UTC | #1
On Tue, Oct 24, 2017 at 12:31:48PM +1100, Alexey Kardashevskiy wrote:
> This replaces current set-chosen-cpu with a cleaner and faster
> implementation which does not clobber the current node and stores
> the chosen CPU phandle/ihandle.
> 
> This adds a helper to get the chosen CPU unit address.
> 
> This moves chosen cpu words to root.fs as otherwise it is quite hard
> to maintain dependencies.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>

It's fine by me, it's clean enough.  How the boot cpu is found is
more worrying (there is no reason the first cpu in the tree will
be it); when that is dealt with some time in the future, this can
be revisited, too (it should be easier then :-) )


Segher


> ---
>  board-qemu/slof/tree.fs |  6 ------
>  slof/fs/root.fs         | 11 +++++++++++
>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/board-qemu/slof/tree.fs b/board-qemu/slof/tree.fs
> index cc35fa3..d95fde3 100644
> --- a/board-qemu/slof/tree.fs
> +++ b/board-qemu/slof/tree.fs
> @@ -155,12 +155,6 @@ populate-pci-busses
>  
>  6c0 cp
>  
> -\ Do not assume that cpu0 is available
> -: set-chosen-cpu
> -    " /cpus" find-device
> -    get-node child dup 0= ABORT" CPU not found"
> -    node>path open-dev encode-int s" cpu" set-chosen
> -;
>  set-chosen-cpu
>  
>  s" /memory@0" open-dev encode-int s" memory" set-chosen
> diff --git a/slof/fs/root.fs b/slof/fs/root.fs
> index 44d087a..3818790 100644
> --- a/slof/fs/root.fs
> +++ b/slof/fs/root.fs
> @@ -33,6 +33,17 @@ defer continue-client
>  : get-chosen ( name len -- [ prop len ] success )
>    chosen get-property 0= ;
>  
> +\ Do not assume that cpu0 is available
> +VARIABLE chosen-cpu-ihandle
> +: set-chosen-cpu ( -- )
> +    s" /cpus" find-node  dup 0= ABORT" /cpus not found"
> +    child                dup 0= ABORT" /cpus/cpu not found"
> +    0 0 rot open-node
> +    dup chosen-cpu-ihandle !  encode-int s" cpu" set-chosen
> +;
> +
> +: chosen-cpu-unit ( -- ret ) chosen-cpu-ihandle @ ihandle>phandle >unit ;
> +
>  \ Look for an exising root, create one if needed
>  " /" find-node dup 0= IF
>      drop
> -- 
> 2.11.0
Alexey Kardashevskiy Oct. 26, 2017, 12:05 a.m. UTC | #2
On 25/10/17 22:43, Segher Boessenkool wrote:
> On Tue, Oct 24, 2017 at 12:31:48PM +1100, Alexey Kardashevskiy wrote:
>> This replaces current set-chosen-cpu with a cleaner and faster
>> implementation which does not clobber the current node and stores
>> the chosen CPU phandle/ihandle.
>>
>> This adds a helper to get the chosen CPU unit address.
>>
>> This moves chosen cpu words to root.fs as otherwise it is quite hard
>> to maintain dependencies.
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> 
> Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
> 
> It's fine by me, it's clean enough.  How the boot cpu is found is
> more worrying (there is no reason the first cpu in the tree will
> be it); when that is dealt with some time in the future, this can
> be revisited, too (it should be easier then :-) )

okay, before pushing this out, I'll add
\ TODO: proper boot cpu selection
:)

Thanks for the reviews.


> 
> 
> Segher
> 
> 
>> ---
>>  board-qemu/slof/tree.fs |  6 ------
>>  slof/fs/root.fs         | 11 +++++++++++
>>  2 files changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/board-qemu/slof/tree.fs b/board-qemu/slof/tree.fs
>> index cc35fa3..d95fde3 100644
>> --- a/board-qemu/slof/tree.fs
>> +++ b/board-qemu/slof/tree.fs
>> @@ -155,12 +155,6 @@ populate-pci-busses
>>  
>>  6c0 cp
>>  
>> -\ Do not assume that cpu0 is available
>> -: set-chosen-cpu
>> -    " /cpus" find-device
>> -    get-node child dup 0= ABORT" CPU not found"
>> -    node>path open-dev encode-int s" cpu" set-chosen
>> -;
>>  set-chosen-cpu
>>  
>>  s" /memory@0" open-dev encode-int s" memory" set-chosen
>> diff --git a/slof/fs/root.fs b/slof/fs/root.fs
>> index 44d087a..3818790 100644
>> --- a/slof/fs/root.fs
>> +++ b/slof/fs/root.fs
>> @@ -33,6 +33,17 @@ defer continue-client
>>  : get-chosen ( name len -- [ prop len ] success )
>>    chosen get-property 0= ;
>>  
>> +\ Do not assume that cpu0 is available
>> +VARIABLE chosen-cpu-ihandle
>> +: set-chosen-cpu ( -- )
>> +    s" /cpus" find-node  dup 0= ABORT" /cpus not found"
>> +    child                dup 0= ABORT" /cpus/cpu not found"
>> +    0 0 rot open-node
>> +    dup chosen-cpu-ihandle !  encode-int s" cpu" set-chosen
>> +;
>> +
>> +: chosen-cpu-unit ( -- ret ) chosen-cpu-ihandle @ ihandle>phandle >unit ;
>> +
>>  \ Look for an exising root, create one if needed
>>  " /" find-node dup 0= IF
>>      drop
>> -- 
>> 2.11.0
Alexey Kardashevskiy Nov. 3, 2017, 4 a.m. UTC | #3
On 26/10/17 11:05, Alexey Kardashevskiy wrote:
> On 25/10/17 22:43, Segher Boessenkool wrote:
>> On Tue, Oct 24, 2017 at 12:31:48PM +1100, Alexey Kardashevskiy wrote:
>>> This replaces current set-chosen-cpu with a cleaner and faster
>>> implementation which does not clobber the current node and stores
>>> the chosen CPU phandle/ihandle.
>>>
>>> This adds a helper to get the chosen CPU unit address.
>>>
>>> This moves chosen cpu words to root.fs as otherwise it is quite hard
>>> to maintain dependencies.
>>>
>>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>>
>> Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
>>
>> It's fine by me, it's clean enough.  How the boot cpu is found is
>> more worrying (there is no reason the first cpu in the tree will
>> be it); when that is dealt with some time in the future, this can
>> be revisited, too (it should be easier then :-) )
> 
> okay, before pushing this out, I'll add
> \ TODO: proper boot cpu selection
> :)

And I forgot to add "todo" and pushed this one out without it :(

Anyway, could you please finish reviewing and "ab"/"rb" these? Thanks!


> 
> Thanks for the reviews.
> 
> 
>>
>>
>> Segher
>>
>>
>>> ---
>>>  board-qemu/slof/tree.fs |  6 ------
>>>  slof/fs/root.fs         | 11 +++++++++++
>>>  2 files changed, 11 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/board-qemu/slof/tree.fs b/board-qemu/slof/tree.fs
>>> index cc35fa3..d95fde3 100644
>>> --- a/board-qemu/slof/tree.fs
>>> +++ b/board-qemu/slof/tree.fs
>>> @@ -155,12 +155,6 @@ populate-pci-busses
>>>  
>>>  6c0 cp
>>>  
>>> -\ Do not assume that cpu0 is available
>>> -: set-chosen-cpu
>>> -    " /cpus" find-device
>>> -    get-node child dup 0= ABORT" CPU not found"
>>> -    node>path open-dev encode-int s" cpu" set-chosen
>>> -;
>>>  set-chosen-cpu
>>>  
>>>  s" /memory@0" open-dev encode-int s" memory" set-chosen
>>> diff --git a/slof/fs/root.fs b/slof/fs/root.fs
>>> index 44d087a..3818790 100644
>>> --- a/slof/fs/root.fs
>>> +++ b/slof/fs/root.fs
>>> @@ -33,6 +33,17 @@ defer continue-client
>>>  : get-chosen ( name len -- [ prop len ] success )
>>>    chosen get-property 0= ;
>>>  
>>> +\ Do not assume that cpu0 is available
>>> +VARIABLE chosen-cpu-ihandle
>>> +: set-chosen-cpu ( -- )
>>> +    s" /cpus" find-node  dup 0= ABORT" /cpus not found"
>>> +    child                dup 0= ABORT" /cpus/cpu not found"
>>> +    0 0 rot open-node
>>> +    dup chosen-cpu-ihandle !  encode-int s" cpu" set-chosen
>>> +;
>>> +
>>> +: chosen-cpu-unit ( -- ret ) chosen-cpu-ihandle @ ihandle>phandle >unit ;
>>> +
>>>  \ Look for an exising root, create one if needed
>>>  " /" find-node dup 0= IF
>>>      drop
>>> -- 
>>> 2.11.0
> 
>
diff mbox series

Patch

diff --git a/board-qemu/slof/tree.fs b/board-qemu/slof/tree.fs
index cc35fa3..d95fde3 100644
--- a/board-qemu/slof/tree.fs
+++ b/board-qemu/slof/tree.fs
@@ -155,12 +155,6 @@  populate-pci-busses
 
 6c0 cp
 
-\ Do not assume that cpu0 is available
-: set-chosen-cpu
-    " /cpus" find-device
-    get-node child dup 0= ABORT" CPU not found"
-    node>path open-dev encode-int s" cpu" set-chosen
-;
 set-chosen-cpu
 
 s" /memory@0" open-dev encode-int s" memory" set-chosen
diff --git a/slof/fs/root.fs b/slof/fs/root.fs
index 44d087a..3818790 100644
--- a/slof/fs/root.fs
+++ b/slof/fs/root.fs
@@ -33,6 +33,17 @@  defer continue-client
 : get-chosen ( name len -- [ prop len ] success )
   chosen get-property 0= ;
 
+\ Do not assume that cpu0 is available
+VARIABLE chosen-cpu-ihandle
+: set-chosen-cpu ( -- )
+    s" /cpus" find-node  dup 0= ABORT" /cpus not found"
+    child                dup 0= ABORT" /cpus/cpu not found"
+    0 0 rot open-node
+    dup chosen-cpu-ihandle !  encode-int s" cpu" set-chosen
+;
+
+: chosen-cpu-unit ( -- ret ) chosen-cpu-ihandle @ ihandle>phandle >unit ;
+
 \ Look for an exising root, create one if needed
 " /" find-node dup 0= IF
     drop