Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7946731ybi; Tue, 9 Jul 2019 06:46:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzebfljUoFE6kAJ8wh3EWT2PZ4pXq/BEvlVlLFCWYYecORkNhZxORk1QBT7AcVxAN8MV8O+ X-Received: by 2002:a63:1658:: with SMTP id 24mr31711154pgw.167.1562679985828; Tue, 09 Jul 2019 06:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562679985; cv=none; d=google.com; s=arc-20160816; b=aieqk48JqCmaOTu/5wmyL4pBeQGXO6NRK1mN9OCqkSlBmSwCT9vbuw5QwgtgFqMi2y IFg7Hp20lagmHtSl7+rAZ+KUHcdjXfXgLNQexyPexDKWqhQ5YFFyYtmx+DEQfETqNnos JoOoiU4Ha5VI6qmqbM2+n8E9s8SxFw9YOwsvdYGz2lXnloKpkqefwF8aWGc2xpzopwKU o6ejAFwS7eMvLSpAOff5vlVtAv1958kBtt8PHNwKoWZJrO98UV0Gz34VLFn8KFQ0m4RB sxKiYU2pFb3W6PojhlpO8ZdwScJ/bqzinCz06+LWsFjNYiQEjFW5nqWsvNNVDlrmcdVf OyhQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JML9axXwh2c5PL6GHoeO+MBFaJn4iGcaXAk9CN/zdf8=; b=r10apLUaoqT1xArmq7G94GULVwKV467XDkqpTh9O/1V1hwiqISWXNvD+SwCOm3qRVm x5H728/r4xWqD8r7NJ89a8HM0peNhGUSt9acAbvWnOYenub3Mte842fNGT9p82HeapIT sYyX0ahhZXtD4oJxDuXzDYxbo9sgwZPXW12vtGBrnQAkQr0rRMDuf5ua1P5AVPlKluBV pPvRMdpmobx2ZM0l65kHZi1TmbnB9Bz9XHAczOkyrUf1z/ZHRjW0nv4b5Xrtj/TzD72K dLu0vpuJxh9Kt0ByzpXApJtrySPN5wh6hmwUBeyWoWEKTc9yqCyEldee54S1PW70Y5x1 I72Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cTwocF9i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x9si20525249plo.98.2019.07.09.06.46.07; Tue, 09 Jul 2019 06:46:25 -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; dkim=pass header.i=@kernel.org header.s=default header.b=cTwocF9i; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbfGINpm (ORCPT + 99 others); Tue, 9 Jul 2019 09:45:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:39260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbfGINpm (ORCPT ); Tue, 9 Jul 2019 09:45:42 -0400 Received: from localhost (249.sub-174-234-174.myvzw.com [174.234.174.249]) (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 39DB3214AF; Tue, 9 Jul 2019 13:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562679940; bh=pFpOkJHiAYbGncovzMXBIx9dzH17tRDacavgDnffM50=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cTwocF9iNQ/MOODLXMFPNInDXPHulYy4PTGwfoOKiR9X6a36MeEmx88KBCV69gbjY HrJtzhMImMqasu++slJvQEkzNZHGf6b32cvpE3dyMvgxRBw0xCDenNROkPdvJmotrN n5qNV764+21kArt71upxYFtC3GGq8N7nqucvZ5G4= Date: Tue, 9 Jul 2019 08:45:38 -0500 From: Bjorn Helgaas To: Kai-Heng Feng Cc: Alan Stern , Rafael Wysocki , linux-pci@vger.kernel.org, LKML , Mathias Nyman , linux-usb@vger.kernel.org Subject: Re: [PATCH] PCI / PM: Don't runtime suspend when device only supports wakeup from D0 Message-ID: <20190709134538.GA35486@google.com> References: <20190522181157.GC79339@google.com> <20190522205231.GD79339@google.com> <010C1D41-C66D-45C0-8AFF-6F746306CE29@canonical.com> <20190527165747.GF79339@google.com> <20190605115724.GE84290@google.com> <7E5CD0E5-2C23-4339-9660-74994FC5C111@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7E5CD0E5-2C23-4339-9660-74994FC5C111@canonical.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 05, 2019 at 03:02:01PM +0800, Kai-Heng Feng wrote: > at 19:57, Bjorn Helgaas wrote: > > On Mon, May 27, 2019 at 11:57:47AM -0500, Bjorn Helgaas wrote: > > > I'm wondering if this platform has a firmware defect. Here's my > > > thinking. The xHC is a Root Complex Integrated Endpoint, so its PME > > > signaling is a little unusual. > > > > > > The typical scenario is that a PCIe device is below a Root Port. In > > > that case, it would send a PME Message upstream to the Root Port. Per > > > PCIe r4.0, sec 6.1.6, when configured for native PME support (for ACPI > > > systems, I assume this means "when firmware has granted PME control to > > > the OS via _OSC"), the Root Port would generate a normal PCI INTx or > > > MSI interrupt: > > > > > > PCI Express-aware software can enable a mode where the Root Complex > > > signals PME via an interrupt. When configured for native PME > > > support, a Root Port receives the PME Message and sets the PME > > > Status bit in its Root Status register. If software has set the PME > > > Interrupt Enable bit in the Root Control register to 1b, the Root > > > Port then generates an interrupt. > > > > > > But on this platform the xHC is a Root Complex Integrated Endpoint, so > > > there is no Root Port upstream from it, and that mechanism can't be > > > used. Per PCIe r4.0, sec 1.3.2.3, RCiEPs signal PME via "the same > > > mechanism as PCI systems" or via Root Complex Event Collectors: > > > > > > An RCiEP must signal PME and error conditions through the same > > > mechanisms used on PCI systems. If a Root Complex Event Collector is > > > implemented, an RCiEP may optionally signal PME and error conditions > > > through a Root Complex Event Collector. > > > > > > This platform has no Root Complex Event Collectors, so the xHC should > > > signal PME via the same mechanism as PCI systems, i.e., asserting a > > > PME# signal. I think this means the OS cannot use native PCIe PME > > > control because it doesn't know what interrupt PME# is connected to. > > > The PCI Firmware Spec r3.2, sec 4.5.1 (also quoted in ACPI v6.2, sec > > > 6.2.11.3), says: > > > > > > PCI Express Native Power Management Events control > > > > > > The firmware sets this bit to 1 to grant control over PCI Express > > > native power management event interrupts (PMEs). If firmware > > > allows the operating system control of this feature, then in the > > > context of the _OSC method, it must ensure that all PMEs are > > > routed to root port interrupts as described in the PCI Express > > > Base Specification. > > > > > > This platform cannot route all PMEs to Root Port interrupts because > > > the xHC RCiEP cannot report PME via a Root Port, so I think its _OSC > > > method should not grant control of PCIe Native Power Management Events > > > to the OS, and I think that would mean we have to use the ACPI > > > mechanism for PME on this platform. > > > > > > Can you confirm or deny any of this line of reasoning? I'm wondering > > > if there's something wrong with the platform's _OSC, so Linux thinks > > > it can use native PME, but that doesn't work for this device. > > > > > > > It’s a platform in development so the name can’t be disclosed. > > > > > > Please attach a complete dmesg log to the bugzilla. You can remove > > > identifying details like the platform name, but I want to see the > > > results of the _OSC negotiation. > > > > Thanks for the dmesg log > > (https://bugzilla.kernel.org/attachment.cgi?id=283109). It shows: > > > > acpi PNP0A08:00: _OSC: OS supports [ExtendedConfig ASPM ClockPM Segments MSI HPX-Type3] > > acpi PNP0A08:00: _OSC: platform does not support [SHPCHotplug LTR] > > acpi PNP0A08:00: _OSC: OS now controls [PCIeHotplug PME AER PCIeCapability] > > > > I think it is incorrect for the platform to give the OS native control > > over PME because the OS has no way to know how the RCiEP PMEs are > > routed. But it would be interesting to know how BIOSes on other > > platforms with RCiEPs handle this, and I did post a question to the > > PCI-SIG to see if there's any guidance there. > > Is there any update from PCI-SIG? Yes, but I did a terrible job asking the question, so we didn't really get an answer for this situation. The thread on the forum is https://forum.pcisig.com/viewtopic.php?f=85&t=1081 (requires PCI-SIG login, unfortunately). My question was: Given an RCiEP that supports PME, can firmware grant control over native power management events to the OS? The PCI Firmware spec, r3.2, sec 4.5.1, says: PCI Express Native Power Management Events control The firmware sets this bit to 1 to grant control over PCI Express native power management event interrupts (PMEs). If firmware allows the operating system control of this feature, then in the context of the _OSC method, it must ensure that all PMEs are routed to root port interrupts as described in the PCI Express Base Specification. I don't think there's a mechanism for RCiEPs to route PMEs to a Root Port interrupt. PCIe r4.0, sec 1.3.2.3, says: An RCiEP must signal PME and error conditions through the same mechanisms used on PCI systems. If a Root Complex Event Collector is implemented, an RCiEP may optionally signal PME and error conditions through a Root Complex Event Collector. If the OS can be granted native PME control, how does it learn where the RCiEP PME is routed? And the response from Robert Gough: The routing of root complex devices- Root Ports and Root Complex Integrated Endpionts- to Event Collectors is described in the Event Collector's RCEC Endpoint Association Capability Structure. In order for OSPM to process PMEs routed to an Event Collector, the source of the PME is found in the PME Requester ID field within the Root Status register of the Event Collector, in the same way that PME messages from children of Root Ports are serviced. I just posted this follow-up question: Thanks, that clarifies one piece. The PCI Firmware spec, r3.2, sec 4.5.1, says that if firmware allows OSPM control of PME, all PMEs should be routed to Root Port interrupts. Your answer suggests that this should be updated to say something like "all PMEs are routed to Root Port *or RCEC* interrupts". The piece I still don't understand is what happens when firmware allows OSPM control of PME in a system with an RCiEP but no RCEC. Where are PMEs from the RCiEP routed, and how does OSPM discover that? Or is it simply illegal for firmware to allow OSPM control of PME in that case? The system we're looking at doesn't have any RCECs, so I don't think the Root Complex Event Collector Endpoint Association Capability (what a mouthful :)) is applicable, but I don't think Linux currently has any support for it, so I think we're likely to trip over similar issues on systems that do have RCECs. It would be good if somebody added support for that capability. Bjorn