Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp345425pxb; Fri, 16 Apr 2021 07:09:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYapTyXUHWcxk3bBMCC43iE1pEiBNec/aOctX0kM7G8AuqMEZaF/ZdXHD7cZyZ74oMa9iN X-Received: by 2002:adf:9567:: with SMTP id 94mr9439151wrs.401.1618582181123; Fri, 16 Apr 2021 07:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618582181; cv=none; d=google.com; s=arc-20160816; b=U04trM+NTa0zk7kbHZQgAV3UUg31kqVTV7CBinsICI6lwPJxK7P382r1cn1fJJj2LO uL3+LP56ewKJOBc/OFyLQMuu1LXKjys3NODEQZECQhRZC8t5m0NfHuzIBYssLZAGvbwi 4CRx1lWh6wDDbo/+W1tD6kp4t35li0QgMtqlfvX9/GWm0DjMyQgmWfByYPhRiud80IzW DhE1Wv8W93ixU8rnOdmhRZ0G0YxD94Td/sSDVaGg/n8G0RN2GtVKusi48XqdIhzMlTVj rfxgLTWLtmbly78qC/sjbg/dG9USti5mWYvkzqFAc652Tsdl9iP33nHQX2fxU91wIxIr 8P4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:cc:to:subject:from:references :in-reply-to:date:dkim-signature; bh=n09IoI3+EM5J3r+EPW4bk457P3y2aTG6caBL6Rnsf8s=; b=Lk8CMxfVzqyJqFYdIdJqgXnWwSYFpWt0NmNS2pT6z0wn7HISkmF6c2OxriTNvgolJ3 bovwcbge3H0R6rD6tAj9J7KEA+C/2vg6NTFm8exdw6RQnIjujBhMJcgxh7C1S5ydjPlZ 3ugAyFJH4RNxvTKXMpHW1zr/RYltAx2ooQko4LaLozugp36VBYJz9C5LC4ODLM6vD4QR 76DqSqcPDqugi3jBGjhQ4xINg/i0UJrBz8nST9BvljLwtT0UfAfX5Ov+suSyyJ0Hmgm7 dGZjS+vtoWTXeQCu5brrDgFjHFX4vy2GPBB6squ8jS1WlHRz9DcDUsg4tQUFMJ3hxloy TGEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=FlSUbb+Q; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si4771044ejj.228.2021.04.16.07.09.18; Fri, 16 Apr 2021 07:09:41 -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=@synopsys.com header.s=mail header.b=FlSUbb+Q; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243683AbhDPMsS (ORCPT + 99 others); Fri, 16 Apr 2021 08:48:18 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]:42270 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243684AbhDPMsP (ORCPT ); Fri, 16 Apr 2021 08:48:15 -0400 Received: from mailhost.synopsys.com (mdc-mailhost1.synopsys.com [10.225.0.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id CD889C06BA; Fri, 16 Apr 2021 12:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1618577271; bh=AsB4pzMO9T/Ifbq2nL27yKkTwDu2eMWyNVeZjwbDJWQ=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=FlSUbb+QQ8QiOnjXEVFvPREY7ezPE+YF+HjB60jnQSIu7IfLHIZ7nZfHbmufWA/IE Qdkmc9FCihPxUdpeXNUy7uY9cFAqMhaPgXwPv+yKo/aQSAE5ywpn55LHEnmNsaFBdH I7L4OuZpyrJ60LUuD+JreEX5v3ZqZvrJQQQXLTtBJSuVyBGafqiQLsMx9R/d+pB0Ft P+wf20bZNFMyD4OChNSFy1CcEmnF8pzHW4KPj2ffTBS7wP0Kc7QoffpUGawhcMsPhR 6W56iHgFUxHVLSFcFmPjoVjAps3II4xNRMb3QbONUcHflKQYx5YqmseT776NDfN8w4 os1gvLezLHp+w== Received: from razpc-HP (razpc-hp.internal.synopsys.com [10.116.126.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id EE79EA005C; Fri, 16 Apr 2021 12:47:47 +0000 (UTC) Received: by razpc-HP (sSMTP sendmail emulation); Fri, 16 Apr 2021 16:47:46 +0400 Date: Fri, 16 Apr 2021 16:47:46 +0400 In-Reply-To: References: X-SNPS-Relay: synopsys.com From: Artur Petrosyan Subject: [PATCH v2 08/15] usb: dwc2: Move enter hibernation to dwc2_port_suspend() function To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: John Youn , Artur Petrosyan Message-Id: <20210416124747.EE79EA005C@mailhost.synopsys.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This move is done to call enter hibernation handler in "dwc2_port_suspend()" function when core receives port suspend. Otherwise it could be confusing to enter to hibernation in "dwc2_hcd_hub_control()" function but other power saving modes in "dwc2_port_suspend()" function. Signed-off-by: Artur Petrosyan --- Changes in v2: - None drivers/usb/dwc2/hcd.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index ff945c40ef8a..43a2298b7d42 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3321,6 +3321,18 @@ int dwc2_port_suspend(struct dwc2_hsotg *hsotg, u16 windex) "enter partial_power_down failed.\n"); break; case DWC2_POWER_DOWN_PARAM_HIBERNATION: + /* + * Perform spin unlock and lock because in + * "dwc2_host_enter_hibernation()" function there is a spinlock + * logic which prevents servicing of any IRQ during entering + * hibernation. + */ + spin_unlock_irqrestore(&hsotg->lock, flags); + ret = dwc2_enter_hibernation(hsotg, 1); + if (ret) + dev_err(hsotg->dev, "enter hibernation failed.\n"); + spin_lock_irqsave(&hsotg->lock, flags); + break; case DWC2_POWER_DOWN_PARAM_NONE: /* * If not hibernation nor partial power down are supported, @@ -3650,10 +3662,8 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq, "SetPortFeature - USB_PORT_FEAT_SUSPEND\n"); if (windex != hsotg->otg_port) goto error; - if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_HIBERNATION) - dwc2_enter_hibernation(hsotg, 1); - else - dwc2_port_suspend(hsotg, windex); + if (!hsotg->bus_suspended) + retval = dwc2_port_suspend(hsotg, windex); break; case USB_PORT_FEAT_POWER: -- 2.25.1