From patchwork Thu Jul 12 07:01:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 1187391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id E9E793FDAE for ; Thu, 12 Jul 2012 07:24:59 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SpDgW-0005QC-RK; Thu, 12 Jul 2012 07:19:37 +0000 Received: from db3ehsobe003.messaging.microsoft.com ([213.199.154.141] helo=db3outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SpDQT-0001l4-En for linux-arm-kernel@lists.infradead.org; Thu, 12 Jul 2012 07:03:42 +0000 Received: from mail18-db3-R.bigfish.com (10.3.81.250) by DB3EHSOBE005.bigfish.com (10.3.84.25) with Microsoft SMTP Server id 14.1.225.23; Thu, 12 Jul 2012 07:02:56 +0000 Received: from mail18-db3 (localhost [127.0.0.1]) by mail18-db3-R.bigfish.com (Postfix) with ESMTP id 5E6AB8044B; Thu, 12 Jul 2012 07:02:56 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 4 X-BigFish: VS4(z4256lzzz1202hzz8275bhz2dh2a8h668h839hd24he5bhf0ah107ah) Received: from mail18-db3 (localhost.localdomain [127.0.0.1]) by mail18-db3 (MessageSwitch) id 134207657579665_11273; Thu, 12 Jul 2012 07:02:55 +0000 (UTC) Received: from DB3EHSMHS012.bigfish.com (unknown [10.3.81.227]) by mail18-db3.bigfish.com (Postfix) with ESMTP id 1092A420048; Thu, 12 Jul 2012 07:02:55 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB3EHSMHS012.bigfish.com (10.3.87.112) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 12 Jul 2012 07:02:54 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.298.5; Thu, 12 Jul 2012 02:02:46 -0500 Received: from b20223-02.ap.freescale.net (b20223-02.ap.freescale.net [10.192.242.124]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id q6C71r2T016222; Thu, 12 Jul 2012 00:02:43 -0700 From: Richard Zhao To: , Subject: [PATCH 11/12] USB: chipidea: re-order irq handling to avoid unhandled irq Date: Thu, 12 Jul 2012 15:01:51 +0800 Message-ID: <1342076512-19207-12-git-send-email-richard.zhao@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1342076512-19207-1-git-send-email-richard.zhao@freescale.com> References: <1342076512-19207-1-git-send-email-richard.zhao@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [213.199.154.141 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: marex@denx.de, B20596@freescale.com, dong.aisheng@linaro.org, fabio.estevam@freescale.com, alexander.shishkin@linux.intel.com, B29397@freescale.com, balbi@ti.com, stern@rowland.harvard.edu, kernel@pengutronix.de, gregkh@linuxfoundation.org, richard.zhao@freescale.com, shawn.guo@linaro.org, mkl@pengutronix.de, linuxzsc@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org - let role driver handle irq before ID change check. It give the role driver a chance to handle disconnect. - disable irq during switch role. No role driver to handle irq in the period. Signed-off-by: Richard Zhao --- drivers/usb/chipidea/core.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 7485c84..0942b9b 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -279,6 +279,7 @@ static void ci_role_work(struct work_struct *work) ci_role_stop(ci); ci_role_start(ci, role); + enable_irq(ci->irq); } } @@ -318,18 +319,22 @@ static irqreturn_t ci_irq(int irq, void *data) { struct ci13xxx *ci = data; irqreturn_t ret = IRQ_NONE; + u32 otgsc = 0; - if (ci->is_otg) { - u32 sts = hw_read(ci, OP_OTGSC, ~0); + if (ci->is_otg) + otgsc = hw_read(ci, OP_OTGSC, ~0); - if (sts & OTGSC_IDIS) { - hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS); - queue_work(ci->wq, &ci->work); - ret = IRQ_HANDLED; - } + if (ci->role != CI_ROLE_END) + ret = ci_role(ci)->irq(ci); + + if (ci->is_otg && (otgsc & OTGSC_IDIS)) { + hw_write(ci, OP_OTGSC, OTGSC_IDIS, OTGSC_IDIS); + disable_irq_nosync(ci->irq); + queue_work(ci->wq, &ci->work); + ret = IRQ_HANDLED; } - return ci->role == CI_ROLE_END ? ret : ci_role(ci)->irq(ci); + return ret; } static DEFINE_IDA(ci_ida);