From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@9fans.net From: Richard Miller <9fans@hamnavoe.com> Date: Mon, 12 Dec 2016 20:33:40 +0000 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] usb serial on raspberry pi (again) Topicbox-Message-UUID: b0ef1824-ead9-11e9-9d60-3106f5b1d025 > I cannot get the usb serial interfaces we use to work. I have never managed to get > usb serial adapters to work with the raspberry pi, though never had problems on x86 boxen. > ... > > Text into the pi works fine, but outgoing text seems stalled until text is received, > I can type ahead and when I receive data the queued outgoing data is sent. Hi Steve - I just had a look at this (as a bit of displacement activity from more stressful tasks...). First of all I dug out an old silabs usbserial adapter and quickly confirmed that I see the same symptoms as you. (I had never thought of using a serial dongle on a pi, since the uart gpio pins have always served my purposes - I always connect to FPGAs or other microprocessors which are happy with 3.3V) By watching changes in the file descriptor r/w count in the 'ps' output for the usbd subprocess, I could see that the first byte of data was being written to the usb ep, but the write was hanging in the kernel till the next read completion. I noted that this particular dongle uses the same ep number for both input and output, which is unusual (and was never properly allowed for in the original design of plan 9 usb). Next I looked in the bcm usb adapter driver (usbdwc.c) for possible interference between reads and writes on the same ep number, and the answer was glaringly obvious. Each ep has a single Epio structure, shared by read and write sides, with a QLock in it. My failure of vision. The fix isn't as obvious (to me) as the diagnosis. Maybe it's as simple as having separate read and write QLocks. I need to study the code for a while to assure myself that it's safe to do that. I wrote it so long ago that I frankly can't recall why there's a lock at all. You're welcome to have a look too and offer suggestions! -- Richard