Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp331622pxb; Fri, 16 Apr 2021 06:51:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOScx4KC3kQ1jNY8JOQDC9j3OY5gV+AMbrR2ENXnSSslAFzp2M58/pZmAIOznd13Ae7gtt X-Received: by 2002:aa7:c40b:: with SMTP id j11mr10112844edq.219.1618581091258; Fri, 16 Apr 2021 06:51:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618581091; cv=none; d=google.com; s=arc-20160816; b=MaPwr1c/lQch4qzh2i9Ijull9WPdjAYoX8idsMP3F/WZxb+3+oRZEUX4b69tlU/Bci quEq8QYWKvC6/8wdJOBDks1LJwSpXsz096TLpMazJpkSZv1i4x2COyl0xIKYeq0GkjO0 KnSk387THFwbK8N/810fP/nTAS2yZJYnpxCs+Duj3gVrshogZC8H+LvFwHPgDJKTKlMJ dN+BDOG10mKxfYw2Sdr16roGwFvo4dfJIKd2lyhAfptBBpww+BLV5ACHka80XjMS9ec/ KURw4ckOl0TCKGK5humt8jNjhxMlWJOZS227cZn/U2hFTs+vcwopWuDKeKYIGa2tri5+ eVDg== 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=GUUiCMbSxMuQBJVYcfqlEs4ImlJnuNiLEf9oV3RQI+w=; b=FG+Q8whWs1f8eX0+PVM2wtzk9EU11Lf71aKRacRREvDAceiEaSplJ7vDmn4OB7Dmk1 XB5AkqnbmKRnMd9pieNa7aBFqal8nnqm2KmA8PmQbS8lrxuCKB39dTSC+g/tNNcrulPi +gkumPOcn/Oi55ypZW2f3JAQ/yeZ1eJwcW/7WRnamtertrv8CO2j5pAnithuEQvFv+kH AbyZpmRu2lM/uDtVu7Ksjm2yh6caefVIMyA51Tu4ri2SLw2zBJGk+X/ORbqYVlF6DUCw TLlLLD9ZKYg1SQw3aa54+eCkTVozzktaCvV5jhJ6gF7lLhIQDRe5N8jo4PNbCX2htr7g RtIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=KFAxS2rd; 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 a21si4475743ejc.736.2021.04.16.06.51.07; Fri, 16 Apr 2021 06:51:31 -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=KFAxS2rd; 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 S243085AbhDPMrw (ORCPT + 99 others); Fri, 16 Apr 2021 08:47:52 -0400 Received: from smtprelay-out1.synopsys.com ([149.117.87.133]:42242 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242906AbhDPMrv (ORCPT ); Fri, 16 Apr 2021 08:47:51 -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 C141EC06B9; Fri, 16 Apr 2021 12:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1618577247; bh=FxOfx5Bn8qkUjQt47mpov0RocJvJwOaxj7tZCSw43H0=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=KFAxS2rdE957emANNFHgpcuDP1iPbikPhu/05rhjrpA8uoJFVXNuFIjrDdGSwOF1W vZIt72IDhbLHmgeAXjWzMtnnnh3iyUvaKXj1WLU/LRzbTGV2kNxCmdQcFESE2WbzRu Y7be61lDxItx4FSEcmKkgwzimKi7UDW2YoFmgSyadWf1aP+oSRvf2YXsgf3NuxOBQ+ 1W1ijWuTKYEQQsS8k4MszPWGzGTecruNE7ij/DKhpoQwSBT1CU4igFF4MqG+glQUEI iNZCU/63ZWiS3I3Qwe6QxXdR6BsF4TA2gEY8PVncVYjySj2ZumS9oW/ezyCo1uu2Wu WWVrimHXEXIrw== 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 B6F17A005C; Fri, 16 Apr 2021 12:47:23 +0000 (UTC) Received: by razpc-HP (sSMTP sendmail emulation); Fri, 16 Apr 2021 16:47:22 +0400 Date: Fri, 16 Apr 2021 16:47:22 +0400 In-Reply-To: References: X-SNPS-Relay: synopsys.com From: Artur Petrosyan Subject: [PATCH v2 05/15] usb: dwc2: Allow exiting hibernation from gpwrdn rst detect To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: John Youn , Artur Petrosyan , Minas Harutyunyan Message-Id: <20210416124723.B6F17A005C@mailhost.synopsys.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When device cable is disconnected core receives suspend interrupt and enters hibernation. After entering into hibernation GPWRDN_RST_DET and GPWRDN_STS_CHGINT interrupts are asserted. Allowed exit from gadget hibernation from GPWRDN_RST_DET by checking only linestate. Changed the return type of "dwc2_handle_gpwrdn_intr()" function from void to int because exit from hibernation functions have a return value. Signed-off-by: Artur Petrosyan Acked-by: Minas Harutyunyan --- drivers/usb/dwc2/core_intr.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c index 27d729fad227..f8963c0cf6af 100644 --- a/drivers/usb/dwc2/core_intr.c +++ b/drivers/usb/dwc2/core_intr.c @@ -751,10 +751,11 @@ static inline void dwc_handle_gpwrdn_disc_det(struct dwc2_hsotg *hsotg, * The GPWRDN interrupts are those that occur in both Host and * Device mode while core is in hibernated state. */ -static void dwc2_handle_gpwrdn_intr(struct dwc2_hsotg *hsotg) +static int dwc2_handle_gpwrdn_intr(struct dwc2_hsotg *hsotg) { u32 gpwrdn; int linestate; + int ret = 0; gpwrdn = dwc2_readl(hsotg, GPWRDN); /* clear all interrupt */ @@ -778,17 +779,27 @@ static void dwc2_handle_gpwrdn_intr(struct dwc2_hsotg *hsotg) if (hsotg->hw_params.hibernation && hsotg->hibernated) { if (gpwrdn & GPWRDN_IDSTS) { - dwc2_exit_hibernation(hsotg, 0, 0, 0); + ret = dwc2_exit_hibernation(hsotg, 0, 0, 0); + if (ret) + dev_err(hsotg->dev, + "exit hibernation failed.\n"); call_gadget(hsotg, resume); } else { - dwc2_exit_hibernation(hsotg, 1, 0, 1); + ret = dwc2_exit_hibernation(hsotg, 1, 0, 1); + if (ret) + dev_err(hsotg->dev, + "exit hibernation failed.\n"); } } } else if ((gpwrdn & GPWRDN_RST_DET) && (gpwrdn & GPWRDN_RST_DET_MSK)) { dev_dbg(hsotg->dev, "%s: GPWRDN_RST_DET\n", __func__); - if (!linestate && (gpwrdn & GPWRDN_BSESSVLD)) - dwc2_exit_hibernation(hsotg, 0, 1, 0); + if (!linestate) { + ret = dwc2_exit_hibernation(hsotg, 0, 1, 0); + if (ret) + dev_err(hsotg->dev, + "exit hibernation failed.\n"); + } } else if ((gpwrdn & GPWRDN_STS_CHGINT) && (gpwrdn & GPWRDN_STS_CHGINT_MSK)) { dev_dbg(hsotg->dev, "%s: GPWRDN_STS_CHGINT\n", __func__); @@ -800,6 +811,8 @@ static void dwc2_handle_gpwrdn_intr(struct dwc2_hsotg *hsotg) */ dwc_handle_gpwrdn_disc_det(hsotg, gpwrdn); } + + return ret; } /* -- 2.25.1