Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1733695ybe; Tue, 3 Sep 2019 02:40:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5g7icS6BezLvp/iluYXmO01jkK+cwxUoPl1B5wcqCo8Wt/Z6/ac8boUcrSd9eBfbGU17s X-Received: by 2002:a17:902:8f95:: with SMTP id z21mr34543085plo.42.1567503646299; Tue, 03 Sep 2019 02:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567503646; cv=none; d=google.com; s=arc-20160816; b=j8DcUWzQUqKH5wnqmNcoEkTQ/hzV5odIY5usU/G0XQHAuuCXwnXu7AH25qTaWelLqY F2Fawt/En/EauR1DBmzlclIq/hCpQKG+pTceb08bx0GTcHQaUEBfC9kAn0AW3daVWsXM L5eWOc1vDHn5M6CcZAs7Zw5d9NsY0qaNsTdMRFJydGxq7eakWdlQpDY0di0SrRCDow0C AB6HsDzLMZrorrh9DVfm91+AsawQu/IRruFEnfQQi6D7lW+23AHZus0D6YXzODOYPcty 4IvGLfN7W0iwhtyASuuxLvu1LmPRPK62OfKfql4e7ov/V6+ro4uc0JsaYuZ8kXH/LRwr seAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=qyOSdeYgt5y4EMGfUd/vYXMucODsrJ/rObdjNMmBLGs=; b=tekY79wtLlfI/7VkfG7Orr61HOK3QsCJkp86lsziFVxKR3zcNA0PjZ529K9DOkc7En bIeNPQu+OPRa7C6JjmZMVr9i+VD7hfFpgYFfQSZH1P1J+usKLkI2jQ+TbAdEfBTYtJ6V Rgi8WbhC25//Rko8kl36Qa5HAIf/lBJE48M/mZ63dA1Uxx4EbVb73lIBxEAHSezR8EVa qRRmWn9g0zbA2bmh+4VyZFjgbk2vBoDtcjemvDrNNGX/BWepGfBLW8slHJeuSGWtyNBq lDByJxEm9UZt0uAyGQ8Jfp8QYuTMyAovq9MOJzEigo3qEbuVqOrbkfey8nMQpfShUPUj QBPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id j23si13685129pgh.535.2019.09.03.02.40.31; Tue, 03 Sep 2019 02:40:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728792AbfICJib (ORCPT + 99 others); Tue, 3 Sep 2019 05:38:31 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:13210 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726946AbfICJia (ORCPT ); Tue, 3 Sep 2019 05:38:30 -0400 X-UUID: 877b6a1feab84943836ebf2104d493b2-20190903 X-UUID: 877b6a1feab84943836ebf2104d493b2-20190903 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 601285533; Tue, 03 Sep 2019 17:38:25 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 3 Sep 2019 17:38:25 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 3 Sep 2019 17:38:23 +0800 From: Yong Wu To: Matthias Brugger , Joerg Roedel , Rob Herring CC: Evan Green , Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , Nicolas Boichat , Matthias Kaehlcke , , , , Subject: [PATCH v3 02/14] iommu/mediatek: Add probe_defer for smi-larb Date: Tue, 3 Sep 2019 17:37:24 +0800 Message-ID: <1567503456-24725-3-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1567503456-24725-1-git-send-email-yong.wu@mediatek.com> References: <1567503456-24725-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org 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 --- drivers/iommu/mtk_iommu.c | 8 +++++++- drivers/iommu/mtk_iommu_v1.c | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 400066d..b138b94 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -660,6 +660,7 @@ static int mtk_iommu_probe(struct platform_device *pdev) for (i = 0; i < larb_nr; i++) { struct device_node *larbnode; struct platform_device *plarbdev; + bool larbdev_is_bound = false; u32 id; larbnode = of_parse_phandle(dev->of_node, "mediatek,larbs", i); @@ -676,7 +677,12 @@ static int mtk_iommu_probe(struct platform_device *pdev) id = i; plarbdev = of_find_device_by_node(larbnode); - if (!plarbdev) { + if (plarbdev) { + device_lock(&plarbdev->dev); + larbdev_is_bound = device_is_bound(&plarbdev->dev); + device_unlock(&plarbdev->dev); + } + if (!plarbdev || !larbdev_is_bound) { of_node_put(larbnode); return -EPROBE_DEFER; } diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 860926c..2034d72 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -601,10 +601,15 @@ static int mtk_iommu_probe(struct platform_device *pdev) plarbdev = of_find_device_by_node(larb_spec.np); if (!plarbdev) { + bool larbdev_is_bound; + plarbdev = of_platform_device_create( larb_spec.np, NULL, platform_bus_type.dev_root); - if (!plarbdev) { + device_lock(&plarbdev->dev); + larbdev_is_bound = device_is_bound(&plarbdev->dev); + device_unlock(&plarbdev->dev); + if (!plarbdev || !larbdev_is_bound) { of_node_put(larb_spec.np); return -EPROBE_DEFER; } -- 1.9.1