Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp459509pxb; Wed, 27 Jan 2021 11:59:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwG/xFgMIHn6LRMS3YgmbQ3+kxmyEZRk5OubWhIThA6iCwmy3Wt9f1HSfoAKqdhNo2SiB47 X-Received: by 2002:a50:9f65:: with SMTP id b92mr10491029edf.74.1611777580347; Wed, 27 Jan 2021 11:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611777580; cv=none; d=google.com; s=arc-20160816; b=tse0TE6KFR157AkOMHVS2ejbD1UMMlhZrrXIQSHTZJ6YgvldYte5z8eH/p/I4xe7h5 rLRMzrrfX5hipCLTpVPKRIGmyxQbfEwU8ZT7Mn+4rVMGLJ28/k02QWwMdu0Odf+oe2lQ eXAZb5ZZMfVd5I15pgpQtw8W2/eIhVAOf7oQi6nlMIRgakyJOX2BoiYVeHuUvddkBfrZ ZD8uOlriL6HiILxvxRbChfj3mFXZXzogyMykdPhNKqakWOAaK84TngeKgtMijfER6Bya Aj+RbJ6Rdx396RA6wa9rInw83Jh/w45bh41bw2arg+Dz3mD/s355ZlVTGzcKSE/kx9CV oIIg== 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=YutxjdaIsUYkhtZknnoee+PXZywSfdfOOOFcW41KRwg=; b=lmAA+hS50QCqAZ97x4oWE1ShUEk6ieSye+W7diHFXORquenCCzG7i9M2A/fqxqOB8H hgusf4/E2LC7PVMrciI4kauJi4rIWg2FW0/jx9x93vlgSLAQUbkk5r9j25rRkkAxBebN MGuHX1dcw+OMnthh4mYM8Op+bDk/t0jPtq+E62sfelaFYwTmo61SD2PdWWJJK/vvqUft L8NfxBrl80Z7lHhG5jQd563eWYpK1eBXkqQ/wi7uX08e/kAXHeWdl0xuACcoHgGhHpoS WbIximJC2kveI5hr3REpWye4slIAkk0dOSePRbjtYnhzR/epXXUAP9oDfAQlLpAS9DT7 0Vbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=achoEHu8; 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 hr35si1305887ejc.274.2021.01.27.11.59.14; Wed, 27 Jan 2021 11:59:40 -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=achoEHu8; 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 S236912AbhA0DoB (ORCPT + 99 others); Tue, 26 Jan 2021 22:44:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:51976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728620AbhAZWXx (ORCPT ); Tue, 26 Jan 2021 17:23:53 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D75302065D; Tue, 26 Jan 2021 22:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611699792; bh=fdRIENxKcgc5beyovt2puqoCoi+rEtNpR+KyZhmJt9I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=achoEHu8k4uN8E83dNG429NPT1uvW4BKjuDha0qFlXbMfhUNqyWIOkGFmn5FIYQjx AAQs2T+cmT/3KagO8qWzYc02+OPzJ8Y0qoV6PONAnxAgS75ryj9A2u9zfPw9P6NK8M cHG5i9P/T7hfT5C7tU+Gu5rsDwAD1jYs0hcLmgrgWzCKcc2j5HXL5Tr/whN3VyMMdQ bx4w3RT7i0ULUk3PrLkCR1ZpN3A9ZiqNQD7ru816XaXg4IngNyw1pIqGVHsHxZ/upn BHC4hf5TqThjyZuxdwR0BPmGGFv4S+W11JMY00+TYtCZw7qigBK4Q9XevrSXLk7/eK peDrVc1pqOHww== Date: Tue, 26 Jan 2021 22:23:06 +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: <20210126222305.GB30460@willie-the-truck> References: <20210111111914.22211-1-yong.wu@mediatek.com> <20210111111914.22211-8-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210111111914.22211-8-yong.wu@mediatek.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Will