From patchwork Tue Feb 24 20:45:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 5875231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C319E9F169 for ; Tue, 24 Feb 2015 20:48:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F38E220218 for ; Tue, 24 Feb 2015 20:48:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF6A1200FF for ; Tue, 24 Feb 2015 20:48:24 +0000 (UTC) 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 1YQMMM-0001ol-GM; Tue, 24 Feb 2015 20:45:38 +0000 Received: from mail-yh0-f45.google.com ([209.85.213.45]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YQMMI-0001lV-1A for linux-arm-kernel@lists.infradead.org; Tue, 24 Feb 2015 20:45:34 +0000 Received: by yhaf73 with SMTP id f73so14951371yha.11 for ; Tue, 24 Feb 2015 12:45:11 -0800 (PST) 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=UuYX8mtWGxgFIdSHJ71nvts/Yl6TIm+kn7gJJSANUXU=; b=B1JofFPb/oKuAYGBBVcBFc64xMmd0LTKegWJBP78GW2M6ON3waKULBMgbygIVXXZa6 yMIG3akjZA6ehJA0R5iNhmXZgMPiHr1I/Q8rsTnFq/z5gUQxN6b56INYcyE+2Tt7KIix ly1Efqe3whyl75JgGDSXcutm5XeRmEOKqDC4h9S+vjvnAWg+YLayWJwIHF5NA8L3NXIf vrwGO74lPpw54wfpAmYJoRBysvdxg9KpA1j1oJzUt/trIU9KxmT6UcX/SNEUg39+8WlG QMTmz/KvIi0jyWn+33+kSmmGQtrFE7Z0dL/T+buktpcG1rKJOAwtDE0NZu1dATkU+ZEB crjw== X-Gm-Message-State: ALoCoQlaPfycuoWHzQ5nNSPg4+cLzLVpXuBFGp9Q+hQPHdBaIdDthCl8LPeSFb/GlS08wIhe0tJw X-Received: by 10.236.50.196 with SMTP id z44mr14020448yhb.79.1424810711195; Tue, 24 Feb 2015 12:45:11 -0800 (PST) Received: from nuc.endlessm-sf.com ([190.181.174.91]) by mx.google.com with ESMTPSA id t2sm31803142yhp.46.2015.02.24.12.45.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Feb 2015 12:45:10 -0800 (PST) From: Daniel Drake To: linux@arm.linux.org.uk, m.szyprowski@samsung.com Subject: [PATCH] ARM: dma-mapping: support non-consistent DMA attribute Date: Tue, 24 Feb 2015 14:45:03 -0600 Message-Id: <1424810703-20382-1-git-send-email-drake@endlessm.com> X-Mailer: git-send-email 2.1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150224_124534_160220_1A8A3C33 X-CRM114-Status: GOOD ( 10.55 ) X-Spam-Score: -0.7 (/) Cc: jasper@endlessm.com, carlo@endlessm.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently when arm_dma_mmap() is called, vm_page_prot is reset according to DMA attributes. Currently, writecombine is the only attribute supported; any other configuration will map uncached memory. Add support for the non-consistent attribute so that cachable memory can be mapped into userspace via the dma_mmap_attrs() API. Signed-off-by: Daniel Drake --- arch/arm/mm/dma-mapping.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 170a116..cfb7d4d 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -562,10 +562,12 @@ static void __free_from_contiguous(struct device *dev, struct page *page, static inline pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot) { - prot = dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs) ? - pgprot_writecombine(prot) : - pgprot_dmacoherent(prot); - return prot; + if (dma_get_attr(DMA_ATTR_NON_CONSISTENT, attrs)) + return prot; + else if (dma_get_attr(DMA_ATTR_WRITE_COMBINE, attrs)) + return pgprot_writecombine(prot); + else + return pgprot_dmacoherent(prot); } #define nommu() 0