From patchwork Thu Sep 26 11:29:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 174466 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1920319ill; Thu, 26 Sep 2019 04:31:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk5/XJvkf08+FGw7cwh/mZZ6lK+euYftdbC5JiUvDGQR8pL3+J3CQ7oYCkNDt+uzc6w11o X-Received: by 2002:a17:906:7798:: with SMTP id s24mr2606480ejm.211.1569497480503; Thu, 26 Sep 2019 04:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569497480; cv=none; d=google.com; s=arc-20160816; b=apv7qYG4tWLA3yNsEEaro66N/tpNu+ulAFJBxPragd4+RbaQeYUZCzrLYfj+Wio4nd t/YBsQmdtWVIqkfstW/rZ67+HLzGjoU4RH3p0w0zwYPU+ZQRlNffUu3ARWIXVtJyaOEv zh6XpaGrU/g4FkiS1sgUplABLdOXOkrOuQIu+a+H43mBPSfMnvE+1wicX6O7xjnFUofm jXlYpuAjCLdzpeet/o5/5YnqUrWRQ+pty+rjCIrYXFjcuy1Z6VFS013E8SZYyxS2oSto LZA8gqV/S8cU+wjlPLl4sKHkbr8rVyOwyIAcC6BQq9f5vTFwoQIL1M88cyr6tnDGqpwQ Kd/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=1Pg02YjtJWenOS8TSc+kZXfjbcewS60naZ8ogDPEpQ0=; b=rQx2troIEILx4lOtLGxXWv1Tg8N4HF7Ql2SdYHmbn6/Sn434y9bHDTZHOPTn0I/+wF 76xQVufcSej1KHPQilidRZHgkCPp4Qc17EPNqNwPjElZWAoKPE/c9dn+diNTYaJCRgIr xW3yKUxUNEdjIf+pHfPOZTGajdKlFtFJI7QRzHA2wnQAJZQ/ipVLqFvig2h9LIkFyKk/ WFfZlJL7TP4P+GorukafN8pjBA34phfbpepiSnVS+2ebnUE0r+7FIx5SyWiQ4psls5vc 3TymqU+Kb3LO98BTnHLopxp1oYHqH9NxHauU+24CkuNLfGePP9hMvp9cvurfOC/pQeIA tTHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=oJoWYIr7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10si1135490eda.293.2019.09.26.04.31.20; Thu, 26 Sep 2019 04:31:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=oJoWYIr7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726515AbfIZLbT (ORCPT + 26 others); Thu, 26 Sep 2019 07:31:19 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:57180 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbfIZLbQ (ORCPT ); Thu, 26 Sep 2019 07:31:16 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8QBV7V5026389; Thu, 26 Sep 2019 06:31:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1569497467; bh=1Pg02YjtJWenOS8TSc+kZXfjbcewS60naZ8ogDPEpQ0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=oJoWYIr7EsDX2IEqmzdUO07/fyqW/bTeExyro+qKR3oV9FgpHXuNnBT1HRnq9vv3m GUNHuTI5N98HjIZvjbO2c2fAgHYBiPDNsza3/tzRMfH6ch6+JQmvUpr03KIrsj/arT RFtsW2mTTMr+24QZb2QClokOA/91cAhcvRViDiRk= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8QBV7st050327 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 26 Sep 2019 06:31:07 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 26 Sep 2019 06:31:00 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 26 Sep 2019 06:30:59 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8QBUTk1069017; Thu, 26 Sep 2019 06:31:03 -0500 From: Kishon Vijay Abraham I To: Bjorn Helgaas , Jonathan Corbet , Rob Herring , Jon Mason , Dave Jiang , Allen Hubbe , Lorenzo Pieralisi CC: Mark Rutland , , , , , , Subject: [RFC PATCH 08/21] PCI: endpoint: Make *_get_first_free_bar() take into account 64 bit BAR Date: Thu, 26 Sep 2019 16:59:20 +0530 Message-ID: <20190926112933.8922-9-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190926112933.8922-1-kishon@ti.com> References: <20190926112933.8922-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pci_epc_get_first_free_bar() uses only "reserved_bar" member in epc_features to get the first unreserved BAR. However if the reserved BAR is also a 64-bit BAR, then the next BAR shouldn't be returned (since 64-bit BAR uses two BARs). Make pci_epc_get_first_free_bar() take into account 64 bit BAR while returning the first free unreserved BAR. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-epc-core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 0c2fdd39090c..7eae7dcaebf9 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -153,12 +153,20 @@ EXPORT_SYMBOL_GPL(of_pci_epc_get_by_name); unsigned int pci_epc_get_first_free_bar(const struct pci_epc_features *epc_features) { - int free_bar; + unsigned long free_bar; if (!epc_features) return 0; - free_bar = ffz(epc_features->reserved_bar); + /* Find if the reserved BAR is also a 64-bit BAR */ + free_bar = epc_features->reserved_bar & epc_features->bar_fixed_64bit; + + /* Set the adjacent bit if the reserved BAR is also a 64-bit BAR */ + free_bar <<= 1; + free_bar |= epc_features->reserved_bar; + + /* Now find the free BAR */ + free_bar = ffz(free_bar); if (free_bar > 5) return 0;