Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2626863ybb; Fri, 27 Mar 2020 09:07:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vta0XJou8nrGFw7ZHUgnEkfmDcGFMFmVzlX4JnuEhA/0wkjgGe6x5HqxWYwYzNEkU+LRkKg X-Received: by 2002:aca:100e:: with SMTP id 14mr4383434oiq.79.1585325220982; Fri, 27 Mar 2020 09:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585325220; cv=none; d=google.com; s=arc-20160816; b=PdasELv+57vhYbT/4xYtqVSmEqzHsA1MHn1PLLNek/Hcv/yPEFD+8I5YW62HcZkH3E KsxLGJNl1k5DUd8ZyRmRiuYBtYeTfTYilrvRZNY/Enh7/9fBorUvWh33McURx8uG1xYc z2X4c1ifQu97HUVz7rB8RhgIJtSmlhq4dHcUT61jzg7QitVcLMW6xN4bPCFX8xmq/oFS 0EcgCHugtK8oHxU02y0fLOND8Aq+AErSoJRmgbWyVCbpsqLju34NgjMT/6suIBD/lqAw MZqx4cH+JXxKCVvqP33PPEtmo+wSareDqLGIhn+o1vhG/WCz36yWhlKI9xidhy39vdNe BaPA== 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:cc:to:subject:dkim-signature; bh=rADClTuM8rDCPwa+pftuZtYBhIX2IPiWqkZ05BPZYE0=; b=EuIl7W68id9PorKdb/Xx5vG8+nmkuzG+vpsA/VQrC4d8RF+jApT/maAPqfiMrwR5hB PqHwBXUbnDGFqM9FBXYzfToj3n2cfnDkyJq623LyP6i/HDpKGSZLKtUC2wGIBxiwBmFz 4Z57EdbkYT0ldAaJNuI0p9BMNzbbdohs3UUzNxfhqWGKuSlLmErw0YiMGrfPXW7NVOmP D8LfOoYtFJAs6QCf0tYKUnmrnXnPU3FhSUniA4KjfNoeQyxZwYcXF0ZFU7dfAiLJne4v e7fWEVxK0Fjbp/brHd88OtT2exouv63reXwDB4jUsLRCMDYW5xEiVGlLFXFg2V9fzmOe cV9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JSlpCw4V; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si2700682otk.128.2020.03.27.09.06.41; Fri, 27 Mar 2020 09:07:00 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JSlpCw4V; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727600AbgC0QGO (ORCPT + 99 others); Fri, 27 Mar 2020 12:06:14 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:42672 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbgC0QGO (ORCPT ); Fri, 27 Mar 2020 12:06:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585325170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rADClTuM8rDCPwa+pftuZtYBhIX2IPiWqkZ05BPZYE0=; b=JSlpCw4VB06QDfm6nFl/AWgn1sohEQ4OEc+rSk558Ro4vZJC9F32OyVpZSrECO8YxUiqVy 4k2fVAR4YGxtfF9/WEKDjSFE3UIj55kcTGRBxFt4xMl6wOAwdFNTWR3b8b96kcTEKBXE1L 3/8R7OIUh1s4bSnANnNrXhOzeSMYrEQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-461-K_ZuWAB8M42Xkd9Far-IRA-1; Fri, 27 Mar 2020 12:06:05 -0400 X-MC-Unique: K_ZuWAB8M42Xkd9Far-IRA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5251A8018A1; Fri, 27 Mar 2020 16:06:03 +0000 (UTC) Received: from [10.36.113.142] (ovpn-113-142.ams2.redhat.com [10.36.113.142]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 957C460304; Fri, 27 Mar 2020 16:05:54 +0000 (UTC) Subject: Re: [PATCH V10 04/11] iommu/vt-d: Use helper function to skip agaw for SL To: "Tian, Kevin" , Jacob Pan , Lu Baolu , "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , David Woodhouse , Alex Williamson , Jean-Philippe Brucker Cc: "Liu, Yi L" , "Raj, Ashok" , Christoph Hellwig , Jonathan Cameron 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> From: Auger Eric Message-ID: <310693c3-9bd2-a764-2053-cd785d329ee6@redhat.com> Date: Fri, 27 Mar 2020 17:05:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks Eric > >> >> pgd_val = virt_to_phys(pgd); >> -- >> 2.7.4 >