Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2307862ybx; Fri, 8 Nov 2019 02:34:49 -0800 (PST) X-Google-Smtp-Source: APXvYqxcS1FC/kxxHXaEGSzdUm3nkOa5DaEokQZYbtCH/RsgSlrlsoI3V+IOekHHqjP9VBQ1j4CQ X-Received: by 2002:a50:9713:: with SMTP id c19mr9268131edb.206.1573209289346; Fri, 08 Nov 2019 02:34:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573209289; cv=none; d=google.com; s=arc-20160816; b=Oh4Mrg2wj3mkUGPCowFv/BtKx0jOsjo4+1rqiHtzaBtQz9NQ/ur/hgLBNSTB9WLFg1 uhWeEl6EtSKzGKmHCjGsKvd/8K12qDzRVk5N6enF4rWlHshohLyc0Fv1YujbKFZkwv2Y YirHHksUb62tLBRdKU4BbAg/GwwrbcCZ7WfEGQopJpDvqNYdb2eUqmRDPgeVnHvvI0UK AvuLVEE01QN/iOUC+oTQGUmhI/tZr88fm1NJ9lgy0zoyhSLds94MLAFBoIXBJbCoWULr 3b6rF3IEhzsXi7bHG5ms4dZsP6HdzUFjTvV/zh3yXfPw7OlokHCKALZOxJx0urQSOXyn ievg== 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:references:cc:to:subject:from:dkim-signature; bh=GJIemJ28V7SlVdwM6PWNhep+T2p/t4Izn4GDnmEe/tw=; b=DC0zxcZkVFn3YwR79KQiezjzornAWYfYTNe8rO0MWoC3b9S4qvTNjCdyOEzQ62VvOx cB4ApMUhCfyFDqKgk/5DivoYKv5P5LgJROgDuUf9NO2ZUrH+AkZ3wH1YBHbdgnFqNzDQ oQuh9zlCere6PHJ8e2xQZPUjaXb4hCjtbFgwT8272N+k4uOVv20FyDis9y8ieyn74z55 vxOtc3Cd9lbONgQIs9e0rB9k5kShj+x11qdeTVr37wOeBT2C927MgVdzJ1OA2ELoSw72 ZEVxs1pI0Yx6XEvN3kij9NcqQVpSK30FKqnajkwZe9AO9XJKOnIgroPudogqkne/wNep SDgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UcenVrjz; 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 r20si3468562edm.17.2019.11.08.02.34.25; Fri, 08 Nov 2019 02:34:49 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UcenVrjz; 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 S1731685AbfKHKdD (ORCPT + 99 others); Fri, 8 Nov 2019 05:33:03 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:46996 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731656AbfKHKdC (ORCPT ); Fri, 8 Nov 2019 05:33:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573209182; 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=GJIemJ28V7SlVdwM6PWNhep+T2p/t4Izn4GDnmEe/tw=; b=UcenVrjzlY4xcfplDTmN7ODuVN19AxU1j5VE2fUWjxQ6NsLYvClZjurgVbxjNf2e1uvFoa N8ZlV2HtqXN3Xb5bSHK8knHGLWsgBwVh2zsx72FsiC9gnIMzbS6on9UHDDVnJoAr6WMaJ7 YCRk/qDhG52F6UQW+qpeUHObadf+Cp4= 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-385-aPiaQ9JyNAWA4YQ0AdCh0w-1; Fri, 08 Nov 2019 05:32:58 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4195D800C72; Fri, 8 Nov 2019 10:32:56 +0000 (UTC) Received: from [10.36.116.54] (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F2931A8D8; Fri, 8 Nov 2019 10:32:53 +0000 (UTC) From: Auger Eric Subject: Re: [PATCH v7 01/11] iommu/vt-d: Cache virtual command capability register To: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Joerg Roedel , David Woodhouse , Alex Williamson , Jean-Philippe Brucker Cc: Yi Liu , "Tian, Kevin" , Raj Ashok , Christoph Hellwig , Lu Baolu , Jonathan Cameron References: <1571946904-86776-1-git-send-email-jacob.jun.pan@linux.intel.com> <1571946904-86776-2-git-send-email-jacob.jun.pan@linux.intel.com> Message-ID: Date: Fri, 8 Nov 2019 11:32:51 +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: <1571946904-86776-2-git-send-email-jacob.jun.pan@linux.intel.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: aPiaQ9JyNAWA4YQ0AdCh0w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacob, On 10/24/19 9:54 PM, Jacob Pan wrote: > Virtual command registers are used in the guest only, to prevent > vmexit cost, we cache the capability and store it during initialization. >=20 > Signed-off-by: Jacob Pan > --- > drivers/iommu/dmar.c | 1 + > include/linux/intel-iommu.h | 4 ++++ > 2 files changed, 5 insertions(+) >=20 > diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c > index eecd6a421667..49bb7d76e646 100644 > --- a/drivers/iommu/dmar.c > +++ b/drivers/iommu/dmar.c > @@ -950,6 +950,7 @@ static int map_iommu(struct intel_iommu *iommu, u64 p= hys_addr) > =09=09warn_invalid_dmar(phys_addr, " returns all ones"); > =09=09goto unmap; > =09} > +=09iommu->vccap =3D dmar_readq(iommu->reg + DMAR_VCCAP_REG); > =20 > =09/* the registers might be more than one page */ > =09map_size =3D max_t(int, ecap_max_iotlb_offset(iommu->ecap), > diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h > index ed11ef594378..2e1bed9b7eef 100644 > --- a/include/linux/intel-iommu.h > +++ b/include/linux/intel-iommu.h > @@ -186,6 +186,9 @@ > #define ecap_max_handle_mask(e) ((e >> 20) & 0xf) > #define ecap_sc_support(e)=09((e >> 7) & 0x1) /* Snooping Control */ > =20 > +/* Virtual command interface capabilities */ > +#define vccap_pasid(v)=09=09((v & DMA_VCS_PAS)) /* PASID allocation */ > + > /* IOTLB_REG */ > #define DMA_TLB_FLUSH_GRANU_OFFSET 60 > #define DMA_TLB_GLOBAL_FLUSH (((u64)1) << 60) > @@ -520,6 +523,7 @@ struct intel_iommu { > =09u64=09=09reg_size; /* size of hw register set */ > =09u64=09=09cap; > =09u64=09=09ecap; > +=09u64=09=09vccap; > =09u32=09=09gcmd; /* Holds TE, EAFL. Don't need SRTP, SFL, WBF */ > =09raw_spinlock_t=09register_lock; /* protect register handling */ > =09int=09=09seq_id;=09/* sequence id of the iommu */ >=20 with DMA_VCS_PAS's move in this patch as pointed out by Kevin or vccap_pasid() move to patch 3, feel free to add Reviewed-by: Eric Auger Eric