Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1032884pxb; Fri, 15 Apr 2022 19:02:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxubjdPFlTUfSBQ8idYhZAa3/fDge6M4EPCx30BELCP4rHQuYsfr2FFAJ5K+zaWjKeRid+k X-Received: by 2002:a17:90a:4897:b0:1c7:5fce:cbcd with SMTP id b23-20020a17090a489700b001c75fcecbcdmr7021583pjh.45.1650074539728; Fri, 15 Apr 2022 19:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650074539; cv=none; d=google.com; s=arc-20160816; b=iHd56Kp7RYYvbllrFarMxcie9F/ZJmEZGOr0Rv05IQUvlYKLc78Y1xuT/oYTJQg6zj iU2zu8nVjZcf/FOWwMipfl3e46Ujx6EL2KVNQXNh0FevsfEQpGoRBo3/4zvi2D52HW+V wL3NRDbOPFeIq73QoX6HuTWALKXuJpu/pDuJr4P6DsWUkLr0v44p6qSqFIBmbue2SYGQ fasbmSFzGo974YypdChFDrVPgKo6pX+STiWmTksgnHJHJUluDDIegkB/+sRyRoV+xCnS Dbxol1PQ01q+mhtlxYWtmnJk2uD0uTFQBQtYaPFclf8cBS8B5XYIykIV3RTyuBo8UaNQ fMXg== 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=e5p7KMRSyldurpjAmUjZP6J5gczblj3ENM01d6l2ZIo=; b=b6/eBOkdf7rMoDDWaDHuFC/wg6MWo98vbxHPQM+aiTkePczE3sDf6GQ1btlTfNlg3F 7PwxqRwlpiyAzISCXz3LVZZgczTjpwgMClfUsSo4dikeCTZa2ROMZTUSrE5JYWQ+bQna tP2R0sckw9acTsT5JjSgz9nbKtt9cJnZg7nkcQb5meyveAW71PEiE2DZ6NaYFTtXfFiq bY4c6TSgtuuvFA1J5QvaN1JlqPMdB7OQeO+Ie0yOcApSU270SkqIZZYliYzDcVuxRXyg +DEF2OU3Yq8er10Q1N7eeVTKr4RC2uDRVvdmYU+RNLl5+gO/oom1LJMLPRndWwiaRdBr 2OAw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o2-20020a625a02000000b004fa3e2a9b13si2662247pfb.378.2022.04.15.19.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:02:19 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9C24235874; Fri, 15 Apr 2022 18:21:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244560AbiDNNej (ORCPT + 99 others); Thu, 14 Apr 2022 09:34:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244346AbiDNN0a (ORCPT ); Thu, 14 Apr 2022 09:26:30 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D5999E9E1; Thu, 14 Apr 2022 06:19:56 -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 6ff0503fedc9cd83; Thu, 14 Apr 2022 15:19:55 +0200 Received: from kreacher.localnet (unknown [213.134.181.101]) (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 3DC4666BE86; Thu, 14 Apr 2022 15:19:54 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PCI Cc: Linux PM , LKML , Bjorn Helgaas , Mika Westerberg Subject: [PATCH v3 6/9] PCI/PM: Clean up pci_set_low_power_state() Date: Thu, 14 Apr 2022 15:15:31 +0200 Message-ID: <1749771.VLH7GnMWUR@kreacher> In-Reply-To: <5838942.lOV4Wx5bFT@kreacher> References: <4419002.LvFx2qVVIh@kreacher> <11975904.O9o76ZdvQC@kreacher> <5838942.lOV4Wx5bFT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.181.101 X-CLIENT-HOSTNAME: 213.134.181.101 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvvddrudelfedgieegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepvddufedrudefgedrudekuddruddtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukedurddutddupdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehm 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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Reviewed-by: Mika Westerberg --- v1 -> v3: * Added R-by from Mika. --- 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 @@ -1345,16 +1345,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., @@ -1362,7 +1355,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; @@ -1375,10 +1368,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;