Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1865680img; Wed, 27 Feb 2019 06:48:00 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaozn/PccSqN+uL9nMDCkZx9BfTXuWvcD77F/7u6/jgMlf3gZ5+PNq1dBWcH3seabZGHMAS X-Received: by 2002:a62:6dc7:: with SMTP id i190mr2012866pfc.166.1551278880393; Wed, 27 Feb 2019 06:48:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551278880; cv=none; d=google.com; s=arc-20160816; b=ajAsM7/WBH7Z+kpysa2iTpTiuKFj0iTsP7EjMLCzdcxOVki3wVKb2XwyqI4FzGASUu pddoBGCs1aKcZi4lqddP37UuWkRbmHahhl0AvjJNzIIlKMHd38HuU1S3yuKQ3WTjSrVe lPQfqQ4queazixakQfprre2SW7uxx/UBXthARZ16lPwUJFhRVTggneLN3DUNtc8/yRaw fB8haKQ/q1JaC4ZgK3kmE8rChUxb/G6oI7tpzxSs4xiVb2nOajvBB+jIppsXLhmLlhVS mIg5uUX+S8o5wFtiY1zp+9hcgUO3hvgBbdCb4bNbnH7QoNcz0CoIhFuBFMlk+dU2gdUl gFhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=wHU0tgbeU1ERcQhfAwgYKqX86vYJW7Ox7s8ZqiBrPP4=; b=TAeq8xqgEuthLD8WM0fIp9cU4YvlROXx11TjyVW5k05sv1qQ4olAa1fA1dRbazFDZX ulI/ZtnLtYCOEBbKQ/nGkqT6bVPpzfdTqo2M0pDXII+ZCEoPlbIDC2SW3nIcBI/tbegp z+QQ4b+K6hI9UZC8FWDYUfPK/LmwsJpCgToHY3KacDzpdYtkTPcgPGntKvOSEN2KFkjN 0y6j6ftAcsbwE3zh5iSaw6/aPHSOEJqQu5OcB2w43Rkngzvq7VN5FCaTmomWFTl8jRg/ cGP2q9DJ++X+SsXpu/eLFk4RJ3Eh5K2c9q4Yg6cXtwzNyBne/cn4cOr5EWvXed/+FdQA T/hw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g75si16109145pfg.49.2019.02.27.06.47.44; Wed, 27 Feb 2019 06:48:00 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730526AbfB0Oez (ORCPT + 99 others); Wed, 27 Feb 2019 09:34:55 -0500 Received: from mailgw02.mediatek.com ([1.203.163.81]:46123 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726866AbfB0Oez (ORCPT ); Wed, 27 Feb 2019 09:34:55 -0500 X-UUID: e51b820e1080497487b9872f867f8a00-20190227 X-UUID: e51b820e1080497487b9872f867f8a00-20190227 Received: from mtkcas34.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1484565171; Wed, 27 Feb 2019 22:34:45 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 27 Feb 2019 22:34:44 +0800 Received: from [10.17.3.153] (172.27.4.253) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 27 Feb 2019 22:34:43 +0800 Message-ID: <1551278083.17917.53.camel@mhfsdcap03> Subject: Re: [PATCH 04/13] iommu/mediatek: Add device_link between the consumer and the larb devices From: Yong Wu To: Evan Green CC: , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Nicolas Boichat , Arnd Bergmann , , Greg Kroah-Hartman , Joerg Roedel , Will Deacon , LKML , Tomasz Figa , , Rob Herring , , Matthias Brugger , , Robin Murphy , Date: Wed, 27 Feb 2019 22:34:43 +0800 In-Reply-To: References: <1546318276-18993-1-git-send-email-yong.wu@mediatek.com> <1546318276-18993-5-git-send-email-yong.wu@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-02-25 at 15:54 -0800, Evan Green wrote: > On Mon, Dec 31, 2018 at 8:52 PM Yong Wu wrote: > > > > MediaTek IOMMU don't have its power-domain. all the consumer connect > > with smi-larb, then connect with smi-common. > > > > M4U > > | > > smi-common > > | > > ------------- > > | | ... > > | | > > larb1 larb2 > > | | > > vdec venc > > > > When the consumer works, it should enable the smi-larb's power which > > also need enable the smi-common's power firstly. > > > > Thus, First of all, use the device link connect the consumer and the > > smi-larbs. then add device link between the smi-larb and smi-common. > > > > This patch adds device_link between the consumer and the larbs. > > > > Suggested-by: Tomasz Figa > > Signed-off-by: Yong Wu > > --- > > drivers/iommu/mtk_iommu.c | 15 +++++++++++++-- > > drivers/iommu/mtk_iommu_v1.c | 14 ++++++++++++-- > > 2 files changed, 25 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > > index 202e41b..735ae8d 100644 > > --- a/drivers/iommu/mtk_iommu.c > > +++ b/drivers/iommu/mtk_iommu.c > > @@ -247,6 +247,7 @@ static void mtk_iommu_config(struct mtk_iommu_data *data, > > struct mtk_smi_larb_iommu *larb_mmu; > > unsigned int larbid, portid; > > struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); > > + struct device_link *link; > > int i; > > > > for (i = 0; i < fwspec->num_ids; ++i) { > > @@ -257,10 +258,20 @@ static void mtk_iommu_config(struct mtk_iommu_data *data, > > dev_dbg(dev, "%s iommu port: %d\n", > > enable ? "enable" : "disable", portid); > > > > - if (enable) > > + if (enable) { > > larb_mmu->mmu |= MTK_SMI_MMU_EN(portid); > > - else > > + /* Link the consumer with the larb device(supplier) */ > > + link = device_link_add(dev, larb_mmu->dev, > > + DL_FLAG_PM_RUNTIME | > > + DL_FLAG_AUTOREMOVE_CONSUMER); > > + if (!link) { > > + dev_err(dev, "Unable to link %s\n", > > + dev_name(larb_mmu->dev)); > > + return; > > The return is a little odd here, given that you don't return an error > and this function doesn't do anything else. If it's non-fatal that > this link didn't get set up, then remove the return. If it is fatal, > then return an error code. I will remove the "return". Thanks. > > > + } > > + } else { > > larb_mmu->mmu &= ~MTK_SMI_MMU_EN(portid); > > + } > > } > > } > > > > diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c > > index 9386aee..022bad9 100644 > > --- a/drivers/iommu/mtk_iommu_v1.c > > +++ b/drivers/iommu/mtk_iommu_v1.c > > @@ -201,6 +201,7 @@ static void mtk_iommu_config(struct mtk_iommu_data *data, > > struct mtk_smi_larb_iommu *larb_mmu; > > unsigned int larbid, portid; > > struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); > > + struct device_link *link; > > int i; > > > > for (i = 0; i < fwspec->num_ids; ++i) { > > @@ -211,10 +212,19 @@ static void mtk_iommu_config(struct mtk_iommu_data *data, > > dev_dbg(dev, "%s iommu port: %d\n", > > enable ? "enable" : "disable", portid); > > > > - if (enable) > > + if (enable) { > > larb_mmu->mmu |= MTK_SMI_MMU_EN(portid); > > - else > > + link = device_link_add(dev, larb_mmu->dev, > > + DL_FLAG_PM_RUNTIME | > > + DL_FLAG_AUTOREMOVE_CONSUMER); > > + if (!link) { > > + dev_err(dev, "Unable to link %s\n", > > + dev_name(larb_mmu->dev)); > > + return; > > Same for this one. > > > + } > > + } else { > > larb_mmu->mmu &= ~MTK_SMI_MMU_EN(portid); > > + } > > } > > } > > > > -- > > 1.9.1 > > > > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek