Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2724725pxb; Mon, 31 Jan 2022 03:00:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbDXNQyIx6FyIgTUud4gWbNF7doRhiVLn4O4kTEftIn4nujMBPdgykTBlGMUkqru7+HMOF X-Received: by 2002:a17:906:1611:: with SMTP id m17mr17039121ejd.443.1643626806744; Mon, 31 Jan 2022 03:00:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643626806; cv=none; d=google.com; s=arc-20160816; b=yqbzD/JHHu6pvcdJGHZYdptJ4XUwuwB6DEjbf+OSDJKUQfKj+ZwbumkH4twVwkJRmC SQmdsvTKl4xQmg1xo3ml/TLAwUZvPoXUfPDVyu1Ey0mCQW8x5oPh07LJr6OWpYH2nCeX Y8YdkhGsh5rpKj+dHYOAgXZQQuvezoHoGgKqOOQ4FtIzJ4jZIEJnZ1L2N4OJNjyLID1H RS2Uv5I8Xh5j7vc5N+y2fOxMIcFZhJ0wgMOjc6KEB1ZZzaBj6lGGv/kM0aOpBlUIxeEX fDNMLUO9cxToFI5EGchqfNqHdfax4PwDwp4l87QoyVSK1n4zYy73Bj+yjZ9DYFic0BrI +qVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=sPVhmelVeQODlt+v1U/Q69e54Ge5JZViBP33IJFc54E=; b=GaInL90THcy2W7fYMCAjgbjD4HjJqs6e0zM0ZmC00YVJ3d1j6ZVayz3oCzotm3ob67 jpWDiAonyGDhkdnyFvLzowHNIoGfVWmCQCcRVsPPesicdGYDqYWu3bvyZzt3NQsCK5eF vF3h+mx5uW/16X7axEG7I/lhQXZXDNE1671xEi8TI/UJWN1IW6JZkbNx2zI/3m5SsH31 YUftIrTmNGGUjQCQV8oGlduRWXZntrphO6qAIPabNIQeFg3vh6xdedL9CoW1+LXMvxtj ZbK4pae+qlRtBgnewErZzeF+EikTbEt7YvxeV0etBEoEJplOdIj7aCY9lQS5C+xKf8Us /Lkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fDDCmQCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 28si6981512ejm.165.2022.01.31.02.59.15; Mon, 31 Jan 2022 03:00:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fDDCmQCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348613AbiA1MlJ (ORCPT + 99 others); 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