NetBSD Problem Report #54663

From sc.dying@gmail.com  Wed Oct 30 06:46:23 2019
Return-Path: <sc.dying@gmail.com>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 855217A1FC
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 30 Oct 2019 06:46:23 +0000 (UTC)
Message-Id: <b15ab625-c0f7-3efb-7b31-8e868a1e8595@gmail.com>
Date: Wed, 30 Oct 2019 06:46:17 +0000
From: sc.dying@gmail.com
Reply-To:
To: gnats-bugs@NetBSD.org
Subject: uplcom(4) does not work with EJ168

>Number:         54663
>Category:       kern
>Synopsis:       uplcom(4) does not work with EJ168
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 30 06:50:00 +0000 2019
>Originator:     sc.dying@gmail.com
>Release:        NetBSD/amd64 9.99.17 201910260710Z
>Organization:
>Environment:
System: NetBSD  9.99.17 NetBSD 9.99.17 (GENERIC) #0: Fri Oct 25 18:03:59 UTC 2019  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

 My uplcom(4) is not attached correctly to Etron EJ168 port.

> [ 214.6308845] uplcom0 at uhub5 port 2
> [ 214.6308845] uplcom0: Prolific Technology Inc. (0x67b) USB-Serial Controller (0x2303), rev 1.10/3.00, addr 1
> [ 214.6608972] ucom0 at uplcom0
> [ 214.6608972] ucom0: attach failed, error=5
> [ 214.6608972] ucom0: WARNING: power management not supported

 This uplcom has lower BULK-out endpoint address than BULK-in has. [*1]
ucom(4) opens BULK-in endpoint successfully, but fails to open BULK-out
endpoint on EJ168 ports because current xhci driver stores the DCI of the
endpoint to be configued to Context Entries.  The Context Entries is
"Maximum DCI of configured endpoint contexts" according to the xhci
specification 4.5.2, otherwise it should fail with Parameter Error.


[*1] lsusb for my uplcom

Bus 001 Device 003: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x067b Prolific Technology, Inc.
  idProduct          0x2303 PL2303 Serial Port
  bcdDevice            3.00
  iManufacturer           1 Prolific Technology Inc.
  iProduct                2 USB-Serial Controller
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      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     0x000a  1x 10 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0000
  (Bus Powered)

>How-To-Repeat:

Plugin-in the uplcom to EJ168 port that have lower bulk-out endpoint
address than bulk-in has.

>Fix:

 Use larger DCI for Context Entries of slot context between given DCI and
Context Entries of output slot context.
 I don't think usb_syncmem is required here as xhci_configure_endpoint does
it instead after do_command for output device context.


--- xhci.c	2019-10-11 00:15:13.822142367 +0000
+++ xhci.c	2019-10-11 00:26:26.605295088 +0000
@@ -3094,10 +3094,14 @@ xhci_setup_ctx(struct usbd_pipe *pipe)
 	cp[1] |= htole32(XHCI_INCTX_1_ADD_MASK(XHCI_DCI_SLOT));
 	cp[7] = htole32(0);

+	cp = xhci_slot_get_dcv(sc, xs, XHCI_DCI_SLOT);
+	uint32_t entries = XHCI_SCTX_0_CTX_NUM_GET(le32toh(cp[0]));
+	entries = uimax(entries, dci);
+
 	/* set up input slot context */
 	cp = xhci_slot_get_icv(sc, xs, xhci_dci_to_ici(XHCI_DCI_SLOT));
 	cp[0] =
-	    XHCI_SCTX_0_CTX_NUM_SET(dci) |
+	    XHCI_SCTX_0_CTX_NUM_SET(entries) |
 	    XHCI_SCTX_0_SPEED_SET(xhci_speed2xspeed(speed));
 	cp[1] = 0;
 	cp[2] = XHCI_SCTX_2_IRQ_TARGET_SET(0);

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.