From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [PATCH v6 4/5] VT-d: Reduce spin timeout to 1ms, which can be boot-time changed Date: Fri, 4 Mar 2016 01:11:43 +0100 Message-ID: <1457050303.2959.502.camel@citrix.com> References: <1456929089-17414-1-git-send-email-quan.xu@intel.com> <1456929089-17414-5-git-send-email-quan.xu@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6441571260017656631==" Return-path: In-Reply-To: <1456929089-17414-5-git-send-email-quan.xu@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Quan Xu , jbeulich@suse.com, kevin.tian@intel.com Cc: feng.wu@intel.com, jun.nakajima@intel.com, george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, xen-devel@lists.xen.org, stefano.stabellini@citrix.com, suravee.suthikulpanit@amd.com, jinsong.liu@alibaba-inc.com List-Id: xen-devel@lists.xenproject.org --===============6441571260017656631== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-nEybXDwgVnUlAuagty1w" --=-nEybXDwgVnUlAuagty1w Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable [Trimmed the Cc-list a bit again] On Wed, 2016-03-02 at 22:31 +0800, Quan Xu wrote: > Signed-off-by: Quan Xu > =C2=A0 > diff --git a/xen/drivers/passthrough/vtd/qinval.c > b/xen/drivers/passthrough/vtd/qinval.c > index b81b0bd..882b9f4 100644 > --- a/xen/drivers/passthrough/vtd/qinval.c > +++ b/xen/drivers/passthrough/vtd/qinval.c > @@ -28,6 +28,11 @@ > =C2=A0#include "vtd.h" > =C2=A0#include "extern.h" > =C2=A0 > +static unsigned int __read_mostly vtd_qi_timeout =3D 1; > +integer_param("vtd_qi_timeout", vtd_qi_timeout); > + > +#define IOMMU_QI_TIMEOUT (vtd_qi_timeout * MILLISECS(1)) > + > =C2=A0static void print_qi_regs(struct iommu *iommu) > =C2=A0{ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0u64 val; > @@ -130,6 +135,10 @@ static void queue_invalidate_iotlb(struct iommu > *iommu, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0spin_unlock_irqrestore(&iommu->register_loc= k, flags); > =C2=A0} > =C2=A0 > +/* > + * NB. We must check all kinds of error and all the way up the > + * call trees. > + */ > =C2=A0static int queue_invalidate_wait(struct iommu *iommu, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0u8 iflag, u8 sw, u8 fn) > =C2=A0{ > @@ -167,10 +176,12 @@ static int queue_invalidate_wait(struct iommu > *iommu, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0start_time =3D NOW(= ); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0while ( poll_slot != =3D QINVAL_STAT_DONE ) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0{ > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= if ( NOW() > (start_time + DMAR_OPERATION_TIMEOUT) ) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= if ( NOW() > (start_time + IOMMU_QI_TIMEOUT) ) > Since this now involves a time unit conversion, can't we: =C2=A0- instead of start_time, above, compute, once and for all: =C2=A0 =C2=A0 =C2=A0timeout =3D NOW() + IOMMU_QI_TIMEOUT; =C2=A0- check whether ( NOW() > timeout ) I appreciate that the default for=C2=A0vtd_qi_timeout is 1, so it's most likely not that a big deal, but it still looks better to me. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0{ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0print_qi_regs(iommu); > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0panic("queue invalidate wait descriptor was not > executed"); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0printk(XENLOG_WARNING VTDPREFIX > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"Queue in= validate wait descriptor was > timeout.\n"); > "Queue invalidate wait descriptor timed out" =C2=A0? Regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-nEybXDwgVnUlAuagty1w Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEABECAAYFAlbY0r8ACgkQk4XaBE3IOsS9fACgh3jZOq9et+mVVgvIMKIHzrLF qIoAniiDgNAi4Pu+CQsixoDgAZ9kZGX4 =Z7kH -----END PGP SIGNATURE----- --=-nEybXDwgVnUlAuagty1w-- --===============6441571260017656631== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --===============6441571260017656631==--