Skip to contentSkip to conversation

UART trouble on the DBAu1100

DISCUSSION Freddy Spierenburg 3 participants 5 messages Apr 13, 2006 – Jun 13, 2006 4 messages not in the archive MIPS

lore
Share & tools
lore
#0 lore raw

Hi,

I have a problem and yet am not sure where to look. It's a problem in the serial driver for the internal UART's of the AU1100. It appeared ever since 2.6.15. 2.6.14 is working like a charm, but 2.6.15 gives me the trouble.

When I open a tty with the open(2) system call (see attached open.c) I see that the UART sends a 0x36 byte on the line.

But that's not the only trouble. I also do not receive any bytes received by the UART. All the received bytes stay in the input buffer of the UART only to be send up to userland as soon as the UART is asked to send a byte on the line itself. Then in one take all the bytes are received by the application listening.

Reproducing is easy with a program like picocom. Just start it on both ends (one called 'a' and the other called 'b') and type on one (a) end. You will see nothing at the other (b) end. Then type 1 or more characters on the other (b) end and you will see that character appear at the one (a) end and all the other previously types at the one (a) end appear on the other (b) end.

I am currently looking into the source to see what's changed, but any help would be greatly appreciated :-)

Signature · 4 lines
$ cat ~/.signature
Freddy Spierenburg <[email protected]>  http://freddy.snarl.nl/
GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1  E588 6F17 FD5D 7941 D1E1
$ # Please read http://www.ietf.org/rfc/rfc2015.txt before complain!

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc,char **argv) {
	int fd;
	char *tty;
	tty=argc>1?argv[1]:"/dev/ttyS0";
	fd=open(tty,O_RDWR);
	if(fd==-1) {
		perror("Can't open tty");
	} else {
		if(argc>2) {
			/* Closing or not doesn't matter, it's the open() system call. */
			close(fd);
		} else {
			/* Nice sleep so you see the character is sent by the open and
			 * not by whatever else one can think of. */
			sleep(2);
		}
	}
	return(0);
}
#1 lore raw
Quoted 9 lines · Freddy Spierenburg

Hi,

I have a problem and yet am not sure where to look. It's a problem in the serial driver for the internal UART's of the AU1100. It appeared ever since 2.6.15. 2.6.14 is working like a charm, but 2.6.15 gives me the trouble.

When I open a tty with the open(2) system call (see attached open.c) I see that the UART sends a 0x36 byte on the line.

We had the same problem on Au1200, applying
http://www.linux-mips.org/archives/linux-mips/2006-03/msg00259.html
(or maybe a different version of this patch) fixed it.

Quoted 7 lines

But that's not the only trouble. I also do not receive any bytes received by the UART. All the received bytes stay in the input buffer of the UART only to be send up to userland as soon as the UART is asked to send a byte on the line itself. Then in one take all the bytes are received by the application listening.

I may be way off, but maybe it's just flow control that needs to be turned off.

Domen

#2 lore raw
Quoted 11 lines · Domen Puncer
Quoted 6 lines · Freddy Spierenburg

But that's not the only trouble. I also do not receive any bytes received by the UART. All the received bytes stay in the input buffer of the UART only to be send up to userland as soon as the UART is asked to send a byte on the line itself. Then in one take all the bytes are received by the application listening.

I may be way off, but maybe it's just flow control that needs to be turned off.

If this is uart 0, it's probably a problem with that uart having irq number 0. Which in the 8250 driver is interpreted as no interrupt.

A quick (and dirty) patch:

drivers/serial/8250.c renamed from drivers/serial/8250.c_org +1 -1
@@ -78,7 +78,7 @@ static unsigned int nr_uarts = CONFIG_SE
  * machine types want others as well - they're free
  * to redefine this in their header file.
  */
-#define is_real_interrupt(irq)	((irq) != 0)
+#define is_real_interrupt(irq)	(1)
 
 #ifdef CONFIG_SERIAL_8250_DETECT_IRQ
 #define CONFIG_SERIAL_DETECT_IRQ 1

