Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp126721rdb; Mon, 22 Jan 2024 14:25:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkowdtZ1nDEamhOlRPBghvgPc4kQvSFQGdBEPcCm1HrqEnaAHpEX3cMTu6ZU+NJfNgLCui X-Received: by 2002:a05:6e02:e51:b0:360:7e0a:a8d3 with SMTP id l17-20020a056e020e5100b003607e0aa8d3mr3516523ilk.95.1705962354853; Mon, 22 Jan 2024 14:25:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705962354; cv=pass; d=google.com; s=arc-20160816; b=pN6WPkbmLVSXGxl39vfACRpNys16kh4vR5fqd++xpIggYhmkz0RN2/p0e1gw56ZclX h1GYQshBn2+9Wl4ZrvBPGYAOmSbWFXR8OkNckbWsju5e9BpMCaFn0kuKSBBVqkHojAz6 VqQ+Daki9N4yZm5dpiGJxve2GIYts1+FMQR8NhYd6jtw64OsX786XC4bEkeSdAsSLrwj 2so4XpXq4sCm1EHm45prNYmCQgY+v+mWbywsoaqewdwV7siWoWf7cOfd7FidW3vDgXnb ntfLVfdVe81Y9/s2LKmI9RGp04/FZRucF7+IXUdrLyaMKxYg6S6HiZ5j4NLRzBhqzBhj Z9ZQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=yhPOciypopBsvWrueII3uDFCtD9V4/6CCjEYuz+PaLw=; fh=LLriCWijJECchkb7bMGzD05/V/s6N7nnMqJghHTgX7A=; b=riGSoXFwMoacp1SGatvOVyS3V4ZXz9OmwEe35RyoxdimJKG/QnmsPZf/ZACBaq2bRC KkMoDa/M8fSUQDk/p5lqGw+h7RtBi8Ia3VQIc6iJQiz1k9zRSlCoL4iIjNlRoG6ZzzW2 9bCbPSvpwkaT+upJH41DwsMI4OsLYjZ02gEsH6O4+EnnxkOFvmf2NuzNzGkcXAhCGLAj LCvF5CZhS/G6XZ8X/e1fHzpEicatxbjbQi/lkFnyUS/8o+e05BJlnCGUiRji9yuBM5kC a5mFKrNCe6PMsIfY2iCfwDpo1Rnh0ujv4xrKMnTVrAz1JEZy4ix8o1siMfMLKPJV3onI Mplg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-34232-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34232-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q5-20020a634305000000b005cee61cfde6si8404563pga.437.2024.01.22.14.25.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 14:25:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34232-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-34232-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34232-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0D1B5B24DE3 for ; Mon, 22 Jan 2024 22:18:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 45CAE48CC9; Mon, 22 Jan 2024 22:17:42 +0000 (UTC) Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [83.223.95.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20D784878F; Mon, 22 Jan 2024 22:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.223.95.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705961861; cv=none; b=L/c8ipRS7v2sY2kD3YmQyZdqDVe6cgRp+4AfJ3ZP2M/rOSiH4O/4zNUOjzR6VsSbmLtYgn0NSrx0Oc+Sa+NHup67BAsqjh6/T4SW4YXHy6ZJtXBZxlP46E2GCYRtEDM5AvNi6tdm10xX/zujvVElt3Aq0VPFikqC5wVA/8xNZ9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705961861; c=relaxed/simple; bh=VXI2zyva/FA7xQVMN8/hQAUXyYWMmB149msEZZUc1/4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eLAPQwlAvwMV6HOL4evE0DT4GDHmlzBeEx/xg6Ai3JOWTtuShgCyqlUNyutkNuOAU3mIYysdDs62fjP9MmS7VuUjRCc72kSN5vU/vcWwYmYP4ZuTATqhNvAm42U4boKB75phOnH2BTJ/9DDyNGjAWaAsdYsc6c7imbyx9bY5liQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de; spf=none smtp.mailfrom=h08.hostsharing.net; arc=none smtp.client-ip=83.223.95.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=wunner.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=h08.hostsharing.net Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS RSA CA G1" (verified OK)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id 2230F300002D2; Mon, 22 Jan 2024 23:17:30 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 1681A30501F; Mon, 22 Jan 2024 23:17:30 +0100 (CET) Date: Mon, 22 Jan 2024 23:17:30 +0100 From: Lukas Wunner To: Alex Williamson Cc: linux-pci@vger.kernel.org, bhelgaas@google.com, linux-kernel@vger.kernel.org, eric.auger@redhat.com, mika.westerberg@linux.intel.com, rafael.j.wysocki@intel.com, Sanath.S@amd.com Subject: Re: [PATCH v2 2/2] PCI: Fix runtime PM race with PME polling Message-ID: <20240122221730.GA16831@wunner.de> References: <20230803171233.3810944-1-alex.williamson@redhat.com> <20230803171233.3810944-3-alex.williamson@redhat.com> <20240118115049.3b5efef0.alex.williamson@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240118115049.3b5efef0.alex.williamson@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) On Thu, Jan 18, 2024 at 11:50:49AM -0700, Alex Williamson wrote: > On Thu, 3 Aug 2023 11:12:33 -0600 Alex Williamson > Testing that a device is not currently in a low power state provides no > > guarantees that the device is not immenently transitioning to such a state. > > We need to increment the PM usage counter before accessing the device. > > Since we don't wish to wake the device for PME polling, do so only if the > > device is already active by using pm_runtime_get_if_active(). > > > > Signed-off-by: Alex Williamson > > --- > > drivers/pci/pci.c | 23 ++++++++++++++++------- > > 1 file changed, 16 insertions(+), 7 deletions(-) > > Resurrecting this patch (currently commit d3fcd7360338) for discussion > as it's been identified as the source of a regression in: > > https://bugzilla.kernel.org/show_bug.cgi?id=218360 > > Copying Mika, Lukas, and Rafael as it's related to: > > 000dd5316e1c ("PCI: Do not poll for PME if the device is in D3cold") > > where we skip devices in D3cold when processing the PME list. > > I think the issue in the above bz is that the downstream TB3/USB4 port > is in D3 (presumably D3hot) and I therefore infer the device is in state > RPM_SUSPENDED. This commit is attempting to make sure the device power > state is stable across the call such that it does not transition into > D3cold while we're accessing it. > > To do that I used pm_runtime_get_if_active(), but in retrospect this > requires the device to be in RPM_ACTIVE so we end up skipping anything > suspended or transitioning. How about dropping the calls to pm_runtime_get_if_active() and pm_runtime_put() and instead simply do: if (pm_runtime_suspended(&pdev->dev) && pdev->current_state != PCI_D3cold) pci_pme_wakeup(pdev, NULL); Thanks, Lukas