Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp511194pxb; Thu, 7 Apr 2022 11:11:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd18RqY+vQ3VmcHETF/vJLDmT0oLRDULM5/aH79oxNLkjQjAXvDsul8a/P7yH8IrjHSaYQ X-Received: by 2002:a50:e79b:0:b0:41c:dd2c:3e19 with SMTP id b27-20020a50e79b000000b0041cdd2c3e19mr15559407edn.291.1649355081437; Thu, 07 Apr 2022 11:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649355081; cv=none; d=google.com; s=arc-20160816; b=LcTLrnv7ot68sgVRWfro6xoHfQuMbEDURV1ACEZ3yZN1w/exweaZzkNfeFW98AjoLb lEYQIleIrOo914NxPeGHDKdXsXAW0iOw2OEIX/KP38396nvWyjjV3bkAHVodovhOppb7 KcZOBKTYlcG2aDOklfQ/iES6ccvhqOu/zcXdjiZm86b5vt/Cijf/ovA0XaJuZ/P9/6IA YBAe/0kSFUW07OKdVKU/yPG7zUOQum7LAv2a9SXPVkzUUAqMtSwopiEO0LNfY5GQ3tWF ya59Jdzz75JE78Jl0/uYJ3f+ApXxQXRj6gQjDh2p/MD2A0JSIiD0/8oxlQ3bJyRUDjNp 9Gxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=3SXvREJFQK30yjxlwPsRWWRCeZShn1HiodN6fSMvN10=; b=atwCG0O5XVmRxIaN/LUrqGYgoW3NzuQE+B0NyLBYGPN7xJQtN3Y1/lScebnfEQgfZY Vh0yfyfxiXsSna6EcB8P2vF3yUwe4up05sS1p1tQvvWnTKLU5zHXjASzMTfvLVF41I3x K3gRCqBjWAuqec/X+B9DxG57gmK6MJNSl/B2PdR4/GpyUu6oNhpyEs66pi2Jas5tMfCd ZQzNCdw2mjvM9/9LMFrvM0uYXgbXIYZhUhFVoEZoc7AfC26KD1DI+hlBw24e040bRYcM ePQ6c06bqbb+FFinHrdZpfxAyvQlkwauXrRNLxIgNBNu2HZlDKf2aa2USX0KAwpPbYJw +9Ow== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l20-20020a50d6d4000000b0041cf3bb1be6si4360752edj.545.2022.04.07.11.10.54; Thu, 07 Apr 2022 11:11:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240978AbiDGGRh (ORCPT + 99 others); Thu, 7 Apr 2022 02:17:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233185AbiDGGRg (ORCPT ); Thu, 7 Apr 2022 02:17:36 -0400 Received: from ZXSHCAS2.zhaoxin.com (ZXSHCAS2.zhaoxin.com [203.148.12.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C4D71F047C; Wed, 6 Apr 2022 23:15:35 -0700 (PDT) Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHCAS2.zhaoxin.com (10.28.252.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 7 Apr 2022 14:15:31 +0800 Received: from [10.29.8.49] (10.29.8.49) by zxbjmbx1.zhaoxin.com (10.29.252.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 7 Apr 2022 14:15:30 +0800 Message-ID: Date: Thu, 7 Apr 2022 14:15:29 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] USB:Fix ehci infinite suspend-resume loop issue in zhaoxin Content-Language: en-US To: Alan Stern CC: , , , , , , References: <3d0ae3ca-9dad-bb8f-5c41-45bdcb07b9cd@zhaoxin.com> <320584eb-ef89-3759-509c-e7e9cb10f983@zhaoxin.com> From: "WeitaoWang-oc@zhaoxin.com" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.29.8.49] X-ClientProxiedBy: ZXSHCAS2.zhaoxin.com (10.28.252.162) To zxbjmbx1.zhaoxin.com (10.29.252.163) X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,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 2022/4/7 00:20, Alan Stern wrote: > On Wed, Apr 06, 2022 at 10:38:28AM +0800, WeitaoWang-oc@zhaoxin.com wrote: >> On 2022/4/6 00:02, Alan Stern wrote: >>> In fact, the resume kernel doesn't call ehci_resume at all. Here's what >>> it does: >>> >>> The resume kernel boots; >>> >>> If your patch causes STS_PCD to be set at this point, the flag >>> should get cleared shortly afterward by ehci_irq; >>> >>> ehci-hcd goes into runtime suspend; >>> >>> The kernel reads the system image that was stored earlier when >>> hibernation began; >>> >>> After the image is loaded, the system goes into the freeze >>> state (this does not call any routines in ehci-hcd); >> On this phase, pci_pm_freeze will be called for pci device. In this >> function, pm_runtime_resume will be called to resume already >> runtime-suspend devices. which will cause ehci_resume to be called. >> Thus STS_PCD flag will be set in ehci_resume function. > > Aha! I was missing that piece of information, thanks. > > But this still doesn't explain why check_root_hub_suspended is failing. > That routine checks the HCD_RH_RUNNING bit, which gets set in > hcd_bus_resume. hcd_bus_resume gets called as part of resuming the root > hub, and in ehci-hcd this happens when ehci_irq sees that STS_PCD is set > and calls usb_hcd_resume_root_hub. That routine queues a wakeup request > on the pm_wq work queue, which is then supposed to run hcd_resume_work > to actually restart the root hub. > > But pm_wq is a freezable work queue! While the system is in the freeze > state, the work queue isn't running. This means that the root hub > should remain suspended until the end of the freeze phase, and so the > call to check_root_hub_suspended should succeed. > > Can you check to see what's really happening on your system? Something > must be wrong with my analysis, but I can't tell what it is. I'm still > puzzled. > > Alan Stern Your analysis is right, my test platform's kernel version is not the latest, this kernel not call freeze_kernel_threads on software_resume function. (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/kernel/power/hibernate.c?h=v5.18-rc1&id=2351f8d295ed63393190e39c2f7c1fee1a80578f) So pm_wq is active and can handle root hub power events. Update my kernel to fix the issue in the url above, system hibernation test was successful with our patch(not clear STS_PCD bit). Thanks for your clarification. Weitao Wang