Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3568833pxb; Tue, 19 Apr 2022 05:42:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYRSugX8XYOb7+OylgiAMMm/88NqWusrjGhGqXGrXm9VRee7aZGQDEqAyaxslxv1jT/nGU X-Received: by 2002:a17:903:1c9:b0:158:e1b9:b395 with SMTP id e9-20020a17090301c900b00158e1b9b395mr15561360plh.20.1650372178342; Tue, 19 Apr 2022 05:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650372178; cv=none; d=google.com; s=arc-20160816; b=ksJS47T64BFd9xPA6aSV280QGfzi0QhxEmS1ednOPYPC1EKBPAoNpFJKajL3AtEkHq uwsO2MRH8atYohIQFW3m8UvL/trYAvs1HWCQdeUBu4jn59Az/VbHAKaiNUm6bQKACywa SjNJm/qyJnGqecVwMjbIgxd6I/raXaifB8xGVb4PuR+7qK7zKF6HoDG1emAIZr53hjPa yhwMcz0C3JSUVktS171Oi5mQTaf3J+/D2WXUIbWfxnaWQdMnJMEUkwyo2w2RRwpARgUi gepkxvDT3PJ8Wpn3r7eGVQ2L3yRqfOcXzCegJ0LRXO1aMH5iDHEm1ZW2axuVFQH792tR WH/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PsqaX0mMaHgNt26YkuFONS0WzSqOE6FUG9W4KvOufeg=; b=KpJEcIlKVtcs7HguBr/CVY/55WPeqJeq02N7Lqfl8Txnsbrm0XIfOHrdAjypJQmhgG fFQpTDQH2sUXIn1NOhXdC44bqgECdmhxUJ2ugzSk5NN8HzoFjUJ5Iyi3+NvZFz/7EUpa o5mZcwk15X90EkdqUzGRRvAPylukBNDHRd3XCNN7EGd+OQk77+UGwQwLSP6ko4I+ljVU h7jbd/gdIrk+o4ZZsJ9w0aSPMXxNuLypnbOgH8THlxdkj/MWTHy7os+KAfGrljTQwBiQ b9GmMe1oAluLgtnzNJQV3CQiQTIgNnhRq7npt+8H59Ctw1HxDS9dcv8hda2HRWtDS9e+ NVng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="L/5wlo3X"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a3-20020a630b43000000b003816043f011si11634834pgl.518.2022.04.19.05.42.42; Tue, 19 Apr 2022 05:42:58 -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; dkim=pass header.i=@chromium.org header.s=google header.b="L/5wlo3X"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347916AbiDRVEW (ORCPT + 99 others); Mon, 18 Apr 2022 17:04:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347912AbiDRVEN (ORCPT ); Mon, 18 Apr 2022 17:04:13 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C5F62A25D for ; Mon, 18 Apr 2022 14:01:32 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id t4so21044400pgc.1 for ; Mon, 18 Apr 2022 14:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PsqaX0mMaHgNt26YkuFONS0WzSqOE6FUG9W4KvOufeg=; b=L/5wlo3XuKXWeDlWiHccl1mrvHuQMGk71l2/UJiNbukNtW8sBFk7L3voXHaL1t1x7c eW1iVPH/smzcAB2Fs+jUjbqUB8Mj4kNYfnfVIZZfxmdUiFjEulFXt8j/x67YiugvzWOW v6JEMH8hXeaeGAZWdVhp+rdshOfKJ9kBZSgeA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PsqaX0mMaHgNt26YkuFONS0WzSqOE6FUG9W4KvOufeg=; b=WqOw1sUj5qOBpAL6lHIyiaMwU6a6jUkWX1879UceXhwsxzhiiLGV4MhHebWkpy/lqw S0D6eKI1abjvdeHix+1UOYqI+rP+PIUPA37sHh0epZp5M3bDwaRO7uk+IdfYJ/hq8t3F G5UmJ6cR6FVr+Di5A1VosYFDFXJ1EQ/tRjoqaOJzdy2IrkTbdCDGS6zIbDc0xmB1aAu7 Kum86tlk5ZGl5Jp9q8xZMSR3qGZkDsTEAawBUIVTnbEbkvmxzAOJl1QytIfFIkhRr+M2 NP9KER8wB3QyoTRBW7owF5PK8aKw88KLBSOn9wmATBPuqCEaDcF8zophloyT68jnUqC3 M+cA== X-Gm-Message-State: AOAM532YeC/0fwRarPsYqqtM614iDzd503DxN9j4aSAQocheGgCWei76 3aR7OsJYaJ2gbCtr/H7O2fRW2w== X-Received: by 2002:a05:6a00:2496:b0:50a:6778:b8c1 with SMTP id c22-20020a056a00249600b0050a6778b8c1mr9247086pfv.47.1650315691606; Mon, 18 Apr 2022 14:01:31 -0700 (PDT) Received: from evgreen-glaptop.lan ([98.47.98.87]) by smtp.gmail.com with ESMTPSA id y15-20020a17090a1f4f00b001c7ecaf9e13sm14047973pjy.35.2022.04.18.14.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 14:01:31 -0700 (PDT) From: Evan Green To: Greg Kroah-Hartman Cc: Thomas Gleixner , Mathias Nyman , Alan Stern , Rajat Jain , Evan Green , Razvan Heghedus , Wei Ming Chen , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v2 1/2] USB: core: Disable remote wakeup for freeze/quiesce Date: Mon, 18 Apr 2022 14:00:45 -0700 Message-Id: <20220418135819.v2.1.I2c636c4decc358f5e6c27b810748904cc69beada@changeid> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220418210046.2060937-1-evgreen@chromium.org> References: <20220418210046.2060937-1-evgreen@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 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. */ 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. -- 2.31.0