From patchwork Mon Oct 24 11:32:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10091 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp625367wru; Mon, 24 Oct 2022 12:54:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73LwLBvivWX3F4PVgSUF/nWYplVIevARUrifIqTzWZcPFUCM75i2OUIjJPXr3cbV3b0/W7 X-Received: by 2002:a17:90b:384a:b0:213:2907:a528 with SMTP id nl10-20020a17090b384a00b002132907a528mr3608641pjb.183.1666641245781; Mon, 24 Oct 2022 12:54:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666641245; cv=none; d=google.com; s=arc-20160816; b=Nh1u65vBNQ7s7EJBi4YnKJHXhgRTUvNApyXKdXzUBmKINLaOZbI6GeXOT/4kIj/57I HV8FLObR1ESYyXXRMV164Cssk7HwKaXZD6SakD3cTTDTtnI4ToDiEtmrXjLYlOxJKWie juQjaQOG66mwQlza9LBzR2Jy8h0BRpJkAV29SAY09u7VC+K0pBSQsZ+QiREnIkmto42y z2XnA0U+b+xPP8AVlqsPzkMkGUj5gs6625PnkNpgx8yOpYPTRYcHrMdjyNnoIaE0Fw0S SRIvoCowB9UvgEVNk7QZAErVuK89pwF47DBaKMZ2tH7NUnK8OjYBJUQTiK61JQEBnTRC FpEw== 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=lOIMTWlgyilb48cpy6ef2nL+3f4BmSivj+OezN2O+fQ=; b=u9EnGniSXbaZc96onAJtSZ3qILZZcAcgpm3g5YBlydPZ1YHGvJfVcCI2Ssm1esXprF iPvdV1hL4onlpIcGheIKluyitXCnpNhf8a97m82rVeXBbpuysCtSJH/iMGvlclXnGMwJ mNQTGYeBkhzx6XfFh33Fz9hYksdq2KQSqTTBJuDw43AB+03QHtrltAti+OyNvZ1vbc8g GiSpq5cWl+0IJWPXdokFs+YknTPQpFJPMxojYs/0JEFQZR3IP2DU2VwkWTq+D0U4tzsA NJoOvMabOYVu32pgmlq0GJ4qGRcencr8E//xNeGML4Fx6B2vA7B5ZMUvx6KTZD1GneGA DYCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dC8hprsM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a656944000000b00453f9620c4dsi380653pgq.503.2022.10.24.12.53.53; Mon, 24 Oct 2022 12:54:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dC8hprsM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S233768AbiJXTxS (ORCPT + 99 others); Mon, 24 Oct 2022 15:53:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233657AbiJXTwA (ORCPT ); Mon, 24 Oct 2022 15:52:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9349889AC2; Mon, 24 Oct 2022 11:17:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1F705B81212; Mon, 24 Oct 2022 12:32:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DA54C433D6; Mon, 24 Oct 2022 12:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614764; bh=pxzcX1ROjpWKjpZ7QbfdNIYZWj4LiTFYhQyNtt/GFNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dC8hprsMX6D3WhzvG7XXOnMyrX5gb6UWdH7yrVfHC7OJrdD9gCWRjhQPebEKz2Kdu H4P0NCnqTmaJQX7xvkbX4g/Y0imQSW8jHnquqZEIIHlogS+CvbhPvgQDeJ74N9x3vn 7Io8v/BR8eSS920B1hEgLPigsa7z9Imy//a5jwHM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Fainelli , Justin Chen , Sasha Levin Subject: [PATCH 5.10 355/390] usb: host: xhci-plat: suspend and resume clocks Date: Mon, 24 Oct 2022 13:32:32 +0200 Message-Id: <20221024113038.120826036@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747600011004364250?= X-GMAIL-MSGID: =?utf-8?q?1747600011004364250?= From: Justin Chen [ Upstream commit 8bd954c56197caf5e3a804d989094bc3fe6329aa ] Introduce XHCI_SUSPEND_RESUME_CLKS quirk as a means to suspend and resume clocks if the hardware is capable of doing so. We assume that clocks will be needed if the device may wake. Reviewed-by: Florian Fainelli Signed-off-by: Justin Chen Link: https://lore.kernel.org/r/1660170455-15781-2-git-send-email-justinpopo6@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-plat.c | 16 +++++++++++++++- drivers/usb/host/xhci.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index dc570ce4e831..2687662f26b6 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -447,7 +447,16 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) * xhci_suspend() needs `do_wakeup` to know whether host is allowed * to do wakeup during suspend. */ - return xhci_suspend(xhci, device_may_wakeup(dev)); + ret = xhci_suspend(xhci, device_may_wakeup(dev)); + if (ret) + return ret; + + if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) { + clk_disable_unprepare(xhci->clk); + clk_disable_unprepare(xhci->reg_clk); + } + + return 0; } static int __maybe_unused xhci_plat_resume(struct device *dev) @@ -456,6 +465,11 @@ static int __maybe_unused xhci_plat_resume(struct device *dev) struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; + if (!device_may_wakeup(dev) && (xhci->quirks & XHCI_SUSPEND_RESUME_CLKS)) { + clk_prepare_enable(xhci->clk); + clk_prepare_enable(xhci->reg_clk); + } + ret = xhci_priv_resume_quirk(hcd); if (ret) return ret; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 6f16a05b1958..e668740000b2 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1888,6 +1888,7 @@ struct xhci_hcd { #define XHCI_SG_TRB_CACHE_SIZE_QUIRK BIT_ULL(39) #define XHCI_NO_SOFT_RETRY BIT_ULL(40) #define XHCI_EP_CTX_BROKEN_DCS BIT_ULL(42) +#define XHCI_SUSPEND_RESUME_CLKS BIT_ULL(43) unsigned int num_active_eps; unsigned int limit_active_eps;