Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752484AbcDRPWK (ORCPT ); Mon, 18 Apr 2016 11:22:10 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59790 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751881AbcDRPWI (ORCPT ); Mon, 18 Apr 2016 11:22:08 -0400 Subject: Re: [PATCH V2] net: ethernet: mellanox: correct page conversion To: Timur Tabi , Christoph Hellwig References: <1460845412-13120-1-git-send-email-okaya@codeaurora.org> <20160418121247.GA25387@infradead.org> <0c6a430c5f0ec64f51d7c594ef9751dd@codeaurora.org> <20160418131058.GA25421@infradead.org> <5714E5D6.7050600@codeaurora.org> <5714FA2C.4030209@codeaurora.org> Cc: linux-rdma@vger.kernel.org, cov@codeaurora.org, Yishai Hadas , netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Sinan Kaya Message-ID: <5714FB9D.4000405@codeaurora.org> Date: Mon, 18 Apr 2016 11:22:05 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <5714FA2C.4030209@codeaurora.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1654 Lines: 34 On 4/18/2016 11:15 AM, Timur Tabi wrote: > Sinan Kaya wrote: >> >> VMAP allows you to make several pages look contiguous to the CPU. >> It can only be used against logical addresses returned from kmalloc >> or alloc_page. >> >> You cannot take several virtually mapped addresses returned by dma_alloc_coherent >> and try to make them virtually contiguous again. >> >> The code happens to work on other architectures by pure luck. AFAIK, dma_alloc_coherent >> returns logical addresses on Intel systems until it runs out of DMA memory. After >> that intel arch will also start returning virtually mapped addresses and this code >> will also fail. ARM64 on the other hand always returns a virtually mapped address. >> >> The goal of this code is to allocate a bunch of page sized memory and make it look >> contiguous. It is just using the wrong API. The correct API is either kmalloc or >> alloc_page map it with dma_map_page not dma_alloc_coherent. >> >> The proper usage of dma_map_page requires code to call dma_sync API in correct >> places to be compatible with noncoherent systems. This code is already assuming >> coherency. It would be a nice to have dma_sync APIs in right places. There is no >> harm in calling dma_sync API for coherent systems as they are no-ops in DMA mapping >> layer whereas it is a cache flush for non-coherent systems. > > The text would be a great addition to the patch description. > I can do that on the next version. -- Sinan Kaya Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project