From 488dc506d6ac8f800728fc6b9fa3b0a235cd4c73 Mon Sep 17 00:00:00 2001 From: yangkai Date: Sat, 5 May 2012 16:57:30 +0800 Subject: [PATCH] handle pcd multiprocess spin_lock --- drivers/usb/dwc_otg/dwc_otg_pcd.c | 16 ++++------------ drivers/usb/dwc_otg/dwc_otg_pcd_intr.c | 3 +++ drivers/usb/dwc_otg/linux/dwc_otg_plat.h | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd.c b/drivers/usb/dwc_otg/dwc_otg_pcd.c index e46b36934f6b..9c50fcb4826b 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd.c @@ -287,8 +287,7 @@ static int dwc_otg_pcd_ep_enable(struct usb_ep *_ep, return -ESHUTDOWN; } - local_irq_save(flags); -// SPIN_LOCK_IRQSAVE(&pcd->lock, flags); + SPIN_LOCK_IRQSAVE(&pcd->lock, flags); ep->desc = _desc; ep->ep.maxpacket = le16_to_cpu (_desc->wMaxPacketSize); @@ -355,8 +354,7 @@ static int dwc_otg_pcd_ep_enable(struct usb_ep *_ep, ep->dwc_ep.type, ep->dwc_ep.maxpacket, ep->desc ); dwc_otg_ep_activate( GET_CORE_IF(pcd), &ep->dwc_ep ); -// SPIN_UNLOCK_IRQRESTORE(&pcd->lock, flags); - local_irq_restore(flags); + SPIN_UNLOCK_IRQRESTORE(&pcd->lock, flags); return 0; } @@ -383,8 +381,7 @@ static int dwc_otg_pcd_ep_disable(struct usb_ep *_ep) return -EINVAL; } -// SPIN_LOCK_IRQSAVE(&ep->pcd->lock, flags); - local_irq_save(flags); + SPIN_LOCK_IRQSAVE(&ep->pcd->lock, flags); request_nuke( ep ); dwc_otg_ep_deactivate( GET_CORE_IF(ep->pcd), &ep->dwc_ep ); @@ -397,8 +394,7 @@ static int dwc_otg_pcd_ep_disable(struct usb_ep *_ep) release_tx_fifo(GET_CORE_IF(ep->pcd), ep->dwc_ep.tx_fifo_num); } -// SPIN_UNLOCK_IRQRESTORE(&ep->pcd->lock, flags); - local_irq_restore(flags); + SPIN_UNLOCK_IRQRESTORE(&ep->pcd->lock, flags); DWC_DEBUGPL(DBG_PCD, "%s disabled\n", _ep->name); return 0; @@ -1152,9 +1148,7 @@ static int32_t dwc_otg_pcd_suspend_cb( void *_p ,int suspend) //#endif if (pcd->driver && pcd->driver->resume) { - SPIN_UNLOCK(&pcd->lock); pcd->driver->suspend(&pcd->gadget); - SPIN_LOCK(&pcd->lock); } return 1; } @@ -1172,9 +1166,7 @@ static int32_t dwc_otg_pcd_resume_cb( void *_p ) if (pcd->driver && pcd->driver->resume) { - SPIN_UNLOCK(&pcd->lock); pcd->driver->resume(&pcd->gadget); - SPIN_LOCK(&pcd->lock); } /* Stop the SRP timeout timer. */ diff --git a/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c b/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c index 60cf52d1e21e..224054ceaabb 100755 --- a/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c +++ b/drivers/usb/dwc_otg/dwc_otg_pcd_intr.c @@ -558,6 +558,8 @@ void dwc_otg_pcd_stop(dwc_otg_pcd_t *_pcd) dwc_otg_pcd_ep_t *ep; gintmsk_data_t intr_mask = {.d32 = 0}; + + SPIN_LOCK(&_pcd->lock); num_in_eps = GET_CORE_IF(_pcd)->dev_if->num_in_eps; num_out_eps = GET_CORE_IF(_pcd)->dev_if->num_out_eps; @@ -607,6 +609,7 @@ void dwc_otg_pcd_stop(dwc_otg_pcd_t *_pcd) _pcd->driver->disconnect(&_pcd->gadget); SPIN_LOCK(&_pcd->lock); } + SPIN_UNLOCK(&_pcd->lock); } /** diff --git a/drivers/usb/dwc_otg/linux/dwc_otg_plat.h b/drivers/usb/dwc_otg/linux/dwc_otg_plat.h index 9037479461fa..e3f7d6e99640 100755 --- a/drivers/usb/dwc_otg/linux/dwc_otg_plat.h +++ b/drivers/usb/dwc_otg/linux/dwc_otg_plat.h @@ -155,7 +155,7 @@ static __inline__ void MDELAY( const uint32_t _msecs ) */ static __inline__ void SPIN_LOCK( spinlock_t *_lock ) { -// spin_lock(_lock); + spin_lock(_lock); } /** @@ -166,7 +166,7 @@ static __inline__ void SPIN_LOCK( spinlock_t *_lock ) */ static __inline__ void SPIN_UNLOCK( spinlock_t *_lock ) { -// spin_unlock(_lock); + spin_unlock(_lock); } /** -- 2.34.1