Subject: Re: [linux-usb-devel] [PATCH RFC] ZyDAS ZD1211 USB-WLAN driver

From: David Brownell <[email-masked]>
Date: Mon, 5 Jun 2006 22:41:02 -0700

On Saturday 03 June 2006 3:25 pm, Oliver Neukum wrote:
> Am Samstag, 3. Juni 2006 21:35 schrieb Daniel Drake:
> > Oliver Neukum wrote:
> > > +static int read_mac_addr(struct zd_chip *chip, u8 *mac_addr)
> > > +{
> > > +	static const zd_addr_t addr[2] = { CR_MAC_ADDR_P1, CR_MAC_ADDR_P2 };
> > > +	return _read_mac_addr(chip, mac_addr, (const zd_addr_t *)addr);
> > > +}
> > > 
> > > Why on the stack?
> > 
> > Technically it's not on the stack because it is static const (it goes in 
> > rodata), but I don't think that this invalidates your point. What's the 
> > alternative? kmalloc and kfree every time?
> 
> In this case rodata will work. However, if you ever switch to direct DMA
> it will fail. I really did overlook the const keyword.

On some platforms rodata will work; but it's not guaranteed on any.
See Documentation/DMA-mapping.txt and read the little section at the
top explaining what types of memory can be DMA'd from ... neither stack,
nor BSS, nor data, nor rodata, nor text are OK.

- Dave