From patchwork Wed Jul 20 03:01:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WW9uZyBXdSAo5ZC05YuHKQ==?= X-Patchwork-Id: 9238699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DEE17602F0 for ; Wed, 20 Jul 2016 03:02:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEF66277D9 for ; Wed, 20 Jul 2016 03:02:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3CF12787C; Wed, 20 Jul 2016 03:02:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 3D23726B4A for ; Wed, 20 Jul 2016 03:02:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bPhmS-0004Sn-12; Wed, 20 Jul 2016 03:02:40 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bPhmP-0004LM-1g; Wed, 20 Jul 2016 03:02:38 +0000 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1441271538; Wed, 20 Jul 2016 11:02:10 +0800 Received: from mhfsdcap03.mhfswrd (10.17.3.153) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.266.1; Wed, 20 Jul 2016 11:02:09 +0800 From: Yong Wu To: Matthias Brugger , David Airlie , Philipp Zabel , Hans Verkuil Subject: [PATCH 1/3] memory: mediatek: Add a new interface mtk_smi_larb_is_ready Date: Wed, 20 Jul 2016 11:01:59 +0800 Message-ID: <1468983721-3627-1-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160719_200237_281419_D388AFB0 X-CRM114-Status: GOOD ( 13.02 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: youlin.pei@mediatek.com, srv_heupstream@mediatek.com, Arnd Bergmann , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, CK Hu , Tomasz Figa , Daniel Kurtz , Yong Wu , Bibby Hsieh , Honghui Zhang , YT Shen , linux-mediatek@lists.infradead.org, Tiffany Lin , linux-arm-kernel@lists.infradead.org, Lucas Stach Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the iommu consumer always call iommu_present to get whether the iommu is ready. But in MTK IOMMU, this function can't indicate this. The IOMMU call bus_set_iommu->mtk_iommu_add_device-> mtk_iommu_attach_device to parse the iommu data, then it's able to transfer "struct mtk_smi_iommu" to SMI-LARB, and the iommu uses the larbs as compoents, the iommu will finish its probe until all the larbs probe done. If the iommu consumer(like DRM) begin to probe after the time of calling bus_set_iommu and before the time of SMI probe finish, it will hang like this: [ 7.832359] Call trace: [ 7.834778] [] mtk_smi_larb_get+0x24/0xa8 [ 7.840300] [] mtk_drm_crtc_enable+0x6c/0x450 Because the larb->mmu is NULL at that time. In order to avoid this issue, we add a new interface (mtk_smi_larb_is_ready) for checking whether the IOMMU and SMI have finished their probe. If it return false, the iommu consumer should probe-defer for the IOMMU and SMI. Signed-off-by: Yong Wu --- Adding this interface is for avoid adjust the sequence of power domain probe[1]. This patch-set is based on next-20160719. And patch[1/3] base on [2], patch[3/3] base on [3], both are in the pull tree. [1]:http://lists.infradead.org/pipermail/linux-mediatek/2016-July/006189.html [2]:https://patchwork.kernel.org/patch/9164067/ [3]:http://www.spinics.net/lists/arm-kernel/msg517840.html --- drivers/memory/mtk-smi.c | 8 ++++++++ include/soc/mediatek/smi.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index 4afbc41..3e58cbb7 100644 --- a/drivers/memory/mtk-smi.c +++ b/drivers/memory/mtk-smi.c @@ -141,6 +141,14 @@ void mtk_smi_larb_put(struct device *larbdev) } EXPORT_SYMBOL_GPL(mtk_smi_larb_put); +bool mtk_smi_larb_is_ready(struct device *larbdev) +{ + struct mtk_smi_larb *larb = dev_get_drvdata(larbdev); + + return larb && larb->mmu; +} +EXPORT_SYMBOL_GPL(mtk_smi_larb_is_ready); + static int mtk_smi_larb_bind(struct device *dev, struct device *master, void *data) { diff --git a/include/soc/mediatek/smi.h b/include/soc/mediatek/smi.h index 8893c5e..f0690e0 100644 --- a/include/soc/mediatek/smi.h +++ b/include/soc/mediatek/smi.h @@ -33,6 +33,9 @@ struct mtk_smi_iommu { struct mtk_smi_larb_iommu larb_imu[MTK_LARB_NR_MAX]; }; +/* Whether SMI-larb has probe done. */ +bool mtk_smi_larb_is_ready(struct device *larbdev); + /* * mtk_smi_larb_get: Enable the power domain and clocks for this local arbiter. * It also initialize some basic setting(like iommu). @@ -46,6 +49,11 @@ void mtk_smi_larb_put(struct device *larbdev); #else +static inline bool mtk_smi_larb_is_ready(struct device *larbdev) +{ + return false; +} + static inline int mtk_smi_larb_get(struct device *larbdev) { return 0;