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: 4897481 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8EDD5BEEA5 for ; Fri, 12 Sep 2014 18:07:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5260320221 for ; Fri, 12 Sep 2014 18:07:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16B492021B for ; Fri, 12 Sep 2014 18:07:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752024AbaILSDN (ORCPT ); Fri, 12 Sep 2014 14:03:13 -0400 Received: from mail-ig0-f181.google.com ([209.85.213.181]:64242 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752002AbaILSDK (ORCPT ); Fri, 12 Sep 2014 14:03:10 -0400 Received: by mail-ig0-f181.google.com with SMTP id h3so963101igd.8 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=CvleN4+SYN1HXcXIpAJiHAsrUpnpmhJYCq5UitB30Xn/fZXFye8qdRi3vsUjrQ5xLe JK+8tlnmgx8VhS41RqWBCqZH5AAYTaxndt6uJZZBZCG7G86Imj9IjXSV70F7vF3cIIKZ OeH3PaPsJBU2Qxna+UPGMpE/PPyEVcpc9605XbHx6luenxqqvjm58zhNkOCxwrkIlJ0h cERVpztAC4EBox5cOl8t09P2iaB9a3aRSQpP5SpceR1pRRcdhVaDIYyhGbfXZ1v+xEer EskUIzTKtBTq0i5zl3GzpCVO+zqwSC4amSkQpk7202BjPKHjG5urP+MzGHynUG+YzpEH IH/g== X-Gm-Message-State: ALoCoQlaYT512Dzlaog7KIS5lbyVKrEDl8QMcsgcWDawSyO2Kd0mUoyi5I154AQs1oumfcpXaMUH 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-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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-pci" 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;