Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1243329ybb; Fri, 20 Mar 2020 16:23:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsWDmigm04p0hhJG+yPdlB2Vf35O5P4eF9NSGmecMrzi2aEUHa+8xILzCvZ9C6dKMrmmh4/ X-Received: by 2002:aca:d50f:: with SMTP id m15mr9018228oig.19.1584746621800; Fri, 20 Mar 2020 16:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584746621; cv=none; d=google.com; s=arc-20160816; b=j1eb2B99erkAYCA20suT2c1ru5/npQMPlUyvxnTLHHp6URFfyZN0oPhKFYtfnP2roR Q02gMXBSVmc5utKB3xXHB3lL5MK6ITI9IoYeuzDcq7ZmrQI25suRtXCGfYeXQJyxJ8HT JYfLnCAAnIRosC0T1BEZrCjP4hXWhjDBkCqrinNjqZpeHA5OnAPxcacJ1ZvMnxEtpECK msqWfyc5dr6fIdb868PGwdz+n2s4a5XQmqOKwZ1NGh4JWjymlWIg/HjiNVaJJj+CzEDA IAi0fOZqo4V3uZgU5ubx7AfOrudTWYuk/MwoM5TYpHXCWQBTQ3jwkbX/Lgq+6SvphLOL Lchg== 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:ironport-sdr:ironport-sdr; bh=4ctilej1Z72BMExSNmwsmAoGavJBJWFW6vNYkAqCV8s=; b=o3vWn5q5vHaj6Co1MsPHrFZ3rHxVZkc7D132+Q0/sY7HSsXoIB8yUwEJd10iefRepO QM46DRp4Y3o2PkNLR3LktiAz/neDc7mPOpLoNzf3ypJkoeBgml1dM2IhKjECEhZkBOSg UeZ281FZWbh47LBLPG4NJmn5f9Rb3AZlqUWweec4X6VnRYwqVkKDBzs8DrXbxX1aUZ6l Vw2IzL9nokU7VlzkwFYcdNVxB/Umm5gziETBOJAFktmEaqIVf1F6987lN/eDjVEQ/NZG uNpxYoBxxDNoEzcg3tvDwhuvbbQwtLoWQ+Tf7n4ml/Dq58llVywNd673lenu8UblHQJw kt7A== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l17si3885223otj.14.2020.03.20.16.23.29; Fri, 20 Mar 2020 16:23:41 -0700 (PDT) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727732AbgCTXWc (ORCPT + 99 others); Fri, 20 Mar 2020 19:22:32 -0400 Received: from mga18.intel.com ([134.134.136.126]:42259 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727415AbgCTXWC (ORCPT ); Fri, 20 Mar 2020 19:22:02 -0400 IronPort-SDR: iipT0ZxzD394PgMHsImpWUzAmRyItrA+CFNda8fVVvzPEK1zpwgrGkhnKm489T8FhLIr6N+7OR oiTcAZHIQwMw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2020 16:22:01 -0700 IronPort-SDR: sFqZaL8OHLTqINBQ8R4AfRkHxYiK58VJg4zXN5l0QpKwK2U64koOB4ZwUyF92xUe1eVcokkofF i01FrZlFbm6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,286,1580803200"; d="scan'208";a="418877231" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga005.jf.intel.com with ESMTP; 20 Mar 2020 16:22:01 -0700 From: Jacob Pan To: "Lu Baolu" , iommu@lists.linux-foundation.org, LKML , Joerg Roedel , David Woodhouse , Alex Williamson , Jean-Philippe Brucker Cc: "Yi Liu" , "Tian, Kevin" , Raj Ashok , "Christoph Hellwig" , Jonathan Cameron , Eric Auger , Jacob Pan Subject: [PATCH V10 04/11] iommu/vt-d: Use helper function to skip agaw for SL Date: Fri, 20 Mar 2020 16:27:34 -0700 Message-Id: <1584746861-76386-5-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584746861-76386-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1584746861-76386-1-git-send-email-jacob.jun.pan@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Jacob Pan --- drivers/iommu/intel-pasid.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/intel-pasid.c b/drivers/iommu/intel-pasid.c index 191508c7c03e..9bdb7ee228b6 100644 --- a/drivers/iommu/intel-pasid.c +++ b/drivers/iommu/intel-pasid.c @@ -544,17 +544,11 @@ int intel_pasid_setup_second_level(struct intel_iommu *iommu, return -EINVAL; } - /* - * Skip top levels of page tables for iommu which has less agaw - * than default. Unnecessary for PT mode. - */ pgd = domain->pgd; - for (agaw = domain->agaw; agaw > iommu->agaw; agaw--) { - pgd = phys_to_virt(dma_pte_addr(pgd)); - if (!dma_pte_present(pgd)) { - dev_err(dev, "Invalid domain page table\n"); - return -EINVAL; - } + agaw = iommu_skip_agaw(domain, iommu, &pgd); + if (agaw < 0) { + dev_err(dev, "Invalid domain page table\n"); + return -EINVAL; } pgd_val = virt_to_phys(pgd); -- 2.7.4