Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1198542pxb; Wed, 6 Apr 2022 11:06:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytTw9DbvGPbMYttxlqorriLhUF6Ptg3gKROc+XMr216Wc2aDlCPdKxR0PJ1Yc4Fgszsezh X-Received: by 2002:a63:de41:0:b0:398:db26:bb6 with SMTP id y1-20020a63de41000000b00398db260bb6mr8059178pgi.516.1649268363246; Wed, 06 Apr 2022 11:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649268363; cv=none; d=google.com; s=arc-20160816; b=Xwm0B4J4LvYoKBlmG1aYEh7wA+1Nj3/XdebUeCA2/iJOnsGvaQo8nawxYwgWv1YPjU bIxK6NubfC4xlxDsghK74Jo+Ayfe60DvFGxPXUkbTjw6s3wgtvJUYDTtPcJPxZfCYkMK V9bSlwuPFwSOOo/lAESKlvJ3CfGdgFhjR84nF1PJBgZ4GwOCMT3Rfxin3ArXfwuUmMm3 gT8aFfUTtfVp6TBuzYhuCufIIgTxSPbbLsv/v/U9PNgDgHiKaxpDqGNRf71T1perID5a yMSXf0q4Tq/oQYkPYscdoU2MqBaN9p9vCAyVXLq5CL5PMNYZDFOtPR9qeZ60TQHumfIE xscA== 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=lA1wLKl2zJ1XLANFx3B+yZchyjake4fwLFaBzloSIv0=; b=K+cxsA7pE3Klvz3F/EjGJ6uEPswOZf04RJlb8TpGaOLqtGkosjgknhfuZGjUL+EMja KZfdBOVkkd1/KunFbNj+NPWrzHZtaQ7p06yLFtUjk9CqS/ECLmh2PZkC9GLu0yp0UgJ9 T6bSSM+OUhOrUnKIzSjK/n8A+B7xtbhJCuCRXkR/vaub9tSdRKxp/jsQQ1WyOUyaDaap uLFH+z7tOEjxF7lZWygdi/FlrI8WdU/u4iJheE/qFmWAabTOPVdM6Q7N0HbpkZFQCB7Y BYxkrAwFHZEi2/0FFUG3U8qKi2hl6nRvyP9VKCPX+Wq7SjhGbjGTThs2GcOcwZSW16Um h7rQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y11-20020a1709029b8b00b00156af8ef4d0si8295592plp.8.2022.04.06.11.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:06:03 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 49C26CD642; Wed, 6 Apr 2022 10:54:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239546AbiDFR40 (ORCPT + 99 others); Wed, 6 Apr 2022 13:56:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239767AbiDFR4I (ORCPT ); Wed, 6 Apr 2022 13:56:08 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 29CBB3C30F9 for ; Wed, 6 Apr 2022 09:20:06 -0700 (PDT) Received: (qmail 192537 invoked by uid 1000); 6 Apr 2022 12:20:05 -0400 Date: Wed, 6 Apr 2022 12:20:05 -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, 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