Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp122622pxb; Wed, 20 Oct 2021 18:03:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCPiqzgV/grBjuQRtCffOlaDY+uWOb5ofHbh3+Pbfu6xQxDUSJSRmx4z/NqydqTNuOEoe5 X-Received: by 2002:a50:da48:: with SMTP id a8mr3234928edk.146.1634778205094; Wed, 20 Oct 2021 18:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634778205; cv=none; d=google.com; s=arc-20160816; b=WlNUikVHV5BcM5ncu/28xIQIj6FfnoSja/3DBY4qz4ughn2VylQGFVJ6ppn3JXQZ8b KlOgdCFM/ZGdpHqwoYlN8n9zAHDvGkboLhWMsy96KjmgxUJxeXde0eJg8E3MncqGXwp7 NoplZQsyAYN70AsZ8zPjVCsNu3/T/k5NxBldH6/jgr+E/rpwf52/x/8u/vp/o7C6G85g NMWH258HSSRTWzpMiZl/rqOWB4dOPvyEt2uaYP6u0CEOYI6BV2ldxf13KQyB7egR2niK +vIxKw+YaUu6uljjyG5xspihcrwMet4Rpr0ZnYdslwJ2GCLcevPVXjUphIxrXGB+PsK5 gdbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=eH3zm/d4mhc7RgG9T6RMrhP1KIU3Pm/HtVkFXqXQ/H0=; b=BKWa0DaX53RUCCjTjZmVR+MO6cKMMehuZ2mUleAUvMQ2Dh4lojz9XMs0LwdZUAg8nb S240G38qLV0I1xojz1MevKCPyxGB2Zv2QTSQiWYckHBfLE1TBWlj48BIAaYC9Vt3eNtl EFojld0iw6XZpTdqfYQPGN/ptP0EnBUo6jiiwCSmt7lcKWk+9PnTajrC3/V/v0yrV4W+ lUfyZ+t9nIWtdXXfyw4fOlkD+blnZKtG0amH75ViIV720xKcMwgSwTabG803FIOhgt+R H8MyArWJ9MKl+OEIDJWKDrU1MZ5z+78SoHNDafWW7oTL7J5mXqRYbHpDji+jw4cXXhmg cKQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rcCFedzt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d22si5403220ejj.387.2021.10.20.18.03.00; Wed, 20 Oct 2021 18:03:25 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rcCFedzt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231225AbhJUBC7 (ORCPT + 99 others); Wed, 20 Oct 2021 21:02:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:52464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbhJUBC7 (ORCPT ); Wed, 20 Oct 2021 21:02:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 866A86109F; Thu, 21 Oct 2021 01:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634778044; bh=k99wuXsaylfYov8RVTNBZrBrDeSF4wpxhJLFuC19V+I=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=rcCFedztLvwxIYWKi6DDMqKdho3My4jT/O1z82+nOGB1PumQ41oPVhfJ4kGIod7JN D1VO+PPUm2ydatp85xMdRqeWx+ziW3AKzsqzJTPZZfzBzhP/cwUJTHw6XD72lKVYbc 0iLFHb7CNRt0kk4hOnY7Takz7RDKTTFIkfDhxvlaYSADUG1liN1lwJ2EDg6wu3Yqza E9jCoTyGiJ4QXRD9PZdJyXr/bJ3tUZfvJ7A6kprxHnJVKr8EQqKZk1xfKUH7WhLK5W +UyRMAJXgGChu2FD2Gh5pL9fBvp8c7nT745h7d001szIn3NzBYgTS9b3Q+G+Y6odc8 RjCJnDG9yHtNg== Date: Wed, 20 Oct 2021 20:00:41 -0500 From: Bjorn Helgaas To: "Rafael J. Wysocki" Cc: Linux PCI , Linux PM , LKML , Mika Westerberg Subject: Re: [PATCH] PCI: PM: Fix ordering of operations in pci_back_from_sleep() Message-ID: <20211021010041.GA2655223@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <11844217.O9o76ZdvQC@kreacher> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 15, 2021 at 06:45:59PM +0200, Rafael J. Wysocki wrote: > 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 Acked-by: Bjorn Helgaas Thanks! > --- > 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); > > > >