Subject: Re: [POWERPC] convert string i/o operations to C

From: Benjamin Herrenschmidt <[email-masked]>
Date: Wed, 20 Sep 2006 09:12:12 +1000

On Tue, 2006-09-19 at 13:29 -0500, Linas Vepstas wrote:
> On Tue, Sep 19, 2006 at 10:23:51PM +1000, Stephen Rothwell wrote:
> 
> Perhaps this:
> 
> > +void _insb(volatile u8 __iomem *port, void *buf, int ns)
> > +{
> > +	asm volatile("sync");
> > +	if (ns <= 0)
> > +		return;
> > +	asm volatile(
> 
> should be this: 
> 
> > +void _insb(volatile u8 __iomem *port, void *buf, int ns)
> > +{
> > +	if (ns <= 0)
> > +		return;
> > +	asm volatile("sync");
> > +	asm volatile(

No. The barrier should be there even if somebody is lame enough to give
a count of 0.

> to assuage David Howell's concern.  Not that ns should be negative
> in the first place ... but what the hey.
> 
> Re Davids other comment: "ns" stands for "no  byte-swap", and 
> "s" stands for "string" so "insl_ns" is input string of longs, 
> no byte swap.

David's comment was about the "ns" argument which is the count (dunno
why "ns").

> Here's a question:
> 
> > +	asm volatile(
> > +		"mtctr	%2\n"
> > +		"subi	%1,%1,1\n"
> > +		"0:	lbz	%2,0(%0)\n"
> > +		"eieio\n"
> > +		"stbu	%2,1(%1)\n"
> > +		"bdnz	0b\n"
> > +		"twi	0,%2,0\n"
> 
> What does this twi do? According to my powerpc docs, this would be a
> no-op.  Does this have some magic synchronizing powers on certain
> implementations? If so, there should be at least a comment card added
> about why the twi is there. (This special ability of twi might be
> well-known to some, but still, this is not immediately obvious,
> and not immedately documented in e.g. the PEM.)
> 
> --linas
> 
> _______________________________________________
> Linuxppc-dev mailing list
> [email-masked]
> https://ozlabs.org/mailman/listinfo/linuxppc-dev