Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1986765pxb; Sun, 17 Oct 2021 02:56:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwN7fmlXPnU/VJ51+bcjUSuPAUeNDdG8jF+Mybn0R4YcaNERsWNOu2tN9HB7cnouS4uy5ft X-Received: by 2002:a05:6402:5189:: with SMTP id q9mr34529592edd.94.1634464590252; Sun, 17 Oct 2021 02:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634464590; cv=none; d=google.com; s=arc-20160816; b=YYnY5AUFUSGUrwJbhTDdXlIgdYWa5TkNrAKnAzrmDfUdW5EfIT20YxJNHAsRyt14mn 6KT4YZjcxzCkCoJ0NHEEVK19/aNO21ycwHHYP5V+IVjzGVT2CcL6gGCqq7g4NFMYSMe3 BFFrZ+rq9DbjnKDkaKuXfj+xxl5+Bf9S1rxqSKtbGbxYortgJhBpZpSjqxp6sioh1MEc XlEKg48aPFkmaWeUG4I9TRQwMyoYiQ7VVLXCNMan7IyElxwdOWhUM6Z2IiLb4thSU+pi 9IkzCAHvTaVMITHDJdJDj52CePLop5XvAzmkxqoVxgBVauMEV8AaWhhxsG0eUqoYvhyt gRAA== 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 :message-id:date:subject:cc:to:from; bh=VmWS5nbrmv0YUF5A61YHjN4SySpjFljmCA4hd/7YTgQ=; b=cZ/F2cKxUjsOyuXxBZok6eFpSTgcnE55zh3EWCrWCVliy3n9abADmUUZsqsFCsDnMi Qov4nILDcSergaTAXKHwTuzhwp4j6y7wACj2aoja6X0hJEK4cLXSFFERMszAZn73QH5M ECyXQWt3c3hqsGQW16Yfi+WInWYopeX9JfelZBhY+H1iURfUD/mVnMozo01y+VtkAc9x ZGa+qLfyPLPb3wh6iYEpAqa+jsKMWKgg43W+sXZ/JdY9x+pNQc2PyzpXdvfZaZOB6MD+ xt6Re0vj6qjdCGK9ODTEAZgR3K4EZ9api1HRmuXMnK6/uylW+48dfu+7yekeaPZYGZqY VuLA== 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 j19si14113714edp.498.2021.10.17.02.56.02; Sun, 17 Oct 2021 02:56:30 -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 S241573AbhJOQsL (ORCPT + 99 others); Fri, 15 Oct 2021 12:48:11 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:62850 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241544AbhJOQsI (ORCPT ); Fri, 15 Oct 2021 12:48:08 -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 d70b789d530c31ba; Fri, 15 Oct 2021 18:46:01 +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 37F5B66A897; Fri, 15 Oct 2021 18:46:00 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PCI Cc: Linux PM , LKML , Bjorn Helgaas , Mika Westerberg Subject: [PATCH] PCI: PM: Fix ordering of operations in pci_back_from_sleep() Date: Fri, 15 Oct 2021 18:45:59 +0200 Message-ID: <11844217.O9o76ZdvQC@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: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrvddugedguddtfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhephfegtdffjeehkeegleejveevtdeugfffieeijeduuddtkefgjedvheeujeejtedvnecukfhppedvudefrddufeegrddujeehrddvheehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudejhedrvdehhedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedprhgtphhtthhopehlihhnuhigqdhptghisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohephhgvlhhgrggrsheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhhikhgrrdifvghsthgvrhgsvghr gheslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki The ordering of operations in pci_back_from_sleep() is incorrect, because the device may be in D3cold when it runs and pci_enable_wake() needs to access the device's configuration space which cannot be done in D3cold. Fix this by calling pci_set_power_state() to put the device into D0 before calling pci_enable_wake() for it. Signed-off-by: Rafael J. Wysocki --- drivers/pci/pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) Index: linux-pm/drivers/pci/pci.c =================================================================== --- linux-pm.orig/drivers/pci/pci.c +++ linux-pm/drivers/pci/pci.c @@ -2638,8 +2638,13 @@ EXPORT_SYMBOL(pci_prepare_to_sleep); */ int pci_back_from_sleep(struct pci_dev *dev) { + int ret = pci_set_power_state(dev, PCI_D0); + + if (ret) + return ret; + pci_enable_wake(dev, PCI_D0, false); - return pci_set_power_state(dev, PCI_D0); + return 0; } EXPORT_SYMBOL(pci_back_from_sleep);