From patchwork Fri Jan 29 14:17:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 60794 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1146244lbb; Fri, 29 Jan 2016 06:19:45 -0800 (PST) X-Received: by 10.66.102.70 with SMTP id fm6mr13737603pab.80.1454077185176; Fri, 29 Jan 2016 06:19:45 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id m79si24576451pfj.40.2016.01.29.06.19.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jan 2016 06:19:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.org 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 1aP9rv-00015I-TN; Fri, 29 Jan 2016 14:17:47 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aP9rs-00010L-J3 for linux-arm-kernel@lists.infradead.org; Fri, 29 Jan 2016 14:17:45 +0000 Received: by mail-wm0-x22a.google.com with SMTP id p63so70478313wmp.1 for ; Fri, 29 Jan 2016 06:17:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=kzQ2FYEEs/9wzlcXKyn+eF4JWnq4/Anie0BH3pnRnD8=; b=eNPwcfuomstuCskLfsPO1aOXXtjnn0dpKMf6YpDZ/WDCWlQ8pjRUnmif04ScolIXPo atS6iyuA/a4m8uGwk/spuYhsicvauI09OgFtdPR00mkxGabkO1za79KJwyyFVez01hV6 tLxOQNf/OXljGXFkwhc3trzijcRpaxib4QPwQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kzQ2FYEEs/9wzlcXKyn+eF4JWnq4/Anie0BH3pnRnD8=; b=O0t1ipwO6EDtA1ngIC3oLQdqP+NKzWlrGV/wu9QTA1YG3+dgv+ciMVEowMhq16XRUm FJLBeatUAZ/9sCpiuEH4N6cxXbRKhDQrLjm3StWIOvAYzGXQHX0lfBALFZK7j9Th8AYu VxC0dsQFfr7XS7ZgNOgPnbFnRoYLzICNixm+3alFcUeP5QFXKkg+krkVhze35x3WkMY0 pm5iZ/VV2YB7/1etATwKixJnpGMNQ34HHvkzqIMjSJSlwxqkx7xAqdZoii5OZf2FMB3D clgxWKDLdUYSy5IvFJsruBI4oekCPejNu2IH8s3U3ISoc1nCXwWbaW2s2NX9jyXwaXjZ dJ7Q== X-Gm-Message-State: AG10YOTWKZPLcodtIyzrWacJ96imiETwoJk/II2LI3V/YGoW0gqK7JGjyMkpFy7sKSA1CCOi X-Received: by 10.28.182.133 with SMTP id g127mr8937612wmf.61.1454077041900; Fri, 29 Jan 2016 06:17:21 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id ka4sm15861229wjc.47.2016.01.29.06.17.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jan 2016 06:17:20 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, linux-pci@vger.kernel.org Subject: [PATCH] PCI: generic: map config window in one go Date: Fri, 29 Jan 2016 15:17:15 +0100 Message-Id: <1454077035-23872-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160129_061744_778720_B1290D22 X-CRM114-Status: GOOD ( 12.14 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22a listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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: bhelgaas@google.com, mark.brown@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Instead of iterating over the PCI config window and performing individual ioremap() calls on all the adjacent slices, perform a single ioremap() to map the entire region, and divvy it up later. This not only prevents leaving some of it mapped if we fail half way through, it also ensures that archs that support huge-vmap can use section mappings to perform the mapping. On my Seattle A0 box, this transforms 128 separate 1 MB mappings that are mapped down to 4 KB pages into a single 128 MB mapping using 2 MB sections, saving 512 KB worth of page tables. Signed-off-by: Ard Biesheuvel --- huge-vmap for arm64 proposed here: http://article.gmane.org/gmane.linux.kernel.hardened.devel/1661 drivers/pci/host/pci-host-generic.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c index 1652bc70b145..3251cd779278 100644 --- a/drivers/pci/host/pci-host-generic.c +++ b/drivers/pci/host/pci-host-generic.c @@ -161,6 +161,7 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci) struct device *dev = pci->host.dev.parent; struct device_node *np = dev->of_node; u32 sz = 1 << pci->cfg.ops->bus_shift; + void *window; err = of_address_to_resource(np, 0, &pci->cfg.res); if (err) { @@ -186,14 +187,15 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci) return -ENOMEM; bus_range = pci->cfg.bus_range; + window = devm_ioremap(dev, pci->cfg.res.start, + (bus_range->end - bus_range->start + 1) * sz); + if (!window) + return -ENOMEM; + for (busn = bus_range->start; busn <= bus_range->end; ++busn) { u32 idx = busn - bus_range->start; - pci->cfg.win[idx] = devm_ioremap(dev, - pci->cfg.res.start + idx * sz, - sz); - if (!pci->cfg.win[idx]) - return -ENOMEM; + pci->cfg.win[idx] = window + idx * sz; } return 0;