Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2851897pxb; Mon, 17 Jan 2022 07:03:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzntJIswPA++DAXaNRISlTGPnQQXecb7aCH3U8l4i0aTjWL1N0kLn96XkI8whBsD5HDXTRu X-Received: by 2002:a17:902:b204:b0:149:d1ca:4e57 with SMTP id t4-20020a170902b20400b00149d1ca4e57mr23283795plr.126.1642431818056; Mon, 17 Jan 2022 07:03:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642431818; cv=none; d=google.com; s=arc-20160816; b=ahZ/vAZO/YbEx8XEMHyVR5bD3QSmv0A8Y5C13WjaKLq2ZBhNIMzvT9RTRjjwGZUGYh Rz3eBtu9JYfv99JUlB+1jiLY/fA7DtgycPt17Oq1TzdaQm2RvyzZUTlaLwElqKU9wJt4 QL5sb914KND6Uc6QtxilEZvHKH4b2FYqqowMuYqXHSsAb+nsmWrmq+0E8R8LTY/AAfFT m61AsX63m8RAJ0+bjUxZerz2Etwr9ga7G9y5Dgb4p15nNotCtwz+CPK2dCwk3L3DYd8/ wHvq4nIk5KzIKUzqEnQ7g/nmoT44cVc8eNX3qcXh5ZuMWXqVGW7Iikonw9+Lo8lSqINi wPBg== 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=NBXFsVWSud+erTMq4Aive9YNEBMF2rS5jWmf/9V9L1w=; b=UOgpfFnSgjKSlFcTj0bKcP19Js25r8J3aAJpSVlyzg+9mYxmrxiXXdt7l4ZpG5+sWH 2UXQAZuLI0gFCHd/mZ5cGrLmEpJ1MBG1SdLDNOHPoYHL8f2swVLkPBo6Yd0JNUFQB0Da DBvw6b/ru/aPbueixofkAGLnbMETftUo8oaSjinK3F2PeVXFfd/nqqYeBWHLMxpSpSD6 xWs/2Emei0RNZQ9pWsYGEo14KowbOPUiQ03KIRiQeCGmWUql1Q6zKXlaEDkhRAW3EyVG gOEHNrK6vhqjazWeOiFUogZUpP3nCNPaPQpUtTEUZ8zw2F7pnPlbzwPTwYtGyOUYv+yj iCsw== 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 q4si7432860pgk.848.2022.01.17.07.03.24; Mon, 17 Jan 2022 07:03:38 -0800 (PST) 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 S237264AbiAQHGS (ORCPT + 99 others); Mon, 17 Jan 2022 02:06:18 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:45546 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S235018AbiAQHGR (ORCPT ); Mon, 17 Jan 2022 02:06:17 -0500 X-UUID: effb381d9712497db536a0dff025128c-20220117 X-UUID: effb381d9712497db536a0dff025128c-20220117 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1837693972; Mon, 17 Jan 2022 15:06:14 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Mon, 17 Jan 2022 15:06:13 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 17 Jan 2022 15:06:11 +0800 From: Yong Wu To: Matthias Brugger , Hans Verkuil , Joerg Roedel , Rob Herring , Krzysztof Kozlowski , David Airlie , "Mauro Carvalho Chehab" CC: Evan Green , Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , Matthias Kaehlcke , , , , , , Daniel Vetter , Chun-Kuang Hu , Philipp Zabel , Tiffany Lin , "Dafna Hirschfeld" , Hsin-Yi Wang , Eizan Miyamoto , , Frank Wunderlich , , , , AngeloGioacchino Del Regno Subject: [PATCH v10 04/13] iommu/mediatek: Add probe_defer for smi-larb Date: Mon, 17 Jan 2022 15:05:01 +0800 Message-ID: <20220117070510.17642-5-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220117070510.17642-1-yong.wu@mediatek.com> References: <20220117070510.17642-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 Prepare for adding device_link. 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 consumers always are 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. device_is_bound may be more elegant here. but it is not allowed to EXPORT from https://lore.kernel.org/patchwork/patch/1334670/. Signed-off-by: Yong Wu Tested-by: Frank Wunderlich # BPI-R2/MT7623 Acked-by: Joerg Roedel Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 4 ++++ drivers/iommu/mtk_iommu_v1.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 77ae20ff9b35..5cff5bc556d4 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -850,6 +850,10 @@ static int mtk_iommu_probe(struct platform_device *pdev) of_node_put(larbnode); return -ENODEV; } + if (!plarbdev->dev.driver) { + of_node_put(larbnode); + return -EPROBE_DEFER; + } data->larb_imu[id].dev = &plarbdev->dev; component_match_add_release(dev, &match, release_of, diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 68bf02f87cfd..4089077256f4 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -606,6 +606,10 @@ static int mtk_iommu_probe(struct platform_device *pdev) of_node_put(larbnode); return -ENODEV; } + if (!plarbdev->dev.driver) { + of_node_put(larbnode); + return -EPROBE_DEFER; + } data->larb_imu[i].dev = &plarbdev->dev; component_match_add_release(dev, &match, release_of, -- 2.18.0