public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 07/27] Introduce generic global_data
Date: Sat, 24 Mar 2012 22:14:20 +1100	[thread overview]
Message-ID: <4F6DAC8C.1000709@gmail.com> (raw)
In-Reply-To: <CAPnjgZ21Ss4_syeePsbYWn+KrNW-EOpYR1MFhUVKaaRO_BkyNw@mail.gmail.com>

Hi Simon,

On 03/24/2012 05:40 PM, Simon Glass wrote:
> Hi Graeme,
> 
> On Wed, Mar 14, 2012 at 8:41 PM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Graeme,
>>
>> On Wed, Mar 14, 2012 at 8:02 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
>>> Hi Simon,
>>>
>>> On Thu, Mar 15, 2012 at 1:50 PM, Simon Glass <sjg@chromium.org> wrote:
>>>> Hi Graeme,
>>>>
>>>> On Wed, Mar 14, 2012 at 7:35 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
>>>>> Hi Simon,
>>>>>
>>>
>>> [snip]
>>>
>>>>>
>>>>> IMHO, global data should contain only globally common members and an arch-
>>>>> specific struct and ditch (most of) the #ifdefs
>>>>
>>>> My thinking here was to try to bring everything into a single file. It
>>>> then should be clearer when things are common between different
>>>> architectures. Patches to the generic file can be made without also
>>>> having to patch the non-generic files, etc.
>>>>
>>>> A fair number of the #ifdefs are not needed, or are there because some
>>>> archs don't implement all the features of U-Boot.
>>>>
>>>> You have an example right there: cpu_clk_rate_hz is similar to cpu_clk
>>>> and core_clk.
>>>>
>>>> That said it is a bit of a daunting task to amalgamate them.
>>>>
>>>> Also there is the purely practical consideration that if we continue
>>>> to have an asm/global_data.h then we end up with two global datas. One
>>>> is for CONFIG_SYS_GENERIC_BOARD and contains just the non-common
>>>> fields. The other is for non-CONFIG_SYS_GENERIC_BOARD and contains all
>>>> fields. Ick.
>>>>
>>>> So what do you think?
>>>
>>> Do you really need to unify global data to achieve what the title of the
>>> patch series suggests (i.e. to unify the init processing loop)? Maybe you
>>> could leave global data as is (or slightly tweak the odd arch) and leave
>>> the resolution of just how bad global data is becoming for another day
>>
>> It's not that easy, because in board_f.c and board_r.c and other files
>> there are certain fields required. It doesn't make a huge amount of
>> sense to have generic code which accesses a different global structure
>> depending on what architecture it is built for. Then there are fields
>> are are only used when certain options are defined. Ick.
>>
>> If I am going to pull this off I need a bit of flexibility. I've
>> looked into this quite a bit and mapped a path through this which I
>> think will work. It requires doing things in stages, or it will never
>> happen.
>>
>>>
>>> I only say this because this is turning into "let's do a dirty hack now to
>>> partially fix it and leave the rest for later (it'll get done, really,
>>> honestly, I promise)" ;)
>>
>> It was always like that. Although I wouldn't characterise it as a
>> dirty hack. If there was a requirement to do all of this in one big
>> bang then I wouldn't have even started. It is just too hard :-(
>>
>>>
>>> There will always be arch specific global data members - I see a few
>>> options:
>>>
>>>  - Move them into bd
>>
>> I recall talk of getting rid of this (Mike?)
>>
>>>  - Move them into an arch_global_data struct inside gd
>>
>> This was Mike's idea. It is probably the easiest thing to do.
>>
>>>  - Move them into an arch_global_data struct totally seperate from gd
>>
>> I sort-of like this except it would slow down access and maybe
>> increase code size. Then again perhaps that's a good thing if it
>> provides an incentive to reduce the number of arch-specific fields.
>>
>>>  - Question how many are really required to be in gd (remember, gd is
>>>   only there to cart around writable global variable before .bss and
>>>   .data are available after relocation)
>>
>> Well yes, I feel there are far more at present than are needed. Having
>> them all there in the open feels like a nice way to draw attention to
>> the mess.
> 
> Any more comments on this thread? At this stage I am still not sure of
> the best approach for this header...none of the options is
> particularly attractive. I can imagine something horrible like:
> 
> struct global_data {
>    <common fields>
>    ...
> #include <asm/arch_global_data.h>
> };

Ick! - NAK NAK NAK NAK ;)

> 
> which would be the smallest code change (essentially no accesses would
> need to change). But it is too awful.
> 
> Of course I have a generic bd structure now, so moving things into
> there doesn't fix the problem.
> 
> So if I rewind back to your first suggestion (just leave global-data
> and bd as they are now), then I have the problem that I need to add
> quite a bit of stuff to these structures for every architecture. This
> is because at present most architectures don't support all the
> features, and so don't need all the fields. As soon as I have generic
> C code, I have references in that C code to global data members that
> only exist for some architectures. Then someone enables CONFIG_SPI,
> and breaks the board on the architecture that didn't previously have
> SPI support. I wonder if that matters?
> 
> It sort-off seems attractive from the 'less work' point of view, and
> is a stepping stone along the way, though.
> 
> Just to repeat your other ideas:
> 
>>  - Move them into bd
>>  - Move them into an arch_global_data struct inside gd
>>  - Move them into an arch_global_data struct totally seperate from gd
>>  - Question how many are really required to be in gd (remember, gd is
>>   only there to cart around writable global variable before .bss and
>>   .data are available after relocation)

