From patchwork Mon Mar 1 08:42:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12109085 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=-16.8 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,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 A10E0C433E0 for ; Mon, 1 Mar 2021 08:47:25 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 5FCDA64DF1 for ; Mon, 1 Mar 2021 08:47:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FCDA64DF1 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8O1mvfMIBPZputHTdk6z5w2ve6sQUeeU2BlGlhE4fQs=; b=w6K3d8I0aaYLfmf1jrB57oE/h 2Ytp3jXyz/sFY8yEiFWPJY1h9fwaetWr0lqM5hvj7wMnh71E0Af7D30EO8bj+Fo5Lm9jQTk5bqt6E bOUbbMZNY8na8J6nxQ7MZNvXZIq1mWcusY40mxdNfizRS6N0SZ7qziEph1YAOwI2+4RY0S0y1FO6t Q1yqfZH34CXaxHdTsz9BHjOWi+xMNjNHeT1HXvH7ZSNYFVXkmOtJPpFCzTNhwPorHUQbssVz1eZ5P 9G68mj5rxN2hXCAyy2Z80F5EYHDWwYLghCYnehU/WGOdqKWh7VKVATwwDliNxg8dMrj/i31wbfTku r6fNJkEGA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lGeBz-0000Gu-8U; Mon, 01 Mar 2021 08:46:15 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lGeBw-0000Fh-RN for linux-arm-kernel@merlin.infradead.org; Mon, 01 Mar 2021 08:46:12 +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=xW3e/be0EWhcIVogSADJb6O7B/1UPJRMXZ1DHw7XToM=; b=DRyzqUvjLicdwyE1oaGJikVtBy aQDPW4RFib9iRVgCqH8O0asS8IXpzN1MHH3K1Lvt8ETu7k4NVb5fAeiqi+A1+q+gYgPxLjm2YcMEf zT+89mwG7MzZM59zy8lUpzNOFJBMeeXnAThdQsqWq1PfoWdcKEvQtvDb3zYowx/cXkI88HzFrnsX5 b8tsOZx/4tAadAZuCY2pz9vC4gXg8gxRwyD72KPNVew+ScbpQxFgXIoEJSS+mVPMOmOBIxWnXQ7RQ tHCO/aZYKICm7c98vq7zV0y9eNRU0OKizoSsJUb1IYcwhG26q0Vb6JO70tamcp1BQHo5CYNqQtZcG kknH2w5g==; Received: from [2001:4bb8:19b:e4b7:cdf9:733f:4874:8eb4] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lGeBL-00FUjk-Ir; Mon, 01 Mar 2021 08:45:46 +0000 From: Christoph Hellwig To: Joerg Roedel , Will Deacon , Li Yang Subject: [PATCH 09/17] iommu/fsl_pamu: merge handle_attach_device into fsl_pamu_attach_device Date: Mon, 1 Mar 2021 09:42:49 +0100 Message-Id: <20210301084257.945454-10-hch@lst.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210301084257.945454-1-hch@lst.de> References: <20210301084257.945454-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: freedreno@lists.freedesktop.org, kvm@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, iommu@lists.linux-foundation.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, David Woodhouse , linux-arm-kernel@lists.infradead.org, Lu Baolu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org No good reason to split this functionality over two functions. Signed-off-by: Christoph Hellwig --- drivers/iommu/fsl_pamu_domain.c | 59 +++++++++++---------------------- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c index 4a4944332674f7..962cdc1a4a1924 100644 --- a/drivers/iommu/fsl_pamu_domain.c +++ b/drivers/iommu/fsl_pamu_domain.c @@ -240,45 +240,13 @@ static int update_domain_stash(struct fsl_dma_domain *dma_domain, u32 val) return ret; } -/* - * Attach the LIODN to the DMA domain and configure the geometry - * and window mappings. - */ -static int handle_attach_device(struct fsl_dma_domain *dma_domain, - struct device *dev, const u32 *liodn, - int num) -{ - unsigned long flags; - int ret = 0; - int i; - - spin_lock_irqsave(&dma_domain->domain_lock, flags); - for (i = 0; i < num; i++) { - /* Ensure that LIODN value is valid */ - if (liodn[i] >= PAACE_NUMBER_ENTRIES) { - pr_debug("Invalid liodn %d, attach device failed for %pOF\n", - liodn[i], dev->of_node); - ret = -EINVAL; - break; - } - - attach_device(dma_domain, liodn[i], dev); - ret = pamu_set_liodn(dma_domain, dev, liodn[i]); - if (ret) - break; - } - spin_unlock_irqrestore(&dma_domain->domain_lock, flags); - - return ret; -} - static int fsl_pamu_attach_device(struct iommu_domain *domain, struct device *dev) { struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); + unsigned long flags; + int len, ret = 0, i; const u32 *liodn; - u32 liodn_cnt; - int len, ret = 0; struct pci_dev *pdev = NULL; struct pci_controller *pci_ctl; @@ -298,14 +266,27 @@ static int fsl_pamu_attach_device(struct iommu_domain *domain, } liodn = of_get_property(dev->of_node, "fsl,liodn", &len); - if (liodn) { - liodn_cnt = len / sizeof(u32); - ret = handle_attach_device(dma_domain, dev, liodn, liodn_cnt); - } else { + if (!liodn) { pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node); - ret = -EINVAL; + return -EINVAL; } + spin_lock_irqsave(&dma_domain->domain_lock, flags); + for (i = 0; i < len / sizeof(u32); i++) { + /* Ensure that LIODN value is valid */ + if (liodn[i] >= PAACE_NUMBER_ENTRIES) { + pr_debug("Invalid liodn %d, attach device failed for %pOF\n", + liodn[i], dev->of_node); + ret = -EINVAL; + break; + } + + attach_device(dma_domain, liodn[i], dev); + ret = pamu_set_liodn(dma_domain, dev, liodn[i]); + if (ret) + break; + } + spin_unlock_irqrestore(&dma_domain->domain_lock, flags); return ret; }