Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp295702pxb; Thu, 14 Apr 2022 23:04:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxvlWClt1ZOBGwHPWLWmDvxa9PYqRYphKdmf2Iz319JsYRZvykkQH+wrnjUQkOi5pdkNZh X-Received: by 2002:a05:6402:84e:b0:422:b76c:bef8 with SMTP id b14-20020a056402084e00b00422b76cbef8mr168712edz.238.1650002693448; Thu, 14 Apr 2022 23:04:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650002693; cv=none; d=google.com; s=arc-20160816; b=DoVWov6RMd9uuFVL9qhTbDZqoNw+j2uKLpUaHbnPLI8eDXwrJWxmITRvnH8qfmg+0Z b8MURhTBfKYBxpx4JA5uBYf59DVYJ07942tIS63il0dS3DU1AuQr8P7TeWrrtDfQf9Ck qA2PLMhdg26bcWTWWt46DPpmnYahuGLlrBdMMnla3B/8schoU+mmVAFIlKnNdi08WLZ/ 3oo3igmg0EpiXPhIjJOJlsdr0mNk3DLPQuWvwP6m2KVfnUJGPqBaKDVWJUuKnZLCUx1L +XD0KIlj4g/Ngb0cxJBR3B5U1TcdRnwlHYQ/KaihskCbmvw4uuVSMmoqS2WmDpdS2q4B n5Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=DpfIGRDdHv3Cp4632fXusbHpM4XCS+FW85MmPIrL314=; b=I0ZTaUY+3IvVm+14/XEBYmNxNg03tlJUvwjknnHR8VFl6gEoAvfyGDB1pa5u6iqYX0 h6JgNGGC2lTKV1nT+tg+IPuy9MqbQHQB+cdRUFM78GBkZdyochgiDEzHYpkypyH0TfZE 3SdWph5dZXr1Oo755QeXlrO9dADzNukFTFirTFCaaM98iNAnydumP+oo5El5+COLYtCf E2dav7wX60BJUeVOVPz92xjaEAu8MV/JqwhHAPWamVx+wHO04hm/dYTNTACaFqz3j3mv ZZl0NfwM0CRDSeJBBMgClsbxrVTs/TutjF9/w1qOb8zyGKXdX7JSr5kk0+ie5BiIBF4O jaCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RfMoz9ZB; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a170906780800b006df76385d57si415407ejm.503.2022.04.14.23.04.12; Thu, 14 Apr 2022 23:04:53 -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=@intel.com header.s=Intel header.b=RfMoz9ZB; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232154AbiDNPZk (ORCPT + 99 others); Thu, 14 Apr 2022 11:25:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348105AbiDNOCM (ORCPT ); Thu, 14 Apr 2022 10:02:12 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F39F5D672; Thu, 14 Apr 2022 06:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649944701; x=1681480701; h=to:cc:references:from:subject:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=VmrXDG9iJKewRIG8lSEXIl4FCcpuFmOe4gRwKxCybl4=; b=RfMoz9ZBhmLCfkBbLiYpwQz0khne0f906HyRjFYDD/w5x8hL4r/OAQR7 bu8RKcz8d2xBuRY7wkEa2b6sI29QN8/0JTAkI3mJPu5UVcl+f5LjqpxzH WAgHxmTt/SHTOwcavwI4zl76AqoaTR03B2Mx+pUhX5McSOhEdoK9IjrZP P0hU948fNn3JGhynDK3DwoRpE++NIZT1X/UUHnQWkAk+frB+UjLo5r7nr Naa1JF3m+GwNe+/pM5pfUbHS/hDi4iWpL/+38HgMfV3VxlNgt0JIb3zYn 3CQ0CWKGlmYjL8CZkJuY8P4/A1vN5nXj1O7laU2x0hweHdwrXheEUocFF A==; X-IronPort-AV: E=McAfee;i="6400,9594,10316"; a="262686545" X-IronPort-AV: E=Sophos;i="5.90,259,1643702400"; d="scan'208";a="262686545" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2022 06:58:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,259,1643702400"; d="scan'208";a="725372894" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.199]) ([10.237.72.199]) by orsmga005.jf.intel.com with ESMTP; 14 Apr 2022 06:58:17 -0700 To: Alan Stern Cc: Evan Green , Greg Kroah-Hartman , Mathias Nyman , Rajat Jain , Thomas Gleixner , Bjorn Helgaas , "Rafael J. Wysocki" , Youngjin Jang , LKML , linux-usb@vger.kernel.org References: <20220407115918.1.I8226c7fdae88329ef70957b96a39b346c69a914e@changeid> <022a50ac-7866-2140-1b40-776255f3a036@linux.intel.com> <4353a956-9855-9c14-7dbf-bf16580abe32@linux.intel.com> From: Mathias Nyman Subject: Re: [PATCH] USB: hcd-pci: Fully suspend across freeze/thaw cycle Message-ID: Date: Thu, 14 Apr 2022 17:00:12 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On 12.4.2022 18.40, Alan Stern wrote: > On Tue, Apr 12, 2022 at 05:56:42PM +0300, Mathias Nyman wrote: >> On 11.4.2022 17.50, Alan Stern wrote: >>> For example, what would happen if the user unplugs a device right in the >>> middle of the freeze transition, after the root hub has been frozen but >>> before the controller is frozen? We don't want such an unplug event to >>> prevent the system from going into hibernation -- especially if the root >>> hub was not enabled for wakeup. >> >> We should be able to let system go to hibernate even if we get a disconnect >> interrupt between roothub and host controller freeze. >> Host is not yet suspended so no PME# wake is generated, only an interrupt. >> >> From Linux PM point of view it should be ok as well as the actual xhci >> device that is generating the interrupt is hasnt completer freeze() >> >> The xhci interrupt handler just needs to make sure that the disconnect >> isn't propagated if roothub is suspended and wake on disconnect >> is not set. And definitely make sure xhci doesn't start roothub polling. >> >> When freeze() is called for the host we should prevent the host from >> generating interrupts. > > I guess that means adding a new callback. Or we could just suspend the > controller, like Evan proposed originally Suspending the host in freeze should work. It will do an extra xhci controller state save stage, but that should be harmless. But is there really a need for the suggested noirq part? + .freeze_noirq = hcd_pci_suspend_noirq, That will try to set the host to PCI D3 state. It seems a bit unnecessary for freeze. > >>> (If the root hub _is_ enabled for wakeup then it's questionable. >>> Unplugging a device would be a wakeup event, so you could easily argue >>> that it _should_ prevent the system from going into hibernation. After >>> all, if the unplug happened a few milliseconds later, after the system >>> had fully gone into hibernation, then it would cause the system to wake >>> up.) >>> >>>> Would it make sense prevent xHCI interrupt generation in the host >>>> freeze() stage, clearing the xHCI EINT bit in addition to calling >>>> check_roothub_suspend()? >>>> Then enable it back in thaw() >>> >>> That won't fully eliminate the problem mentioned in the preceding >>> paragraphs, although I guess it would help somewhat. >> >> Would the following steps solve this? >> >> 1. Disable device initiated resume for connected usb devices in freeze() >> >> 2. Don't propagate connect or OC changes if roothub is suspended and port wake >> flags are disabled. I.E don't kick roothub polling in xhci interrupt >> handler here. > > I guess you can't just halt the entire host controller when only one of > the root hubs is suspended with wakeup disabled. That does complicate > things. But you could halt it as soon as both of the root hubs are > frozen. Wouldn't that prevent interrupt generation? True, but probably easier to just suspend host in freeze() as you stated above. -Mathias