Hi all,

I have a 4-port ST Lab umsc(4) device that used to work quite well for
serial access to a set of machines.  Unfortunately, after upgrading to
6.2-ish, it stopped working with the error:

umcs0: unable to get number of ports

Bisecting through a set of snapshot kernels, I found the problem was
introduced between:

OpenBSD 6.1-current (GENERIC.MP) #52: Tue Aug  8 23:36:00 MDT 2017

and

OpenBSD 6.1-current (GENERIC.MP) #1: Fri Aug 11 21:26:07 MDT 2017

These are the start and end of the t2k17 hackathon, so quite a long
period.  That's unfortunate, because there were quite a few commits in
that time.  I quickly counted ~225 mails to source-changes@ in those
few days.  Fortunately, only only ~80 of those touched sys/ in some
way or another, reducing the search space quite a bit already.  And
while skimming through those commit messages, one stood out in
particular:

https://marc.info/?l=openbsd-cvs&m=150237790323831&w=2

which bumps dev/usb/umcs.c to revision 1.5 with commit message:

"Deactivate the device if I/O fails in attach.

Coverity CID 1453399; ok deraadt@"

reverting this makes the device work again, but since there's a
Coverity CID attached, that's probably not the best move.  To try and
better understand what's going on, I added some printf debugging
around the original (revision 1.4) code:

Index: umcs.c
===================================================================
RCS file: /cvs/src/sys/dev/usb/umcs.c,v
retrieving revision 1.5
diff -u -p -r1.5 umcs.c
--- umcs.c      10 Aug 2017 15:11:34 -0000      1.5
+++ umcs.c      4 Oct 2017 08:18:29 -0000
@@ -209,11 +209,15 @@ umcs_attach(struct device *parent, struc
         *
         * Also, see notes in header file for these constants.
         */
-       if (!umcs_get_reg(sc, UMCS_GPIO, &data)) {
+       printf("%s: data before umcs_get_reg: %d\n", DEVNAME(sc), data);
+       umcs_get_reg(sc, UMCS_GPIO, &data);
+       printf("%s: data after umcs_get_reg: %d\n", DEVNAME(sc), data);
+/*     if (!umcs_get_reg(sc, UMCS_GPIO, &data)) {
                printf("%s: unable to get number of ports\n", DEVNAME(sc));
                usbd_deactivate(sc->sc_udev);
                return;
        }
+*/
        if (data & UMCS_GPIO_4PORTS)
                sc->sc_numports = 4; /* physical port no are : 0, 1, 2, 3 */
        else if (uaa->product == USB_PRODUCT_MOSCHIP_MCS7810)


With this diff in, I get the following output in dmesg when I attach
the device:

umcs0 at uhub4 port 2 configuration 1 interface 0 "MosChip MCS7840 Serial" rev 
2.00/0.01 addr 3
umcs0: data before umcs_get_reg: 0
umcs0: data after umcs_get_reg: 1
ucom0 at umcs0 portno 0
ucom1 at umcs0 portno 1
ucom2 at umcs0 portno 2
ucom3 at umcs0 portno 3

So 'data' *does* change with the call to umcs_get_reg.  Yet
umcs_get_reg can only return EIO - returning '1' doesn't seem like EIO
to me.

I'm not really sure how to further debug this.  Anyone got an idea?

Thanks,

Paul 'WEiRD' de Weerd

-- 
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
                 http://www.weirdnet.nl/                 

Reply via email to