Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3815556ybk; Tue, 19 May 2020 13:39:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn7zj7dnnX/BJlowpaM2FvscD/64ilwWwNTrM/r0h4LK9zqOQZerG2fBJEz72f2UhdqXhO X-Received: by 2002:a17:906:c108:: with SMTP id do8mr1050459ejc.134.1589920799181; Tue, 19 May 2020 13:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589920799; cv=none; d=google.com; s=arc-20160816; b=BmhwoZM4S0YE19umknL9ufa3t1HPEUMM3nQX3WpLmBj7ycDNentioxPw44nxox39Qk 8lRqP37Cw97+IaBaUyJVBw3GFUudIkwg4QQCYdAHNJddHgpreioeRNqEtuGcMCMQ8nBj GyKPYRwftweKMAPqgpCSINi6UrYJMFk53nuYWumBCV+ZzX4gqo5Vx9JJR4P2CkuVUcRp Nqx7hxZuAgHPX7fTW4MCCnnbcnGVpVWiIvF0VGGfZw8nGG//OjLWScYVGM4XkVQ3py+y hvIrLSZd40QQyVO+yZxD675zYK/vY5KFIGjW5yBnLTpMDCNIA/oEzv0DZqOKS1+FZaXL HKBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=TG5CHkl4KlI+DPT6pbJmozykP7xbn6V+PthMvfOYB1o=; b=XbUKbJN+Fip1U6cqiSDUXdDnlCELf06p6q5cgW0U5WfYuF9KmUPfV+WIcoswTqBVWw lJf8UgYKvSiKQl5ZmFBYaEtPC8ualZENWk0gwGmOrJ+G5Bt/QVHkra9W04ZPDlWk0fxN Y7CyQBBU3g9gR/CO6L3IFQJIBlXCJJZZwd7TJHWREc6s+KKQAz5hwako9Eq8dXlNy0vI EOrz0zpiPGkKboyJSVgrDAV+KBaA86KMPPtMCHzTuijv+Eb2FBPKTEqYJeEcqcO/hoTg e+zoIc5ftLwAePks09j6LLLsvU56y9Sqhvb9J1pXHK86LwbqscqCEmXNpkuR8lUQJYnU qjrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=tD8NW3F1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si320488eds.231.2020.05.19.13.39.28; Tue, 19 May 2020 13:39:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=tD8NW3F1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728175AbgESUfY (ORCPT + 99 others); Tue, 19 May 2020 16:35:24 -0400 Received: from rnd-relay.smtp.broadcom.com ([192.19.229.170]:35392 "EHLO rnd-relay.smtp.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728018AbgESUfF (ORCPT ); Tue, 19 May 2020 16:35:05 -0400 Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.242.48]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 8D33630D83D; Tue, 19 May 2020 13:33:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 8D33630D83D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1589920421; bh=VpnotEhiNEPSL/h1q0ZC3ux+vegZ1N4bcsFwvtQO+FE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tD8NW3F1ADu3W5qZO8tm5cZkY83a5YfdW7Pok6YJk0J1MpyyryIIm/cxU9CkPMVTc +5gYtA0NGWpyE8xH+allbbIhLgRkOvpoHf8j6wb1JOVgEqSXswIoctk4C48jTkUBfI 5cTjhW6JJKAbljyC57848rTE07nHe9qnVK5NhHxY= Received: from stbsrv-and-01.and.broadcom.net (stbsrv-and-01.and.broadcom.net [10.28.16.211]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id 29C5D140239; Tue, 19 May 2020 13:35:02 -0700 (PDT) From: Jim Quinlan To: james.quinlan@broadcom.com, Nicolas Saenz Julienne Cc: Russell King , Stefano Stabellini , Julien Grall , Ulf Hansson , linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 11/15] arm: dma-mapping: Invoke dma offset func if needed Date: Tue, 19 May 2020 16:34:09 -0400 Message-Id: <20200519203419.12369-12-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200519203419.12369-1-james.quinlan@broadcom.com> References: <20200519203419.12369-1-james.quinlan@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just like dma_pfn_offset, another offset is added to the dma/phys translation if there happen to be multiple regions that have different mapping offsets. Signed-off-by: Jim Quinlan --- arch/arm/include/asm/dma-mapping.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index bdd80ddbca34..f0c0a1fa9ac0 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -35,8 +35,14 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) #ifndef __arch_pfn_to_dma static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) { - if (dev) + if (dev) { +#ifdef CONFIG_DMA_PFN_OFFSET_MAP + if (unlikely(dev->dma_offset_map)) + pfn -= dma_pfn_offset_frm_phys_addr( + dev->dma_offset_map, PFN_PHYS(pfn)); +#endif pfn -= dev->dma_pfn_offset; + } return (dma_addr_t)__pfn_to_bus(pfn); } @@ -44,9 +50,14 @@ static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) { unsigned long pfn = __bus_to_pfn(addr); - if (dev) + if (dev) { +#ifdef CONFIG_DMA_PFN_OFFSET_MAP + if (unlikely(dev->dma_offset_map)) + pfn += dma_pfn_offset_frm_dma_addr( + dev->dma_offset_map, addr); +#endif pfn += dev->dma_pfn_offset; - + } return pfn; } -- 2.17.1