But this is not a desired solution according to this:
http://lkml.org/lkml/2006/3/29/91

Have somebody got a idea about how a mapping of interrupt numbers should be done in order to avoid irq 0 for Alchemy?

Signature · 1 line
Jon Anders Haugum
#3 lore raw

Hi Jon,

Quoted 11 lines · Jon Anders Haugum
Quoted 7 lines · Domen Puncer
Quoted 3 lines · Freddy Spierenburg

All the received bytes stay in the input buffer of the UART only to be send up to userland as soon as the UART is asked to send a byte on the line itself.

I may be way off, but maybe it's just flow control that needs to be turned off.

If this is uart 0, it's probably a problem with that uart having irq number 0. Which in the 8250 driver is interpreted as no interrupt.

No, it was actually all caused by the incorrect usage of the non standard Au1x00 divisor latch. When I applied your patch all worked and I was once again a happy man.

Thanks for the work!

Signature · 4 lines
$ cat ~/.signature
Freddy Spierenburg <[email protected]>  http://freddy.snarl.nl/
GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1  E588 6F17 FD5D 7941 D1E1
$ # Please read http://www.ietf.org/rfc/rfc2015.txt before complain!
#8 lore raw

Re: Fix potential bug in au1xxx_ddma_add_device()

In reply to a message not in the archive

Hi Domen,

Quoted 2 lines · Domen Puncer

First a note, that your patch [dbdma.patch] doesn't make any difference for me. Well... at least not an obvious one.

That's exactly what it should do, since it's a bug that I do not yet expect to happen. So no difference is good for now.

Including the patch, so hopefully Ralf sees it again. :-)

Quoted 7 lines

OK. I have an IDE drive connected now. It's a bit weird, with CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA I can't enable dma with hdparm, but if works on about 6 MB/sec.
With CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA, I can enable DMA, but it works slow, like 1.7 MB/sec.

Seems odd to me.

Hmmmm, strange. You should at least expect the other way around. Transferring you to the mailing list, hopefully somebody over there has got a clue.

Signature · 4 lines
$ cat ~/.signature
Freddy Spierenburg <[email protected]>  http://freddy.snarl.nl/
GnuPG: 0x7941D1E1=C948 5851 26D2 FA5C 39F1  E588 6F17 FD5D 7941 D1E1
$ # Please read http://www.ietf.org/rfc/rfc2015.txt before complain!
include/asm-mips/mach-au1x00/au1xxx_dbdma.h +4 -1
@@ -200,7 +200,10 @@
 #define DSCR_CMD0_ALWAYS	31
 #define DSCR_NDEV_IDS		32
 /* THis macro is used to find/create custom device types */
-#define DSCR_DEV2CUSTOM_ID(x,d)	(((((x)&0xFFFF)<<8)|0x32000000)|((d)&0xFF))
+#define DSCR_ID_BASE 0x32000000
+#define DSCR_ID_OFFSET 0x1000
+#define DSCR_ID_FREE DSCR_ID_BASE
+#define DSCR_DEV2CUSTOM_ID(x,d)	(((((x)&0xFFFF)<<8)|DSCR_ID_BASE)|((d)&0xFF))
 #define DSCR_CUSTOM2DEV_ID(x)	((x)&0xFF)
 
 
ar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R_ID_FREE, 0, 0, 0, 0, 0, 0 },
+	{ DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 },
+	{ DSCR_ID_FREE, 0, 0, 0, 0, 0, 0 },
 };
 
 #define DBDEV_TAB_SIZE (sizeof(dbdev_tab) / sizeof(dbdev_tab_t))
@@ -208,9 +208,9 @@
 {
 	u32 ret = 0;
 	dbdev_tab_t *p=NULL;
-	static u16 new_id=0x1000;
+	static u16 new_id=DSCR_ID_OFFSET;
 
-	p = find_dbdev_id(0);
+	p = find_dbdev_id(DSCR_ID_FREE);
 	if ( NULL != p )
 	{
 		memcpy(p, dev, sizeof(dbdev_tab_t));