Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp269510pxb; Sat, 10 Apr 2021 02:13:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCSKds7JZeKhidLsLdEMMdEM6sUm6cdQ8KqcmKea1fcBmnrO0bQ85Zn9QC0t1eAWjHY0tV X-Received: by 2002:a17:902:b185:b029:e6:6d17:6ea with SMTP id s5-20020a170902b185b02900e66d1706eamr16859886plr.40.1618045987482; Sat, 10 Apr 2021 02:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618045987; cv=none; d=google.com; s=arc-20160816; b=yuDyvqCTsaPOA6BBdbFa4TaGJtQgwjyrrVK2ENEMK7JvewDxBcogCwuqFoskKTU6fH 5pelu+pvfvFYbh44FcEl2ol1GaKukQS9CeoqaTPiDeP9Q74Yl7R0EVHdRZ3AphdK2Sp4 BLOQCfVMq2RQqAGyQNlevfabkBjrdq4+49Gn3LZnw9wyzxl4gIeMlyIg1tol55zLdxey nrraLec1X7nMseob8i6MdGQrgBg5risV48YUyPc5YJuWvHx0saYfi6yE5KfEOPuQ8KBf Dtbrehx6fjCBKE+pagWdXmfGfk3JeQvbRVAED+/bB8mCjhRKbHrUHDXhXdBC+qyIpDf9 OR5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=QXz47aMmKvgPaarxvPQauQ6HKGrgBYs6Cz795uNLunA=; b=GdrtD5+24MEZsS92j84t73zeRsMBXyBE0qPXSdMUvEBMSwAbNLLQ+r3tIqmJ2lcGZ9 oC4J3e5/OO3XQ0TxTPmnOxNBVRQkhItp7ebmhAAucP2fR6n5vRiXLZfuVq4ZaxT5Sd3R ypy1NkKjSx+62j6X0YFGYNixxegGoTt6NUkNbuHZ+qoNuBQcFSp/0fwP1ddY5aiWsZ1W aAMmGsZrZAbkEaY/8hwB3GxqEcqxCttDqHMrgaUmmg1aaMcfh1xXE3Rt2XF+JNYEEBSJ NyW7GhFAt87QEQeptPoubb/bffTKZm9u/4i68aZKcfCE7S6RL7fbLGRddafshg9SvJ2B 5unQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h11si7214991plk.312.2021.04.10.02.12.55; Sat, 10 Apr 2021 02:13:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234386AbhDJJMb (ORCPT + 99 others); Sat, 10 Apr 2021 05:12:31 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:33533 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229591AbhDJJMa (ORCPT ); Sat, 10 Apr 2021 05:12:30 -0400 X-UUID: 36954cfc71454c1993b8acfecc617f9f-20210410 X-UUID: 36954cfc71454c1993b8acfecc617f9f-20210410 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1650693383; Sat, 10 Apr 2021 17:12:12 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 10 Apr 2021 17:12:11 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 10 Apr 2021 17:12:04 +0800 From: Yong Wu To: Matthias Brugger , Joerg Roedel , Rob Herring , Krzysztof Kozlowski CC: Evan Green , Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , Nicolas Boichat , Matthias Kaehlcke , , , , , , Subject: [PATCH v5 02/16] iommu/mediatek: Add probe_defer for smi-larb Date: Sat, 10 Apr 2021 17:11:14 +0800 Message-ID: <20210410091128.31823-3-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210410091128.31823-1-yong.wu@mediatek.com> References: <20210410091128.31823-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The iommu consumer should use device_link to connect with the smi-larb(supplier). then the smi-larb should run before the iommu consumer. Here we delay the iommu driver until the smi driver is ready, then all the iommu consumer always is after the smi driver. When there is no this patch, if some consumer drivers run before smi-larb, the supplier link_status is DL_DEV_NO_DRIVER(0) in the device_link_add, then device_links_driver_bound will use WARN_ON to complain that the link_status of supplier is not right. This is a preparing patch for adding device_link. Signed-off-by: Yong Wu --- To Matthias, In v2, You suggested use device_is_bound here. But from [1], this interface is not allowed to be EXPORT. It will affect this driver built as module. thus I still use dev.driver to check here. [1] https://lore.kernel.org/patchwork/patch/1334670/ --- drivers/iommu/mtk_iommu.c | 2 +- drivers/iommu/mtk_iommu_v1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 6ecc007f07cd..7a7b8260d308 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -862,7 +862,7 @@ static int mtk_iommu_probe(struct platform_device *pdev) id = i; plarbdev = of_find_device_by_node(larbnode); - if (!plarbdev) { + if (!plarbdev || !plarbdev->dev.driver) { of_node_put(larbnode); return -EPROBE_DEFER; } diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 82ddfe9170d4..a82466e4046e 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -597,7 +597,7 @@ static int mtk_iommu_probe(struct platform_device *pdev) plarbdev = of_platform_device_create( larb_spec.np, NULL, platform_bus_type.dev_root); - if (!plarbdev) { + if (!plarbdev || !plarbdev->dev.driver) { of_node_put(larb_spec.np); return -EPROBE_DEFER; } -- 2.18.0