Subject: Re: [PATCH v2] gianfar: Add I/O barriers when touching buffer descriptor ownership.

From: Scott Wood <[email-masked]>
Date: Thu, 03 May 2007 11:00:50 -0500

Kumar Gala wrote:
> 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. 
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?), 
and there's probably many other places that would break if it did, but I 
wasn't up for digging around GCC to prove otherwise.

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

-Scott