From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751998AbdFTNm0 (ORCPT ); Tue, 20 Jun 2017 09:42:26 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:53249 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751116AbdFTNmZ (ORCPT ); Tue, 20 Jun 2017 09:42:25 -0400 Date: Tue, 20 Jun 2017 06:42:19 -0700 From: Christoph Hellwig To: Vladimir Murzin Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk, sza@esh.hu, arnd@arndb.de, gregkh@linuxfoundation.org, akpm@linux-foundation.org, alexandre.torgue@st.com, robin.murphy@arm.com, benjamin.gaignard@linaro.org, kbuild-all@01.org, Michal Nazarewicz , Marek Szyprowski , Roger Quadros Subject: Re: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when used with device tree Message-ID: <20170620134219.GA31496@infradead.org> References: <1495621472-9323-1-git-send-email-vladimir.murzin@arm.com> <1495621472-9323-4-git-send-email-vladimir.murzin@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1495621472-9323-4-git-send-email-vladimir.murzin@arm.com> User-Agent: Mutt/1.8.0 (2017-02-23) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wouldn't the smal patch below solve the same issue in a simple way? diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 640a7e63c453..e8f8447d705b 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -290,9 +290,11 @@ EXPORT_SYMBOL(dma_mmap_from_coherent); static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) { struct dma_coherent_mem *mem = rmem->priv; + dma_addr_t dev_addr = ((rmem->base >> PAGE_SHIFT) - + dev->dma_pfn_offset) << PAGE_SHIFT; if (!mem && - !dma_init_coherent_memory(rmem->base, rmem->base, rmem->size, + !dma_init_coherent_memory(rmem->base, dev_addr, rmem->size, DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE, &mem)) { pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n",