On Tue, May 23, 2017 at 07:53:45AM -0400, Bryan Steele wrote:
> On Tue, May 23, 2017 at 01:04:58PM +0200, Martin Pieuchot wrote:
> > On 19/05/17(Fri) 15:28, Bryan Steele wrote:
> > > Still noticing this, kind of disappears when X is running.. *hand wavey*
> > >
> > > May 19th amd64 snap
> >
> > Could you try the diff below?
> >
> > Index: ohci.c
> > ===================================================================
> > RCS file: /cvs/src/sys/dev/usb/ohci.c,v
> > retrieving revision 1.150
> > diff -u -p -r1.150 ohci.c
> > --- ohci.c 15 May 2017 10:52:08 -0000 1.150
> > +++ ohci.c 23 May 2017 11:00:55 -0000
> > @@ -3,12 +3,14 @@
> > /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp
> > $ */
> >
> > /*
> > - * Copyright (c) 1998 The NetBSD Foundation, Inc.
> > + * Copyright (c) 1998, 2005 The NetBSD Foundation, Inc.
> > * All rights reserved.
> > *
> > * This code is derived from software contributed to The NetBSD Foundation
> > * by Lennart Augustsson ([email protected]) at
> > * Carlstedt Research & Technology.
> > + * This code is derived from software contributed to The NetBSD Foundation
> > + * by Charles M. Hannum.
> > *
> > * Redistribution and use in source and binary forms, with or without
> > * modification, are permitted provided that the following conditions
> > @@ -90,7 +92,6 @@ usbd_status ohci_open(struct usbd_pipe *
> > int ohci_setaddr(struct usbd_device *, int);
> > void ohci_poll(struct usbd_bus *);
> > void ohci_softintr(void *);
> > -void ohci_add_done(struct ohci_softc *, ohci_physaddr_t);
> > void ohci_rhsc(struct ohci_softc *, struct usbd_xfer *);
> >
> > usbd_status ohci_device_request(struct usbd_xfer *xfer);
> > @@ -149,7 +150,6 @@ usbd_status ohci_device_setintr(struct o
> >
> > void ohci_timeout(void *);
> > void ohci_timeout_task(void *);
> > -void ohci_rhsc_able(struct ohci_softc *, int);
> > void ohci_rhsc_enable(void *);
> >
> > void ohci_close_pipe(struct usbd_pipe *, struct ohci_soft_ed
> > *);
> > @@ -1016,7 +1016,6 @@ int
> > ohci_intr1(struct ohci_softc *sc)
> > {
> > u_int32_t intrs, eintrs;
> > - ohci_physaddr_t done;
> >
> > DPRINTFN(14,("ohci_intr1: enter\n"));
> >
> > @@ -1028,28 +1027,11 @@ ohci_intr1(struct ohci_softc *sc)
> > return (0);
> > }
> >
> > - intrs = 0;
> > - done = letoh32(sc->sc_hcca->hcca_done_head);
> > - if (done != 0) {
> > - if (done & ~OHCI_DONE_INTRS)
> > - intrs = OHCI_WDH;
> > - if (done & OHCI_DONE_INTRS)
> > - intrs |= OREAD4(sc, OHCI_INTERRUPT_STATUS);
> > - sc->sc_hcca->hcca_done_head = 0;
> > - } else {
> > - intrs = OREAD4(sc, OHCI_INTERRUPT_STATUS);
> > - /* If we've flushed out a WDH then reread */
> > - if (intrs & OHCI_WDH) {
> > - done = letoh32(sc->sc_hcca->hcca_done_head);
> > - sc->sc_hcca->hcca_done_head = 0;
> > - }
> > - }
> > -
> > + intrs = OREAD4(sc, OHCI_INTERRUPT_STATUS);
> > if (intrs == 0xffffffff) {
> > sc->sc_bus.dying = 1;
> > return (0);
> > }
> > -
> > if (!intrs)
> > return (0);
> >
> > @@ -1059,11 +1041,7 @@ ohci_intr1(struct ohci_softc *sc)
> > if (!eintrs)
> > return (0);
> >
> > - sc->sc_bus.intr_context++;
> > sc->sc_bus.no_intrs++;
> > - DPRINTFN(7, ("ohci_intr: sc=%p intrs=0x%x(0x%x) eintrs=0x%x\n",
> > - sc, (u_int)intrs, OREAD4(sc, OHCI_INTERRUPT_STATUS),
> > - (u_int)eintrs));
> >
> > if (eintrs & OHCI_SO) {
> > sc->sc_overrun_cnt++;
> > @@ -1076,7 +1054,6 @@ ohci_intr1(struct ohci_softc *sc)
> > eintrs &= ~OHCI_SO;
> > }
> > if (eintrs & OHCI_WDH) {
> > - ohci_add_done(sc, done &~ OHCI_DONE_INTRS);
> > usb_schedsoftintr(&sc->sc_bus);
> > eintrs &= ~OHCI_WDH;
> > }
> > @@ -1091,47 +1068,24 @@ ohci_intr1(struct ohci_softc *sc)
> > /* XXX what else */
> > }
> > if (eintrs & OHCI_RHSC) {
> > - ohci_rhsc(sc, sc->sc_intrxfer);
> > - /*
> > - * Disable RHSC interrupt for now, because it will be
> > - * on until the port has been reset.
> > - */
> > - ohci_rhsc_able(sc, 0);
> > - DPRINTFN(2, ("%s: rhsc interrupt disabled\n",
> > - sc->sc_bus.bdev.dv_xname));
> > -
> > + atomic_setbits_int(&sc->sc_flags, OHCIF_RHSC_INTR);
> > + usb_schedsoftintr(&sc->sc_bus);
> > /* Do not allow RHSC interrupts > 1 per second */
> > timeout_add_sec(&sc->sc_tmo_rhsc, 1);
> > - eintrs &= ~OHCI_RHSC;
> > }
> >
> > - sc->sc_bus.intr_context--;
> > -
> > if (eintrs != 0) {
> > - /* Block unprocessed interrupts. XXX */
> > + /* Block unprocessed interrupts. */
> > OWRITE4(sc, OHCI_INTERRUPT_DISABLE, eintrs);
> > sc->sc_eintrs &= ~eintrs;
> > - printf("%s: blocking intrs 0x%x\n",
> > - sc->sc_bus.bdev.dv_xname, eintrs);
> > + DPRINTFN(1, ("%s: blocking intrs 0x%x\n",
> > + sc->sc_bus.bdev.dv_xname, eintrs));
> > }
> >
> > return (1);
> > }
> >
> > void
> > -ohci_rhsc_able(struct ohci_softc *sc, int on)
> > -{
> > - DPRINTFN(4, ("ohci_rhsc_able: on=%d\n", on));
> > - if (on) {
> > - sc->sc_eintrs |= OHCI_RHSC;
> > - OWRITE4(sc, OHCI_INTERRUPT_ENABLE, OHCI_RHSC);
> > - } else {
> > - sc->sc_eintrs &= ~OHCI_RHSC;
> > - OWRITE4(sc, OHCI_INTERRUPT_DISABLE, OHCI_RHSC);
> > - }
> > -}
> > -
> > -void
> > ohci_rhsc_enable(void *v_sc)
> > {
> > struct ohci_softc *sc = v_sc;
> > @@ -1141,11 +1095,8 @@ ohci_rhsc_enable(void *v_sc)
> > return;
> >
> > s = splhardusb();
> > - ohci_rhsc(sc, sc->sc_intrxfer);
> > - DPRINTFN(2, ("%s: rhsc interrupt enabled\n",
> > - sc->sc_bus.bdev.dv_xname));
> > -
> > - ohci_rhsc_able(sc, 1);
> > + sc->sc_eintrs |= OHCI_RHSC;
> > + OWRITE4(sc, OHCI_INTERRUPT_ENABLE, OHCI_RHSC);
> > splx(s);
> > }
> >
> > @@ -1171,10 +1122,39 @@ char *ohci_cc_strs[] = {
> > #endif
> >
> > void
> > -ohci_add_done(struct ohci_softc *sc, ohci_physaddr_t done)
> > +ohci_softintr(void *v)
> > {
> > - struct ohci_soft_itd *sitd, *sidone, **ip;
> > - struct ohci_soft_td *std, *sdone, **p;
> > + struct ohci_softc *sc = v;
> > + struct ohci_soft_itd *sitd, *sidone, *sitdnext;
> > + struct ohci_soft_td *std, *sdone, *stdnext;
> > + struct usbd_xfer *xfer;
> > + struct ohci_pipe *opipe;
> > + int len, cc, s;
> > + int i, j, actlen, iframes, uedir;
> > + ohci_physaddr_t done = 0;
> > +
> > + DPRINTFN(10,("ohci_softintr: enter\n"));
> > +
> > + if (sc->sc_bus.dying)
> > + return;
> > +
> > + sc->sc_bus.intr_context++;
> > +
> > + if (sc->sc_flags & OHCIF_RHSC_INTR) {
> > + atomic_clearbits_int(&sc->sc_flags, OHCIF_RHSC_INTR);
> > + ohci_rhsc(sc, sc->sc_intrxfer);
> > + }
> > +
> > + s = splhardusb();
> > + usb_syncmem(&sc->sc_hccadma, offsetof(struct ohci_hcca, hcca_done_head),
> > + sizeof(sc->sc_hcca->hcca_done_head),
> > + BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
> > + done = le32toh(sc->sc_hcca->hcca_done_head) & ~OHCI_DONE_INTRS;
> > + sc->sc_hcca->hcca_done_head = 0;
> > + usb_syncmem(&sc->sc_hccadma, offsetof(struct ohci_hcca, hcca_done_head),
> > + sizeof(sc->sc_hcca->hcca_done_head),
> > + BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
> > + splx(s);
> >
> > /* Reverse the done list. */
> > for (sdone = NULL, sidone = NULL; done != 0; ) {
> > @@ -1194,44 +1174,9 @@ ohci_add_done(struct ohci_softc *sc, ohc
> > DPRINTFN(5,("add ITD %p\n", sitd));
> > continue;
> > }
> > - panic("ohci_add_done: addr 0x%08lx not found", (u_long)done);
> > + panic("addr 0x%08lx not found", (u_long)done);
> > }
> >
> > - /* sdone & sidone now hold the done lists. */
> > - /* Put them on the already processed lists. */
> > - for (p = &sc->sc_sdone; *p != NULL; p = &(*p)->dnext)
> > - ;
> > - *p = sdone;
> > - for (ip = &sc->sc_sidone; *ip != NULL; ip = &(*ip)->dnext)
> > - ;
> > - *ip = sidone;
> > -}
> > -
> > -void
> > -ohci_softintr(void *v)
> > -{
> > - struct ohci_softc *sc = v;
> > - struct ohci_soft_itd *sitd, *sidone, *sitdnext;
> > - struct ohci_soft_td *std, *sdone, *stdnext;
> > - struct usbd_xfer *xfer;
> > - struct ohci_pipe *opipe;
> > - int len, cc, s;
> > - int i, j, actlen, iframes, uedir;
> > -
> > - DPRINTFN(10,("ohci_softintr: enter\n"));
> > -
> > - if (sc->sc_bus.dying)
> > - return;
> > -
> > - sc->sc_bus.intr_context++;
> > -
> > - s = splhardusb();
> > - sdone = sc->sc_sdone;
> > - sc->sc_sdone = NULL;
> > - sidone = sc->sc_sidone;
> > - sc->sc_sidone = NULL;
> > - splx(s);
> > -
> > DPRINTFN(10,("ohci_softintr: sdone=%p sidone=%p\n", sdone, sidone));
> >
> > #ifdef OHCI_DEBUG
> > @@ -2435,7 +2380,7 @@ ohci_root_ctrl_start(struct usbd_xfer *x
> > case UHF_C_PORT_RESET:
> > /* Enable RHSC interrupt if condition is cleared. */
> > if ((OREAD4(sc, port) >> 16) == 0)
> > - ohci_rhsc_able(sc, 1);
> > + ohci_rhsc_enable(sc);
> > break;
> > default:
> > break;
> > Index: ohcivar.h
> > ===================================================================
> > RCS file: /cvs/src/sys/dev/usb/ohcivar.h,v
> > retrieving revision 1.37
> > diff -u -p -r1.37 ohcivar.h
> > --- ohcivar.h 16 May 2014 18:17:03 -0000 1.37
> > +++ ohcivar.h 23 May 2017 10:31:49 -0000
> > @@ -82,6 +82,8 @@ struct ohci_softc {
> > bus_space_tag_t iot;
> > bus_space_handle_t ioh;
> > bus_size_t sc_size;
> > + int sc_flags; /* misc flags */
> > +#define OHCIF_RHSC_INTR 0x01
> >
> > struct usb_dma sc_hccadma;
> > struct ohci_hcca *sc_hcca;
> > @@ -106,9 +108,6 @@ struct ohci_softc {
> > struct ohci_soft_itd *sc_freeitds;
> >
> > struct usbd_xfer *sc_intrxfer;
> > -
> > - struct ohci_soft_itd *sc_sidone;
> > - struct ohci_soft_td *sc_sdone;
> >
> > char sc_vendor[16];
> > int sc_id_vendor;
> >
>
> Missing header?
>
> /src/sys/dev/usb/ohci.c: In function
> 'ohci_intr1':
> /src/sys/dev/usb/ohci.c:1071: warning:
> implicit declaration of function 'atomic_setbits_int'
> /src/sys/dev/usb/ohci.c: In function
> 'ohci_softintr':
> /src/sys/dev/usb/ohci.c:1144: warning:
> implicit declaration of function 'atomic_clearbits_int'
> *** Error 1 in target 'ohci.o'
Adding <sys/atomic.h> to ohci.c fixes the build, and the splasserts, but
sadly not the occasional mouse flapping.
wsmouse0 detached
ums0 detached
uhidev0 detached
uhidev0 at uhub2 port 2 configuration 1 interface 0 "PixArt USB Optical
Mouse" rev 1.10/1.00 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 3 buttons, Z dir
wsmouse0 at ums0 mux 0
wsmouse0 detached
ums0 detached
uhidev0 detached
uhidev0 at uhub2 port 2 configuration 1 interface 0 "PixArt USB Optical
Mouse" rev 1.10/1.00 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 3 buttons, Z dir
wsmouse0 at ums0 mux
Bus 002 Device 001: ID 1002:0000
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 0 Full speed (or root) hub
bMaxPacketSize0 64
idVendor 0x1002
idProduct 0x0000
bcdDevice 1.00
iManufacturer 1 ATI
iProduct 2 OHCI root hub
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 25
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x40
(Missing must-be-set bit!)
Self Powered
MaxPower 0mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 9 Hub
bInterfaceSubClass 0 Unused
bInterfaceProtocol 0 Full speed (or root) hub
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 255
Hub Descriptor:
bLength 10
bDescriptorType 41
nNbrPorts 3
wHubCharacteristic 0x0002
No power switching (usb 1.0)
Ganged overcurrent protection
bPwrOn2PwrGood 2 * 2 milli seconds
bHubContrCurrent 0 milli Ampere
DeviceRemovable 0x00
PortPwrCtrlMask 0x00
Hub Port Status:
Port 1: 0000.0100 power
Port 2: 0000.0303 lowspeed power enable connect
Port 3: 0000.0100 power
Device Status: 0x0001
Self Powered
Bus 002 Device 002: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x093a Pixart Imaging, Inc.
idProduct 0x2510 Optical Mouse
bcdDevice 1.00
iManufacturer 1 PixArt
iProduct 2 USB Optical Mouse
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xa0
(Bus Powered)
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 2 Mouse
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.11
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 52
Report Descriptor: (length is 52)
Item(Global): Usage Page, data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x02 ] 2
Mouse
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Local ): Usage, data= [ 0x01 ] 1
Pointer
Item(Main ): Collection, data= [ 0x00 ] 0
Physical
Item(Global): Usage Page, data= [ 0x09 ] 9
Buttons
Item(Local ): Usage Minimum, data= [ 0x01 ] 1
Button 1 (Primary)
Item(Local ): Usage Maximum, data= [ 0x03 ] 3
Button 3 (Tertiary)
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x01 ] 1
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x03 ] 3
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile
Bitfield
Item(Global): Report Size, data= [ 0x05 ] 5
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x01 ] 1
Constant Array Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile
Bitfield
Item(Global): Usage Page, data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x30 ] 48
Direction-X
Item(Local ): Usage, data= [ 0x31 ] 49
Direction-Y
Item(Local ): Usage, data= [ 0x38 ] 56
Wheel
Item(Global): Logical Minimum, data= [ 0x81 ] 129
Item(Global): Logical Maximum, data= [ 0x7f ] 127
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x03 ] 3
Item(Main ): Input, data= [ 0x06 ] 6
Data Variable Relative No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile
Bitfield
Item(Main ): End Collection, data=none
Item(Main ): End Collection, data=none
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0004 1x 4 bytes
bInterval 10
Device Status: 0x0000
(Bus Powered)