Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4409582imu; Tue, 29 Jan 2019 00:44:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN6vMsWKygsGxgu/wa8krOonRN/6m4kU4GGPVJLCKekogqgS+fdZi6RoDOlAjtOlrGdObZIT X-Received: by 2002:a62:46d0:: with SMTP id o77mr25512413pfi.172.1548751461127; Tue, 29 Jan 2019 00:44:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548751461; cv=none; d=google.com; s=arc-20160816; b=lGWQpGz0AioCynBfvPieTfF8nqQGErkISpDaEByjzY8gkOEGcpyUyvrc27sLbBTDOo uF07hxpaC0ZKWBbikpxqBph4JssrdhFl5IM2LZX5wUTJXnH2ZR2otCQe2ZB6gyPmKQZW Dvk3//G3sqNZZ2zF51ZSRlz7mrL0C4XJf4sLm8p3NO5FEgWwYQk1vAVINJh2E0lBhKB1 GTBPz6F3T/7umBlBfgCq2izMT4rAJsuGS4UZ/phPIHMuoVmqF2t9Dpet2DkOEId7U/Od 5vEup+xQKJLtkT5wwq3v45aaiNXAiMYkFFOMadbL4i2T+H4jA56yh8+loZZQhZ8w40yN Ow/g== 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; bh=weam4eTAhL4c4EzEzlEwuvq/SpmA7Xe+O9sQdIywj/k=; b=ZBzW/gV8BKjPVa0CEJXgRIgdOwzBw/vNw02/FlY6297rvymeg8UEAMVMRzSd43pd1v Lw7DDNYRU33Ny+VWG8fhl5j0+UPQlEppezoIHqmTLseu0p1oPO756jWfRHn2Ua5Oljkr vdHO2EIDk2PcV0p2nkDpDnQ+qtwhGvvIDU9IYxlkj2kXWfRZHngl/sL3IwC1TVvII1w8 o8WNhXNbZeufutWoDt4LifcpDIndxIH2FLupHo832867HS4d6oLKCxIiDYYF+NlhJhqT RoblFPOu9EKLBDtRpUDDlUjXvSv6dzszxLrxTZpFlEWgeCX4Vm1jtlRl7dwPwYLtLb/j M+nQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 36si8759779pgt.213.2019.01.29.00.44.04; Tue, 29 Jan 2019 00:44:21 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727710AbfA2Inu (ORCPT + 99 others); Tue, 29 Jan 2019 03:43:50 -0500 Received: from 8bytes.org ([81.169.241.247]:35550 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727176AbfA2Inq (ORCPT ); Tue, 29 Jan 2019 03:43:46 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 963E0364; Tue, 29 Jan 2019 09:43:44 +0100 (CET) From: Joerg Roedel To: "Michael S . Tsirkin" , Jason Wang , Konrad Rzeszutek Wilk , Christoph Hellwig Cc: Jens Axboe , virtualization@lists.linux-foundation.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, jfehlig@suse.com, jon.grimm@amd.com, brijesh.singh@amd.com, joro@8bytes.org, jroedel@suse.de Subject: [PATCH 2/5] swiotlb: Add is_swiotlb_active() function Date: Tue, 29 Jan 2019 09:43:39 +0100 Message-Id: <20190129084342.26030-3-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190129084342.26030-1-joro@8bytes.org> References: <20190129084342.26030-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel This function will be used from dma_direct code to determine the maximum segment size of a dma mapping. Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Joerg Roedel --- include/linux/swiotlb.h | 6 ++++++ kernel/dma/swiotlb.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index 1c22d96e1742..e9e786b4b598 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h @@ -63,6 +63,7 @@ extern void swiotlb_tbl_sync_single(struct device *hwdev, extern int swiotlb_dma_supported(struct device *hwdev, u64 mask); size_t swiotlb_max_mapping_size(struct device *dev); +bool is_swiotlb_active(void); #ifdef CONFIG_SWIOTLB extern enum swiotlb_force swiotlb_force; @@ -100,6 +101,11 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev) { return SIZE_MAX; } + +static inline bool is_swiotlb_active(void) +{ + return false; +} #endif /* CONFIG_SWIOTLB */ extern void swiotlb_print_info(void); diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 9cb21259cb0b..c873f9cc2146 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -667,3 +667,12 @@ size_t swiotlb_max_mapping_size(struct device *dev) { return ((size_t)1 << IO_TLB_SHIFT) * IO_TLB_SEGSIZE; } + +bool is_swiotlb_active(void) +{ + /* + * When SWIOTLB is initialized, even if io_tlb_start points to physical + * address zero, io_tlb_end surely doesn't. + */ + return io_tlb_end != 0; +} -- 2.17.1