Subject: broken devfs-support in SGI Zilog8530 serial driver

From: [email-masked] (Raoul Borenius)
Date: Fri, 29 Mar 2002 11:32:44 +0100

Hi,

I'm not sure if this is a devfs or mips problem so I'm sending it
to both lists.

I just compiled my own mips-kernel from oss.sgi.com:/cvs to get
devfs-support. Unfortunately there seems to be a problem with the
serial-driver at least in the linux_2_4 branch:

SGI Zilog8530 serial driver version 1.00
devfs_register(ttyS): could not append to parent, err: -17
devfs_register(cua): could not append to parent, err: -17
tty00 at 0xbfbd9830 (irq = 29) is a Zilog8530
tty01 at 0xbfbd9838 (irq = 29) is a Zilog8530

The result is that the directories /dev/tts and /dev/cua are missing.

There are only the files /dev/ttS and /dev/cua which can be used to get
access to the first serial port.

I have attached the full dmesg output at the end.

Regards

Raoul

---

From: Borsenkow Andrej <[email-masked]>
Date: Fri, 29 Mar 2002 14:01:54 +0300

> devfs_register(ttyS): could not append to parent, err: -17

This means that somebody else registered ttyS (and cua) before Zilog8530
driver attempted to do it. The possible reason could be that driver
calls tty_register_devfs itself in this case it must set
TTY_DRIVER_NO_DEVFS flag to prevent the same nodes registered by
tty_register_driver.

-andrej

---

From: [email-masked] (Raoul Borenius)
Date: Fri, 29 Mar 2002 14:26:50 +0100

Hi Andrej,

> TTY_DRIVER_NO_DEVFS flag to prevent the same nodes registered by

