Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp270630pxb; Wed, 20 Apr 2022 22:20:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybH4RvZgPkjWLJGQRHcX8s3ETvU5HCUh8bMWBBVTRsz5f/UWu9ho2ddozubnA07rd1Etqs X-Received: by 2002:a17:906:3082:b0:6e0:111f:8986 with SMTP id 2-20020a170906308200b006e0111f8986mr20580141ejv.677.1650518427355; Wed, 20 Apr 2022 22:20:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650518427; cv=none; d=google.com; s=arc-20160816; b=hd7R5QcUO3vBOj7z5PA1sR/khRG4CnNrT+o8CDmzpCbpbujGj7JPNNDwq8QBZibdIa 14nSSB1NuH7PAuCGvlKEnKR3I48KnTK1L6JeF6TWV8mTqDLO40ED0QBUJJ57bCbQ/eBm xLW/ouK3sXb66ErFtSl8hs24dQxGEKTqNdxyt6M6zhC4ZyGf7V3VGv0dhCpud+PaPgc/ 49gLN2u311qP+pzhSqHfj0CTdcHcGng//7jAaFlzaJt0gyBnyCn+yhVpE1W5QRN3gW8y iekqyJc1muP9eWlFKbhscOgOslgoop/tRq/RU0/eci9R8v0z9C1Ksv3d1PZ83q0W5pzI 0i6Q== 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=VTLNUyUXFqfQ9o/BlRlfVxLElz8CDprvOENbZch2mcQ=; b=OaXOxIoM2Kh6PWFQhMCmSG/jV01VBSZoLejTAnx/WAPvUxEO+IF4/ZnA2sLzUl8xzJ nN73+13ZpBgA+lfq4RGDymp//kZ9k7PetSqcGPznq7qXqnIcNKzISLrTj3UFFUPAteOv 4qSlbpF4DnLSCmrZjYdI4LqPZjbZgZ4gBkq+F1WIgmKo9JB28wVfyuNayAUTnKU3G3fn FJuTOwoGSriEoyda6PRTMmSZ7rSCOqsN+3k9dcPG6fyB73YorbraaoF7oVXFuzRMTsHR yfvXzaKeGL5y9O8BBy6hobE1HTegui3qSf21cJXsBSL61//wMRuj07A+JnvtmrG2lwXU QXCA== 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 s8-20020a170906168800b006e76f053445si3189388ejd.55.2022.04.20.22.20.02; Wed, 20 Apr 2022 22:20:27 -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 S1351389AbiDSOoH (ORCPT + 99 others); Tue, 19 Apr 2022 10:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351508AbiDSOoF (ORCPT ); Tue, 19 Apr 2022 10:44:05 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 3DB7D24BCA for ; Tue, 19 Apr 2022 07:41:22 -0700 (PDT) Received: (qmail 594199 invoked by uid 1000); 19 Apr 2022 10:41:21 -0400 Date: Tue, 19 Apr 2022 10:41:21 -0400 From: Alan Stern To: Evan Green Cc: Greg Kroah-Hartman , Thomas Gleixner , Mathias Nyman , Rajat Jain , Razvan Heghedus , Wei Ming Chen , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v2 1/2] USB: core: Disable remote wakeup for freeze/quiesce Message-ID: References: <20220418210046.2060937-1-evgreen@chromium.org> <20220418135819.v2.1.I2c636c4decc358f5e6c27b810748904cc69beada@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220418135819.v2.1.I2c636c4decc358f5e6c27b810748904cc69beada@changeid> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, 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 Mon, Apr 18, 2022 at 02:00:45PM -0700, Evan Green wrote: > The PM_EVENT_FREEZE and PM_EVENT_QUIESCE messages should cause the > device to stop generating interrupts. USB core was previously allowing > devices that were already runtime suspended to keep remote wakeup > enabled if they had gone down that way. This violates the contract with > pm, and can potentially cause MSI interrupts to be lost. > > Change that so that if a device is runtime suspended with remote wakeups > enabled, it will be resumed to ensure remote wakeup is always disabled > across a freeze. > > Signed-off-by: Evan Green > --- > > (no changes since v1) > > drivers/usb/core/driver.c | 20 +++++++++----------- > 1 file changed, 9 insertions(+), 11 deletions(-) > > diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c > index 355ed33a21792b..93c8cf66adccec 100644 > --- a/drivers/usb/core/driver.c > +++ b/drivers/usb/core/driver.c > @@ -1533,20 +1533,18 @@ static void choose_wakeup(struct usb_device *udev, pm_message_t msg) > { > int w; > > - /* Remote wakeup is needed only when we actually go to sleep. > - * For things like FREEZE and QUIESCE, if the device is already > - * autosuspended then its current wakeup setting is okay. > + /* For FREEZE/QUIESCE, disable remote wakeups so no interrupts get generated > + * by the device. You mean "by the host controller". USB devices don't generate interrupts; they generate wakeup requests (which can cause a host controller to generate an interrupt). > */ > if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_QUIESCE) { > - if (udev->state != USB_STATE_SUSPENDED) > - udev->do_remote_wakeup = 0; > - return; > - } > + w = 0; > > - /* Enable remote wakeup if it is allowed, even if no interface drivers > - * actually want it. > - */ > - w = device_may_wakeup(&udev->dev); > + } else { > + /* Enable remote wakeup if it is allowed, even if no interface drivers > + * actually want it. > + */ > + w = device_may_wakeup(&udev->dev); > + } > > /* If the device is autosuspended with the wrong wakeup setting, > * autoresume now so the setting can be changed. > -- I would prefer it if you reformatted the comments to agree with the current style: /* * Blah blah blah */ and to avoid line wrap beyond 80 columns. Apart from that: Acked-by: Alan Stern Alan Stern