From patchwork Tue Jul 21 07:30:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 6832571 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2EA0A9F1D4 for ; Tue, 21 Jul 2015 07:34:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4DC4220490 for ; Tue, 21 Jul 2015 07:34:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79A3020138 for ; Tue, 21 Jul 2015 07:34:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHS2h-0005HL-9p; Tue, 21 Jul 2015 07:32:47 +0000 Received: from szxga03-in.huawei.com ([119.145.14.66]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHS2R-0004wI-Ae for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2015 07:32:32 +0000 Received: from 172.24.1.49 (EHLO szxeml427-hub.china.huawei.com) ([172.24.1.49]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BJQ14554; Tue, 21 Jul 2015 15:31:27 +0800 (CST) Received: from localhost (10.177.23.164) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.158.1; Tue, 21 Jul 2015 15:31:18 +0800 From: Zhen Lei To: Will Deacon , Joerg Roedel , linux-arm-kernel , iommu Subject: [PATCH v3 4/5] iommu/arm-smmu: add support for non-pci devices Date: Tue, 21 Jul 2015 15:30:32 +0800 Message-ID: <1437463833-16112-5-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1437463833-16112-1-git-send-email-thunder.leizhen@huawei.com> References: <1437463833-16112-1-git-send-email-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.55ADF550.00AE, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 7fb295b2834bd1eef1d57c7a0fc3a81f X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150721_003231_716174_94E92CBB X-CRM114-Status: GOOD ( 15.25 ) X-Spam-Score: -5.4 (-----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xinwei Hu , Zhen Lei , Zefan Li , Robin Murphy , Tianhong Ding Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch support a master with multiple stream IDs, but doesn't support a master behinds more than one SMMUs. Reviewed-by: Robin Murphy Signed-off-by: Zhen Lei --- drivers/iommu/arm-smmu-v3.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) -- 1.8.0 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 216c9d4..129ff36 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -1965,9 +1966,36 @@ static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) return -EINVAL; } - /* We only support PCI, for now */ if (!dev_is_pci(dev)) { - return -ENODEV; + struct iommu_group *group; + + if (args->args_count != 1) { + dev_err(dev, + "only support #iommu-cells = <1>, please check node: %s\n", + dev_name(smmu->dev)); + return -ENODEV; + } + + group = iommu_group_get(dev); + if (!group) { + group = iommu_group_alloc(); + if (IS_ERR(group)) { + dev_err(dev, "failed to allocate IOMMU group\n"); + return PTR_ERR(group); + } + + ret = iommu_group_add_device(group, dev); + if (ret) { + iommu_group_put(group); + dev_err(dev, "failed to add device into IOMMU group\n"); + return ret; + } + } + iommu_group_put(group); + + ret = __arm_smmu_add_device(dev, args->args[0]); + if (ret) + return ret; } else { struct device *root; struct pci_dev *pdev = NULL; @@ -2762,6 +2790,14 @@ static int __init arm_smmu_init(void) if (ret) return ret; + if (!iommu_present(&platform_bus_type)) + bus_set_iommu(&platform_bus_type, &arm_smmu_ops); + +#ifdef CONFIG_ARM_AMBA + if (!iommu_present(&amba_bustype)) + bus_set_iommu(&amba_bustype, &arm_smmu_ops); +#endif + return bus_set_iommu(&pci_bus_type, &arm_smmu_ops); }