Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2185600pxb; Thu, 4 Nov 2021 15:41:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFCXrkdw0BSMZpVN21AXSkl3sMeWdZRKDTlqeIjGA8pIqN39e2s0zaFQfaqFZVQFtuABFO X-Received: by 2002:a05:6402:158:: with SMTP id s24mr73997116edu.189.1636065670050; Thu, 04 Nov 2021 15:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636065670; cv=none; d=google.com; s=arc-20160816; b=hP0PRKp/VvuKDyV9LH6p7ifiEy6RLnpgN/HDUybhY95bP3AbbZzIwSNSeFL4EhkFG1 hyGuXSyPRUWoc2K83HrgXkCvJQwLBavPXmP3VcAd4XaLdAs4Djrsw0IQRnC1++Gnwab4 lJ0F68v3KvPkXyBDjhWDE8CIGmvLIhr1oSUv+ZPY+LODRFrKmB+SVtCSKTMe/UYGE9P5 //Buz0EKE25Ihorgea3FCbiz6EEmWbH+2hIwOrObCfYW2TDH6W3sOjSDpWNQ6y1FII1R utpFmGxOuzIWLeOUTG3Iof3ZG4rV90lonT9vOeu5WDNtcmxx0tLWjoyXOB+UimxOqEf8 u+fg== 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=hU+9mW0MOb5cFml29OD2xXxNXCNRaiaamlp4jFRtEss=; b=J0mP5XtaHcvRbl8i2CI0e0/IJyUjprEeSCNMwkj34gIl4wae9efjzgsO//OEt+hCR5 BTWunHdrNEHKQp8lz9qRGyzL230YXYlYrMqj9PuD8ozjoVaurFVxEtzRf5u1yMmwJUu7 1mtjecXQoPSV8/0/gCKet1SbeWlLnhDbz+GNg1aOKIA1LdAyJNBOGtK/wiJonSrPQZti MPVPSZU7wbXbatZW8q/IONk+Tkvjr8HgIH2SgzazEZuaM1LiNcp1HzMO8SUzAqT0+DTG ckYGzQUck/YJRCKnNW81FfdUqr0SU80zawK8bzDsFr/QD64lg3rodcS9ycBXTMXNmDd7 GOBw== 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 nb28si14210275ejc.623.2021.11.04.15.40.45; Thu, 04 Nov 2021 15:41:10 -0700 (PDT) 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 S232239AbhKDV47 (ORCPT + 99 others); Thu, 4 Nov 2021 17:56:59 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:63504 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbhKDV46 (ORCPT ); Thu, 4 Nov 2021 17:56:58 -0400 Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 3.0.0) id 85590c0a1e8a073d; Thu, 4 Nov 2021 22:54:19 +0100 Received: from kreacher.localnet (89-77-51-84.dynamic.chello.pl [89.77.51.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 62E01663077; Thu, 4 Nov 2021 22:54:18 +0100 (CET) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , "Rafael J. Wysocki" Subject: Re: [PATCH] ACPI: PM: Fix device wakeup power reference counting error Date: Thu, 04 Nov 2021 22:54:17 +0100 Message-ID: <11862743.O9o76ZdvQC@kreacher> In-Reply-To: <2606454.mvXUDI8C0e@kreacher> References: <2606454.mvXUDI8C0e@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 89.77.51.84 X-CLIENT-HOSTNAME: 89-77-51-84.dynamic.chello.pl X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvuddrtdeggddugeelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepkeelrdejjedrhedurdekgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeekledrjeejrdehuddrkeegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, November 4, 2021 6:21:51 PM CET Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Fix a device wakeup power reference counting error introduced by > commit a2d7b2e004af ("ACPI: PM: Fix sharing of wakeup power > resources"). > > Fixes: a2d7b2e004af ("ACPI: PM: Fix sharing of wakeup power resources") > Signed-off-by: Rafael J. Wysocki > --- > drivers/acpi/power.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > Index: linux-pm/drivers/acpi/power.c > =================================================================== > --- linux-pm.orig/drivers/acpi/power.c > +++ linux-pm/drivers/acpi/power.c > @@ -757,10 +757,8 @@ int acpi_disable_wakeup_device_power(str > > mutex_lock(&acpi_device_lock); > > - if (dev->wakeup.prepare_count > 1) { > + if (dev->wakeup.prepare_count >= 1) > dev->wakeup.prepare_count--; > - goto out; > - } > > /* Do nothing if wakeup power has not been enabled for this device. */ > if (!dev->wakeup.prepare_count) This is still not good. It should be something like the patch below, but I need to test that one. --- From: Rafael J. Wysocki Subject: [PATCH v2] ACPI: PM: Fix device wakeup power reference counting error Fix a device wakeup power reference counting error introduced by commit a2d7b2e004af ("ACPI: PM: Fix sharing of wakeup power resources"). Fixes: a2d7b2e004af ("ACPI: PM: Fix sharing of wakeup power resources") Signed-off-by: Rafael J. Wysocki --- -> v2: Actually disable wakeup power when the reference count becomes zero. --- drivers/acpi/power.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) Index: linux-pm/drivers/acpi/power.c =================================================================== --- linux-pm.orig/drivers/acpi/power.c +++ linux-pm/drivers/acpi/power.c @@ -757,13 +757,11 @@ int acpi_disable_wakeup_device_power(str mutex_lock(&acpi_device_lock); - if (dev->wakeup.prepare_count > 1) { - dev->wakeup.prepare_count--; + /* Do nothing if wakeup power has not been enabled for this device. */ + if (dev->wakeup.prepare_count <= 0) goto out; - } - /* Do nothing if wakeup power has not been enabled for this device. */ - if (!dev->wakeup.prepare_count) + if (--dev->wakeup.prepare_count > 0) goto out; err = acpi_device_sleep_wake(dev, 0, 0, 0);