Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp823244pxu; Fri, 11 Dec 2020 15:37:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJweAdQSkopCrjEJ47wqFp2OUWwB9QArzAWTM4mtxnEEr+WbfHPLJSjYbhE91bs9czvmbRme X-Received: by 2002:a17:906:af83:: with SMTP id mj3mr12771519ejb.243.1607729831629; Fri, 11 Dec 2020 15:37:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607729831; cv=none; d=google.com; s=arc-20160816; b=UBQD71WOTU1+nEfUmP+ycWAdvK513j8BSlnSCfhJTPJG6eG1uUJKiH1pYMK/dPK3oq TODqhkpQdmPvcv6i5SRayN+HETc0oYUk5/U8OnLdbg42aoKv+k2YuRSHL+opZiopcQUd 7uQZmUQ1+O0Lw4uHCMnmemHvXICZAvH9+49JULgh5Vip0/n0e873QgBb74xywa5srXrp JCa2UtRH5GTND04QQ6E22m5MmLp4x9YdxCz2ye4urAEYUWuBipODiiT9d7NniNLgXt0F Th+zBxuLZ1znpR1JxiKjTeXzEDTcEHI35CFbVRj5+ekmn5utrOhgje4HEESP8lQu9e0+ 5LgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qtlZ0DEPLlgnakZuegRLLP1pu6eYE/7+9AbraWd6Nl4=; b=nZ/koaeHTNqjQ/pYAw8et2xW7aW3/W9cpIUY3BOUk33V/VCWLqjcEFM5n1SHEUeTgs WSz247v7ugredv43mFos4QfUhv+dPMZIVrR2UXL8DK3aN6izcMg2iBW9yzFRYaJxJRDg WVZxsPFLTsXznNR3xSWiZuliL+h6wwZqmGsFrpnlLT71P8GIGFeW81BqYj8PkHkgGOtI LS7i6nCwb379QK4yyfFtSIGElWJn9f7MzKYOcHmYBlRftbgUH5UTX3hqHl4N/aEaOApV JV3uYvOeJJneH37wpr8bECcy79BE5nOkgTBNHziQzLBkUJL6Ky1jsj1If97zh/hpDwh0 BnFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DV0aRUCL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t6si5302774ejr.116.2020.12.11.15.36.48; Fri, 11 Dec 2020 15:37:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DV0aRUCL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732695AbgLKAs4 (ORCPT + 99 others); Thu, 10 Dec 2020 19:48:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389200AbgLKAsc (ORCPT ); Thu, 10 Dec 2020 19:48:32 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 039DAC0613CF for ; Thu, 10 Dec 2020 16:47:52 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id w16so5939518pga.9 for ; Thu, 10 Dec 2020 16:47:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=qtlZ0DEPLlgnakZuegRLLP1pu6eYE/7+9AbraWd6Nl4=; b=DV0aRUCL7xoEuNHuX09WvmYZV82z8THJlzxFil5QBevlOpCiike574SS8SEzmsjdii C/YvxmeCmQ6m4TNLQVJp6E1gCWFXNvrHhuE5GjK37WPZESjVUbqj1YdDtt7dGmyGM7H6 +eqxHo29ONRuSxlM6byLmlS2rCWIRjYO9b8hE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qtlZ0DEPLlgnakZuegRLLP1pu6eYE/7+9AbraWd6Nl4=; b=G120XTOvrdRvtw/JCj5gj1/yuoDLJZrbfSIywPMjMd6FbPp1wnho8uxl8IJ4HCbzaD z7HVxxytGNle1OqinxTT83mXcO7QXG+GR1EgF2odddD4/7ukyW7CpWgvXWFcg5ki4z/2 faN6pstTN7/4FbRO7062APtjuPjtkFckmMICXZE5wnrBhsGtiHOO9o4TMftn/wW1CwAw nFHFJ7zsn/QOOPGz9WkWyihy5cGnTyGt0myIdWvPOn0spQJ2cK4ExO79FlholkgkyVok aXe7en6gJ+ycvga8xy65X12dcg/YmB1f+ajO2vNH2j2cViiXa+Eu/s051tFMJuDdggKK OSHQ== X-Gm-Message-State: AOAM532R/65MYn3q7gWKyUL1lP+AW/5sEni9OYnPhSmxFjGn0U7EA40t ycKUhWmNUS1b9m7JNc5hPEzhgQ== X-Received: by 2002:a65:5547:: with SMTP id t7mr9104969pgr.50.1607647671565; Thu, 10 Dec 2020 16:47:51 -0800 (PST) Received: from localhost ([2620:15c:202:1:f693:9fff:fef4:e70a]) by smtp.gmail.com with ESMTPSA id w2sm7882452pfj.110.2020.12.10.16.47.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Dec 2020 16:47:51 -0800 (PST) Date: Thu, 10 Dec 2020 16:47:49 -0800 From: Matthias Kaehlcke To: Sandeep Maheswaram Cc: Andy Gross , Bjorn Andersson , Greg Kroah-Hartman , Rob Herring , Mark Rutland , Felipe Balbi , Stephen Boyd , Doug Anderson , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Manu Gautam Subject: Re: [PATCH v4 3/5] usb: dwc3: qcom: Configure wakeup interrupts and set genpd active wakeup flag Message-ID: References: <1603831083-2025-1-git-send-email-sanm@codeaurora.org> <1603831083-2025-4-git-send-email-sanm@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1603831083-2025-4-git-send-email-sanm@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 28, 2020 at 02:08:01AM +0530, Sandeep Maheswaram wrote: > Configure interrupts based on hs_phy_mode to avoid triggering of > interrupts during system suspend and suspends successfully. > Set genpd active wakeup flag for usb gdsc if wakeup capable devices > are connected so that wake up happens without reenumeration. > Add helper functions to enable,disable wake irqs. > > Signed-off-by: Sandeep Maheswaram > --- > drivers/usb/dwc3/dwc3-qcom.c | 82 ++++++++++++++++++++++++++++---------------- > 1 file changed, 52 insertions(+), 30 deletions(-) > > diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c > index c703d55..c93f7bb 100644 > --- a/drivers/usb/dwc3/dwc3-qcom.c > +++ b/drivers/usb/dwc3/dwc3-qcom.c > @@ -17,9 +17,11 @@ > #include > #include > #include > +#include > #include > #include > #include > +#include > > #include "core.h" > > @@ -291,60 +293,75 @@ static void dwc3_qcom_interconnect_exit(struct dwc3_qcom *qcom) > icc_put(qcom->icc_path_apps); > } > > -static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) > +static void dwc3_qcom_enable_wakeup_irq(int wake_irq) super-nit: from the name of the function it's evident that this is a wakeup irq, you could omit the 'wake_' prefix. > { > - if (qcom->hs_phy_irq) { > - disable_irq_wake(qcom->hs_phy_irq); > - disable_irq_nosync(qcom->hs_phy_irq); > + if (wake_irq) { > + enable_irq(wake_irq); > + enable_irq_wake(wake_irq); > } nit: the following would be a more common structure: if (!wake_irq) return; enable_irq(wake_irq); enable_irq_wake(wake_irq); > +} > > - if (qcom->dp_hs_phy_irq) { > - disable_irq_wake(qcom->dp_hs_phy_irq); > - disable_irq_nosync(qcom->dp_hs_phy_irq); > +static void dwc3_qcom_disable_wakeup_irq(int wake_irq) same as above > +{ > + if (wake_irq) { > + disable_irq_wake(wake_irq); > + disable_irq_nosync(wake_irq); > } same as above > +} > > - if (qcom->dm_hs_phy_irq) { > - disable_irq_wake(qcom->dm_hs_phy_irq); > - disable_irq_nosync(qcom->dm_hs_phy_irq); > - } > +static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom) > +{ > + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); > + > + dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq); > > - if (qcom->ss_phy_irq) { > - disable_irq_wake(qcom->ss_phy_irq); > - disable_irq_nosync(qcom->ss_phy_irq); > + if (dwc->hs_phy_mode & PHY_MODE_USB_HOST_LS) > + dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq); > + else if (dwc->hs_phy_mode & PHY_MODE_USB_HOST_HS) > + dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); > + else { > + dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq); > + dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); > } The following would be clearer IMO: if (dwc->hs_phy_mode & (PHY_MODE_USB_HOST_LS | PHY_MODE_USB_HOST_SS)) dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq); if (dwc->hs_phy_mode & (PHY_MODE_USB_HOST_HS | PHY_MODE_USB_HOST_SS)) dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq); > + > + dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq); Why isn't this conditional on 'dwc->hs_phy_mode & PHY_MODE_USB_HOST_SS'? > } > > static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) > { > - if (qcom->hs_phy_irq) { > - enable_irq(qcom->hs_phy_irq); > - enable_irq_wake(qcom->hs_phy_irq); > - } > + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); > > - if (qcom->dp_hs_phy_irq) { > - enable_irq(qcom->dp_hs_phy_irq); > - enable_irq_wake(qcom->dp_hs_phy_irq); > - } > + dwc3_qcom_enable_wakeup_irq(qcom->hs_phy_irq); > > - if (qcom->dm_hs_phy_irq) { > - enable_irq(qcom->dm_hs_phy_irq); > - enable_irq_wake(qcom->dm_hs_phy_irq); > + if (dwc->hs_phy_mode & PHY_MODE_USB_HOST_LS) > + dwc3_qcom_enable_wakeup_irq(qcom->dp_hs_phy_irq); > + else if (dwc->hs_phy_mode & PHY_MODE_USB_HOST_HS) > + dwc3_qcom_enable_wakeup_irq(qcom->dm_hs_phy_irq); > + else { > + dwc3_qcom_enable_wakeup_irq(qcom->dp_hs_phy_irq); > + dwc3_qcom_enable_wakeup_irq(qcom->dm_hs_phy_irq); > } > > - if (qcom->ss_phy_irq) { > - enable_irq(qcom->ss_phy_irq); > - enable_irq_wake(qcom->ss_phy_irq); > - } > + dwc3_qcom_enable_wakeup_irq(qcom->ss_phy_irq); same comments as for dwc3_qcom_disable_interrupts() > } > > static int dwc3_qcom_suspend(struct dwc3_qcom *qcom) > { > u32 val; > int i, ret; > + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); > + struct usb_hcd *hcd; nit: remove one blank > + struct generic_pm_domain *genpd = pd_to_genpd(qcom->dev->pm_domain); > > if (qcom->is_suspended) > return 0; > > + if (dwc->xhci) { > + hcd = platform_get_drvdata(dwc->xhci); > + if (usb_wakeup_enabled_descendants(hcd->self.root_hub)) > + genpd->flags |= GENPD_FLAG_ACTIVE_WAKEUP; Shouldn't this only be done when wakeup is enabled? > + } > + > val = readl(qcom->qscratch_base + PWR_EVNT_IRQ_STAT_REG); > if (!(val & PWR_EVNT_LPM_IN_L2_MASK)) > dev_err(qcom->dev, "HS-PHY not in L2\n"); > @@ -366,10 +383,15 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom) > { > int ret; > int i; > + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); > + struct generic_pm_domain *genpd = pd_to_genpd(qcom->dev->pm_domain); > > if (!qcom->is_suspended) > return 0; > > + if (dwc->xhci) > + genpd->flags &= ~GENPD_FLAG_ACTIVE_WAKEUP; Could also depend on wakeup being enabled, but less important. > + > dwc3_qcom_disable_interrupts(qcom); > > for (i = 0; i < qcom->num_clocks; i++) { > @@ -764,7 +786,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev) > if (ret) > goto interconnect_exit; > > - device_init_wakeup(&pdev->dev, 1); > + device_init_wakeup(&pdev->dev, of_property_read_bool(np, "wakeup-source")); > qcom->is_suspended = false; > pm_runtime_set_active(dev); > pm_runtime_enable(dev); > -- > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member > of Code Aurora Forum, hosted by The Linux Foundation >