From patchwork Tue Oct 6 23:50:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 527059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1115D140082 for ; Wed, 7 Oct 2015 10:51:41 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=JHGd/vWw; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753063AbbJFXvL (ORCPT ); Tue, 6 Oct 2015 19:51:11 -0400 Received: from mail-qk0-f174.google.com ([209.85.220.174]:32887 "EHLO mail-qk0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753051AbbJFXut (ORCPT ); Tue, 6 Oct 2015 19:50:49 -0400 Received: by qkas79 with SMTP id s79so570680qka.0; Tue, 06 Oct 2015 16:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GiTuuVzz4ZPIoUXxP406HKaOJ2CRUMj9oCO57eIz668=; b=JHGd/vWw+nCDFS46Y+cPMiKaOI1EpmD1wFpTIsLFxrxaFlVapZ084vR2+063wg8Yc9 1Wf4Z8AhLKNJrPYg/TuccjZ1kqYhJVoXN8B08/uIYnc9TA1cvtHC/Rm86wpLaSkv/SdO qGVVwA4O3g7J37DvqIIbDLhFJDAPbXBAdHd94vOukV5S5NctywdCotvwczoL5jo6Kkwx kV4rTd27seLZRZPlsCWQS2N/bWzPIRhgJnCWYnGzDrl77dIPsw2jFx1bKTmwO85DEfqJ k0f9E7WrHESKZ9XwTf12V9NfiKONOMglcGvsWTnYAcsQ6bJCDzoflKPAbTFEvhBjlg+P g6uQ== X-Received: by 10.55.26.14 with SMTP id a14mr40839475qka.99.1444175448759; Tue, 06 Oct 2015 16:50:48 -0700 (PDT) Received: from dl.caveonetworks.com (64.2.3.194.ptr.us.xo.net. [64.2.3.194]) by smtp.gmail.com with ESMTPSA id o65sm14925502qhb.21.2015.10.06.16.50.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 06 Oct 2015 16:50:47 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id t96NoikO007499; Tue, 6 Oct 2015 16:50:44 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id t96Noi7A007498; Tue, 6 Oct 2015 16:50:44 -0700 From: David Daney To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas , "Michael S. Tsirkin" , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , linux-api@vger.kernel.org, "Sean O. Stalley" , yinghai@kernel.org, rajatxjain@gmail.com, gong.chen@linux.intel.com Cc: David Daney Subject: [PATCH v5 4/4] PCI: Handle Enhanced Allocation (EA) capability for SRIOV devices. Date: Tue, 6 Oct 2015 16:50:38 -0700 Message-Id: <1444175438-7443-5-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1444175438-7443-1-git-send-email-ddaney.cavm@gmail.com> References: <1444175438-7443-1-git-send-email-ddaney.cavm@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: David Daney SRIOV BARs can be specified via EA entries. Extend the EA parser to extract the SRIOV BAR resources, and modify sriov_init() to use resources previously obtained via EA. Signed-off-by: David Daney --- drivers/pci/iov.c | 11 +++++++++-- drivers/pci/pci.c | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index ee0ebff..c789e68 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -436,8 +436,15 @@ found: nres = 0; for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { res = &dev->resource[i + PCI_IOV_RESOURCES]; - bar64 = __pci_read_base(dev, pci_bar_unknown, res, - pos + PCI_SRIOV_BAR + i * 4); + /* + * If it is already FIXED, don't change it, something + * (perhaps EA or header fixups) wants it this way. + */ + if (res->flags & IORESOURCE_PCI_FIXED) + bar64 = (res->flags & IORESOURCE_MEM_64) ? 1 : 0; + else + bar64 = __pci_read_base(dev, pci_bar_unknown, res, + pos + PCI_SRIOV_BAR + i * 4); if (!res->flags) continue; if (resource_size(res) & (PAGE_SIZE - 1)) { diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 30a90d1..6c41585 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2176,6 +2176,13 @@ static struct resource *pci_ea_get_resource(struct pci_dev *dev, u8 bei, { if (bei <= PCI_EA_BEI_BAR5 && prop <= PCI_EA_P_IO) return &dev->resource[bei]; +#ifdef CONFIG_PCI_IOV + else if (bei >= PCI_EA_BEI_VF_BAR0 && bei <= PCI_EA_BEI_VF_BAR5 && + (prop == PCI_EA_P_VIRT_MEM || + prop == PCI_EA_P_VIRT_MEM_PREFETCH)) + return &dev->resource[PCI_IOV_RESOURCES + + bei - PCI_EA_BEI_VF_BAR0]; +#endif else if (bei == PCI_EA_BEI_ROM) return &dev->resource[PCI_ROM_RESOURCE]; else