Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: usb and no bus_dma(9)
Hi! tsutsui-san,
From: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
Date: Sun, 13 Mar 2011 19:26:02 +0900
> > > > 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.
> > >
> > > Isn't it easy to provide a bus_dma implementation that does not realy
> > > do dma?
> > >
> > > That would be far preferable to crippling lots of other code with MD
> > > hacks,
> > > IMHO.
> >
> > I think that it is strange to implement bus_dma(9) for port that doesn't
> > use DMA.
>
> For compromise, how about:
> - use "#if NUHCI > 0 || NOHCI > 0 || NEHCI > 0" (or so) in *.c sources
> - prepare dummy typedefs in MD bus.h for structures in headers
> (I guess landisk one might help)
I remake this patch.
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 17 Mar 2011 07:58:43 -0000
@@ -43,6 +43,9 @@
#ifdef _KERNEL_OPT
#include "opt_usb.h"
#endif
+#include "ehci.h"
+#include "ohci.h"
+#include "uhci.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -149,6 +152,7 @@
p->tag = tag;
p->size = size;
p->align = align;
+#if (NEHCI + NOHCI + NUHCI) > 0
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 +173,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 +187,14 @@
#endif
return (USBD_NORMAL_COMPLETION);
+#if (NEHCI + NOHCI + NUHCI) > 0
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 +324,10 @@
void
usb_syncmem(usb_dma_t *p, bus_addr_t offset, bus_size_t len, int ops)
{
+#if (NEHCI + NOHCI + NUHCI) > 0
bus_dmamap_sync(p->block->tag, p->block->map, p->offs + offset,
len, ops);
+#endif
}
@@ -348,8 +363,10 @@
dma->block->size = size;
dma->block->nsegs = 1;
/* XXX segs appears to be unused */
+#if (NEHCI + NOHCI + NUHCI) > 0
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 +387,16 @@
usb_setup_reserve(device_t dv, struct usb_dma_reserve *rs, bus_dma_tag_t dtag,
size_t size)
{
+#if (NEHCI + NOHCI + NUHCI) > 0
int error, nseg;
bus_dma_segment_t seg;
+#endif
rs->dtag = dtag;
rs->size = size;
rs->dv = dv;
+#if (NEHCI + NOHCI + NUHCI) > 0
error = bus_dmamem_alloc(dtag, USB_MEM_RESERVE, PAGE_SIZE, 0,
&seg, 1, &nseg, BUS_DMA_NOWAIT);
if (error != 0)
@@ -398,6 +418,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 +434,7 @@
return 0;
+#if (NEHCI + NOHCI + NUHCI) > 0
destroy:
bus_dmamap_destroy(dtag, rs->map);
unmap:
@@ -418,5 +445,6 @@
rs->vaddr = 0;
return error;
+#endif
}
#endif
Index: mmeye/include/bus.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mmeye/include/bus.h,v
retrieving revision 1.1
diff -u -r1.1 bus.h
--- mmeye/include/bus.h 13 Sep 1999 10:30:54 -0000 1.1
+++ mmeye/include/bus.h 17 Mar 2011 08:15:02 -0000
@@ -1,3 +1,16 @@
/* $NetBSD: bus.h,v 1.1 1999/09/13 10:30:54 itojun Exp $ */
+#ifndef _MMEYE_BUS_H_
+#define _MMEYE_BUS_H_
+
#include <sh3/bus.h>
+
+/*
+ * Dummy bus_dma(9)
+ * XXXX: mmeye don't use bus_dma.
+ */
+typedef void * bus_dma_tag_t;
+typedef void * bus_dmamap_t;
+typedef void * bus_dma_segment_t;
+
+#endif /* _MMEYE_BUS_H_ */
Home |
Main Index |
Thread Index |
Old Index