Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1046909pxb; Wed, 6 Apr 2022 07:28:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbwh5kePUmVqKJhgdMsh0sKVSa4UzrVpqc9y2O0B7/gr6Govk8QySOJTNRuvf0YH9ophJz X-Received: by 2002:a05:6a00:114b:b0:4f7:915:3ec3 with SMTP id b11-20020a056a00114b00b004f709153ec3mr9376186pfm.8.1649255317739; Wed, 06 Apr 2022 07:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649255317; cv=none; d=google.com; s=arc-20160816; b=Sqt57hJc4oed7FFe3z0ZV0dAgBiLCYEyvP6N+xohV8nitNMtm8nQI4h0DpS97dBOSw Efd7OBTd6fEK0bdaK+3oYwwQRPa5L8NIO6oLWa//q5bUjnKKYTJWoMHm33FsveOOarTF H8b3tWJEfQCKMP+70CI7YgPze5W2QaaTAOb7lQdrEfyIHR9Vg8FP1TJD0HUTy2cSwO4c AAv96vvN17azadHaMMltSFHJudx9Iap7lYzuiNM17K8ng0YNnLCHaWUQ7ri9ZtWnSBe/ AF0cROxM5zLNpScdVp56JWAqwdJavPfCgXHMzmRaqu8bH3D0s2O8aherwTKM0KSxZQvY 5BTA== 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=7au+vboFkAYaFctxdwSdyXCMIaRGf8Xfu+iJ69JRE/4=; b=egEUk6itFzLkvSvTgHFuShpMglzT+9jIb/O1b+cKXjgmGoP4mosQGiIrEo2gjzmS29 Xw58I5/pd6X/l0CFhRP0saOObYotFHpYpqPl9HTA+977Bv8QFquSG60g/Y7RhwmSXozm mET8/P9dpGB7XDr6THR0nGazQd++yzcUT1rkV6ignFlFHQKXHGOU2aYc2vQhjjlioBVo iCBsfV9+f4VNZ/hcPJp20Iq8d/qGT1/Kt+PKuQ2Arjzj+S94Es/1Cdcg8zYhZ/K0g51T rjr4+253xVHwAg4OwEFGilpstiSp7Pxw+RL9i/LGypX4x3GewR0VOVWXYT8NodxjieHk PX2Q== 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 b75-20020a63344e000000b00398be20ca1csi17129648pga.537.2022.04.06.07.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:28:37 -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 A56564FB6A3; Wed, 6 Apr 2022 05:10:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229906AbiDFMJ3 (ORCPT + 99 others); Wed, 6 Apr 2022 08:09:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232469AbiDFMI3 (ORCPT ); Wed, 6 Apr 2022 08:08:29 -0400 Received: from ZXSHCAS1.zhaoxin.com (ZXSHCAS1.zhaoxin.com [203.148.12.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA0A11A3949; Tue, 5 Apr 2022 19:38:34 -0700 (PDT) Received: from zxbjmbx1.zhaoxin.com (10.29.252.163) by ZXSHCAS1.zhaoxin.com (10.28.252.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 6 Apr 2022 10:38:30 +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; Wed, 6 Apr 2022 10:38:29 +0800 Message-ID: Date: Wed, 6 Apr 2022 10:38:28 +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.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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/6 00:02, Alan Stern wrote: > 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); 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. Thanks Weitao Wang > > 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. > o > 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 > .