[PATCH 4/6] ARM: smp: set thread_info->cpu to hardware CPU number for boot thread
Russell King - ARM Linux
linux at arm.linux.org.uk
Mon Aug 8 16:02:56 EDT 2011
On Mon, Aug 08, 2011 at 07:14:59PM +0100, Will Deacon wrote:
> On Mon, Aug 08, 2011 at 06:33:38PM +0100, Stephen Boyd wrote:
> > On 08/08/2011 10:10 AM, Will Deacon wrote:
> > >
> > >
> > > +void __init smp_setup_processor_id(void)
> > > +{
> > > + u32 mpidr;
> > > +
> > > + /* Read the MPIDR to find the hardware ID of the current CPU. */
> > > + asm("1: mrc p15, 0, %0, c0, c0, 5\n"
> > > + " .pushsection \".alt.smp.init\", \"a\"\n"
> > > + " .long 1b\n"
> > > + " mov %0, #0\n"
> > > + " .popsection"
> > > + : "=r" (mpidr));
> >
> > Would it be a good idea to put this into asm/cputype.h? I suppose the
> > smp alternatives part would need to be written in C.
> >
> > mpidr = is_smp() ? read_cpuid_mpidr() : 0;
>
> Yes, that's much better. We used to have asm/smp_mpidr.h which did this, so I
> lifted the code from there but doing it in C is easier to read.
>
> > >
> > > +
> > > + current_thread_info()->cpu = mpidr & 0xff;
> > > + printk("Booting Linux on CPU %d\n", current_thread_info()->cpu);
> > > +}
> > > +
> >
> > Should there be a KERN_INFO there?
>
> Can be. I just followed suit with secondary_start_kernel, but smp.c doesn't
> seem to be consistent anyway so I'll add the specifier.
Actually, it's probably much better to keep logical CPU0 as the boot CPU.
The hotplug code makes the assumption that the lowest online CPU number
is the boot CPU.
So unless we want even more pain, I suggest we just ensure logical CPU0
is the boot CPU.
We're already fairly clean on our interactions between CPU numbering and
the hardware CPU numbering - there's only a limited number of places where
the two interact. Those are the GIC, IPI, secondary CPU bringup, and
hotplug code. I suggest that we preserve the independence, and introduce
a mapping between logical CPU numbering and hardware CPU numbering.
More information about the linux-arm-kernel
mailing list