Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1015667pxb; Wed, 6 Apr 2022 06:47:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh7Ju68sg1XolcNL3Dh22a5MgmFxzv/QginQbN8eWGp98Z6pKrlGnQcAnzV84v0dC8W51K X-Received: by 2002:a17:902:ec8b:b0:154:5c1c:bc8 with SMTP id x11-20020a170902ec8b00b001545c1c0bc8mr8520532plg.154.1649252831385; Wed, 06 Apr 2022 06:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252831; cv=none; d=google.com; s=arc-20160816; b=GfNjMCT96f/wiToid+yYUMJDtIQSfRD9eDmuOetiVcZPJRtAPHW6gD67d5LivU425/ kXp/e/yTA0OVGnMwpRz8/BvJS527Dr+ZEfxlHZ1NnkycxB/dBJlsf7TFk5IBpApGa89g ZyKJ30MXsxzoINK7uJPtcvotcN3W8/WAnuEanHDV8S1+Dj6GAauxbTHI1Wp+nMwmrjhh J+fRSzcHZEWpURnma1Yjm1QpqDdcRlTO8CGwtOtrjF4rDUBjMPpJR1Ks9Inb+H2kA8bn CIR1CJXpp+TSOiHcFyayfLVZefoxehs37bqFnhiD6nDR7EN+DzNXAdA0bBd/VLFHBJvC JFZA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=27dmX9c/4Jr5xomDRpvuDJPopqAgnXBUtwTi5gUd1L0=; b=jrz4iN8aJxJq5bruUQ75BcihDSzHx1NWKLbw+I7HewOPoZzyKJNMcnpmELawXRUeGA O7XQcpxPA647rzVpCeQDIazFYcJxBuOcRLn4LMjjjhUVHx/aqtMRieoFlRWjhqgxOIUx i53FJ9UbX1zKHUNwzr9AfG7XNQI/M6t+MgoB82VX7aR4eXZUb425R4IV3ojTNF2aXrEV NONbFeFSKH0w4jllV0RnpZ1XrbmnfdjK3VeGbnrtk6Fzko83nTgj4OJx+lWiyR6glW62 tcm12ECygAJRIJM18EXylyM5j5z9CAwgdWAcoRTKecmGy6mUQI67s2lgWjcHfyosZFw/ dJlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L1uIdMHx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pi4-20020a17090b1e4400b001ca8aa27fcbsi5915618pjb.164.2022.04.06.06.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:47:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L1uIdMHx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ABBAF61BB92; Wed, 6 Apr 2022 04:45:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1453845AbiDEWhF (ORCPT + 99 others); Tue, 5 Apr 2022 18:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351677AbiDEKDL (ORCPT ); Tue, 5 Apr 2022 06:03:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 302E172E02; Tue, 5 Apr 2022 02:52:05 -0700 (PDT) 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 9CE21B81B76; Tue, 5 Apr 2022 09:52:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A49BC385A1; Tue, 5 Apr 2022 09:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152323; bh=or7vMsAJ5qPVBHGYQ8AZJOSb3BRjqMrEX/v6pBzhP1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L1uIdMHxhcKrYzA3YOOqDUwOyfzfqgXDi+MIOxLrC+HIFtMWuy/a1GHnatu5kE4Na YNaqOCaQIHgAh2XEPqAY6XavIdfccF6863KcwmL8Z7cbWWA8tyq1RqNyuoD09hOCnz 6+nz8oI1LoVPPkfH2PkKW7cihCRFdeRQ0EsxrhRk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Frank Wunderlich , Yong Wu , Joerg Roedel , AngeloGioacchino Del Regno , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.15 734/913] media: iommu/mediatek-v1: Free the existed fwspec if the master dev already has Date: Tue, 5 Apr 2022 09:29:56 +0200 Message-Id: <20220405070401.833508928@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yong Wu [ Upstream commit 822a2ed8c606caf6a11b1a180b8e46292bd77d71 ] 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 Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- 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)) { -- 2.34.1