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: 7211441 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 7F3039F39B for ; Thu, 17 Sep 2015 22:42:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DB0720742 for ; Thu, 17 Sep 2015 22:42:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AFB8C20591 for ; Thu, 17 Sep 2015 22:42:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752121AbbIQWlp (ORCPT ); Thu, 17 Sep 2015 18:41:45 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:34415 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811AbbIQWln (ORCPT ); Thu, 17 Sep 2015 18:41:43 -0400 Received: by iofb144 with SMTP id b144so38688504iof.1; 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 Cc: David Daney 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> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 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)) {