Subject: Re: [PATCH net-next 1/4] via-rhine: commit receive buffer address before descriptor status update.

From: Alexander Duyck <[email-masked]>
Date: Tue, 07 Apr 2015 14:19:03 -0700

On 04/07/2015 02:02 PM, Francois Romieu wrote:
> David Miller <[email-masked]> :
>> From: Francois Romieu <[email-masked]>
> [...]
>>> @@ -2063,6 +2063,7 @@ static int rhine_rx(struct net_device *dev, int limit)
>>>   				break;
>>>   			}
>>>   			rp->rx_ring[entry].addr = cpu_to_le32(rp->rx_skbuff_dma[entry]);
>>> +			wmb();
>> dma_wmb() perhaps?  I think this is exactly the situation that interface was
>> added for.
> I need the buffer address to be written in the receive descriptor before
> the descriptor status is. The cpu does W1, W2 and the nic mustn't see W2, W1.

That is the point of the dma_wmb().  If you are writing both W1 and W2 
to system memory then dma_wmb should be enough, if W1 is system memory 
and W2 is device memory (MMIO) then you need wmb().

You can think of dma_wmb as being something similar to smp_wmb w/o the 
SMP processor requirement.  On architectures that are strong ordered 
such as most x86 the wmb() translates to a barrier.  On other 
architectures it is something usually a little lighter than a full wmb() 
so for example on PowerPC wmb is sync() while dma_wmb() is lwsync().

- Alex