Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp931672imu; Fri, 7 Dec 2018 11:09:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/WoyXY0fDJSbswZO7zABZdBs1q93CIIsBRUwpk43dUlzNH9QwVyPv20ZWMkTCoUUoVv1Zxk X-Received: by 2002:a65:560e:: with SMTP id l14mr3012322pgs.168.1544209783608; Fri, 07 Dec 2018 11:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544209783; cv=none; d=google.com; s=arc-20160816; b=nYnogN8jJk9vYN2+Q+sAwUPEDa7WpyHm1fJFiKW8etECh0/3xn4KYXJPnJNf4A0ZzW M23GsKp9A1/H5oPeD4Voyb8/Oo1DvVYNcNKOBUNuQ6ft3cysEI3aYGIiXrguiOG4Tvky lKg8zNEHC618qqdFX8UZPtYGcXvK85I84Tv+FXmlNgMIO/HpHo4tVcy7twE6k4EY5j7S IZlxB6Xp9miDncHN+7mu6+UaSbl7uzkXys8TKpaZ9M+fJtOhnukMC30fboGHTCjy6lBC 9J9rGjmkYeTyD3swOy9TnciCGF4qEUzNgL7fhQhcpnGLqssb21n0JRr2zK27TxJUXrJO AUvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5bxE7/nVpI/7mlzaLJcxDeM0h4Y+t/nWwWlVgLKUuRA=; b=Stm2UNXl+U6HylvZUTkAAmUfmN7p96YIeAtj2nX0WghaU7yz71qYfVDK4jqBo58ekK 1XTtEvZVE6HPiEAyQArBROAwcZDlt2mN27PG8y2/bZB9TsZ65MVbUgUsxMs8HxkIPJY4 8AwtucoiAgDeuF+NYXmeVGGqMaow7HGoFXkFIpOS2I39pEtzdCKbgpTlJalhoJOMmUxK fIJ2j9OtDKRNl0v6GKWKcF2PKhfho0xX0O8sXoI7MbiuJV0vKDRmbfHq/NHDcMbdDNLJ 67G6cbmqmAhwbGxDeoKAQeHCZKIWE6eXXsLjwDMiCCf9Hu1EvWjASHuyS7t3iX+CetCh Cjow== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dDexeD96; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h33si3580952plh.119.2018.12.07.11.09.28; Fri, 07 Dec 2018 11:09:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dDexeD96; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726330AbeLGTIM (ORCPT + 99 others); Fri, 7 Dec 2018 14:08:12 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48496 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbeLGTIJ (ORCPT ); Fri, 7 Dec 2018 14:08:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5bxE7/nVpI/7mlzaLJcxDeM0h4Y+t/nWwWlVgLKUuRA=; b=dDexeD96yAPO79Ix1tQz87OVpW G29DQAswPSuivne90/uGy9Xrw9h0kNG91Ce9Q+9tH9b8bfcUefZhyADffVs4AejMAPKrq+9PnosQH 2r+i8pifikF+hU2ljTRS/MzifPsNqdi1jRvuhpIwNCWfow9R77feomnLAZr7XGx44OxQW+NhMHmGH ldYqtml/N4C6CFPXd6MeDAUfQ4nGThsgsJK1M7MRy+N5DvrSSYt/X4QZrfsWu1T0R1xT5uWWaBtOL mFLI6pXXfmoU5r255fb48XjhAo8QFLjjRCe47u1NccyrgRwAmyzxVmYmCuJ1YEOil2QnN4aCUIT8m R4ikW/pg==; Received: from [199.255.44.128] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVLTj-0006lz-3b; Fri, 07 Dec 2018 19:07:59 +0000 From: Christoph Hellwig To: iommu@lists.linux-foundation.org, Linus Torvalds , Jesper Dangaard Brouer Cc: Tariq Toukan , Ilias Apalodimas , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Robin Murphy , Konrad Rzeszutek Wilk , Tony Luck , Fenghua Yu , Marek Szyprowski , Keith Busch , Jonathan Derrick , linux-pci@vger.kernel.org, linux-ia64@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/15] dma-mapping: simplify the dma_sync_single_range_for_{cpu,device} implementation Date: Fri, 7 Dec 2018 11:07:11 -0800 Message-Id: <20181207190720.18517-7-hch@lst.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181207190720.18517-1-hch@lst.de> References: <20181207190720.18517-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can just call the regular calls after adding offset the the address instead of reimplementing them. Signed-off-by: Christoph Hellwig --- include/linux/dma-debug.h | 27 ------------------------ include/linux/dma-mapping.h | 34 +++++++++--------------------- kernel/dma/debug.c | 42 ------------------------------------- 3 files changed, 10 insertions(+), 93 deletions(-) diff --git a/include/linux/dma-debug.h b/include/linux/dma-debug.h index 30213adbb6b9..c85e097a984c 100644 --- a/include/linux/dma-debug.h +++ b/include/linux/dma-debug.h @@ -72,17 +72,6 @@ extern void debug_dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size, int direction); -extern void debug_dma_sync_single_range_for_cpu(struct device *dev, - dma_addr_t dma_handle, - unsigned long offset, - size_t size, - int direction); - -extern void debug_dma_sync_single_range_for_device(struct device *dev, - dma_addr_t dma_handle, - unsigned long offset, - size_t size, int direction); - extern void debug_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, int direction); @@ -174,22 +163,6 @@ static inline void debug_dma_sync_single_for_device(struct device *dev, { } -static inline void debug_dma_sync_single_range_for_cpu(struct device *dev, - dma_addr_t dma_handle, - unsigned long offset, - size_t size, - int direction) -{ -} - -static inline void debug_dma_sync_single_range_for_device(struct device *dev, - dma_addr_t dma_handle, - unsigned long offset, - size_t size, - int direction) -{ -} - static inline void debug_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, int direction) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 7799c2b27849..8916499d2805 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -360,6 +360,13 @@ static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr, debug_dma_sync_single_for_cpu(dev, addr, size, dir); } +static inline void dma_sync_single_range_for_cpu(struct device *dev, + dma_addr_t addr, unsigned long offset, size_t size, + enum dma_data_direction dir) +{ + return dma_sync_single_for_cpu(dev, addr + offset, size, dir); +} + static inline void dma_sync_single_for_device(struct device *dev, dma_addr_t addr, size_t size, enum dma_data_direction dir) @@ -372,32 +379,11 @@ static inline void dma_sync_single_for_device(struct device *dev, debug_dma_sync_single_for_device(dev, addr, size, dir); } -static inline void dma_sync_single_range_for_cpu(struct device *dev, - dma_addr_t addr, - unsigned long offset, - size_t size, - enum dma_data_direction dir) -{ - const struct dma_map_ops *ops = get_dma_ops(dev); - - BUG_ON(!valid_dma_direction(dir)); - if (ops->sync_single_for_cpu) - ops->sync_single_for_cpu(dev, addr + offset, size, dir); - debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir); -} - static inline void dma_sync_single_range_for_device(struct device *dev, - dma_addr_t addr, - unsigned long offset, - size_t size, - enum dma_data_direction dir) + dma_addr_t addr, unsigned long offset, size_t size, + enum dma_data_direction dir) { - const struct dma_map_ops *ops = get_dma_ops(dev); - - BUG_ON(!valid_dma_direction(dir)); - if (ops->sync_single_for_device) - ops->sync_single_for_device(dev, addr + offset, size, dir); - debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir); + return dma_sync_single_for_device(dev, addr + offset, size, dir); } static inline void diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c index 231ca4628062..3214833b47e2 100644 --- a/kernel/dma/debug.c +++ b/kernel/dma/debug.c @@ -1662,48 +1662,6 @@ void debug_dma_sync_single_for_device(struct device *dev, } EXPORT_SYMBOL(debug_dma_sync_single_for_device); -void debug_dma_sync_single_range_for_cpu(struct device *dev, - dma_addr_t dma_handle, - unsigned long offset, size_t size, - int direction) -{ - struct dma_debug_entry ref; - - if (unlikely(dma_debug_disabled())) - return; - - ref.type = dma_debug_single; - ref.dev = dev; - ref.dev_addr = dma_handle; - ref.size = offset + size; - ref.direction = direction; - ref.sg_call_ents = 0; - - check_sync(dev, &ref, true); -} -EXPORT_SYMBOL(debug_dma_sync_single_range_for_cpu); - -void debug_dma_sync_single_range_for_device(struct device *dev, - dma_addr_t dma_handle, - unsigned long offset, - size_t size, int direction) -{ - struct dma_debug_entry ref; - - if (unlikely(dma_debug_disabled())) - return; - - ref.type = dma_debug_single; - ref.dev = dev; - ref.dev_addr = dma_handle; - ref.size = offset + size; - ref.direction = direction; - ref.sg_call_ents = 0; - - check_sync(dev, &ref, false); -} -EXPORT_SYMBOL(debug_dma_sync_single_range_for_device); - void debug_dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, int direction) { -- 2.19.1