Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3060251ybi; Mon, 17 Jun 2019 15:44:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHIQ6Gmt+bMbc/ZbclTYpQ0qnuFRgwFZ+oBfwKtcaj+RqNHcBRLKCRAZpdxsg2REscil8Y X-Received: by 2002:a17:902:3fa5:: with SMTP id a34mr106636372pld.317.1560811445747; Mon, 17 Jun 2019 15:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560811445; cv=none; d=google.com; s=arc-20160816; b=0RYyoXBfBTZ3Si7pydIBgTJI8jBu++vEdN74g9Vx4pnBX2LYhRb5A7sDo8QEobu+Cs qbDAw/EEAH1n7QDoocfv8gjHPez2IEAPOEbY2p/UoYgUs8nV3keze47oqLQmboCZqqqg D26sR722YV35Ia3SYAtS9i4x7erdNePgKkS/fHlnUQVa81LO1ZzoXlPwoIgytpB8s61Q srPkwB3R0iLY+VWSNd5dRgsklBbxW7Sicr3B40g2LnCzdzhIKoj+tbC9dE6qyXLqXWTQ QtMgFlhjgpWAzhsh7Ez805SniB3FPBjLh471oJXBxRE/5GKr4GUj41uGm9T1JLzFDGD3 22lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=lQ9BUkZT6TU/CdFSxjQyUGnJiYZenOXaUeZ6yuL7jOQ=; b=UhUg4ZPcj3fkhqAnamyhjUHvMopL0lCcrGkyxcCQPchIHq/Y0RZtdm8mnP5wVFofxu BQkC0TLmO337RfcAMCuB1+2vCCJTPa2T2eUUMM01cwFRoPQ5XitVzvJz1RPdY48i+54i gDYvjS/nBkqTwnXjVr7m9KpJd8pURiIvrG3YRALnKWWsaVPn3k6DVwsH/C1QdKpyty7W s3vV+XMILTc8C4uT/aUZqf5i05edqx7iIf8+GaAhg8a05HmH539oHmxiaG/hxs/5mc0u wVROjsaz7R24zzfPpeJcWmiR3EKxcSIoFlFktfVaTAQWHHxt0Vni+Vb5BhT89dY/raDH iWwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id co12si1144914plb.197.2019.06.17.15.43.49; Mon, 17 Jun 2019 15:44:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727399AbfFQWnh (ORCPT + 99 others); Mon, 17 Jun 2019 18:43:37 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:54653 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbfFQWnh (ORCPT ); Mon, 17 Jun 2019 18:43:37 -0400 Received: from 79.184.254.20.ipv4.supernova.orange.pl (79.184.254.20) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.267) id a683a0a51c8ced34; Tue, 18 Jun 2019 00:43:35 +0200 From: "Rafael J. Wysocki" To: Lukas Wunner Cc: Mika Westerberg , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Keith Busch , Alex Williamson , Alexandru Gagniuc Subject: Re: [PATCH] PCI/PME: Fix race on PME polling Date: Tue, 18 Jun 2019 00:43:35 +0200 Message-ID: <1943367.SoULSMlgxK@kreacher> In-Reply-To: <20190617145348.cqmtuqlvabgpo2ky@wunner.de> References: <0113014581dbe2d1f938813f1783905bd81b79db.1560079442.git.lukas@wunner.de> <20190617143510.GT2640@lahna.fi.intel.com> <20190617145348.cqmtuqlvabgpo2ky@wunner.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, June 17, 2019 4:53:48 PM CEST Lukas Wunner wrote: > On Mon, Jun 17, 2019 at 05:35:10PM +0300, Mika Westerberg wrote: > > Today when doing some PM testing I noticed that this patch actually > > reveals an issue in our native PME handling. Problem is in > > pcie_pme_handle_request() where we first convert req_id to struct > > pci_dev and then call pci_check_pme_status() for it. Now, when a device > > triggers wake the link is first brought up and then the PME is sent to > > root complex with req_id matching the originating device. However, if > > there are PCIe ports in the middle they may still be in D3 which means > > that pci_check_pme_status() returns 0xffff for the device below so there > > are lots of > > > > Spurious native interrupt" > > > > messages in the dmesg but the actual PME is never handled. > > > > It has been working because pci_check_pme_status() returned true in case > > of 0xffff as well and we went and runtime resumed to originating device. > > > > I think the correct way to handle this is actually drop the call to > > pci_check_pme_status() in pcie_pme_handle_request() because the whole > > idea of req_id in PME message is to allow the root complex and SW to > > identify the device without need to poll for the PME status bit. > > Either that or the call to pci_check_pme_status() should be encapsulated > in a pci_config_pm_runtime_get() / _put() pair. And the whole hierarchy might as well be resumed, which could be rather wasteful. The problem is that the $subject patch should affect polling only, but it has side effects beyond that.