Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1291156ybb; Sun, 29 Mar 2020 00:39:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvfWlY9TepkztPhZ06NCPR6PqIN/jNRZxUcomElveS4+id7o/TAELh5fKdokZadUp4MXoUF X-Received: by 2002:aca:4a86:: with SMTP id x128mr4294956oia.29.1585467542612; Sun, 29 Mar 2020 00:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585467542; cv=none; d=google.com; s=arc-20160816; b=rwI4llGe0Tw2vbR/rBRj28NLE3aX865OLkVIDfjjuBsADj0tfroWpUMJVREGp8LuXy iogoBmGb5rrF1LYH5WSJ0McWOpnEGPDMjAuzG/cxBesAt2f5uOKEtudWBNh/u6pM5ers ACY2Sz3CUydrvkwIMEpNgJSrTcO6V94a+s/8iNJKVQ8Qk3ezCJBiT0Kck94tFGjT7l0J qGrQaTn5BRfaPBtRxZtdCACzQINZ47OJm/FAmtxy1/4eg9qYRKt5Go3/M/xM8IGAbjoE 9xS/Y9UNEn9N+kR2kOCTWXvcu/yQgeGgKDdtrDLBLPsBA0tKIdFbkOFX91kh47VySpfo CaOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc:ironport-sdr:ironport-sdr; bh=9Tf/jZswhBVIV5ZW+EtnBeoD5ykluqmnOYswOxYePPc=; b=HHglp6DWPTqrSDyyU2l92iLxn44skUWrJ0HTdJ+AEU/QSLPGUVHWEzdOlMUObGB4yR LDp/9BG7NntIIMEsgclLCPvAygSTOcQkGJRBURTe22DCMEmOycQVAHMlPep8H02B7OWP 7km+CQlAxVYONM1e9B/YZDWw5zIGBT5cQmNKoSfRIcDvxJO+2wggMt7UZh/VcQorQr7o DMu8zxohxoEXqlKZpngVhrvA1rEz3L8ZHwpbrtt32II7SzD5nKA+fpXFrtQDrICsSrcn j3Y7CeCMiffaYF7aC3iZigik2tMKiFJQ6F3DRjoyhNX155wzfQ+xuzWYHWPZqk4yQdFg 7i0A== 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 f128si4431780oig.208.2020.03.29.00.38.49; Sun, 29 Mar 2020 00:39:02 -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 S1727503AbgC2Hfx (ORCPT + 99 others); Sun, 29 Mar 2020 03:35:53 -0400 Received: from mga01.intel.com ([192.55.52.88]:11649 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726342AbgC2Hfx (ORCPT ); Sun, 29 Mar 2020 03:35:53 -0400 IronPort-SDR: eB54OcCA0/HKv3ALiPj2Urc2gaqyI2Gn+MYW4E4sX8tPLwfwPzZzVITMK7a39K3iMAkacxardS gGkFh33WzOVg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2020 00:35:53 -0700 IronPort-SDR: FjWvP1xi9YludaFnGgcfP59D58Ut974bJyTxqpEAKHMvjg6Ta2KiTb67BmFIsnsRPHhXaK+dpQ +6rv20iStvdg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,319,1580803200"; d="scan'208";a="358885404" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.210.24]) ([10.254.210.24]) by fmsmga001.fm.intel.com with ESMTP; 29 Mar 2020 00:35:50 -0700 Cc: baolu.lu@linux.intel.com, "Liu, Yi L" , "Raj, Ashok" , Christoph Hellwig , Jonathan Cameron Subject: Re: [PATCH V10 04/11] iommu/vt-d: Use helper function to skip agaw for SL To: Auger Eric , "Tian, Kevin" , Jacob Pan , "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , David Woodhouse , Alex Williamson , Jean-Philippe Brucker References: <1584746861-76386-1-git-send-email-jacob.jun.pan@linux.intel.com> <1584746861-76386-5-git-send-email-jacob.jun.pan@linux.intel.com> <310693c3-9bd2-a764-2053-cd785d329ee6@redhat.com> From: Lu Baolu Message-ID: <527a5b65-e7df-1281-beee-208d156bee01@linux.intel.com> Date: Sun, 29 Mar 2020 15:35:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <310693c3-9bd2-a764-2053-cd785d329ee6@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/3/28 0:05, Auger Eric wrote: > Hi Jacob, > > On 3/27/20 12:55 PM, Tian, Kevin wrote: >>> From: Jacob Pan >>> Sent: Saturday, March 21, 2020 7:28 AM >>> >>> 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"); > is the dev_err() really requested. I see in domain_setup_first_level(), > there is none. >>> + return -EINVAL; >>> } >> ok, I see how it is used. possibly combine last and this one together since >> it's mostly moving code... > I tend to agree with Kevin. May be better squash the 2 patches. Also not > sure the inline of iommu_skip_agaw() is meaningful then. Also Add commit > messages on the resulting patch. > > Note domain_setup_first_level() also could use the helper while we are > it (if declaration moved to common helper). Only the error code differs > in case !dma_pte_present(pgd), ie. -ENOMEM. May be good to align. > > Otherwise those stuff may be done in a fixup patch. Agreed. Will squash these 2 patches with a meaningful commit message. As for using this helper in other files, like domain_setup_first_level(), we need more review and test efforts, hence it's better to put it in a followup patch. Best regards, baolu