Skip to contentSkip to conversation

set altix preferred console

PATCH In review Greg Edwards 4 participants 16 messages Sep 30, 2005 – Nov 11, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 set altix preferred console

Set the preferred console on Altix, if no console=<console> was passed on the boot line.

Bjorn, the hunk I removed in pcdp.c broke the vga console on Altix and the virtual terminal if any console= was passed in. For example, if you booted with console=ttySG0 (the L1 serial console), there would be no login prompt on tty1 when you got to multiuser, even though a getty was running. Is removing this ok?

 arch/ia64/sn/kernel/setup.c |   12 +++++++++---
 drivers/firmware/pcdp.c     |    3 ---
 2 files changed, 9 insertions(+), 6 deletions(-)

Index: git-linus/arch/ia64/sn/kernel/setup.c
=================================--- git-linus.orig/arch/ia64/sn/kernel/setup.c 2005-09-12 11:34:36.342472611 -0500
+++ git-linus/arch/ia64/sn/kernel/setup.c 2005-09-30 14:49:50.941056190 -0500
@@ -281,15 +281,21 @@ void __init sn_setup(char **cmdline_p)
#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
/*
* If there was a primary vga adapter identified through the
- * EFI PCDP table, make it the preferred console. Otherwise
+ * EFI PCDP table, and no console was specified on the boot
+ * line, make vga the preferred console.
+ *
+ * If no vga adapter was found, and no console was specified on
+ * the boot line, make the L1 console the preferred console and
* zero out conswitchp.
*/

if (vga_console_membase) {
- /* usable vga ... make tty0 the preferred default console */
- add_preferred_console("tty", 0, NULL);
+ if (!strstr(*cmdline_p, "console="))
+ add_preferred_console("tty", 0, NULL);
} else {
printk(KERN_DEBUG "SGI: Disabling VGA console\n");
+ if (!strstr(*cmdline_p, "console="))
+ add_preferred_console("ttySG", 0, NULL);
#ifdef CONFIG_DUMMY_CONSOLE
conswitchp = &dummy_con;
#else
Index: git-linus/drivers/firmware/pcdp.c
=================================--- git-linus.orig/drivers/firmware/pcdp.c 2005-08-24 16:06:59.911622221 -0500
+++ git-linus/drivers/firmware/pcdp.c 2005-09-30 14:49:50.998667555 -0500
@@ -99,9 +99,6 @@ efi_setup_pcdp_console(char *cmdline)
if (strstr(cmdline, "console=hcdp")) {
if (pcdp->rev < 3)
serial = 1;
- } else if (strstr(cmdline, "console=")) {
- printk(KERN_INFO "Explicit \"console=\"; ignoring PCDP\n");
- return -ENODEV;
}

if (pcdp->rev < 3 && efi_uart_console_only())

#1 lore raw
Quoted 8 lines · Greg Edwards

Set the preferred console on Altix, if no console=<console> was passed on the boot line.

Bjorn, the hunk I removed in pcdp.c broke the vga console on Altix and the virtual terminal if any console= was passed in. For example, if you booted with console=ttySG0 (the L1 serial console), there would be no login prompt on tty1 when you got to multiuser, even though a getty was running. Is removing this ok?

I don't think removing the pcdp.c hunk is the right fix.

The PCDP not a device discovery interface. The OS must be able to discover console devices some other way, and the PCDP is only a mechanism for firmware to tell the OS which of those devices to use. That's why we ignore the PCDP if the user explicitly uses "console=" -- he's saying "ignore what the firmware told you, and use *this* device as the console."

So the intent is that pcdp.c should be completely optional, i.e., it basically gives you a pointer to a device that is completely described elsewhere, either in ACPI or by standard PCI enumeration. If you turn off "CONFIG_EFI_PCDP", everything should work (except that now you have to use "console=" if you want something other than the default console).

But I think that if you turn off CONFIG_EFI_PCDP, your VGA device won't work at all, because you're relying on the PCDP to set vga_console_{iobase,membase}, and there's currently no other way those get set.

I think what *should* happen is that we should discover VGA devices by PCI enumeration, and the iobase/membase information would come from the ACPI description of the PCI root bridges. Then we could support multiple VGA devices, and the PCDP could point to one of them to be used as the console.

The VGA code in the kernel is a long ways from that. But your firmware should provide the vga_console_{iobase,membase} data somewhere besides the PCDP. Can you do something in ia64/sn to dig it out?

#2 lore raw
In reply to Greg Edwards

On Fri, Sep 30, 2005 at 03:20:11PM -0600, Bjorn Helgaas wrote:

| I think what *should* happen is that we should discover VGA
| devices by PCI enumeration, and the iobase/membase information
| would come from the ACPI description of the PCI root bridges.
| Then we could support multiple VGA devices, and the PCDP could
| point to one of them to be used as the console.
| 
| The VGA code in the kernel is a long ways from that.  But your
| firmware should provide the vga_console_{iobase,membase} data
| somewhere besides the PCDP.  Can you do something in ia64/sn
| to dig it out?

Thanks for the info and suggestion, Bjorn. I think we should be able to come up with something in sn-specific code. I'll talk to our I/O guys and see what we can come up with.

Greg

#3 lore raw
In reply to Greg Edwards
Quoted 12 lines · Greg Edwards

On Fri, Sep 30, 2005 at 03:20:11PM -0600, Bjorn Helgaas wrote:

| I think what *should* happen is that we should discover VGA
| devices by PCI enumeration, and the iobase/membase information
| would come from the ACPI description of the PCI root bridges.
| Then we could support multiple VGA devices, and the PCDP could
| point to one of them to be used as the console.
| 
| The VGA code in the kernel is a long ways from that.  But your
| firmware should provide the vga_console_{iobase,membase} data
| somewhere besides the PCDP.  Can you do something in ia64/sn
| to dig it out?
Quoted 5 lines

Thanks for the info and suggestion, Bjorn. I think we should be able to come up with something in sn-specific code. I'll talk to our I/O guys and see what we can come up with.

Greg

Our prom currently does not build up ACPI tables describing PCI (or any IO) devices. We are working toward that goal, but it is still
work in progress and will be some time yet before this is done.

It is because of this shortcoming that we have to rely on the PCDP table to provide the io addresses needed for VGA console.

Outside of PCDP, our earliest opportunity to get information about VGA devices is through the call sequence initiated with subsys_initcall(sn_pci_init), which would seem way too late for early boot messages.

Out of curiousity, what are the mmio_tra/ioport_tra fields in the PCDP PCI interface structure intended for if not for this purpose?

Mark

#4 lore raw
In reply to Greg Edwards
Quoted 5 lines

Our prom currently does not build up ACPI tables describing PCI (or any IO)
devices. We are working toward that goal, but it is still work in progress and will be some time yet before this is done.

Quoted 7 lines

It is because of this shortcoming that we have to rely on the PCDP table to provide the io addresses needed for VGA console.

Outside of PCDP, our earliest opportunity to get information about VGA devices is through the call sequence initiated with subsys_initcall(sn_pci_init), which would seem way too late for early boot messages.

It's the same for us. We don't find out about our built-in serial ports until the 8250 driver initializes, which is pretty late. So we have "8250_early" that uses information from the PCDP to talk to the serial port before the normal 8250 driver discovers it. The important thing is that the PCDP doesn't influence the naming of the device (and there isn't really a "name" for VGA devices, AFAIK).

