From patchwork Sat May 13 09:47:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 9725111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DBF9360387 for ; Sat, 13 May 2017 09:53:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEDC2288CF for ; Sat, 13 May 2017 09:53:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B390F288D3; Sat, 13 May 2017 09:53:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE37B288CF for ; Sat, 13 May 2017 09:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.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=m30LRluzvLnRJKcaEqzAWP9+g1euktglg1IksBQqics=; b=WiZin12eAkDyx6 BgeaiNfmlLoPcpylo129KR4NnK1bKM2Gs+QDHhpIz9Em8Zzv1EHnTu1Fjx3X7GJTHrnupplwaK+4D bNUL+MWurLuCG18hNko+95/qViGf1L9nzMWYJ7HqHVKfvPsNtCRhcGBLzNbEkyZvI4oWn3SQ8hdpY uL1exLXjD9AQNqkye8ErkOeyTLbLJsB0uSlO+dJz+65KiBgVM7/5OtJB+X6OlYQFRC+VGJoLvMIAU 89TEgzTM2GIah7e0/WNRi0QcTL72MfvuO2DYaW3hFzqy3XwVv42nvsRZpXzjcO4EwsAlzFSZy2K9B Z+pwMx/u7PsCGEhU/XnQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d9TkC-0001si-ML; Sat, 13 May 2017 09:53:48 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d9TkA-0001pk-53 for linux-arm-kernel@bombadil.infradead.org; Sat, 13 May 2017 09:53:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding: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=3rJ7a8PBDrNwXBCneb4vjjcmX/YzyyTsbIPd9IgeZ84=; b=XaI5TeIN4MzDOgr3LGPfqVBGO IisJoM6pM0T+YNk0ZQRt6ix7TslGpJChgGluGest65lP6/NaSiZMYL7j1nafD8jPbq2M77aN1rL1c jkEoq7ZZW9Bwrd+QwkhHkF2rnu5J6yAoCY9tLzZQn7jrCjPpJMC9ZEPNGmPmPRnIAHDqSKfX8CyDk /V2++JGcKrcBwQMLN32f4TwXLf4ad6GfV+mjdHZB3ywhDmHyk4Dasls2DGgXlbkh2Rer266bgs75N LHKaiKXnV7sUJPYbjRhKvpdeOHwbAvm3ZMCOP2F9jaWp3u7d4W1MA967he/S1XU5nDRmocpzj8uEZ zmMICGvOg==; Received: from szxga01-in.huawei.com ([45.249.212.187]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d9Tk8-0007ri-9F for linux-arm-kernel@lists.infradead.org; Sat, 13 May 2017 09:53:45 +0000 Received: from 172.30.72.55 (EHLO DGGEML404-HUB.china.huawei.com) ([172.30.72.55]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AOL14086; Sat, 13 May 2017 17:53:04 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.91.84) by DGGEML404-HUB.china.huawei.com (10.3.17.39) with Microsoft SMTP Server id 14.3.301.0; Sat, 13 May 2017 17:51:17 +0800 From: shameer To: , , , , Subject: [RFC v1 6/7] iommu/arm-smmu-v3: Rearrange msi resv alloc functions Date: Sat, 13 May 2017 10:47:30 +0100 Message-ID: <20170513094731.3676-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170513094731.3676-1-shameerali.kolothum.thodi@huawei.com> References: <20170513094731.3676-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.91.84] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.5916D782.00E5, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b1ecc8ad0eb9e58693c849ebc2e7782d X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170513_055344_888212_466E041A X-CRM114-Status: GOOD ( 12.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, gabriele.paoloni@huawei.com, john.garry@huawei.com, linuxarm@huawei.com, shameer , linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, wangzhou1@hisilicon.com, guohanjun@huawei.com, linux-arm-kernel@lists.infradead.org, devel@acpica.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This moves the SW MSI reserve region allocation to probe fn. Signed-off-by: shameer --- drivers/iommu/arm-smmu-v3.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 770cc9e..e7a8a50 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -619,6 +619,9 @@ struct arm_smmu_device { /* IOMMU core code handle */ struct iommu_device iommu; + + /* MSI Reserve region */ + struct iommu_resv_region *msi_region; }; /* SMMU private data for each master */ @@ -1960,15 +1963,12 @@ static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) static void arm_smmu_get_resv_regions(struct device *dev, struct list_head *head) { - struct iommu_resv_region *region; - int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO; - - region = iommu_alloc_resv_region(MSI_IOVA_BASE, MSI_IOVA_LENGTH, - prot, IOMMU_RESV_SW_MSI); - if (!region) - return; + struct iommu_domain *domain = iommu_get_domain_for_dev(dev); + struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); + struct arm_smmu_device *smmu = smmu_domain->smmu; - list_add_tail(®ion->list, head); + if (smmu && smmu->msi_region) + list_add_tail(&smmu->msi_region->list, head); iommu_dma_get_resv_regions(dev, head); } @@ -1978,8 +1978,13 @@ static void arm_smmu_put_resv_regions(struct device *dev, { struct iommu_resv_region *entry, *next; - list_for_each_entry_safe(entry, next, head, list) + list_for_each_entry_safe(entry, next, head, list) { + if (entry->type == IOMMU_RESV_SW_MSI || + entry->type == IOMMU_RESV_MSI) + continue; + kfree(entry); + } } static struct iommu_ops arm_smmu_ops = { @@ -2711,6 +2716,17 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev, return ret; } +static struct iommu_resv_region *arm_smmu_alloc_msi_region( + struct arm_smmu_device *smmu) +{ + struct iommu_resv_region *region; + int prot = IOMMU_WRITE | IOMMU_NOEXEC | IOMMU_MMIO; + + region = iommu_alloc_resv_region(MSI_IOVA_BASE, MSI_IOVA_LENGTH, + prot, IOMMU_RESV_SW_MSI); + return region; +} + static int arm_smmu_device_probe(struct platform_device *pdev) { int irq, ret; @@ -2756,6 +2772,8 @@ static int arm_smmu_device_probe(struct platform_device *pdev) if (irq > 0) smmu->gerr_irq = irq; + smmu->msi_region = arm_smmu_alloc_msi_region(smmu); + if (dev->of_node) { ret = arm_smmu_device_dt_probe(pdev, smmu); } else {