brcm2708: update 3.10 patches with raspberrypi/rpi-3.10.y of 27 Apr. 2014
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0030-Avoid-dynamic-memory-allocation-for-channel-lock-in-.patch
1 From f97cc1b1a4c868500cee6b016f54d78bdd3cdc26 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Sat, 8 Sep 2012 15:17:53 +0100
4 Subject: [PATCH 030/196] Avoid dynamic memory allocation for channel lock in
5 USB driver. Thanks ddv2005.
6
7 ---
8 drivers/usb/host/dwc_otg/dwc_otg_hcd.c | 6 +++---
9 drivers/usb/host/dwc_otg/dwc_otg_hcd.h | 2 +-
10 drivers/usb/host/dwc_otg/dwc_otg_hcd_ddma.c | 3 +--
11 drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c | 3 +--
12 4 files changed, 6 insertions(+), 8 deletions(-)
13
14 diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c
15 index 20f989e..0ce7e46 100644
16 --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd.c
17 +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.c
18 @@ -822,6 +822,7 @@ static void dwc_otg_hcd_free(dwc_otg_hcd_t * dwc_otg_hcd)
19 } else if (dwc_otg_hcd->status_buf != NULL) {
20 DWC_FREE(dwc_otg_hcd->status_buf);
21 }
22 + DWC_SPINLOCK_FREE(dwc_otg_hcd->channel_lock);
23 DWC_SPINLOCK_FREE(dwc_otg_hcd->lock);
24 /* Set core_if's lock pointer to NULL */
25 dwc_otg_hcd->core_if->lock = NULL;
26 @@ -848,6 +849,7 @@ int dwc_otg_hcd_init(dwc_otg_hcd_t * hcd, dwc_otg_core_if_t * core_if)
27 dwc_hc_t *channel;
28
29 hcd->lock = DWC_SPINLOCK_ALLOC();
30 + hcd->channel_lock = DWC_SPINLOCK_ALLOC();
31 DWC_DEBUGPL(DBG_HCDV, "init of HCD %p given core_if %p\n",
32 hcd, core_if);
33 if (!hcd->lock) {
34 @@ -1248,7 +1250,7 @@ dwc_otg_transaction_type_e dwc_otg_hcd_select_transactions(dwc_otg_hcd_t * hcd)
35 dwc_otg_qh_t *qh;
36 int num_channels;
37 dwc_irqflags_t flags;
38 - dwc_spinlock_t *channel_lock = DWC_SPINLOCK_ALLOC();
39 + dwc_spinlock_t *channel_lock = hcd->channel_lock;
40 dwc_otg_transaction_type_e ret_val = DWC_OTG_TRANSACTION_NONE;
41
42 #ifdef DEBUG_SOF
43 @@ -1348,8 +1350,6 @@ dwc_otg_transaction_type_e dwc_otg_hcd_select_transactions(dwc_otg_hcd_t * hcd)
44 #ifdef DEBUG_HOST_CHANNELS
45 last_sel_trans_num_avail_hc_at_end = hcd->available_host_channels;
46 #endif /* DEBUG_HOST_CHANNELS */
47 -
48 - DWC_SPINLOCK_FREE(channel_lock);
49 return ret_val;
50 }
51
52 diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd.h b/drivers/usb/host/dwc_otg/dwc_otg_hcd.h
53 index dd30f47..6d82127 100644
54 --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd.h
55 +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd.h
56 @@ -548,7 +548,7 @@ struct dwc_otg_hcd {
57
58 /* */
59 dwc_spinlock_t *lock;
60 -
61 + dwc_spinlock_t *channel_lock;
62 /**
63 * Private data that could be used by OS wrapper.
64 */
65 diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd_ddma.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd_ddma.c
66 index d0d5fa1..a2ceb77 100644
67 --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_ddma.c
68 +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_ddma.c
69 @@ -276,7 +276,7 @@ void dump_frame_list(dwc_otg_hcd_t * hcd)
70 static void release_channel_ddma(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh)
71 {
72 dwc_irqflags_t flags;
73 - dwc_spinlock_t *channel_lock = DWC_SPINLOCK_ALLOC();
74 + dwc_spinlock_t *channel_lock = hcd->channel_lock;
75
76 dwc_hc_t *hc = qh->channel;
77 if (dwc_qh_is_non_per(qh)) {
78 @@ -306,7 +306,6 @@ static void release_channel_ddma(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh)
79 dwc_memset(qh->desc_list, 0x00,
80 sizeof(dwc_otg_host_dma_desc_t) * max_desc_num(qh));
81 }
82 - DWC_SPINLOCK_FREE(channel_lock);
83 }
84
85 /**
86 diff --git a/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c
87 index f1658fa..21e8f09 100644
88 --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c
89 +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c
90 @@ -922,7 +922,7 @@ static void release_channel(dwc_otg_hcd_t * hcd,
91 dwc_otg_transaction_type_e tr_type;
92 int free_qtd;
93 dwc_irqflags_t flags;
94 - dwc_spinlock_t *channel_lock = DWC_SPINLOCK_ALLOC();
95 + dwc_spinlock_t *channel_lock = hcd->channel_lock;
96
97 DWC_DEBUGPL(DBG_HCDV, " %s: channel %d, halt_status %d, xfer_len %d\n",
98 __func__, hc->hc_num, halt_status, hc->xfer_len);
99 @@ -1009,7 +1009,6 @@ cleanup:
100 if (tr_type != DWC_OTG_TRANSACTION_NONE) {
101 dwc_otg_hcd_queue_transactions(hcd, tr_type);
102 }
103 - DWC_SPINLOCK_FREE(channel_lock);
104 }
105
106 /**
107 --
108 1.9.1
109