Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1541912ybt; Thu, 9 Jul 2020 09:23:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJj8/Ed4RbTV9sRhMiJTHFOucPgF3K3Vk/tW03eZYLy1iBGu6+NRYyns13dV/ihloRYQQh X-Received: by 2002:a17:906:9387:: with SMTP id l7mr55054187ejx.274.1594311834606; Thu, 09 Jul 2020 09:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594311834; cv=none; d=google.com; s=arc-20160816; b=N5N+u7czKrNk8Tx8asP4MOVJPg1a1VunttvdU6zqSXVrT3K3yoPjtTlz7WjvRWoUe5 xRscg35EjLIhWmF7UxkjezdkC30WvJZE9UbEmxBy5PoXCBo2QcsOtec47zgljfWCtBDD FMOdvlULGdBkwZD/mm9nBq640SI08ij91zLH/obnNcafti8s7jO8p4wstGfRhrqaWV18 6K0jTuyBW8HP/uilCVnvxIwp5Q8wDpdmv34V5r6uoTVEDsf9Rv3p4nWmtmXEhhMblgZi FNzBfZH5aOKx07JVjwirBwjfZSfxTQkLPv0C12ATBhqRILuMT9OQcIrdvtjKPMyJsI7g F8Jg== 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; bh=ZvhlxnRmMyjIcJh225tGZgBeaEuDoNvhU5oE8M8ke8g=; b=KDLyPj/Lfv3umKulF8xvReht6UzuThET2uK8kL0P4gsxYe/LsxYXs5I4YErbBa5xjn lsGJAexo99qZt3f9T71t27uMTWGCFaql2i2InHvDjF8ybRhh/q/8qAGPEICaL2ij2DSv fShnx61mdVNcTw2QbqJXl31aM5MpQ56g3dAv4xA82Ts9b8mUOD3GVn6gBPi0QLox/+q+ rBIxDvwRfJIuRuzuOW/BdBYNw/sDxtlZi+dU84kEM0aB+qQaUEBZoSYiw6Kg2YMYT2b6 qOjHPiT6xz25iRs3oJJcFr+ThFymbPtDlKbz4Vrh5ArCnzNlr1/CV8bTwsOHI8ERHGME IHAg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si2440865edm.63.2020.07.09.09.23.31; Thu, 09 Jul 2020 09:23:54 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728133AbgGIQTf (ORCPT + 99 others); Thu, 9 Jul 2020 12:19:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:39104 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726357AbgGIQTd (ORCPT ); Thu, 9 Jul 2020 12:19:33 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7ADF6AEC4; Thu, 9 Jul 2020 16:19:32 +0000 (UTC) From: Nicolas Saenz Julienne To: hch@lst.de, Robin Murphy , David Rientjes , iommu@lists.linux-foundation.org, Marek Szyprowski Cc: linux-rpi-kernel@lists.infradead.org, jeremy.linton@arm.com, Nicolas Saenz Julienne , linux-kernel@vger.kernel.org Subject: [PATCH 1/4] dma-direct: Provide function to check physical memory area validity Date: Thu, 9 Jul 2020 18:19:01 +0200 Message-Id: <20200709161903.26229-2-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200709161903.26229-1-nsaenzjulienne@suse.de> References: <20200709161903.26229-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dma_coherent_ok() checks if a physical memory area fits a device's DMA constraints. Signed-off-by: Nicolas Saenz Julienne --- include/linux/dma-direct.h | 1 + kernel/dma/direct.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h index cdfa400f89b3..cb23a8305132 100644 --- a/include/linux/dma-direct.h +++ b/include/linux/dma-direct.h @@ -69,6 +69,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size, u64 dma_direct_get_required_mask(struct device *dev); gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask, u64 *phys_mask); +bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size); void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs); void dma_direct_free(struct device *dev, size_t size, void *cpu_addr, diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 93f578a8e613..4de864cacd22 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -70,7 +70,7 @@ gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask, return 0; } -static bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size) +bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size) { return phys_to_dma_direct(dev, phys) + size - 1 <= min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit); -- 2.27.0