Quoted 2 lines

Out of curiousity, what are the mmio_tra/ioport_tra fields in the PCDP PCI interface structure intended for if not for this purpose?

You *can* use the _tra fields in the PCDP -- that's what they're there for. But the PCDP should be *optional*, and I think it's not for your current setup.

If we don't build pcdp.o on an HP box, the console still works just fine; it just doesn't work until the 8250 driver discovers the port, which is fairly late.

So I think all you need to do is add some SN-specific code somewhere that discovers the VGA device. It sounds like the only way to do that right now is to get the information from the PCDP, so I guess that's what you need to do. But having this duplicated in the SN code means that you won't need the change to pcdp.c.

#5 lore raw
In reply to Greg Edwards
Quoted 13 lines · Bjorn Helgaas
Quoted 5 lines

Our prom currently does not build up ACPI tables describing PCI (or any IO)
devices. We are working toward that goal, but it is still work in progress and will be some time yet before this is done.

Quoted 7 lines

It is because of this shortcoming that we have to rely on the PCDP table to provide the io addresses needed for VGA console.

Outside of PCDP, our earliest opportunity to get information about VGA devices is through the call sequence initiated with subsys_initcall(sn_pci_init), which would seem way too late for early boot messages.

Quoted 7 lines

It's the same for us. We don't find out about our built-in serial ports until the 8250 driver initializes, which is pretty late. So we have "8250_early" that uses information from the PCDP to talk to the serial port before the normal 8250 driver discovers it. The important thing is that the PCDP doesn't influence the naming of the device (and there isn't really a "name" for VGA devices, AFAIK).

Ok. I was assuming that tty0 implied a vga device, but I guess tty0 is really the VT driver which drives whatever conswitchp is pointing to ...

Quoted 12 lines
Quoted 3 lines

Out of curiousity, what are the mmio_tra/ioport_tra fields in the PCDP PCI interface structure intended for if not for this purpose?

You *can* use the _tra fields in the PCDP -- that's what they're there for. But the PCDP should be *optional*, and I think it's not for your current setup.

If we don't build pcdp.o on an HP box, the console still works just fine; it just doesn't work until the 8250 driver discovers the port, which is fairly late.

Quoted 7 lines

So I think all you need to do is add some SN-specific code somewhere that discovers the VGA device. It sounds like the only way to do that right now is to get the information from the PCDP, so I guess that's what you need to do. But having this duplicated in the SN code means that you won't need the change to pcdp.c.

Ok. One other hitch is that the sn prom doesn't guarantee that all VGA cards will have their firmware executed. The only vga cards guaranteed to be init'd are the ones present in the pcdp table which could be a subset of the vga cards in a system. Were it not for this, we could just pick one (say lowest segment/bus number or some such thing) during sn pci discovery. But we'll have to scan the pcdp in order to see what cards are available (unless there's some other standard way to tell if a vga card is initialized).

Mark

#6 lore raw
In reply to Greg Edwards
Quoted 32 lines · Bjorn Helgaas
Quoted 5 lines

Our prom currently does not build up ACPI tables describing PCI (or any IO)
devices. We are working toward that goal, but it is still work in progress and will be some time yet before this is done.

