Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1009679pxb; Wed, 6 Apr 2022 06:38:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyF5utIaN+edXNGBH2BV8Xq/QKTqAl6DUaaAkVn9cIleb/DVYlOhqxXgcChqXrz098TLEtN X-Received: by 2002:a17:903:4052:b0:155:fc0b:48fb with SMTP id n18-20020a170903405200b00155fc0b48fbmr8560422pla.27.1649252291975; Wed, 06 Apr 2022 06:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252291; cv=none; d=google.com; s=arc-20160816; b=L+ozt4vKGmWJ6hTMoVGIvoSeLmybV3dzPrYo/fxxljIzVG2wHJS8aR8Obaist68aCg 8Ek4fhEubqU3xxzRlxwZe5ySli8FkCgFXfHHAkCneayvWUGdtMg7RfFzaFboyV9ZiK/j YGvrgComVUH5m0nxvJcqMutk/TsDT55FyGn6+q9iXwZdTmVwgsy+EyYc+vIbpWxML/hq 92+2D5Q2ZXNbWJDtMtZoaCiSu/w3IkeGdgkVZ2VcHxWFNzc70i7xFh2X3dCSK3oaMuFH tEe4vaZNPMkB5vZILmHBp1viT8IPxK1JfTyQDRnqHzVM2VkLBOkIOys/dPUtyj4iFS+x C22w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Ihzg5a4rx6PHuTopk55oPTKUyt8fTjrfjEfN/hVkWDE=; b=wUBiogU8JT3y/IxEL4jw73myJ8vk71slBYmzffV8w8xveTKkRX8CnVAu3SeEBPg4SF 5jtVFK0T2LkZoWO/pjaO8xVVSC3s4OnAOM8FSNvFA05wciwYyyrhiCOQSFPvd9ciB+BI sJCYCOsdpcqz7wPjRyN/+Xt07tTaTiZ3anRoYor/Bg3H5Rg0Hgp2i0HZAIGXC6UfYhCG xnci9XT+HRDLhzo72w/CvVhAqi8R8xnlHCqlblJhpcZYe8inA8Cnzxd/gdSJfks4+kqB fQt4xuYZo7LD2NAq0cJ6GyPcnbb9sjIWjJPFvJvVXtYxnnmVyHcWSrhsj3yCI/FjqsYi pV+g== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l3-20020a635703000000b003816043efdbsi15424550pgb.464.2022.04.06.06.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:38:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 35220B6474; Wed, 6 Apr 2022 04:23:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575882AbiDEXJf (ORCPT + 99 others); Tue, 5 Apr 2022 19:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1457528AbiDEQEh (ORCPT ); Tue, 5 Apr 2022 12:04:37 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id CF27BCD for ; Tue, 5 Apr 2022 09:02:38 -0700 (PDT) Received: (qmail 155879 invoked by uid 1000); 5 Apr 2022 12:02:37 -0400 Date: Tue, 5 Apr 2022 12:02:37 -0400 From: Alan Stern To: "WeitaoWang-oc@zhaoxin.com" Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, CobeChen@zhaoxin.com, TimGuo@zhaoxin.com, tonywwang@zhaoxin.com, weitaowang@zhaoxin.com Subject: Re: [PATCH] USB:Fix ehci infinite suspend-resume loop issue in zhaoxin Message-ID: References: <3d0ae3ca-9dad-bb8f-5c41-45bdcb07b9cd@zhaoxin.com> <320584eb-ef89-3759-509c-e7e9cb10f983@zhaoxin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, Mar 16, 2022 at 10:18:39AM +0800, WeitaoWang-oc@zhaoxin.com wrote: > On 2022/3/15 11:18, Alan Stern wrote: > > On Tue, Mar 15, 2022 at 08:39:09PM +0800, WeitaoWang-oc@zhaoxin.com wrote: > > > I have encountered the following situation if EHCI runtime suspend is > > > enabled by default. Some things about this still confuse me... > > > 1.Wake from system to disk and boot OS. > > > > You're talking about resuming after hibernation, right? > > You're right. > > > 2.EHCI will entry runtime suspend after enumerated by driver during boot > > > phase of suspend to disk > > > > I'm not sure what you mean by "boot phase of suspend to disk". This is > > while the restore kernel is starting up at the beginning of resume from > > hibernation, right? > > > You understood exactly what I was saying. Okay, so we're waking up from hibernation. > > > 3.EHCI will be placed to freeze state and ehci_resume is called after image > > > is loaded. > > > > ehci_resume is called to leave runtime suspend. Going into the freeze > > state doesn't require any changes. 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); The resume kernel transfers control to the image kernel; Now the image kernel is running. It goes into the restore state, which involves calling ehci_resume. Presumably your patch cases the STS_PCD flag to get set at this point. But that's all! The system is now back up, out of hibernation, and running normally. There are no more calls to check_root_hub_suspended > > > 4.If PCD flag is set(caused by patch), then HCD_FLAG_RH_RUNNING will be set. > > > > > > 5.Pci_pm_freeze_noirq is called to check ehci root hub state and return > > > value is -EBUSY. which will cause > > > quiesce phase of suspend to disk fail. > > > > You're talking about check_root_hub_suspended() in hcd-pci.c, right? > > > It's right. So how can this happen, given that the image kernel doesn't call pci_pm_freeze_noirq? Alan Stern