Re: [PATCH 02/18] Blackfin Serial Driver: use barrier instead of cpu_relax for Blackfin SMP like patch

graff yang
2009-03-11T09:50:34Z

On Wed, Mar 11, 2009 at 12:48 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
>
> On Tue, 10 Mar 2009 06:25:08 -0400 Mike Frysinger <vapier.adi@gmail.com> wrote:
>
> > On Tue, Mar 10, 2009 at 06:07, gyang wrote:
> > > On Fri, 2009-03-06 at 14:37 -0800, Andrew Morton wrote:
> > >> On Fri,  6 Mar 2009 14:42:44 +0800
> > >> Bryan Wu <cooloney@kernel.org> wrote:
> > >>
> > >> > From: Graf Yang <graf.yang@analog.com>
> > >> >
> > >> > We are making a SMP like patch to blackfin, cpu_relax() is replaced by a
> > >> > data cache flush function which will count it to a per-cpu counter.
> > >> > If this serial function is called too early, the per-cpu data area have
> > >> > not been initialized, this call will cause crash.
> > >>
> > >> That's a bug in blackfin architecture support.  The kernel should be
> > >> able to call cpu_relax() at any time, surely.  It's a very low-level
> > >> and simple thing.
> > >>
> > >> > So we'd like to use barrier() instead of cpu_relax().
> > >> >
> > >>
> > >> barrier() is purely a compiler concept.  We might as well just remove
> > >> the cpu_relax() altogether.
> > >
> > > Do you mean remove cpu_relax(), and either not add barrier() here?
> >
> > afaik, early printk all runs before SMP is setup, so having it be a
> > 100% busy wait is fine
>
> No, blackfin is busted, please fix this bug in blackfin core.
>
> What happens if core kernel code decides to run cpu_relax() prior to
> initialising per-cpu data?

cpu_relax() will call smp_mb(), and it need to invalidate data-cache
in blackfin smp-like kernel,
the cache flush number is increased and recorded into a per-cpu data.

When cpu_relax() is called from early-printk functions, the per-cpu
data areas have not
been initialized.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
-Graff