From patchwork Fri Oct 2 22:37:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 525842 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 9BDF9140180 for ; Sat, 3 Oct 2015 08:40:57 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=C3Qxc/nd; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751989AbbJBWjX (ORCPT ); Fri, 2 Oct 2015 18:39:23 -0400 Received: from mail-io0-f175.google.com ([209.85.223.175]:33175 "EHLO mail-io0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751575AbbJBWiE (ORCPT ); Fri, 2 Oct 2015 18:38:04 -0400 Received: by iofh134 with SMTP id h134so135651428iof.0; Fri, 02 Oct 2015 15:38:03 -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=5MOr9K+y8/o6uzKeIiPEMguJbzcuGSa5xkA94mp278s=; b=C3Qxc/nd8D+IdRJKYQIM7mDzVkKR+R21/4oMAjs07M2k2PY5PHmdY58YpwquluohK+ m8fZPfcQTuq0y5UJTSZdw4XufKJMW4rKq3KWnVCV5eVKnYYXJGGyf6FpCiPtsHi/wWco Q+haCwCuEPLLVD9TB4fZReFqk6TucBSdIYjapuVhrp4i8lpu7ce2BVnqooSxIVbwTGNY YLk7WtCFKhXhSpGFjHTuCD6ugTFrHP+uifm3twxkaMaylZ5eDQ6/XR/1Vy98gik7TNjD pPS6l6oyMyFCWXdewan9du3kx8+2h5mDi2WDpsDplixClAOjGzPauenYVGoLQVqLc1iV s/AQ== X-Received: by 10.107.10.11 with SMTP id u11mr20876931ioi.36.1443825483842; Fri, 02 Oct 2015 15:38:03 -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 y6sm464116igl.17.2015.10.02.15.38.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 02 Oct 2015 15:38:00 -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 t92MbxhD026935; Fri, 2 Oct 2015 15:37:59 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id t92MbxTQ026934; Fri, 2 Oct 2015 15:37:59 -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 v4 4/5] PCI: Handle Enhanced Allocation (EA) capability for SRIOV devices. Date: Fri, 2 Oct 2015 15:37:55 -0700 Message-Id: <1443825476-26880-5-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1443825476-26880-1-git-send-email-ddaney.cavm@gmail.com> References: <1443825476-26880-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 | 5 +++++ 2 files changed, 14 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 54a0a98..6750edf 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2178,6 +2178,11 @@ static struct resource *pci_ea_get_resource(struct pci_dev *dev, u8 bei, u8 prop { 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