From patchwork Tue Mar 16 15:38:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12143049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D650C433DB for ; Tue, 16 Mar 2021 17:03:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B926665114 for ; Tue, 16 Mar 2021 17:02:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B926665114 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dok2jwuw6YYrHIAarZloIk2Gn757AWc/62ZAHvxkPkU=; b=QqGR3ybRT+ZnNy4w1UXB27rVq 88CBALTyKlhMHdjuFOlxhIpIhUgaWF2BWn1g6CKKcFUr2s3uFsZoZ3p22yfa8bwVDJKwQqk24I15g tVIsqw/Qs1wZg+p4S8SSSJa5zvEnCIGb7rrghJIOXl8fLxTo77sY1P0OJKECfe/afxbzZIhZb5kx0 Vf9Pm72++t6zHHFEDEsjWidpA8ny+x/2ey2QDd8kuyz6+ntdfGR3/SCMmRQKKA27hG7xhVMw/EK5s Muqv633M34DIa/M5wEiOD7u6MgH/bgL+QU6MR+1FVB8561P6rtduw7Iglv/YynLmwPSDMf0dndLgx EBsutkPTw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lMD4D-001IDk-0f; Tue, 16 Mar 2021 17:01:13 +0000 Received: from casper.infradead.org ([90.155.50.34]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lMD2z-001HDR-Fs for linux-arm-kernel@desiato.infradead.org; Tue, 16 Mar 2021 16:59:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=Rw7EzDJS9qw2BQD9ybEsSVHRfrLN5SOhcMfS8kp3ZR4=; b=wO7ZBevcmjJiemSBKSjj4uO268 KqJjDeIav31h0tTKUvZY27AJEWA560Wj1p1l7UTBYcz0BJeAWkWkkj5/a1W5iB7YfMtLZf8M8gMaa xcDgkI08ipECOG9nTB20LOf/J9+jK3qQEtY/V3t/8aSV6+08iXjATWpqr+QbwLUGVms6zRsknZvJ/ ZaDj8FDBcaN1W2C6pr67cBD62CEjgDK2SWIwU0tGjHa1RVqOPIAc/XXh0xcHou91+QUcif3YjGYh7 Q5ME8Giltlt3gHu2jbcEhyzpf0o6GtJ/+A+TkQf0ew6b8UPFPRnnH6a5BlhMY/DtVyqZbylYs0nzz tWRpCaLg==; Received: from 089144199244.atnat0008.highway.a1.net ([89.144.199.244] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lMBxO-000GJk-5v; Tue, 16 Mar 2021 15:50:08 +0000 From: Christoph Hellwig To: Joerg Roedel , Will Deacon , Li Yang Cc: Michael Ellerman , David Woodhouse , Lu Baolu , linuxppc-dev@lists.ozlabs.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Subject: [PATCH 04/18] iommu/fsl_pamu: merge iommu_alloc_dma_domain into fsl_pamu_domain_alloc Date: Tue, 16 Mar 2021 16:38:10 +0100 Message-Id: <20210316153825.135976-5-hch@lst.de> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210316153825.135976-1-hch@lst.de> References: <20210316153825.135976-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Keep the functionality to allocate the domain together. Signed-off-by: Christoph Hellwig Acked-by: Li Yang Acked-by: Will Deacon --- drivers/iommu/fsl_pamu_domain.c | 34 ++++++++++----------------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c index 7bd08ddad07779..a4da5597755d3d 100644 --- a/drivers/iommu/fsl_pamu_domain.c +++ b/drivers/iommu/fsl_pamu_domain.c @@ -292,25 +292,6 @@ static int check_size(u64 size, dma_addr_t iova) return 0; } -static struct fsl_dma_domain *iommu_alloc_dma_domain(void) -{ - struct fsl_dma_domain *domain; - - domain = kmem_cache_zalloc(fsl_pamu_domain_cache, GFP_KERNEL); - if (!domain) - return NULL; - - domain->stash_id = ~(u32)0; - domain->snoop_id = ~(u32)0; - domain->win_cnt = pamu_get_max_subwin_cnt(); - - INIT_LIST_HEAD(&domain->devices); - - spin_lock_init(&domain->domain_lock); - - return domain; -} - static void remove_device_ref(struct device_domain_info *info, u32 win_cnt) { unsigned long flags; @@ -412,12 +393,17 @@ static struct iommu_domain *fsl_pamu_domain_alloc(unsigned type) if (type != IOMMU_DOMAIN_UNMANAGED) return NULL; - dma_domain = iommu_alloc_dma_domain(); - if (!dma_domain) { - pr_debug("dma_domain allocation failed\n"); + dma_domain = kmem_cache_zalloc(fsl_pamu_domain_cache, GFP_KERNEL); + if (!dma_domain) return NULL; - } - /* defaul geometry 64 GB i.e. maximum system address */ + + dma_domain->stash_id = ~(u32)0; + dma_domain->snoop_id = ~(u32)0; + dma_domain->win_cnt = pamu_get_max_subwin_cnt(); + INIT_LIST_HEAD(&dma_domain->devices); + spin_lock_init(&dma_domain->domain_lock); + + /* default geometry 64 GB i.e. maximum system address */ dma_domain->iommu_domain. geometry.aperture_start = 0; dma_domain->iommu_domain.geometry.aperture_end = (1ULL << 36) - 1; dma_domain->iommu_domain.geometry.force_aperture = true;