Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941056AbcKOPqV (ORCPT ); Tue, 15 Nov 2016 10:46:21 -0500 Received: from smtprelay2.synopsys.com ([198.182.60.111]:51302 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935544AbcKOPqT (ORCPT ); Tue, 15 Nov 2016 10:46:19 -0500 Subject: Re: [PATCH v2] arc: Implement arch-specific dma_map_ops.mmap To: Alexey Brodkin , "linux-snps-arc@lists.infradead.org" References: <1478185573-12871-1-git-send-email-abrodkin@synopsys.com> CC: "linux-arch@vger.kernel.org" , Vineet Gupta , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Marek Szyprowski From: Ramiro Oliveira Message-ID: Date: Tue, 15 Nov 2016 15:45:35 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1478185573-12871-1-git-send-email-abrodkin@synopsys.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.107.25.125] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1158 Lines: 26 On 11/3/2016 3:06 PM, Alexey Brodkin wrote: > We used to use generic implementation of dma_map_ops.mmap which is > dma_common_mmap() but that only worked for simpler cached mappings when > vaddr = paddr. > > If a driver requests uncached DMA buffer kernel maps it to virtual > address so that MMU gets involved and page uncached status takes into > account. In that case usage of dma_common_mmap() lead to mapping of > vaddr to vaddr for user-space which is obviously wrong. For more detals > please refer to verbose explanation here [1]. > > So here we implement our own version of mmap() which always deals > with dma_addr and maps underlying memory to user-space properly > (note that DMA buffer mapped to user-space is always uncached > because there's no way to properly manage cache from user-space). > > [1] https://lkml.org/lkml/2016/10/26/973 > > Signed-off-by: Alexey Brodkin > Reviewed-by: Catalin Marinas > Cc: Marek Szyprowski > Cc: Vineet Gupta > Cc: > --- Tested-by: Ramiro Oliveira