Subject: Re: CVS commit: src/sys/dev/ic
To: None <source-changes@NetBSD.org>
From: Christian Biere <christianbiere@gmx.de>
List: source-changes
Date: 10/29/2006 14:34:08
David Young wrote:
> On Fri, Oct 20, 2006 at 03:44:00PM +0000, Izumi Tsutsui wrote:
> > I can't think of a good way to avoid race condition between writeback and
> > DMA write against descriptors if cachelinesize > sizeof(struct rtk_desc)...
> 
> You must pad struct rtk_desc to the cacheline size to avoid cacheline
> interference.  I cannot emphasize enough how important that is!
> 
> bus_dma really ought to provide a #define for the machine's cacheline
> size.

Don't you need at least __attribute__((__packed__)) for struct rtk_desc too?
Maybe it's good enough for now but in general you have to expect padding
between struct members and at the end of the struct. So on a 64-bit arch,
the struct may as well look like this in memory:

 0: uint32_t rtk_cmdstat
 4: pad1
 8: uint32_t rtk_vlanctl
12: pad2
16: uint32_t rtk_bufaddr_lo
20: pad3
24: uint32_t rtk_bufaddr_hi
28: pad4

-- 
Christian