Received: from eggs.gnu.org ([2001:4830:134:3::10]:49930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bevfs-0005Ve-Sk for qemu-devel@nongnu.org; Tue, 30 Aug 2016 22:54:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bevfn-0006Kc-Sz for qemu-devel@nongnu.org; Tue, 30 Aug 2016 22:54:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bevfn-0006KY-LI for qemu-devel@nongnu.org; Tue, 30 Aug 2016 22:54:43 -0400 References: <1472526419-5900-1-git-send-email-jasowang@redhat.com> <1472526419-5900-7-git-send-email-jasowang@redhat.com> <20160830131611.GB13644@pxdev.xzpeter.org> From: Jason Wang Message-ID: Date: Wed, 31 Aug 2016 10:54:36 +0800 MIME-Version: 1.0 In-Reply-To: <20160830131611.GB13644@pxdev.xzpeter.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for 2.8 06/11] intel_iommu: support device iotlb descriptor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu Cc: mst@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com, cornelia.huck@de.ibm.com, wexu@redhat.com, vkaplans@redhat.com, Richard Henderson , Eduardo Habkost On 2016=E5=B9=B408=E6=9C=8830=E6=97=A5 21:16, Peter Xu wrote: > On Tue, Aug 30, 2016 at 11:06:54AM +0800, Jason Wang wrote: >> This patch enables device IOTLB support for intel iommu. The major >> work is to implement QI device IOTLB descriptor processing and notify >> the device through iommu notifier. > IMHO it'll be nicer if we can mention the new bit in the commit > message, like: > > One new property "device-iotlb" is introduced to enable device > IOTLB capability for VT-d IOMMU device. By default, it is turned > off. To enable it: > > -device intel-iommu,device-iotlb=3Don > > [...] Yes, this looks better. > >> +static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s, >> + VTDInvDesc *inv_desc) >> +{ > [...] > >> + entry.target_as =3D &vtd_dev_as->as; >> + entry.addr_mask =3D sz - 1; >> + entry.iova =3D addr; > Do we need to setup translated_addr and perm fields as well? > > [...] Good question, tough vhost does not care about those two fileds now (we=20 only care about invalidation). But I think it's better to add them, it=20 may be used in the future (e.g CM which may also depends on notifier). > >> diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c >> index ce26b2a..a70a363 100644 >> --- a/hw/i386/x86-iommu.c >> +++ b/hw/i386/x86-iommu.c >> @@ -100,6 +100,18 @@ static void x86_iommu_intremap_prop_set(Object *o= , bool value, Error **errp) >> s->intr_supported =3D value; >> } >> =20 >> +static bool x86_iommu_device_iotlb_prop_get(Object *o, Error **errp) >> +{ >> + X86IOMMUState *s =3D X86_IOMMU_DEVICE(o); >> + return s->dt_supported; >> +} >> + >> +static void x86_iommu_device_iotlb_prop_set(Object *o, bool value, Er= ror **errp) >> +{ >> + X86IOMMUState *s =3D X86_IOMMU_DEVICE(o); >> + s->dt_supported =3D value; >> +} >> + >> static void x86_iommu_instance_init(Object *o) >> { >> X86IOMMUState *s =3D X86_IOMMU_DEVICE(o); >> @@ -108,6 +120,11 @@ static void x86_iommu_instance_init(Object *o) >> s->intr_supported =3D false; >> object_property_add_bool(o, "intremap", x86_iommu_intremap_prop_= get, >> x86_iommu_intremap_prop_set, NULL); >> + s->dt_supported =3D false; >> + object_property_add_bool(o, "device_iotlb", >> + x86_iommu_device_iotlb_prop_get, >> + x86_iommu_device_iotlb_prop_set, >> + NULL); > Nit 1: use "device-iotlb" instead of "device_iotlb"? Yes. > Nit 2: use Property bit (like vtd_properties)? Not sure, I thought this may be reused by AMD IOMMU but maybe I was wrong= . > > Thanks, > > -- peterx