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 117B4ECAAD3 for ; Wed, 7 Sep 2022 03:20:53 +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: Date:CC:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Mxx/vQVeAeAIt/W3Qsh2LZ5nJMrp502uXX6r+SZGJG0=; b=euT7J/lEr/im+U 7OmA5hD/gOCiXR8Dwx+pK7Z2IZvKykqQ+s9ZAM10UinGS9/dsjhcT6gvdC4LQGMgUtt9JEaFErELZ 0KYshYXwhHc8QmgOgJFsIRn2p3J4v+yvEtuUqQfjBsnaZua1czavZqONy9AGtNPRu8UVu4mpmGIaT xdo5s3uXM46QVn9kJYGe9PmkkWNcMSOk0Qfvzl+4GH8DQaKN+MiXo2TsWO0NZKKstf62B5zXa0KBb X5vaWW5KSkDX3ejXLZvAYcbVBha9XQoBIcD/0UTOwHeypsUz0s0segLNgK18XDW1GpBUb5O9Bdhp0 /U9V9Z0tkLz1ODpFb+UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVlbB-001xBb-Lj; Wed, 07 Sep 2022 03:19:34 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVlb7-001x82-13; Wed, 07 Sep 2022 03:19:30 +0000 X-UUID: c566a0e39325401e821eefd611e6ae38-20220906 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=VkcihY9ABi04XqXVV22kyb/oL68WO+uzwQnvKJrjdU8=; b=ibO1SJX8+yDFWg5f9V+JoYcmF8wLZyzTrHDL/tJHxJXvjF9QfxS/vTB1u6CPWB+IjaiHHu8/FzNg401qIYlhYHvk31ilPYKWX75kpCmm33oQZCzVua9bpsvgOHvnSxk17EWbvSJpItVTl/qC7w8xFN0otgL2Kk2GADiGGlCGAJg=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.10,REQID:38ea4518-817f-41af-b306-10fafb256656,OB:0,L OB:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_ Ham,ACTION:release,TS:0 X-CID-META: VersionHash:84eae18,CLOUDID:0a03e656-e800-47dc-8adf-0c936acf4f1b,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: c566a0e39325401e821eefd611e6ae38-20220906 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 859803432; Tue, 06 Sep 2022 20:08:44 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 7 Sep 2022 11:08:09 +0800 Received: from mhfsdcap04 (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 7 Sep 2022 11:08:06 +0800 Message-ID: Subject: Re: [PATCH v4 3/6] iommu/mediatek: Add error path for loop of mm_dts_parse From: Yong Wu To: AngeloGioacchino Del Regno , Joerg Roedel , Matthias Brugger , Will Deacon CC: Robin Murphy , , , , , , , , , , , , , Guenter Roeck , Dan Carpenter Date: Wed, 7 Sep 2022 11:08:05 +0800 In-Reply-To: References: <20220824064306.21495-1-yong.wu@mediatek.com> <20220824064306.21495-4-yong.wu@mediatek.com> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_201929_101140_C8DBB304 X-CRM114-Status: GOOD ( 27.50 ) 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 On Tue, 2022-08-30 at 10:14 +0200, AngeloGioacchino Del Regno wrote: > Il 24/08/22 08:43, Yong Wu ha scritto: > > The mtk_iommu_mm_dts_parse will parse the smi larbs nodes. if the > > i+1 > > larb is parsed fail, we should put_device for the 0..i larbs. > > > > There are two places need to comment: > > 1) The larbid may be not linear mapping, we should loop whole > > the array in the error path. > > 2) I move this line position: "data->larb_imu[id].dev = &plarbdev- > > >dev;" > > That means set data->larb_imu[id].dev before the error path. > > then we don't need "platform_device_put(plarbdev)" again while > > probe_defer case. All depend on "put_device" in the error path > > in error > > cases. > > > > Fixes: d2e9a1102cfc ("iommu/mediatek: Contain MM IOMMU flow with > > the MM TYPE") > > Signed-off-by: Yong Wu > > --- > > drivers/iommu/mtk_iommu.c | 42 ++++++++++++++++++++++++++++---- > > ------- > > 1 file changed, 30 insertions(+), 12 deletions(-) [...] > > + > > +err_larbdev_put: > > + /* id may be not linear mapping, loop whole the array */ > > + for (i = 0; i < MTK_LARB_NR_MAX; i++) { > > Since there may be a case in which the mapping is linear and we're > doing teardown, > I think it would be sensible to loop the other way around instead, > from > MTK_LARB_NR_MAX to 0. Thanks very much. I will change from MTK_LARB_NR_MAX to 0. > > Everything else looks good to me. > > Cheers, > Angelo > > > + if (!data->larb_imu[i].dev) > > + continue; > > + put_device(data->larb_imu[i].dev); > > + } > > + return ret; > > } > > > > static int mtk_iommu_probe(struct platform_device *pdev) > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel