Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp985574pxv; Thu, 15 Jul 2021 22:03:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9TJzeAgXqfLvOOlZeayxpyi1Bta9hP3Y7tOF1V7tnIGuzoeUX3AQiCs4SWgC4ei68cmOD X-Received: by 2002:a17:906:b0d1:: with SMTP id bk17mr9686894ejb.59.1626411790333; Thu, 15 Jul 2021 22:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626411790; cv=none; d=google.com; s=arc-20160816; b=SEjvcMeEpNgODmc9iLfF8zCsRAnOuAjGpwK/m3G5syuYgoAy1sDdv4hv/X/fJxf/HG EypKOourBGfAvqgvJgM19rOK3Wv6dAkrqtOqzUg239AripIToOEjxe0VIpbEyK6tWTaS SMZMtqDgciUGitOvdMPkPtqgyTXe+rKfqpxVZJvL9ykhdAxlrYxmMI0leIXj8oxGrrtx VpK/IIfPBjtElDUu8wsDxV5qo4uk9gBufMl4f5NwAhIBOBJ4HIHyBbkl5qO9sipu0/es H8gbsrfXXys5tuau3p3gRR1GtUAV77FLkJAEV0TFmG2DFHP0rvM8OncX0gY311ru0uZw 1vrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:message-id:date:subject:cc :to:from:dkim-signature:dkim-filter; bh=tlnKnhtiuN5X69bO+zZbqtZ5WXVcvvkwRcRObs1MPDY=; b=T4yahPWZPvHoZ2WLHBYdM9Lkw2ObJYGwrIPLKh9nldf+z50MDkFwUUs5H2Nq8O4jwE lUYBH2bWcj2vbHbBhdkf+7CvBcsRUEz7fU8pWTeaFZ38MIkvvaxbyLx1AFr/QFsaG/Oi fPQ921P75vykCQ8bPWuoFrm91YjA2V2+jYObwVFzgrEgPG3jxHo/1brHBoEmo1hYGnFk u9/BBjqj0FAuDJkiZnrISjPRlRlmiXY9D8vAgL1cjLmdNs+NiRoWaSuIM079ekteYX59 WN6q8vmFM4xOImZjwR2+Vh4bYd7mtNiYY2eQkaPyWqX1RrIQxxltbFTXloFuHJOsuySt E+DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=iJ4j4jRP; 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=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p13si9773488edx.221.2021.07.15.22.02.46; Thu, 15 Jul 2021 22:03:10 -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=@samsung.com header.s=mail20170921 header.b=iJ4j4jRP; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbhGPFEa (ORCPT + 99 others); Fri, 16 Jul 2021 01:04:30 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:29733 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbhGPFEa (ORCPT ); Fri, 16 Jul 2021 01:04:30 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20210716050134euoutp01bb5b94068bcbc3029e5e0fe71147046c~SLNGh3P3b1031610316euoutp01t for ; Fri, 16 Jul 2021 05:01:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20210716050134euoutp01bb5b94068bcbc3029e5e0fe71147046c~SLNGh3P3b1031610316euoutp01t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1626411694; bh=tlnKnhtiuN5X69bO+zZbqtZ5WXVcvvkwRcRObs1MPDY=; h=From:To:Cc:Subject:Date:References:From; b=iJ4j4jRPItwyKhnYGRLBU19LK0E3pyJsvJ4ld1V6eZnbp8+k+l3sQqst9hUXjOYrp tyu2ebV9il0VM+ecWFWHXk/Jo9+2GVAU/Ybm2fRW4lUqT5ed+lzcY9queAj6EhxgTS iYaKdmsQmRZUV4L79Pv6gG36kErtGZExgo2lZXmU= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20210716050133eucas1p1a8635c11b814b4b831610b2febd77f93~SLNGJ9k7I2287522875eucas1p1H; Fri, 16 Jul 2021 05:01:33 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 56.60.42068.DA211F06; Fri, 16 Jul 2021 06:01:33 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20210716050132eucas1p285949f9a73764b173c29ad0fa8502f23~SLNFIrIWE0138901389eucas1p2x; Fri, 16 Jul 2021 05:01:32 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210716050132eusmtrp1e7e85bfbdd812b3043d7b211ef2958c9~SLNFH_zkQ1937119371eusmtrp1k; Fri, 16 Jul 2021 05:01:32 +0000 (GMT) X-AuditID: cbfec7f4-c89ff7000002a454-a0-60f112ad36d1 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1F.14.20981.CA211F06; Fri, 16 Jul 2021 06:01:32 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210716050132eusmtip1e14cbdb21a1f293aacdd2cb276f51aed~SLNEnnoAG0836508365eusmtip1U; Fri, 16 Jul 2021 05:01:32 +0000 (GMT) From: Marek Szyprowski To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Minas Harutyunyan , Felipe Balbi , Artur Petrosyan , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski Subject: [PATCH] usb: dwc2: Skip clock gating on Samsung SoCs Date: Fri, 16 Jul 2021 07:01:27 +0200 Message-Id: <20210716050127.4406-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djPc7prhT4mGPxsMbDovWNisXHGelaL +TeTLBp/7WW3OH9+A7vF5V1z2CxmnN/HZLFoWSuzxdojd9kdOD02repk85h3MtCjb8sqRo8t +z8zenzeJBfAGsVlk5Kak1mWWqRvl8CVcXNeN1PBbpmK88v/MjcwzhfvYuTkkBAwkfjes465 i5GLQ0hgBaNET8sURpCEkMAXRonLn60g7M+MEk0TGWEa1u9dygjRsJxRYsbCDlYIB6jhwok5 LCBVbAKGEl1vu9hAbBGBBIkjm98zg9jMAjOZJLqmCoDYwgK2EuvXLGQHsVkEVCWWfz3JCmLz CthIrPm0nQVim7zE6g0HwM6TEOjlkPi0dT07RMJF4ubSg1BFwhKvjm+BistInJ7cwwLR0Mwo 8fDcWnYIpwfon6YZUE9YS9w59wvoPA6gkzQl1u/Shwg7Srye18kKEpYQ4JO48VYQ4mg+iUnb pjNDhHklOtqEIKrVJGYdXwe39uCFS8wQtofEzqWzoaEYK/Hi40+2CYxysxB2LWBkXMUonlpa nJueWmyUl1quV5yYW1yal66XnJ+7iRGYGE7/O/5lB+PyVx/1DjEycTAeYpTgYFYS4V1q9DZB iDclsbIqtSg/vqg0J7X4EKM0B4uSOG/SljXxQgLpiSWp2ampBalFMFkmDk6pBqZex78ikx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bmF7IfHh6e61m55v7fjbv/R7Zn i+rdF7qdVcM9edexf+xyc7bwvoi2Xdjz/ed6v71XZnpcvufft2XaF5slDRutNlWtYEptmPQw 7a5t7pWtHao8Mj327toHJbUd/qq4VZl8eP98w9bJZom9ykbnb7/YytbR0uEktp/TPPlduKNv 4Ja8TJ67+jZeD5acPPqq4/jmS7lf5px9cm5JsEDd1SWPblQFfYiynntb44bn35nbuq6KfJ/w yDjTl/PDTh8GJZbijERDLeai4kQAy8uLwtMCAAA= X-CMS-MailID: 20210716050132eucas1p285949f9a73764b173c29ad0fa8502f23 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20210716050132eucas1p285949f9a73764b173c29ad0fa8502f23 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20210716050132eucas1p285949f9a73764b173c29ad0fa8502f23 References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.") Signed-off-by: Marek Szyprowski --- 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(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index ab6b815e0089..483de2bbfaab 100644 --- 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; diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c index a5ab03808da6..a5c52b237e72 100644 --- 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(struct dwc2_hsotg *hsotg) * 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); } /* diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 035d4911a3c3..2a7828971d05 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3338,7 +3338,8 @@ int dwc2_port_suspend(struct dwc2_hsotg *hsotg, u16 windex) * 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_hcd *hcd) * 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); diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 67c5eb140232..59e119345994 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -76,6 +76,7 @@ static void dwc2_set_s3c6400_params(struct dwc2_hsotg *hsotg) 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; } -- 2.17.1