Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2050501pxu; Tue, 24 Nov 2020 15:54:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMR88C0P6Pv4sqIuzh49NWmUWYNB724+NMnfOhhc8fL7B2ck9XYKCeehqp3iUwB0uTu16E X-Received: by 2002:aa7:d502:: with SMTP id y2mr1007287edq.120.1606262083157; Tue, 24 Nov 2020 15:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606262083; cv=none; d=google.com; s=arc-20160816; b=Voj3ES2f5K/0esevvIQClYsCRWIcX2pIrxQm5gl+2Egofph6PHijONKQYxPDSmnThu dphQx8cLGsZ1qNC6mEK7h1+4Cg/L0S25lJTbrI8dezpoo9xdYC0xgm/9aCJkH6NC+Q// oVl5/G2yk0OSZ+l5Zl0xDqE1IKKXhkdT6/Fl7Wd4kKefuR4Iv0B+5TADpTsJ3YY7G3cs 9VEv9OmnrZZ8ocPJnMlC5Bnd3+4mWkCM+3akvJ2UG/myD9ZGvBWdcL9QW+hZZemNwZTO yrN6WToiEVkpO+xbwjuK7d8V+vdEyKUnneWo6LPxAi6ZxAyIW4OK2pEyd0mNfAZEVG1o XYhw== 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; bh=JFfsWdtLQbSJV2yGPULRMkDqzVgqOjwFhiYw1LGo1Ro=; b=p5nM3ohZf0c5jq0ZSk3jpIWD9Sde2A1Wq6MvaOc1ulJYVlDjzcNuOFt62/6XLvseWl kZRBDhfzs8Kesbd4r25Z4j5qV5RRXlkUGZ3fvKINZH1HHPSRHxvOYcD3YtFZUTI/4YG+ W1QB2Q5ihq5j6AdpjgmdUtVQWNIHoamg/MV7jLd0Kg0VmX1M1KJapH5LpHvXYe/R1I6D 3RsEE9qJxekVbDSht1a6vJxVf1k5EMYhmrKOPGShOBzDvWsWZ5KSoYzVPLMPXgajAG2M i2nKTp0C4oaV2xgiZVuVBLjmK2HMV/daCy5SdoGMjMCXR7eOdic9yk2PFHCLALjpfbGT Lnsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si170537eds.434.2020.11.24.15.54.20; Tue, 24 Nov 2020 15:54:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728122AbgKXTrD (ORCPT + 99 others); Tue, 24 Nov 2020 14:47:03 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:51424 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726275AbgKXTqw (ORCPT ); Tue, 24 Nov 2020 14:46:52 -0500 Received: from 89-64-86-188.dynamic.chello.pl (89.64.86.188) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.520) id 4da66d67e8e81342; Tue, 24 Nov 2020 20:46:48 +0100 From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , Linux PCI , Mika Westerberg , "Rafael J. Wysocki" , Bjorn Helgaas , Kai-Heng Feng Subject: [PATCH v1 2/2] PM: ACPI: Refresh wakeup device power configuration every time Date: Tue, 24 Nov 2020 20:46:38 +0100 Message-ID: <1717218.WU8ttdIIEu@kreacher> In-Reply-To: <27714988.CF3CpBaniU@kreacher> References: <27714988.CF3CpBaniU@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki When wakeup signaling is enabled for a bridge for the second (or every next) time in a row, its existing device wakeup power configuration may not match the new conditions. For example, some devices below it may have been put into low-power states and that changes the device wakeup power conditions or similar. This causes functional problems to appear on some systems (for example, because of it the Thunderbolt port on Dell Precision 5550 cannot detect devices plugged in after it has been suspended). For this reason, modify __acpi_device_wakeup_enable() to refresh the device wakeup power configuration of the target device on every invocation, not just when it is called for that device first time in a row. Signed-off-by: Rafael J. Wysocki Reported-by: Kai-Heng Feng Tested-by: Kai-Heng Feng --- drivers/acpi/device_pm.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) Index: linux-pm/drivers/acpi/device_pm.c =================================================================== --- linux-pm.orig/drivers/acpi/device_pm.c +++ linux-pm/drivers/acpi/device_pm.c @@ -757,16 +757,26 @@ static int __acpi_device_wakeup_enable(s mutex_lock(&acpi_wakeup_lock); - if (wakeup->enable_count >= INT_MAX) { - acpi_handle_info(adev->handle, "Wakeup enable count out of bounds!\n"); - goto out; - } + /* + * If the device wakeup power is already enabled, disable it and enable + * it again in case it depends on the configuration of subordinate + * devices and the conditions have changed since it was enabled last + * time. + */ if (wakeup->enable_count > 0) - goto inc; + acpi_disable_wakeup_device_power(adev); error = acpi_enable_wakeup_device_power(adev, target_state); - if (error) + if (error) { + if (wakeup->enable_count > 0) { + acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); + wakeup->enable_count = 0; + } goto out; + } + + if (wakeup->enable_count > 0) + goto inc; status = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); if (ACPI_FAILURE(status)) { @@ -779,7 +789,10 @@ static int __acpi_device_wakeup_enable(s (unsigned int)wakeup->gpe_number); inc: - wakeup->enable_count++; + if (wakeup->enable_count < INT_MAX) + wakeup->enable_count++; + else + acpi_handle_info(adev->handle, "Wakeup enable count out of bounds!\n"); out: mutex_unlock(&acpi_wakeup_lock);