From patchwork Mon Jul 26 15:39:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 485844 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp3980182jao; Mon, 26 Jul 2021 09:17:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvHdOGUinbTFycY/uC/tlTCOWPNbr5Gde2OiMbhs2pOphR2WLC0/ggKsV7rxxggf95MUs6 X-Received: by 2002:a17:906:9c84:: with SMTP id fj4mr17662087ejc.356.1627316254859; Mon, 26 Jul 2021 09:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627316254; cv=none; d=google.com; s=arc-20160816; b=YoZDGUuOE6919x5cHbU8+ZGc16wRBqG18ZkcoXiLh100V4EvIcNfe58yB7DnmbNjBx Y0j0xnecXHjqOK+MbpR6Bk9eb+2Tf1lUup8RIaZVYNHXwF3m+2ruQ0MHzqcSMi1gZnPk joS9YcCWE4sMigj3Z13W5/OwFJ00N8m0WxMo6cJ8FqDbrclZ4e53rF3Srsk4w5JyBR6w SOFzoI6xetfpIN7roOGkL73Pn2/F+MtT3QQKDR/9hw5pKaaydALl2ebIwu09FY12mCED wc41i+WiVoAiI7yHLY+GKAdqwYiOj8/cSHf7/nbxTjtTA/Fe76QSHzpoTVycG4IroW/W vv4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LyFFVLS9QnWIlSFDmyqxvDKpmua8bAnL3fR73UO5OXs=; b=eDdvbCdekQDuiWTWRsKMthMMUFE7t6vYBFnbuQZ7JCIFAdH09AGi84WvP7i7yJ/mQv /v/LC5cHS9BkZitk2dmHd+dLGvfE5WfkY87sQV0HuTE6dUMgQmPZJk7ius8TbvkzXGhr QmWO3ADHrd3nVXBeqhOpD32c3EtTthxvQD/pmUqqJNauEVlcC6RtiWZoLmj1yIijcLPv Kpsz+S1iyeJyFGN828eNu74gHtQZDSJBBL3R1Yr/R2wfgprCA+ZoAY1B4qOWCt4t5pSg 2nxxnOJo7Mtsd1iYTRD4i0FMvrneQoWYAesO+v/EXOFaZgWaFOnOIFFeQeQpB+9j9xQH lcDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sxSSoLmh; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pv18si289902ejb.567.2021.07.26.09.17.34; Mon, 26 Jul 2021 09:17:34 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b=sxSSoLmh; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235280AbhGZPfU (ORCPT + 12 others); Mon, 26 Jul 2021 11:35:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:51074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234779AbhGZPd5 (ORCPT ); Mon, 26 Jul 2021 11:33:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D24D560F6E; Mon, 26 Jul 2021 16:14:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627316054; bh=2b3PArOjnZazMsR2ZUq+OGH7tjb2qq3jyjIc7tFW/w4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sxSSoLmhm1sB3Gv6cqalxw0dwcddbOAxNxlaMYF44v+9TQ9+PY+dxzmclxuEl85IC pjt3zB+3wJhTrBmYX+a2Jb8A2JbIk+MS71rkI1+DIhhStgkkvM2AV1d7QTpgIgH2A+ VI2/b1+WTMg6JEEVTTi86QVW88hQfM8T6mp/Y/pE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Marek Szyprowski Subject: [PATCH 5.13 170/223] usb: dwc2: Skip clock gating on Samsung SoCs Date: Mon, 26 Jul 2021 17:39:22 +0200 Message-Id: <20210726153851.763379342@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153846.245305071@linuxfoundation.org> References: <20210726153846.245305071@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marek Szyprowski commit c4a0f7a6ab5417eb6105b0e1d7e6e67f6ef7d4e5 upstream. Commit 0112b7ce68ea ("usb: dwc2: Update dwc2_handle_usb_suspend_intr function.") changed the way the driver handles power down modes in a such way that it uses clock gating when no other power down mode is available. This however doesn't work well on the DWC2 implementation used on the Samsung SoCs. When a clock gating is enabled, system hangs. It looks that the proper clock gating requires some additional glue code in the shared USB2 PHY and/or Samsung glue code for the DWC2. To restore driver operation on the Samsung SoCs simply skip enabling clock gating mode until one finds what is really needed to make it working reliably. Fixes: 0112b7ce68ea ("usb: dwc2: Update dwc2_handle_usb_suspend_intr function.") Cc: stable Acked-by: Krzysztof Kozlowski Signed-off-by: Marek Szyprowski Link: https://lore.kernel.org/r/20210716050127.4406-1-m.szyprowski@samsung.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/dwc2/core.h | 4 ++++ drivers/usb/dwc2/core_intr.c | 3 ++- drivers/usb/dwc2/hcd.c | 6 ++++-- drivers/usb/dwc2/params.c | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -383,6 +383,9 @@ enum dwc2_ep0_state { * 0 - No (default) * 1 - Partial power down * 2 - Hibernation + * @no_clock_gating: Specifies whether to avoid clock gating feature. + * 0 - No (use clock gating) + * 1 - Yes (avoid it) * @lpm: Enable LPM support. * 0 - No * 1 - Yes @@ -480,6 +483,7 @@ struct dwc2_core_params { #define DWC2_POWER_DOWN_PARAM_NONE 0 #define DWC2_POWER_DOWN_PARAM_PARTIAL 1 #define DWC2_POWER_DOWN_PARAM_HIBERNATION 2 + bool no_clock_gating; bool lpm; bool lpm_clock_gating; --- a/drivers/usb/dwc2/core_intr.c +++ b/drivers/usb/dwc2/core_intr.c @@ -556,7 +556,8 @@ static void dwc2_handle_usb_suspend_intr * If neither hibernation nor partial power down are supported, * clock gating is used to save power. */ - dwc2_gadget_enter_clock_gating(hsotg); + if (!hsotg->params.no_clock_gating) + dwc2_gadget_enter_clock_gating(hsotg); } /* --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3338,7 +3338,8 @@ int dwc2_port_suspend(struct dwc2_hsotg * If not hibernation nor partial power down are supported, * clock gating is used to save power. */ - dwc2_host_enter_clock_gating(hsotg); + if (!hsotg->params.no_clock_gating) + dwc2_host_enter_clock_gating(hsotg); break; } @@ -4402,7 +4403,8 @@ static int _dwc2_hcd_suspend(struct usb_ * If not hibernation nor partial power down are supported, * clock gating is used to save power. */ - dwc2_host_enter_clock_gating(hsotg); + if (!hsotg->params.no_clock_gating) + dwc2_host_enter_clock_gating(hsotg); /* After entering suspend, hardware is not accessible */ clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -76,6 +76,7 @@ static void dwc2_set_s3c6400_params(stru struct dwc2_core_params *p = &hsotg->params; p->power_down = DWC2_POWER_DOWN_PARAM_NONE; + p->no_clock_gating = true; p->phy_utmi_width = 8; }