From nobody Mon Feb 9 06:49:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486382267656160.16096368289232; Mon, 6 Feb 2017 03:57:47 -0800 (PST) Received: from localhost ([::1]:46903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahvW-00080p-F5 for importer@patchew.org; Mon, 06 Feb 2017 06:57:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahtc-0006mL-O4 for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:55:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahtZ-00043g-NF for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:55:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahtZ-000438-Fi for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:55:45 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 54E5D7E9D5 for ; Mon, 6 Feb 2017 11:55:45 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16BtiFj022039; Mon, 6 Feb 2017 06:55:44 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id C39828092B; Mon, 6 Feb 2017 12:55:42 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:55:38 +0100 Message-Id: <1486382139-30630-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1486382139-30630-1-git-send-email-kraxel@redhat.com> References: <1486382139-30630-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 06 Feb 2017 11:55:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/4] xhci: fix nec vendor quirk handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Only the TYPE_NEC_XHCI controller will have the nec vendor quirks. Signed-off-by: Gerd Hoffmann --- hw/usb/hcd-xhci.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 887bb39..0e25943 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -485,6 +485,8 @@ struct XHCIState { XHCIInterrupter intr[MAXINTRS]; =20 XHCIRing cmd_ring; + + bool nec_quirks; }; =20 #define TYPE_XHCI "base-xhci" @@ -2737,20 +2739,26 @@ static void xhci_process_commands(XHCIState *xhci) xhci_via_challenge(xhci, trb.parameter); break; case CR_VENDOR_NEC_FIRMWARE_REVISION: - event.type =3D 48; /* NEC reply */ - event.length =3D 0x3025; + if (xhci->nec_quirks) { + event.type =3D 48; /* NEC reply */ + event.length =3D 0x3025; + } else { + event.ccode =3D CC_TRB_ERROR; + } break; case CR_VENDOR_NEC_CHALLENGE_RESPONSE: - { - uint32_t chi =3D trb.parameter >> 32; - uint32_t clo =3D trb.parameter; - uint32_t val =3D xhci_nec_challenge(chi, clo); - event.length =3D val & 0xFFFF; - event.epid =3D val >> 16; - slotid =3D val >> 24; - event.type =3D 48; /* NEC reply */ - } - break; + if (xhci->nec_quirks) { + uint32_t chi =3D trb.parameter >> 32; + uint32_t clo =3D trb.parameter; + uint32_t val =3D xhci_nec_challenge(chi, clo); + event.length =3D val & 0xFFFF; + event.epid =3D val >> 16; + slotid =3D val >> 24; + event.type =3D 48; /* NEC reply */ + } else { + event.ccode =3D CC_TRB_ERROR; + } + break; default: trace_usb_xhci_unimplemented("command", type); event.ccode =3D CC_TRB_ERROR; @@ -3252,9 +3260,12 @@ static void xhci_runtime_write(void *ptr, hwaddr reg, intr->erstsz =3D val & 0xffff; break; case 0x10: /* ERSTBA low */ - /* XXX NEC driver bug: it doesn't align this to 64 bytes - intr->erstba_low =3D val & 0xffffffc0; */ - intr->erstba_low =3D val & 0xfffffff0; + if (xhci->nec_quirks) { + /* NEC driver bug: it doesn't align this to 64 bytes */ + intr->erstba_low =3D val & 0xfffffff0; + } else { + intr->erstba_low =3D val & 0xffffffc0; + } break; case 0x14: /* ERSTBA high */ intr->erstba_high =3D val; @@ -3549,6 +3560,9 @@ static void usb_xhci_realize(struct PCIDevice *dev, E= rror **errp) dev->config[PCI_CACHE_LINE_SIZE] =3D 0x10; dev->config[0x60] =3D 0x30; /* release number */ =20 + if (strcmp(object_get_typename(OBJECT(dev)), TYPE_NEC_XHCI) =3D=3D 0) { + xhci->nec_quirks =3D true; + } if (xhci->numintrs > MAXINTRS) { xhci->numintrs =3D MAXINTRS; } --=20 1.8.3.1