From patchwork Tue Jul 24 01:09:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Chemparathy X-Patchwork-Id: 1415631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 4FFF33FC71 for ; Thu, 6 Sep 2012 15:08:21 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T9day-0005Sy-Ee; Thu, 06 Sep 2012 15:02:18 +0000 Received: from bombadil.infradead.org ([2001:4830:2446:ff00:4687:fcff:fea6:5117]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1StU4v-0003kO-P9 for linux-arm-kernel@merlin.infradead.org; Tue, 24 Jul 2012 01:38:26 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by bombadil.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1StTdD-0000Qf-2Y for linux-arm-kernel@lists.infradead.org; Tue, 24 Jul 2012 01:09:48 +0000 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id q6O19e3D030397; Mon, 23 Jul 2012 20:09:40 -0500 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6O19eSh010278; Mon, 23 Jul 2012 20:09:40 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Mon, 23 Jul 2012 20:09:40 -0500 Received: from ares-ubuntu.am.dhcp.ti.com (ares-ubuntu.am.dhcp.ti.com [158.218.103.17]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id q6O19dYW024611; Mon, 23 Jul 2012 20:09:40 -0500 Received: from a0875269 by ares-ubuntu.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1StTd5-0002Ul-PQ; Mon, 23 Jul 2012 21:09:39 -0400 From: Cyril Chemparathy To: Subject: [RFC 19/23] drivers: cma: fix addressing on PAE machines Date: Mon, 23 Jul 2012 21:09:21 -0400 Message-ID: <1343092165-9470-20-git-send-email-cyril@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343092165-9470-1-git-send-email-cyril@ti.com> References: <1343092165-9470-1-git-send-email-cyril@ti.com> MIME-Version: 1.0 X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120723_210947_352781_BDA3BD44 X-CRM114-Status: GOOD ( 12.53 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.94.94.41 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Mailman-Approved-At: Thu, 06 Sep 2012 10:43:38 -0400 Cc: nico@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, Vitaly Andrianov , Cyril Chemparathy X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch fixes a couple of bugs that otherwise impair CMA functionality on PAE machines: - alignment must be a 64-bit type when running on systems with 64-bit physical addresses. If this is not the case, the limit calculation thunks allocations down to an address range < 4G. - The allocated range is now being checked using dma_supported() instead of hardcoding a 32-bit addressable limit. Signed-off-by: Vitaly Andrianov Signed-off-by: Cyril Chemparathy --- drivers/base/dma-contiguous.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c index 78efb03..e10bd9a 100644 --- a/drivers/base/dma-contiguous.c +++ b/drivers/base/dma-contiguous.c @@ -234,7 +234,7 @@ int __init dma_declare_contiguous(struct device *dev, unsigned long size, phys_addr_t base, phys_addr_t limit) { struct cma_reserved *r = &cma_reserved[cma_reserved_count]; - unsigned long alignment; + phys_addr_t alignment; pr_debug("%s(size %lx, base %08lx, limit %08lx)\n", __func__, (unsigned long)size, (unsigned long)base, @@ -271,7 +271,7 @@ int __init dma_declare_contiguous(struct device *dev, unsigned long size, if (!addr) { base = -ENOMEM; goto err; - } else if (addr + size > ~(unsigned long)0) { + } else if (!dma_supported(dev, addr + size)) { memblock_free(addr, size); base = -EINVAL; goto err;