Quoted 7 lines

It is because of this shortcoming that we have to rely on the PCDP table to provide the io addresses needed for VGA console.

Outside of PCDP, our earliest opportunity to get information about VGA devices is through the call sequence initiated with subsys_initcall(sn_pci_init), which would seem way too late for early boot messages.

It's the same for us. We don't find out about our built-in serial ports until the 8250 driver initializes, which is pretty late. So we have "8250_early" that uses information from the PCDP to talk to the serial port before the normal 8250 driver discovers it. The important thing is that the PCDP doesn't influence the naming of the device (and there isn't really a "name" for VGA devices, AFAIK).

Quoted 2 lines

Out of curiousity, what are the mmio_tra/ioport_tra fields in the PCDP PCI interface structure intended for if not for this purpose?

You *can* use the _tra fields in the PCDP -- that's what they're there for. But the PCDP should be *optional*, and I think it's not for your current setup.

If we don't build pcdp.o on an HP box, the console still works just fine; it just doesn't work until the 8250 driver discovers the port, which is fairly late.

Quoted 7 lines

So I think all you need to do is add some SN-specific code somewhere that discovers the VGA device. It sounds like the only way to do that right now is to get the information from the PCDP, so I guess that's what you need to do. But having this duplicated in the SN code means that you won't need the change to pcdp.c.

Finally getting back to this ...

So we will dup some of the PCDP scan code in sn/kernel/setup.c for the time being. Does anyone have a problem with moving drivers/firmware/pcdp.h under include/asm-ia64 so that I don't also have to dup the structure definitions?

thanks
Mark

#7 lore raw
In reply to Greg Edwards
Quoted 3 lines · Mark Maule

So we will dup some of the PCDP scan code in sn/kernel/setup.c for the time being. Does anyone have a problem with moving drivers/firmware/pcdp.h under include/asm-ia64 so that I don't also have to dup the structure definitions?

I don't want to move pcdp.h under asm-ia64. EFI (and, I hope, PCDP) is coming to x86 soon. There's nothing ia64-specific in pcdp.h or pcdp.c, so I think it would be a mistake to move it to an arch-specific directory.

#8 lore raw
In reply to Greg Edwards
Quoted 9 lines · Bjorn Helgaas
Quoted 3 lines · Mark Maule

So we will dup some of the PCDP scan code in sn/kernel/setup.c for the time being. Does anyone have a problem with moving drivers/firmware/pcdp.h under include/asm-ia64 so that I don't also have to dup the structure definitions?

I don't want to move pcdp.h under asm-ia64. EFI (and, I hope, PCDP) is coming to x86 soon. There's nothing ia64-specific in pcdp.h or pcdp.c, so I think it would be a mistake to move it to an arch-specific directory.

Ok, thanks Bjorn. I was under the impression that stuff under dig64.org was ia64 specific ...

Would moving it to include/linux be an option? If not I'll just dup the structs that I need for this.

Mark

#9 lore raw
In reply to Greg Edwards
Quoted 11 lines · Mark Maule
Quoted 9 lines · Bjorn Helgaas
Quoted 3 lines · Mark Maule

So we will dup some of the PCDP scan code in sn/kernel/setup.c for the time being. Does anyone have a problem with moving drivers/firmware/pcdp.h under include/asm-ia64 so that I don't also have to dup the structure definitions?

I don't want to move pcdp.h under asm-ia64. EFI (and, I hope, PCDP) is coming to x86 soon. There's nothing ia64-specific in pcdp.h or pcdp.c, so I think it would be a mistake to move it to an arch-specific directory.

Quoted 4 lines

Ok, thanks Bjorn. I was under the impression that stuff under dig64.org was ia64 specific ...

Would moving it to include/linux be an option?

I sort of hate to put it in include/linux, too, but I guess it's already a dumping ground for all sorts of miscellaneous stuff, so one more wouldn't make it much worse.

And I can't think of any better options.

#10 lore raw
In reply to Greg Edwards

New version of Greg's original patch per review comments from Bjorn:

Fix default VGA console on SN platforms. Since SN firmware does not pass enough ACPI information to identify VGA cards and the associated legacy IO/MEM addresses, we rely on the EFI PCDP table. Since the linux pcdp driver is optional (and overridden if console= directives are used) SN duplicates a portion of the pcdp scan code to identify if there is a usable console VGA adapter.

To avoid also dup'ing PCDP structures, drivers/firmware/pcdp.h is moved to include/linux/pcdp.h.

Index: vga/arch/ia64/sn/kernel/setup.c
=================================--- vga.orig/arch/ia64/sn/kernel/setup.c 2005-10-12 10:36:40.914797412 -0500
+++ vga/arch/ia64/sn/kernel/setup.c 2005-10-12 11:50:44.543433497 -0500
@@ -30,6 +30,8 @@
#include <linux/root_dev.h>
#include <linux/nodemask.h>
#include <linux/pm.h>
+#include <linux/efi.h>
+#include <linux/pcdp.h>

#include <asm/io.h>
#include <asm/sal.h>
@@ -242,6 +244,48 @@
}
}

