Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2188379pxb; Mon, 11 Jan 2021 03:25:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUy939Zyr3mybBL4P9RPKZEu7k47dvIIRzc3mdYTlDkknXDODhjAlUOmQF7GQnKKPa0B3A X-Received: by 2002:aa7:d7d8:: with SMTP id e24mr13623127eds.135.1610364309413; Mon, 11 Jan 2021 03:25:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610364309; cv=none; d=google.com; s=arc-20160816; b=rYh/sp4qiTjMcvV26Rfzv4SihMr9bhkZn+tw/ONGakHavUAO8zV4cHv9L+Uu5WBJdE XK0zbSi+GaaPw/NmLxWqdKv1xhK5ATLYbHEJMQ3K9yi8yiqXvLUDwPfMRPxxfzzGec1m YylZ6syyJB0GX9HDdoradlGwSIvSjX4xSAxGP3fd3VZr5G9mCRq2pXg+jYdOOSh/Hbtw FomL3NNeIsN4eGMnXQurBp8EZ0rz/Y+MVC1G7wQVFFBQD6d78AcrpK/CWCDJk6SQTAoa BPbkR618uW+PzykTdWvn8Mm2SMRDvVFtjq5EKg12yg+w9Bo3D9CN+LxPZFTnYHG/CxYC CrOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=rl0JTHNsTIeTp2mMZZUNApN0YPv3NJ5sXJSzsc6PFl8=; b=rRdPNGZJhyd0Vom4iPbO5a+7+29/TRMrLvA42OTddaBHaBgY9L2g6xeUVSljIJE7C/ xBOlVp+KtJcQNMWE0zkN4k44VmuatVO/EZ6dQs7+tJH1L5XtUJ9SkzHdP+yYBApJXqr0 PjA9vrsIBqb8cq59rka8Svot3x3PVVPt9cvTWi6mE0za2JpeX5DoYi0+IBtz2kcEBnnL wkbxR4DMMUsdWJC6C2IHxBy+LARwKZD9ysI/IrMLboGIw/woV+QOEltlp8cQxxH6R2qd kXQxpNjpykaTi4tBN0SPU4ksm1hkbjhSIlXlDW/9/WtDA4SY/eh81IN0GetwEbExoxXW 9PvA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si6738107edy.25.2021.01.11.03.24.45; Mon, 11 Jan 2021 03:25:09 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729720AbhAKLVY (ORCPT + 99 others); Mon, 11 Jan 2021 06:21:24 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:44552 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729564AbhAKLVX (ORCPT ); Mon, 11 Jan 2021 06:21:23 -0500 X-UUID: 32df15a92620427a9bb40d1eadbeb112-20210111 X-UUID: 32df15a92620427a9bb40d1eadbeb112-20210111 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 606885166; Mon, 11 Jan 2021 19:20:41 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 11 Jan 2021 19:20:39 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 11 Jan 2021 19:20:39 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v6 07/33] iommu: Avoid reallocate default domain for a group Date: Mon, 11 Jan 2021 19:18:48 +0800 Message-ID: <20210111111914.22211-8-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210111111914.22211-1-yong.wu@mediatek.com> References: <20210111111914.22211-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); if (group->default_domain) { ret = __iommu_attach_device(group->default_domain, dev); -- 2.18.0