Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1719328ybh; Tue, 14 Jul 2020 05:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwbPVhznJiLs/aWO5UlckMIzAauUKrXnnd2a1+9G/4zUcxTq8VhI5aOl+0NI+QpT/T7R7a X-Received: by 2002:a17:906:924d:: with SMTP id c13mr4140005ejx.518.1594730587367; Tue, 14 Jul 2020 05:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594730587; cv=none; d=google.com; s=arc-20160816; b=R4cy+nBGH2L0rayXOGkT0niNNb+t8I/brqloQ4hCASCPS/pREUNz6H9ydakL3GDXaN q06BGixQ3zY0YP3R7mj2SzgbhhW6TrnE94Tt7B92gSr7qOaEsuXB5xxGgI5M3qo5EnsC NVVm84Rm8l4jZHNN7rkgyj+wqOhXi82pj4Onj5MPDmqO32NdzBCjd2BoTKK5PYTVfDNa 6n1mDHY86uVRuFvRKlS9Yu7bFvijuotlpjdp0eEKiqex6R/kcQ/jzfT1CNoB0z2eZvrl 7AZQVEtYKgMfvWP8Yn0S58AHYh9JzpmRloHWknFoAwngA7vtfB7TqoLX9wHYEzjKzihq 8Rug== 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=0h1EpxFaDBIYIFf763Ai3xZjQdmCW9U6HWpQzRVAf6s=; b=KQz5mT0SalxEtGjZNF++GuiqJyhiWyAfzFF9AUyXeNSC1RoCJs2ZjSROx96YsQrifh OPo5ePEowRDaVhTS6dKOm0XHrESJ8xDGV1ucjTRS3N+HdyUCqHafJpQcHNvOeAvFS8xs m+76Z/Pq4AjM/jS6ch8En9MiFq+4zNM0ig38Y8QVyNm0uSaEu1NeKmUFDWNeVGyn9tuR pRGeCeobcfg0gFnT7QFX3/z0s0pbPp4uoYT9faNZI8/KgrvABJhRJsKIZnEa+CaBh239 Kj0QDbwaKQ3Y0Uv3ai7bcM9DM8FJWRa5ii9yedVlJSMPAhUSWXPYlTRzQQj018TctCxf MrRg== 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 g8si2908448edr.455.2020.07.14.05.42.44; Tue, 14 Jul 2020 05:43:07 -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 S1728561AbgGNMkQ (ORCPT + 99 others); Tue, 14 Jul 2020 08:40:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:54780 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728455AbgGNMkB (ORCPT ); Tue, 14 Jul 2020 08:40:01 -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 11DD0AD3A; Tue, 14 Jul 2020 12:40:02 +0000 (UTC) From: Nicolas Saenz Julienne To: hch@lst.de, linux-kernel@vger.kernel.org, Marek Szyprowski , Robin Murphy Cc: linux-rpi-kernel@lists.infradead.org, jeremy.linton@arm.com, Nicolas Saenz Julienne , iommu@lists.linux-foundation.org Subject: [PATCH v2 1/4] dma-direct: Provide function to check physical memory area validity Date: Tue, 14 Jul 2020 14:39:25 +0200 Message-Id: <20200714123928.8581-2-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714123928.8581-1-nsaenzjulienne@suse.de> References: <20200714123928.8581-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 5184735a0fe8..ab2e20cba951 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 95866b647581..67f060b86a73 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