Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752698AbdGDKiI (ORCPT ); Tue, 4 Jul 2017 06:38:08 -0400 Received: from mga02.intel.com ([134.134.136.20]:33128 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752040AbdGDKiF (ORCPT ); Tue, 4 Jul 2017 06:38:05 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,307,1496127600"; d="scan'208";a="281941382" From: Vladimir Kondratiev To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Vladimir Kondratiev Subject: [PATCH] rmem: support for dma_addr different from phys_addr Date: Tue, 4 Jul 2017 13:34:38 +0300 Message-Id: <20170704103438.21628-1-vladimir.kondratiev@intel.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1611 Lines: 40 On some systems, dma address differs from physical one due to various reasons. dma_init_coherent_memory is aware of it, it takes both phys_addr_t and dma_addt_t arguments for memory block. However, rmem_dma_device_init passes physical address for DMA one. Fix this, using phys_to_dma(). This assumes the whole buffer has same offset between physical and dma addresses. Change-Id: Ic709312941ee4e1a37afb2ea25cbd759eabc009b Signed-off-by: Vladimir Kondratiev --- drivers/base/dma-coherent.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 640a7e63c453..5371cb19c918 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -292,7 +292,8 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev) struct dma_coherent_mem *mem = rmem->priv; if (!mem && - !dma_init_coherent_memory(rmem->base, rmem->base, rmem->size, + !dma_init_coherent_memory(rmem->base, phys_to_dma(dev, rmem->base), + 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", -- 2.11.0 --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.