From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O7OME-0003Vb-QW for qemu-devel@nongnu.org; Thu, 29 Apr 2010 03:40:27 -0400 Received: from [140.186.70.92] (port=39060 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O7OM9-0003VB-Sf for qemu-devel@nongnu.org; Thu, 29 Apr 2010 03:40:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O7OM7-0001AY-TX for qemu-devel@nongnu.org; Thu, 29 Apr 2010 03:40:21 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:59481) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O7OM7-000188-IR for qemu-devel@nongnu.org; Thu, 29 Apr 2010 03:40:19 -0400 Message-ID: <4BD937CF.9080700@web.de> Date: Thu, 29 Apr 2010 09:39:59 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1272217710-28120-1-git-send-email-daahern@cisco.com> <1272217710-28120-2-git-send-email-daahern@cisco.com> In-Reply-To: <1272217710-28120-2-git-send-email-daahern@cisco.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigFB464E968C7DC95339535A66" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH] Improve detection of invalid entries in the async schedule List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Ahern Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigFB464E968C7DC95339535A66 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable David Ahern wrote: > Signed-off-by: David Ahern Thanks, merged (with a tiny cleanup). Jan > --- > hw/usb-ehci.c | 41 +++++++++++++++++++++++++++++------------ > 1 files changed, 29 insertions(+), 12 deletions(-) >=20 > diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c > index 29baf74..e2f8e54 100644 > --- a/hw/usb-ehci.c > +++ b/hw/usb-ehci.c > @@ -144,7 +144,7 @@ > #define NB_MAXINTRATE 8 // Max rate at which controller issu= es ints > #define NB_PORTS 4 // Number of downstream ports > #define BUFF_SIZE 5*4096 // Max bytes to transfer per transac= tion > -#define MAX_ITERATIONS 50 // Max number of states before we ab= ort > +#define MAX_ITERATIONS 20 // Max number of QH before we break = the loop > #define MAX_QH 100 // Max allowable queue heads in a ch= ain > =20 > /* Internal periodic / asynchronous schedule state machine states > @@ -1319,6 +1319,11 @@ static int ehci_state_fetchentry(EHCIState *ehci= , int async, int *state) > } > } > #endif > + if (entry < 0x1000) { > + DPRINTF("fetchentry: entry invalid (0x%08x)\n", entry); > + *state =3D EST_ACTIVE; > + goto out; > + } > =20 > /* section 4.8, only QH in async schedule */ > if (async && (NLPTR_TYPE_GET(entry) !=3D NLPTR_TYPE_QH)) { > @@ -1348,6 +1353,7 @@ static int ehci_state_fetchentry(EHCIState *ehci,= int async, int *state) > return -1; > } > =20 > +out: > return again; > } > =20 > @@ -1394,7 +1400,7 @@ static int ehci_state_fetchqh(EHCIState *ehci, in= t async, int *state) > *state =3D EST_HORIZONTALQH; > again =3D 1; > =20 > - } else if (qh->token & QTD_TOKEN_ACTIVE) { > + } else if ((qh->token & QTD_TOKEN_ACTIVE) && (qh->current_qtd > 0x= 1000)) { > DPRINTF_ST("FETCHQH: Active, !Halt, execute - fetch qTD\n"); > ehci->qtdaddr =3D qh->current_qtd; > *state =3D EST_FETCHQTD; > @@ -1499,10 +1505,17 @@ static int ehci_state_fetchqtd(EHCIState *ehci,= int async, int *state) > =20 > static int ehci_state_horizqh(EHCIState *ehci, int async, int *state) > { > - ehci->fetch_addr =3D ehci->qh.next; > - *state =3D EST_FETCHENTRY; > + int again =3D 0; > =20 > - return 1; > + if (ehci->fetch_addr !=3D ehci->qh.next) { > + ehci->fetch_addr =3D ehci->qh.next; > + *state =3D EST_FETCHENTRY; > + again =3D 1; > + } else { > + *state =3D EST_ACTIVE; > + } > + > + return again; > } > =20 > static int ehci_state_execute(EHCIState *ehci, int async, int *state) > @@ -1682,11 +1695,17 @@ static int ehci_advance_state(EHCIState *ehci, > int iter =3D 0; > =20 > do { > - iter++; > - if (iter > MAX_ITERATIONS) { > - DPRINTF("\n*** advance_state: bailing on MAX ITERATIONS***= \n\n");=20 > - state =3D EST_ACTIVE; > - break; > + if (state =3D=3D EST_FETCHQH) { > + iter++; > + /* if we are roaming a lot of QH without executing a qTD > + * something is wrong with the linked list. TO-DO: why is > + * this hack needed? > + */ > + if (iter > MAX_ITERATIONS) { > + DPRINTF("\n*** advance_state: bailing on MAX ITERATION= S***\n");=20 > + state =3D EST_ACTIVE; > + break; > + } > } > switch(state) { > case EST_WAITLISTHEAD: > @@ -1723,12 +1742,10 @@ static int ehci_advance_state(EHCIState *ehci, > break; > =20 > case EST_EXECUTING: > - iter =3D 0; > again =3D ehci_state_executing(ehci, async, &state); > break; > =20 > case EST_WRITEBACK: > - iter =3D 0; > again =3D ehci_state_writeback(ehci, async, &state); > break; > =20 --------------enigFB464E968C7DC95339535A66 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkvZN9MACgkQitSsb3rl5xSfQACgswjywQgfrWRmOdGkjRGtN88G KygAn1zQdix/rBq7toI0OQsYHQusXu97 =cUdM -----END PGP SIGNATURE----- --------------enigFB464E968C7DC95339535A66--