Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4866002imm; Tue, 9 Oct 2018 06:29:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV6144qz8rrIhVQYaNKzdEO1GtM/AVb8bvuJJYJwsrFMvT2onyya50t3URQ1cCv122xEvXtOE X-Received: by 2002:a17:902:a989:: with SMTP id bh9-v6mr27904439plb.245.1539091745664; Tue, 09 Oct 2018 06:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539091745; cv=none; d=google.com; s=arc-20160816; b=BbYhWtciem6roAI3/h2HLE+JnR89IndrT+M8+o2YiwsWhjmKjdAubwZDhDJRJ9bAWP HWWg2DdKiUP/5eUlsEfagv7+eqxasfGojlTSR5Q6hrQlaqRGhYKXaA7MB9I9qB+3ztKP 2CCO0NMD1acFKvmpIF2sXEqsXyrtcKBvm8TyGbgKKzJoVxMnOSEK01tM4poEkTS2K/Ye QJjMsn9PRl6NtqlvvPZmWqN2xZAt5y3f4X2YwJVMMoXmRjh22RaqsRo/Zx365deRnbAt 4XnEi6TsN7jpYFEnA+y/uGDmR4cI9vXWJZn6KT1Ftw7eM83KlFHCRI3VBByacjeOY6yW FC9w== 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 :dkim-signature; bh=Z1NpYAlNjtOl6wtV5jUw9RPikGAiju1XuiWRoBAFPXo=; b=jPdksYFyBQnKqDf06Ji9lkqgyZweUpaf6D3B2ZZGqv2DH7I1ARiwk6LzRBim11vTUL tKQtcbQO14jqtJ1sN9V/uFPXzEIL+sw/cQ/DF81Rkoy0yKzaz5uIYYebi1Eb/lS6OzoP w3JTf0jujYT1rmwdSExT5HEY7z5XJUS8NveQzumJCI2ic++WVSMcwbVMlD88/MURPPai YWOEm7+dZF/Lc9DBxC9epncKMYN4zp5tAJkPlsWyhVuStW78RPpJsiqviVx4zSD8HlXY /K1qIVMf1wTc9NjJ53zmtMkhVSk4pCvjxFdZrg5EqStXtmPK7BqT2rQRf7jzmWtUSOEJ O61g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=i9L1kOia; 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 g22-v6si19942924pgg.575.2018.10.09.06.28.50; Tue, 09 Oct 2018 06:29:05 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=i9L1kOia; 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 S1727642AbeJIUnR (ORCPT + 99 others); Tue, 9 Oct 2018 16:43:17 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49862 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727623AbeJIUnQ (ORCPT ); Tue, 9 Oct 2018 16:43:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Z1NpYAlNjtOl6wtV5jUw9RPikGAiju1XuiWRoBAFPXo=; b=i9L1kOiaNfNO/7tZVTeWRXi2kz I0a1agaNzMsnb522ajukDtVwUPc2LpL27ozdBJ9e5zSvgje4+azhFCnTPzq6vLxMZgdUN7m52NRQp EDpw5ZUT7Z6yCVZGESJ9dPHF1jbJHlO9WSTQSey4XLseB6F6FlZJQWvgyRddKIuQClZPLZaNk4FOF DpOYFj/AJjdwhKFwLk/V+ZH1Bfk29QjQK6S+yhwnLgxpjmgUsSfD0VcnXjNcoXyaxA0AhNvUvVSZv Qtx828RuRHH8+AZ8OyeY+W+Zhpa2Z4MghUPWbV0g6EmjVD3KbNucebmbE/xEt5rGEp/L/XGWFa9QD cVc3bl+Q==; Received: from clnet-p19-102.ikbnet.co.at ([83.175.77.102] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g9s1R-0001Q3-5q; Tue, 09 Oct 2018 13:26:01 +0000 From: Christoph Hellwig To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 23/33] powerpc/dma: remove max_direct_dma_addr Date: Tue, 9 Oct 2018 15:24:50 +0200 Message-Id: <20181009132500.17643-24-hch@lst.de> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181009132500.17643-1-hch@lst.de> References: <20181009132500.17643-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The max_direct_dma_addr duplicates the bus_dma_mask field in struct device. Use the generic field instead. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/device.h | 3 --- arch/powerpc/include/asm/dma-direct.h | 4 +--- arch/powerpc/kernel/dma-swiotlb.c | 20 -------------------- arch/powerpc/kernel/dma.c | 5 ++--- arch/powerpc/sysdev/fsl_pci.c | 3 +-- 5 files changed, 4 insertions(+), 31 deletions(-) diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h index 3814e1c2d4bc..a130be13ee83 100644 --- a/arch/powerpc/include/asm/device.h +++ b/arch/powerpc/include/asm/device.h @@ -38,9 +38,6 @@ struct dev_archdata { #ifdef CONFIG_IOMMU_API void *iommu_domain; #endif -#ifdef CONFIG_SWIOTLB - dma_addr_t max_direct_dma_addr; -#endif #ifdef CONFIG_PPC64 struct pci_dn *pci_data; #endif diff --git a/arch/powerpc/include/asm/dma-direct.h b/arch/powerpc/include/asm/dma-direct.h index 7702875aabb7..e00ab5d0612d 100644 --- a/arch/powerpc/include/asm/dma-direct.h +++ b/arch/powerpc/include/asm/dma-direct.h @@ -5,9 +5,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size) { #ifdef CONFIG_SWIOTLB - struct dev_archdata *sd = &dev->archdata; - - if (sd->max_direct_dma_addr && addr + size > sd->max_direct_dma_addr) + if (dev->bus_dma_mask && addr + size > dev->bus_dma_mask) return false; #endif diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index 60cb86338233..e05d95ff50ad 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -24,21 +24,6 @@ unsigned int ppc_swiotlb_enable; -static u64 swiotlb_powerpc_get_required(struct device *dev) -{ - u64 end, mask, max_direct_dma_addr = dev->archdata.max_direct_dma_addr; - - end = memblock_end_of_DRAM(); - if (max_direct_dma_addr && end > max_direct_dma_addr) - end = max_direct_dma_addr; - end += get_dma_offset(dev); - - mask = 1ULL << (fls64(end) - 1); - mask += mask - 1; - - return mask; -} - /* * At the moment, all platforms that use this code only require * swiotlb to be used if we're operating on HIGHMEM. Since @@ -60,22 +45,17 @@ const struct dma_map_ops powerpc_swiotlb_dma_ops = { .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, .sync_sg_for_device = swiotlb_sync_sg_for_device, .mapping_error = swiotlb_dma_mapping_error, - .get_required_mask = swiotlb_powerpc_get_required, }; static int ppc_swiotlb_bus_notify(struct notifier_block *nb, unsigned long action, void *data) { struct device *dev = data; - struct dev_archdata *sd; /* We are only intereted in device addition */ if (action != BUS_NOTIFY_ADD_DEVICE) return 0; - sd = &dev->archdata; - sd->max_direct_dma_addr = 0; - /* May need to bounce if the device can't address all of DRAM */ if ((dma_get_mask(dev) + 1) < memblock_end_of_DRAM()) set_dma_ops(dev, &powerpc_swiotlb_dma_ops); diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index bef91b8ad064..e3d2c15b209c 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -30,11 +30,10 @@ static u64 __maybe_unused get_pfn_limit(struct device *dev) { u64 pfn = (dev->coherent_dma_mask >> PAGE_SHIFT) + 1; - struct dev_archdata __maybe_unused *sd = &dev->archdata; #ifdef CONFIG_SWIOTLB - if (sd->max_direct_dma_addr && dev->dma_ops == &powerpc_swiotlb_dma_ops) - pfn = min_t(u64, pfn, sd->max_direct_dma_addr >> PAGE_SHIFT); + if (dev->bus_dma_mask && dev->dma_ops == &powerpc_swiotlb_dma_ops) + pfn = min_t(u64, pfn, dev->bus_dma_mask >> PAGE_SHIFT); #endif return pfn; diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index 561f97d698cc..f136567a5ed5 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -117,9 +117,8 @@ static u64 pci64_dma_offset; static void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev) { struct pci_controller *hose = pci_bus_to_host(pdev->bus); - struct dev_archdata *sd = &pdev->dev.archdata; - sd->max_direct_dma_addr = + pdev->dev.bus_dma_mask = hose->dma_window_base_cur + hose->dma_window_size; } -- 2.19.0