Received: by 2002:a05:6a10:87d6:0:0:0:0 with SMTP id g22csp873927pxr; Mon, 11 Apr 2022 09:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiP4GHs1HUvVJFqMoVW8eUr5AjMdtra+kPoqqTEjlYieaoOjDwHLHjMP1E7gUoJ2TnforW X-Received: by 2002:a05:6402:1ac4:b0:41d:83d1:9da7 with SMTP id ba4-20020a0564021ac400b0041d83d19da7mr3146314edb.272.1649693661984; Mon, 11 Apr 2022 09:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649693661; cv=none; d=google.com; s=arc-20160816; b=V1CPq8CF4OfHZCUYrMRPu9/Oo3NaPJ1ZY2YQKw5x1Pf4XvcXQHJA/RMPu8x9m9X8i6 lv5X0kDFcXGNCnhhaT66ZoD0BLgz7K4fxiuEPcP/OKusPjrhHO3QwYXD8SD3vsjCyUsV O2ULgRIZxOSjqkJWHO3AsDGKpOwPkfW7Fp1+furlQPecHuCk6uFkwfUCSfiNYDaQz3Iv UZBufbBVVpjVJScMLzLZDoyVl0pE4nJkBpbn9l2c/c2b9gD1zAQn880t0+iPI654O7q3 zjdRPQtFdwlcgBLxYKQA98+kkY3U7jwivpfSb3CgUQjbLlN4XOlEwL4JeCGESp5MoxNj n/mA== 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=Cat0SzOTEnZ4O/xixS9c+fcp1VtugR2EPkfyGJcrZmI=; b=U88oNuFCt7rzXGomR1oFardz6ji71UrzdfzQplwJacgyVTfDaFL18VjCtuXzUBNkQn JxOAUbdldYJmm16bTR/Vvvw71zXWKSpmyQHR/l/0LASS0r5X6lvoi9TZhppVXvQL+arN 5xngxnwf9/Her7lIAcMFlY7aUHWfQ2c8qXjn6eXap6J+fR7waPmbuLnAoPNqZIfy0+RB luRJJ5hEXpX119OhHgpDo7fq3QjrDs8R+xklMBFFd6eTl/v+yVHFTXmU9bQ7TQjUVXSH 5Ikwi0lEjjdq44PqjNEo/v5iocJvJEdTN5fSBiB9mmivHbUX0nvcZdERdmjsETdNQnUT zSxg== 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 g21-20020a056402091500b0041cdc080d82si6677691edz.502.2022.04.11.09.13.56; Mon, 11 Apr 2022 09:14:21 -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 S1347374AbiDKOgn (ORCPT + 99 others); Mon, 11 Apr 2022 10:36:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347337AbiDKOgV (ORCPT ); Mon, 11 Apr 2022 10:36:21 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF258B50; Mon, 11 Apr 2022 07:34:05 -0700 (PDT) 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 5.0.0) id 30d5335c6f6b4a51; Mon, 11 Apr 2022 16:34:04 +0200 Received: from kreacher.localnet (unknown [213.134.175.113]) (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 6193A66BDED; Mon, 11 Apr 2022 16:34:03 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PCI Cc: Linux PM , LKML , Bjorn Helgaas , Mika Westerberg Subject: [PATCH v2 6/9] PCI/PM: Clean up pci_set_low_power_state() Date: Mon, 11 Apr 2022 16:28:38 +0200 Message-ID: <8068908.T7Z3S40VBb@kreacher> In-Reply-To: <11975904.O9o76ZdvQC@kreacher> References: <4419002.LvFx2qVVIh@kreacher> <11975904.O9o76ZdvQC@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.175.113 X-CLIENT-HOSTNAME: 213.134.175.113 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvvddrudekiedgjeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepvddufedrudefgedrudejhedruddufeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddujeehrdduudefpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehm ihhkrgdrfigvshhtvghrsggvrhhgsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 From: Rafael J. Wysocki Make the following assorted non-essential changes in pci_set_low_power_state(): 1. Drop two redundant checks from it (the caller takes care of these conditions). 2. Modify error messages printed by it to make them more consistent with the messages printed by pci_power_up() and pci_set_full_power_state(). 3. Change the log level of one of the messages to "debug", because it only indicates a programming mistake. 4. Make it return -ENODEV (instead of -EIO) when the device is not accessible. Signed-off-by: Rafael J. Wysocki --- v1 -> v2: * Rebase on top of the [4-5/9]. --- drivers/pci/pci.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) Index: linux-pm/drivers/pci/pci.c =================================================================== --- linux-pm.orig/drivers/pci/pci.c +++ linux-pm/drivers/pci/pci.c @@ -1324,16 +1324,9 @@ static int pci_set_low_power_state(struc { u16 pmcsr; - /* Check if we're already there */ - if (dev->current_state == state) - return 0; - if (!dev->pm_cap) return -EIO; - if (state < PCI_D1 || state > PCI_D3hot) - return -EINVAL; - /* * Validate transition: We can enter D0 from any state, but if * we're already in a low-power state, we can only go deeper. E.g., @@ -1341,7 +1334,7 @@ static int pci_set_low_power_state(struc * we'd have to go from D3 to D0, then to D1. */ if (dev->current_state <= PCI_D3cold && dev->current_state > state) { - pci_err(dev, "invalid power transition (from %s to %s)\n", + pci_dbg(dev, "Invalid power transition (from %s to %s)\n", pci_power_name(dev->current_state), pci_power_name(state)); return -EINVAL; @@ -1354,10 +1347,10 @@ static int pci_set_low_power_state(struc pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); if (PCI_POSSIBLE_ERROR(pmcsr)) { - pci_err(dev, "can't change power state from %s to %s (config space inaccessible)\n", + pci_err(dev, "Unable to change power state from %s to %s, device inaccessible\n", pci_power_name(dev->current_state), pci_power_name(state)); - return -EIO; + return -ENODEV; } pmcsr &= ~PCI_PM_CTRL_STATE_MASK;