Deleted Added
full compact
usb_transfer.c (195121) usb_transfer.c (195960)
1/* $FreeBSD: head/sys/dev/usb/usb_transfer.c 195121 2009-06-27 21:23:30Z thompsa $ */
1/* $FreeBSD: head/sys/dev/usb/usb_transfer.c 195960 2009-07-30 00:14:34Z alfred $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 2838 unchanged lines hidden (view full) ---

2848 if (xfer1->error == USB_ERR_CANCELLED) {
2849 return (0);
2850 }
2851 break;
2852 }
2853 return (1); /* Clear Stall Finished */
2854}
2855
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 2838 unchanged lines hidden (view full) ---

2848 if (xfer1->error == USB_ERR_CANCELLED) {
2849 return (0);
2850 }
2851 break;
2852 }
2853 return (1); /* Clear Stall Finished */
2854}
2855
2856/*------------------------------------------------------------------------*
2857 * usbd_transfer_poll
2858 *
2859 * The following function gets called from the USB keyboard driver and
2860 * UMASS when the system has paniced.
2861 *
2862 * NOTE: It is currently not possible to resume normal operation on
2863 * the USB controller which has been polled, due to clearing of the
2864 * "up_dsleep" and "up_msleep" flags.
2865 *------------------------------------------------------------------------*/
2856void
2857usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
2858{
2866void
2867usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
2868{
2859 static uint8_t once = 0;
2860 /* polling is currently not supported */
2861 if (!once) {
2862 once = 1;
2863 printf("usbd_transfer_poll: USB polling is "
2864 "not supported!\n");
2869 struct usb_xfer *xfer;
2870 struct usb_xfer_root *xroot;
2871 struct usb_device *udev;
2872 struct usb_proc_msg *pm;
2873 uint16_t n;
2874 uint16_t drop_bus;
2875 uint16_t drop_xfer;
2876
2877 for (n = 0; n != max; n++) {
2878 /* Extra checks to avoid panic */
2879 xfer = ppxfer[n];
2880 if (xfer == NULL)
2881 continue; /* no USB transfer */
2882 xroot = xfer->xroot;
2883 if (xroot == NULL)
2884 continue; /* no USB root */
2885 udev = xroot->udev;
2886 if (udev == NULL)
2887 continue; /* no USB device */
2888 if (udev->bus == NULL)
2889 continue; /* no BUS structure */
2890 if (udev->bus->methods == NULL)
2891 continue; /* no BUS methods */
2892 if (udev->bus->methods->xfer_poll == NULL)
2893 continue; /* no poll method */
2894
2895 /* make sure that the BUS mutex is not locked */
2896 drop_bus = 0;
2897 while (mtx_owned(&xroot->udev->bus->bus_mtx)) {
2898 mtx_unlock(&xroot->udev->bus->bus_mtx);
2899 drop_bus++;
2900 }
2901
2902 /* make sure that the transfer mutex is not locked */
2903 drop_xfer = 0;
2904 while (mtx_owned(xroot->xfer_mtx)) {
2905 mtx_unlock(xroot->xfer_mtx);
2906 drop_xfer++;
2907 }
2908
2909 /* Make sure cv_signal() and cv_broadcast() is not called */
2910 udev->bus->control_xfer_proc.up_dsleep = 0;
2911 udev->bus->control_xfer_proc.up_msleep = 0;
2912 udev->bus->explore_proc.up_dsleep = 0;
2913 udev->bus->explore_proc.up_msleep = 0;
2914 udev->bus->giant_callback_proc.up_dsleep = 0;
2915 udev->bus->giant_callback_proc.up_msleep = 0;
2916 udev->bus->non_giant_callback_proc.up_dsleep = 0;
2917 udev->bus->non_giant_callback_proc.up_msleep = 0;
2918
2919 /* poll USB hardware */
2920 (udev->bus->methods->xfer_poll) (udev->bus);
2921
2922 USB_BUS_LOCK(xroot->bus);
2923
2924 /* check for clear stall */
2925 if (udev->default_xfer[1] != NULL) {
2926
2927 /* poll clear stall start */
2928 pm = &udev->cs_msg[0].hdr;
2929 (pm->pm_callback) (pm);
2930 /* poll clear stall done thread */
2931 pm = &udev->default_xfer[1]->
2932 xroot->done_m[0].hdr;
2933 (pm->pm_callback) (pm);
2934 }
2935
2936 /* poll done thread */
2937 pm = &xroot->done_m[0].hdr;
2938 (pm->pm_callback) (pm);
2939
2940 USB_BUS_UNLOCK(xroot->bus);
2941
2942 /* restore transfer mutex */
2943 while (drop_xfer--)
2944 mtx_lock(xroot->xfer_mtx);
2945
2946 /* restore BUS mutex */
2947 while (drop_bus--)
2948 mtx_lock(&xroot->udev->bus->bus_mtx);
2865 }
2866}
2867
2868static void
2869usbd_get_std_packet_size(struct usb_std_packet_size *ptr,
2870 uint8_t type, enum usb_dev_speed speed)
2871{
2872 static const uint16_t intr_range_max[USB_SPEED_MAX] = {

--- 142 unchanged lines hidden ---
2949 }
2950}
2951
2952static void
2953usbd_get_std_packet_size(struct usb_std_packet_size *ptr,
2954 uint8_t type, enum usb_dev_speed speed)
2955{
2956 static const uint16_t intr_range_max[USB_SPEED_MAX] = {

--- 142 unchanged lines hidden ---