From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Subject: Re: [RFC PATCH] net/mlx4: Get rid of page operation after dma_alloc_coherent Date: Tue, 18 Dec 2018 12:04:12 -0700 Message-ID: <20181218190412.GE21992@ziepe.ca> References: <20181214233254.5860-1-swarren@wwwdotorg.org> <20181218163202.GJ21949@mellanox.com> <498653b9-5006-2153-fa53-3bc217626303@wwwdotorg.org> <20181218171246.GC21992@ziepe.ca> <66cea824-19f4-1ca2-b6be-550ba1c0636b@wwwdotorg.org> <20181218184308.GD21992@ziepe.ca> <20181218185012.GB16052@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Stephen Warren , Tariq Toukan , xavier.huwei@huawei.com, "netdev@vger.kernel.org" , "linux-rdma@vger.kernel.org" , Doug Ledford To: Christoph Hellwig Return-path: Received: from mail-pl1-f195.google.com ([209.85.214.195]:44574 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726575AbeLRTEP (ORCPT ); Tue, 18 Dec 2018 14:04:15 -0500 Received: by mail-pl1-f195.google.com with SMTP id e11so7585916plt.11 for ; Tue, 18 Dec 2018 11:04:14 -0800 (PST) Content-Disposition: inline In-Reply-To: <20181218185012.GB16052@lst.de> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, Dec 18, 2018 at 07:50:12PM +0100, Christoph Hellwig wrote: > On Tue, Dec 18, 2018 at 11:43:08AM -0700, Jason Gunthorpe wrote: > > So the problem here is that on some arches > > > > sg_set_buf(sg, dma_coherent_buf, size) > > p = sg_virt(sg); > > assert(p == dma_coherent_buf); > > dma allocations purely return a virtual address, you must never > call virt_to_page or virt_to_phys on them, which sg_set_buf > will do. On many architectures this will give your the wrong > result as the coherent DMA address is a vmap or ioremap address. Yes, that is what I gathered - if that is the design then I'd say that drivers shouldn't be stuffing these DMA coherent virtual addresses into a sg at all. Jason