+static void
+sn_scan_pcdp(void)
+{
+ u8 *bp;
+ struct pcdp *pcdp;
+ struct pcdp_device device;
+ struct pcdp_if_pci if_pci;
+ extern struct efi efi;
+
+ pcdp = efi.hcdp;
+ if (! pcdp)
+ return; /* no hcdp/pcdp table */
+
+ if (pcdp->rev < 3)
+ return; /* only support PCDP (rev >= 3) */
+
+ for (bp = (u8 *)&pcdp->uart[pcdp->num_uarts];
+ bp < (u8 *)pcdp + pcdp->length;
+ bp += device.length) {
+ memcpy(&device, bp, sizeof(device));
+ if (! (device.flags & PCDP_PRIMARY_CONSOLE))
+ continue; /* not primary console */
+
+ if (device.type != PCDP_CONSOLE_VGA)
+ continue; /* not VGA descriptor */
+
+ memcpy(&if_pci, bp+sizeof(device), sizeof(if_pci));
+ if (if_pci.interconnect != PCDP_IF_PCI)
+ continue; /* not PCI interconnect */
+
+ if (if_pci.trans & PCDP_PCI_TRANS_IOPORT)
+ vga_console_iobase + if_pci.ioport_tra | __IA64_UNCACHED_OFFSET;
+
+ if (if_pci.trans & PCDP_PCI_TRANS_MMIO)
+ vga_console_membase + if_pci.mmio_tra | __IA64_UNCACHED_OFFSET;
+
+ break; /* once we find the primary, we're done */
+ }
+}
+
/**
* sn_setup - SN platform setup routine
* @cmdline_p: kernel command line
@@ -263,16 +307,35 @@

#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
/*
- * If there was a primary vga adapter identified through the
- * EFI PCDP table, make it the preferred console. Otherwise
- * zero out conswitchp.
+ * Handle SN vga console.
+ *
+ * SN systems do not have enough ACPI table information
+ * being passed from prom to identify VGA adapters and the legacy
+ * addresses to access them. Until that is done, SN systems rely
+ * on the PCDP table to identify the primary VGA console if one
+ * exists.
+ *
+ * However, kernel PCDP support is optional, and even if it is built
+ * into the kernel, it will not be used if the boot cmdline contains
+ * console= directives.
+ *
+ * So, to work around this mess, we duplicate some of the PCDP code
+ * here so that the primary VGA console (as defined by PCDP) will
+ * work on SN systems even if a different console (e.g. serial) is
+ * selected on the boot line (or CONFIG_EFI_PCDP is off).
*/

