From patchwork Thu Apr 9 14:09:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 11481817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5339381 for ; Thu, 9 Apr 2020 14:09:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2DAE220730 for ; Thu, 9 Apr 2020 14:09:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KYw96A3y"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Ss/rI+6N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2DAE220730 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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=AuRy3YD7RgMqMpJmGYHuCTRVtsruxktJUb0b8mX6r4g=; b=KYw96A3yNXIjQdfJh7MvJysLNn 0Tlp9vvo702kK4nqdajP5AQTTtWUQCJEZ43wEYZ1UiHA8sCWfa5ihR/5595qPmFKkKNYsuhVG8QE/ p3iecKyYbtbbz4OKUTc2vMtuVGVR8pLZVcGNB/Tf2P33aV1IfhCnScHvR5StNMcfB8GyRKVwd/c9G Kgp82PKrFL/YOaYHlPs3ws4QD7rddf+iynWHaOnr2sY1aET78Wdl5wuI0uV/6Tqm67gRwVnmrrvxG JDFevEzTo5pcNbT/vSfo/ye5VHsvlrMr2pBuwI307OIHFs8KyMnCifyC697qvBzG02vsY4JOgG5zZ HLDspWJg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jMXsH-0007JH-KZ; Thu, 09 Apr 2020 14:09:45 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jMXsE-0007Hi-8C for linux-mediatek@lists.infradead.org; Thu, 09 Apr 2020 14:09:44 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200409140940euoutp021d44c030f707780d449629844ca29215~ELAe3s-NJ0505905059euoutp029 for ; Thu, 9 Apr 2020 14:09:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200409140940euoutp021d44c030f707780d449629844ca29215~ELAe3s-NJ0505905059euoutp029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586441380; bh=uOPOsjDBeoOPh/LWEsOhJf6fcYgFmHlbGZ8c2IaZow8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ss/rI+6NlyU3oEvmTa4XmrEG+8okyYAoMJCMGnHj7bBPUJbItptqJs7eL+ZclycFW qNPPpcbbyJYm/6tUzbTUgmDIz5eTJygGGL2Gfhpoyfk+6OJ3taOZAJPzf4Fn6iQbjD TDz84m2jcnqsPQVV0gax9Vu6eK3ZtTiOWkF5NIeA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200409140939eucas1p1fd05eadd1ffe536c1416de7d8ab426ea~ELAedSvQg1667416674eucas1p18; Thu, 9 Apr 2020 14:09:39 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id AC.CD.60698.3AC2F8E5; Thu, 9 Apr 2020 15:09:39 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200409140939eucas1p190daac74c0d5dda4627314c49c1a5b50~ELAdsr7MZ1667916679eucas1p1_; Thu, 9 Apr 2020 14:09:39 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200409140939eusmtrp1ca40318d7b5d19361604d60509ea60fa~ELAdrogZI2358223582eusmtrp1R; Thu, 9 Apr 2020 14:09:39 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-16-5e8f2ca3fdfe Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A6.A6.07950.2AC2F8E5; Thu, 9 Apr 2020 15:09:39 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200409140938eusmtip13f3b3d64a3bf6142809d9900bb2f4a50~ELAcr5K9K1665516655eusmtip1O; Thu, 9 Apr 2020 14:09:38 +0000 (GMT) From: Marek Szyprowski To: Joerg Roedel Subject: [PATCH] iommu/exynos: Rework intialization Date: Thu, 9 Apr 2020 16:09:28 +0200 Message-Id: <20200409140928.1403-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <40af831b-d00c-0cf9-0a06-e60c048a9ab8@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0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eucas1p190daac74c0d5dda4627314c49c1a5b50 X-Msg-Generator: CA X-RootMTR: 20200409140939eucas1p190daac74c0d5dda4627314c49c1a5b50 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200409140939eucas1p190daac74c0d5dda4627314c49c1a5b50 References: <40af831b-d00c-0cf9-0a06-e60c048a9ab8@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200409_070942_496226_E84AB111 X-CRM114-Status: GOOD ( 19.90 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.12 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Bjorn Andersson , linux-tegra@vger.kernel.org, Thierry Reding , Will Deacon , Marek Szyprowski , Jean-Philippe Brucker , linux-samsung-soc@vger.kernel.org, Rob Clark , Krzysztof Kozlowski , Jonathan Hunter , linux-rockchip@lists.infradead.org, Andy Gross , Joerg Roedel , linux-s390@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, Matthias Brugger , virtualization@lists.linux-foundation.org, Gerald Schaefer , David Woodhouse , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Kukjin Kim , Robin Murphy , Lu Baolu MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Fix initialization after driver conversion to probe_device()/release_device(). Prepared on top of: https://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git/log/?h=iommu-probe-device Signed-off-by: Marek Szyprowski --- drivers/iommu/exynos-iommu.c | 80 +++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index f865c90..53c784f 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -565,6 +565,7 @@ static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data, } static const struct iommu_ops exynos_iommu_ops; +static int exynos_iommu_initialize_owner(struct device *sysmmu); static int exynos_sysmmu_probe(struct platform_device *pdev) { @@ -573,6 +574,8 @@ static int exynos_sysmmu_probe(struct platform_device *pdev) struct sysmmu_drvdata *data; struct resource *res; + dev_info(dev, "%s %d\n", __func__, __LINE__); + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -649,6 +652,8 @@ static int exynos_sysmmu_probe(struct platform_device *pdev) pm_runtime_enable(dev); + exynos_iommu_initialize_owner(dev); + return 0; } @@ -1225,24 +1230,8 @@ static phys_addr_t exynos_iommu_iova_to_phys(struct iommu_domain *iommu_domain, static struct iommu_device *exynos_iommu_probe_device(struct device *dev) { - struct exynos_iommu_owner *owner = dev->archdata.iommu; - struct sysmmu_drvdata *data; - - if (!has_sysmmu(dev)) - return ERR_PTR(-ENODEV); - - list_for_each_entry(data, &owner->controllers, owner_node) { - /* - * SYSMMU will be runtime activated via device link - * (dependency) to its master device, so there are no - * direct calls to pm_runtime_get/put in this driver. - */ - data->link = device_link_add(dev, data->sysmmu, - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME); - } - - return &owner->iommu; + /* this is called too early on ARM 32bit to do anything usefull */ + return ERR_PTR(-ENODEV); } static void exynos_iommu_release_device(struct device *dev) @@ -1268,7 +1257,8 @@ static void exynos_iommu_release_device(struct device *dev) device_link_del(data->link); } -static int exynos_iommu_device_init(struct exynos_iommu_owner *owner) +static int exynos_iommu_device_init(struct device *dev, + struct exynos_iommu_owner *owner) { static u32 counter = 0; int ret; @@ -1287,6 +1277,12 @@ static int exynos_iommu_device_init(struct exynos_iommu_owner *owner) iommu_device_set_ops(&owner->iommu, &exynos_iommu_ops); + /* + * the above iommu_device_set_ops is not enough, initializing fwspec + * is also required + */ + iommu_fwspec_init(dev, &dev->of_node->fwnode, &exynos_iommu_ops); + return 0; } @@ -1308,7 +1304,7 @@ static int exynos_owner_init(struct device *dev) if (!owner) return -ENOMEM; - ret = exynos_iommu_device_init(owner); + ret = exynos_iommu_device_init(dev, owner); if (ret) goto out_free_owner; @@ -1330,34 +1326,51 @@ static int exynos_owner_init(struct device *dev) return ret; } -static int exynos_iommu_of_xlate(struct device *dev, - struct of_phandle_args *spec) +static int exynos_iommu_dev_match_owner(struct device *dev, const void *data) +{ + const struct device *sysmmu = data; + struct device_node *np; + int idx = 0; + + do { + np = of_parse_phandle(dev->of_node, "iommus", idx++); + if (np == sysmmu->of_node) + return true; + } while (np); + + return false; +} + +static int exynos_iommu_initialize_owner(struct device *sysmmu) { - struct platform_device *sysmmu = of_find_device_by_node(spec->np); - struct sysmmu_drvdata *data, *entry; + struct sysmmu_drvdata *data = dev_get_drvdata(sysmmu); struct exynos_iommu_owner *owner; + struct device *dev; int ret; - if (!sysmmu) + dev = bus_find_device(&platform_bus_type, NULL, sysmmu, + exynos_iommu_dev_match_owner); + if (!dev) return -ENODEV; - data = platform_get_drvdata(sysmmu); - if (!data) - return -ENODEV; + dev_info(sysmmu, "found master device %s\n", dev_name(dev)); ret = exynos_owner_init(dev); if (ret) return ret; owner = dev->archdata.iommu; - - list_for_each_entry(entry, &owner->controllers, owner_node) - if (entry == data) - return 0; - list_add_tail(&data->owner_node, &owner->controllers); data->master = dev; + /* + * SYSMMU will be runtime activated via device link + * (dependency) to its master device, so there are no + * direct calls to pm_runtime_get/put in this driver. + */ + data->link = device_link_add(dev, data->sysmmu, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME); return 0; } @@ -1373,7 +1386,6 @@ static int exynos_iommu_of_xlate(struct device *dev, .probe_device = exynos_iommu_probe_device, .release_device = exynos_iommu_release_device, .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE, - .of_xlate = exynos_iommu_of_xlate, }; static int __init exynos_iommu_init(void)