From patchwork Fri Sep 12 18:03:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 4897471 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7936A9F430 for ; Fri, 12 Sep 2014 18:02:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7442B2024C for ; Fri, 12 Sep 2014 18:07:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B6FF2021B for ; Fri, 12 Sep 2014 18:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752032AbaILSDN (ORCPT ); Fri, 12 Sep 2014 14:03:13 -0400 Received: from mail-ig0-f173.google.com ([209.85.213.173]:48796 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751884AbaILSDK (ORCPT ); Fri, 12 Sep 2014 14:03:10 -0400 Received: by mail-ig0-f173.google.com with SMTP id l13so959206iga.12 for ; Fri, 12 Sep 2014 11:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=NWc6AggOxSddoPGyW3ZHSyMDVaFCmsXTtEcdDNQ804k=; b=iObv0e4fJ+l2fNBaLAanMiWNWOJtZiGw3/M7gav6I6GP4sj7/I+4weRKhugZS0O7N7 WRGfQ7UmCvk2aQkd+aNDmcGar1ASkV8+9W9IoB9CkNpvHMslUsvxX7XFDUMSwU6bHQAr g64Snzm1Hpp4IIbKN6dubTfKoKHEfKzou/Gy5fMn66xfXmi5k5q0gvnhGTCMwlNmZVPj K33rRRv5JnkcIbiI+QUe6k+Yqg5WG8IJ4LscrGWWMKnXfVBFMYZVW+EDd4bP6FQTKLqH PsVSnLKpC/SbXRaPL55Yocs8aJMXnM9mzl0iaokMx++N9Oc9DSvs9s7q4IPcE6tSL91H E0fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=NWc6AggOxSddoPGyW3ZHSyMDVaFCmsXTtEcdDNQ804k=; b=h0+rytDP2bH3FcBrnz2gEo8xAYodpfsb6guUahgiLx/T7oc3q0ooADZkE1wHNdlHyW 7Q3sSuyXrTBRQx9Km6cgtnKOcLxBDhIVjt1YD7iHbY8LBckQpjiYeX11z/yVjoFVsVGa cok+Hd7k/6cQFuic9ZjSo9j3FzF27AenOZEHmM7wVjhnIT7aH+O/xrTneWnZQIV81UT8 zbpP6HjQQHW9FOJYNHfpddHtyI+Dk7++6GDq/GIIj4Zgeg1aEx8aX3AexaX471vFe3bT xHzWyGpR6DvFecWkqGhPQM/1j/pydChxzYnB1P0T091AJ0FjxU/cw6z7fweosJ7ui7gY dV0A== X-Gm-Message-State: ALoCoQmaOlZfYyMft/jxsbKp5/DIFqwswqaNUOmGdZ7+r1aWbbg+246ruVpAYFBsCA997Fs8FDq4 X-Received: by 10.50.142.68 with SMTP id ru4mr4417454igb.18.1410544989389; Fri, 12 Sep 2014 11:03:09 -0700 (PDT) Received: from localhost ([172.16.49.108]) by mx.google.com with ESMTPSA id i6sm2096147igm.6.2014.09.12.11.03.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 12 Sep 2014 11:03:08 -0700 (PDT) Subject: [PATCH v1 03/13] PCI: Add pci_configure_device() during enumeration To: linux-pci@vger.kernel.org From: Bjorn Helgaas Cc: Rajat Jain , Linus Torvalds , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Yinghai Lu Date: Fri, 12 Sep 2014 12:03:07 -0600 Message-ID: <20140912180307.1630.63799.stgit@bhelgaas-glaptop2.roam.corp.google.com> In-Reply-To: <20140912180141.1630.17120.stgit@bhelgaas-glaptop2.roam.corp.google.com> References: <20140912180141.1630.17120.stgit@bhelgaas-glaptop2.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some platforms can tell the OS how to configure PCI devices, e.g., how to set cache line size, error reporting enables, etc. ACPI defines _HPP and _HPX methods for this purpose. This configuration was previously done by some of the hotplug drivers using pci_configure_slot(). But not all hotplug drivers did this, and per the spec (ACPI rev 5.0, sec 6.2.7), we can also do it for "devices not configured by the BIOS at system boot." Move this configuration into the PCI core by adding pci_configure_device() and calling it from pci_device_add(), so we do this for all devices as we enumerate them. This is based on pci_configure_slot(), which is used by hotplug drivers. I omitted: - pcie_bus_configure_settings() because it configures MPS and MRRS, which requires global knowledge of the fabric and must be done later, and - configuration of subordinate devices; that will happen when we call pci_device_add() for those devices. Because pci_configure_slot() was only done by hotplug drivers, this initial version of pci_configure_device() only configures hot-added devices, ignoring anything added during boot. Signed-off-by: Bjorn Helgaas --- drivers/pci/probe.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 5d0cc646817a..93d2b41163fa 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1384,6 +1384,30 @@ void pci_configure_slot(struct pci_dev *dev) } } EXPORT_SYMBOL_GPL(pci_configure_slot); + +static void pci_configure_device(struct pci_dev *dev) +{ + struct hotplug_params hpp; + int ret; + + if (system_state == SYSTEM_BOOTING) + return; + + if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL || + (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE && + (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) + return; + + memset(&hpp, 0, sizeof(hpp)); + ret = pci_get_hp_params(dev, &hpp); + if (ret) + return; + + program_hpp_type2(dev, hpp.t2); + program_hpp_type1(dev, hpp.t1); + program_hpp_type0(dev, hpp.t0); +} + static void pci_release_capabilities(struct pci_dev *dev) { pci_vpd_release(dev); @@ -1521,6 +1545,8 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) { int ret; + pci_configure_device(dev); + device_initialize(&dev->dev); dev->dev.release = pci_release_dev;