From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752051AbbIAXOM (ORCPT ); Tue, 1 Sep 2015 19:14:12 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:33852 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751029AbbIAXOJ (ORCPT ); Tue, 1 Sep 2015 19:14:09 -0400 MIME-Version: 1.0 In-Reply-To: <1440089947-2839-3-git-send-email-sean.stalley@intel.com> References: <1440089947-2839-1-git-send-email-sean.stalley@intel.com> <1440089947-2839-3-git-send-email-sean.stalley@intel.com> Date: Tue, 1 Sep 2015 16:14:08 -0700 X-Google-Sender-Auth: C18WWwOGT7WtEAZKcdTxLMPj9eg Message-ID: Subject: Re: [PATCH 2/2] PCI: Add support for Enhanced Allocation devices From: Yinghai Lu To: "Sean O. Stalley" Cc: Bjorn Helgaas , Rajat Jain , "Michael S. Tsirkin" , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , "gong.chen@linux.intel.com" , "linux-pci@vger.kernel.org" , Linux Kernel Mailing List , linux-api@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 20, 2015 at 9:59 AM, Sean O. Stalley wrote: > Add support for devices using Enhanced Allocation entries instead of BARs. > This patch allows the kernel to parse the EA Extended Capability structure > in PCI configspace and claim the BAR-equivalent resources. > > Signed-off-by: Sean O. Stalley > --- > drivers/pci/pci.c | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > drivers/pci/pci.h | 1 + > drivers/pci/probe.c | 3 + > 3 files changed, 223 insertions(+) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index 0008c95..c8217a8 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c ... > + > +/* Read an Enhanced Allocation (EA) entry */ > +static int pci_ea_read(struct pci_dev *dev, int offset) > +{ ... > + res->name = pci_name(dev); > + res->start = start; > + res->end = end; > + res->flags = flags; > + > + pci_ea_claim_resource(dev, res); > + > +out: > + return offset + ent_size; > +} > + > +/* Enhanced Allocation Initalization */ > +void pci_ea_init(struct pci_dev *dev) > +{ ... > + > + for (i = 0; i < num_ent; ++i) { > + /* parse each EA entry */ > + dev_dbg(&dev->dev, "%s: parsing entry %i...\n", __func__, i); > + offset = pci_ea_read(dev, offset); > + } > +} > + > static void pci_add_saved_cap(struct pci_dev *pci_dev, > struct pci_cap_saved_state *new_cap) > { > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index cefd636..4cadf35 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -1522,6 +1522,9 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) > > static void pci_init_capabilities(struct pci_dev *dev) > { > + /* Enhanced Allocation */ > + pci_ea_init(dev); > + > /* MSI/MSI-X list */ > pci_msi_init_pci_dev(dev); > Should not call pci_ea_claim_resource() that early. For x86 and other arches, we call pcibios_resource_survey/pcibios_allocate_bus_resouce/pcibios_allocate_resources quite late. Yinghai