From patchwork Sun Apr 7 12:41:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 161918 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2603659jan; Sun, 7 Apr 2019 05:48:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBDBdq84KNNcFOpitdLGzIksQKiWScKKLyOAnJQFCjK0IwyPJRkeUB/PkwldTXYsVdgGN7 X-Received: by 2002:a17:902:2a2b:: with SMTP id i40mr8190305plb.80.1554641302581; Sun, 07 Apr 2019 05:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554641302; cv=none; d=google.com; s=arc-20160816; b=kG6z4LtgZ7iM91ekZlPJcjZyJ3uessSqxP8dkb2xPyi/8cIxZx6r7VfIxODrKie49K 91qGmmQFM/LwvNh0sN6Wrf8U2AaqegyljA8sCgZ2/Y4XnuARRkCENBFkBPB5t+Ab6zPM UJm2GnHnYc+Y6zjugL7VykDjXOVQ2EV4f29JC9Qnz9w287nv2OPx0By0uiPhrEWfIjaU k8KIZGOqKmb9vsOMEyaB9RT/m/cddXNqk0y4Q+ivqIDJi0xR1gBV8z48oVq9js7f1vcY Aa9jf901pZZ1d5khL21rl0Tuk7R1f3cfCOw4g/nxWN4SxRZVoIXWx+eC1qwVwguoYbtw WC5Q== 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=Nb+MWYJwDL1g7sFDu+hmxW7gsDf3fhyRARjD8WuiWas=; b=yjK91ITRkBrLjaoQnSiZJxVJVV53g1gvOLeCCTTlAOwFdwAyxyyzl0VT0FVk8/JGv6 wj7fr+ySWmeKNYSbV3sfncnNdvl5dZvda6j8lMefV4PS8LNkrtFbp2FzUJladTeqODHh /d4ouAtsDPYQFNUYVemfietqqDLSDRpEgCj9AdSchUGumqa41SGqa8KF/NyF9pjQd8UK xFbN68uHAOH2raNu9tgasntMYlWjqbgUtgypwTYNpycu+/O9I/XgukRAkpXQlL/INfao spTOdwUfYVW7NwGq+GsGTyPTgP7gf3ybTjqky1qkBrTdsQmji42NXIEU1akv73MTp0hY Z/Og== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z61si25194625plb.81.2019.04.07.05.48.22; Sun, 07 Apr 2019 05:48:22 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726633AbfDGMsR (ORCPT + 31 others); Sun, 7 Apr 2019 08:48:17 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6698 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726527AbfDGMsO (ORCPT ); Sun, 7 Apr 2019 08:48:14 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D94DA2587E4ADED563FF; Sun, 7 Apr 2019 20:48:10 +0800 (CST) Received: from HGHY1l002753561.china.huawei.com (10.177.23.164) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Sun, 7 Apr 2019 20:48:04 +0800 From: Zhen Lei To: Jean-Philippe Brucker , John Garry , Robin Murphy , Will Deacon , Joerg Roedel , Jonathan Corbet , linux-doc , Sebastian Ott , Gerald Schaefer , "Martin Schwidefsky" , Heiko Carstens , Benjamin Herrenschmidt , Paul Mackerras , "Michael Ellerman" , Tony Luck , Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , David Woodhouse , iommu , linux-kernel , linux-s390 , linuxppc-dev , x86 , linux-ia64 CC: Zhen Lei , Hanjun Guo Subject: [PATCH v4 4/6] s390/pci: use common boot option iommu.dma_mode Date: Sun, 7 Apr 2019 20:41:45 +0800 Message-ID: <20190407124147.13576-5-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.19.2.windows.1 In-Reply-To: <20190407124147.13576-1-thunder.leizhen@huawei.com> References: <20190407124147.13576-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org s390_iommu=strict can be replaced with iommu.dma_mode=strict. Signed-off-by: Zhen Lei --- Documentation/admin-guide/kernel-parameters.txt | 7 ------- arch/s390/pci/pci_dma.c | 20 +++++--------------- drivers/iommu/Kconfig | 1 + 3 files changed, 6 insertions(+), 22 deletions(-) -- 1.8.3 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 60409ad23b2ac8b..a2df11945b33fc9 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4095,13 +4095,6 @@ S [KNL] Run init in single mode - s390_iommu= [HW,S390] - Set s390 IOTLB flushing mode - strict - With strict flushing every unmap operation will result in - an IOTLB flush. Default is lazy flushing before reuse, - which is faster. - sa1100ir [NET] See drivers/net/irda/sa1100_ir.c. diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c index 9e52d1527f71495..6f1615c16f33995 100644 --- a/arch/s390/pci/pci_dma.c +++ b/arch/s390/pci/pci_dma.c @@ -17,7 +17,6 @@ static struct kmem_cache *dma_region_table_cache; static struct kmem_cache *dma_page_table_cache; -static int s390_iommu_strict; static int zpci_refresh_global(struct zpci_dev *zdev) { @@ -193,13 +192,13 @@ static int __dma_purge_tlb(struct zpci_dev *zdev, dma_addr_t dma_addr, if (!zdev->tlb_refresh) return 0; } else { - if (!s390_iommu_strict) + if (IOMMU_DMA_MODE_IS_LAZY()) return 0; } ret = zpci_refresh_trans((u64) zdev->fh << 32, dma_addr, PAGE_ALIGN(size)); - if (ret == -ENOMEM && !s390_iommu_strict) { + if (ret == -ENOMEM && IOMMU_DMA_MODE_IS_LAZY()) { /* enable the hypervisor to free some resources */ if (zpci_refresh_global(zdev)) goto out; @@ -278,7 +277,7 @@ static dma_addr_t dma_alloc_address(struct device *dev, int size) spin_lock_irqsave(&zdev->iommu_bitmap_lock, flags); offset = __dma_alloc_iommu(dev, zdev->next_bit, size); if (offset == -1) { - if (!s390_iommu_strict) { + if (IOMMU_DMA_MODE_IS_LAZY()) { /* global flush before DMA addresses are reused */ if (zpci_refresh_global(zdev)) goto out_error; @@ -313,7 +312,7 @@ static void dma_free_address(struct device *dev, dma_addr_t dma_addr, int size) if (!zdev->iommu_bitmap) goto out; - if (s390_iommu_strict) + if (!IOMMU_DMA_MODE_IS_LAZY()) bitmap_clear(zdev->iommu_bitmap, offset, size); else bitmap_set(zdev->lazy_bitmap, offset, size); @@ -584,7 +583,7 @@ int zpci_dma_init_device(struct zpci_dev *zdev) rc = -ENOMEM; goto free_dma_table; } - if (!s390_iommu_strict) { + if (IOMMU_DMA_MODE_IS_LAZY()) { zdev->lazy_bitmap = vzalloc(zdev->iommu_pages / 8); if (!zdev->lazy_bitmap) { rc = -ENOMEM; @@ -671,12 +670,3 @@ void zpci_dma_exit(void) /* dma_supported is unconditionally true without a callback */ }; EXPORT_SYMBOL_GPL(s390_pci_dma_ops); - -static int __init s390_iommu_setup(char *str) -{ - if (!strncmp(str, "strict", 6)) - s390_iommu_strict = 1; - return 0; -} - -__setup("s390_iommu=", s390_iommu_setup); diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 19118cfdea1c335..d88dc44d60d88ea 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -77,6 +77,7 @@ config IOMMU_DEBUGFS choice prompt "IOMMU dma mode" depends on IOMMU_API + default IOMMU_DMA_MODE_LAZY if S390_IOMMU default IOMMU_DMA_MODE_STRICT help IOMMU dma mode, such as: passthrough, lazy, strict.