Yeah, but I think the serial ports should be placed under /dev/tts/* and
/dev/cua/*, shouldn't they?

Which driver could have registered /dev/ttyS? if I search the
kernel-sources under arch/mips I get

testserv (raoul) ~/linux_2_4/linux/arch/mips> find . -name \*.c | xargs grep ttyS
./arc/arc_con.c:        "ttyS",
./au1000/common/serial.c:       printk("Testing ttyS%d (0x%04lx, 0x%04x)...\n", state->line,
./au1000/common/serial.c:       serial_driver.name = "ttyS";
./au1000/common/serial.c:               printk(KERN_INFO "ttyS%02d%s at 0x%04lx (irq = %d) is a %s\n",
./au1000/common/serial.c:       printk(KERN_INFO "ttyS%02d at %s 0x%04lx (irq = %d) is a %s\n",
./au1000/common/serial.c:       name:           "ttyS",
./au1000/pb1000/setup.c:                strcat(argptr, " console=ttyS0,115200");
./au1000/pb1500/setup.c:                strcat(argptr, " console=ttyS0,115200");
./baget/vacserial.c:    serial_driver.name = "ttyS";
./baget/vacserial.c:            printk(KERN_INFO "ttyS%02d%s at 0x%04x (irq = %d) is a %s\n",
./baget/vacserial.c:    name:           "ttyS",
./baget/vacserial.c:    autoconfig(info);       /* autoconfigure ttyS0, whatever that is */
./cobalt/setup.c:char arcs_cmdline[CL_SIZE] = { "console=ttyS0,115200 root=/dev/hda1" };
./dec/promcon.c:    name:       "ttyS",
./galileo-boards/ev64120/promcon.c:     "ttyS",
./galileo-boards/ev64120/setup.c:char arcs_cmdline[CL_SIZE] = { "console=ttyS0,115200 "
./galileo-boards/ev96100/setup.c:               strcat(argptr, " console=ttyS0,115200");
./ite-boards/generic/it8172_setup.c:            strcat(argptr, " console=ttyS0,115200");
./jmr3927/rbhma3100/setup.c:            strcat(argptr, " console=ttyS1,115200");
./kernel/gdb-stub.c: *    (gdb) target remote /dev/ttyS1
./mips-boards/atlas/atlas_setup.c:      if ((argptr = strstr(argptr, "console=ttyS0")) == NULL) {
./mips-boards/atlas/atlas_setup.c:              strcpy(serial_console, "ttyS0,");
./mips-boards/atlas/atlas_setup.c:      if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
./mips-boards/atlas/atlas_setup.c:              argptr += strlen("kgdb=ttyS");
./mips-boards/atlas/atlas_setup.c:                      printk("KGDB: Uknown serial line /dev/ttyS%c, "
./mips-boards/atlas/atlas_setup.c:                             "falling back to /dev/ttyS1\n", *argptr);
./mips-boards/atlas/atlas_setup.c:              printk("KGDB: Using serial line /dev/ttyS%d for session\n",
./mips-boards/atlas/atlas_setup.c:              prom_printf("KGDB: Using serial line /dev/ttyS%d for session, "
./mips-boards/malta/malta_setup.c:              strcat(argptr, " console=ttyS0,38400");
./mips-boards/malta/malta_setup.c:      if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
./mips-boards/malta/malta_setup.c:              argptr += strlen("kgdb=ttyS");
./mips-boards/malta/malta_setup.c:                      printk("KGDB: Uknown serial line /dev/ttyS%c, "
./mips-boards/malta/malta_setup.c:                             "falling back to /dev/ttyS1\n", *argptr);
./mips-boards/malta/malta_setup.c:              printk("KGDB: Using serial line /dev/ttyS%d for session\n",
./mips-boards/malta/malta_setup.c:              prom_printf("KGDB: Using serial line /dev/ttyS%d for session, "
./philips/nino/prom.c:  strcpy(arcs_cmdline, "console=tty0 console=ttyS0,115200");
./sgi-ip22/ip22-setup.c:                        console_setup ("ttyS1");
./sgi-ip22/ip22-setup.c:                        console_setup ("ttyS0");
./sgi-ip22/ip22-setup.c:        console_setup("ttyS0");
testserv (raoul) ~/linux_2_4/linux/arch/mips>

but I have not compiled support for arc console (when do you need that
btw?) and all other drivers do not apply to IP22 AFAIK.

My .config is attached below.

Regards

Raoul

---

From: Russell Coker <[email-masked]>
Date: Fri, 29 Mar 2002 14:38:35 +0100

You need some code similar to the following in the serial driver:

#ifdef CONFIG_DEVFS_FS
        serial_driver.name = "tts/%d";
#else
        serial_driver.name = "ttyS";
#endif

Of course if the original device nodes were named /dev/ttyZ0 etc then you 
want "tts/Z%d".

Look at the Cyclades and Stallion drivers for examples of it being done 
correctly.  Or tell me exactly the details of what you want and I'll send you 
a patch.

-- 
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

---

From: Ralf Baechle <[email-masked]>
Date: Fri, 29 Mar 2002 23:35:59 -0800

> devfs_register(cua): could not append to parent, err: -17

At this time we don't even claim to have proper devfs support in the
Indy serial drivers ...

  Ralf

---

From: [email-masked] (Raoul Borenius)
Date: Sat, 30 Mar 2002 14:28:56 +0100

Hi Ralf,

> At this time we don't even claim to have proper devfs support in the

But it would be nice to have ;-)

Especially because you only need the small change pointed out by
Russell Coker:

--- sgiserial.c.orig    Sat Mar 30 10:51:03 2002
+++ sgiserial.c Sat Mar 30 10:54:28 2002
@@ -1875,7 +1875,11 @@
        
        memset(&serial_driver, 0, sizeof(struct tty_driver));
        serial_driver.magic = TTY_DRIVER_MAGIC;
+#ifdef CONFIG_DEVFS_FS
+       serial_driver.name = "tts/%d";
+#else
        serial_driver.name = "ttyS";
+#endif
        serial_driver.major = TTY_MAJOR;
        serial_driver.minor_start = 64;
        serial_driver.num = NUM_CHANNELS;
@@ -1911,7 +1915,11 @@
         * major number and the subtype code.
         */
        callout_driver = serial_driver;
+#ifdef CONFIG_DEVFS_FS
+       callout_driver.name = "cua/%d";
+#else
        callout_driver.name = "cua";
+#endif
        callout_driver.major = TTYAUX_MAJOR;
        callout_driver.subtype = SERIAL_TYPE_CALLOUT;

It works for my Indy and I just love devfs. All other drivers used
on my box also work fine with devfs (sound, watchdog, rtc etc.).

Regards

Raoul

---

From: [email-masked] (Raoul Borenius)
Date: Sun, 31 Mar 2002 17:00:23 +0200

Hi Ralf,

> +++ sgiserial.c Sat Mar 30 10:54:28 2002

Thanks for including the changes fr the ttyS's. But it seems you forgot the

Could you commit that too?

Thanx

Raoul

---

From: Ralf Baechle <[email-masked]>
Date: Sat, 30 Mar 2002 12:18:11 -0800

> Especially because you only need the small change pointed out by

Ok :-)  Applied to 2.4 and 2.5.

  Ralf

---

From: Ralf Baechle <[email-masked]>
Date: Sun, 31 Mar 2002 14:15:45 -0800

> Thanks for including the changes fr the ttyS's. But it seems you forgot the

That's what you get for submitting patches that don't apply ;)  Did you do
cut'n'paste or similiar cruelties to that poor little patch?

> Could you commit that too?

Sure.

  Ralf