From patchwork Mon Aug 28 15:25:16 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: 9925813 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 D160C60329 for ; Mon, 28 Aug 2017 15:26:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C36FA286FC for ; Mon, 28 Aug 2017 15:26:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8411286FE; Mon, 28 Aug 2017 15:26:07 +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=ham 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 41673286FC for ; Mon, 28 Aug 2017 15:26:07 +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=5UcA1+uwZt9f6jbnkw6DIrIceZCS0CfnNCIfuAcgULk=; b=ssph8hX7cH2gY3vu7OR/cMZb3P oyk6cRCMh+pMqdZnVILCv/on40sOM8UkBFIiyF/36oZ1PDs0c++WH5dgO77TitYgoHWedo7SdjyRC 06OjUXrFQh2Kn7XdFQFJboNG7Ma+Efw+zHk6c/3Lu37FNb8prkIermdVx7j4SdbTgTVUM2ssr6zO9 LUb4QApc0zpFAXsrOK/QGZoC3mkaCyL3OyB9LcwJlogQFAf86sNGgCL8cv4uMcJVlhj5F8AzZpzcM in0sUa+wMWltesmktA6U8Bpx4LIYKg7vZuM5ebWApYy1jFBMM0L5OhelnzsTQO4XeWDGCqK8E4v33 fUrdAt1g==; 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 1dmLvP-0003oP-D9; Mon, 28 Aug 2017 15:26:03 +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 1dmLvM-0003o9-HP for linux-arm-kernel@bombadil.infradead.org; Mon, 28 Aug 2017 15:26:00 +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=keLPCFpUWWGKNduk0V+4w6eyHM02tAqxl1Kdyn7QtBc=; b=jX/wpmOnhru5bFOiLq0yLsPw9 ziGddmttQvL/Wf8fkT4+L3Do1cpFnbFOOmYG0tOLMadBXULnmeVwUGbV+2P/O/RfJAK1f0y1yQ3K5 AXQ2OUlrwypYl/yr2kQVbdI/alWOLvhSjMbx0F2IfhL1ObnObUrt2cu0hBkz5j3wNajJA+b0KxNPy FQGlxJ9FKERpPja/ZYG6k3/mw58GiaYyyrKZBsgHbnbNyrRs0zyi8KhMQUn3Bu024tBAKxNVpj1Lb /zbIMlgk43ROT5MghRX5XYZXVG2DPxnC6VqRUurnjzqr1t+vEc1bBxXerwMQ9YX6OjBVMFZFEMRhA BSuPtzpfQ==; 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 1dmLvJ-0006ls-OU for linux-arm-kernel@lists.infradead.org; Mon, 28 Aug 2017 15:25:58 +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 1dmLus-00080o-Cc; Mon, 28 Aug 2017 17:25:30 +0200 Received: from jlu by dude.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1dmLur-0006O2-Jg; Mon, 28 Aug 2017 17:25:29 +0200 From: Jan Luebbe To: Gregory Clement , Andrew Lunn , Thomas Petazzoni , Jason Cooper Subject: [PATCH 1/2] bus: mbus: fix window size calculation for 4GB windows Date: Mon, 28 Aug 2017 17:25:16 +0200 Message-Id: <20170828152517.24506-2-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 At least the Armada XP SoC supports 4GB on a single DRAM window. Because the size register values contain the actual size - 1, the MSB is set in that case. For example, the SDRAM window's control register's value is 0xffffffe1 for 4GB (bits 31 to 24 contain the size). The MBUS driver reads back each window's size from registers and calculates the actual size as (control_reg | ~DDR_SIZE_MASK) + 1, which overflows for 32 bit values, resulting in other miscalculations further on (a bad RAM window for the CESA crypto engine calculated by mvebu_mbus_setup_cpu_target_nooverlap() in my case). This patch changes the type in 'struct mbus_dram_window' from u32 to u64, which allows us to keep using the same register calculation code in most MBUS-using drivers (which calculate ->size - 1 again). Signed-off-by: Jan Luebbe --- drivers/bus/mvebu-mbus.c | 2 +- include/linux/mbus.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index c7f396903184..70db4d5638a6 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c @@ -720,7 +720,7 @@ mvebu_mbus_default_setup_cpu_target(struct mvebu_mbus_state *mbus) if (mbus->hw_io_coherency) w->mbus_attr |= ATTR_HW_COHERENCY; w->base = base & DDR_BASE_CS_LOW_MASK; - w->size = (size | ~DDR_SIZE_MASK) + 1; + w->size = (u64)(size | ~DDR_SIZE_MASK) + 1; } } mvebu_mbus_dram_info.num_cs = cs; diff --git a/include/linux/mbus.h b/include/linux/mbus.h index 0d3f14fd2621..4773145246ed 100644 --- a/include/linux/mbus.h +++ b/include/linux/mbus.h @@ -31,8 +31,8 @@ struct mbus_dram_target_info struct mbus_dram_window { u8 cs_index; u8 mbus_attr; - u32 base; - u32 size; + u64 base; + u64 size; } cs[4]; };