Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7338513imu; Thu, 31 Jan 2019 08:35:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN4OpqbWIBjrrM0TkhqTiW/L+y88V4nILJCMdqpsK6m998zDIDbMgskyOCR/QBluLY0jADR5 X-Received: by 2002:a63:a002:: with SMTP id r2mr31687473pge.212.1548952502335; Thu, 31 Jan 2019 08:35:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548952502; cv=none; d=google.com; s=arc-20160816; b=GM81cFa5CxnV0/32bxVYqtfzxZbONMoAIxxIGtGdnAgQW4t9bqv3TPwW/H+Rx6alnD xr5DHrMGJirVQQf6MV6r43hXRBYaKEzhRGLMlaR1J6o3tm9tzZxDRyMhRq5SdBqJOW2d 0MLVhNm60mNmpJRKs3ASBdiB/UIKWrf/4iWue3YNjPn5t/vSU7Y4xhRnptWRr0F5Yo3n p+sK9o7R/sFZ9Z3n2a0VDKsjyTPB2ynlvseEldNBVQc+Zeq4985FM8lxjSq/I+prc4Co 1h/cRDy8YJmzbrgw4xnf9N1jt4aFpB2bvurPo8bnGOhZDwXqZoe8a0zaFXJMMyiBq3hn 2LVA== 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=Br1v1nyou8u7SHGyKcjte9SZll+2dg+z4zlbZL3ki2vHBijltjz39+xj/NLL78WSSZ pVWLOjTGHn9mi3UDU1M5F7xYJf+IlGo4a+PWF8x9Qxa1qrpybJEu9xtMV7tG9WE4VNZB dVPm0ijJS9LLxatBEDypR5ZPBPpBj+PAB4ufY8LLnFgm8fCEdEm6LnO0F8qNXHUfqdel QoVG0bC6jje39SP16gW34R7qREdspuI1QUu/IhXBMNBPX5aWV/hsoPRh2Do41CvsOwYE XaIViO3TYNhv0m3mN3fhT/+dmgweqGajnNZAfzsUuUUQ5M1F1llPODPhfWbeZ1xW+yz5 EWOw== 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 33si5082584plt.228.2019.01.31.08.34.46; Thu, 31 Jan 2019 08:35:02 -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 S2388579AbfAaQeW (ORCPT + 99 others); Thu, 31 Jan 2019 11:34:22 -0500 Received: from 8bytes.org ([81.169.241.247]:36354 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388184AbfAaQeG (ORCPT ); Thu, 31 Jan 2019 11:34:06 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id ED2D6273; Thu, 31 Jan 2019 17:34:04 +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: Thu, 31 Jan 2019 17:34:00 +0100 Message-Id: <20190131163403.11363-3-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190131163403.11363-1-joro@8bytes.org> References: <20190131163403.11363-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