Received: by 10.223.185.116 with SMTP id b49csp982194wrg; Tue, 20 Feb 2018 11:02:09 -0800 (PST) X-Google-Smtp-Source: AH8x224++fgwHnXiG50T2q6kK+HfmvuuXcqNK9tQB0OUXZkGC9dIEwT0Egohvu/zTM3EGTHRyTsU X-Received: by 2002:a17:902:b215:: with SMTP id t21-v6mr579194plr.414.1519153329471; Tue, 20 Feb 2018 11:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519153329; cv=none; d=google.com; s=arc-20160816; b=jfd3GdYU24B6UEmlJ0y+Fuh6KHOi4bomzM1GWB81zj05hWg1g/w23P6sFo4jjG7MEh 4hhGO03DCX4SWESw9FbS9C+V3w8NA0MyiABUIiykj2iaiYo0y/IQtW59utMcdtGLQEEx iPCLBfdUdBE5eLREZtt5wm8YdpVIkDzvr9IawmOcCg8jtQYPyyXvLQt/GtatF6tMnT/n KxEaXjD8cXlprVEgKM3ltipjxr4W8tKwmHy/EUUkmn9Z5ZzX8bOqvbss8ffH3awSDQPl EV0utu4aQbTZD7O5P9uIaFqX4JEvwrFC9abSP2m8W5tl/hkQ+fp2DflVYbH5y3OmeK95 ZwUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=plw0UPlGEiXDwwKrUhPriVvDlL1SW7MvvVvIdKiXuAw=; b=OdjHGYuLZronZHfFoxzy24hnxym80SFavtO0kTtPif3GjN5j7T8zz4AW2dB9ttJfL7 LNC9Z2F2jt432CoBsEb5WvVhmTAu8ELcSLNGRyy9zF6wlsw8aXtChIviugehBFXXAoGK hOvpr/2bNvFujUkGcyTKwC573yc8XGhlvJ736Qn6uLhJ72IqjmN1Tc2fzIljxWk/up2L zpi0mIIqPiGebiEQmGIbLdEzznS1XXsMsMFOCL8cfoNeamfv1zeP9f1oxZlLbwEL7Vj0 BZPwyXtcc8TptPhnoYdSF1hQjSioHUv8SXEF3JoNyevrZ3eX4fJzWA+Kn6HgRZ0fp1DE s8lg== 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 v7si1707165pfi.302.2018.02.20.11.01.54; Tue, 20 Feb 2018 11:02:09 -0800 (PST) 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 S1752018AbeBTTAk (ORCPT + 99 others); Tue, 20 Feb 2018 14:00:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:53896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751785AbeBTTAj (ORCPT ); Tue, 20 Feb 2018 14:00:39 -0500 Received: from localhost (unknown [69.71.4.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 614A021799; Tue, 20 Feb 2018 19:00:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 614A021799 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Date: Tue, 20 Feb 2018 13:00:37 -0600 From: Bjorn Helgaas To: Lukas Wunner Cc: "Rafael J. Wysocki" , Mika Westerberg , George Cherian , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, bhelgaas@google.com, Jayachandran.Nair@cavium.com, Robert.Richter@cavium.com, Lorenzo Pieralisi , Huang Ying Subject: Re: [PATCH] PCI: Add quirk for Cavium Thunder-X2 PCIe erratum #173 Message-ID: <20180220190037.GB32228@bhelgaas-glaptop.roam.corp.google.com> References: <1517554846-16703-1-git-send-email-george.cherian@cavium.com> <2323301.ORZpb3hFRe@aspire.rjw.lan> <20180216203434.GC11014@bhelgaas-glaptop.roam.corp.google.com> <2858019.9TUCWsDpTB@aspire.rjw.lan> <20180220015433.GA9656@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180220015433.GA9656@wunner.de> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [+cc Huang] On Tue, Feb 20, 2018 at 02:54:33AM +0100, Lukas Wunner wrote: > On Mon, Feb 19, 2018 at 12:21:56PM +0100, Rafael J. Wysocki wrote: > > On Friday, February 16, 2018 9:34:34 PM CET Bjorn Helgaas wrote: > > > On Fri, Feb 16, 2018 at 01:40:37PM +0100, Rafael J. Wysocki wrote: > > > > On Friday, February 16, 2018 12:39:00 AM CET Bjorn Helgaas wrote: > > > > > On Thu, Feb 15, 2018 at 10:57:25PM +0100, Rafael J. Wysocki wrote: > > > > > > On Wednesday, February 14, 2018 9:16:53 PM CET Bjorn Helgaas wrote: > > > > > > > I don't know how this runtime PM works, but maybe Rafael can help > > > > > > > us out. > > This has nothing to do with runtime PM AFAICS. > > The device seems to be in D3hot on boot, is that correct? I actually don't know for sure what device caused the issue or what state it was in. George, if you could clarify that, it would be helpful. My assumption (possibly incorrect) is that the issue happens when we read config space of an endpoint behind a PCIe bridge that is in D3. The PCIe portdrv binds to the bridge before the pci_sysfs_init() late_initcall happens, and it enables runtime PM on the bridge, so it's possible the bridge is in D3 before pci_sysfs_init() happens. > The PCI core assumes that unbound devices remain in D0 > (see comments in pci_pm_runtime_resume() / pci_pm_runtime_suspend()). That comment was added by 967577b06241 ("PCI/PM: Keep runtime PM enabled for unbound PCI devices"), apparently because "some devices do not work again after being put into D3". That commit mentions https://bugzilla.kernel.org/show_bug.cgi?id=48201 but I don't think it's completely convincing about the requirement for keeping things in D0. Even if it's true that some devices don't work after being in D3, that doesn't seem like sufficient reason to keep *all* devices on all systems in D0. We would normally use quirks to address device issues like this. > > > > > > I'm not sure what the question is to be honest. > > > > > > > > > > My questions are basically "What does the PCI core need to do to make > > > > > sure a device is in D0 before it operates on it? And where do we need > > > > > to do that?" > > When scanning the bus and discovering the device is not in D0, > call pci_power_up(). This could probably go into pci_init_pm(). > Once a driver binds to it, it may choose to runtime suspend it to > D3hot again. s/pci_init_pm/pci_pm_init/ That's an interesting idea. I hadn't thought of the case where a device is not in D0 when we enumerate it. We *do* make sure bridges are in D0 before scanning behind them (pci_scan_bridge_extend() calls pm_runtime_get_sync()). Since enumeration should only perform config accesses, and devices must respond to config accesses even when in D3hot, I guess I'm not convinced that we need to power up everything (other than bridges) during enumeration. Bjorn