Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp88659pxb; Tue, 28 Sep 2021 16:11:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgb4Jqpj9ibR8P9bJXfpPjfzpbslwhkVQOu7vOLLVIUEe4qCLg3gIeF69Iq2Pr22omtEP/ X-Received: by 2002:a50:8145:: with SMTP id 63mr8043734edc.190.1632870668344; Tue, 28 Sep 2021 16:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632870668; cv=none; d=google.com; s=arc-20160816; b=yzADcrORYPbLUk0zO+FyDWPnmZaOkiKrxIpWOhmzTkx7t8Wq4/p/kuBfkoyiKhjY+X I9zWuU8GlJil9x2IOJ0p30T5mdnOuqPJZvZGLsLAIxhvlyHEkb52nS9BgbRfnHzZ3kdG 6v9lZPePiwndHM0WiIN//TaZMlce/MmsC7PZm0fexk2/zDvli+vJCgQ7094ezDdhE1Nv Jl5JhoFl/Fhe6R1HgTaVFZAamupvzuHCimHVRUH/9clVPQDv2SyVe8OtscH8oOMO6Tpo gnO5hB5D/OkfZStM6GeHNtQdHvAvy0/iUJFifSNultr4c/UveSO/xHZojNv2z6yC7uJq FSrg== 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=VAVjy8HcaFqaIzDnTlnGPoodVICGjX7cWhESEeYfADg=; b=oboOclDMY3TeZP6Ny85+wzyV80+KJ5Fi6CtNA089OEK3jwbQDNLE9m0A5YrdZ7AFsH +Tpw99GzSl9z4jvq995Xcr9XvyAUX4O5A29XP+Tikv9GTHgjBWt2dnFwMCsw4sbVPNFY 9tr9T23jVpSHRLk38hI72f9RLgFa2aG5Qp7NuTRkhW6/Vut4Ic10idQZnnB+aPW+HI0z h/5kVC2nRCiPB44rOWV+Rk3k+YXqgS51TV78+AgVKVrMjpEkDGuuA989bsuExLjjehqi MAGLMsASQYHWap+2jPbLRDgTdX0VoWfi1AdTJY2/eRQkCT+b7wZDjROu9xjK/u30q9B/ 4XyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oS9uweXO; 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 v4si816527edc.167.2021.09.28.16.10.44; Tue, 28 Sep 2021 16:11:08 -0700 (PDT) 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=oS9uweXO; 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 S243200AbhI1XKj (ORCPT + 99 others); Tue, 28 Sep 2021 19:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243191AbhI1XKi (ORCPT ); Tue, 28 Sep 2021 19:10:38 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10EC1C06161C for ; Tue, 28 Sep 2021 16:08:58 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id n18so635495pgm.12 for ; Tue, 28 Sep 2021 16:08:58 -0700 (PDT) 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=VAVjy8HcaFqaIzDnTlnGPoodVICGjX7cWhESEeYfADg=; b=oS9uweXO3FrPncRchHQEfxqL1veKPLliIy5Xe0MgjcruuM1JKRfGB5avSRn6VzVDYO HgHHKd0oa1DhfeUZbkCgAAo2H3nCvK1bfcnUs4bzu64kowqxKpgxGfbfxudBdL23iGpT lGY4k6Suz3YUqw8MjgjmTZRp05OIiD3pzKpHY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VAVjy8HcaFqaIzDnTlnGPoodVICGjX7cWhESEeYfADg=; b=QkfizIywIWNwcqE7Q+J1R5uatDF4yDbbGgF3jOtPWhbt1uUFROe9mYkUfUdbIX5yBG Yt1V2N+6W/jjnkWCuTBMmHycj/+gatP79Haidl5Afyg7l0gRyEivXxaRwKAX0/WFNXw8 cFFGxYONL3kX2yQr2eOgsqAefxKZwZuTh1DqXxhNJRPpdwp79lZubcvBQ5SBay++xZqg ywXGanh4PzyAjGkY+Qqf1mKdYms+LBs63vIbge6ZFsf1ATAnr3oVcKugqLCMwtcUxKuF 6qZ6yICPOnArx/pC+EJ19x0zifhGR3kB2iCwrUaeKROR1FU/661kRdrFDp8vqauIlAws cxAw== X-Gm-Message-State: AOAM531Ru5OBbkmXMBbJHmhCDdEqiXK/2GBNq43w1jINtnOCVO+6k/+T MmPTx77wpIq7Q5j/oqbc+n8K/w== X-Received: by 2002:a62:8f93:0:b0:447:baea:b5a7 with SMTP id n141-20020a628f93000000b00447baeab5a7mr288096pfd.68.1632870537575; Tue, 28 Sep 2021 16:08:57 -0700 (PDT) Received: from google.com ([2620:15c:202:201:d7ca:580:94ab:8af8]) by smtp.gmail.com with ESMTPSA id b2sm190693pfr.58.2021.09.28.16.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 16:08:57 -0700 (PDT) Date: Tue, 28 Sep 2021 16:08:54 -0700 From: Brian Norris To: Sandeep Maheswaram Cc: Andy Gross , Bjorn Andersson , Greg Kroah-Hartman , Felipe Balbi , Stephen Boyd , Doug Anderson , Matthias Kaehlcke , Mathias Nyman , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Pratham Pratap Subject: Re: [PATCH v8 2/6] usb: host: xhci: plat: Add suspend quirk for dwc3 controller Message-ID: References: <1624882097-23265-1-git-send-email-sanm@codeaurora.org> <1624882097-23265-3-git-send-email-sanm@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1624882097-23265-3-git-send-email-sanm@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, Jun 28, 2021 at 05:38:13PM +0530, Sandeep Maheswaram wrote: > During suspend read the status of all port and make sure the PHYs > are in the correct mode based on current speed. > Phy interrupt masks are set based on this mode. Keep track of the mode > of the HS PHY to be able to configure wakeup properly. > > Also check during suspend if any wakeup capable devices are > connected to the controller (directly or through hubs), if there > are none set a flag to indicate that the PHY should be powered > down during suspend. ... > --- a/drivers/usb/host/xhci-plat.c > +++ b/drivers/usb/host/xhci-plat.c > @@ -430,6 +431,39 @@ static int xhci_plat_remove(struct platform_device *dev) > > return 0; > } > +static void xhci_dwc3_suspend_quirk(struct usb_hcd *hcd) nit: you need a blank line above this (in between functions). > +{ > + int i, num_ports; > + u32 reg; > + unsigned int ss_phy_mode = 0; > + struct dwc3 *dwc = dev_get_drvdata(hcd->self.controller->parent); > + struct xhci_hcd *xhci_hcd = hcd_to_xhci(hcd); > + > + dwc->hs_phy_mode = 0; > + > + reg = readl(&xhci_hcd->cap_regs->hcs_params1); > + num_ports = HCS_MAX_PORTS(reg); > + > + for (i = 0; i < num_ports; i++) { > + reg = readl(&xhci_hcd->op_regs->port_status_base + i * 0x04); > + if (reg & PORT_PE) { > + if (DEV_HIGHSPEED(reg) || DEV_FULLSPEED(reg)) > + dwc->hs_phy_mode |= PHY_MODE_USB_HOST_HS; > + else if (DEV_LOWSPEED(reg)) > + dwc->hs_phy_mode |= PHY_MODE_USB_HOST_LS; > + > + if (DEV_SUPERSPEED(reg)) > + ss_phy_mode |= PHY_MODE_USB_HOST_SS; > + } > + } > + phy_set_mode(dwc->usb2_generic_phy, dwc->hs_phy_mode); > + phy_set_mode(dwc->usb3_generic_phy, ss_phy_mode); > + > + if (usb_wakeup_enabled_descendants(hcd->self.root_hub)) > + dwc->phy_power_off = false; > + else > + dwc->phy_power_off = true; > +} This series breaks USB across S3 suspend/resume on Rockchip RK3399 Gru platforms. Those platforms do not support USB wake (they power off many of the relevant IP blocks in S3), and they *require* reconfiguring the PHY on resume, but usb_wakeup_enabled_descendants() is returning non-zero. If I revert patch 3, things work again. Perhaps that's a Rockchip bug (should such platforms be disabling all PM wakeup capabilities for their child hubs/devices?), but I'd much appreciate resolving that before merging such a regression. This also may be a sign that usb_wakeup_enabled_descendants() isn't really the precise condition you should be using, if other platforms aren't accurately reflecting feature support status in here. Brian P.S. In case it matters, I'm noticing this because earlier versions of your patches (which have the same problem) are merged in our downstream Chromium kernel tree.