Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6093256imu; Wed, 30 Jan 2019 08:41:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN4UuwkSP9kmdOWeFTKGyhQhNc+5gyuZaB9tkCWZBhwUVqX1NCo/N59b7AL0weQMRanzpbyo X-Received: by 2002:a17:902:8b88:: with SMTP id ay8mr31564438plb.55.1548866484244; Wed, 30 Jan 2019 08:41:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548866484; cv=none; d=google.com; s=arc-20160816; b=N8rSGws4ZLVwRKDvI8zk/7OtfrrdqfYG6jRz1D1n7mNoAMCT8Q//YdxD7W8lEV97ip L646JEpDpNijbWurkusnnO32s8WMXSj1w8q9qYYsz6eDfOupR1fPb56kRymigZuxAWLT kPBks7kG4BhhS8IdhgQAI22agT88yoRBpAWZiCDZQXcFaaGJk7EYT6L7U5eh7O96JJDr RuqLlvNrD8jBskv+qQgImMbdYLvNeWuIbQYh51OzoGe7i6SbTWBoTosI5ge9xLojgheR 2zfwST9BpxlqI9tx1Y36MwLSbrvPrNwIxdldjg+arLtblVAyrPg5QXm3UzvZgtYfXMZQ oQeA== 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=7yJhcRhFZMIektHLOtjj8d/IamIpx5XlTUg03vl7rQg=; b=ZWuMP1tAiqt8GxNRg8409TpNw6pZ0OU6vzyPapHtHdfOAx7dk5loL9LDKjVEMYFG67 MBIu+W888tWz7oCygbez/gL11M488NGZCmNoWJBhN70w4Zr91xbtF7fLiiRbiLsz6FTc R+zRvw3vlddvQfrlMCsl97oZ/anzyp6MU38aC6h7JCwAVyt3wxqHm1y0b5zeRaJSWveb QyZ49B33LSrpW3THyOfMa+avqACFuieExV5cZOW7ngfvNTO8AErG3D8bFs5Zv6S0Xsnr yxCCk+jp0RY3ZsoHD0kaTe462j5NVyYCZE0FH6Iw4vh0QCvDzvheraHx+OwAV8W9rqog lqUA== 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 z2si1775151pgs.267.2019.01.30.08.41.09; Wed, 30 Jan 2019 08:41:24 -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 S1732295AbfA3Qkf (ORCPT + 99 others); Wed, 30 Jan 2019 11:40:35 -0500 Received: from 8bytes.org ([81.169.241.247]:36028 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732089AbfA3QkK (ORCPT ); Wed, 30 Jan 2019 11:40:10 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id 0102E69F; Wed, 30 Jan 2019 17:40:08 +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, Thomas.Lendacky@amd.com Subject: [PATCH 2/5] swiotlb: Add is_swiotlb_active() function Date: Wed, 30 Jan 2019 17:40:04 +0100 Message-Id: <20190130164007.26497-3-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190130164007.26497-1-joro@8bytes.org> References: <20190130164007.26497-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 Reviewed-by: Christoph Hellwig 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