]> code.ossystems Code Review - openembedded-core.git/blob
438f11cf7ae9f2a8ef1547728ed5fce1968e82fe
[openembedded-core.git] /
1 From 9ebf351bcd28a89a0b1ba8d0496fffbc72421611 Mon Sep 17 00:00:00 2001
2 From: Sergei Shtylyov <sshtylyov-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
3 Date: Tue, 24 Mar 2009 17:22:50 -0700
4 Subject: [PATCH] USB: musb: rewrite host periodic endpoint allocation
5
6 The current MUSB host code doesn't make use of all the available
7 FIFOs in for periodic transfers since it wrongly assumes the RX
8 and TX sides of any given hw_ep always share one FIFO.
9
10 Change:  use 'in_qh' and 'out_qh' fields of the 'struct musb_hw_ep'
11 to check the endpoint's business; get rid of the now-unused 'periodic'
12 array in the 'struct musb'.  Also optimize a loop induction variable
13 in the endpoint lookup code.
14
15 (Based on a previous patch from Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>)
16
17 [ dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org: clarify description and origin
18   of this fix; whitespace ]
19
20 Signed-off-by: Sergei Shtylyov <sshtylyov-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
21 Signed-off-by: David Brownell <dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
22 Cc: Felipe Balbi <felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
23 Signed-off-by: Greg Kroah-Hartman <gregkh-l3A5Bk7waGM@public.gmane.org>
24 ---
25  drivers/usb/musb/musb_core.h |    1 -
26  drivers/usb/musb/musb_host.c |   28 +++++++++++-----------------
27  2 files changed, 11 insertions(+), 18 deletions(-)
28
29 diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
30 index 630946a..adf1806 100644
31 --- a/drivers/usb/musb/musb_core.h
32 +++ b/drivers/usb/musb/musb_core.h
33 @@ -331,7 +331,6 @@ struct musb {
34         struct list_head        control;        /* of musb_qh */
35         struct list_head        in_bulk;        /* of musb_qh */
36         struct list_head        out_bulk;       /* of musb_qh */
37 -       struct musb_qh          *periodic[32];  /* tree of interrupt+iso */
38  #endif
39  
40         /* called with IRQs blocked; ON/nonzero implies starting a session,
41 diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
42 index bd1d5ae..499c431 100644
43 --- a/drivers/usb/musb/musb_host.c
44 +++ b/drivers/usb/musb/musb_host.c
45 @@ -390,7 +390,6 @@ musb_giveback(struct musb_qh *qh, struct urb *urb, int status)
46                          * de-allocated if it's tracked and allocated;
47                          * and where we'd update the schedule tree...
48                          */
49 -                       musb->periodic[ep->epnum] = NULL;
50                         kfree(qh);
51                         qh = NULL;
52                         break;
53 @@ -1760,31 +1759,27 @@ static int musb_schedule(
54  
55         /* else, periodic transfers get muxed to other endpoints */
56  
57 -       /* FIXME this doesn't consider direction, so it can only
58 -        * work for one half of the endpoint hardware, and assumes
59 -        * the previous cases handled all non-shared endpoints...
60 -        */
61 -
62 -       /* we know this qh hasn't been scheduled, so all we need to do
63 +       /*
64 +        * We know this qh hasn't been scheduled, so all we need to do
65          * is choose which hardware endpoint to put it on ...
66          *
67          * REVISIT what we really want here is a regular schedule tree
68 -        * like e.g. OHCI uses, but for now musb->periodic is just an
69 -        * array of the _single_ logical endpoint associated with a
70 -        * given physical one (identity mapping logical->physical).
71 -        *
72 -        * that simplistic approach makes TT scheduling a lot simpler;
73 -        * there is none, and thus none of its complexity...
74 +        * like e.g. OHCI uses.
75          */
76         best_diff = 4096;
77         best_end = -1;
78  
79 -       for (epnum = 1; epnum < musb->nr_endpoints; epnum++) {
80 +       for (epnum = 1, hw_ep = musb->endpoints + 1;
81 +                       epnum < musb->nr_endpoints;
82 +                       epnum++, hw_ep++) {
83                 int     diff;
84  
85 -               if (musb->periodic[epnum])
86 +               if (is_in || hw_ep->is_shared_fifo) {
87 +                       if (hw_ep->in_qh  != NULL)
88 +                               continue;
89 +               } else  if (hw_ep->out_qh != NULL)
90                         continue;
91 -               hw_ep = &musb->endpoints[epnum];
92 +
93                 if (hw_ep == musb->bulk_ep)
94                         continue;
95  
96 @@ -1824,7 +1819,6 @@ static int musb_schedule(
97         idle = 1;
98         qh->mux = 0;
99         hw_ep = musb->endpoints + best_end;
100 -       musb->periodic[best_end] = qh;
101         DBG(4, "qh %p periodic slot %d\n", qh, best_end);
102  success:
103         if (head) {
104 -- 
105 1.6.0.4
106