Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5149462rwb; Tue, 6 Sep 2022 20:14:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR7t2H5lL3vtDudq8gsXYDZlPINaln9CtmsBSZdSWVUi/HzV2GGdJBm6GqkoSdmGcvN3trk0 X-Received: by 2002:a05:6402:35cf:b0:448:84a9:12cf with SMTP id z15-20020a05640235cf00b0044884a912cfmr1316776edc.51.1662520483128; Tue, 06 Sep 2022 20:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662520483; cv=none; d=google.com; s=arc-20160816; b=vuHsy2NRzi9fasLMTOEFm4ZAFSth4o3n7RU9lu7SK9xzaHabKKLCay0ISN1kz2S9NR yNFF3IPOsXZUgsLt7kWhWf74IdLeNgm46bHq5ni3gEAW8M+h8hxxCF7RlgFDZjB7OlOK yUZst4YThgXdFb1OVqmZVo/yKIVACKWHsu24yRIpc9YR8HJxe0ZmRsYd1CqMECcCV1Xc YXhi1EF7iW0j2IsnMn9jmO1ECIM8ye7Y0vRlXqvLCWdVkE5aqGzHMmcIMVDORAFbwaVy fv3xXEwmUk+/pLHJstjWKRR3CGKRopNQbST/BdqB7hAZDvr7D12Tyrz+ldHKyNux5Af2 2cpQ== 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:date:cc:to:from:subject:message-id :dkim-signature; bh=VkcihY9ABi04XqXVV22kyb/oL68WO+uzwQnvKJrjdU8=; b=GEHOwKa9m2WpYVuDpg3qxMJFkpMHClmqT2KpNh1vZqdJTPqxjD00QDN+4WiO4AmXKo wWPuKVROZoCG+IbOOp8YfIJVVWokoXuuAkbZo8+LjVNg/IndXz63ZlhAUfEp9fTLzREz qKytijSoC5qk+DzgYl2Hqxg/C0FVFf51HA3T/+NRqOQYaT/2ctXiz32BOGi4EbDs2WqL AZers59ommlBQMOrbFBHJRpA0dckH6g9yY6MMLsnV4GN6qY/Ovk4QYhGcMXwYvOSR5Iv 6i0zD9zQzqWL4yOjG5Q6F9KooKPiZy5Iwi6rhdAwMQKPmWkKsSiLjkPCMH3TF+nJ2gvH KJog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ibO1SJX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js13-20020a17090797cd00b0073159d67b74si9607343ejc.46.2022.09.06.20.14.18; Tue, 06 Sep 2022 20:14:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ibO1SJX8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbiIGDIj (ORCPT + 99 others); Tue, 6 Sep 2022 23:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbiIGDI1 (ORCPT ); Tue, 6 Sep 2022 23:08:27 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0E9589808 for ; Tue, 6 Sep 2022 20:08:18 -0700 (PDT) X-UUID: e165945259534340ba26ebc6a7892780-20220907 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:ecebd88c-f886-4732-83e0-61300462c671,OB:0,L OB:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:45,FILE:0,BULK:0,RULE:Release _Ham,ACTION:release,TS:45 X-CID-INFO: VERSION:1.1.10,REQID:ecebd88c-f886-4732-83e0-61300462c671,OB:0,LOB :0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:45,FILE:0,BULK:0,RULE:Release_H am,ACTION:release,TS:45 X-CID-META: VersionHash:84eae18,CLOUDID:00ee6e21-1c20-48a5-82a0-25f9c331906d,C OID:8f337ed2212a,Recheck:0,SF:28|17|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: e165945259534340ba26ebc6a7892780-20220907 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1942156582; Wed, 07 Sep 2022 11:08:10 +0800 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> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_CSS 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 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) > >