From patchwork Thu Jun 21 10:50:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 9533 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 14F8E23E37 for ; Thu, 21 Jun 2012 10:51:21 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id ADFF9A18117 for ; Thu, 21 Jun 2012 10:51:20 +0000 (UTC) Received: by ggnf1 with SMTP id f1so316160ggn.11 for ; Thu, 21 Jun 2012 03:51:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:x-auditid :from:to:date:message-id:x-mailer:x-brightmail-tracker:x-tm-as-mml :cc:subject:x-beenthere:x-mailman-version:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:sender :errors-to:x-gm-message-state; bh=TEOSWh3Aw26rDdKF99M1Zgc7WQtTYPFJnUhKkEvm6Qo=; b=bA0gDZVY3RdIrmW0qpNdLIrBgPtVrVGvZF13xrGXjWPa8sQ8dBqJRaUVY9xFlPC9aS 2cgXyh51fAUd42uMxjnf4t1xp1Ypf3pUkzqzBRuNdpFd7NAhhFB/DNNgEBIF2oBwKMa7 N75LaBI8sAfjU2CDjS6G1e047B0nxXp2AsFZjOglvGtVhWdDzyMpIIxvaXMvyf+rDgZQ kCLiLXqQTvDA+SGKl8VWg7y6Wefn68SjH20/FDOMQPMdJjKOlAPam1NG0O8s1+s5WgZ+ s1kKwwxKUMI0Pi8uOk2Rd7KfYm/8l4VChpnYLscDYeyxXDP0ZCpJtiJFsEirF7/Prbq/ 1lqw== Received: by 10.50.87.227 with SMTP id bb3mr6855862igb.57.1340275875500; Thu, 21 Jun 2012 03:51:15 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp14381ibb; Thu, 21 Jun 2012 03:51:14 -0700 (PDT) Received: by 10.216.216.148 with SMTP id g20mr14344033wep.187.1340275873649; Thu, 21 Jun 2012 03:51:13 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id u5si40609408wif.17.2012.06.21.03.51.11; Thu, 21 Jun 2012 03:51:13 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Sheyj-00051D-29; Thu, 21 Jun 2012 10:51:09 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Sheyh-00050F-6i for linaro-mm-sig@lists.linaro.org; Thu, 21 Jun 2012 10:51:07 +0000 Received: from epcpsbgm2.samsung.com (mailout1.samsung.com [203.254.224.24]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M5Y009U5RH0NU30@mailout1.samsung.com> for linaro-mm-sig@lists.linaro.org; Thu, 21 Jun 2012 19:51:03 +0900 (KST) X-AuditID: cbfee61b-b7fcc6d000003a7a-7c-4fe2fc979bbd Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id F8.75.14970.79CF2EF4; Thu, 21 Jun 2012 19:51:03 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M5Y00G7JRGRIY10@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Thu, 21 Jun 2012 19:51:03 +0900 (KST) From: Marek Szyprowski To: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org Date: Thu, 21 Jun 2012 12:50:44 +0200 Message-id: <1340275844-18705-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.10 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNJMWRmVeSWpSXmKPExsVy+t9jAd3pfx75G9z4qmrx5cpDJgdGj9v/ HjMHMEZx2aSk5mSWpRbp2yVwZeztPsFa0MJdcff2XeYGxn7OLkYODgkBE4lP90K7GDmBTDGJ C/fWs3UxcnEICSxilJi1ppkZwlnLJPF84nx2kCo2AUOJrrddbCC2iICHxJMV58CKmAUWM0u8 +7CMESQhLOAiMfH3EmYQm0VAVeLwrGcsIDYvUMPXWx9YINbJSzy938c2gZF7ASPDKkbR1ILk guKk9FwjveLE3OLSvHS95PzcTYxgLz6T3sG4qsHiEKMAB6MSD6/pz0f+QqyJZcWVuYcYJTiY lUR4Tz0CCvGmJFZWpRblxxeV5qQWH2KU5mBREudtsr7gLySQnliSmp2aWpBaBJNl4uCUamCc XLkzY+N2pTfVO75r/F9S9emaJEeWvlRf3bqysGu7eX+FtVzK/R2XN/N60/EfglbJ71qmq/3b edMqXztfIO5s5tags7PE/SN+b1fjcN+scdVDfqqPYZn3lCtTZY0MtBkVXl08uLeCYZ+mId/s 87/X3RHIZgq49DfVSFkw4uHelW0X9RjWZUcrsRRnJBpqMRcVJwIAEMfCh94BAAA= X-TM-AS-MML: No Cc: Abhinav Kochhar , Russell King - ARM Linux , Arnd Bergmann , Kyungmin Park , Subash Patel Subject: [Linaro-mm-sig] [PATCH] ARM: dma-mapping: fix buffer chunk allocation order X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQnTv4e/+i+H4yxyKf78QZwdXzxq9tBYDVFORNQAKbikqTDBKeW91maruh+8Sp1XH2F8YjsC IOMMU-aware dma_alloc_attrs() implementation allocates buffers in power-of-two chunks to improve performance and take advantage of large page mappings provided by some IOMMU hardware. However current code, due to a subtle bug, allocated those chunks in the smallest-to-largest order, what completely killed all the advantages of using larger than page chunks. If a 4KiB chunk has been mapped as a first chunk, the consecutive chunks are not aligned correctly to the power-of-two which match their size and IOMMU drivers were not able to use internal mappings of size other than the 4KiB (largest common denominator of alignment and chunk size). This patch fixes this issue by changing to the correct largest-to-smallest chunk size allocation sequence. Signed-off-by: Marek Szyprowski --- arch/arm/mm/dma-mapping.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index d766e42..4044abc 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1067,7 +1067,7 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size, gfp_t return NULL; while (count) { - int j, order = __ffs(count); + int j, order = __fls(count); pages[i] = alloc_pages(gfp | __GFP_NOWARN, order); while (!pages[i] && order)