tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

USB 3.0 xhci questions



Hi,

I have read some xhci-related source code, and I have two questions.


(1) The definition of XHCI_HCS2_MAXSPBUF macro.
In src/sys/dev/usb/xhcireg.h, there is the following macro definition.

#define        XHCI_HCS2_MAXSPBUF(x)   (((x) >> 27) & 0x7F)

It seems that XHCI_HCS2_MAXSPBUF is used for reading Max Scratchpad Buffers.
Max Scratchpad Buffers are in 31:27 bit of HCSPARAMS2 in capability
register. 0x7F is 1111111(2). I feel it is too long to mask 31:27.
It would be 0x1F = 11111(2).


(2) I may not get USB Status (USBSTS).
In src/sys/dev/usb/xhci.c's xhci_intr1() function, USBSTS is read from
operational register, but my machine returns always 0x00000000.
The code in xhci_intr1() expects XHCI_STS_PCD flag is detcted.

The following is my modified source code snipet (enable device_printf).
I think "usbsts & XHCI_STS_PCD != 0" in this case, but always "== 0".
PCD means Port Change Detect, and port change is not detected.
I have dumped all PORTSC value, and there is no Current Connect Status (CCS)
and Connect Status Change (CSC) bits.

I have concluded that port change is not deteced on my machine.
What may be wrong?

int
xhci_intr1(struct xhci_softc * const sc)
{
        uint32_t usbsts;
        uint32_t iman;

        usbsts = xhci_op_read_4(sc, XHCI_USBSTS);
        device_printf(sc->sc_dev, "%s USBSTS %08x\n", __func__, usbsts);
#if 0
        if ((usbsts & (XHCI_STS_EINT|XHCI_STS_PCD)) == 0) {
                return 0;
        }
#endif
        xhci_op_write_4(sc, XHCI_USBSTS,
            usbsts & (2|XHCI_STS_EINT|XHCI_STS_PCD)); /* XXX */
        usbsts = xhci_op_read_4(sc, XHCI_USBSTS);
        device_printf(sc->sc_dev, "%s USBSTS %08x\n", __func__, usbsts);

        iman = xhci_rt_read_4(sc, XHCI_IMAN(0));
        device_printf(sc->sc_dev, "%s IMAN0 %08x\n", __func__, iman);
        if ((iman & XHCI_IMAN_INTR_PEND) == 0) {
                return 0;
        }


And here is a part of dmesg.

xhci0 at pci0 dev 20 function 0: vendor 0x8086 product 0x8c31 (rev. 0x04)
xhci0: interrupting at ioapic0 pin 16
xhci_init
xhci0: xHCI version 1.0
xhci0: ac64 1 ctxsz 32
xhci0: xECP 8000
xhci0: ECR 8000: 02000802
xhci0: SP: 02000802 20425355 30010f01
xhci0: ECR 8020: 03000802
xhci0: SP: 03000802 20425355 10000610
xhci0: ECR 8040: 00000cc1
xhci0: ECR 8070: 0000ffc0
xhci0: ECR 846c: 00000001
xhci0: PAGESIZE 0x00000001
xhci0: sc_pgsz 0x00001000
xhci0: sc_maxslots 0x00000020
xhci0: sc_maxspbuf 16
xhci0: eventst: NORMAL_COMPLETION 000000013a6cbfc0 0xffff80023a25cfc0 1000
xhci0: dcbaa: NORMAL_COMPLETION 000000013a6cc000 0xffff80023a25d000 1000
xhci0: USBCMD 00000005
usb0 at xhci0: USB revision 2.0

xhci1 at pci3 dev 0 function 0: vendor 0x1912 product 0x0015 (rev. 0x02)
xhci1: interrupting at ioapic0 pin 17
xhci_init
xhci1: xHCI version 1.0
xhci1: ac64 1 ctxsz 64
xhci1: xECP 500
xhci1: ECR 500: 00000401
xhci1: ECR 510: 03000502
xhci1: SP: 03000502 20425355 00000201
xhci1: ECR 524: 02000702
xhci1: SP: 02000702 20425355 00000203
xhci1: ECR 540: 000004c0
xhci1: ECR 550: 0000000a
xhci1: PAGESIZE 0x00000001
xhci1: sc_pgsz 0x00001000
xhci1: sc_maxslots 0x00000020
xhci1: sc_maxspbuf 4
xhci1: eventst: NORMAL_COMPLETION 000000013a6cbf40 0xffff80023a25cf40 1000
xhci1: dcbaa: NORMAL_COMPLETION 000000013a84e000 0xffff80023a2e5000 1000
xhci1: USBCMD 00000005
usb1 at xhci1: USB revision 2.0

(USB 3.0 memory stick is inserted)
xhci_intr: xhci0
xhci0: xhci_intr1 USBSTS 00000000
xhci0: xhci_intr1 USBSTS 00000000
xhci0: xhci_intr1 IMAN0 00000002

Sadly, if my guess (1) was true, my MacBook Air' and
Lenovo ThinkStation E32's USB 3.0 does not work. No device is detected.

Thank you.

--
Ryo ONODERA // ryo_on%yk.rim.or.jp@localhost
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


Home | Main Index | Thread Index | Old Index