From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpq8a-0003Y4-6w for qemu-devel@nongnu.org; Fri, 30 Sep 2016 01:13:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpq8V-0003GY-V7 for qemu-devel@nongnu.org; Fri, 30 Sep 2016 01:13:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpq8V-0003GE-PK for qemu-devel@nongnu.org; Fri, 30 Sep 2016 01:13:27 -0400 Date: Fri, 30 Sep 2016 13:13:20 +0800 From: Peter Xu Message-ID: <20160930051320.GM11134@pxdev.xzpeter.org> References: <20160929112329.2408-1-rkrcmar@redhat.com> <20160929112329.2408-6-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160929112329.2408-6-rkrcmar@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 5/7] intel-iommu: add OnOffAuto intr_eim as "eim" property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Radim =?utf-8?B?S3LEjW3DocWZ?= Cc: qemu-devel@nongnu.org, Igor Mammedov , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" On Thu, Sep 29, 2016 at 01:23:27PM +0200, Radim Kr=C4=8Dm=C3=A1=C5=99 wro= te: > The default (auto) emulates the current behavior. >=20 > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 > --- > hw/i386/intel_iommu.c | 20 +++++++++++++++++++- > include/hw/i386/intel_iommu.h | 1 + > 2 files changed, 20 insertions(+), 1 deletion(-) >=20 > diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c > index eb488c14625d..47141cea64f4 100644 > --- a/hw/i386/intel_iommu.c > +++ b/hw/i386/intel_iommu.c > @@ -2011,6 +2011,8 @@ static const MemoryRegionOps vtd_mem_ops =3D { > =20 > static Property vtd_properties[] =3D { > DEFINE_PROP_UINT32("version", IntelIOMMUState, version, 0), > + DEFINE_PROP_ON_OFF_AUTO("eim", IntelIOMMUState, intr_eim, > + ON_OFF_AUTO_AUTO), > DEFINE_PROP_END_OF_LIST(), > }; > =20 > @@ -2367,7 +2369,11 @@ static void vtd_init(IntelIOMMUState *s) > s->ecap =3D VTD_ECAP_QI | VTD_ECAP_IRO; > =20 > if (x86_iommu->intr_supported) { > - s->ecap |=3D VTD_ECAP_IR | VTD_ECAP_EIM | VTD_ECAP_MHMV; > + s->ecap |=3D VTD_ECAP_IR | VTD_ECAP_MHMV; > + if (s->intr_eim =3D=3D ON_OFF_AUTO_ON) { > + s->ecap |=3D VTD_ECAP_EIM; > + } > + assert(s->intr_eim !=3D ON_OFF_AUTO_AUTO); > } > =20 > vtd_reset_context_cache(s); > @@ -2466,6 +2472,18 @@ static void vtd_realize(DeviceState *dev, Error = **errp) > exit(1); > } > =20 > + if (s->intr_eim =3D=3D ON_OFF_AUTO_ON && !x86_iommu->intr_supporte= d) { > + error_report("intel-iommu,eim=3Don cannot be selected without = " > + "intremap=3Don."); > + exit(1); > + } > + if (s->intr_eim =3D=3D ON_OFF_AUTO_AUTO && !x86_iommu->intr_suppor= ted) { > + s->intr_eim =3D ON_OFF_AUTO_OFF; > + } > + if (s->intr_eim =3D=3D ON_OFF_AUTO_AUTO) { > + s->intr_eim =3D ON_OFF_AUTO_ON; > + } A single if() instead of above two might be nicer: if (s->intr_eim =3D=3D ON_OFF_AUTO_AUTO) { e->intr_eim =3D x86_iommu->intr_supported ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; } Otherwise good to me. Thanks, -- peterx