aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-01-16 11:57:13 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-02-07 18:44:37 -0500
commit896fbd7199035958013d106329843d8ae9618753 (patch)
tree24187ddb0820b472c48fb442bdbc30bde79ea9bd /drivers/usb
parent3ca2a3211ee5078d49b04fe7149ff2a76473be51 (diff)
usbcore: remove unused bandwith-related code
This patch (as841) removes from usbcore a couple of support routines meant to help with bandwidth allocation. With the changes to uhci-hcd in the previous patch, these routines are no longer used anywhere. Also removed is the CONFIG_USB_BANDWIDTH option; it no longer does anything and is no longer needed since the HCDs now handle bandwidth issues correctly. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/Kconfig13
-rw-r--r--drivers/usb/core/hcd.c137
-rw-r--r--drivers/usb/core/hcd.h6
-rw-r--r--drivers/usb/core/urb.c1
4 files changed, 0 insertions, 157 deletions
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 3e66b2a9974a..2fc0f88a3d86 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -33,19 +33,6 @@ config USB_DEVICEFS
33 33
34 Most users want to say Y here. 34 Most users want to say Y here.
35 35
36config USB_BANDWIDTH
37 bool "Enforce USB bandwidth allocation (EXPERIMENTAL)"
38 depends on USB && EXPERIMENTAL
39 help
40 If you say Y here, the USB subsystem enforces USB bandwidth
41 allocation and will prevent some device opens from succeeding
42 if they would cause USB bandwidth usage to go above 90% of
43 the bus bandwidth.
44
45 If you say N here, these conditions will cause warning messages
46 about USB bandwidth usage to be logged and some devices or
47 drivers may not work correctly.
48
49config USB_DYNAMIC_MINORS 36config USB_DYNAMIC_MINORS
50 bool "Dynamic USB minor allocation (EXPERIMENTAL)" 37 bool "Dynamic USB minor allocation (EXPERIMENTAL)"
51 depends on USB && EXPERIMENTAL 38 depends on USB && EXPERIMENTAL
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 10064af65d17..b26c19e8d19f 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -45,8 +45,6 @@
45#include "hub.h" 45#include "hub.h"
46 46
47 47
48// #define USB_BANDWIDTH_MESSAGES
49
50/*-------------------------------------------------------------------------*/ 48/*-------------------------------------------------------------------------*/
51 49
52/* 50/*
@@ -891,136 +889,6 @@ long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount)
891} 889}
892EXPORT_SYMBOL (usb_calc_bus_time); 890EXPORT_SYMBOL (usb_calc_bus_time);
893 891
894/*
895 * usb_check_bandwidth():
896 *
897 * old_alloc is from host_controller->bandwidth_allocated in microseconds;
898 * bustime is from calc_bus_time(), but converted to microseconds.
899 *
900 * returns <bustime in us> if successful,
901 * or -ENOSPC if bandwidth request fails.
902 *
903 * FIXME:
904 * This initial implementation does not use Endpoint.bInterval
905 * in managing bandwidth allocation.
906 * It probably needs to be expanded to use Endpoint.bInterval.
907 * This can be done as a later enhancement (correction).
908 *
909 * This will also probably require some kind of
910 * frame allocation tracking...meaning, for example,
911 * that if multiple drivers request interrupts every 10 USB frames,
912 * they don't all have to be allocated at
913 * frame numbers N, N+10, N+20, etc. Some of them could be at
914 * N+11, N+21, N+31, etc., and others at
915 * N+12, N+22, N+32, etc.
916 *
917 * Similarly for isochronous transfers...
918 *
919 * Individual HCDs can schedule more directly ... this logic
920 * is not correct for high speed transfers.
921 */
922int usb_check_bandwidth (struct usb_device *dev, struct urb *urb)
923{
924 unsigned int pipe = urb->pipe;
925 long bustime;
926 int is_in = usb_pipein (pipe);
927 int is_iso = usb_pipeisoc (pipe);
928 int old_alloc = dev->bus->bandwidth_allocated;
929 int new_alloc;
930
931
932 bustime = NS_TO_US (usb_calc_bus_time (dev->speed, is_in, is_iso,
933 usb_maxpacket (dev, pipe, !is_in)));
934 if (is_iso)
935 bustime /= urb->number_of_packets;
936
937 new_alloc = old_alloc + (int) bustime;
938 if (new_alloc > FRAME_TIME_MAX_USECS_ALLOC) {
939#ifdef DEBUG
940 char *mode =
941#ifdef CONFIG_USB_BANDWIDTH
942 "";
943#else
944 "would have ";
945#endif
946 dev_dbg (&dev->dev, "usb_check_bandwidth %sFAILED: %d + %ld = %d usec\n",
947 mode, old_alloc, bustime, new_alloc);
948#endif
949#ifdef CONFIG_USB_BANDWIDTH
950 bustime = -ENOSPC; /* report error */
951#endif
952 }
953
954 return bustime;
955}
956EXPORT_SYMBOL (usb_check_bandwidth);
957
958
959/**
960 * usb_claim_bandwidth - records bandwidth for a periodic transfer
961 * @dev: source/target of request
962 * @urb: request (urb->dev == dev)
963 * @bustime: bandwidth consumed, in (average) microseconds per frame
964 * @isoc: true iff the request is isochronous
965 *
966 * Bus bandwidth reservations are recorded purely for diagnostic purposes.
967 * HCDs are expected not to overcommit periodic bandwidth, and to record such
968 * reservations whenever endpoints are added to the periodic schedule.
969 *
970 * FIXME averaging per-frame is suboptimal. Better to sum over the HCD's
971 * entire periodic schedule ... 32 frames for OHCI, 1024 for UHCI, settable
972 * for EHCI (256/512/1024 frames, default 1024) and have the bus expose how
973 * large its periodic schedule is.
974 */
975void usb_claim_bandwidth (struct usb_device *dev, struct urb *urb, int bustime, int isoc)
976{
977 dev->bus->bandwidth_allocated += bustime;
978 if (isoc)
979 dev->bus->bandwidth_isoc_reqs++;
980 else
981 dev->bus->bandwidth_int_reqs++;
982 urb->bandwidth = bustime;
983
984#ifdef USB_BANDWIDTH_MESSAGES
985 dev_dbg (&dev->dev, "bandwidth alloc increased by %d (%s) to %d for %d requesters\n",
986 bustime,
987 isoc ? "ISOC" : "INTR",
988 dev->bus->bandwidth_allocated,
989 dev->bus->bandwidth_int_reqs + dev->bus->bandwidth_isoc_reqs);
990#endif
991}
992EXPORT_SYMBOL (usb_claim_bandwidth);
993
994
995/**
996 * usb_release_bandwidth - reverses effect of usb_claim_bandwidth()
997 * @dev: source/target of request
998 * @urb: request (urb->dev == dev)
999 * @isoc: true iff the request is isochronous
1000 *
1001 * This records that previously allocated bandwidth has been released.
1002 * Bandwidth is released when endpoints are removed from the host controller's
1003 * periodic schedule.
1004 */
1005void usb_release_bandwidth (struct usb_device *dev, struct urb *urb, int isoc)
1006{
1007 dev->bus->bandwidth_allocated -= urb->bandwidth;
1008 if (isoc)
1009 dev->bus->bandwidth_isoc_reqs--;
1010 else
1011 dev->bus->bandwidth_int_reqs--;
1012
1013#ifdef USB_BANDWIDTH_MESSAGES
1014 dev_dbg (&dev->dev, "bandwidth alloc reduced by %d (%s) to %d for %d requesters\n",
1015 urb->bandwidth,
1016 isoc ? "ISOC" : "INTR",
1017 dev->bus->bandwidth_allocated,
1018 dev->bus->bandwidth_int_reqs + dev->bus->bandwidth_isoc_reqs);
1019#endif
1020 urb->bandwidth = 0;
1021}
1022EXPORT_SYMBOL (usb_release_bandwidth);
1023
1024 892
1025/*-------------------------------------------------------------------------*/ 893/*-------------------------------------------------------------------------*/
1026 894
@@ -1034,11 +902,6 @@ static void urb_unlink (struct urb *urb)
1034{ 902{
1035 unsigned long flags; 903 unsigned long flags;
1036 904
1037 /* Release any periodic transfer bandwidth */
1038 if (urb->bandwidth)
1039 usb_release_bandwidth (urb->dev, urb,
1040 usb_pipeisoc (urb->pipe));
1041
1042 /* clear all state linking urb to this dev (and hcd) */ 905 /* clear all state linking urb to this dev (and hcd) */
1043 906
1044 spin_lock_irqsave (&hcd_data_lock, flags); 907 spin_lock_irqsave (&hcd_data_lock, flags);
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 8f8df0d4382e..2a269ca20517 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -308,10 +308,6 @@ extern void usb_destroy_configuration(struct usb_device *dev);
308#define NS_TO_US(ns) ((ns + 500L) / 1000L) 308#define NS_TO_US(ns) ((ns + 500L) / 1000L)
309 /* convert & round nanoseconds to microseconds */ 309 /* convert & round nanoseconds to microseconds */
310 310
311extern void usb_claim_bandwidth (struct usb_device *dev, struct urb *urb,
312 int bustime, int isoc);
313extern void usb_release_bandwidth (struct usb_device *dev, struct urb *urb,
314 int isoc);
315 311
316/* 312/*
317 * Full/low speed bandwidth allocation constants/support. 313 * Full/low speed bandwidth allocation constants/support.
@@ -324,8 +320,6 @@ extern void usb_release_bandwidth (struct usb_device *dev, struct urb *urb,
324#define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L) 320#define FRAME_TIME_MAX_BITS_ALLOC (90L * FRAME_TIME_BITS / 100L)
325#define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L) 321#define FRAME_TIME_MAX_USECS_ALLOC (90L * FRAME_TIME_USECS / 100L)
326 322
327extern int usb_check_bandwidth (struct usb_device *dev, struct urb *urb);
328
329/* 323/*
330 * Ceiling [nano/micro]seconds (typical) for that many bytes at high speed 324 * Ceiling [nano/micro]seconds (typical) for that many bytes at high speed
331 * ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed 325 * ISO is a bit less, no ACK ... from USB 2.0 spec, 5.11.3 (and needed
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 9801d08edacf..a4fa3e66c307 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -235,7 +235,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
235 235
236 urb->status = -EINPROGRESS; 236 urb->status = -EINPROGRESS;
237 urb->actual_length = 0; 237 urb->actual_length = 0;
238 urb->bandwidth = 0;
239 238
240 /* Lots of sanity checks, so HCDs can rely on clean data 239 /* Lots of sanity checks, so HCDs can rely on clean data
241 * and don't need to duplicate tests 240 * and don't need to duplicate tests