Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11533259imu; Tue, 1 Jan 2019 01:15:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN6hF4jvAtGuQ+Pltd5hiNRghgNEaI23Q7ppdpp8420YpIvQ1OCc0RJerO78iz91CAZDLdhw X-Received: by 2002:a17:902:70c6:: with SMTP id l6mr40774867plt.30.1546334150359; Tue, 01 Jan 2019 01:15:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546334150; cv=none; d=google.com; s=arc-20160816; b=O4PE4SVyohTlTdA4PBm9H0p8BO2T7Iegaqu7QQdY9GdJ456HUgTOhX8c/8MAzwRquf NGXJUFocRIu2IAy/RDB+3wfz723HQs0qR/Gao20eLp7BfELbJa26r/oqLAJLYBSDPyO3 ja13whM7fDXOd8dMRWEZ2YVMBa5Ov5IvoxVzc3O3ZJiUmTHFWoFpe0gs5E7mEA/mWvMO NGpDnwUKj5CSE8NsAeDj/FpOiDVI6AB7to4R3FJBovw5ZFeeTeOoeULf6BDUDmJqdePw azVmC4KiqcAOHfSTAP0yzdPLGYJGbagCIH1bkO/+g3qJo/veNS7qpD/m2BeIDBD9Bm/h lXlQ== 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=TFf/KOANJA2QxEvqQkOBpcB9SYDUpm2ModhhUtMBxaM=; b=qK+xpj1nGCU7KrWO6d9mzyii2fc4o87rxHj29pSDBi2/Ij76oC7u1wdxqtR48FR8lB BIs84ThVDT50sISq2qZo9je533wCg8e4YU3BQeEusMiIocKdA7O0DH9waYWEC8UTcU+R c/nWgg435fKy4YbyBU2dC/cps19PJvzIPDw9GXVfYE/ZL7dY6kscJ1+UmiMIRlSuhCtd hSM0ptUlqnzcl9jA2oO3Ygg+Em/02AAY0XseWTK0/R/evyeg2qW9he0oiAVN2KfGnq0d k2+0qFdkwl5xnOEvMF4JNzBTHQLIIj7+C/nNAhc+JjLBYssV9kDdqj630jPOXzqCy2Yf aZhQ== 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 k62si3652830pfc.208.2019.01.01.01.15.12; Tue, 01 Jan 2019 01:15:50 -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 S1728472AbfAAEwO (ORCPT + 99 others); Mon, 31 Dec 2018 23:52:14 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:13761 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728425AbfAAEwN (ORCPT ); Mon, 31 Dec 2018 23:52:13 -0500 X-UUID: 99391a316f84448482293b626c148373-20190101 X-UUID: 99391a316f84448482293b626c148373-20190101 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1306635633; Tue, 01 Jan 2019 12:52:07 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 1 Jan 2019 12:52:05 +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, 1 Jan 2019 12:52:04 +0800 From: Yong Wu To: Joerg Roedel , Greg Kroah-Hartman , Matthias Brugger , Rob Herring CC: Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , , , , Nicolas Boichat Subject: [PATCH 04/13] iommu/mediatek: Add device_link between the consumer and the larb devices Date: Tue, 1 Jan 2019 12:51:07 +0800 Message-ID: <1546318276-18993-5-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546318276-18993-1-git-send-email-yong.wu@mediatek.com> References: <1546318276-18993-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 706CAF65DE7F61A95F88EF0E0AA91A03FA1915A56FF44879FCD4C8307A0520812000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + } + } 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; + } + } else { larb_mmu->mmu &= ~MTK_SMI_MMU_EN(portid); + } } } -- 1.9.1