From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDC16C433F5 for ; Fri, 28 Jan 2022 12:41:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348615AbiA1MlJ (ORCPT ); Fri, 28 Jan 2022 07:41:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237505AbiA1MlH (ORCPT ); Fri, 28 Jan 2022 07:41:07 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BEE9C061714; Fri, 28 Jan 2022 04:41:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0ACE2619B9; Fri, 28 Jan 2022 12:41:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA84CC340E6; Fri, 28 Jan 2022 12:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643373666; bh=QTzghuuSPtxJUTuUKx+W2/InQdxW15PSFwUv7VwUABw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fDDCmQCAaMcJEavgtcJqwJ2QJDBq3pXRsPPc/l3by+2yESxDGmW5Kc9OAQqn3MlGS 9u8Jv1ppUGuCND2rokmY9SaMNtaybtUEWIbP9oXZ0jFRJDx82sG3zyppd2O0w9G76o Uf6erkYS+tgPQeVG5Z4aajPuWDNl06NAHpm7V+osyHiEA1BafH1iqrwBRt4Nwh5f7b wTP3ylF7iEUpGtGw+XjQr3MkFPOrG30hsWP/p9VE+pXFzTebvsbCxultxHFmtTO7Ho qvm2eN+tw7ziwQofhdfjUSM4ZDTzEncDr5Kmwnm/HUP8sHcsjZTVNARCCP6qFvyT/z eHYTGTk6Yk5gg== Date: Fri, 28 Jan 2022 13:40:55 +0100 From: Mauro Carvalho Chehab To: Yong Wu , Matthias Brugger Cc: Hans Verkuil , Joerg Roedel , Rob Herring , Krzysztof Kozlowski , David Airlie , Evan Green , Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , Matthias Kaehlcke , , , , , , Daniel Vetter , Chun-Kuang Hu , Philipp Zabel , Tiffany Lin , "Dafna Hirschfeld" , Hsin-Yi Wang , Eizan Miyamoto , , Frank Wunderlich , , , , AngeloGioacchino Del Regno Subject: Re: [PATCH v10 02/13] iommu/mediatek-v1: Free the existed fwspec if the master dev already has Message-ID: <20220128134055.720bb43c@coco.lan> In-Reply-To: <20220117070510.17642-3-yong.wu@mediatek.com> References: <20220117070510.17642-1-yong.wu@mediatek.com> <20220117070510.17642-3-yong.wu@mediatek.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Matthias/Yong, Are you ok if this patch gets merged via the media tree together with the remaining series, or do you prefer to apply it via SoC tree instead? Regards, Mauro Em Mon, 17 Jan 2022 15:04:59 +0800 Yong Wu escreveu: > When the iommu master device enters of_iommu_xlate, the ops may be > NULL(iommu dev is defered), then it will initialize the fwspec here: > > [] (dev_iommu_fwspec_set) from [] > (iommu_fwspec_init+0xbc/0xd4) > [] (iommu_fwspec_init) from [] > (of_iommu_xlate+0x7c/0x12c) > [] (of_iommu_xlate) from [] > (of_iommu_configure+0x144/0x1e8) > > BUT the mtk_iommu_v1.c only supports arm32, the probing flow still is a bit > weird. We always expect create the fwspec internally. otherwise it will > enter here and return fail. > > static int mtk_iommu_create_mapping(struct device *dev, > struct of_phandle_args *args) > { > ... > if (!fwspec) { > .... > } else if (dev_iommu_fwspec_get(dev)->ops != &mtk_iommu_ops) { > >>>>>>>>>>Enter here. return fail.<<<<<<<<<<<< > return -EINVAL; > } > ... > } > > Thus, Free the existed fwspec if the master device already has fwspec. > > This issue is reported at: > https://lore.kernel.org/linux-mediatek/trinity-7d9ebdc9-4849-4d93-bfb5-429dcb4ee449-1626253158870@3c-app-gmx-bs01/ > > Reported-by: Frank Wunderlich > Tested-by: Frank Wunderlich # BPI-R2/MT7623 > Signed-off-by: Yong Wu > Acked-by: Joerg Roedel > Acked-by: AngeloGioacchino Del Regno > --- > drivers/iommu/mtk_iommu_v1.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c > index be22fcf988ce..1467ba1e4417 100644 > --- a/drivers/iommu/mtk_iommu_v1.c > +++ b/drivers/iommu/mtk_iommu_v1.c > @@ -425,6 +425,15 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev) > struct mtk_iommu_data *data; > int err, idx = 0; > > + /* > + * In the deferred case, free the existed fwspec. > + * Always initialize the fwspec internally. > + */ > + if (fwspec) { > + iommu_fwspec_free(dev); > + fwspec = dev_iommu_fwspec_get(dev); > + } > + > while (!of_parse_phandle_with_args(dev->of_node, "iommus", > "#iommu-cells", > idx, &iommu_spec)) { Thanks, Mauro From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B96B2C433EF for ; Fri, 28 Jan 2022 12:41:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB1E410EB1D; Fri, 28 Jan 2022 12:41:11 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id B213B10EB05 for ; Fri, 28 Jan 2022 12:41:10 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BFF7DB8250F; Fri, 28 Jan 2022 12:41:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA84CC340E6; Fri, 28 Jan 2022 12:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643373666; bh=QTzghuuSPtxJUTuUKx+W2/InQdxW15PSFwUv7VwUABw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fDDCmQCAaMcJEavgtcJqwJ2QJDBq3pXRsPPc/l3by+2yESxDGmW5Kc9OAQqn3MlGS 9u8Jv1ppUGuCND2rokmY9SaMNtaybtUEWIbP9oXZ0jFRJDx82sG3zyppd2O0w9G76o Uf6erkYS+tgPQeVG5Z4aajPuWDNl06NAHpm7V+osyHiEA1BafH1iqrwBRt4Nwh5f7b wTP3ylF7iEUpGtGw+XjQr3MkFPOrG30hsWP/p9VE+pXFzTebvsbCxultxHFmtTO7Ho qvm2eN+tw7ziwQofhdfjUSM4ZDTzEncDr5Kmwnm/HUP8sHcsjZTVNARCCP6qFvyT/z eHYTGTk6Yk5gg== Date: Fri, 28 Jan 2022 13:40:55 +0100 From: Mauro Carvalho Chehab To: Yong Wu , Matthias Brugger Subject: Re: [PATCH v10 02/13] iommu/mediatek-v1: Free the existed fwspec if the master dev already has Message-ID: <20220128134055.720bb43c@coco.lan> In-Reply-To: <20220117070510.17642-3-yong.wu@mediatek.com> References: <20220117070510.17642-1-yong.wu@mediatek.com> <20220117070510.17642-3-yong.wu@mediatek.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dafna Hirschfeld , Chun-Kuang Hu , David Airlie , Will Deacon , dri-devel@lists.freedesktop.org, yf.wang@mediatek.com, Hans Verkuil , anthony.huang@mediatek.com, youlin.pei@mediatek.com, Krzysztof Kozlowski , Evan Green , Eizan Miyamoto , Matthias Kaehlcke , mingyuan.ma@mediatek.com, linux-media@vger.kernel.org, devicetree@vger.kernel.org, Joerg Roedel , Frank Wunderlich , libo.kang@mediatek.com, yi.kuo@mediatek.com, Rob Herring , linux-mediatek@lists.infradead.org, Hsin-Yi Wang , Tiffany Lin , linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno , anan.sun@mediatek.com, srv_heupstream@mediatek.com, acourbot@chromium.org, linux-kernel@vger.kernel.org, Tomasz Figa , iommu@lists.linux-foundation.org, Robin Murphy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Matthias/Yong, Are you ok if this patch gets merged via the media tree together with the remaining series, or do you prefer to apply it via SoC tree instead? Regards, Mauro Em Mon, 17 Jan 2022 15:04:59 +0800 Yong Wu escreveu: > When the iommu master device enters of_iommu_xlate, the ops may be > NULL(iommu dev is defered), then it will initialize the fwspec here: > > [] (dev_iommu_fwspec_set) from [] > (iommu_fwspec_init+0xbc/0xd4) > [] (iommu_fwspec_init) from [] > (of_iommu_xlate+0x7c/0x12c) > [] (of_iommu_xlate) from [] > (of_iommu_configure+0x144/0x1e8) > > BUT the mtk_iommu_v1.c only supports arm32, the probing flow still is a bit > weird. We always expect create the fwspec internally. otherwise it will > enter here and return fail. > > static int mtk_iommu_create_mapping(struct device *dev, > struct of_phandle_args *args) > { > ... > if (!fwspec) { > .... > } else if (dev_iommu_fwspec_get(dev)->ops != &mtk_iommu_ops) { > >>>>>>>>>>Enter here. return fail.<<<<<<<<<<<< > return -EINVAL; > } > ... > } > > Thus, Free the existed fwspec if the master device already has fwspec. > > This issue is reported at: > https://lore.kernel.org/linux-mediatek/trinity-7d9ebdc9-4849-4d93-bfb5-429dcb4ee449-1626253158870@3c-app-gmx-bs01/ > > Reported-by: Frank Wunderlich > Tested-by: Frank Wunderlich # BPI-R2/MT7623 > Signed-off-by: Yong Wu > Acked-by: Joerg Roedel > Acked-by: AngeloGioacchino Del Regno > --- > drivers/iommu/mtk_iommu_v1.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c > index be22fcf988ce..1467ba1e4417 100644 > --- a/drivers/iommu/mtk_iommu_v1.c > +++ b/drivers/iommu/mtk_iommu_v1.c > @@ -425,6 +425,15 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev) > struct mtk_iommu_data *data; > int err, idx = 0; > > + /* > + * In the deferred case, free the existed fwspec. > + * Always initialize the fwspec internally. > + */ > + if (fwspec) { > + iommu_fwspec_free(dev); > + fwspec = dev_iommu_fwspec_get(dev); > + } > + > while (!of_parse_phandle_with_args(dev->of_node, "iommus", > "#iommu-cells", > idx, &iommu_spec)) { Thanks, Mauro From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15B42C433F5 for ; Fri, 28 Jan 2022 12:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Re3n+25mUmAQBEzzK3VTrW4YO4VDXwOosPdTzE2XoLA=; b=wIzQh4maxmilAa PyRemjHkwouph2BW5r7Qip8LnRnim5fCJe/PkR02v4XaoE9VGko0fEpdZV7AnZbsdtc6LoU4xTEva jxsdXTpE91MyBJPFSE/Jz9Naoh2BSLRYPjxnPPHPuwPKA3VlZcJwNVZRnHPrdP3zn4P+EeCCGJODH qjcBWqrd8dZjrgH+dlIwY+TxaUEdaRAcWPZzMRIH3k40LqWIt1rpXzWG9BftOhHOK903cRshFD0GR 7DGcLIoxrpBZ4XmNnrhwTltdk12T32QoFBbASvk5CXIl7Z2N/5SHDhJSReLtzeNSzYNk0MOq/Yzvd 1hDs/QU7QL/sAyN+oyUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDQgS-0024UJ-6B; Fri, 28 Jan 2022 12:48:56 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDQYw-0021N0-1i; Fri, 28 Jan 2022 12:41:12 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BFF7DB8250F; Fri, 28 Jan 2022 12:41:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA84CC340E6; Fri, 28 Jan 2022 12:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643373666; bh=QTzghuuSPtxJUTuUKx+W2/InQdxW15PSFwUv7VwUABw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fDDCmQCAaMcJEavgtcJqwJ2QJDBq3pXRsPPc/l3by+2yESxDGmW5Kc9OAQqn3MlGS 9u8Jv1ppUGuCND2rokmY9SaMNtaybtUEWIbP9oXZ0jFRJDx82sG3zyppd2O0w9G76o Uf6erkYS+tgPQeVG5Z4aajPuWDNl06NAHpm7V+osyHiEA1BafH1iqrwBRt4Nwh5f7b wTP3ylF7iEUpGtGw+XjQr3MkFPOrG30hsWP/p9VE+pXFzTebvsbCxultxHFmtTO7Ho qvm2eN+tw7ziwQofhdfjUSM4ZDTzEncDr5Kmwnm/HUP8sHcsjZTVNARCCP6qFvyT/z eHYTGTk6Yk5gg== Date: Fri, 28 Jan 2022 13:40:55 +0100 From: Mauro Carvalho Chehab To: Yong Wu , Matthias Brugger Subject: Re: [PATCH v10 02/13] iommu/mediatek-v1: Free the existed fwspec if the master dev already has Message-ID: <20220128134055.720bb43c@coco.lan> In-Reply-To: <20220117070510.17642-3-yong.wu@mediatek.com> References: <20220117070510.17642-1-yong.wu@mediatek.com> <20220117070510.17642-3-yong.wu@mediatek.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220128_044110_427477_13B51CE9 X-CRM114-Status: GOOD ( 24.78 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dafna Hirschfeld , Chun-Kuang Hu , David Airlie , Will Deacon , dri-devel@lists.freedesktop.org, yf.wang@mediatek.com, Hans Verkuil , anthony.huang@mediatek.com, youlin.pei@mediatek.com, Krzysztof Kozlowski , Evan Green , Eizan Miyamoto , Matthias Kaehlcke , mingyuan.ma@mediatek.com, linux-media@vger.kernel.org, devicetree@vger.kernel.org, Joerg Roedel , Philipp Zabel , libo.kang@mediatek.com, yi.kuo@mediatek.com, Rob Herring , linux-mediatek@lists.infradead.org, Hsin-Yi Wang , Tiffany Lin , linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno , anan.sun@mediatek.com, srv_heupstream@mediatek.com, acourbot@chromium.org, linux-kernel@vger.kernel.org, Tomasz Figa , iommu@lists.linux-foundation.org, Daniel Vetter , Robin Murphy Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Hi Matthias/Yong, Are you ok if this patch gets merged via the media tree together with the remaining series, or do you prefer to apply it via SoC tree instead? Regards, Mauro Em Mon, 17 Jan 2022 15:04:59 +0800 Yong Wu escreveu: > When the iommu master device enters of_iommu_xlate, the ops may be > NULL(iommu dev is defered), then it will initialize the fwspec here: > > [] (dev_iommu_fwspec_set) from [] > (iommu_fwspec_init+0xbc/0xd4) > [] (iommu_fwspec_init) from [] > (of_iommu_xlate+0x7c/0x12c) > [] (of_iommu_xlate) from [] > (of_iommu_configure+0x144/0x1e8) > > BUT the mtk_iommu_v1.c only supports arm32, the probing flow still is a bit > weird. We always expect create the fwspec internally. otherwise it will > enter here and return fail. > > static int mtk_iommu_create_mapping(struct device *dev, > struct of_phandle_args *args) > { > ... > if (!fwspec) { > .... > } else if (dev_iommu_fwspec_get(dev)->ops != &mtk_iommu_ops) { > >>>>>>>>>>Enter here. return fail.<<<<<<<<<<<< > return -EINVAL; > } > ... > } > > Thus, Free the existed fwspec if the master device already has fwspec. > > This issue is reported at: > https://lore.kernel.org/linux-mediatek/trinity-7d9ebdc9-4849-4d93-bfb5-429dcb4ee449-1626253158870@3c-app-gmx-bs01/ > > Reported-by: Frank Wunderlich > Tested-by: Frank Wunderlich # BPI-R2/MT7623 > Signed-off-by: Yong Wu > Acked-by: Joerg Roedel > Acked-by: AngeloGioacchino Del Regno > --- > drivers/iommu/mtk_iommu_v1.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c > index be22fcf988ce..1467ba1e4417 100644 > --- a/drivers/iommu/mtk_iommu_v1.c > +++ b/drivers/iommu/mtk_iommu_v1.c > @@ -425,6 +425,15 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev) > struct mtk_iommu_data *data; > int err, idx = 0; > > + /* > + * In the deferred case, free the existed fwspec. > + * Always initialize the fwspec internally. > + */ > + if (fwspec) { > + iommu_fwspec_free(dev); > + fwspec = dev_iommu_fwspec_get(dev); > + } > + > while (!of_parse_phandle_with_args(dev->of_node, "iommus", > "#iommu-cells", > idx, &iommu_spec)) { Thanks, Mauro _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA7BDC4332F for ; Fri, 28 Jan 2022 12:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J6QPdoEgrOkCLkYTm/V0wGsQww1N57vD3kxQdEppzlA=; b=m+XdhZLr/oMYsz RbpuytUdx+/a7Q4tIX0kJnMHIWpuVt0e7Y7Lp6N4rr7Yg/upIT35u5PchRMeVbLw5GtKt8stQzlAc T/SheZKLySwP0jXjUZZAX7CgBymtmZeUlxucev0nqFxBHQxe1rlaIzVKZkTKZzEnlcQp0MVgi7zoU kPjH33E9hbWIYwtIZjYjAvE0Tzwk85MD618QMmvX/A1tu76NkYSK0mO8Cyo8R0mygTUIWIuRRe01Y L9waIJ5E/Kk3g9+nmkrZ3P9oak/pnDKlFFMobDWKp88pdzP3xftGGmNxtIRYTVBzNUYg49vgZQ7fp 6eowaPGBpG+rIryy82Dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDQfk-0024GW-O0; Fri, 28 Jan 2022 12:48:12 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDQYw-0021N0-1i; Fri, 28 Jan 2022 12:41:12 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BFF7DB8250F; Fri, 28 Jan 2022 12:41:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA84CC340E6; Fri, 28 Jan 2022 12:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643373666; bh=QTzghuuSPtxJUTuUKx+W2/InQdxW15PSFwUv7VwUABw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fDDCmQCAaMcJEavgtcJqwJ2QJDBq3pXRsPPc/l3by+2yESxDGmW5Kc9OAQqn3MlGS 9u8Jv1ppUGuCND2rokmY9SaMNtaybtUEWIbP9oXZ0jFRJDx82sG3zyppd2O0w9G76o Uf6erkYS+tgPQeVG5Z4aajPuWDNl06NAHpm7V+osyHiEA1BafH1iqrwBRt4Nwh5f7b wTP3ylF7iEUpGtGw+XjQr3MkFPOrG30hsWP/p9VE+pXFzTebvsbCxultxHFmtTO7Ho qvm2eN+tw7ziwQofhdfjUSM4ZDTzEncDr5Kmwnm/HUP8sHcsjZTVNARCCP6qFvyT/z eHYTGTk6Yk5gg== Date: Fri, 28 Jan 2022 13:40:55 +0100 From: Mauro Carvalho Chehab To: Yong Wu , Matthias Brugger Cc: Hans Verkuil , Joerg Roedel , Rob Herring , Krzysztof Kozlowski , David Airlie , Evan Green , Robin Murphy , Tomasz Figa , Will Deacon , , , , , , , , Matthias Kaehlcke , , , , , , Daniel Vetter , Chun-Kuang Hu , Philipp Zabel , Tiffany Lin , "Dafna Hirschfeld" , Hsin-Yi Wang , Eizan Miyamoto , , Frank Wunderlich , , , , AngeloGioacchino Del Regno Subject: Re: [PATCH v10 02/13] iommu/mediatek-v1: Free the existed fwspec if the master dev already has Message-ID: <20220128134055.720bb43c@coco.lan> In-Reply-To: <20220117070510.17642-3-yong.wu@mediatek.com> References: <20220117070510.17642-1-yong.wu@mediatek.com> <20220117070510.17642-3-yong.wu@mediatek.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220128_044110_427477_13B51CE9 X-CRM114-Status: GOOD ( 24.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Matthias/Yong, Are you ok if this patch gets merged via the media tree together with the remaining series, or do you prefer to apply it via SoC tree instead? Regards, Mauro Em Mon, 17 Jan 2022 15:04:59 +0800 Yong Wu escreveu: > When the iommu master device enters of_iommu_xlate, the ops may be > NULL(iommu dev is defered), then it will initialize the fwspec here: > > [] (dev_iommu_fwspec_set) from [] > (iommu_fwspec_init+0xbc/0xd4) > [] (iommu_fwspec_init) from [] > (of_iommu_xlate+0x7c/0x12c) > [] (of_iommu_xlate) from [] > (of_iommu_configure+0x144/0x1e8) > > BUT the mtk_iommu_v1.c only supports arm32, the probing flow still is a bit > weird. We always expect create the fwspec internally. otherwise it will > enter here and return fail. > > static int mtk_iommu_create_mapping(struct device *dev, > struct of_phandle_args *args) > { > ... > if (!fwspec) { > .... > } else if (dev_iommu_fwspec_get(dev)->ops != &mtk_iommu_ops) { > >>>>>>>>>>Enter here. return fail.<<<<<<<<<<<< > return -EINVAL; > } > ... > } > > Thus, Free the existed fwspec if the master device already has fwspec. > > This issue is reported at: > https://lore.kernel.org/linux-mediatek/trinity-7d9ebdc9-4849-4d93-bfb5-429dcb4ee449-1626253158870@3c-app-gmx-bs01/ > > Reported-by: Frank Wunderlich > Tested-by: Frank Wunderlich # BPI-R2/MT7623 > Signed-off-by: Yong Wu > Acked-by: Joerg Roedel > Acked-by: AngeloGioacchino Del Regno > --- > drivers/iommu/mtk_iommu_v1.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c > index be22fcf988ce..1467ba1e4417 100644 > --- a/drivers/iommu/mtk_iommu_v1.c > +++ b/drivers/iommu/mtk_iommu_v1.c > @@ -425,6 +425,15 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev) > struct mtk_iommu_data *data; > int err, idx = 0; > > + /* > + * In the deferred case, free the existed fwspec. > + * Always initialize the fwspec internally. > + */ > + if (fwspec) { > + iommu_fwspec_free(dev); > + fwspec = dev_iommu_fwspec_get(dev); > + } > + > while (!of_parse_phandle_with_args(dev->of_node, "iommus", > "#iommu-cells", > idx, &iommu_spec)) { Thanks, Mauro _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4CA0BC433EF for ; Fri, 28 Jan 2022 12:59:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D3A4A60B8C; Fri, 28 Jan 2022 12:59:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZyBiXDOjV7Ki; Fri, 28 Jan 2022 12:59:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9099760AD1; Fri, 28 Jan 2022 12:59:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 62101C001A; Fri, 28 Jan 2022 12:59:34 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5125EC000B for ; Fri, 28 Jan 2022 12:41:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 2A0D640286 for ; Fri, 28 Jan 2022 12:41:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Sz_eM_M9HQPN for ; Fri, 28 Jan 2022 12:41:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by smtp2.osuosl.org (Postfix) with ESMTPS id 70322400C6 for ; Fri, 28 Jan 2022 12:41:10 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BFF7DB8250F; Fri, 28 Jan 2022 12:41:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA84CC340E6; Fri, 28 Jan 2022 12:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643373666; bh=QTzghuuSPtxJUTuUKx+W2/InQdxW15PSFwUv7VwUABw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fDDCmQCAaMcJEavgtcJqwJ2QJDBq3pXRsPPc/l3by+2yESxDGmW5Kc9OAQqn3MlGS 9u8Jv1ppUGuCND2rokmY9SaMNtaybtUEWIbP9oXZ0jFRJDx82sG3zyppd2O0w9G76o Uf6erkYS+tgPQeVG5Z4aajPuWDNl06NAHpm7V+osyHiEA1BafH1iqrwBRt4Nwh5f7b wTP3ylF7iEUpGtGw+XjQr3MkFPOrG30hsWP/p9VE+pXFzTebvsbCxultxHFmtTO7Ho qvm2eN+tw7ziwQofhdfjUSM4ZDTzEncDr5Kmwnm/HUP8sHcsjZTVNARCCP6qFvyT/z eHYTGTk6Yk5gg== Date: Fri, 28 Jan 2022 13:40:55 +0100 From: Mauro Carvalho Chehab To: Yong Wu , Matthias Brugger Subject: Re: [PATCH v10 02/13] iommu/mediatek-v1: Free the existed fwspec if the master dev already has Message-ID: <20220128134055.720bb43c@coco.lan> In-Reply-To: <20220117070510.17642-3-yong.wu@mediatek.com> References: <20220117070510.17642-1-yong.wu@mediatek.com> <20220117070510.17642-3-yong.wu@mediatek.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 28 Jan 2022 12:59:34 +0000 Cc: Chun-Kuang Hu , David Airlie , Will Deacon , dri-devel@lists.freedesktop.org, yf.wang@mediatek.com, Hans Verkuil , anthony.huang@mediatek.com, Krzysztof Kozlowski , Evan Green , Eizan Miyamoto , Matthias Kaehlcke , mingyuan.ma@mediatek.com, linux-media@vger.kernel.org, devicetree@vger.kernel.org, Joerg Roedel , Philipp Zabel , Frank Wunderlich , libo.kang@mediatek.com, yi.kuo@mediatek.com, Rob Herring , linux-mediatek@lists.infradead.org, Hsin-Yi Wang , Tiffany Lin , linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno , anan.sun@mediatek.com, srv_heupstream@mediatek.com, acourbot@chromium.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Daniel Vetter , Robin Murphy X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" Hi Matthias/Yong, Are you ok if this patch gets merged via the media tree together with the remaining series, or do you prefer to apply it via SoC tree instead? Regards, Mauro Em Mon, 17 Jan 2022 15:04:59 +0800 Yong Wu escreveu: > When the iommu master device enters of_iommu_xlate, the ops may be > NULL(iommu dev is defered), then it will initialize the fwspec here: > > [] (dev_iommu_fwspec_set) from [] > (iommu_fwspec_init+0xbc/0xd4) > [] (iommu_fwspec_init) from [] > (of_iommu_xlate+0x7c/0x12c) > [] (of_iommu_xlate) from [] > (of_iommu_configure+0x144/0x1e8) > > BUT the mtk_iommu_v1.c only supports arm32, the probing flow still is a bit > weird. We always expect create the fwspec internally. otherwise it will > enter here and return fail. > > static int mtk_iommu_create_mapping(struct device *dev, > struct of_phandle_args *args) > { > ... > if (!fwspec) { > .... > } else if (dev_iommu_fwspec_get(dev)->ops != &mtk_iommu_ops) { > >>>>>>>>>>Enter here. return fail.<<<<<<<<<<<< > return -EINVAL; > } > ... > } > > Thus, Free the existed fwspec if the master device already has fwspec. > > This issue is reported at: > https://lore.kernel.org/linux-mediatek/trinity-7d9ebdc9-4849-4d93-bfb5-429dcb4ee449-1626253158870@3c-app-gmx-bs01/ > > Reported-by: Frank Wunderlich > Tested-by: Frank Wunderlich # BPI-R2/MT7623 > Signed-off-by: Yong Wu > Acked-by: Joerg Roedel > Acked-by: AngeloGioacchino Del Regno > --- > drivers/iommu/mtk_iommu_v1.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c > index be22fcf988ce..1467ba1e4417 100644 > --- a/drivers/iommu/mtk_iommu_v1.c > +++ b/drivers/iommu/mtk_iommu_v1.c > @@ -425,6 +425,15 @@ static struct iommu_device *mtk_iommu_probe_device(struct device *dev) > struct mtk_iommu_data *data; > int err, idx = 0; > > + /* > + * In the deferred case, free the existed fwspec. > + * Always initialize the fwspec internally. > + */ > + if (fwspec) { > + iommu_fwspec_free(dev); > + fwspec = dev_iommu_fwspec_get(dev); > + } > + > while (!of_parse_phandle_with_args(dev->of_node, "iommus", > "#iommu-cells", > idx, &iommu_spec)) { Thanks, Mauro _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu