Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Preallocate command and status buffers as auto a...
details: https://anonhg.NetBSD.org/src/rev/22e5ea1b7700
branches: trunk
changeset: 325398:22e5ea1b7700
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Dec 22 18:30:21 2013 +0000
description:
Preallocate command and status buffers as auto allocation cannot
happen in intrrupt context.
diffstat:
sys/dev/usb/umass.c | 59 +++++++++++++++++++++++++++++++++++--------------
sys/dev/usb/umassvar.h | 5 +++-
2 files changed, 46 insertions(+), 18 deletions(-)
diffs (115 lines):
diff -r 263f3ae5d16d -r 22e5ea1b7700 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c Sun Dec 22 18:29:25 2013 +0000
+++ b/sys/dev/usb/umass.c Sun Dec 22 18:30:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umass.c,v 1.147 2013/01/11 06:22:23 skrll Exp $ */
+/* $NetBSD: umass.c,v 1.148 2013/12/22 18:30:21 mlelstv Exp $ */
/*
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.147 2013/01/11 06:22:23 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.148 2013/12/22 18:30:21 mlelstv Exp $");
#ifdef _KERNEL_OPT
#include "opt_umass.h"
@@ -302,7 +302,7 @@
const char *sWire, *sCommand;
char *devinfop;
usbd_status err;
- int i, bno, error;
+ int i, error;
sc->sc_dev = self;
@@ -558,29 +558,54 @@
return;
}
}
- /* Allocate buffer for data transfer (it's huge). */
+ /* Allocate buffer for data transfer (it's huge), command and
+ status data here as auto allocation cannot happen in interrupt
+ context */
switch (sc->sc_wire) {
case UMASS_WPROTO_BBB:
- bno = XFER_BBB_DATA;
- goto dalloc;
+ sc->data_buffer = usbd_alloc_buffer(
+ sc->transfer_xfer[XFER_BBB_DATA],
+ UMASS_MAX_TRANSFER_SIZE);
+ sc->cmd_buffer = usbd_alloc_buffer(
+ sc->transfer_xfer[XFER_BBB_CBW],
+ UMASS_BBB_CBW_SIZE);
+ sc->s1_buffer = usbd_alloc_buffer(
+ sc->transfer_xfer[XFER_BBB_CSW1],
+ UMASS_BBB_CSW_SIZE);
+ sc->s2_buffer = usbd_alloc_buffer(
+ sc->transfer_xfer[XFER_BBB_CSW2],
+ UMASS_BBB_CSW_SIZE);
+ break;
case UMASS_WPROTO_CBI:
- bno = XFER_CBI_DATA;
- goto dalloc;
case UMASS_WPROTO_CBI_I:
- bno = XFER_CBI_DATA;
- dalloc:
- sc->data_buffer = usbd_alloc_buffer(sc->transfer_xfer[bno],
- UMASS_MAX_TRANSFER_SIZE);
- if (sc->data_buffer == NULL) {
- aprint_error_dev(self, "no buffer memory\n");
- umass_disco(sc);
- return;
- }
+ sc->data_buffer = usbd_alloc_buffer(
+ sc->transfer_xfer[XFER_CBI_DATA],
+ UMASS_MAX_TRANSFER_SIZE);
+ sc->cmd_buffer = usbd_alloc_buffer(
+ sc->transfer_xfer[XFER_CBI_CB],
+ sizeof(sc->cbl));
+ sc->s1_buffer = usbd_alloc_buffer(
+ sc->transfer_xfer[XFER_CBI_STATUS],
+ sizeof(sc->sbl));
+ sc->s2_buffer = usbd_alloc_buffer(
+ sc->transfer_xfer[XFER_CBI_RESET1],
+ sizeof(sc->cbl));
break;
default:
break;
}
+ if (sc->data_buffer == NULL || sc->cmd_buffer == NULL
+ || sc->s1_buffer == NULL || sc->s2_buffer == NULL) {
+ /*
+ * partially preallocated buffers are freed with
+ * the xfer structures
+ */
+ aprint_error_dev(self, "no buffer memory\n");
+ umass_disco(sc);
+ return;
+ }
+
/* Initialise the wire protocol specific methods */
switch (sc->sc_wire) {
case UMASS_WPROTO_BBB:
diff -r 263f3ae5d16d -r 22e5ea1b7700 sys/dev/usb/umassvar.h
--- a/sys/dev/usb/umassvar.h Sun Dec 22 18:29:25 2013 +0000
+++ b/sys/dev/usb/umassvar.h Sun Dec 22 18:30:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umassvar.h,v 1.34 2012/08/24 12:20:02 drochner Exp $ */
+/* $NetBSD: umassvar.h,v 1.35 2013/12/22 18:30:21 mlelstv Exp $ */
/*-
* Copyright (c) 1999 MAEKAWA Masahide <bishop%rr.iij4u.or.jp@localhost>,
@@ -226,6 +226,9 @@
usbd_xfer_handle transfer_xfer[XFER_NR]; /* for ctrl xfers */
void *data_buffer;
+ void *cmd_buffer;
+ void *s1_buffer;
+ void *s2_buffer;
int transfer_dir; /* data direction */
void *transfer_data; /* data buffer */
Home |
Main Index |
Thread Index |
Old Index