From patchwork Thu Oct 15 08:30:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 7403951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 88CCCBEEA4 for ; Thu, 15 Oct 2015 08:39:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA8A120451 for ; Thu, 15 Oct 2015 08:39:46 +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 C1D7E203AA for ; Thu, 15 Oct 2015 08:39:45 +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 1Zme33-000524-UK; Thu, 15 Oct 2015 08:38:05 +0000 Received: from szxga01-in.huawei.com ([58.251.152.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zme2z-0004nD-Fn for linux-arm-kernel@lists.infradead.org; Thu, 15 Oct 2015 08:38:03 +0000 Received: from 172.24.1.51 (EHLO szxeml433-hub.china.huawei.com) ([172.24.1.51]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CWU18554; Thu, 15 Oct 2015 16:36:25 +0800 (CST) Received: from localhost (10.177.23.164) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.235.1; Thu, 15 Oct 2015 16:36:17 +0800 From: Zhen Lei To: Catalin Marinas , Will Deacon , Joerg Roedel , linux-arm-kernel , iommu , Robin Murphy , Laurent Pinchart , linux-kernel Subject: [PATCH v4 4/5] iommu/arm-smmu: to backward compatible with probe non-deferral Date: Thu, 15 Oct 2015 16:30:46 +0800 Message-ID: <1444897847-18040-5-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1444897847-18040-1-git-send-email-thunder.leizhen@huawei.com> References: <1444897847-18040-1-git-send-email-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151015_013802_540083_F0A3B203 X-CRM114-Status: GOOD ( 14.32 ) X-Spam-Score: -4.2 (----) 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 , Hanjun Guo , 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 eliminate the strong dependence on Laurent's series(to support probe deferral). That means, no matter whether Laurent's series upstreamed or not, the smmu-v3 driver will always work well. Signed-off-by: Zhen Lei --- drivers/iommu/arm-smmu-v3.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.5.0 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 021a846..66052e9 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1857,6 +1857,12 @@ static int arm_smmu_add_device(struct device *dev) struct pci_dev *pdev; struct device *root; + if (dev->archdata.iommu == ERR_PTR(-EPROBE_DEFER)) { + dev->archdata.iommu = NULL; + + return of_iommu_configure(dev, dev->of_node) ? 0 : -ENODEV; + } + /* only support pci devices hotplug */ if (!dev_is_pci(dev)) return -ENODEV; @@ -1930,6 +1936,11 @@ static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) return -EINVAL; smmu = platform_get_drvdata(pdev); + if (!smmu) { + dev->archdata.iommu = ERR_PTR(-EPROBE_DEFER); + + return -EPROBE_DEFER; + } if (!dev->archdata.iommu) dev->archdata.iommu = smmu; @@ -2768,7 +2779,6 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev) /* Record our private device structure */ platform_set_drvdata(pdev, smmu); - of_iommu_set_ops(smmu->dev->of_node, &arm_smmu_ops); /* Reset the device */ ret = arm_smmu_device_reset(smmu); @@ -2840,7 +2850,13 @@ static void __exit arm_smmu_exit(void) subsys_initcall(arm_smmu_init); module_exit(arm_smmu_exit); -IOMMU_OF_DECLARE(arm_smmu_v3, "arm,smmu-v3", NULL); +static int arm_smmu_of_iommu_init(struct device_node *np) +{ + of_iommu_set_ops(np, &arm_smmu_ops); + + return 0; +} +IOMMU_OF_DECLARE(arm_smmu_v3, "arm,smmu-v3", arm_smmu_of_iommu_init); MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations"); MODULE_AUTHOR("Will Deacon ");