Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4442078ybi; Mon, 3 Jun 2019 10:55:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzmo7xD4M3VK5CJ/jhDubAXVFGxI2/7HhXm8pyoEEW9DXVaN90/g+iPVmFcuEma1nzJt7/ X-Received: by 2002:a63:5024:: with SMTP id e36mr31030740pgb.220.1559584543360; Mon, 03 Jun 2019 10:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559584543; cv=none; d=google.com; s=arc-20160816; b=mv5WxV+9bdVTpVrpWjYTswVr/8B6UhhllSFnvOFMSPJEGeo99vr2FbSnjkqC6LGqZW Bbn7ofLaZe0Ua2VHtvUYM8mpNyYVhcX3/tw+CGzJiSkOPQWpKDoFeNTTeKEDHoua45cj 8slsEMsX971JcbEwe2AmkQjozTiHsVJrlF/Cv0EgtkpwJf6DGYKukKJ6IBoXDpWBpbjY sUzLWZ2NbXyvU3Lxz4oafTBhNOyebeNySRI+md0G7dNFui9sbs5KyWzcvPW/lWaQII8T jhw797n06W1mM5APNTFuGvigy2IpG1Rt42vC7Qt7FrUkFXu6gzjX9cK2QfV5i/HGw4vS iekQ== 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:dkim-signature; bh=q4R9kuSo4ycgCPfne0O2QoFG6eU9AnpnBsduB9+oVvw=; b=aEsszCfbeveCb0EPNF9jol9A7dPE7HJ57DrsHqJh5E/jkkCORgNpF+szLyTV35We0J YcQIwr+dcgKva1aX9+lARFoUx129TRy0IgAI9v60eNLkdzvL5fwtzdjrTUNfrmy7/UIS fcfV0zW82qem7Am0kKCznl8xcxOvKPROt+/RTm7QCU0t3tp4Jj2FXd25A9SCo+WFPST6 9FtH6NiR4E2516ra5Qc5Ej/caUWxGAkYdmWuv5lv5PZ4hEOKhBduVROTPFpJI3kR7JEh 6kbZNLseetiBVZ5KfsYgGFakf2DIscwURBkayo/hx2zYAhwvaSc60JSgDEfL35ZiMU2f e5PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FVBwrdqK; 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 q11si10898476pff.105.2019.06.03.10.55.27; Mon, 03 Jun 2019 10:55:43 -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=FVBwrdqK; 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 S1729717AbfFCRWt (ORCPT + 99 others); Mon, 3 Jun 2019 13:22:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:39242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728903AbfFCRWt (ORCPT ); Mon, 3 Jun 2019 13:22:49 -0400 Received: from localhost (unknown [69.71.4.100]) (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 35A6824C34; Mon, 3 Jun 2019 17:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559582568; bh=m0c/8JcFUckNJFkz15Q5J1w/EVegsKZJsLr7Fax2zA4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FVBwrdqKBKoPlJXO30OviEZLYdX77wsHDwzw4SIctDxTLeEVYLmHVG5EoOg9NvXdu +iP5zmJOrg/eVs0K0SSz97Eg90OfN71PbpzcGzr6+VH0jQ0ZkM4TalnsxQBdMwFeZa 3vurzZmUXDszgBZMC8Zu7Sms2Rd1eHRIfpuTnjOw= Date: Mon, 3 Jun 2019 12:22:47 -0500 From: Bjorn Helgaas To: Abhishek Sahu Cc: linux-kernel@vger.kernel.org, Lukas Wunner , linux-pci@vger.kernel.org, "Rafael J. Wysocki" Subject: Re: [PATCH 2/2] PCI: Create device link for NVIDIA GPU Message-ID: <20190603172246.GC189360@google.com> References: <20190531050109.16211-1-abhsahu@nvidia.com> <20190531050109.16211-3-abhsahu@nvidia.com> <20190531203908.GA58810@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 [+cc Rafael, just FYI] On Mon, Jun 03, 2019 at 01:30:51PM +0530, Abhishek Sahu wrote: > On 6/1/2019 2:09 AM, Bjorn Helgaas wrote: > > On Fri, May 31, 2019 at 10:31:09AM +0530, Abhishek Sahu wrote: > >> NVIDIA Turing GPUs include hardware support for USB Type-C and > >> VirtualLink. It helps in delivering the power, display, and data > >> required to power VR headsets through a single USB Type-C connector. > >> The Turing GPU is a multi-function PCI device has the following > >> four functions: > >> > >> - VGA display controller (Function 0) > >> - Audio controller (Function 1) > >> - USB xHCI Host controller (Function 2) > >> - USB Type-C USCI controller (Function 3) > >> > >> The function 0 is tightly coupled with other functions in the > >> hardware. When function 0 goes in runtime suspended state, > >> then it will do power gating for most of the hardware blocks. > >> Some of these hardware blocks are used by other functions which > >> leads to functional failure. So if any of these functions (1/2/3) > >> are active, then function 0 should also be in active state. > > > >> 'commit 07f4f97d7b4b ("vga_switcheroo: Use device link for > >> HDA controller")' creates the device link from function 1 to > >> function 0. A similar kind of device link needs to be created > >> between function 0 and functions 2 and 3 for NVIDIA Turing GPU. > > > > I can't point to language that addresses this, but this sounds like a > > case of the GPU not conforming to the PCI spec. The general > > assumption is that the OS should be able to discover everything it > > needs to do power management directly from the architected PCI config > > space. > > The GPU is following PCIe spec but following is the implementation > from HW side Unless you can find spec language that talks about D-state dependencies between functions, I claim this is not following the PCIe spec. For example, PCIe r5.0, sec 1.4, says "the PCI/PCIe hardware/software model includes architectural constructs necessary to discover, configure, and use a Function, without needing Function- specific knowledge." Sec 5.1 says "D states are associated with a particular Function" and "PM provides ... a mechanism to identify power management capabilities of a given Function [and] the ability to transition a Function into a certain power management state." If there *is* something about dependencies between functions in the spec, we should improve the generic PCI core to pay attention to that, and then we wouldn't need this quirk. If the spec doesn't provide a way to discover them, these dependencies are exceptions from the spec, and we have to handle them as hardware defects, using quirks like this. That's fine, but let's not pretend that this is a conforming device and that adding quirks is the expected process. Just call a spade a spade and say we're working around a defect in this particular device. I think the best path forward would be to add this quirk for the existing device, and then pursue a spec change to add something like a new PCIe capability to describe the dependencies. Then we could enhance the PCI core once and power management for future devices would "Just Work" without having to add quirks. Bjorn