From 6f2302d279a7dc8c31e7bae29eee66e95743b74e Mon Sep 17 00:00:00 2001 From: Robert Mustacchi Date: Sat, 27 May 2017 21:07:48 +0000 Subject: [PATCH] 8173 workaround qemu-xhci HCIVERSION bug Reviewed by: Gordon Ross Reviewed by: Igor Kozhukhov Reviewed by: Toomas Soome Approved by: Dan McDonald --- usr/src/uts/common/io/usb/hcd/xhci/xhci.c | 13 ++++++++++--- usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/usr/src/uts/common/io/usb/hcd/xhci/xhci.c b/usr/src/uts/common/io/usb/hcd/xhci/xhci.c index 17d190f3e0..84bd1a13c9 100644 --- a/usr/src/uts/common/io/usb/hcd/xhci/xhci.c +++ b/usr/src/uts/common/io/usb/hcd/xhci/xhci.c @@ -10,7 +10,7 @@ */ /* - * Copyright 2016 Joyent, Inc. + * Copyright (c) 2017, Joyent, Inc. */ /* @@ -1172,12 +1172,19 @@ xhci_read_params(xhci_t *xhcip) uint8_t usb; uint16_t vers; uint32_t struc1, struc2, struc3, cap1, cap2, pgsz; - uint32_t psize, pbit; + uint32_t psize, pbit, capreg; xhci_capability_t *xcap; unsigned long ps; + /* + * While it's tempting to do a 16-bit read at offset 0x2, unfortunately, + * a few emulated systems don't support reading at offset 0x2 for the + * version. Instead we need to read the caplength register and get the + * upper two bytes. + */ + capreg = xhci_get32(xhcip, XHCI_R_CAP, XHCI_CAPLENGTH); + vers = XHCI_VERSION_MASK(capreg); usb = pci_config_get8(xhcip->xhci_cfg_handle, PCI_XHCI_USBREV); - vers = xhci_get16(xhcip, XHCI_R_CAP, XHCI_HCIVERSION); struc1 = xhci_get32(xhcip, XHCI_R_CAP, XHCI_HCSPARAMS1); struc2 = xhci_get32(xhcip, XHCI_R_CAP, XHCI_HCSPARAMS2); struc3 = xhci_get32(xhcip, XHCI_R_CAP, XHCI_HCSPARAMS3); diff --git a/usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h b/usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h index 7e23463ea4..f521428852 100644 --- a/usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h +++ b/usr/src/uts/common/sys/usb/hcd/xhci/xhcireg.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2014 Martin Pieuchot. All rights reserved. * Copyright (c) 2010 Hans Petter Selasky. All rights reserved. - * Copyright 2016 Joyent, Inc. + * Copyright (c) 2017, Joyent, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -58,6 +58,8 @@ extern "C" { #define XHCI_HCIVERSION_0_9 0x0090 /* xHCI version 0.9 */ #define XHCI_HCIVERSION_1_0 0x0100 /* xHCI version 1.0 */ +#define XHCI_VERSION_MASK(x) (((x) >> 16) & 0xffff) + /* * Structural Parameters 1 - xHCI 1.1 / 5.3.3 */ -- 2.11.4.GIT