From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BF83C3DA7F for ; Mon, 5 Aug 2024 13:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=X9P4czSK6fIbYzvn/B5k9XKXK9BpzR8ey6Rf0GT8ztw=; b=dUsRd0dOjjXqF0IUXgHLM5Tbl8 c7894ID3mRDiY0GNkqEamRGh+c0eSNZIniPIrsxvok2q2yRYcnFuXIEVLNGzvgGYi18NFpEczBooG LBdbSAbWLihed2lKT5O180HmG+csWvWAcw7jBdnDE7Hd5UBFrD6kVDN2f8DSUh7VEtgR29KGARX5Z gJh84Q2+OAhDyXrStD2Qa0m5X/ODiX1Z8ug9vKQrJV4DEQVijfR8fIzChaGhTYzAdzY6Yueh5t68C HrAHEb0rBzackowOziGLl2vvNTHo0cbBS0HgjSbW+J5pWaUe0Xi4w40oj5ndYPPW2Pz7hctzPwBee uoDss9GQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1saxyq-0000000Fzdq-3HhP; Mon, 05 Aug 2024 13:42:32 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1saxyK-0000000FzWS-2tsb for linux-arm-kernel@lists.infradead.org; Mon, 05 Aug 2024 13:42:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8702260C47; Mon, 5 Aug 2024 13:41:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 039F3C32782; Mon, 5 Aug 2024 13:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722865319; bh=iTK51eVs3lIrDUEMAnPJgIK0M1ZWpTpCLF/jpClvAuM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=s0nU9vy22dh3PXweEa8DUwGXbYBl0DZe3NFoL5yI8om5TDVe7iULiWjljN2IyJKl/ vu0hWSjfhuHkFdHnQwccEWHKr3aJQL/9n2pR0kUK2+zFV+l+8hO7rz+I6y21zsIw3C a2zgdFlBfT1a4yb2i/R+jMSIRQTT7njDnCKbIPKl913TDEpVOcr3FdZeKwL2lTrhxF BIkQjV5XizxCUfoM2puYE5pynK6SnX9j2itUSFaDahhix1fF4H11YuEEXtvKQCLGnJ kcWFhIR8Jlv1yjXfpeCJUSdohkKOEuUYBuDvlMrwZPQ1Unof3IwZcH20nKX4oA55W+ ADEvBcyDRwevA== Message-ID: <1cd45625-84e4-43aa-ae2b-a59f10add898@kernel.org> Date: Mon, 5 Aug 2024 16:41:52 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 09/12] xhci: introduce xhci->lost_power flag To: =?UTF-8?Q?Th=C3=A9o_Lebrun?= , Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Chen , Pawel Laszczak , Mathias Nyman , Nishanth Menon , Vignesh Raghavendra , Tero Kristo Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kevin Hilman , =?UTF-8?Q?Gr=C3=A9gory_Clement?= , Thomas Petazzoni References: <20240726-s2r-cdns-v5-0-8664bfb032ac@bootlin.com> <20240726-s2r-cdns-v5-9-8664bfb032ac@bootlin.com> Content-Language: en-US From: Roger Quadros In-Reply-To: <20240726-s2r-cdns-v5-9-8664bfb032ac@bootlin.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_064200_887547_B2439B17 X-CRM114-Status: GOOD ( 26.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 26/07/2024 21:17, Théo Lebrun wrote: > The XHCI_RESET_ON_RESUME quirk allows wrappers to signal that they > expect a reset after resume. It is also used by some to enforce a XHCI > reset on resume (see needs-reset-on-resume DT prop). > > Some wrappers are unsure beforehands if they will reset. Add a mechanism > to signal *at resume* if power has been lost. Parent devices can set > this flag, that defaults to the XHCI_RESET_ON_RESUME value. > > The XHCI_RESET_ON_RESUME quirk still triggers a runtime_pm_get() on the > controller. This is required as we do not know if a suspend will > trigger a reset, so the best guess is to avoid runtime PM. > > Reset the xhci->lost_power value each time in xhci_resume(), making it > safe for devices to only set lost_power on some resumes. > > Signed-off-by: Théo Lebrun > --- > drivers/usb/host/xhci.c | 8 +++++++- > drivers/usb/host/xhci.h | 6 ++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c > index 0a8cf6c17f82..2c9b32d339f9 100644 > --- a/drivers/usb/host/xhci.c > +++ b/drivers/usb/host/xhci.c > @@ -1029,9 +1029,12 @@ int xhci_resume(struct xhci_hcd *xhci, pm_message_t msg) > > spin_lock_irq(&xhci->lock); > > - if (hibernated || xhci->quirks & XHCI_RESET_ON_RESUME || xhci->broken_suspend) > + if (hibernated || xhci->lost_power || xhci->broken_suspend) Why not treat xhci->lost_power and xhci->quriks & XHCI_RESET_ON_RESUME independently? XHCI_RESET_ON_RESUME is sued by devices that know they always need to be reset on resume. xhci->lost_power is used by devices that don't have consistent behavior. > reinit_xhc = true; > > + /* Reset to default value, parent devices might correct it at next resume. */ > + xhci->lost_power = !!(xhci->quirks & XHCI_RESET_ON_RESUME); > + then you don't need to do this. > if (!reinit_xhc) { > /* > * Some controllers might lose power during suspend, so wait > @@ -5228,6 +5231,9 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) > if (get_quirks) > get_quirks(dev, xhci); > > + /* Default value, that can be corrected at resume. */ > + xhci->lost_power = !!(xhci->quirks & XHCI_RESET_ON_RESUME); > + nor this. > /* In xhci controllers which follow xhci 1.0 spec gives a spurious > * success event after a short transfer. This quirk will ignore such > * spurious event. > diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h > index ebd0afd59a60..ec7c6061363f 100644 > --- a/drivers/usb/host/xhci.h > +++ b/drivers/usb/host/xhci.h > @@ -1640,6 +1640,12 @@ struct xhci_hcd { > unsigned broken_suspend:1; > /* Indicates that omitting hcd is supported if root hub has no ports */ > unsigned allow_single_roothub:1; > + /* > + * Signal from upper stacks that we lost power during system-wide > + * suspend. Its default value is based on XHCI_RESET_ON_RESUME, meaning > + * it is safe for wrappers to not modify lost_power at resume. > + */ > + unsigned lost_power:1; > /* cached extended protocol port capabilities */ > struct xhci_port_cap *port_caps; > unsigned int num_port_caps; > -- cheers, -roger