+ if (! vga_console_membase)
+ sn_scan_pcdp();
+
if (vga_console_membase) {
/* usable vga ... make tty0 the preferred default console */
- add_preferred_console("tty", 0, NULL);
+ if (!strstr(*cmdline_p, "console="))
+ add_preferred_console("tty", 0, NULL);
} else {
printk(KERN_DEBUG "SGI: Disabling VGA console\n");
+ if (!strstr(*cmdline_p, "console="))
+ add_preferred_console("ttySG", 0, NULL);
#ifdef CONFIG_DUMMY_CONSOLE
conswitchp = &dummy_con;
#else
Index: vga/drivers/firmware/pcdp.c
=================================--- vga.orig/drivers/firmware/pcdp.c 2005-10-12 10:36:40.915773877 -0500
+++ vga/drivers/firmware/pcdp.c 2005-10-12 10:43:38.156192381 -0500
@@ -16,8 +16,8 @@
#include <linux/console.h>
#include <linux/efi.h>
#include <linux/serial.h>
+#include <linux/pcdp.h>
#include <asm/vga.h>
-#include "pcdp.h"

static int __init
setup_serial_console(struct pcdp_uart *uart)
Index: vga/drivers/firmware/pcdp.h
=================================--- vga.orig/drivers/firmware/pcdp.h 2005-10-12 10:36:40.914797412 -0500
+++ /dev/null 1970-01-01 00:00:00.000000000 +0000
@@ -1,111 +0,0 @@
-/*
- * Definitions for PCDP-defined console devices
- *
- * v1.0a: http://www.dig64.org/specifications/DIG64_HCDPv10a_01.pdf
- * v2.0: http://www.dig64.org/specifications/DIG64_PCDPv20.pdf
- *
- * (c) Copyright 2002, 2004 Hewlett-Packard Development Company, L.P.
- * Khalid Aziz <[email protected]>
- * Bjorn Helgaas <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#define PCDP_CONSOLE 0
-#define PCDP_DEBUG 1
-#define PCDP_CONSOLE_OUTPUT 2
-#define PCDP_CONSOLE_INPUT 3
-
-#define PCDP_UART (0 << 3)
-#define PCDP_VGA (1 << 3)
-#define PCDP_USB (2 << 3)
-
-/* pcdp_uart.type and pcdp_device.type */
-#define PCDP_CONSOLE_UART (PCDP_UART | PCDP_CONSOLE)

-#define PCDP_DEBUG_UART			(PCDP_UART | PCDP_DEBUG)
-#define PCDP_CONSOLE_VGA		(PCDP_VGA  | PCDP_CONSOLE_OUTPUT)
-#define PCDP_CONSOLE_USB		(PCDP_USB  | PCDP_CONSOLE_INPUT)

-
-/* pcdp_uart.flags */
-#define PCDP_UART_EDGE_SENSITIVE (1 << 0)
-#define PCDP_UART_ACTIVE_LOW (1 << 1)
-#define PCDP_UART_PRIMARY_CONSOLE (1 << 2)
-#define PCDP_UART_IRQ (1 << 6) /* in pci_func for rev < 3 */
-#define PCDP_UART_PCI (1 << 7) /* in pci_func for rev < 3 */
-
-struct pcdp_uart {
- u8 type;
- u8 bits;
- u8 parity;
- u8 stop_bits;
- u8 pci_seg;
- u8 pci_bus;
- u8 pci_dev;
- u8 pci_func;
- u64 baud;
- struct acpi_generic_address addr;
- u16 pci_dev_id;
- u16 pci_vendor_id;
- u32 gsi;
- u32 clock_rate;
- u8 pci_prog_intfc;
- u8 flags;
- u16 conout_index;
- u32 reserved;
-} __attribute__((packed));
-
-#define PCDP_IF_PCI 1
-
-/* pcdp_if_pci.trans */
-#define PCDP_PCI_TRANS_IOPORT 0x02
-#define PCDP_PCI_TRANS_MMIO 0x01
-
-struct pcdp_if_pci {
- u8 interconnect;
- u8 reserved;
- u16 length;
- u8 segment;
- u8 bus;
- u8 dev;
- u8 fun;
- u16 dev_id;
- u16 vendor_id;
- u32 acpi_interrupt;
- u64 mmio_tra;
- u64 ioport_tra;
- u8 flags;
- u8 trans;
-} __attribute__((packed));
-
-struct pcdp_vga {
- u8 count; /* address space descriptors */
-} __attribute__((packed));
-
-/* pcdp_device.flags */
-#define PCDP_PRIMARY_CONSOLE 1
-
-struct pcdp_device {
- u8 type;
- u8 flags;
- u16 length;
- u16 efi_index;
- /* next data is pcdp_if_pci or pcdp_if_acpi (not yet supported) */
- /* next data is device specific type (currently only pcdp_vga) */
-} __attribute__((packed));
-
-struct pcdp {
- u8 signature[4];
- u32 length;
- u8 rev; /* PCDP v2.0 is rev 3 */
- u8 chksum;
- u8 oemid[6];
- u8 oem_tabid[8];
- u32 oem_rev;
- u8 creator_id[4];
- u32 creator_rev;
- u32 num_uarts;
- struct pcdp_uart uart[0]; /* actual size is num_uarts */
- /* remainder of table is pcdp_device structures */
-} __attribute__((packed));
Index: vga/include/linux/pcdp.h
=================================--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ vga/include/linux/pcdp.h 2005-10-12 10:43:38.172792280 -0500
@@ -0,0 +1,111 @@
+/*
+ * Definitions for PCDP-defined console devices
+ *
+ * v1.0a: http://www.dig64.org/specifications/DIG64_HCDPv10a_01.pdf
+ * v2.0: http://www.dig64.org/specifications/DIG64_PCDPv20.pdf
+ *
+ * (c) Copyright 2002, 2004 Hewlett-Packard Development Company, L.P.
+ * Khalid Aziz <[email protected]>
+ * Bjorn Helgaas <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#define PCDP_CONSOLE 0
+#define PCDP_DEBUG 1
+#define PCDP_CONSOLE_OUTPUT 2
+#define PCDP_CONSOLE_INPUT 3
+
+#define PCDP_UART (0 << 3)
+#define PCDP_VGA (1 << 3)
+#define PCDP_USB (2 << 3)
+
+/* pcdp_uart.type and pcdp_device.type */
+#define PCDP_CONSOLE_UART (PCDP_UART | PCDP_CONSOLE)

+#define PCDP_DEBUG_UART			(PCDP_UART | PCDP_DEBUG)
+#define PCDP_CONSOLE_VGA		(PCDP_VGA  | PCDP_CONSOLE_OUTPUT)
+#define PCDP_CONSOLE_USB		(PCDP_USB  | PCDP_CONSOLE_INPUT)

+
+/* pcdp_uart.flags */
+#define PCDP_UART_EDGE_SENSITIVE (1 << 0)
+#define PCDP_UART_ACTIVE_LOW (1 << 1)
+#define PCDP_UART_PRIMARY_CONSOLE (1 << 2)
+#define PCDP_UART_IRQ (1 << 6) /* in pci_func for rev < 3 */
+#define PCDP_UART_PCI (1 << 7) /* in pci_func for rev < 3 */
+
+struct pcdp_uart {
+ u8 type;
+ u8 bits;
+ u8 parity;
+ u8 stop_bits;
+ u8 pci_seg;
+ u8 pci_bus;
+ u8 pci_dev;
+ u8 pci_func;
+ u64 baud;
+ struct acpi_generic_address addr;
+ u16 pci_dev_id;
+ u16 pci_vendor_id;
+ u32 gsi;
+ u32 clock_rate;
+ u8 pci_prog_intfc;
+ u8 flags;
+ u16 conout_index;
+ u32 reserved;
+} __attribute__((packed));
+
+#define PCDP_IF_PCI 1
+
+/* pcdp_if_pci.trans */
+#define PCDP_PCI_TRANS_IOPORT 0x02
+#define PCDP_PCI_TRANS_MMIO 0x01
+
+struct pcdp_if_pci {
+ u8 interconnect;
+ u8 reserved;
+ u16 length;
+ u8 segment;
+ u8 bus;
+ u8 dev;
+ u8 fun;
+ u16 dev_id;
+ u16 vendor_id;
+ u32 acpi_interrupt;
+ u64 mmio_tra;
+ u64 ioport_tra;
+ u8 flags;
+ u8 trans;
+} __attribute__((packed));
+
+struct pcdp_vga {
+ u8 count; /* address space descriptors */
+} __attribute__((packed));
+
+/* pcdp_device.flags */
+#define PCDP_PRIMARY_CONSOLE 1
+
+struct pcdp_device {
+ u8 type;
+ u8 flags;
+ u16 length;
+ u16 efi_index;
+ /* next data is pcdp_if_pci or pcdp_if_acpi (not yet supported) */
+ /* next data is device specific type (currently only pcdp_vga) */
+} __attribute__((packed));
+
+struct pcdp {
+ u8 signature[4];
+ u32 length;
+ u8 rev; /* PCDP v2.0 is rev 3 */
+ u8 chksum;
+ u8 oemid[6];
+ u8 oem_tabid[8];
+ u32 oem_rev;
+ u8 creator_id[4];
+ u32 creator_rev;
+ u32 num_uarts;
+ struct pcdp_uart uart[0]; /* actual size is num_uarts */
+ /* remainder of table is pcdp_device structures */
+} __attribute__((packed));

author Acked-by on v1 1/1
#11 lore raw
In reply to Greg Edwards

On Wed, Oct 12, 2005 at 01:55:02PM -0500, Mark Maule wrote:

| New version of Greg's original patch per review comments from Bjorn:
| 
| 
| Fix default VGA console on SN platforms.  Since SN firmware does not pass
| enough ACPI information to identify VGA cards and the associated legacy IO/MEM
| addresses, we rely on the EFI PCDP table.  Since the linux pcdp driver is
| optional (and overridden if console= directives are used) SN duplicates a
| portion of the pcdp scan code to identify if there is a usable console VGA
| adapter.
| 
| To avoid also dup'ing PCDP structures, drivers/firmware/pcdp.h is moved to
| include/linux/pcdp.h.
| 
| Signed-off-by: Mark Maule <[email protected]>

This does fix the problem I was experiencing earlier while booting with console= boot options.

#12 lore raw
In reply to Greg Edwards
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

I don't want to move pcdp.h under asm-ia64. EFI (and, I hope, PCDP) is coming to x86 soon. There's nothing ia64-specific in pcdp.h or pcdp.c, so I think it would be a mistake to move it to an arch-specific directory.

Ok, thanks Bjorn. I was under the impression that stuff under dig64.org was ia64 specific ...

Quoted 7 lines
Quoted 1 line

Would moving it to include/linux be an option?

I sort of hate to put it in include/linux, too, but I guess it's already a dumping ground for all sorts of miscellaneous stuff, so one more wouldn't make it much worse.

And I can't think of any better options.

The comments at the head of pcdp.h certainly make it look very ia64 specific. Are there any newer EFI documents that it could point to instead of the dig64.org URLs?

Linus is just as fond of EFI as he is of ACPI (i.e. not at all), so I don't think he'll be too happy with include/linux/pcdp.h If it really is the only place for this to move, then this discussion needs to happen on linux-kernel, not on linux-ia64.

Since PCDP is closely linked to ACPI, would include/acpi/pcdp.h be at all plausible? At least this keeps all the bits Linus doesn't like together and he can more easily avert his eyes.

Or, merge the contents into include/linux/efi.h?

-Tony

#13 lore raw
In reply to Greg Edwards
Quoted 14 lines · Tony
Quoted 14 lines
Quoted 9 lines
Quoted 4 lines

I don't want to move pcdp.h under asm-ia64. EFI (and, I hope, PCDP) is coming to x86 soon. There's nothing ia64-specific in pcdp.h or pcdp.c, so I think it would be a mistake to move it to an arch-specific directory.

Ok, thanks Bjorn. I was under the impression that stuff under dig64.org was ia64 specific ...

Would moving it to include/linux be an option?

I sort of hate to put it in include/linux, too, but I guess it's already a dumping ground for all sorts of miscellaneous stuff, so one more wouldn't make it much worse.

Quoted 5 lines
Quoted 1 line

And I can't think of any better options.

The comments at the head of pcdp.h certainly make it look very ia64 specific. Are there any newer EFI documents that it could point to instead of the dig64.org URLs?

The point of the PCDP is to tell the OS what console firmware was using, so you don't need "console=" arguments. It's defined to be very easy to parse, so the OS can use it before ACPI or PCI device enumeration.

So other than the URL that contains "dig64", there's nothing ia64-specific. Matt Tolentino (Intel) was hoping that the PCDP or something similar would eventually be supported on x86 as well. But that world still has its blinders on and assumes all the world is VGA, and seems to think that if you want something other than VGA, by George, you ought to *have* to use "console=".

Quoted 7 lines

Linus is just as fond of EFI as he is of ACPI (i.e. not at all), so I don't think he'll be too happy with include/linux/pcdp.h If it really is the only place for this to move, then this discussion needs to happen on linux-kernel, not on linux-ia64.

Since PCDP is closely linked to ACPI, would include/acpi/pcdp.h be at all plausible?

PCDP is not linked with ACPI at all, except that it happens to use an address structure that matches the ACPI "generic address". We should probably just duplicate that structure definition and kill the linux/acpi.h include.

Quoted 1 line

Or, merge the contents into include/linux/efi.h?

This would be a possibility. But other than the fact that we get the address of the PCDP from EFI, there's no EFI dependency either.

The only problem with the current location is that SGI firmware doesn't have quite enough device enumeration support for their VGA devices, so they have to depend on the PCDP as a crutch. So maybe we should just leave pcdp.h alone and make SGI duplicate what they need.

#14 lore raw
In reply to Greg Edwards
Quoted 53 lines · Bjorn Helgaas
Quoted 14 lines · Tony
Quoted 14 lines
Quoted 9 lines
Quoted 4 lines

I don't want to move pcdp.h under asm-ia64. EFI (and, I hope, PCDP) is coming to x86 soon. There's nothing ia64-specific in pcdp.h or pcdp.c, so I think it would be a mistake to move it to an arch-specific directory.

Ok, thanks Bjorn. I was under the impression that stuff under dig64.org was ia64 specific ...

Would moving it to include/linux be an option?

I sort of hate to put it in include/linux, too, but I guess it's already a dumping ground for all sorts of miscellaneous stuff, so one more wouldn't make it much worse.

Quoted 5 lines
Quoted 1 line

And I can't think of any better options.

The comments at the head of pcdp.h certainly make it look very ia64 specific. Are there any newer EFI documents that it could point to instead of the dig64.org URLs?

The point of the PCDP is to tell the OS what console firmware was using, so you don't need "console=" arguments. It's defined to be very easy to parse, so the OS can use it before ACPI or PCI device enumeration.

So other than the URL that contains "dig64", there's nothing ia64-specific. Matt Tolentino (Intel) was hoping that the PCDP or something similar would eventually be supported on x86 as well. But that world still has its blinders on and assumes all the world is VGA, and seems to think that if you want something other than VGA, by George, you ought to *have* to use "console=".

Quoted 7 lines

Linus is just as fond of EFI as he is of ACPI (i.e. not at all), so I don't think he'll be too happy with include/linux/pcdp.h If it really is the only place for this to move, then this discussion needs to happen on linux-kernel, not on linux-ia64.

Since PCDP is closely linked to ACPI, would include/acpi/pcdp.h be at all plausible?

PCDP is not linked with ACPI at all, except that it happens to use an address structure that matches the ACPI "generic address". We should probably just duplicate that structure definition and kill the linux/acpi.h include.

Quoted 1 line

Or, merge the contents into include/linux/efi.h?

This would be a possibility. But other than the fact that we get the address of the PCDP from EFI, there's no EFI dependency either.

Quoted 5 lines

The only problem with the current location is that SGI firmware doesn't have quite enough device enumeration support for their VGA devices, so they have to depend on the PCDP as a crutch. So maybe we should just leave pcdp.h alone and make SGI duplicate what they need.

I'm ok with that too. Just thought it was a little neater to not dup the structs. This is probably better in the long run anyway as we can more easily rip the crutches out as we move forward with ACPI.

Mark

#15 lore raw

PATCH 1/1 set altix preferred console

In reply to Greg Edwards

Fix default VGA console on SN platforms. Since SN firmware does not pass enough ACPI information to identify VGA cards and the associated legacy IO/MEM addresses, we rely on the EFI PCDP table. Since the linux pcdp driver is optional (and overridden if console= directives are used) SN duplicates a portion of the pcdp scan code to identify if there is a usable console VGA adapter. Additionally, dup necessary pcdp related structs to avoid dragging drivers/pcdp.h into a more public location.

Index: vga/arch/ia64/sn/kernel/setup.c
=================================--- vga.orig/arch/ia64/sn/kernel/setup.c 2005-10-12 10:36:40.914797412 -0500
+++ vga/arch/ia64/sn/kernel/setup.c 2005-11-09 11:28:04.181164653 -0600
@@ -30,6 +30,7 @@
#include <linux/root_dev.h>
#include <linux/nodemask.h>
#include <linux/pm.h>
+#include <linux/efi.h>

#include <asm/io.h>
#include <asm/sal.h>
@@ -242,6 +243,135 @@
}
}

