Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp5023413imc; Mon, 25 Feb 2019 15:55:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IaB1hO7/rsplZWMWhUsbWKVYprYyKq0Y4cTwaADhzvS8/YkcseL3HwurkF8q8B/emm+ZvjF X-Received: by 2002:a63:f648:: with SMTP id u8mr21094656pgj.91.1551138943495; Mon, 25 Feb 2019 15:55:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551138943; cv=none; d=google.com; s=arc-20160816; b=LGbRt5zBl/swm6W5WHVqXmgrJsUKK4xx0n0AGXCYVzqhx8IsM6qDW2d6Q6bT5DwKhU KNULWPzMEkmEZL8hAd6Bd3Ct/LK2rOQaZBsqv+Z5zjrlvE6C9pQCQV7UUUfDhLQECtue 1I6Y3H+mlRBi+dyKdvWiV5LVTLzhWd3T9VNZR4SSd1CgnzzEZd3JThC1/bD2oZ1qr5RU LezikMQzrSAKtz9sRPKlWILlTnyjZ/+h6m3Zt4ZPHNvqHEgCAD3mhM3SDnMBeKHC4lJd 51cw85GfwCrSmuHpyJeyG4f3kQILrdO22gRVsPrXVOrka1KLk8CxzD42ajMWFeLu4xGs 6EZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=v4zKbHDhMsN+Mg7u0glRIUId4HtPnOzdJXLjXBeHdzg=; b=kmu78HqgHFZaMmdSnoBWI1EFrkSFiw15DSbp2g1ZZ1c/22vPCHhqF3Nm9baAkzCsif BBaxoyeYMxbI9gexyp87GL6wCgniOI1DzsLM5ldUeIdzYMdDKfUs+V4GBgcxvopuRfQ3 7Id49tqCnU4iYZfhA6vvrUxzTlJNwS/SfzfSgBkvdG+oRNeLQ4ym4f1lUPvdkfSBA2n5 qn2NWpXplW+gf1t2+ozPkDA9oZEMYpzn0tD77tmoAPJCKimo2Lfbsodd3C08Wu8s+rMF Jf0Yv55Qi+JIE08j00yC0le0sUaq+sKeuEPliXIrRfJF1U6F0MRt4sx+8jqYXHsG/dKk /Uag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OHWprtkO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 128si11698098pfz.86.2019.02.25.15.55.28; Mon, 25 Feb 2019 15:55:43 -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; dkim=pass header.i=@chromium.org header.s=google header.b=OHWprtkO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729075AbfBYXzH (ORCPT + 99 others); Mon, 25 Feb 2019 18:55:07 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44300 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729038AbfBYXzG (ORCPT ); Mon, 25 Feb 2019 18:55:06 -0500 Received: by mail-lf1-f67.google.com with SMTP id g2so8236271lfh.11 for ; Mon, 25 Feb 2019 15:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v4zKbHDhMsN+Mg7u0glRIUId4HtPnOzdJXLjXBeHdzg=; b=OHWprtkORMqk3kKdabHOVWP/Y3RhmlW9snAjiZJfKfl2rYVcSsU1z+ZiO0XpIGJ7p7 rAbQl+Wz97fdWOmXL2ZHPI0o1G4vZ9X6yozpLEHUy6h4GmN62k4NgA/+Wo0dci4/8Gr2 qrDCwCrbOy+JLyMuJXexQR8LZ2/ijBPYnyPkE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=v4zKbHDhMsN+Mg7u0glRIUId4HtPnOzdJXLjXBeHdzg=; b=q0lfajQymJDt0co0VQ3NA7jvfpvY+MOe7N1ImZtD7BeIz5GupgRzLS9CN9kWJAg7Iv nq2Np/GRKdgGaa7BgXebPpsbBR/FckjulHiCFvtOi0WP0R7QPrTJdjwR2ovSQt6EpAcq WqKF1vb+yBhjrJkl3//HyeyO57h1+nmM+I+mAphozomADHda7PvP0rk0RAcj0g3VlOxt Dva7cmSd/aJrAszd9piHxZCI3PtwM90yFxtzhe70WSbtjNmkdj78GMYh4fr/llnE3ckn kUp463wUJunGa1jqPXttwZv3LZ+yJtciCTkpFQfFEUh9UcY/6oZb3GVdhFHhuf1sgDO3 fODA== X-Gm-Message-State: AHQUAuY/Ngs4TuqEwtuS9kyAaE1ky590O/Wkpw+jFM/0LTnaqtgvtI5Z wveiFTuCsHpU/ezSp4jVYJCFUd+N7uI= X-Received: by 2002:ac2:5496:: with SMTP id t22mr11409375lfk.65.1551138903327; Mon, 25 Feb 2019 15:55:03 -0800 (PST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com. [209.85.167.41]) by smtp.gmail.com with ESMTPSA id x2sm2519898ljj.79.2019.02.25.15.55.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 15:55:02 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id x206so243820lff.3 for ; Mon, 25 Feb 2019 15:55:01 -0800 (PST) X-Received: by 2002:a19:ae0b:: with SMTP id f11mr12318394lfc.104.1551138901438; Mon, 25 Feb 2019 15:55:01 -0800 (PST) MIME-Version: 1.0 References: <1546318276-18993-1-git-send-email-yong.wu@mediatek.com> <1546318276-18993-5-git-send-email-yong.wu@mediatek.com> In-Reply-To: <1546318276-18993-5-git-send-email-yong.wu@mediatek.com> From: Evan Green Date: Mon, 25 Feb 2019 15:54:25 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 04/13] iommu/mediatek: Add device_link between the consumer and the larb devices To: Yong Wu Cc: Joerg Roedel , Greg Kroah-Hartman , Matthias Brugger , Rob Herring , Robin Murphy , Tomasz Figa , Will Deacon , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , LKML , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, Arnd Bergmann , yingjoe.chen@mediatek.com, youlin.pei@mediatek.com, Nicolas Boichat Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + } > + } 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 >