Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp806700rwi; Wed, 19 Oct 2022 03:15:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6hLmK9xTnBUzVQdF8QYEufg8VfI8XnHrXDZd7lpDEwFtjD4Wko95sqjqFakv5M5mpXQ84l X-Received: by 2002:a05:6402:5cd:b0:446:5965:f4af with SMTP id n13-20020a05640205cd00b004465965f4afmr6657465edx.12.1666174531535; Wed, 19 Oct 2022 03:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174531; cv=none; d=google.com; s=arc-20160816; b=s24MDFbIs831XMG3PNX9ApuGW/uW9e2etxVNe203M04I73kH2YmMH19t+FWauzypVq vXFoEASaZocAEEMwXnXgZHNkX8H4RJtRDNau43QdnQ9SCcckhOeeCcmEWHD55txfYvDO iyz2xc2oj7FG3+++P6xXXSSEX29AlrZySHeGFFUPb/sX4mfc434SsLfNWXMwRwlvUz+t sQOAgqHYtrhWblMQa6LccIBQ4cTtx8MOWKBkgq8OCDBM5iyLzFVrL1+ZuCN9O2de2rIY 1TaPZhyOsBO3z710hUqDaKhCGCSSsC70MSUyd83pUxzUDAw9WW6itCQ+SzHSjCGFTK5i lBVA== 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=x0N2yxRtUT6+XAXdn0Z2VnXss3cMJQrlmvLLA4Fqsbw=; b=M9zm9AOx7cXFzCR6rhY0/GrvHcQYkNzYW9FzB8vieRZJE50wko72xYF6AB6lqWSdM9 t6G87Xuk21Wc0VdAAbierPT8SfnS2j9hcLM+ZaU+Tu0XkDWeMXpkrg+fTiqBjv64LwBr hoQv9ZUmlIAa7FZnmT7RsO2M4xSNKLNbpsQmLIt3xHvACZvVFKfGS511B+1hlcAjGBuY a67iJcdsHgOjIXZpm57ze6TjIr+Z/5rsG0fr5Woc80EXBON2SHc2FBd2eTlhklJBccOM oqpfX7TL89ZgVNVcNwVTkgz1gRazOr5lAk82viDSKjh9peWlOXgHW6ZsvBEAqizyok/2 NqLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OM4hNUIX; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020aa7cb13000000b0045829a1c0b3si11450217edt.251.2022.10.19.03.15.05; Wed, 19 Oct 2022 03:15:31 -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=OM4hNUIX; 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 S230098AbiJSJgr (ORCPT + 99 others); Wed, 19 Oct 2022 05:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233945AbiJSJ37 (ORCPT ); Wed, 19 Oct 2022 05:29:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62EE5ED9A3; Wed, 19 Oct 2022 02:13:35 -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 dfw.source.kernel.org (Postfix) with ESMTPS id C84CE6170D; Wed, 19 Oct 2022 09:13:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB13DC433C1; Wed, 19 Oct 2022 09:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170814; bh=COvMImI5EhtK7DDUN4rrlXlj6Olbp9bHPrM5fbNPEo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OM4hNUIXnfQ6Pilf9Pkuc91P85yR96sSFtb1emQoIKcLPA1CNjmsflUjF1EYJx1J2 z6lXwmtrVb8ZQ6Lp6BSlnZXdH/KHFW5dztY9EByrz6yCrICaCbs1JnBwc/0EdurDEi fSm6HnEZulO+Gyi4d+zSS98O0bQLFFg0u9oas/aA= 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 6.0 797/862] usb: host: xhci-plat: suspend and resume clocks Date: Wed, 19 Oct 2022 10:34:44 +0200 Message-Id: <20221019083325.121509847@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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 a8641b6536ee..ef10982ad482 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -437,7 +437,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) @@ -446,6 +455,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 7caa0db5e826..6dfbf73ee840 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1899,6 +1899,7 @@ struct xhci_hcd { #define XHCI_NO_SOFT_RETRY BIT_ULL(40) #define XHCI_BROKEN_D3COLD BIT_ULL(41) #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; -- 2.35.1