diff options
Diffstat (limited to 'drivers/usb/core/hcd.c')
-rw-r--r-- | drivers/usb/core/hcd.c | 137 |
1 files changed, 0 insertions, 137 deletions
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 | } |
892 | EXPORT_SYMBOL (usb_calc_bus_time); | 890 | EXPORT_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 | */ | ||
922 | int 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 | } | ||
956 | EXPORT_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 | */ | ||
975 | void 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 | } | ||
992 | EXPORT_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 | */ | ||
1005 | void 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 | } | ||
1022 | EXPORT_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); |