Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5073402ybv; Mon, 17 Feb 2020 11:41:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyFxIp7rpryc0kdoIetraz6OJslw6iwWWxOKzxGiYgxC4h5Xo1wVJdpMM66EjFrVMNW43fk X-Received: by 2002:aca:b60a:: with SMTP id g10mr374315oif.102.1581968463446; Mon, 17 Feb 2020 11:41:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581968463; cv=none; d=google.com; s=arc-20160816; b=P/eqqer31CFLPb4bstbWGYkEeXv3eJyg4VaKR3swP2sn/57iO/M6Z19qEl+ehnaGlo Po3iOczsZoslXN+t0BBvyM6+G8TECpkPxSA8ynfwe8X0bCgZZ+myqXhvciGXNtyKgmSh KK6IBoYS0oUkqSXPjig2gu4D0No2CLEnpLDC0xXq2BUMRoct7qaOGc/v4GbaRwp3YVEx qdDrfQ5rtEvAJK6TWWjCfXsS4irIaS3BhMqbENLn5WRBQomo++eWelcFE+NORLfYR5z+ uSePsx/VHZxBtqYVW6+zMdM05AmRRiuAq+uiX/X/v78dLJ+MOKFoPx0Wb7kZMA1qfs2A bFsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=uyVkgxlSVR438sKKp3c8M7jgOEwbR3qoj2OOCZ2TDdY=; b=UrR3KaTnUPmHsQognFKBDZ8RpenotJKceNwtihg0xdJooYS06HGjdQLgBkfl1YOMuw hit/hJbjzkEbDAWwVUWOerCRcgFLALD9Ha0JwPo/S6q0pu0U7xwTB4ctUtWB13Mt0IGU m6w6ixTEE6HlkN3B0Gbg+Mpwaak4s+DOrSkSAJT8LxRXXohsFH15zhvm5uj4pgIveXwJ eK0L8pfipp7pkXNDwx2Nz1z93pQ7vcIltGK69v/Wbbkr1dq8HK2iB1WhwVNkD2hpDD54 UBb6p9L+CNJ1Lr7Jo1DAOcXpW951RbGWbK095Rn8GOEt+mThkkv9CE3sCKoQyBHbAcLo ZzAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si566754otq.217.2020.02.17.11.40.51; Mon, 17 Feb 2020 11:41:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729478AbgBQTjJ (ORCPT + 99 others); Mon, 17 Feb 2020 14:39:09 -0500 Received: from 8bytes.org ([81.169.241.247]:54508 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726781AbgBQTjI (ORCPT ); Mon, 17 Feb 2020 14:39:08 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id BE1CF28C; Mon, 17 Feb 2020 20:39:06 +0100 (CET) From: Joerg Roedel To: Lu Baolu , David Woodhouse Cc: Joerg Roedel , jroedel@suse.de, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] iommu/vt-d: Add attach_deferred() helper Date: Mon, 17 Feb 2020 20:38:54 +0100 Message-Id: <20200217193858.26990-2-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217193858.26990-1-joro@8bytes.org> References: <20200217193858.26990-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Implement a helper function to check whether a device's attach process is deferred. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 9dc37672bf89..80f2332a5466 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -762,6 +762,11 @@ static int iommu_dummy(struct device *dev) return dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO; } +static bool attach_deferred(struct device *dev) +{ + return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO; +} + /** * is_downstream_to_pci_bridge - test if a device belongs to the PCI * sub-hierarchy of a candidate PCI-PCI bridge @@ -2510,8 +2515,7 @@ struct dmar_domain *find_domain(struct device *dev) { struct device_domain_info *info; - if (unlikely(dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO || - dev->archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)) + if (unlikely(attach_deferred(dev) || iommu_dummy(dev))) return NULL; if (dev_is_pci(dev)) @@ -2527,7 +2531,7 @@ struct dmar_domain *find_domain(struct device *dev) static struct dmar_domain *deferred_attach_domain(struct device *dev) { - if (unlikely(dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO)) { + if (unlikely(attach_deferred(dev))) { struct iommu_domain *domain; dev->archdata.iommu = NULL; @@ -6133,7 +6137,7 @@ intel_iommu_aux_get_pasid(struct iommu_domain *domain, struct device *dev) static bool intel_iommu_is_attach_deferred(struct iommu_domain *domain, struct device *dev) { - return dev->archdata.iommu == DEFER_DEVICE_DOMAIN_INFO; + return attach_deferred(dev); } static int -- 2.17.1