Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1314232pxb; Thu, 28 Jan 2021 13:13:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwugyVI/QHZhVpZrqnTVYtE7SGuXdLaO1qJEhBEpuFpLULDFIdVS2wvbpiGRJZKcrrsvjI+ X-Received: by 2002:a17:906:780c:: with SMTP id u12mr1366329ejm.125.1611868384835; Thu, 28 Jan 2021 13:13:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611868384; cv=none; d=google.com; s=arc-20160816; b=HpFdHt+AJP7PzBjWrsi60NwORoaaZKRbic2wG6fqOFV3whcx9okdW4PYmP2uI86BmE OBm4h5CXXjbWm4IIlPlBtM2NXIYDuC2ZaLrbKFiKtAlFoBfNybt+IFKU4nPJYNqN18GZ N/6424Ddq0jtpzv0LkoOu8HCglMigSmTsA8FgkSbv5DlSIPQaQW7xSNCgm7cAHArbDFI pnJMUrBpLPnr9uXaIJ/eHA0C1EgsO4Zv99oeU9QrIL7lyiIm4OO8UsUjzaPXoDpIY0d+ bPs+eKh0KkzMX9ywp9v/YLy2GB9VoM+IyRjQglX5fzASjQd9fDUIAIfWA791Ildwhwsw f18A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=KSY+MjlvOIYrd8BeFlvpXeT+2+9cJIEQ70vOAXSGDCY=; b=I7q2E8F4jrFXlf1dFGemecu95dekwXX675bfpEPCOX9qdNiM95M8Fe4V8i1RaVXZNL MVYqVGS3631NvlgMWnvZvgvWc7ZDFkr/LRE5KiMfpVq7NZebEpuSNXYzdywpajtz2KKP CGzc+VVQ++Bto2n35apgdLNmNOjgTeYPUg7fF5gmifPQWEbK08H8StD2zELBAEdYKJec VuA6Qw9Kyos+AyHzOHN1s7WYxurkxQ172HLkJ1X2vWUynkZFMQoxYAIlfNP+h8HA+72V tZts6TeRMIfGo8sbdqfOMFZkh3A0/uKF2Tc43ETzna81DhjyanIrSy5hfXtGqJJByEx1 V7dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UDy8g1B6; 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 t18si3293279ejc.249.2021.01.28.13.12.39; Thu, 28 Jan 2021 13:13:04 -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=UDy8g1B6; 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 S231410AbhA1VLI (ORCPT + 99 others); Thu, 28 Jan 2021 16:11:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:59034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbhA1VLH (ORCPT ); Thu, 28 Jan 2021 16:11:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E203464DDB; Thu, 28 Jan 2021 21:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611868226; bh=Wa3oCHdbhNI1rC5aNsjPzPLiyWlgSVs5J8jobh+d16o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UDy8g1B6xXUCMyvUCEeP3sXc/2mWaH+aOzhkdIt9x4BNWlNenfnPapZYWW8Am2sA0 1P2Qr5F1Ssd+GPV0IbsWoNHLqxohnEy/M6feG0Sz6CS1rlYGIKNIUeE1xtVno9B/g4 9RAF0vPuqOR028QU/LMmX1/Vjw9AQxLEkAw1QMPyVsJza2HePfbkP6rApwZZBXlZZU ZWH/oMCV/7zu/gOVT5AD0j2RGsyQ5AILr6L2tyo9xIMQXyLXXXU+e6pEYRYNiq7Rqy GlqCM3FSWikkY89/Yil+uuctnscrmmcMqJV/IfckIyfCmg5bgG3FIyDm7NpmplejKK j+hxxClSbtcNA== Date: Thu, 28 Jan 2021 21:10:20 +0000 From: Will Deacon To: Yong Wu Cc: Joerg Roedel , Rob Herring , Matthias Brugger , Robin Murphy , Krzysztof Kozlowski , Evan Green , Tomasz Figa , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, youlin.pei@mediatek.com, Nicolas Boichat , anan.sun@mediatek.com, chao.hao@mediatek.com Subject: Re: [PATCH v6 07/33] iommu: Avoid reallocate default domain for a group Message-ID: <20210128211020.GA3531@willie-the-truck> References: <20210111111914.22211-1-yong.wu@mediatek.com> <20210111111914.22211-8-yong.wu@mediatek.com> <20210126222305.GB30460@willie-the-truck> <1611740356.5302.14.camel@mhfsdcap03> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1611740356.5302.14.camel@mhfsdcap03> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 27, 2021 at 05:39:16PM +0800, Yong Wu wrote: > On Tue, 2021-01-26 at 22:23 +0000, Will Deacon wrote: > > On Mon, Jan 11, 2021 at 07:18:48PM +0800, Yong Wu wrote: > > > If group->default_domain exists, avoid reallocate it. > > > > > > In some iommu drivers, there may be several devices share a group. Avoid > > > realloc the default domain for this case. > > > > > > Signed-off-by: Yong Wu > > > --- > > > drivers/iommu/iommu.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > > > index 3d099a31ddca..f4b87e6abe80 100644 > > > --- a/drivers/iommu/iommu.c > > > +++ b/drivers/iommu/iommu.c > > > @@ -266,7 +266,8 @@ int iommu_probe_device(struct device *dev) > > > * support default domains, so the return value is not yet > > > * checked. > > > */ > > > - iommu_alloc_default_domain(group, dev); > > > + if (!group->default_domain) > > > + iommu_alloc_default_domain(group, dev); > > > > I don't really get what this achieves, since iommu_alloc_default_domain() > > looks like this: > > > > static int iommu_alloc_default_domain(struct iommu_group *group, > > struct device *dev) > > { > > unsigned int type; > > > > if (group->default_domain) > > return 0; > > > > ... > > > > in which case, it should be fine? > > oh. sorry, I overlooked this. the current code is enough. > I will remove this patch. and send the next version in this week. > Thanks very much. Actually, looking at this again, if we're dropping this patch and patch 6 just needs the kfree() moving about, then there's no need to repost. The issue that Robin and Paul are discussing can be handled separately. Will