From patchwork Thu Aug 28 10:25:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 36182 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C2053202DD for ; Thu, 28 Aug 2014 10:27:36 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id v10sf3837926qac.0 for ; Thu, 28 Aug 2014 03:27:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=nS/GPW/n3wYmc3uz7zACqo2wOxzfY7TV+Jk4XmJ35HY=; b=fkWQrJEMVvS/Jg5BNQTsJyphzhajq9YgUA9S4lo9Ct1+wARKoNr6hlzeUOa5NcosPw WBr5mptkXR5QgEPczatQQCAcRcZD+gPD+EBbDwCd9m5FMqIUfNI426gljmucfVhTLvz7 xKbCe2OCUOdQ5f+ZKJ99hnYfI9aH1w2eq1/pIb0IXHOzFtRX3r/oszOzxwtgMhF4A8EQ SlCOvEXRS3gVXRKQdYi6lelp+cOclm+gFwvJVn4JsO/Dsj3DWEmZ/vPbGLzU4iFE5bHA cbfgqIewMQnsMnqI5adGiWaYr3ttryfqA54vl6AvFsJHeCqW/HX5oGfKG2Mfe95aRhV9 zcLg== X-Gm-Message-State: ALoCoQnd1opbJIM6NX5yLtL9cWH+VmL35CW4saic/MnyHi0kzGVRSQQE6ZapgJi2dc/ff/7av7Co X-Received: by 10.52.174.178 with SMTP id bt18mr1691475vdc.1.1409221656616; Thu, 28 Aug 2014 03:27:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.212 with SMTP id o78ls503751qge.55.gmail; Thu, 28 Aug 2014 03:27:36 -0700 (PDT) X-Received: by 10.52.144.232 with SMTP id sp8mr20490vdb.61.1409221656515; Thu, 28 Aug 2014 03:27:36 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id mn6si3035077vcb.40.2014.08.28.03.27.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 03:27:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id hq11so566333vcb.0 for ; Thu, 28 Aug 2014 03:27:36 -0700 (PDT) X-Received: by 10.220.114.66 with SMTP id d2mr1106143vcq.27.1409221656435; Thu, 28 Aug 2014 03:27:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp212920vcb; Thu, 28 Aug 2014 03:27:35 -0700 (PDT) X-Received: by 10.70.37.67 with SMTP id w3mr4224418pdj.107.1409221655474; Thu, 28 Aug 2014 03:27:35 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tc10si5780788pbc.42.2014.08.28.03.27.34 for ; Thu, 28 Aug 2014 03:27:35 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965741AbaH1K13 (ORCPT + 26 others); Thu, 28 Aug 2014 06:27:29 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:39407 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934654AbaH1K03 (ORCPT ); Thu, 28 Aug 2014 06:26:29 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s7SAQStB029843; Thu, 28 Aug 2014 05:26:28 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7SAQSQO029614; Thu, 28 Aug 2014 05:26:28 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Thu, 28 Aug 2014 05:26:28 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s7SAQN02030923; Thu, 28 Aug 2014 05:26:27 -0500 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 2/5] usb: phy: twl4030-usb: Fix lost interrupts after ID pin goes down Date: Thu, 28 Aug 2014 15:55:03 +0530 Message-ID: <1409221506-6262-3-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1409221506-6262-1-git-send-email-kishon@ti.com> References: <1409221506-6262-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kishon@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tony Lindgren Commit 249751f22380 ("usb: phy: twl4030-usb: poll for ID disconnect") added twl4030_id_workaround_work() to deal with lost interrupts after ID pin goes down. Looks like commit f1ddc24c9e33 ("usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops") changed things around for the generic phy framework, and delayed work no longer got called except initially during boot. The PHY connect and disconnect interrupts for twl4030-usb are not working after disconnecting a USB-A cable from the board, and the deeper idle states for omap are blocked as the USB controller stays busy. The issue can be solved by calling delayed work from twl4030_usb_irq() when ID pin is down and the PHY is not asleep like we already do in twl4030_id_workaround_work(). But as both twl4030_usb_irq() and twl4030_id_workaround_work() already do pretty much the same thing, let's call twl4030_usb_irq() from twl4030_id_workaround_work() instead of adding some more duplicate code. We also must call sysfs_notify() only when we have an interrupt and not from the delayed work as notified by Grazvydas Ignotas . Fixes: f1ddc24c9e33 ("usb: phy: twl4030-usb: remove *set_suspend* and *phy_init* ops") Cc: stable@vger.kernel.org # v3.13+ Acked-by: Felipe Balbi Signed-off-by: Tony Lindgren Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/phy-twl4030-usb.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index 0cb872b..9cd33a4 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -589,7 +589,15 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl) } omap_musb_mailbox(status); } - sysfs_notify(&twl->dev->kobj, NULL, "vbus"); + + /* don't schedule during sleep - irq works right then */ + if (status == OMAP_MUSB_ID_GROUND && !twl->asleep) { + cancel_delayed_work(&twl->id_workaround_work); + schedule_delayed_work(&twl->id_workaround_work, HZ); + } + + if (irq) + sysfs_notify(&twl->dev->kobj, NULL, "vbus"); return IRQ_HANDLED; } @@ -598,29 +606,8 @@ static void twl4030_id_workaround_work(struct work_struct *work) { struct twl4030_usb *twl = container_of(work, struct twl4030_usb, id_workaround_work.work); - enum omap_musb_vbus_id_status status; - bool status_changed = false; - - status = twl4030_usb_linkstat(twl); - - spin_lock_irq(&twl->lock); - if (status >= 0 && status != twl->linkstat) { - twl->linkstat = status; - status_changed = true; - } - spin_unlock_irq(&twl->lock); - - if (status_changed) { - dev_dbg(twl->dev, "handle missing status change to %d\n", - status); - omap_musb_mailbox(status); - } - /* don't schedule during sleep - irq works right then */ - if (status == OMAP_MUSB_ID_GROUND && !twl->asleep) { - cancel_delayed_work(&twl->id_workaround_work); - schedule_delayed_work(&twl->id_workaround_work, HZ); - } + twl4030_usb_irq(0, twl); } static int twl4030_phy_init(struct phy *phy)