On Thursday 14 October 2004 7:25 pm, Randy.Dunlap wrote:
> >>>>Could mark req.dma as __le32...
> >>
> >>I didn't like that suggestion (yet), other people can comment on it,
> >>though. For now I'm just adding a cast.
> >
> >
> > Changing that type for sparse sounds better to me, so it works
> > on a big-endian 64bit CPU as well as just fixing the warning.
> > Do you want me to make those changes?
>
> If you would, please. I just wasn't sure about the more global
> ramifications of that.
Attached ... see if it behaves for you.
> > One of these moments I really should install "sparse".
>
> Yes.
Finally did it ... :)
> > Looks OK, at least if you ignore the fact that it'll print out
> > byteswapped on big-endian ... I'm told the driver does
> > work OK on PPC32, though.
>
> So this is a net2280 dma addr, therefore it's always little-endian?
> ugh. So it can be something like
>
> (unsigned long long) le32_to_cpu(req->td_dma),
> ? argh. that doesn't make much sense.
> this is a "dma_32bit_t", right? darn.
> otherwise le32_to_cpu(on a 64-bit dma addr) is funky.
Yes, dma32_addr_t or something similarly non-existent! :)
Most places didn't use the pointer based conversion; those
allegedly save an instruction on some CPUs. Not using the
cpu_to_le32p() version was safer, it turns out.
- Dave
Fix some compiler warnings that came up with net2280 on processors with
64bit dma_addr-t ... one of them would have been a bug on big-endian CPUs.
(Thanks to Randy Dunlap for reporting these.)
Signed-off-by: David Brownell <[EMAIL PROTECTED]>
--- 1.64/drivers/usb/gadget/net2280.c 2004-09-22 21:25:26 -07:00
+++ edited/drivers/usb/gadget/net2280.c 2004-10-15 13:34:35 -07:00
@@ -717,7 +717,7 @@
dmacount |= (1 << DMA_DONE_INTERRUPT_ENABLE);
/* td->dmadesc = previously set by caller */
- td->dmaaddr = cpu_to_le32p (&req->req.dma);
+ td->dmaaddr = cpu_to_le32 (req->req.dma);
/* 2280 may be polling VALID_BIT through ep->dma->dmadesc */
wmb ();
@@ -1707,8 +1707,10 @@
td = req->td;
t = scnprintf (next, size, "\t td %08x "
" count %08x buf %08x desc %08x\n",
- req->td_dma, td->dmacount,
- td->dmaaddr, td->dmadesc);
+ (u32) req->td_dma,
+ le32_to_cpu (td->dmacount),
+ le32_to_cpu (td->dmaaddr),
+ le32_to_cpu (td->dmadesc));
if (t <= 0 || t > size)
goto done;
size -= t;
@@ -2845,6 +2847,7 @@
dev->got_irq = 1;
/* DMA setup */
+ /* NOTE: we know only the 32 LSBs of dma addresses may be nonzero */
dev->requests = pci_pool_create ("requests", pdev,
sizeof (struct net2280_dma),
0 /* no alignment requirements */,
--- 1.18/drivers/usb/gadget/net2280.h 2004-09-22 21:25:27 -07:00
+++ edited/drivers/usb/gadget/net2280.h 2004-10-15 13:26:59 -07:00
@@ -495,10 +495,10 @@
* use struct net2280_dma_regs bitfields
*/
struct net2280_dma {
- u32 dmacount;
- u32 dmaaddr; /* the buffer */
- u32 dmadesc; /* next dma descriptor */
- u32 _reserved;
+ __le32 dmacount;
+ __le32 dmaaddr; /* the buffer */
+ __le32 dmadesc; /* next dma descriptor */
+ __le32 _reserved;
} __attribute__ ((aligned (16)));
/*-------------------------------------------------------------------------*/