From patchwork Mon Aug 28 15:30:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_L=C3=BCbbe?= X-Patchwork-Id: 9925825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E2D460380 for ; Mon, 28 Aug 2017 15:50:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F9F1286E5 for ; Mon, 28 Aug 2017 15:50:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7462528706; Mon, 28 Aug 2017 15:50:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EAAC9286E5 for ; Mon, 28 Aug 2017 15:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lBIHco796WErui8VdY2WSk7FVfGkNr2+zf5Lz0gO0uY=; b=jhZEHIfBMCcdlxIJNj730HWp3a 2LxMtkGp04KNuQ5/+c4C0jPpEqOP5FYVWSnjLZq8BedfI8C9nVpgX0l2aWWiscWnv02/JoOeJCGY5 863QDd8saYzgTMteYFN5gu9UShYwPuxOp6uFBzjo7zNa6dvZzOAEChOZBrRmmc8esIoFHzU11iE2X f7ODUH9AWPh6Rg9wvRfiBKAiNKGrCBRlYcuJkTeTxd+7bk+U3cdYA12BCsMIxQhT6Nrlz3wkIeWos lzSIKebsPD2L7cOE56KwoTLx72/P04Dux0gleqdUaT7/Mw3plHYT096rX26L7nPup5IK0gZz4M2oV 5AaYHeYQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dmMIs-0000D2-4L; Mon, 28 Aug 2017 15:50:18 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmMIq-0000Cj-AX for linux-arm-kernel@bombadil.infradead.org; Mon, 28 Aug 2017 15:50:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cRw/kiDAdGent5fvqBpBXu+y6ZdutDv2edVlgLJUuZU=; b=R8ZwlprEMukyF1zKknSQnKNzk W0LLvXsRla3IGzY8T9jX9RTJRtyschq1TVed1/kaW6YFIEgEhXjQukvO5UIljA0t9b27WlT+ydNWR ICSsm2yEmwvpN0vvMRFltjGGdtkSF5EBd5BxZltQR2aHmFqUerVuzrKWpUF+binQPmz4kRTJVKXMt 84OLZcTBmwLfIBNq8jA7S9bWM0JnWDSDyHkbCHRurU7tRBBlK3Xzx1rVDUZxFnp4cDawl/WG24nb0 3aMcKYgZXZf7JsEzeEOreQvVXFJ7Fx3reHFaetFoSdsYvHxMzXjbfDnwuEZ7tFJUXOxcIOWm8FmNP wM/Qp0ZDQ==; Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmM0I-0006p5-Lp for linux-arm-kernel@lists.infradead.org; Mon, 28 Aug 2017 15:31:07 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dmLzw-0000kc-LO; Mon, 28 Aug 2017 17:30:44 +0200 Received: from jlu by dude.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1dmLzw-00073i-Bh; Mon, 28 Aug 2017 17:30:44 +0200 From: Jan Luebbe To: Gregory Clement , Andrew Lunn , Thomas Petazzoni , Jason Cooper Subject: [RFC] ARM: Orion: Check DRAM window size Date: Mon, 28 Aug 2017 17:30:39 +0200 Message-Id: <20170828153039.27088-1-jlu@pengutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170828152517.24506-1-jlu@pengutronix.de> References: <20170828152517.24506-1-jlu@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: jlu@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel@pengutronix.de, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jan Luebbe MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This is a corresponding change as "PCI: mvebu: Check DRAM window size" applied to the Orion PCIe driver. I don't have the relevant hardware myself, but the patch may still be useful for someone who has. This is completely untested. Signed-off-by: Jan Luebbe --- arch/arm/mach-dove/pcie.c | 3 ++- arch/arm/mach-mv78xx0/pcie.c | 3 ++- arch/arm/mach-orion5x/pci.c | 3 ++- arch/arm/plat-orion/pcie.c | 19 +++++++++++++++---- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c index 91fe97144570..27e4689ee58d 100644 --- a/arch/arm/mach-dove/pcie.c +++ b/arch/arm/mach-dove/pcie.c @@ -51,7 +51,8 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys) */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); - orion_pcie_setup(pp->base); + if (!orion_pcie_setup(pp->base)) + return 0; if (pp->index == 0) pci_ioremap_io(sys->busnr * SZ_64K, DOVE_PCIE0_IO_PHYS_BASE); diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c index 81ff4327a962..3d17eeff44bf 100644 --- a/arch/arm/mach-mv78xx0/pcie.c +++ b/arch/arm/mach-mv78xx0/pcie.c @@ -113,7 +113,8 @@ static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys) * Generic PCIe unit setup. */ orion_pcie_set_local_bus_nr(pp->base, sys->busnr); - orion_pcie_setup(pp->base); + if (!orion_pcie_setup(pp->base)) + return 0; pci_ioremap_io(nr * SZ_64K, MV78XX0_PCIE_IO_PHYS_BASE(nr)); diff --git a/arch/arm/mach-orion5x/pci.c b/arch/arm/mach-orion5x/pci.c index ecb998e7f8dc..f7f830872cc9 100644 --- a/arch/arm/mach-orion5x/pci.c +++ b/arch/arm/mach-orion5x/pci.c @@ -147,7 +147,8 @@ static int __init pcie_setup(struct pci_sys_data *sys) /* * Generic PCIe unit setup. */ - orion_pcie_setup(PCIE_BASE); + if (!orion_pcie_setup(PCIE_BASE)) + return 0; /* * Check whether to apply Orion-1/Orion-NAS PCIe config diff --git a/arch/arm/plat-orion/pcie.c b/arch/arm/plat-orion/pcie.c index 8b8c06d2e9c4..07ae382cf48a 100644 --- a/arch/arm/plat-orion/pcie.c +++ b/arch/arm/plat-orion/pcie.c @@ -120,10 +120,10 @@ void __init orion_pcie_reset(void __iomem *base) * BAR[0,2] -> disabled, BAR[1] -> covers all DRAM banks * WIN[0-3] -> DRAM bank[0-3] */ -static void __init orion_pcie_setup_wins(void __iomem *base) +static int __init orion_pcie_setup_wins(void __iomem *base) { const struct mbus_dram_target_info *dram; - u32 size; + u64 size; int i; dram = mv_mbus_dram_info(); @@ -170,15 +170,23 @@ static void __init orion_pcie_setup_wins(void __iomem *base) if ((size & (size - 1)) != 0) size = 1 << fls(size); + if (size > 0x100000000) { + pr_err("Could not configure DRAM window (too large): 0x%llx\n", + size); + return 0; + } + /* * Setup BAR[1] to all DRAM banks. */ writel(dram->cs[0].base, base + PCIE_BAR_LO_OFF(1)); writel(0, base + PCIE_BAR_HI_OFF(1)); writel(((size - 1) & 0xffff0000) | 1, base + PCIE_BAR_CTRL_OFF(1)); + + return 1; } -void __init orion_pcie_setup(void __iomem *base) +int __init orion_pcie_setup(void __iomem *base) { u16 cmd; u32 mask; @@ -186,7 +194,8 @@ void __init orion_pcie_setup(void __iomem *base) /* * Point PCIe unit MBUS decode windows to DRAM space. */ - orion_pcie_setup_wins(base); + if (!orion_pcie_setup_wins(base)) + return 0; /* * Master + slave enable. @@ -203,6 +212,8 @@ void __init orion_pcie_setup(void __iomem *base) mask = readl(base + PCIE_MASK_OFF); mask |= 0x0f000000; writel(mask, base + PCIE_MASK_OFF); + + return 1; } int orion_pcie_rd_conf(void __iomem *base, struct pci_bus *bus,