linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Scott Wood <scottwood@freescale.com>
Cc: linuxppc-dev@ozlabs.org, jgarzik@pobox.com, netdev@vger.kernel.org
Subject: Re: [PATCH v2] gianfar: Add I/O barriers when touching buffer descriptor ownership.
Date: Thu, 3 May 2007 18:38:34 +0200	[thread overview]
Message-ID: <4561c9f5d97ee3ed3d2ec661068cdd08@kernel.crashing.org> (raw)
In-Reply-To: <463A0732.2060802@freescale.com>

>> So what about some thing like this where we do the read only once?
>>
>> - k
>>
>> diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
>> index a06d8d1..9cd7d1e 100644
>> --- a/drivers/net/gianfar.c
>> +++ b/drivers/net/gianfar.c
>> @@ -1438,31 +1438,35 @@ int gfar_clean_rx_ring(struct net_device 
>> *dev, int rx_work_limit)
>>  {
>>  	struct rxbd8 *bdp;
>>  	struct sk_buff *skb;
>> -	u16 pkt_len;
>> +	u16 pkt_len, status;
>> +	u32 bd_info;
>
>
> I suggested that on IRC yesterday, and Segher was concerned that the
> compiler might, in theory, "optimize" it into to two lhz instructions.

Yes.  The same is true of the original code btw, but since
you test only one bit there, all is fine.

> I'm rather skeptical that it would actually do so (even if it needs to
> load twice due to register pressure, why not just use lwz both times?),

Sure.  That doesn't make this code correct though.

> and there's probably many other places that would break if it did,

Most other network drivers read from an MMIO reg to see
which RX ring entries are kernel owned AFAICS.

> but I wasn't up for digging around GCC to prove otherwise.

It doesn't matter what current GCC does -- simply look
at what it is *allowed* to do instead.

If you want a 32-bit read to be atomic, you should
do the read via a (volatile u32 *).  Doing this with
a cast in the places where you need the atomic access
makes sure you don't get unnecessary rereads.

> Plus, that wouldn't synchronize the bd_info read with the buffer data 
> reads.

Yes, you still need the rmb().


Segher

  reply	other threads:[~2007-05-03 16:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-02 19:57 [PATCH v2] gianfar: Add I/O barriers when touching buffer descriptor ownership Scott Wood
2007-05-02 20:09 ` Kumar Gala
2007-05-02 20:12   ` Scott Wood
2007-05-02 20:20     ` Kumar Gala
2007-05-02 20:40       ` Scott Wood
2007-05-02 21:23         ` Kumar Gala
2007-05-02 21:30           ` Scott Wood
2007-05-03  2:10             ` Kumar Gala
2007-05-03 16:00               ` Scott Wood
2007-05-03 16:38                 ` Segher Boessenkool [this message]
2007-05-02 23:42         ` Segher Boessenkool
2007-05-04 22:13         ` Linas Vepstas
2007-05-04 23:24           ` Olof Johansson
2007-05-05  0:41           ` Segher Boessenkool

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=4561c9f5d97ee3ed3d2ec661068cdd08@kernel.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=jgarzik@pobox.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=netdev@vger.kernel.org \
    --cc=scottwood@freescale.com \
    /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;
as well as URLs for NNTP newsgroup(s).