Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2059054pxb; Sun, 17 Oct 2021 04:57:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsujGhll4TL/EP/txcivi8tjsHzff+8BfIcZYZxnTb2sMWT4U4Bb4yyiuKjniTVMPa50ct X-Received: by 2002:a63:3d4c:: with SMTP id k73mr17939395pga.44.1634471862606; Sun, 17 Oct 2021 04:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634471862; cv=none; d=google.com; s=arc-20160816; b=BlFO+5xz/RIuLOVDGoJuGXA3gLm1OfPCsvanWLgV+ANl7IcEfjBuYB1nYQdo7naphV 6wM+3RfqoclUSey9eLVcaTOr8nk8Hcu9+r6fla5OJ7HfbnYvqkv2Cv36qWgUiv32OKwm fJJIW91bwcud6fTeTL73OsUE1InzWs78EAKdc6Bg7z2iTI9mrk8H52CDNWd0jbKfoHYw q93TubM2tosEbotcI7C45N171biR23LAWGQhIM5MXdz2kaXGn+lX+xWHmVCMHBrSqe9n GIJgnTbHAzmfwVCc5ww6eWTOOEzROl6sIMZuqSXR3RPz2Xpt7Xp6y/QN0Hv0vRra3zv4 IS1Q== 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=mi9ECkbJCm3wqriUpZlMwuY0m/s24BTBWgZAkPkb/YQ=; b=cIcD9v2//jbeDjiN7NlGQbUqNreCscxcr6tRMV3zlPo5/w7Z5s5Yibq9/9Np+Hhy4E K5UFcvs9sFeEo/4Wj/pzkR7m6mbieauLqjUfRWaRB4VzTaxR+1mBY4zOxiCK4nZ4Rxyo 8tF1zLfJtfVHobDfsnTDXtAF4SJjQXlHwi5WmfCFv4QbjZU5Xmu0mDH4lQLlEorTDThP 8kdTs5mc7WcI6dbOYCTyS5wyOz5+1gfNc/arZbAN3v2grt6NUx+zdkGMEy+6+oibKEGb qTEazh3rklD7e4RllibHomkOD6Nsu3288W7QhYNQAfPJdqy8POw20wlgzxHTaaBUxdzy UvwQ== 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 e10si21811340pjs.107.2021.10.17.04.57.30; Sun, 17 Oct 2021 04:57:42 -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 S242098AbhJORQ4 (ORCPT + 99 others); Fri, 15 Oct 2021 13:16:56 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:60030 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238023AbhJORQz (ORCPT ); Fri, 15 Oct 2021 13:16:55 -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 615faa74ca6a96bd; Fri, 15 Oct 2021 19:14:48 +0200 Received: from kreacher.localnet (unknown [213.134.175.255]) (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 2DAE666A8C0; Fri, 15 Oct 2021 19:14:47 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI , "Andreas K. Huettel" Cc: LKML , Linux PCI , Linux PM , Mika Westerberg Subject: [PATCH v1 2/2][RFT] ACPI: PM: Check states of power resources during initialization Date: Fri, 15 Oct 2021 19:14:10 +0200 Message-ID: <8835496.CDJkKcVGEf@kreacher> In-Reply-To: <21226252.EfDdHjke4D@kreacher> References: <21226252.EfDdHjke4D@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.175.255 X-CLIENT-HOSTNAME: 213.134.175.255 X-VADE-SPAMSTATE: spam:medium X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrudeljedguddtfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucfuphgrmhfkphgprhhtucdlfedttddmnecujfgurhephffvufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdejlefghfeiudektdelkeekvddugfeghffggeejgfeukeejleevgffgvdeluddtnecukfhppedvudefrddufeegrddujeehrddvheehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudejhedrvdehhedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegrnhgurhgvrghsrdhhuhgvthhtvghlsehurhdruggvpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhg vghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehmihhkrgdrfigvshhtvghrsggvrhhgsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki To avoid situations in which the actual states of certain ACPI power resources are not known just because they have never been referenced by any device configuration objects, check the initial states of all power resources as soon as they are found in the ACPI namespace (and fall back to turning them on if the state check fails). Signed-off-by: Rafael J. Wysocki --- Andreas, please test this patch (on top of the [1/2]) and let me know if it works for you. Thanks! --- drivers/acpi/power.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) Index: linux-pm/drivers/acpi/power.c =================================================================== --- linux-pm.orig/drivers/acpi/power.c +++ linux-pm/drivers/acpi/power.c @@ -923,6 +919,7 @@ struct acpi_device *acpi_add_power_resou union acpi_object acpi_object; struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object }; acpi_status status; + u8 state_dummy; int result; acpi_bus_get_device(handle, &device); @@ -951,6 +948,10 @@ struct acpi_device *acpi_add_power_resou resource->order = acpi_object.power_resource.resource_order; resource->state = ACPI_POWER_RESOURCE_STATE_UNKNOWN; + /* Get the initial state or just flip it on if that fails. */ + if (acpi_power_get_state(resource, &state_dummy)) + __acpi_power_on(resource); + pr_info("%s [%s]\n", acpi_device_name(device), acpi_device_bid(device)); device->flags.match_driver = true;