From patchwork Thu Sep 17 22:41:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 7211511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6C8A19F39B for ; Thu, 17 Sep 2015 22:43:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90A6920734 for ; Thu, 17 Sep 2015 22:43:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C33B220591 for ; Thu, 17 Sep 2015 22:43:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zchsa-0004cv-5u; Thu, 17 Sep 2015 22:42:12 +0000 Received: from mail-io0-x22e.google.com ([2607:f8b0:4001:c06::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZchsQ-0004Oq-Sa for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2015 22:42:04 +0000 Received: by iofh134 with SMTP id h134so38587182iof.0 for ; Thu, 17 Sep 2015 15:41:42 -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=1Bzxl7aItH+Pnjv0x+VOnwfU0qTnaqljMQ7YfGf5vWs=; b=qJ1w0Zf5Ys+/j25esprGatu+RqF1ChmCXcuJjEBvFoQnF/ogbK7G7xXaZ0Vfv6khp9 NXRRo9Vs1alCrLK3YRYjhnMYLdWZ9dFOjJR5TmUCoiH4LUiQFDXohu0q+ILusrDfRKzl Ao8HHE7Tn8Q32ITqTom64JOWhCBD+McKHqCgNgBkjPLymfBsabPCeU+0jBN7wd5RPSB9 ara+7cAJ1/FpbzrdxlirmOD7QXNPBOvF74DDeeIETQoHwUOeFPNUaqQcOT2vNKfGSY+M oTkmsNRh3THKE8rMqNcrR/VGSEtiD3jCdwnOo7Gg/m3OwE0W/BfMYYc2T0eLcrJftYR/ dQTw== X-Received: by 10.107.7.225 with SMTP id g94mr10903168ioi.28.1442529702334; Thu, 17 Sep 2015 15:41:42 -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 v10sm5185620igh.12.2015.09.17.15.41.40 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 17 Sep 2015 15:41:41 -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 t8HMfdUb001833; Thu, 17 Sep 2015 15:41:39 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id t8HMfdrr001832; Thu, 17 Sep 2015 15:41:39 -0700 From: David Daney To: linux-kernel@vger.kernel.org, Bjorn Helgaas , linux-pci@vger.kernel.org, Will Deacon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Marc Zyngier Subject: [PATCH 1/3] PCI: Allow quirks to override SRIOV BARs. Date: Thu, 17 Sep 2015 15:41:32 -0700 Message-Id: <1442529694-1792-2-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1442529694-1792-1-git-send-email-ddaney.cavm@gmail.com> References: <1442529694-1792-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150917_154202_977491_8D90FF67 X-CRM114-Status: GOOD ( 14.32 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Daney MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: David Daney Devices with fixed BARs can install BAR resources with IORESOURCE_PCI_FIXED from the header fixup. Allow this to work with the SRIOV BARs as well by testing if the BAR resource has already been set before attempting to read it from the config space. Signed-off-by: David Daney --- drivers/pci/iov.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index ee0ebff..f8a6e1e 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -436,8 +436,13 @@ 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 (res->flags) + /* Already populated by quirks, just set bar64. */ + 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)) {