Skip to content

Commit

Permalink
Merge pull request #671 from karis79/dwc_lockdep_fixes_rpi-3.16.y
Browse files Browse the repository at this point in the history
Dwc lockdep fixes rpi 3.16.y
  • Loading branch information
P33M committed Aug 22, 2014
2 parents 504990c + 51dd458 commit 0d99826
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
8 changes: 8 additions & 0 deletions drivers/usb/host/dwc_common_port/dwc_common_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,11 @@ dwc_timer_t *DWC_TIMER_ALLOC(char *name, dwc_timer_callback_t cb, void *data)
goto no_name;
}

#if (defined(DWC_LINUX) && defined(CONFIG_DEBUG_SPINLOCK))
DWC_SPINLOCK_ALLOC_LINUX_DEBUG(t->lock);
#else
t->lock = DWC_SPINLOCK_ALLOC();
#endif
if (!t->lock) {
DWC_ERROR("Cannot allocate memory for lock");
goto no_lock;
Expand Down Expand Up @@ -1083,7 +1087,11 @@ dwc_workq_t *DWC_WORKQ_ALLOC(char *name)

wq->pending = 0;

#if (defined(DWC_LINUX) && defined(CONFIG_DEBUG_SPINLOCK))
DWC_SPINLOCK_ALLOC_LINUX_DEBUG(wq->lock);
#else
wq->lock = DWC_SPINLOCK_ALLOC();
#endif
if (!wq->lock) {
goto no_lock;
}
Expand Down
16 changes: 15 additions & 1 deletion drivers/usb/host/dwc_common_port/dwc_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ extern "C" {
# ifdef CONFIG_DEBUG_MUTEXES
# include <linux/mutex.h>
# endif
# include <linux/spinlock.h>
# include <linux/errno.h>
# include <stdarg.h>
#endif
Expand Down Expand Up @@ -1039,9 +1040,22 @@ typedef unsigned long dwc_irqflags_t;
/** Returns an initialized lock variable. This function should allocate and
* initialize the OS-specific data structure used for locking. This data
* structure is to be used for the DWC_LOCK and DWC_UNLOCK functions and should
* be freed by the DWC_FREE_LOCK when it is no longer used. */
* be freed by the DWC_FREE_LOCK when it is no longer used.
*
* For Linux Spinlock Debugging make it macro because the debugging routines use
* the symbol name to determine recursive locking. Using a wrapper function
* makes it falsely think recursive locking occurs. */
#if defined(DWC_LINUX) && defined(CONFIG_DEBUG_SPINLOCK)
#define DWC_SPINLOCK_ALLOC_LINUX_DEBUG(lock) ({ \
lock = DWC_ALLOC(sizeof(spinlock_t)); \
if (lock) { \
spin_lock_init((spinlock_t *)lock); \
} \
})
#else
extern dwc_spinlock_t *DWC_SPINLOCK_ALLOC(void);
#define dwc_spinlock_alloc(_ctx_) DWC_SPINLOCK_ALLOC()
#endif

/** Frees an initialized lock variable. */
extern void DWC_SPINLOCK_FREE(dwc_spinlock_t *lock);
Expand Down
5 changes: 5 additions & 0 deletions drivers/usb/host/dwc_otg/dwc_otg_hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,13 @@ int dwc_otg_hcd_init(dwc_otg_hcd_t * hcd, dwc_otg_core_if_t * core_if)
int i;
dwc_hc_t *channel;

#if (defined(DWC_LINUX) && defined(CONFIG_DEBUG_SPINLOCK))
DWC_SPINLOCK_ALLOC_LINUX_DEBUG(hcd->lock);
DWC_SPINLOCK_ALLOC_LINUX_DEBUG(hcd->channel_lock);
#else
hcd->lock = DWC_SPINLOCK_ALLOC();
hcd->channel_lock = DWC_SPINLOCK_ALLOC();
#endif
DWC_DEBUGPL(DBG_HCDV, "init of HCD %p given core_if %p\n",
hcd, core_if);
if (!hcd->lock) {
Expand Down
5 changes: 3 additions & 2 deletions drivers/usb/host/dwc_otg/dwc_otg_hcd_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ extern bool microframe_schedule;
void dwc_otg_hcd_qh_free(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh)
{
dwc_otg_qtd_t *qtd, *qtd_tmp;
dwc_irqflags_t flags;

/* Free each QTD in the QTD list */
DWC_SPINLOCK(hcd->lock);
DWC_SPINLOCK_IRQSAVE(hcd->lock, &flags);
DWC_CIRCLEQ_FOREACH_SAFE(qtd, qtd_tmp, &qh->qtd_list, qtd_list_entry) {
DWC_CIRCLEQ_REMOVE(&qh->qtd_list, qtd, qtd_list_entry);
dwc_otg_hcd_qtd_free(qtd);
Expand All @@ -76,7 +77,7 @@ void dwc_otg_hcd_qh_free(dwc_otg_hcd_t * hcd, dwc_otg_qh_t * qh)
}

DWC_FREE(qh);
DWC_SPINUNLOCK(hcd->lock);
DWC_SPINUNLOCK_IRQRESTORE(hcd->lock, flags);
return;
}

Expand Down
4 changes: 4 additions & 0 deletions drivers/usb/host/dwc_otg/dwc_otg_pcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,11 @@ dwc_otg_pcd_t *dwc_otg_pcd_init(dwc_otg_core_if_t * core_if)
return NULL;
}

#if (defined(DWC_LINUX) && defined(CONFIG_DEBUG_SPINLOCK))
DWC_SPINLOCK_ALLOC_LINUX_DEBUG(pcd->lock);
#else
pcd->lock = DWC_SPINLOCK_ALLOC();
#endif
DWC_DEBUGPL(DBG_HCDV, "Init of PCD %p given core_if %p\n",
pcd, core_if);//GRAYG
if (!pcd->lock) {
Expand Down

0 comments on commit 0d99826

Please sign in to comment.