IIRC the Linux driver model includes a pointer to non-generic driver
specific data which only the driver knows what to do with (the framework
ignores it)
If struct global_data has struct arch_global_data *agd in gd - Means a lot
of changing of accessors and maybe a little code increase and slight access
penalty (and maybe changes to asm startup code to handle the creation of gd
plus agd and setting the pointer)

But that would be way cleaner for stuct global_data

Having agd in gd is probably a lot easier as the auto-generated gd size
will be good to use

Hmmm..

arch/asm/global_data.h:

#define HAS_ARCH_GD

struct arch_global_data {
	...
};

include/global_data.h:


#include <arch/asm/global_data.h>

struct global_data {
	...
#ifdef HAS_ARCH_GD
	struct arch_global_data agd;
#endif
};

I like this better

P.S. Can we ditch the typedef while we are at it?

Q: Are there any board specific global data members anywhere?

> 
> (I feel the last one has to come later, though, even if unfortunately
> it would simplify things now - how on earth are we going to work out
> what things are really needed in global data?)

Look at the functions which are called prior to relocation - Anything
referenced in these functions needs to be in gd

Regards,

Graeme

  reply	other threads:[~2012-03-24 11:14 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15  2:15 [U-Boot] [PATCH v4 0/27] Create generic board init for ARM, x86, PPC Simon Glass
2012-03-15  2:15 ` [U-Boot] [PATCH v4 01/27] arm: Change board baud_rate to ulong Simon Glass
2012-03-15  2:15 ` [U-Boot] [PATCH v4 02/27] x86: " Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 03/27] arm: Only display frame buffer info if there is LCD/video support Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 04/27] x86: Remove dead code in eNET Simon Glass
2012-03-15  2:27   ` Graeme Russ
2012-03-15  2:28     ` Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 05/27] x86: Add initial memory barrier macros Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 06/27] ppc: " Simon Glass
2012-03-15 17:56   ` Scott Wood
2012-03-15  2:16 ` [U-Boot] [PATCH v4 07/27] Introduce generic global_data Simon Glass
2012-03-15  2:30   ` Graeme Russ
2012-03-15  2:35   ` Graeme Russ
2012-03-15  2:50     ` Simon Glass
2012-03-15  3:02       ` Graeme Russ
2012-03-15  3:41         ` Simon Glass
2012-03-24  6:40           ` Simon Glass
2012-03-24 11:14             ` Graeme Russ [this message]
2012-03-24 23:10               ` Simon Glass
2012-03-24 23:54                 ` Graeme Russ
2012-03-15  2:16 ` [U-Boot] [PATCH v4 08/27] Introduce generic u-boot.h file Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 09/27] Introduce generic link section.h symbol files Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 10/27] arm: Use sections header to obtain link symbols Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 11/27] x86: Change stub example to use asm-generic/sections.h Simon Glass
2012-03-15  2:29   ` Graeme Russ
2012-03-15  2:44     ` Simon Glass
2012-03-15  2:48       ` Graeme Russ
2012-03-15  2:16 ` [U-Boot] [PATCH v4 12/27] Introduce a basic initcall implementation Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 13/27] Define CONFIG_SYS_LEGACY_BOARD everywhere Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 14/27] Introduce generic pre-relocation board_f.c Simon Glass
2012-03-15 19:09   ` Scott Wood
2012-03-15 21:23     ` Simon Glass
2012-03-15 21:25       ` Scott Wood
2012-03-16  5:31       ` Wolfgang Denk
2012-03-15  2:16 ` [U-Boot] [PATCH v4 15/27] Introduce generic post-relocation board_r.c Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 16/27] Add spl load feature Simon Glass
2012-03-15 19:29   ` Scott Wood
2012-03-15  2:16 ` [U-Boot] [PATCH v4 17/27] arm: Enable generic board support Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 18/27] Add CONFIG_SYS_SYM_OFFSETS to support offset symbols Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 19/27] x86: Use sections header to obtain link symbols Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 20/27] Add x86 fields to generic global_data Simon Glass
2012-03-15  2:36   ` Graeme Russ
2012-03-15  2:54     ` Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 21/27] x86: Enable generic board support Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 22/27] Add ppc fields to generic global data Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 23/27] Adjust board_f for ppc Simon Glass
2012-03-15 19:12   ` Scott Wood
2012-03-15 21:25     ` Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 24/27] Adjust board_r.c for PowerPC Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 25/27] ppc: Enable generic board board Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 26/27] tegra: Mark board init files for ARMv4t Simon Glass
2012-03-15  2:16 ` [U-Boot] [PATCH v4 27/27] tegra: Enable generic board for Seaboard Simon Glass
2012-03-16 19:23 ` [U-Boot] [PATCH v4 0/27] Create generic board init for ARM, x86, PPC Tom Rini
2012-03-16 19:34   ` Simon Glass
2012-03-16 20:07     ` Tom Rini
2012-03-16 21:53       ` Tom Rini
2012-03-16 22:19         ` Simon Glass
2012-03-16 22:26           ` 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=4F6DAC8C.1000709@gmail.com \
    --to=graeme.russ@gmail.com \
    --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