Received: by 10.213.65.68 with SMTP id h4csp662361imn; Fri, 23 Mar 2018 12:51:54 -0700 (PDT) X-Google-Smtp-Source: AG47ELuTeqYxWptHjbQ3BOSMCwA4dwF28O7bkyU02lRBh/ZgGEN2zRdRnOtbBWLuTDBNhI317tNg X-Received: by 10.99.185.7 with SMTP id z7mr22453062pge.123.1521834714529; Fri, 23 Mar 2018 12:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521834714; cv=none; d=google.com; s=arc-20160816; b=HkHOPzPJFPHPetf95mRLLOGiRhr13Ozv0O910fu7Mz7uAVukXqsAuR0QJO5YFS9sOS 2WhOhktrfP4xZCYn3qxUEMFrz8Vks0rvatG3Cyaj8bvcQP3bU3y7QkVReGbFEbgo2549 BZdcSUpOnx495LoTYoA8itmBFCifuRe6OKw0zAAedDYdBls4/N0gIWHBO30a25xcz8LG 95Ts4wCiqCdaTcs/pLDSp4KSV8ntRPylZMXXSlKqbeOgsKMD1A5oIl17wal06i6OPxNX xKaYjt+KfQd03KXu/dJxar6XSLx1O9GsDQNjQIdpADw3hELVdrvOEO63oz8EUSAFefuw wxeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=mPaj5aAkjL0fiXlKmhRx8Rz0yKj1Ezp2xvovLSVpZEg=; b=mbymxDXOWpP7c6PZdug0Qs4IAP92eJVnUgRrb4pemhZSIV9DI+itW24vrkkYN/dKTH xLciHsIJSaiYXt2VGbr6u80Njy1YuV/ENZTno4kXOcolHE7cLodjOfMJp/oEiqVJ/mLL 4e/JHgMaBekt0hMhq/+sVS2km8hQ+/msIniY3/CTodmYUUgV+lZpYwaMUNz1Q9SUi9xi rgjH1O63+jn7q80YtXskfVqSbifO9px6/gRGP9bpZIG7jqVSIIikRLHszizxfbidrvyU BHMBgXcZJD46ltjA8AI0ObdwbaqDzRkgRLQVDmKmD/9ZsP0YPWQP2Y9eN/actq0tYGAw kpDA== 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 q9-v6si9245409plr.21.2018.03.23.12.51.40; Fri, 23 Mar 2018 12:51:54 -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 S1751961AbeCWTto (ORCPT + 99 others); Fri, 23 Mar 2018 15:49:44 -0400 Received: from terminus.zytor.com ([198.137.202.136]:56565 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751691AbeCWTtn (ORCPT ); Fri, 23 Mar 2018 15:49:43 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w2NJmmHX019413; Fri, 23 Mar 2018 12:48:48 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w2NJmlfc019406; Fri, 23 Mar 2018 12:48:47 -0700 Date: Fri, 23 Mar 2018 12:48:47 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Christoph Hellwig Message-ID: Cc: thomas.lendacky@amd.com, jdmason@kudzu.us, hpa@zytor.com, dwmw2@infradead.org, linux-kernel@vger.kernel.org, joro@8bytes.org, tglx@linutronix.de, konrad.wilk@oracle.com, peterz@infradead.org, hch@lst.de, torvalds@linux-foundation.org, mulix@mulix.org, mingo@kernel.org Reply-To: tglx@linutronix.de, joro@8bytes.org, hch@lst.de, peterz@infradead.org, konrad.wilk@oracle.com, mulix@mulix.org, torvalds@linux-foundation.org, mingo@kernel.org, hpa@zytor.com, jdmason@kudzu.us, thomas.lendacky@amd.com, linux-kernel@vger.kernel.org, dwmw2@infradead.org In-Reply-To: <20180319103826.12853-3-hch@lst.de> References: <20180319103826.12853-3-hch@lst.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/dma] x86/dma: Remove dma_alloc_coherent_mask() Git-Commit-ID: 038d07a283d62336b32cc23b62aecdf9418cfc11 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 038d07a283d62336b32cc23b62aecdf9418cfc11 Gitweb: https://git.kernel.org/tip/038d07a283d62336b32cc23b62aecdf9418cfc11 Author: Christoph Hellwig AuthorDate: Mon, 19 Mar 2018 11:38:14 +0100 Committer: Ingo Molnar CommitDate: Tue, 20 Mar 2018 10:01:56 +0100 x86/dma: Remove dma_alloc_coherent_mask() These days all devices (including the ISA fallback device) have a coherent DMA mask set, so remove the workaround. Tested-by: Tom Lendacky Signed-off-by: Christoph Hellwig Reviewed-by: Thomas Gleixner Reviewed-by: Konrad Rzeszutek Wilk Cc: David Woodhouse Cc: Joerg Roedel Cc: Jon Mason Cc: Linus Torvalds Cc: Muli Ben-Yehuda Cc: Peter Zijlstra Cc: iommu@lists.linux-foundation.org Link: http://lkml.kernel.org/r/20180319103826.12853-3-hch@lst.de Signed-off-by: Ingo Molnar --- arch/x86/include/asm/dma-mapping.h | 18 ++---------------- arch/x86/kernel/pci-dma.c | 10 ++++------ arch/x86/mm/mem_encrypt.c | 4 +--- drivers/xen/swiotlb-xen.c | 16 +--------------- 4 files changed, 8 insertions(+), 40 deletions(-) diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h index 6277c83c0eb1..545bf3721bc0 100644 --- a/arch/x86/include/asm/dma-mapping.h +++ b/arch/x86/include/asm/dma-mapping.h @@ -44,26 +44,12 @@ extern void dma_generic_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_addr, unsigned long attrs); -static inline unsigned long dma_alloc_coherent_mask(struct device *dev, - gfp_t gfp) -{ - unsigned long dma_mask = 0; - - dma_mask = dev->coherent_dma_mask; - if (!dma_mask) - dma_mask = (gfp & GFP_DMA) ? DMA_BIT_MASK(24) : DMA_BIT_MASK(32); - - return dma_mask; -} - static inline gfp_t dma_alloc_coherent_gfp_flags(struct device *dev, gfp_t gfp) { - unsigned long dma_mask = dma_alloc_coherent_mask(dev, gfp); - - if (dma_mask <= DMA_BIT_MASK(24)) + if (dev->coherent_dma_mask <= DMA_BIT_MASK(24)) gfp |= GFP_DMA; #ifdef CONFIG_X86_64 - if (dma_mask <= DMA_BIT_MASK(32) && !(gfp & GFP_DMA)) + if (dev->coherent_dma_mask <= DMA_BIT_MASK(32) && !(gfp & GFP_DMA)) gfp |= GFP_DMA32; #endif return gfp; diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index df7ab02f959f..b59820872ec7 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -80,13 +80,10 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_addr, gfp_t flag, unsigned long attrs) { - unsigned long dma_mask; struct page *page; unsigned int count = PAGE_ALIGN(size) >> PAGE_SHIFT; dma_addr_t addr; - dma_mask = dma_alloc_coherent_mask(dev, flag); - again: page = NULL; /* CMA can be used only in the context which permits sleeping */ @@ -95,7 +92,7 @@ again: flag); if (page) { addr = phys_to_dma(dev, page_to_phys(page)); - if (addr + size > dma_mask) { + if (addr + size > dev->coherent_dma_mask) { dma_release_from_contiguous(dev, page, count); page = NULL; } @@ -108,10 +105,11 @@ again: return NULL; addr = phys_to_dma(dev, page_to_phys(page)); - if (addr + size > dma_mask) { + if (addr + size > dev->coherent_dma_mask) { __free_pages(page, get_order(size)); - if (dma_mask < DMA_BIT_MASK(32) && !(flag & GFP_DMA)) { + if (dev->coherent_dma_mask < DMA_BIT_MASK(32) && + !(flag & GFP_DMA)) { flag = (flag & ~GFP_DMA32) | GFP_DMA; goto again; } diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c index 3a1b5fe4c2ca..f6cd84beb610 100644 --- a/arch/x86/mm/mem_encrypt.c +++ b/arch/x86/mm/mem_encrypt.c @@ -198,12 +198,10 @@ void __init sme_early_init(void) static void *sev_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) { - unsigned long dma_mask; unsigned int order; struct page *page; void *vaddr = NULL; - dma_mask = dma_alloc_coherent_mask(dev, gfp); order = get_order(size); /* @@ -221,7 +219,7 @@ static void *sev_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, * mask with it already cleared. */ addr = __sme_clr(phys_to_dma(dev, page_to_phys(page))); - if ((addr + size) > dma_mask) { + if ((addr + size) > dev->coherent_dma_mask) { __free_pages(page, get_order(size)); } else { vaddr = page_address(page); diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 5bb72d3f8337..e1c60899fdbc 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -53,20 +53,6 @@ * API. */ -#ifndef CONFIG_X86 -static unsigned long dma_alloc_coherent_mask(struct device *dev, - gfp_t gfp) -{ - unsigned long dma_mask = 0; - - dma_mask = dev->coherent_dma_mask; - if (!dma_mask) - dma_mask = (gfp & GFP_DMA) ? DMA_BIT_MASK(24) : DMA_BIT_MASK(32); - - return dma_mask; -} -#endif - #define XEN_SWIOTLB_ERROR_CODE (~(dma_addr_t)0x0) static char *xen_io_tlb_start, *xen_io_tlb_end; @@ -328,7 +314,7 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size, return ret; if (hwdev && hwdev->coherent_dma_mask) - dma_mask = dma_alloc_coherent_mask(hwdev, flags); + dma_mask = hwdev->coherent_dma_mask; /* At this point dma_handle is the physical address, next we are * going to set it to the machine address.