+/*
+ * Scan the EFI PCDP table (if it exists) for an acceptable VGA console
+ * output device. If one exists, pick it and set sn_legacy_{io,mem} to
+ * reflect the bus offsets needed to address it.
+ *
+ * Since pcdp support in SN is not supported in the 2.4 kernel (or at least
+ * the one lbs is based on) just declare the needed structs here.
+ *
+ * Reference spec http://www.dig64.org/specifications/DIG64_PCDPv20.pdf
+ *
+ * Returns 0 if no acceptable vga is found, !0 otherwise.
+ *
+ * Note: This stuff is duped here because Altix requires the PCDP to
+ * locate a usable VGA device due to lack of proper ACPI support. Structures
+ * could be used from drivers/firmware/pcdp.h, but it was decided that moving
+ * this file to a more public location just for Altix use was undesireable.
+ */
+
+struct hcdp_uart_desc {
+ u8 pad[45];
+};
+
+struct pcdp {
+ u8 signature[4]; /* should be 'HCDP' */
+ u32 length;
+ u8 rev; /* should be >=3 for pcdp, <3 for hcdp */
+ u8 sum;
+ u8 oem_id[6];
+ u64 oem_tableid;
+ u32 oem_rev;
+ u32 creator_id;
+ u32 creator_rev;
+ u32 num_type0;
+ struct hcdp_uart_desc uart[0]; /* num_type0 of these */
+ /* pcdp descriptors follow */
+} __attribute__((packed));
+
+struct pcdp_device_desc {
+ u8 type;
+ u8 primary;
+ u16 length;
+ u16 index;
+ /* interconnect specific structure follows */
+ /* device specific structure follows that */
+} __attribute__((packed));
+
+struct pcdp_interface_pci {
+ u8 type; /* 1 = pci */
+ u8 reserved;
+ u16 length;
+ u8 segment;
+ u8 bus;
+ u8 dev;
+ u8 fun;
+ u16 devid;
+ u16 vendid;
+ u32 acpi_interrupt;
+ u64 mmio_tra;
+ u64 ioport_tra;
+ u8 flags;
+ u8 translation;
+} __attribute__((packed));
+
+struct pcdp_vga_device {
+ u8 num_eas_desc;
+ /* ACPI Extended Address Space Desc follows */
+} __attribute__((packed));
+
+/* from pcdp_device_desc.primary */
+#define PCDP_PRIMARY_CONSOLE 0x01
+
+/* from pcdp_device_desc.type */
+#define PCDP_CONSOLE_INOUT 0x0
+#define PCDP_CONSOLE_DEBUG 0x1
+#define PCDP_CONSOLE_OUT 0x2
+#define PCDP_CONSOLE_IN 0x3
+#define PCDP_CONSOLE_TYPE_VGA 0x8
+
+#define PCDP_CONSOLE_VGA (PCDP_CONSOLE_TYPE_VGA | PCDP_CONSOLE_OUT)
+
+/* from pcdp_interface_pci.type */
+#define PCDP_IF_PCI 1
+
+/* from pcdp_interface_pci.translation */
+#define PCDP_PCI_TRANS_IOPORT 0x02
+#define PCDP_PCI_TRANS_MMIO 0x01
+
+static void
+sn_scan_pcdp(void)
+{
+ u8 *bp;
+ struct pcdp *pcdp;
+ struct pcdp_device_desc device;
+ struct pcdp_interface_pci if_pci;
+ extern struct efi efi;
+
+ pcdp = efi.hcdp;
+ if (! pcdp)
+ return; /* no hcdp/pcdp table */
+
+ if (pcdp->rev < 3)
+ return; /* only support PCDP (rev >= 3) */
+
+ for (bp = (u8 *)&pcdp->uart[pcdp->num_type0];
+ bp < (u8 *)pcdp + pcdp->length;
+ bp += device.length) {
+ memcpy(&device, bp, sizeof(device));
+ if (! (device.primary & PCDP_PRIMARY_CONSOLE))
+ continue; /* not primary console */
+
+ if (device.type != PCDP_CONSOLE_VGA)
+ continue; /* not VGA descriptor */
+
+ memcpy(&if_pci, bp+sizeof(device), sizeof(if_pci));
+ if (if_pci.type != PCDP_IF_PCI)
+ continue; /* not PCI interconnect */
+
+ if (if_pci.translation & PCDP_PCI_TRANS_IOPORT)
+ vga_console_iobase + if_pci.ioport_tra | __IA64_UNCACHED_OFFSET;
+
+ if (if_pci.translation & PCDP_PCI_TRANS_MMIO)
+ vga_console_membase + if_pci.mmio_tra | __IA64_UNCACHED_OFFSET;
+
+ break; /* once we find the primary, we're done */
+ }
+}
+
/**
* sn_setup - SN platform setup routine
* @cmdline_p: kernel command line
@@ -263,16 +393,35 @@

#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
/*
- * If there was a primary vga adapter identified through the
- * EFI PCDP table, make it the preferred console. Otherwise
- * zero out conswitchp.
+ * Handle SN vga console.
+ *
+ * SN systems do not have enough ACPI table information
+ * being passed from prom to identify VGA adapters and the legacy
+ * addresses to access them. Until that is done, SN systems rely
+ * on the PCDP table to identify the primary VGA console if one
+ * exists.
+ *
+ * However, kernel PCDP support is optional, and even if it is built
+ * into the kernel, it will not be used if the boot cmdline contains
+ * console= directives.
+ *
+ * So, to work around this mess, we duplicate some of the PCDP code
+ * here so that the primary VGA console (as defined by PCDP) will
+ * work on SN systems even if a different console (e.g. serial) is
+ * selected on the boot line (or CONFIG_EFI_PCDP is off).
*/

+ if (! vga_console_membase)
+ sn_scan_pcdp();
+
if (vga_console_membase) {
/* usable vga ... make tty0 the preferred default console */
- add_preferred_console("tty", 0, NULL);
+ if (!strstr(*cmdline_p, "console="))
+ add_preferred_console("tty", 0, NULL);
} else {
printk(KERN_DEBUG "SGI: Disabling VGA console\n");
+ if (!strstr(*cmdline_p, "console="))
+ add_preferred_console("ttySG", 0, NULL);
#ifdef CONFIG_DUMMY_CONSOLE
conswitchp = &dummy_con;
#else