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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB49DC433F5 for ; Mon, 16 May 2022 02:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239321AbiEPCBz (ORCPT ); Sun, 15 May 2022 22:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239284AbiEPCBd (ORCPT ); Sun, 15 May 2022 22:01:33 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43DDE13CC8 for ; Sun, 15 May 2022 19:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652666488; x=1684202488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3Hgd203HC0g1TyuguE1zfaQq4/xIrHOAw15KA4w3UCI=; b=QoL5oRg1QK9im9fU54zVQ6CpArV2ppg8t5DrLYTreMM56e+Wsz/a7tJV OoriwvPrhuMKbLvNWLUbBrbqdRaZ5ucvkj/XpPL0dxgCBGEmXllfl+tH3 R62XSSuwVpjws09MRh2XsZg/nrkoy96M/P4KpiRzFdmxmUrJiyBWEADEa ZOpEXpcY5oed7L+Z+b1EhARtD8WrhnTMkQequYNNiTmHiPPplq3YzBB/N nL+vLMFAI7ujJDIPE3z6GmFiv2QTBQrCGm8KFxl9M+Qr5f7ggEvpE9f+Y JEmHUBejBe6y7uzq8/sTrVElOvrnYSVw1G+jZ/b0a9WbioEHQSkIoj50J A==; X-IronPort-AV: E=McAfee;i="6400,9594,10348"; a="270659018" X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="270659018" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2022 19:01:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,229,1647327600"; d="scan'208";a="713172191" Received: from allen-box.sh.intel.com ([10.239.159.48]) by fmsmga001.fm.intel.com with ESMTP; 15 May 2022 19:01:24 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Jean-Philippe Brucker Cc: Eric Auger , Liu Yi L , Jacob jun Pan , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 4/5] iommu: Use blocking domain for empty domain attaching Date: Mon, 16 May 2022 09:57:58 +0800 Message-Id: <20220516015759.2952771-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220516015759.2952771-1-baolu.lu@linux.intel.com> References: <20220516015759.2952771-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a NULL domain is about to set to a device, let's set the blocking domain instead. Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index dcbc55c9d8d7..ba0f427c2823 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2058,16 +2058,6 @@ int iommu_deferred_attach(struct device *dev, struct iommu_domain *domain) return 0; } -static void __iommu_detach_device(struct iommu_domain *domain, - struct device *dev) -{ - if (iommu_is_attach_deferred(dev)) - return; - - domain->ops->detach_dev(domain, dev); - trace_detach_device_from_domain(dev); -} - void iommu_detach_device(struct iommu_domain *domain, struct device *dev) { struct iommu_group *group; @@ -2160,15 +2150,6 @@ int iommu_attach_group(struct iommu_domain *domain, struct iommu_group *group) } EXPORT_SYMBOL_GPL(iommu_attach_group); -static int iommu_group_do_detach_device(struct device *dev, void *data) -{ - struct iommu_domain *domain = data; - - __iommu_detach_device(domain, dev); - - return 0; -} - static int __iommu_group_set_domain(struct iommu_group *group, struct iommu_domain *new_domain) { @@ -2177,19 +2158,9 @@ static int __iommu_group_set_domain(struct iommu_group *group, if (group->domain == new_domain) return 0; - /* - * New drivers should support default domains and so the detach_dev() op - * will never be called. Otherwise the NULL domain represents some - * platform specific behavior. - */ - if (!new_domain) { - if (WARN_ON(!group->domain->ops->detach_dev)) - return -EINVAL; - __iommu_group_for_each_dev(group, group->domain, - iommu_group_do_detach_device); - group->domain = NULL; - return 0; - } + /* The NULL domain represents some platform specific behavior. */ + if (!new_domain) + new_domain = group->blocking_domain; /* * Changing the domain is done by calling set_dev() on the new -- 2.25.1