From patchwork Thu Sep 26 13:08:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 2948191 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A0FB9BFF05 for ; Thu, 26 Sep 2013 13:09:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6725020318 for ; Thu, 26 Sep 2013 13:09:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7D0E20320 for ; Thu, 26 Sep 2013 13:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932091Ab3IZNJR (ORCPT ); Thu, 26 Sep 2013 09:09:17 -0400 Received: from svenfoo.org ([82.94.215.22]:41299 "EHLO mail.zonque.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757008Ab3IZNJO (ORCPT ); Thu, 26 Sep 2013 09:09:14 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.zonque.de (Postfix) with ESMTP id 37C32C1735; Thu, 26 Sep 2013 15:09:07 +0200 (CEST) Received: from mail.zonque.de ([127.0.0.1]) by localhost (rambrand.bugwerft.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gISC52wy1lmr; Thu, 26 Sep 2013 15:09:07 +0200 (CEST) Received: from tamtam.fritz.box (unknown [212.87.41.14]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.zonque.de (Postfix) with ESMTPSA id C8131C1731; Thu, 26 Sep 2013 15:09:06 +0200 (CEST) From: Daniel Mack To: linux-usb@vger.kernel.org Cc: linux-omap@vger.kernel.org, neumann@teufel.de, bigeasy@linutronix.de, balbi@ti.com, gregkh@linuxfoundation.org, Daniel Mack Subject: [PATCH 1/4] usb: musb: move port reset to worker Date: Thu, 26 Sep 2013 15:08:59 +0200 Message-Id: <1380200942-28175-2-git-send-email-zonque@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1380200942-28175-1-git-send-email-zonque@gmail.com> References: <1380200942-28175-1-git-send-email-zonque@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP musb_port_reset() sleeps, so we can't call it from atomic context. It is, however, called from places inside musb_hub_control() while &musb->lock is held, which leads to a "scheduling while atomic" warning. Fix this by moving the logic into a worker, and call it where the function was previously called directly. Signed-off-by: Daniel Mack --- drivers/usb/musb/musb_core.c | 7 +++++++ drivers/usb/musb/musb_core.h | 3 +++ drivers/usb/musb/musb_host.h | 2 ++ drivers/usb/musb/musb_virthub.c | 13 ++++++++----- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 18e877f..2b9f4b4 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1699,6 +1699,12 @@ static void musb_irq_work(struct work_struct *data) } } +static void musb_port_reset_work(struct work_struct *data) +{ + struct musb *musb = container_of(data, struct musb, port_reset_work); + musb_port_reset(musb); +} + /* -------------------------------------------------------------------------- * Init support */ @@ -1857,6 +1863,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) /* Init IRQ workqueue before request_irq */ INIT_WORK(&musb->irq_work, musb_irq_work); + INIT_WORK(&musb->port_reset_work, musb_port_reset_work); /* attach to the IRQ */ if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) { diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 65f3917..9529512 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -294,6 +294,9 @@ struct musb { irqreturn_t (*isr)(int, void *); struct work_struct irq_work; + struct work_struct port_reset_work; + bool port_reset_state; + u16 hwvers; u16 intrrxe; diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h index 960d735..843f48e 100644 --- a/drivers/usb/musb/musb_host.h +++ b/drivers/usb/musb/musb_host.h @@ -92,6 +92,7 @@ extern void musb_host_rx(struct musb *, u8); extern void musb_root_disconnect(struct musb *musb); extern void musb_host_resume_root_hub(struct musb *musb); extern void musb_host_poke_root_hub(struct musb *musb); +extern void musb_port_reset(struct musb *musb); #else static inline struct musb *hcd_to_musb(struct usb_hcd *hcd) { @@ -121,6 +122,7 @@ static inline void musb_root_disconnect(struct musb *musb) {} static inline void musb_host_resume_root_hub(struct musb *musb) {} static inline void musb_host_poll_rh_status(struct musb *musb) {} static inline void musb_host_poke_root_hub(struct musb *musb) {} +static inline void musb_port_reset(struct musb *musb) {} #endif struct usb_hcd; diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index a523950..30b43a1 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -155,7 +155,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) } } -static void musb_port_reset(struct musb *musb, bool do_reset) +void musb_port_reset(struct musb *musb) { u8 power; void __iomem *mbase = musb->mregs; @@ -173,7 +173,7 @@ static void musb_port_reset(struct musb *musb, bool do_reset) * the appropriate amount of time has passed */ power = musb_readb(mbase, MUSB_POWER); - if (do_reset) { + if (musb->port_reset_state) { /* * If RESUME is set, we must make sure it stays minimum 20 ms. @@ -356,8 +356,10 @@ int musb_hub_control( /* finish RESET signaling? */ if ((musb->port1_status & USB_PORT_STAT_RESET) - && time_after_eq(jiffies, musb->rh_timer)) - musb_port_reset(musb, false); + && time_after_eq(jiffies, musb->rh_timer)) { + musb->port_reset_state = false; + schedule_work(&musb->port_reset_work); + } /* finish RESUME signaling? */ if ((musb->port1_status & MUSB_PORT_STAT_RESUME) @@ -412,7 +414,8 @@ int musb_hub_control( musb_start(musb); break; case USB_PORT_FEAT_RESET: - musb_port_reset(musb, true); + musb->port_reset_state = true; + schedule_work(&musb->port_reset_work); break; case USB_PORT_FEAT_SUSPEND: musb_port_suspend(musb, true);