[PATCH] UHCI: use integer-sized frame numbers
[pandora-kernel.git] / drivers / usb / host / uhci-hcd.h
index d5c8f4d..c87ceaa 100644 (file)
 #define CAN_SCHEDULE_FRAMES    1000    /* how far in the future frames
                                         * can be scheduled */
 
+/* When no queues need Full-Speed Bandwidth Reclamation,
+ * delay this long before turning FSBR off */
+#define FSBR_OFF_DELAY         msecs_to_jiffies(400)
+
+/* If a queue hasn't advanced after this much time, assume it is stuck */
+#define QH_WAIT_TIMEOUT                msecs_to_jiffies(200)
+
 
 /*
  *     Queue Headers
@@ -129,13 +136,17 @@ struct uhci_qh {
        struct list_head queue;         /* Queue of urbps for this QH */
        struct uhci_qh *skel;           /* Skeleton for this QH */
        struct uhci_td *dummy_td;       /* Dummy TD to end the queue */
+       struct uhci_td *post_td;        /* Last TD completed */
 
+       unsigned long advance_jiffies;  /* Time of last queue advance */
        unsigned int unlink_frame;      /* When the QH was unlinked */
        int state;                      /* QH_STATE_xxx; see above */
+       int type;                       /* Queue type (control, bulk, etc) */
 
        unsigned int initial_toggle:1;  /* Endpoint's current toggle value */
        unsigned int needs_fixup:1;     /* Must fix the TD toggle values */
-       unsigned int is_stopped:1;      /* Queue was stopped by an error */
+       unsigned int is_stopped:1;      /* Queue was stopped by error/unlink */
+       unsigned int wait_expired:1;    /* QH_WAIT_TIMEOUT has expired */
 } __attribute__((aligned(16)));
 
 /*
@@ -226,7 +237,6 @@ struct uhci_td {
        dma_addr_t dma_handle;
 
        struct list_head list;
-       struct list_head remove_list;
 
        int frame;                      /* for iso: what frame? */
        struct list_head fl_list;
@@ -396,8 +406,7 @@ struct uhci_hcd {
        __le32 *frame;
        void **frame_cpu;               /* CPU's frame list */
 
-       int fsbr;                       /* Full-speed bandwidth reclamation */
-       unsigned long fsbrtimeout;      /* FSBR delay */
+       unsigned long fsbr_jiffies;     /* Time when FSBR was last wanted */
 
        enum uhci_rh_state rh_state;
        unsigned long auto_stop_time;           /* When to AUTO_STOP */
@@ -412,16 +421,13 @@ struct uhci_hcd {
        unsigned int working_RD:1;              /* Suspended root hub doesn't
                                                   need to be polled */
        unsigned int is_initialized:1;          /* Data structure is usable */
+       unsigned int fsbr_is_on:1;              /* FSBR is turned on */
 
        /* Support for port suspend/resume/reset */
        unsigned long port_c_suspend;           /* Bit-arrays of ports */
        unsigned long resuming_ports;
        unsigned long ports_timeout;            /* Time to stop signalling */
 
-       /* List of TDs that are done, but waiting to be freed (race) */
-       struct list_head td_remove_list;
-       unsigned int td_remove_age;             /* Age in frames */
-
        struct list_head idle_qh_list;          /* Where the idle QHs live */
 
        int rh_numports;                        /* Number of root-hub ports */
@@ -442,6 +448,9 @@ static inline struct usb_hcd *uhci_to_hcd(struct uhci_hcd *uhci)
 
 #define uhci_dev(u)    (uhci_to_hcd(u)->self.controller)
 
+/* Utility macro for comparing frame numbers */
+#define uhci_frame_before_eq(f1, f2)   (0 <= (int) ((f2) - (f1)))
+
 
 /*
  *     Private per-URB data
@@ -454,9 +463,7 @@ struct urb_priv {
        struct uhci_qh *qh;             /* QH for this URB */
        struct list_head td_list;
 
-       unsigned fsbr : 1;              /* URB turned on FSBR */
-       unsigned short_transfer : 1;    /* URB got a short transfer, no
-                                        * need to rescan */
+       unsigned fsbr:1;                /* URB wants FSBR */
 };