From patchwork Mon Jan 14 11:15:08 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: 155444 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3537063jaa; Mon, 14 Jan 2019 03:17:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN71CWnpnqm5dUzywqsDdZo0VP/elSU8nqaN76Ez18tT37pW81UE0eWBekH6Z/1uAISgFc2r X-Received: by 2002:a62:6f88:: with SMTP id k130mr24715812pfc.234.1547464626696; Mon, 14 Jan 2019 03:17:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547464626; cv=none; d=google.com; s=arc-20160816; b=Qx9uXGDeVmPoi1wyLbVL0visBjDCCI+MZX4vFtFZmXMOZZFNOQCl9I3CuhBU26G4J5 AZ5rDyIab95TZS5gRYBNENV5+48MzM4nRWwKjP1hePr10NifJSGswjJ5nZEW5tMM3J5a LpB00QJtjh3m2mhxxv6I1J47DrT9SFjdq5a21vzZwybvc56LneUhcMZvmBYcjJo2zse0 Zd+9CJnC/aEBeuiInxFq9W3KkfXfJl1SpW5ehJ8wskOeJo1edppUSIKbwwKlXFdRqogF OWvKjd1qa0heTy6aN1kYAASTYHlGpArFfju8G/H8vGXyrJnUQWS2T3dVI/qpNzolB815 a0WA== 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=9uy7oBAgopBKXmOWf1Xu6i0EmqFED+atLS7+JVzPan8=; b=Lc8oE/6JVvKy+EreFOoRF0tINE3OH4Mpf3YRWHxV1gSeeDqBZgeFDrNaqoxEhm13Bk X++YVnMZWgTpjreT3Tuek1H27IPHD9/PprqwI+TD1g9MVIWBQdn7zZ3NJFIRgJA+IEFy hC9PT4qny2P0qvUE3c7wuQMOHsk9fCfs2d71xbmEASvhxrffoN24m0SW/4sVvb1V9pLz z580U5jQhK088kICA0mL6K+Qdpf8IL71yQxjK0c1/KWCo0sDLaBj7+rdq9Hv+thgeAEc Hmx8d2TqZZSh8SErIo+/3T5WAauZ4MZ0ce4JOY2lTEfrJDdBQ3b+YGPqLcfloXAA1r2p sAzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=P7XFzsI5; 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 s5si113260plr.211.2019.01.14.03.17.06; Mon, 14 Jan 2019 03:17:06 -0800 (PST) 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=P7XFzsI5; 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 S1726851AbfANLRF (ORCPT + 31 others); Mon, 14 Jan 2019 06:17:05 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:46922 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726561AbfANLRC (ORCPT ); Mon, 14 Jan 2019 06:17:02 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x0EBGMva065556; Mon, 14 Jan 2019 05:16:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1547464582; bh=9uy7oBAgopBKXmOWf1Xu6i0EmqFED+atLS7+JVzPan8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=P7XFzsI5AoIR5lwIf7kdytlIcvYG00NuEKVT4PSzp9QW8AhQvxBUBmmb2XZYz8W8b GKgjjaaZ/1uHaeqpM/3tdbWaQwPnmby9LN5zD/X6UYTmmxqapNrzQcC+UYaDcXkRbv Im82/pbFYLEuc3n10X216xnTWvR7ImNq0PACzjiM= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x0EBGMVu024049 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 14 Jan 2019 05:16:22 -0600 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 14 Jan 2019 05:16:21 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 14 Jan 2019 05:16:21 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x0EBFd1c011560; Mon, 14 Jan 2019 05:16:18 -0600 From: Kishon Vijay Abraham I To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Gustavo Pimentel , Alan Douglas , Shawn Lin , Heiko Stuebner CC: Bjorn Helgaas , Jingoo Han , , , , , Subject: [PATCH v2 10/15] PCI: pci-epf-test: Do not allocate next BARs memory if current BAR is 64Bit Date: Mon, 14 Jan 2019 16:45:08 +0530 Message-ID: <20190114111513.21618-11-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190114111513.21618-1-kishon@ti.com> References: <20190114111513.21618-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 It's useless to allocate memory for next BAR if the current BAR is a 64Bit BAR. Stop allocating memory for the next BAR, if the current BARs flag indicates this is a 64Bit BAR. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/functions/pci-epf-test.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.17.1 diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 44cc31343a80..ade296180383 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -429,6 +429,7 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) { struct pci_epf_test *epf_test = epf_get_drvdata(epf); struct device *dev = &epf->dev; + struct pci_epf_bar *epf_bar; void *base; int bar; enum pci_barno test_reg_bar = epf_test->test_reg_bar; @@ -442,6 +443,7 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) epf_test->reg[test_reg_bar] = base; for (bar = BAR_0; bar <= BAR_5; bar++) { + epf_bar = &epf->bar[bar]; if (bar == test_reg_bar) continue; base = pci_epf_alloc_space(epf, bar_size[bar], bar); @@ -449,6 +451,8 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) dev_err(dev, "Failed to allocate space for BAR%d\n", bar); epf_test->reg[bar] = base; + if (epf_bar->flags & PCI_BASE_ADDRESS_MEM_TYPE_64) + bar++; } return 0;