Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
usb and no bus_dma(9)
Hi! all,
Our usb driver demands bus_dma(9) without fail. However, slhci(4)
doesn't use DMA. Moreover, some ports is not supporting bus_dma(9)
now. This becomes a big problem to use USB with some ports. For
instance, mmeye (Perhaps, amiga also :) can insert slhci@pcmcia to
the pcmcia slot. It is necessary to merge this diff for mmeye and
amiga user.
However, I can't name to this. For instance, #ifdef USB_NO_BUS_DMA
-#endif.
Do you have better name?
Thanks,
--
kiyohara
Index: usb_mem.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usb_mem.c,v
retrieving revision 1.45
diff -u -r1.45 usb_mem.c
--- usb_mem.c 4 Jan 2011 01:37:55 -0000 1.45
+++ usb_mem.c 13 Mar 2011 06:08:38 -0000
@@ -149,6 +149,7 @@
p->tag = tag;
p->size = size;
p->align = align;
+#ifndef mmeye
error = bus_dmamem_alloc(tag, p->size, align, 0,
p->segs, sizeof(p->segs)/sizeof(p->segs[0]),
&p->nsegs, BUS_DMA_NOWAIT);
@@ -169,6 +170,13 @@
BUS_DMA_NOWAIT);
if (error)
goto destroy;
+#else
+ p->kaddr = malloc(p->size, M_USB, M_NOWAIT);
+ if (p->kaddr == NULL) {
+ error = ENOMEM;
+ goto free0;
+ }
+#endif
*dmap = p;
#ifdef USB_FRAG_DMA_WORKAROUND
@@ -176,12 +184,14 @@
#endif
return (USBD_NORMAL_COMPLETION);
+#ifndef mmeye
destroy:
bus_dmamap_destroy(tag, p->map);
unmap:
bus_dmamem_unmap(tag, p->kaddr, p->size);
free1:
bus_dmamem_free(tag, p->segs, p->nsegs);
+#endif
free0:
free(p, M_USB);
return (USBD_NOMEM);
@@ -311,8 +321,10 @@
void
usb_syncmem(usb_dma_t *p, bus_addr_t offset, bus_size_t len, int ops)
{
+#ifndef mmeye
bus_dmamap_sync(p->block->tag, p->block->map, p->offs + offset,
len, ops);
+#endif
}
@@ -348,8 +360,10 @@
dma->block->size = size;
dma->block->nsegs = 1;
/* XXX segs appears to be unused */
+#ifndef mmeye
dma->block->segs[0] = rs->map->dm_segs[0];
dma->block->map = rs->map;
+#endif
dma->block->kaddr = rs->vaddr;
dma->block->tag = rs->dtag;
@@ -370,13 +384,16 @@
usb_setup_reserve(device_t dv, struct usb_dma_reserve *rs, bus_dma_tag_t dtag,
size_t size)
{
+#ifndef mmeye
int error, nseg;
bus_dma_segment_t seg;
+#endif
rs->dtag = dtag;
rs->size = size;
rs->dv = dv;
+#ifndef mmeye
error = bus_dmamem_alloc(dtag, USB_MEM_RESERVE, PAGE_SIZE, 0,
&seg, 1, &nseg, BUS_DMA_NOWAIT);
if (error != 0)
@@ -398,6 +415,12 @@
goto destroy;
rs->paddr = rs->map->dm_segs[0].ds_addr;
+#else
+ rs->vaddr = malloc(USB_MEM_RESERVE, M_USB, M_NOWAIT);
+ if (rs->vaddr == NULL) {
+ return ENOMEM;
+ }
+#endif
rs->extent = extent_create(device_xname(dv), (u_long)rs->paddr,
(u_long)(rs->paddr + USB_MEM_RESERVE - 1),
M_USB, 0, 0, 0);
@@ -408,6 +431,7 @@
return 0;
+#ifndef mmeye
destroy:
bus_dmamap_destroy(dtag, rs->map);
unmap:
@@ -418,5 +442,6 @@
rs->vaddr = 0;
return error;
+#endif
}
#endif
Index: usb_mem.h
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usb_mem.h,v
retrieving revision 1.27
diff -u -r1.27 usb_mem.h
--- usb_mem.h 28 Jun 2008 17:42:53 -0000 1.27
+++ usb_mem.h 13 Mar 2011 06:08:38 -0000
@@ -32,11 +32,16 @@
*/
#if defined(__NetBSD__) || defined(__OpenBSD__)
+#ifdef mmeye
+typedef void *bus_dma_tag_t;
+#endif
typedef struct usb_dma_block {
bus_dma_tag_t tag;
+#ifndef mmeye
bus_dmamap_t map;
- void *kaddr;
bus_dma_segment_t segs[1];
+#endif
+ void *kaddr;
int nsegs;
size_t size;
size_t align;
@@ -59,7 +64,9 @@
struct usb_dma_reserve {
bus_dma_tag_t dtag;
+#ifndef mmeye
bus_dmamap_t map;
+#endif
void *vaddr;
bus_addr_t paddr;
size_t size;
Index: usbdivar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usbdivar.h,v
retrieving revision 1.92
diff -u -r1.92 usbdivar.h
--- usbdivar.h 20 Dec 2010 18:49:12 -0000 1.92
+++ usbdivar.h 13 Mar 2011 06:08:43 -0000
@@ -120,7 +120,11 @@
#define USBREV_STR { "unknown", "pre 1.0", "1.0", "1.1", "2.0" }
void *soft; /* soft interrupt cookie */
+#ifdef mmeye
+ void * dmatag;
+#else
bus_dma_tag_t dmatag; /* DMA tag */
+#endif
};
struct usbd_device {
Home |
Main Index |
Thread Index |
Old Index