Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Totally redo the way device detach is done. It ...
details: https://anonhg.NetBSD.org/src/rev/f315e8eec3e3
branches: trunk
changeset: 474163:f315e8eec3e3
user: augustss <augustss%NetBSD.org@localhost>
date: Wed Jun 30 06:44:22 1999 +0000
description:
Totally redo the way device detach is done. It now uses a kernel event
thread and the config detach method.
Squish a number of space leaks on detach.
diffstat:
sys/dev/usb/files.usb | 19 +---
sys/dev/usb/ohci.c | 36 +++++-
sys/dev/usb/ucom.c | 17 +---
sys/dev/usb/ugen.c | 214 ++++++++++++++++++++++++++++++++--------------
sys/dev/usb/uhci.c | 38 ++++----
sys/dev/usb/uhid.c | 211 +++++++++++++++++++++++++++++++---------------
sys/dev/usb/uhub.c | 162 +++++++++++++++++++++--------------
sys/dev/usb/ukbd.c | 84 +++++++----------
sys/dev/usb/ulpt.c | 94 ++++++++++++++++----
sys/dev/usb/umodem.c | 21 +----
sys/dev/usb/ums.c | 68 +++++++-------
sys/dev/usb/usb.c | 115 ++++++++++++++++++-------
sys/dev/usb/usb.h | 3 +-
sys/dev/usb/usb_port.h | 11 +-
sys/dev/usb/usb_subr.c | 61 +++++++++++-
sys/dev/usb/usbdi.c | 19 +--
sys/dev/usb/usbdi.h | 3 +-
sys/dev/usb/usbdi_util.c | 21 ++++-
sys/dev/usb/usbdi_util.h | 6 +-
sys/dev/usb/usbdivar.h | 9 +-
20 files changed, 768 insertions(+), 444 deletions(-)
diffs (truncated from 2573 to 300 lines):
diff -r 3be6adc28389 -r f315e8eec3e3 sys/dev/usb/files.usb
--- a/sys/dev/usb/files.usb Wed Jun 30 06:23:28 1999 +0000
+++ b/sys/dev/usb/files.usb Wed Jun 30 06:44:22 1999 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.usb,v 1.7 1999/05/16 13:51:05 augustss Exp $
+# $NetBSD: files.usb,v 1.8 1999/06/30 06:44:22 augustss Exp $
#
# Config file and device description for machine-independent USB code.
# Included by ports that need it. Ports that use it must provide
@@ -29,11 +29,6 @@
attach uaudio at uhub
file dev/usb/uaudio.c uaudio
-# Com ports
-#device ucom
-#attach ucom at uhub
-#file dev/usb/ucom.c ucom needs-flag
-
# Generic devices
device ugen
attach ugen at uhub
@@ -61,9 +56,9 @@
#file dev/usb/umass.c umass needs-flag
# Modems
-device umodem
-attach umodem at uhub
-file dev/usb/umodem.c umodem needs-flag
+#device umodem
+#attach umodem at uhub
+#file dev/usb/umodem.c umodem needs-flag
# Mice
device ums: wsmousedev
@@ -71,9 +66,3 @@
file dev/usb/ums.c ums needs-flag
-#
-# Inside Out Networks, Edgeport/4, 4 serial ports
-#device uep
-#attach uep at uhub
-#file dev/usb/uep.c uep
-
diff -r 3be6adc28389 -r f315e8eec3e3 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c Wed Jun 30 06:23:28 1999 +0000
+++ b/sys/dev/usb/ohci.c Wed Jun 30 06:44:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.32 1999/06/09 22:57:16 augustss Exp $ */
+/* $NetBSD: ohci.c,v 1.33 1999/06/30 06:44:23 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -95,6 +95,7 @@
ohci_soft_td_t *ohci_alloc_std __P((ohci_softc_t *));
void ohci_free_std __P((ohci_softc_t *, ohci_soft_td_t *));
+void ohci_power __P((int, void *));
usbd_status ohci_open __P((usbd_pipe_handle));
void ohci_poll __P((struct usbd_bus *));
void ohci_waitintr __P((ohci_softc_t *, usbd_request_handle));
@@ -250,13 +251,13 @@
if (!sc->sc_freeeds) {
DPRINTFN(2, ("ohci_alloc_sed: allocating chunk\n"));
sed = malloc(sizeof(ohci_soft_ed_t) * OHCI_ED_CHUNK,
- M_USBDEV, M_NOWAIT);
+ M_USBHC, M_NOWAIT);
if (!sed)
return 0;
r = usb_allocmem(sc->sc_dmatag, OHCI_ED_SIZE * OHCI_ED_CHUNK,
OHCI_ED_ALIGN, &dma);
if (r != USBD_NORMAL_COMPLETION) {
- free(sed, M_USBDEV);
+ free(sed, M_USBHC);
return 0;
}
for(i = 0; i < OHCI_ED_CHUNK; i++, sed++) {
@@ -296,13 +297,13 @@
if (!sc->sc_freetds) {
DPRINTFN(2, ("ohci_alloc_std: allocating chunk\n"));
std = malloc(sizeof(ohci_soft_td_t) * OHCI_TD_CHUNK,
- M_USBDEV, M_NOWAIT);
+ M_USBHC, M_NOWAIT);
if (!std)
return 0;
r = usb_allocmem(sc->sc_dmatag, OHCI_TD_SIZE * OHCI_TD_CHUNK,
OHCI_TD_ALIGN, &dma);
if (r != USBD_NORMAL_COMPLETION) {
- free(std, M_USBDEV);
+ free(std, M_USBHC);
return 0;
}
for(i = 0; i < OHCI_TD_CHUNK; i++, std++) {
@@ -504,6 +505,8 @@
sc->sc_bus.pipe_size = sizeof(struct ohci_pipe);
sc->sc_bus.do_poll = ohci_poll;
+ (void)powerhook_establish(ohci_power, sc);
+
return (USBD_NORMAL_COMPLETION);
bad3:
@@ -515,6 +518,20 @@
return (r);
}
+void
+ohci_power(why, v)
+ int why;
+ void *v;
+{
+#ifdef USB_DEBUG
+ ohci_softc_t *sc = v;
+
+ printf("ohci_power: sc=%p, why=%d\n", sc, why);
+ /* XXX should suspend/resume */
+ ohci_dumpregs(sc);
+#endif
+}
+
#ifdef USB_DEBUG
void ohcidump(void);
void ohcidump(void) { ohci_dumpregs(thesc); }
@@ -609,6 +626,7 @@
intrs &= ~OHCI_WDH;
}
if (eintrs & OHCI_RD) {
+ printf("%s: resume detect\n", USBDEVNAME(sc->sc_bus.bdev));
/* XXX process resume detect */
}
if (eintrs & OHCI_UE) {
@@ -825,7 +843,7 @@
dma = &opipe->u.intr.datadma;
memcpy(reqh->buffer, KERNADDR(dma), reqh->actlen);
- if (reqh->pipe->intrreqh == reqh) {
+ if (reqh->pipe->repeat) {
xfer = opipe->tail;
tail = ohci_alloc_std(sc); /* XXX should reuse TD */
if (!tail) {
@@ -914,7 +932,7 @@
reqh->status = USBD_NORMAL_COMPLETION;
reqh->xfercb(reqh);
- if (reqh->pipe->intrreqh != reqh) {
+ if (!reqh->pipe->repeat) {
sc->sc_intrreqh = 0;
usb_freemem(sc->sc_dmatag, &opipe->u.intr.datadma);
usb_start_next(reqh->pipe);
@@ -2124,9 +2142,9 @@
{
/* XXX inactivate */
usb_delay_ms(reqh->pipe->device->bus, 1); /* make sure it is done */
- if (reqh->pipe->intrreqh == reqh) {
+ if (reqh->pipe->repeat) {
DPRINTF(("ohci_device_intr_abort: remove\n"));
- reqh->pipe->intrreqh = 0;
+ reqh->pipe->repeat = 0;
ohci_intr_done((ohci_softc_t *)reqh->pipe->device->bus, reqh);
}
}
diff -r 3be6adc28389 -r f315e8eec3e3 sys/dev/usb/ucom.c
--- a/sys/dev/usb/ucom.c Wed Jun 30 06:23:28 1999 +0000
+++ b/sys/dev/usb/ucom.c Wed Jun 30 06:44:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ucom.c,v 1.7 1999/01/10 19:13:15 augustss Exp $ */
+/* $NetBSD: ucom.c,v 1.8 1999/06/30 06:44:23 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -120,21 +120,6 @@
}
#if defined(__FreeBSD__)
-static int
-ucom_detach(device_t self)
-{
- struct ucom_softc *sc = device_get_softc(self);
- char *devinfo = (char *) device_get_desc(self);
-
- if (devinfo) {
- device_set_desc(self, NULL);
- free(devinfo, M_USB);
- }
- return 0;
-}
-#endif
-
-#if defined(__FreeBSD__)
DRIVER_MODULE(ucom, usb, ucom_driver, ucom_devclass, usbd_driver_load, 0);
#endif
diff -r 3be6adc28389 -r f315e8eec3e3 sys/dev/usb/ugen.c
--- a/sys/dev/usb/ugen.c Wed Jun 30 06:23:28 1999 +0000
+++ b/sys/dev/usb/ugen.c Wed Jun 30 06:44:22 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ugen.c,v 1.11 1999/01/08 11:58:25 augustss Exp $ */
+/* $NetBSD: ugen.c,v 1.12 1999/06/30 06:44:23 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -53,6 +53,7 @@
#include <sys/fcntl.h>
#include <sys/filio.h>
#endif
+#include <sys/conf.h>
#include <sys/tty.h>
#include <sys/file.h>
#include <sys/select.h>
@@ -99,27 +100,32 @@
#define OUT 0 /* index order is important, from UE_OUT */
#define IN 1 /* from UE_IN */
- int sc_disconnected; /* device is gone */
+ int sc_refcnt;
+ u_char sc_dying;
};
int ugenopen __P((dev_t, int, int, struct proc *));
-int ugenclose __P((dev_t, int, int, struct proc *p));
-int ugenread __P((dev_t, struct uio *uio, int));
-int ugenwrite __P((dev_t, struct uio *uio, int));
+int ugenclose __P((dev_t, int, int, struct proc *));
+int ugenread __P((dev_t, struct uio *, int));
+int ugenwrite __P((dev_t, struct uio *, int));
int ugenioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
int ugenpoll __P((dev_t, int, struct proc *));
void ugenintr __P((usbd_request_handle reqh, usbd_private_handle addr,
usbd_status status));
-void ugen_disco __P((void *));
+int ugen_do_read __P((struct ugen_softc *, int, struct uio *, int));
+int ugen_do_write __P((struct ugen_softc *, int, struct uio *, int));
+int ugen_do_ioctl __P((struct ugen_softc *, int, u_long,
+ caddr_t, int, struct proc *));
int ugen_set_config __P((struct ugen_softc *sc, int configno));
usb_config_descriptor_t *ugen_get_cdesc __P((struct ugen_softc *sc, int index,
int *lenp));
usbd_status ugen_set_interface __P((struct ugen_softc *, int, int));
int ugen_get_alt_index __P((struct ugen_softc *sc, int ifaceidx));
-#define UGENUNIT(n) (((n) >> 4) & 0xf)
-#define UGENENDPOINT(n) ((n) & 0xf)
+#define UGENUNIT(n) ((minor(n) >> 4) & 0xf)
+#define UGENENDPOINT(n) (minor(n) & 0xf)
+#define UGENDEV(u, e) (makedev(0, ((u) << 4) | (e)))
USB_DECLARE_DRIVER(ugen);
@@ -150,7 +156,7 @@
if (r != USBD_NORMAL_COMPLETION) {
printf("%s: setting configuration %d failed\n",
USBDEVNAME(sc->sc_dev), conf);
- sc->sc_disconnected = 1;
+ sc->sc_dying = 1;
USB_ATTACH_ERROR_RETURN;
}
USB_ATTACH_SUCCESS_RETURN;
@@ -207,14 +213,6 @@
return (USBD_NORMAL_COMPLETION);
}
-void
-ugen_disco(p)
- void *p;
-{
- struct ugen_softc *sc = p;
- sc->sc_disconnected = 1;
-}
-
int
ugenopen(dev, flag, mode, p)
dev_t dev;
@@ -233,8 +231,8 @@
DPRINTFN(5, ("ugenopen: flag=%d, mode=%d, unit=%d endpt=%d\n",
flag, mode, unit, endpt));
- if (sc->sc_disconnected)
- return (EIO);
+ if (sc->sc_dying)
+ return (ENXIO);
if (endpt == USB_CONTROL_ENDPOINT) {
/*if ((flag & (FWRITE|FREAD)) != (FWRITE|FREAD))
@@ -266,7 +264,7 @@
isize = UGETW(edesc->wMaxPacketSize);
if (isize == 0) /* shouldn't happen */
return (EINVAL);
- sce->ibuf = malloc(isize, M_USB, M_WAITOK);
+ sce->ibuf = malloc(isize, M_USBDEV, M_WAITOK);
DPRINTFN(5, ("ugenopen: intr endpt=%d,isize=%d\n",
endpt, isize));
#if defined(__NetBSD__)
@@ -280,7 +278,7 @@
USBD_SHORT_XFER_OK, &sce->pipeh, sce,
sce->ibuf, isize, ugenintr);
if (r != USBD_NORMAL_COMPLETION) {
- free(sce->ibuf, M_USB);
+ free(sce->ibuf, M_USBDEV);
#if defined(__NetBSD__)
Home |
Main Index |
Thread Index |
Old Index