From patchwork Mon Jul 25 08:39:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 9245421 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 652A9607FD for ; Mon, 25 Jul 2016 08:41:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 546B520587 for ; Mon, 25 Jul 2016 08:41:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 483D12624D; Mon, 25 Jul 2016 08:41:54 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable 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 D62BB20587 for ; Mon, 25 Jul 2016 08:41:53 +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 1bRbQz-0006Ak-7R; Mon, 25 Jul 2016 08:40:21 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bRbQv-0004tO-CT; Mon, 25 Jul 2016 08:40:17 +0000 Received: by mail-wm0-x243.google.com with SMTP id i5so15682244wmg.2; Mon, 25 Jul 2016 01:39:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=D7SuW9uXPET+fG15u21xqkV5R+rREvsfuF4AJNhtIUU=; b=LugXbrUmHu1dIl692i+j2fcfaeZBsyuu9VqCy7FlK0nvhmI76OcwZP6OobpDxik+8A Cn2KcTqo27/TNts+XCO05KbxCHH0AlzcWIoWPzgTzFDoQG7iuX+JQb/zpdMF+M3/Zlw1 WK4PMbgxN5CjGQa0QoKeUR+17gYZelHvfOholEKsTOQJmyMSK4KeI7J55JGQsDheqod6 F7Q69faAW0s+dtrjYIcf+HM0HjhUE2+QkaScuzyaaEin5CdKj8fE6E81qMsCS2OXMLT2 qAMPHjQhRgTBVBJEppTPu20KgPpf51lWBTCu6mc1YfOnFMRUtsxSi19UgaEQnqsMBp2z 9JfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=D7SuW9uXPET+fG15u21xqkV5R+rREvsfuF4AJNhtIUU=; b=B/v9m9qQ7yNYTtuOX+chW3jGj4C37ynAa1zFIbFI2NLwKR9zjYqJA8bEy+vDHSWnT1 8wzkPUwxj1BhkM8Lz7pA0OanASxwG0pv1UKXg9E3RAbRYTD80weTYoFjpCES9yK5aMr5 6tw/CE5h/mbrjNOB6yJCCms/lEy+CnukdCpCZEo6vWpMplrJsV/eJwcPPBlvg+SUOyIU 4sDqbBgGVAKTTEzvd7DIqgBnEEAjLVjE5hThUpLRn6leYDUByKttxXe/98l3TmRefkPs Ku6qcXu/MSdomP/qcVIsobVGN7KZR0y7yqdba0yJq+febS51pfjNw1+LxvxctUWUpC+F i2gw== X-Gm-Message-State: ALyK8tLCrprgqF/RK28ihJn0eUrSPIJZe0VW7euDFW6JLX+L9I8PqwMGCWAW0pUAmOehOQ== X-Received: by 10.28.113.151 with SMTP id d23mr40649906wmi.89.1469435995834; Mon, 25 Jul 2016 01:39:55 -0700 (PDT) Received: from linux-gy6r.site (129.red-83-39-44.dynamicip.rima-tde.net. [83.39.44.129]) by smtp.gmail.com with ESMTPSA id d8sm26242961wmi.0.2016.07.25.01.39.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jul 2016 01:39:54 -0700 (PDT) Subject: Re: [PATCH 1/3] memory: mediatek: Add a new interface mtk_smi_larb_is_ready To: Yong Wu , David Airlie , Philipp Zabel , Hans Verkuil References: <1468983721-3627-1-git-send-email-yong.wu@mediatek.com> From: Matthias Brugger Message-ID: Date: Mon, 25 Jul 2016 10:39:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <1468983721-3627-1-git-send-email-yong.wu@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160725_014017_583941_15ED4618 X-CRM114-Status: GOOD ( 18.58 ) X-BeenThere: linux-arm-kernel@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 , Joerg Roedel , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, CK Hu , Tomasz Figa , Daniel Kurtz , Bibby Hsieh , Honghui Zhang , YT Shen , linux-mediatek@lists.infradead.org, Tiffany Lin , linux-arm-kernel@lists.infradead.org, Lucas Stach Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 20/07/16 05:01, Yong Wu wrote: > 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. > Can't we just skip the functions in the probe and call bus_set_iommu only if we were able to bind all components? Something like this: } static int mtk_iommu_remove(struct platform_device *pdev) Regards, Matthias diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index c3043d8..0bef49b 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -649,10 +649,14 @@ static int mtk_iommu_probe(struct platform_device *pdev) if (ret) return ret; + ret = component_master_add_with_match(dev, &mtk_iommu_com_ops, match); + if (ret) + return ret; + if (!iommu_present(&platform_bus_type)) bus_set_iommu(&platform_bus_type, &mtk_iommu_ops); - return component_master_add_with_match(dev, &mtk_iommu_com_ops, match); + return ret;