Skip to contentSkip to conversation

MIPS: SGI-IP27: add support for the IP35 (Bedrock hub) machines

PATCH In review Imre Kaloz 8 participants 76 messages Oct 13 – Nov 2

Subsystems (11)
lore
Share & tools
lore

Imre Kaloz

author
#0 lore raw

v2 cover MIPS: SGI-IP27: add support for the IP35 (Bedrock hub) machines

This series adds support for the SGI machines built around the Bedrock hub (IP35), such as Fuel and Tezro, to the IP27 platform code.

Patches 1-5 fix the config space accessors and slot setup of the Bridge, XBridge and PIC driver: device numbers past the last slot, slots the PROM leaves unconfigured, the type 1 IOC3 write, posted config writes and slots whose devio window the PROM maps elsewhere.

Patches 6-22 teach the IP27 code the Bedrock hub: detection, the node address layout and register windows, the node id, CPU slots, memory banks, both PIs and the kernel load address.

Patches 23-32 add the crossbar, bridge and I/O parts of these machines:
PXBow, XBridge, PIC and IOC4.

Patches 33-44 add the L1 system controller and what it provides, the Origin 300 IO8 serial interrupts, the Odyssey graphics widget, the KLCONFIG console and a topology package id per CPU.

Patches 45-47 add a libata driver for the IOC4 ATA/ATAPI controller, which carries the DVD-ROM of Tezro and Origin 350 I-bricks. It drives PIO4 and multiword DMA mode 2.

Patch 48 updates ip27_defconfig to the onboard hardware of these machines, dropping add-in card drivers and enabling USB and PS/2 input. Patch 49 enables the IOC4 ATA driver in it.

Patches 50-53 add a driver for the Fuel and Tezro front-panel LEDs, which the L1 sets, as white:status and red:fault. The red LED blinks on panic, and a Tezro shows the OS state on its L1 display.

The series applies on top of "[PATCH v2] MIPS: SGI-IP27: print the NMI dump on an nbcon console", which the NMI dump needs to reach the 8250 console.

Tested on SGI Fuel and Tezro, the Fuel with an LSI 53C1030 and an NVMe drive behind a PCI-X-to-PCIe bridge in slots the PROM leaves unconfigured, on a 4GB Tezro with an LSI SAS1064 on a PCI-X bus, and for patch 5 also on an Octane. Patches 50-53 were tested on a Tezro only, and patch 48 was only built.

On IP27 (Hub) machines:
- patch 22 moves the kernel up by 144KB, and the 144KB below it stays reserved and unused;
- with patch 26 SWIOTLB takes 64MB of node 0 on a multi-node Origin, and ZONE_DMA32 spans the first 2GB;
- the XBridge and PIC DMA address forms (patch 26) and the w1 change (patch 39) do nothing on a Hub with classic Bridges;
- patches 1-5 change the config space handling of its Bridges as well.

Given I have no IP27 boxes, none of this was booted on one. ip27_defconfig builds at every patch, ip30_defconfig at every patch that changes code it builds.

An XBridge or PIC on a Bedrock hub takes its board setup from the first board part number the L1 reports that the setup table knows (patch 35), so on a machine with several bricks every such bridge gets that one board's setup.

Patch 42 registers the Odyssey graphics widget as the "sgi-odyssey" platform device used by the Odyssey DRM driver, a separate series, and passes it the master widget id as the "sgi,master-widget" property.

checkpatch reports "spaces required around that ':'" in patches 14 and 21 for the GAS numeric local labels 1: and 2: in assembler macros.

Changes in v2:
- New patches 1-5 (Bridge config space and slot fixes), 37 (Origin 300 IO8 serial interrupts), 45-47 and 49 (IOC4 ATA/ATAPI), 48 (ip27_defconfig update) and 50-53 (front-panel LEDs).
- Patch 15 (was 10): slot 0 takes master_nasid as its node, not 0.
- Patch 24 (was 19): also enables the SGI 1-wire master and the DS250x slave the Bridge probe waits for.
- Patch 25 (was 20): comment and message name the IOC3 on the 32-bit window behind an XBridge or PIC.
- Patch 26 (was 21), retitled (Christoph Hellwig): an XBridge or PIC device with a 64-bit DMA mask uses the 64-bit direct form with bit 55 set, other devices the 32-bit window with SWIOTLB and ZONE_DMA32; a PIC bus in PCI-X mode uses the direct form only; the IOC3 and IOC4 always use the window, with byte swapping off; an IOC3 or IOC4 MFD cell maps through its PCI parent.
- Patch 29 (was 24): the PIC slot count goes through bridge_nslots() from patch 1.
- Patch 30 (was 25): probe fails without a platform device id.
- Patch 31 (was 26): probe fails on a PCI id without variant data; const mfd_cell array; MAINTAINERS covers sgi-ioc3-serial.h; the IOC4 register layout includes the ATA/ATAPI block; the IOC4 firmware revision is printed, and the serial ports need revision 62 or later; the PCI id is PCI_DEVICE_ID_SGI_IOC4, which patch 26 adds.
- Patch 36 (was 31): const mfd_cell array.
- Patch 38 (was 32): the random fallback address is set with eth_hw_addr_random().
- Patch 42 (was 36): passes the "sgi,master-widget" property.
- Patch 43 (was 37): the PROM's console baud rate is printed unsigned, so 38400 does not come out negative.
- mfd subjects capitalised; rebased onto v7.3-rc7 and the NMI v2 patch.
- v1: https://lore.kernel.org/all/[email protected]/

Imre Kaloz (53):
MIPS: PCI: xtalk-bridge: refuse device numbers past the last slot
MIPS: PCI: xtalk-bridge: assign slots the PROM leaves unconfigured
MIPS: PCI: xtalk-bridge: write a type 1 IOC3 through the type 1 window
MIPS: PCI: xtalk-bridge: flush config space writes
MIPS: PCI: xtalk-bridge: reassign slots whose devio window maps
elsewhere
MIPS: Xtalk: guard the widget identification table from assembly
MIPS: SGI-IP27: dump the NMI save areas the CPU scan recorded
MIPS: SGI-IP27: add REMOTE_HUB_PI_S()/REMOTE_HUB_PI_L()
MIPS: SGI-IP27: detect Bedrock hubs at boot
MIPS: SGI-IP27: widen Kconfig for the Bedrock-based machines
MIPS: SGI-IP27: fold the dead SN1 arm out of klconfig.h
MIPS: SGI-IP27: choose the node address layout at runtime
MIPS: SGI-IP27: add the Bedrock hub register windows
MIPS: SGI-IP27: decode a Bedrock hub's node id and system size
MIPS: SGI-IP27: put a Bedrock hub's boot CPU in slot 0
MIPS: SGI-IP27: lay out node memory in 1GB banks on Bedrock hubs
MIPS: SGI-IP27: reserve the bottom 64MB of node 0 on Bedrock hubs
MIPS: SGI-IP27: route interrupt masks and slices through both PIs
MIPS: SGI-IP27: address a CPU's own PI for NMI, IPI and RT counter
MIPS: SGI-IP27: take a CPU's node from the CPU table in per_cpu_init()
MIPS: SGI-IP27: resolve the mapped-kernel node shift at runtime
MIPS: SGI-IP27: load the kernel at node offset 0x40000
MIPS: SGI-IP27: xbow_probe(): recognize KLTYPE_PBRICK_XBOW
MIPS: ip27_defconfig: enable the IOC3 MFD, its cell drivers and tg3
net: ethernet: sgi: ioc3-eth: apply the DMA attributes only to 64-bit
addresses
MIPS: SGI-IP27: pick the XBridge and PIC DMA address form by mask
MIPS: SGI-IP27: recognize the PXBow crossbar
MIPS: PCI: xtalk-bridge: recognize the PIC widget's 64-bit-only
registers
MIPS: PCI: xtalk-bridge: match PIC's register-level differences
rtc: m48t35: support the SGI IP35 timekeeper's 1968 year base
mfd: ioc3: Add support for IOC4
MIPS: SGI-IP27: dispatch the early console between IOC3 and IOC4
MIPS: SGI-IP27: add L1 system controller support
MIPS: SGI-IP27: wire the L1 into reset and the Ethernet address
MIPS: PCI: xtalk-bridge: take the board part number from the L1
mfd: ioc3: Add IP34 system-board entry to ioc3_infos[]
mfd: ioc3: Cross the serial IRQs on the Origin 300 IO8
net: ethernet: sgi: ioc3-eth: fall back to the platform MAC address
MIPS: SGI-IP27: don't register a w1 master on an XBridge or PIC
MIPS: SGI-IP27: report a Bedrock machine as SGI IP35
MIPS: SGI-IP27: identify the machine by the L1 brick type
MIPS: SGI-IP27: register the Odyssey graphics widget
MIPS: SGI-IP27: take the console from the KLCONFIG header on IP35
MIPS: SGI-IP27: give each CPU its own topology package id
ata: add pata_sgiioc4 driver for the SGI IOC4 ATA/ATAPI controller
mfd: ioc3: Add IOC4 ATA/ATAPI cell
MAINTAINERS: add an entry for the SGI IOC4 ATA driver
MIPS: ip27_defconfig: update for the onboard hardware
MIPS: ip27_defconfig: enable pata_sgiioc4 and the DVD-ROM path
MIPS: SGI-IP27: add L1 front-panel LED and display requests
leds: Add driver for the SGI Fuel and Tezro front-panel LEDs
MIPS: SGI-IP27: show the OS state on the Fuel and Tezro front panels
MIPS: ip27_defconfig: enable the Fuel and Tezro front-panel LEDs

 MAINTAINERS                                   |   7 +
 arch/mips/Kconfig                             |  13 +-
 arch/mips/configs/ip27_defconfig              | 192 +---
 .../include/asm/mach-ip27/kernel-entry-init.h |  33 +-
 arch/mips/include/asm/pci/bridge.h            |  88 +-
 arch/mips/include/asm/sn/addrs.h              |  39 +-
 arch/mips/include/asm/sn/agent.h              |   5 +-
 arch/mips/include/asm/sn/arch.h               |   8 +
 arch/mips/include/asm/sn/intr.h               |  14 +-
 arch/mips/include/asm/sn/ioc4.h               | 143 +++
 arch/mips/include/asm/sn/klconfig.h           |  19 +-
 arch/mips/include/asm/sn/kldir.h              |   1 +
 arch/mips/include/asm/sn/l1.h                 |  38 +
 arch/mips/include/asm/sn/mapped_kernel.h      |   6 +-
 arch/mips/include/asm/sn/sn0/addrs.h          |   8 +-
 arch/mips/include/asm/sn/sn0/hub.h            |  37 +-
 arch/mips/include/asm/sn/sn0/hubni.h          |   3 +
 arch/mips/include/asm/sn/sn1/addrs.h          |  22 +
 arch/mips/include/asm/sn/sn1/hub.h            |  40 +
 arch/mips/include/asm/sn/sn1/kldir.h          |  14 +
 arch/mips/include/asm/xtalk/xwidget.h         |  11 +-
 arch/mips/pci/pci-xtalk-bridge.c              | 467 ++++++++-
 arch/mips/sgi-ip27/Makefile                   |   4 +-
 arch/mips/sgi-ip27/Platform                   |  11 +-
 arch/mips/sgi-ip27/ip27-berr.c                |   4 +-
 arch/mips/sgi-ip27/ip27-console.c             |  47 +-
 arch/mips/sgi-ip27/ip27-init.c                | 178 +++-
 arch/mips/sgi-ip27/ip27-irq.c                 |  17 +-
 arch/mips/sgi-ip27/ip27-l1.c                  | 884 ++++++++++++++++++
 arch/mips/sgi-ip27/ip27-memory.c              |  55 +-
 arch/mips/sgi-ip27/ip27-nmi.c                 |  54 +-
 arch/mips/sgi-ip27/ip27-reset.c               |  47 +-
 arch/mips/sgi-ip27/ip27-smp.c                 |  41 +-
 arch/mips/sgi-ip27/ip27-timer.c               |  12 +-
 arch/mips/sgi-ip27/ip27-xtalk.c               | 138 ++-
 drivers/ata/Kconfig                           |  10 +
 drivers/ata/Makefile                          |   1 +
 drivers/ata/pata_sgiioc4.c                    | 311 ++++++
 drivers/leds/Kconfig                          |  12 +
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-ip35.c                      | 144 +++
 drivers/mfd/ioc3.c                            | 455 ++++++++-
 drivers/net/ethernet/sgi/ioc3-eth.c           |  44 +-
 drivers/rtc/rtc-m48t35.c                      |  33 +-
 drivers/tty/serial/8250/8250_ioc3.c           |   5 +-
 include/linux/pci_ids.h                       |   1 +
 include/linux/platform_data/sgi-ioc3-serial.h |  13 +
 include/linux/platform_data/xtalk-bridge.h    |   2 +
 48 files changed, 3334 insertions(+), 398 deletions(-)
 create mode 100644 arch/mips/include/asm/sn/ioc4.h
 create mode 100644 arch/mips/include/asm/sn/l1.h
 create mode 100644 arch/mips/include/asm/sn/sn1/addrs.h
 create mode 100644 arch/mips/include/asm/sn/sn1/hub.h
 create mode 100644 arch/mips/include/asm/sn/sn1/kldir.h
 create mode 100644 arch/mips/sgi-ip27/ip27-l1.c
 create mode 100644 drivers/ata/pata_sgiioc4.c
 create mode 100644 drivers/leds/leds-ip35.c
 create mode 100644 include/linux/platform_data/sgi-ioc3-serial.h

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
prerequisite-patch-id: 642054c4c189f29a3f589a119d2311c20e395a23

Signature · 1 line
2.47.3
author
#1 lore raw

PATCH v2 1/53 MIPS: PCI: xtalk-bridge: refuse device numbers past the last slot

Config slots 8 and up alias the type 1 window, so a root bus scan finds phantom copies of whatever device b_pci_cfg selects. Refuse root bus accesses past the ASIC's last slot.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 arch/mips/pci/pci-xtalk-bridge.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
arch/mips/pci/pci-xtalk-bridge.c +16 -1
index cf115abb54e0..9451b7546068 100644
@@ -92,6 +92,11 @@ static int ioc3_cfg_wr(void *addr, int where, int size, u32 value)
 	return PCIBIOS_SUCCESSFUL;
 }
 
+static int bridge_nslots(struct bridge_controller *bc)
+{
+	return BRIDGE_DEV_CNT;
+}
+
 static void bridge_disable_swapping(struct pci_dev *dev)
 {
 	struct bridge_controller *bc = BRIDGE_CONTROLLER(dev->bus);
@@ -127,6 +132,13 @@ static int pci_conf0_read_config(struct pci_bus *bus, unsigned int devfn,
 	u32 cf;
 	int res;
 
+	/*
+	 * Only bridge_nslots() slots exist.  Config slots 8 and up alias the
+	 * type 1 window and would answer for whatever b_pci_cfg selects.
+	 */
+	if (slot >= bridge_nslots(bc))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
 	addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID];
 	if (get_dbe(cf, (u32 *)addr))
 		return PCIBIOS_DEVICE_NOT_FOUND;
@@ -212,6 +224,9 @@ static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn,
 	u32 cf;
 	int res;
 
+	if (slot >= bridge_nslots(bc))
+		return PCIBIOS_DEVICE_NOT_FOUND;
+
 	addr = &bridge->b_type0_cfg_dev[slot].f[fn].c[PCI_VENDOR_ID];
 	if (get_dbe(cf, (u32 *)addr))
 		return PCIBIOS_DEVICE_NOT_FOUND;
@@ -695,7 +710,7 @@ static int bridge_probe(struct platform_device *pdev)
 	bridge_write(bc, b_dir_map, (bd->masterwid << 20));	/* DMA */
 	bridge_write(bc, b_int_enable, 0);
 
-	for (slot = 0; slot < 8; slot++) {
+	for (slot = 0; slot < bridge_nslots(bc); slot++) {
 		bridge_set(bc, b_device[slot].reg, BRIDGE_DEV_SWAP_DIR);
 		bc->pci_int[slot][0] = -1;
 		bc->pci_int[slot][1] = -1;
Signature · 1 line
2.47.3
author
#2 lore raw

PATCH v2 2/53 MIPS: PCI: xtalk-bridge: assign slots the PROM leaves unconfigured

In reply to Imre Kaloz

The PROM leaves some slots unassigned, such as an LSI SAS1064 or the bus behind a PCI-to-PCI bridge, so their drivers cannot bind. Map their devio windows, borrowing an empty slot's for I/O when memory takes their own.

---
 arch/mips/pci/pci-xtalk-bridge.c | 192 +++++++++++++++++++++++++++++++
 1 file changed, 192 insertions(+)
arch/mips/pci/pci-xtalk-bridge.c +192 -0
index 9451b7546068..2fa9ac8d0a1c 100644
@@ -619,6 +619,192 @@ static int bridge_get_partnum(u64 baddr, char *partnum)
 	return 0;
 }
 
+static unsigned long bridge_dev_space(struct pci_dev *pdev)
+{
+	unsigned long flags = 0;
+	struct resource *res;
+	int i;
+
+	pci_dev_for_each_resource(pdev, res, i)
+		if (i < PCI_ROM_RESOURCE && resource_size(res))
+			flags |= res->flags & (IORESOURCE_IO | IORESOURCE_MEM);
+
+	return flags;
+}
+
+static bool bridge_ppb_window(struct pci_dev *ppb, int idx,
+			      struct resource *win)
+{
+	struct resource *res = &ppb->resource[idx];
+
+	if (!win)
+		return false;
+	res->start = win->start;
+	res->end = win->end;
+	res->flags = win->flags;
+	if (request_resource(win, res))
+		return false;
+	pci_info(ppb, "bridge window %pR: assigned\n", res);
+	return true;
+}
+
+static void bridge_setup_ppb(struct pci_dev *ppb,
+			     struct xtalk_bridge_platform_data *bd,
+			     struct resource *io, struct resource *mem)
+{
+	u32 start, end;
+	u8 io_type;
+
+	pci_read_config_byte(ppb, PCI_IO_BASE, &io_type);
+	if (io && (io_type & PCI_IO_RANGE_TYPE_MASK) != PCI_IO_RANGE_TYPE_32) {
+		pci_warn(ppb, "no 32-bit I/O window\n");
+		io = NULL;
+	}
+	if (!bridge_ppb_window(ppb, PCI_BRIDGE_IO_WINDOW, io))
+		io = NULL;
+	if (!bridge_ppb_window(ppb, PCI_BRIDGE_MEM_WINDOW, mem))
+		mem = NULL;
+	if (!io && !mem)
+		return;
+
+	if (io) {
+		start = io->start - bd->io_offset;
+		end = io->end - bd->io_offset;
+		pci_write_config_dword(ppb, PCI_IO_BASE_UPPER16,
+				       (end & 0xffff0000) | (start >> 16));
+		pci_write_config_word(ppb, PCI_IO_BASE,
+				      (end & 0xf000) | (start >> 8 & 0xf0));
+	} else {
+		pci_write_config_dword(ppb, PCI_IO_BASE_UPPER16, 0);
+		pci_write_config_word(ppb, PCI_IO_BASE, 0x00f0);
+	}
+	if (mem) {
+		start = mem->start - bd->mem_offset;
+		end = mem->end - bd->mem_offset;
+		pci_write_config_dword(ppb, PCI_MEMORY_BASE,
+				       (end & 0xfff00000) | (start >> 16));
+	} else {
+		pci_write_config_dword(ppb, PCI_MEMORY_BASE, 0x0000fff0);
+	}
+	pci_write_config_dword(ppb, PCI_PREF_MEMORY_BASE, 0x0000fff0);
+	pci_write_config_dword(ppb, PCI_PREF_BASE_UPPER32, 0);
+	pci_write_config_dword(ppb, PCI_PREF_LIMIT_UPPER32, 0);
+
+	pci_bus_assign_resources(ppb->subordinate);
+}
+
+/* Map devio window @win, at its own address, in memory or I/O space. */
+static struct resource *bridge_map_devio(struct bridge_controller *bc,
+					 struct xtalk_bridge_platform_data *bd,
+					 struct device *dev, int win, bool mem)
+{
+	struct resource *root = mem ? &bd->mem : &bd->io;
+	resource_size_t offset = mem ? bd->mem_offset : bd->io_offset;
+	struct resource *res;
+	u32 devreg;
+
+	res = devm_kzalloc(dev, sizeof(*res), GFP_KERNEL);
+	if (!res)
+		return NULL;
+	res->name = "Bridge PCI slot";
+	res->start = root->start - BRIDGE_DEVIO0 + BRIDGE_DEVIO(win);
+	res->end = res->start + (win <= 1 ? BRIDGE_DEVIO_2MB :
+					    BRIDGE_DEVIO_1MB) - 1;
+	res->flags = root->flags;
+	if (devm_request_resource(dev, root, res))
+		return NULL;
+
+	devreg = bridge_read(bc, b_device[win].reg);
+	devreg &= ~(BRIDGE_DEV_OFF_MASK | BRIDGE_DEV_DEV_IO_MEM);
+	devreg |= (res->start - offset) >> BRIDGE_DEV_OFF_ADDR_SHFT;
+	if (mem)
+		devreg |= BRIDGE_DEV_DEV_IO_MEM;
+	bridge_write(bc, b_device[win].reg, devreg);
+	bridge_read(bc, b_wid_tflush);
+
+	return res;
+}
+
+/*
+ * A slot's BARs are reached only through a devio window, which Device(x)
+ * points at either PCI I/O or PCI memory space.  The PROM leaves some slots
+ * without resources, the secondary bus of a PCI-to-PCI bridge among them.
+ * Give such a slot its own window, in memory space if anything in the slot
+ * needs memory, and the window of a slot with no device for I/O space if
+ * it needs both: PIO through any devio window reaches every device on the
+ * bus.
+ */
+static void bridge_setup_slot(struct bridge_controller *bc,
+			      struct xtalk_bridge_platform_data *bd,
+			      struct device *dev, struct pci_bus *bus, int slot,
+			      unsigned long *busy)
+{
+	struct resource *res, *win, *io = NULL, *mem = NULL;
+	struct pci_dev *pdev, *child;
+	unsigned long flags = 0;
+	int i;
+
+	list_for_each_entry(pdev, &bus->devices, bus_list) {
+		if (PCI_SLOT(pdev->devfn) != slot)
+			continue;
+		pci_dev_for_each_resource(pdev, res)
+			if (res->parent)
+				return;
+		if (!pdev->subordinate)
+			flags |= bridge_dev_space(pdev);
+		else
+			list_for_each_entry(child, &pdev->subordinate->devices,
+					    bus_list)
+				flags |= bridge_dev_space(child);
+	}
+	if (!flags)
+		return;
+
+	if (flags & IORESOURCE_MEM)
+		mem = bridge_map_devio(bc, bd, dev, slot, true);
+	else
+		io = bridge_map_devio(bc, bd, dev, slot, false);
+	if (!io && !mem)
+		return;
+
+	if ((flags & IORESOURCE_IO) && !io) {
+		i = find_first_zero_bit(busy, bridge_nslots(bc));
+		if (i < bridge_nslots(bc)) {
+			__set_bit(i, busy);
+			io = bridge_map_devio(bc, bd, dev, i, false);
+		}
+		if (!io)
+			dev_warn(dev, "slot %d: no devio window for I/O space\n",
+				 slot);
+	}
+
+	list_for_each_entry(pdev, &bus->devices, bus_list) {
+		if (PCI_SLOT(pdev->devfn) != slot)
+			continue;
+		if (pdev->subordinate) {
+			bridge_setup_ppb(pdev, bd, io, mem);
+			continue;
+		}
+		pci_dev_for_each_resource(pdev, res, i) {
+			win = res->flags & IORESOURCE_MEM ? mem : io;
+			if (i >= PCI_ROM_RESOURCE || !win ||
+			    !(res->flags & win->flags) || !resource_size(res))
+				continue;
+			if (allocate_resource(win, res, resource_size(res),
+					      win->start, win->end,
+					      resource_alignment(res),
+					      NULL, NULL)) {
+				pci_warn(pdev, "BAR %d %pR: no space in slot\n",
+					 i, res);
+				continue;
+			}
+			res->flags &= ~IORESOURCE_UNSET;
+			pci_update_resource(pdev, i);
+			pci_info(pdev, "BAR %d %pR: assigned\n", i, res);
+		}
+	}
+}
+
 static int bridge_probe(struct platform_device *pdev)
 {
 	struct xtalk_bridge_platform_data *bd = dev_get_platdata(&pdev->dev);
@@ -627,6 +813,8 @@ static int bridge_probe(struct platform_device *pdev)
 	struct pci_host_bridge *host;
 	struct irq_domain *domain, *parent;
 	struct fwnode_handle *fn;
+	struct pci_dev *pcidev;
+	unsigned long busy = 0;
 	char partnum[26];
 	int slot;
 	int err;
@@ -734,6 +922,10 @@ static int bridge_probe(struct platform_device *pdev)
 		goto err_free_resource;
 
 	pci_bus_claim_resources(host->bus);
+	list_for_each_entry(pcidev, &host->bus->devices, bus_list)
+		__set_bit(PCI_SLOT(pcidev->devfn), &busy);
+	for (slot = 0; slot < bridge_nslots(bc); slot++)
+		bridge_setup_slot(bc, bd, dev, host->bus, slot, &busy);
 	pci_bus_add_devices(host->bus);
 
 	platform_set_drvdata(pdev, host->bus);
Signature · 1 line
2.47.3
author
#3 lore raw

PATCH v2 3/53 MIPS: PCI: xtalk-bridge: write a type 1 IOC3 through the type 1 window

In reply to Imre Kaloz

The IOC3 case of the type 1 config write goes through the root bus slot's type 0 window and so writes a different device. Use the type 1 window, as the matching read does.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
---
 arch/mips/pci/pci-xtalk-bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/pci/pci-xtalk-bridge.c +1 -1
index 2fa9ac8d0a1c..18251a68fa06 100644
@@ -277,7 +277,7 @@ static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
 	 * generic PCI code a chance to look at it for real ...
 	 */
 	if (cf == (PCI_VENDOR_ID_SGI | (PCI_DEVICE_ID_SGI_IOC3 << 16))) {
-		addr = &bridge->b_type0_cfg_dev[slot].f[fn].l[where >> 2];
+		addr = &bridge->b_type1_cfg.c[(fn << 8) | (where & ~3)];
 		return ioc3_cfg_wr(addr, where, size, value);
 	}
 
Signature · 1 line
2.47.3
author
#4 lore raw

PATCH v2 4/53 MIPS: PCI: xtalk-bridge: flush config space writes

In reply to Imre Kaloz

PIC hangs on a config access issued behind a config write that is still posted, as when probing an SGI PCI digital audio board. Read the widget flush register after each config write other than an IOC3's.

---
 arch/mips/pci/pci-xtalk-bridge.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/mips/pci/pci-xtalk-bridge.c +5 -0
index 18251a68fa06..16c1ac2c2551 100644
@@ -252,6 +252,9 @@ static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn,
 	if (res)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
+	/* PIC hangs on a config access behind an unflushed config write. */
+	bridge_read(bc, b_wid_tflush);
+
 	return PCIBIOS_SUCCESSFUL;
 }
 
@@ -293,6 +296,8 @@ static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
 	if (res)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
+	bridge_read(bc, b_wid_tflush);
+
 	return PCIBIOS_SUCCESSFUL;
 }
 
Signature · 1 line
2.47.3
author
#5 lore raw

PATCH v2 5/53 MIPS: PCI: xtalk-bridge: reassign slots whose devio window maps elsewhere

In reply to Imre Kaloz

The PROM may point the devio window covering a BAR elsewhere. On an Octane, window 2 maps the IOC3 while the RAD1 BAR sits in it, so RAD1 writes land in the IOC3. Reassign such slots like unconfigured ones.

---
 arch/mips/pci/pci-xtalk-bridge.c | 58 ++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/mips/pci/pci-xtalk-bridge.c +58 -0
index 16c1ac2c2551..8b56c754245d 100644
@@ -730,6 +730,63 @@ static struct resource *bridge_map_devio(struct bridge_controller *bc,
 	return res;
 }
 
+/*
+ * Linux reaches a BAR through the devio window at the BAR's own address, but
+ * the PROM may point that window elsewhere: an Octane's window 2 maps the IOC3
+ * at 0x500000 while the RAD1 BAR sits at 0x600000.  Only the offset matters;
+ * the PROM puts a slot's I/O and memory BARs at one address and maps the
+ * window for memory.
+ */
+static bool bridge_devio_reaches(struct bridge_controller *bc,
+				 struct xtalk_bridge_platform_data *bd,
+				 struct resource *res)
+{
+	resource_size_t base = bd->mem.start - BRIDGE_DEVIO0;
+	resource_size_t offset = res->flags & IORESOURCE_IO ? bd->io_offset :
+							      bd->mem_offset;
+	resource_size_t addr = res->start;
+	u32 off;
+	int win;
+
+	while (addr <= res->end) {
+		addr -= base;
+		win = addr < BRIDGE_DEVIO2 ?
+		      (addr - BRIDGE_DEVIO0) / BRIDGE_DEVIO_2MB :
+		      2 + (addr - BRIDGE_DEVIO2) / BRIDGE_DEVIO_1MB;
+		if (win >= bridge_nslots(bc))
+			return false;
+		off = bridge_read(bc, b_device[win].reg) & BRIDGE_DEV_OFF_MASK;
+		if (off != (base + BRIDGE_DEVIO(win) - offset) >>
+			   BRIDGE_DEV_OFF_ADDR_SHFT)
+			return false;
+		addr = base + BRIDGE_DEVIO(win + 1);
+	}
+
+	return true;
+}
+
+/* Release slots with a BAR Linux cannot reach, for bridge_setup_slot(). */
+static void bridge_release_unreached(struct bridge_controller *bc,
+				     struct xtalk_bridge_platform_data *bd,
+				     struct pci_bus *bus)
+{
+	unsigned long unreached = 0;
+	struct pci_dev *pdev;
+	struct resource *res;
+	int i;
+
+	list_for_each_entry(pdev, &bus->devices, bus_list)
+		pci_dev_for_each_resource(pdev, res)
+			if (res->parent && !pdev->subordinate &&
+			    !bridge_devio_reaches(bc, bd, res))
+				__set_bit(PCI_SLOT(pdev->devfn), &unreached);
+
+	list_for_each_entry(pdev, &bus->devices, bus_list)
+		if (test_bit(PCI_SLOT(pdev->devfn), &unreached))
+			pci_dev_for_each_resource(pdev, res, i)
+				pci_release_resource(pdev, i);
+}
+
 /*
  * A slot's BARs are reached only through a devio window, which Device(x)
  * points at either PCI I/O or PCI memory space.  The PROM leaves some slots
@@ -929,6 +986,7 @@ static int bridge_probe(struct platform_device *pdev)
 	pci_bus_claim_resources(host->bus);
 	list_for_each_entry(pcidev, &host->bus->devices, bus_list)
 		__set_bit(PCI_SLOT(pcidev->devfn), &busy);
+	bridge_release_unreached(bc, bd, host->bus);
 	for (slot = 0; slot < bridge_nslots(bc); slot++)
 		bridge_setup_slot(bc, bd, dev, host->bus, slot, &busy);
 	pci_bus_add_devices(host->bus);
Signature · 1 line
2.47.3
author
#6 lore raw

PATCH v2 6/53 MIPS: Xtalk: guard the widget identification table from assembly

In reply to Imre Kaloz

Only the constant definitions in this header are usable from assembly; the widget identification table and the struct it is built from are not. Put those behind __ASSEMBLER__ so the header can be included from an assembly file.

---
 arch/mips/include/asm/xtalk/xwidget.h | 2 ++
 1 file changed, 2 insertions(+)
arch/mips/include/asm/xtalk/xwidget.h +2 -0
index efcfe4494576..6dae5d9628f7 100644
@@ -112,6 +112,7 @@
 #define WIDGET_XBRDG_PART_NUM	0xd002
 #define WIDGET_NULL_PART_NUM	-1
 
+#ifndef __ASSEMBLER__
 /* For Xtalk Widget identification */
 struct widget_ident {
 	u32 mfgr;
@@ -195,6 +196,7 @@ static const struct widget_ident __initconst widget_idents[] = {
 		{NULL},
 	}
 };
+#endif /* !__ASSEMBLER__ */
 
 /*
  * according to the crosstalk spec, only 32-bits access to the widget
Signature · 1 line
2.47.3
author
#7 lore raw

PATCH v2 7/53 MIPS: SGI-IP27: dump the NMI save areas the CPU scan recorded

In reply to Imre Kaloz

nmi_node_eframe_save() walks a fixed two slices per node, so the crash dump can print a register set and a hub interrupt state for a slice the node's CPU scan never recorded. Walk the recorded slices instead.

---
 arch/mips/sgi-ip27/ip27-nmi.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
arch/mips/sgi-ip27/ip27-nmi.c +8 -8
index c502982621e6..2cb17f8c7bf3 100644
@@ -5,6 +5,7 @@
 #include <linux/nodemask.h>
 #include <linux/spinlock.h>
 #include <linux/smp.h>
+#include <linux/topology.h>
 #include <linux/atomic.h>
 #include <asm/sn/types.h>
 #include <asm/sn/addrs.h>
@@ -14,12 +15,6 @@
 
 #include "ip27-common.h"
 
-#if 0
-#define NODE_NUM_CPUS(n)	CNODE_NUM_CPUS(n)
-#else
-#define NODE_NUM_CPUS(n)	CPUS_PER_NODE
-#endif
-
 #define SEND_NMI(_nasid, _slice)	\
 	REMOTE_HUB_S((_nasid),  (PI_NMI_A + ((_slice) * PI_NMI_OFFSET)), 1)
 
@@ -149,13 +144,18 @@ static void nmi_dump_hub_irq(nasid_t nasid, int slice)
  */
 static void nmi_node_eframe_save(nasid_t nasid)
 {
-	int slice;
+	int cpu;
 
 	if (nasid == INVALID_NASID)
 		return;
 
 	/* Save the registers into eframe for each cpu */
-	for (slice = 0; slice < NODE_NUM_CPUS(slice); slice++) {
+	for_each_possible_cpu(cpu) {
+		int slice = cputoslice(cpu);
+
+		if (cputonasid(cpu) != nasid)
+			continue;
+
 		nmi_cpu_eframe_save(nasid, slice);
 		nmi_dump_hub_irq(nasid, slice);
 	}
Signature · 1 line
2.47.3
author
#8 lore raw

PATCH v2 8/53 MIPS: SGI-IP27: add REMOTE_HUB_PI_S()/REMOTE_HUB_PI_L()

In reply to Imre Kaloz

Some hub generations split each hub's PI registers across two subnode blocks instead of one, so a remote access needs a subnode selector on top of REMOTE_HUB_ADDR()'s node selector. Passing subnode 0 reduces the new form to plain REMOTE_HUB_L()/REMOTE_HUB_S().

---
 arch/mips/include/asm/sn/addrs.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/mips/include/asm/sn/addrs.h +21 -0
index 7c675fecbf9a..d5c7cfea7761 100644
@@ -267,6 +267,27 @@
 
 #endif /* !__ASSEMBLER__ */
 
+/*
+ * Some hub generations split each hub's PI registers across two subnode
+ * blocks HUBPI_OFFSET apart; REMOTE_HUB_ADDR() always targets subnode 0.
+ */
+#define HUBPI_OFFSET		0x00200000
+
+#define REMOTE_HUB_PI_ADDR(_n, _sn, _x) \
+	(REMOTE_HUB_ADDR((_n), (_x)) + ((_sn) ? HUBPI_OFFSET : 0))
+
+#ifndef __ASSEMBLER__
+
+#define REMOTE_HUB_PI_PTR(_n, _sn, _x)	\
+	((u64 *)REMOTE_HUB_PI_ADDR((_n), (_sn), (_x)))
+
+#define REMOTE_HUB_PI_L(_n, _sn, _r)		\
+	__raw_readq(REMOTE_HUB_PI_PTR((_n), (_sn), (_r)))
+#define REMOTE_HUB_PI_S(_n, _sn, _r, _d)	\
+	__raw_writeq((_d), REMOTE_HUB_PI_PTR((_n), (_sn), (_r)))
+
+#endif /* !__ASSEMBLER__ */
+
 /*
  * Software structure locations -- permanently fixed
  *    See diagram in kldir.h
Signature · 1 line
2.47.3
author
#9 lore raw

PATCH v2 9/53 MIPS: SGI-IP27: detect Bedrock hubs at boot

In reply to Imre Kaloz

Read a hub's widget-ID register as the first thing prom_init() does and record whether it is a Bedrock ASIC, so later code can branch on that instead of a compile-time select. A local alias read needs no nasid, so this runs first.

---
 arch/mips/include/asm/sn/addrs.h | 6 ++++++
 arch/mips/sgi-ip27/ip27-init.c   | 9 +++++++++
 2 files changed, 15 insertions(+)
arch/mips/include/asm/sn/addrs.h +6 -0
index d5c7cfea7761..51161fd5130b 100644
@@ -35,6 +35,12 @@
 
 #endif /* __ASSEMBLER__ */
 
+#ifndef __ASSEMBLER__
+
+extern bool system_is_ip35;
+
+#endif /* __ASSEMBLER__ */
+
 
 #define NASID_GET_META(_n)	((_n) >> NASID_LOCAL_BITS)
 #ifdef CONFIG_SGI_IP27
arch/mips/sgi-ip27/ip27-init.c +9 -0
index a4daf8ccd16c..6394c2076041 100644
@@ -31,6 +31,7 @@
 #include <asm/thread_info.h>
 #include <asm/sn/launch.h>
 #include <asm/sn/mapped_kernel.h>
+#include <asm/xtalk/xwidget.h>
 
 #include "ip27-common.h"
 
@@ -38,6 +39,7 @@
 
 static DECLARE_BITMAP(hub_init_mask, MAX_NUMNODES);
 nasid_t master_nasid = INVALID_NASID;
+bool system_is_ip35;
 
 struct cpuinfo_ip27 sn_cpu_info[NR_CPUS];
 EXPORT_SYMBOL_GPL(sn_cpu_info);
@@ -139,8 +141,15 @@ const char *get_system_type(void)
 	return "SGI Origin";
 }
 
+static inline bool hub_is_bedrock(void)
+{
+	return XWIDGET_PART_NUM(LOCAL_HUB_L(IIO_WID)) == WIDGET_BDRCK_PART_NUM;
+}
+
 void __init prom_init(void)
 {
+	system_is_ip35 = hub_is_bedrock();
+
 	prom_init_cmdline(fw_arg0, (LONG *)fw_arg1);
 	prom_meminit();
 }
Signature · 1 line
2.47.3
author
#10 lore raw

PATCH v2 10/53 MIPS: SGI-IP27: widen Kconfig for the Bedrock-based machines

In reply to Imre Kaloz

CONFIG_SGI_IP27 now also covers the Bedrock-based IP35 machines such as Fuel and Tezro, told apart from Origin 200/2000 at runtime rather than by a separate config symbol. Update the prompt and help text.

---
 arch/mips/Kconfig | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/mips/Kconfig +5 -4
index d7c67cebe065..b64f1a8ebf41 100644
@@ -755,7 +755,7 @@ config SGI_IP22
 	  that runs on these, say Y here.
 
 config SGI_IP27
-	bool "SGI IP27 (Origin200/2000)"
+	bool "SGI IP27 (Origin200/2000) and IP35 (Fuel, Tezro)"
 	select ARCH_HAS_PHYS_TO_DMA
 	select ARCH_SPARSEMEM_ENABLE
 	select FW_ARC
@@ -780,9 +780,10 @@ config SGI_IP27
 	select MIPS_L1_CACHE_SHIFT_7
 	select NUMA
 	help
-	  This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
-	  workstations.  To compile a Linux kernel that runs on these, say Y
-	  here.
+	  These are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
+	  workstations, and the IP35 machines built around the Bedrock hub
+	  ASIC, such as Fuel and Tezro.  To compile a Linux kernel that runs
+	  on these, say Y here.
 
 config SGI_IP28
 	bool "SGI IP28 (Indigo2 R10k)"
Signature · 1 line
2.47.3
author
#11 lore raw

PATCH v2 11/53 MIPS: SGI-IP27: fold the dead SN1 arm out of klconfig.h

In reply to Imre Kaloz

klconfig.h's CONFIG_SGI_IP35 branch is unreachable: that symbol is never selected, and the branch names headers that do not exist in this tree. Fold its shared includes into the CONFIG_SGI_IP27 branch and drop the unreachable rest.

---
 arch/mips/include/asm/sn/klconfig.h | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)
arch/mips/include/asm/sn/klconfig.h +2 -17
index 3d1670b3e052..433d2d05aba3 100644
@@ -40,26 +40,11 @@
 //#include <sys/graph.h>
 //#include <sys/xtalk/xbow.h>
 
-#elif defined(CONFIG_SGI_IP35)
-
-#include <asm/sn/sn1/addrs.h>
-#include <sys/sn/router.h>
-#include <sys/graph.h>
-#include <asm/xtalk/xbow.h>
-
-#endif /* !CONFIG_SGI_IP27 && !CONFIG_SGI_IP35 */
-
-#if defined(CONFIG_SGI_IP27) || defined(CONFIG_SGI_IP35)
 #include <asm/sn/agent.h>
 #include <asm/fw/arc/types.h>
 #include <asm/fw/arc/hinv.h>
-#if defined(CONFIG_SGI_IP35)
-// The hack file has to be before vector and after sn0_fru....
-#include <asm/hack.h>
-#include <asm/sn/vector.h>
-#include <asm/xtalk/xtalk.h>
-#endif /* CONFIG_SGI_IP35 */
-#endif /* CONFIG_SGI_IP27 || CONFIG_SGI_IP35 */
+
+#endif /* CONFIG_SGI_IP27 */
 
 typedef u64  nic_t;
 
Signature · 1 line
2.47.3
author
#12 lore raw

PATCH v2 12/53 MIPS: SGI-IP27: choose the node address layout at runtime

In reply to Imre Kaloz

A Bedrock node owns twice the address space a Hub node does, putting the nasid one bit higher. Take the shift and the node size from the generation detected at boot; head.S runs before that and keeps Hub's values.

---
 arch/mips/include/asm/sn/addrs.h     | 12 +++++++++++-
 arch/mips/include/asm/sn/sn0/addrs.h |  8 ++++----
 arch/mips/include/asm/sn/sn1/addrs.h | 22 ++++++++++++++++++++++
 3 files changed, 37 insertions(+), 5 deletions(-)
 create mode 100644 arch/mips/include/asm/sn/sn1/addrs.h
arch/mips/include/asm/sn/addrs.h +11 -1
index 51161fd5130b..499615abd501 100644
@@ -20,7 +20,6 @@
 
 #if defined(CONFIG_SGI_IP27)
 #include <asm/sn/sn0/addrs.h>
-#elif defined(CONFIG_SGI_IP35)
 #include <asm/sn/sn1/addrs.h>
 #endif
 
@@ -39,6 +38,17 @@
 
 extern bool system_is_ip35;
 
+#define NASID_SHFT		(system_is_ip35 ? SN1_NASID_SHFT :	\
+				 SN0_NASID_SHFT)
+#define NODE_SIZE_BITS		(system_is_ip35 ? SN1_NODE_SIZE_BITS :	\
+				 SN0_NODE_SIZE_BITS)
+
+#else /* __ASSEMBLER__ */
+
+/* The entry paths run before prom_init() reads the hub's part number. */
+#define NASID_SHFT		SN0_NASID_SHFT
+#define NODE_SIZE_BITS		SN0_NODE_SIZE_BITS
+
 #endif /* __ASSEMBLER__ */
 
 
arch/mips/include/asm/sn/sn0/addrs.h +4 -4
index a28158a91ecf..f1a161913ae4 100644
@@ -50,12 +50,12 @@
 
 #ifdef CONFIG_SGI_SN_N_MODE
 
-#define NODE_SIZE_BITS		31
+#define SN0_NODE_SIZE_BITS	31
 #define BWIN_SIZE_BITS		28
 
 #define NASID_BITS		9
 #define NASID_BITMASK		(0x1ffLL)
-#define NASID_SHFT		31
+#define SN0_NASID_SHFT		31
 #define NASID_META_BITS		5
 #define NASID_LOCAL_BITS	4
 
@@ -64,12 +64,12 @@
 
 #else /* !defined(CONFIG_SGI_SN_N_MODE), assume that M-mode is desired */
 
-#define NODE_SIZE_BITS		32
+#define SN0_NODE_SIZE_BITS	32
 #define BWIN_SIZE_BITS		29
 
 #define NASID_BITMASK		(0xffLL)
 #define NASID_BITS		8
-#define NASID_SHFT		32
+#define SN0_NASID_SHFT		32
 #define NASID_META_BITS		4
 #define NASID_LOCAL_BITS	4
 
arch/mips/include/asm/sn/sn1/addrs.h new file +22 -0
new file mode 100644
index 000000000000..58878a5b4710
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * SN1 (Bedrock) address space layout.
+ *
+ * Copyright (C) 2026 Imre Kaloz <[email protected]>
+ */
+#ifndef _ASM_SN_SN1_ADDRS_H
+#define _ASM_SN_SN1_ADDRS_H
+
+#ifdef CONFIG_SGI_SN_N_MODE
+
+#define SN1_NODE_SIZE_BITS	32
+#define SN1_NASID_SHFT		32
+
+#else /* !defined(CONFIG_SGI_SN_N_MODE), assume that M-mode is desired */
+
+#define SN1_NODE_SIZE_BITS	33
+#define SN1_NASID_SHFT		33
+
+#endif /* !defined(CONFIG_SGI_SN_N_MODE) */
+
+#endif /* _ASM_SN_SN1_ADDRS_H */
Signature · 1 line
2.47.3
author
#13 lore raw

PATCH v2 13/53 MIPS: SGI-IP27: add the Bedrock hub register windows

In reply to Imre Kaloz

Bedrock places its hub register blocks at different offsets than Hub does. Add a header for them and include it next to the Hub one, since one kernel has to reach either generation's blocks.

---
 arch/mips/include/asm/sn/agent.h   |  3 +--
 arch/mips/include/asm/sn/sn1/hub.h | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 arch/mips/include/asm/sn/sn1/hub.h
arch/mips/include/asm/sn/agent.h +1 -2
index 7e9b3271737a..8873eb34e31b 100644
@@ -16,9 +16,8 @@
 
 #if defined(CONFIG_SGI_IP27)
 #include <asm/sn/sn0/hub.h>
-#elif defined(CONFIG_SGI_IP35)
 #include <asm/sn/sn1/hub.h>
-#endif	/* !CONFIG_SGI_IP27 && !CONFIG_SGI_IP35 */
+#endif /* CONFIG_SGI_IP27 */
 
 /*
  * NIC register macros
arch/mips/include/asm/sn/sn1/hub.h new file +15 -0
new file mode 100644
index 000000000000..db41bcb3d34a
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * SN1 (Bedrock) hub register windows.
+ *
+ * Copyright (C) 2026 Imre Kaloz <[email protected]>
+ */
+#ifndef _ASM_SN_SN1_HUB_H
+#define _ASM_SN_SN1_HUB_H
+
+#define HUBLBBASE_IP35		0x00600000
+#define HUBNIBASE_IP35		0x00680000
+#define HUBXBBASE_IP35		0x00700000
+#define HUBMDBASE_IP35		0x00780000
+
+#endif /* _ASM_SN_SN1_HUB_H */
Signature · 1 line
2.47.3
author
#14 lore raw

PATCH v2 14/53 MIPS: SGI-IP27: decode a Bedrock hub's node id and system size

In reply to Imre Kaloz

Bedrock's LB_REV_ID holds the node id in bits 39:32 and the system size, which sets N mode and the region size, in bits 47:46. Decode both by hub generation; the assembly form, built only for MAPPED_KERNEL, keys on the widget ID.

---
 .../include/asm/mach-ip27/kernel-entry-init.h |  8 +++-
 arch/mips/include/asm/sn/agent.h              |  2 +-
 arch/mips/include/asm/sn/sn0/hub.h            | 37 +++++++++++++++++--
 arch/mips/include/asm/sn/sn0/hubni.h          |  3 ++
 arch/mips/include/asm/sn/sn1/hub.h            | 14 +++++++
 arch/mips/include/asm/xtalk/xwidget.h         |  2 +-
 arch/mips/sgi-ip27/ip27-init.c                |  6 ++-
 7 files changed, 63 insertions(+), 9 deletions(-)
arch/mips/include/asm/mach-ip27/kernel-entry-init.h +6 -2
index 3e54f605a70b..cd50e6d3d966 100644
@@ -65,8 +65,10 @@
  * arch/mips/mach-xxx/kernel-entry-init.h when necessary.
  */
 	.macro	kernel_entry_setup
-	GET_NASID_ASM	t1
+#ifdef CONFIG_MAPPED_KERNEL
+	GET_NASID_ASM	t1, t0
 	move		t2, t1			# text and data are here
+#endif
 	MAPPED_KERNEL_SETUP_TLB
 	.endm
 
@@ -74,7 +76,8 @@
  * Do SMP slave processor setup necessary before we can safely execute C code.
  */
 	.macro	smp_slave_setup
-	GET_NASID_ASM	t1
+#ifdef CONFIG_MAPPED_KERNEL
+	GET_NASID_ASM	t1, t0
 	dli	t0, KLDIR_OFFSET + (KLI_KERN_VARS * KLDIR_ENT_SIZE) + \
 		    KLDIR_OFF_POINTER + CAC_BASE
 	dsll	t1, NASID_SHFT
@@ -82,6 +85,7 @@
 	ld	t0, 0(t0)			# t0 points to kern_vars struct
 	lh	t1, KV_RO_NASID_OFFSET(t0)
 	lh	t2, KV_RW_NASID_OFFSET(t0)
+#endif
 	MAPPED_KERNEL_SETUP_TLB
 
 	/*
arch/mips/include/asm/sn/agent.h +1 -1
index 8873eb34e31b..1d6d0cd5e5fd 100644
@@ -15,8 +15,8 @@
 #include <asm/sn/arch.h>
 
 #if defined(CONFIG_SGI_IP27)
-#include <asm/sn/sn0/hub.h>
 #include <asm/sn/sn1/hub.h>
+#include <asm/sn/sn0/hub.h>
 #endif /* CONFIG_SGI_IP27 */
 
 /*
arch/mips/include/asm/sn/sn0/hub.h +33 -4
index 916394319af5..c5429dbddc7a 100644
@@ -31,6 +31,8 @@
 #include <asm/sn/sn0/hubni.h>
 //#include <asm/sn/sn0/hubcore.h>
 
+#include <asm/xtalk/xwidget.h>
+
 /* Translation of uncached attributes */
 #define UATTR_HSPEC	0
 #define UATTR_IO	1
@@ -39,13 +41,35 @@
 
 #ifdef __ASSEMBLER__
 /*
- * Returns the local nasid into res.
+ * Clears tmp on a Bedrock hub.  Nothing has read the hub's part number
+ * this early, so take it from the widget ID.
  */
-	.macro GET_NASID_ASM res
+	.macro GET_HUB_GEN_ASM tmp
+	dli	\tmp, LOCAL_HUB_ADDR(IIO_WID)
+	ld	\tmp, (\tmp)
+	dsrl	\tmp, WIDGET_PART_NUM_SHFT
+	andi	\tmp, (WIDGET_PART_NUM >> WIDGET_PART_NUM_SHFT)
+	xori	\tmp, WIDGET_BDRCK_PART_NUM
+	.endm
+
+/*
+ * Returns the local nasid into res, clobbering tmp.
+ */
+	.macro GET_NASID_ASM res, tmp
+	.set	push
+	.set	reorder
+	GET_HUB_GEN_ASM \tmp
 	dli	\res, LOCAL_HUB_ADDR(NI_STATUS_REV_ID)
 	ld	\res, (\res)
+	beqz	\tmp, 1f
 	and	\res, NSRI_NODEID_MASK
 	dsrl	\res, NSRI_NODEID_SHFT
+	b	2f
+1:
+	dsrl	\res, LRI_NODEID_SHFT_IP35
+	andi	\res, LRI_NODEID_MASK_IP35
+2:
+	.set	pop
 	.endm
 #else
 
@@ -54,8 +78,13 @@
  */
 static inline nasid_t get_nasid(void)
 {
-	return (nasid_t)((LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_NODEID_MASK)
-			 >> NSRI_NODEID_SHFT);
+	u64 id = LOCAL_HUB_L(NI_STATUS_REV_ID);
+
+	if (system_is_ip35)
+		return (nasid_t)((id >> LRI_NODEID_SHFT_IP35) &
+				 LRI_NODEID_MASK_IP35);
+
+	return (nasid_t)((id & NSRI_NODEID_MASK) >> NSRI_NODEID_SHFT);
 }
 #endif
 
arch/mips/include/asm/sn/sn0/hubni.h +3 -0
index 4830bae723e4..ff7df5e27f66 100644
@@ -252,6 +252,9 @@ typedef union	hubni_port_error_u {
 
 static inline int get_region_shift(void)
 {
+	if (system_is_ip35)
+		return LRI_SYSTEM_SIZE_IP35(LOCAL_HUB_L(NI_STATUS_REV_ID));
+
 	if (LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_REGIONSIZE_MASK)
 		return NASID_TO_FINEREG_SHFT;
 
arch/mips/include/asm/sn/sn1/hub.h +14 -0
index db41bcb3d34a..71ccd2ba3698 100644
@@ -12,4 +12,18 @@
 #define HUBXBBASE_IP35		0x00700000
 #define HUBMDBASE_IP35		0x00780000
 
+/*
+ * LB_REV_ID, at the base of the LB block and so at Hub's NI_STATUS_REV_ID
+ * offset, holds the node id in bits 39:32.
+ */
+#define LRI_NODEID_SHFT_IP35	32
+#define LRI_NODEID_MASK_IP35	0xff
+
+/*
+ * Bits 47:46 give the system size: 0, 1 or 2 is log2 of the nodes per
+ * region, and 2 is N mode.
+ */
+#define LRI_SYSTEM_SIZE_IP35(id)	(((id) >> 46) & 0x3)
+#define LRI_SYSTEM_SIZE_NMODE_IP35	2
+
 #endif /* _ASM_SN_SN1_HUB_H */
arch/mips/include/asm/xtalk/xwidget.h +1 -1
index 6dae5d9628f7..978877e8a090 100644
@@ -122,7 +122,7 @@ struct widget_ident {
 };
 
 /* Known Xtalk Widgets */
-static const struct widget_ident __initconst widget_idents[] = {
+static const struct widget_ident widget_idents[] __initconst __maybe_unused = {
 	{
 		WIDGET_XBOW_MFGR_NUM,
 		WIDGET_XBOW_PART_NUM,
arch/mips/sgi-ip27/ip27-init.c +5 -1
index 6394c2076041..108d90908763 100644
@@ -121,7 +121,11 @@ void __init plat_mem_setup(void)
 	 * Try to catch kernel missconfigurations and give user an
 	 * indication what option to select.
 	 */
-	n_mode = LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_MORENODES_MASK;
+	if (system_is_ip35)
+		n_mode = LRI_SYSTEM_SIZE_IP35(LOCAL_HUB_L(NI_STATUS_REV_ID)) ==
+			 LRI_SYSTEM_SIZE_NMODE_IP35;
+	else
+		n_mode = LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_MORENODES_MASK;
 	printk("Machine is in %c mode.\n", n_mode ? 'N' : 'M');
 #ifdef CONFIG_SGI_SN_N_MODE
 	if (!n_mode)
Signature · 1 line
2.47.3
author
#15 lore raw

PATCH v2 15/53 MIPS: SGI-IP27: put a Bedrock hub's boot CPU in slot 0

In reply to Imre Kaloz

ip27_smp_setup() takes CPU 0 to be the boot CPU. On a Bedrock hub, swap the boot CPU's sn_cpu_info[] entry, found by nasid and PI_CPU_NUM slice, into slot 0, and give slot 0 master_nasid. The PROM's virtids run densely from 0 in board-list order and so match the table's slots.

---
 arch/mips/sgi-ip27/ip27-smp.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
arch/mips/sgi-ip27/ip27-smp.c +11 -2
index 62733e049570..d49766cffd12 100644
@@ -80,6 +80,15 @@ void cpu_node_probe(void)
 		highest = node_scan_cpus(nasid, highest);
 	}
 
+	/* The boot CPU must be CPU 0 wherever the board list puts it. */
+	for (i = 1; system_is_ip35 && i <= highest; i++) {
+		if (cputonasid(i) == master_nasid &&
+		    cputoslice(i) == LOCAL_HUB_L(PI_CPU_NUM)) {
+			swap(sn_cpu_info[0], sn_cpu_info[i]);
+			break;
+		}
+	}
+
 	printk("Discovered %d cpus on %d nodes\n", highest + 1, num_online_nodes());
 }
 
@@ -168,9 +177,9 @@ static void __init ip27_smp_setup(void)
 	replicate_kernel_text();
 
 	/*
-	 * PROM sets up system, that boot cpu is always first CPU on nasid 0
+	 * The boot CPU is CPU 0, on the node it booted from
 	 */
-	cputonasid(0) = 0;
+	cputonasid(0) = master_nasid;
 	cputoslice(0) = LOCAL_HUB_L(PI_CPU_NUM);
 }
 
Signature · 1 line
2.47.3
author
#16 lore raw

PATCH v2 16/53 MIPS: SGI-IP27: lay out node memory in 1GB banks on Bedrock hubs

In reply to Imre Kaloz

Hub describes a node's memory as 128MB slots, four slots to a klconfig bank entry. Bedrock gives each bank entry a 1GB slot of its own and sizes it in megabytes. Take the slot shift, the slot count and the bank size from the hub generation.

---
 arch/mips/sgi-ip27/ip27-memory.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)
arch/mips/sgi-ip27/ip27-memory.c +20 -5
index 4317f5ae1fd1..0204dc8bb1bb 100644
@@ -31,9 +31,16 @@
 
 #include "ip27-common.h"
 
-#define SLOT_PFNSHIFT		(SLOT_SHIFT - PAGE_SHIFT)
 #define PFN_NASIDSHFT		(NASID_SHFT - PAGE_SHIFT)
 
+/* A Bedrock node's memory comes in 1GB banks. */
+#define BEDROCK_SLOT_SHIFT	30
+
+static unsigned int __init slot_shift(void)
+{
+	return system_is_ip35 ? BEDROCK_SLOT_SHIFT : SLOT_SHIFT;
+}
+
 struct node_data *__node_data[MAX_NUMNODES];
 EXPORT_SYMBOL(__node_data);
 
@@ -230,7 +237,8 @@ static void __init dump_topology(void)
 
 static unsigned long __init slot_getbasepfn(nasid_t nasid, int slot)
 {
-	return ((unsigned long)nasid << PFN_NASIDSHFT) | (slot << SLOT_PFNSHIFT);
+	return ((unsigned long)nasid << PFN_NASIDSHFT) |
+	       ((unsigned long)slot << (slot_shift() - PAGE_SHIFT));
 }
 
 static unsigned long __init slot_psize_compute(nasid_t nasid, int slot)
@@ -249,6 +257,12 @@ static unsigned long __init slot_psize_compute(nasid_t nasid, int slot)
 	if (!banks)
 		return 0;
 
+	/* Bedrock bank entry N sizes the 1GB slot N, in megabytes. */
+	if (system_is_ip35) {
+		size = (unsigned long)banks->membnk_bnksz[slot];
+		return (size << 20) >> PAGE_SHIFT;
+	}
+
 	/* Size in _Megabytes_ */
 	size = (unsigned long)banks->membnk_bnksz[slot/4];
 
@@ -315,12 +329,13 @@ static void __init mlreset(void)
 static void __init szmem(void)
 {
 	unsigned long slot_psize, slot0sz = 0, nodebytes;	/* Hack to detect problem configs */
+	int slots = system_is_ip35 ? MD_MEM_BANKS : MAX_MEM_SLOTS;
 	int slot;
 	nasid_t node;
 
 	for_each_online_node(node) {
 		nodebytes = 0;
-		for (slot = 0; slot < MAX_MEM_SLOTS; slot++) {
+		for (slot = 0; slot < slots; slot++) {
 			slot_psize = slot_psize_compute(node, slot);
 			if (slot == 0)
 				slot0sz = slot_psize;
@@ -328,7 +343,7 @@ static void __init szmem(void)
 			 * We need to refine the hack when we have replicated
 			 * kernel text.
 			 */
-			nodebytes += (1LL << SLOT_SHIFT);
+			nodebytes += (1LL << slot_shift());
 
 			if (!slot_psize)
 				continue;
@@ -337,7 +352,7 @@ static void __init szmem(void)
 						(slot0sz << PAGE_SHIFT)) {
 				pr_info("Ignoring slot %d onwards on node %d\n",
 								slot, node);
-				slot = MAX_MEM_SLOTS;
+				slot = slots;
 				continue;
 			}
 			memblock_add_node(PFN_PHYS(slot_getbasepfn(node, slot)),
Signature · 1 line
2.47.3
author
#17 lore raw

PATCH v2 17/53 MIPS: SGI-IP27: reserve the bottom 64MB of node 0 on Bedrock hubs

In reply to Imre Kaloz

On Bedrock hubs, reserve the first 64MB of physical memory, the bottom of node 0, and place node 0's node data above it. node_getfirstfree() covers only the kernel image, so the area needs a reservation of its own.

---
 arch/mips/sgi-ip27/ip27-memory.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/mips/sgi-ip27/ip27-memory.c +12 -0
index 0204dc8bb1bb..98184dfcd8c5 100644
@@ -17,6 +17,7 @@
 #include <linux/mmzone.h>
 #include <linux/export.h>
 #include <linux/nodemask.h>
+#include <linux/sizes.h>
 #include <linux/swap.h>
 #include <linux/pfn.h>
 #include <linux/highmem.h>
@@ -36,6 +37,9 @@
 /* A Bedrock node's memory comes in 1GB banks. */
 #define BEDROCK_SLOT_SHIFT	30
 
+/* Reserved at the bottom of node 0, which starts at physical 0. */
+#define BEDROCK_RSVD_SIZE	SZ_64M
+
 static unsigned int __init slot_shift(void)
 {
 	return system_is_ip35 ? BEDROCK_SLOT_SHIFT : SLOT_SHIFT;
@@ -370,6 +374,10 @@ static void __init node_mem_init(nasid_t node)
 
 	get_pfn_range_for_nid(node, &start_pfn, &end_pfn);
 
+	/* Keep the node data above the reserved area. */
+	if (system_is_ip35 && node == 0)
+		slot_freepfn = max(slot_freepfn, PFN_UP(BEDROCK_RSVD_SIZE));
+
 	/*
 	 * Allocate the node data structures on the node first.
 	 */
@@ -410,6 +418,10 @@ void __init prom_meminit(void)
 
 	mlreset();
 	szmem();
+
+	if (system_is_ip35)
+		memblock_reserve(0, BEDROCK_RSVD_SIZE);
+
 	max_low_pfn = PHYS_PFN(memblock_end_of_DRAM());
 
 	for (node = 0; node < MAX_NUMNODES; node++) {
Signature · 1 line
2.47.3
author
#18 lore raw

PATCH v2 18/53 MIPS: SGI-IP27: route interrupt masks and slices through both PIs

In reply to Imre Kaloz

cputoslice() and PI_CPU_NUM return a physid, 0-3 across a Bedrock hub's two PIs, where a Hub has a plain A/B bit. Add helpers splitting it into A/B slot and PI block, and give every remote access the slice's PI block. Local accesses already reach the running CPU's own PI.

---
 arch/mips/include/asm/sn/arch.h |  8 ++++++++
 arch/mips/include/asm/sn/intr.h | 10 ++++++----
 arch/mips/sgi-ip27/ip27-berr.c  |  4 ++--
 arch/mips/sgi-ip27/ip27-irq.c   | 17 +++++++++--------
 arch/mips/sgi-ip27/ip27-smp.c   | 16 +++++++++-------
 arch/mips/sgi-ip27/ip27-timer.c |  4 ++--
 6 files changed, 36 insertions(+), 23 deletions(-)
arch/mips/include/asm/sn/arch.h +8 -0
index 9a9682543e89..602219f98b04 100644
@@ -18,7 +18,15 @@
 #endif
 
 #define cputonasid(cpu)		(sn_cpu_info[(cpu)].p_nasid)
+/*
+ * The slice is the CPU's physid: on a Bedrock hub 0-3 across two PI blocks,
+ * bit 0 selecting a PI's A/B register slot and bit 1 the PI block.
+ */
 #define cputoslice(cpu)		(sn_cpu_info[(cpu)].p_slice)
+#define slicetoab(slice)	((slice) & 1)
+#define slicetosubnode(slice)	(((slice) >> 1) & 1)
+#define cputoab(cpu)		slicetoab(cputoslice(cpu))
+#define cputosubnode(cpu)	slicetosubnode(cputoslice(cpu))
 
 #define INVALID_NASID		(nasid_t)-1
 #define INVALID_PNODEID		(pnodeid_t)-1
arch/mips/include/asm/sn/intr.h +6 -4
index 3d6954d370dc..90b613f68623 100644
@@ -29,13 +29,15 @@ do {								\
 	LOCAL_HUB_L(PI_INT_PEND0);				\
 } while (0);
 
-#define REMOTE_HUB_CLR_INTR(hub, level)				\
+/* An interrupt is pending in the PI block of the CPU it is routed to. */
+#define REMOTE_HUB_PI_CLR_INTR(hub, sn, level)			\
 do {								\
 	nasid_t	 __hub = (hub);					\
+	int __sn = (sn);					\
 								\
-	REMOTE_HUB_S(__hub, PI_INT_PEND_MOD, (level));		\
-	REMOTE_HUB_L(__hub, PI_INT_PEND0);			\
-} while (0);
+	REMOTE_HUB_PI_S(__hub, __sn, PI_INT_PEND_MOD, (level));	\
+	REMOTE_HUB_PI_L(__hub, __sn, PI_INT_PEND0);		\
+} while (0)
 
 /*
  * Hard-coded interrupt levels:
arch/mips/sgi-ip27/ip27-berr.c +2 -2
index 9eb497cb5d52..b176856aa77c 100644
@@ -63,7 +63,7 @@ static int ip27_be_handler(struct pt_regs *regs, int is_fixup)
 {
 	unsigned long errst0, errst1;
 	int data = regs->cp0_cause & 4;
-	int cpu = LOCAL_HUB_L(PI_CPU_NUM);
+	int cpu = slicetoab(LOCAL_HUB_L(PI_CPU_NUM));
 
 	if (is_fixup)
 		return MIPS_BE_FIXUP;
@@ -84,7 +84,7 @@ static int ip27_be_handler(struct pt_regs *regs, int is_fixup)
 void __init ip27_be_init(void)
 {
 	/* XXX Initialize all the Hub & Bridge error handling here.  */
-	int cpu = LOCAL_HUB_L(PI_CPU_NUM);
+	int cpu = slicetoab(LOCAL_HUB_L(PI_CPU_NUM));
 	int cpuoff = cpu << 8;
 
 	mips_set_be_handler(ip27_be_handler);
arch/mips/sgi-ip27/ip27-irq.c +9 -8
index 7e5aa04c6695..02a49bb8529d 100644
@@ -72,7 +72,7 @@ static void disable_hub_irq(struct irq_data *d)
 static void setup_hub_mask(struct hub_irq_data *hd, const struct cpumask *mask)
 {
 	nasid_t nasid;
-	int cpu;
+	int cpu, sn;
 
 	cpu = cpumask_first_and(mask, cpu_online_mask);
 	if (cpu >= nr_cpu_ids)
@@ -80,12 +80,13 @@ static void setup_hub_mask(struct hub_irq_data *hd, const struct cpumask *mask)
 
 	nasid = cpu_to_node(cpu);
 	hd->cpu = cpu;
-	if (!cputoslice(cpu)) {
-		hd->irq_mask[0] = REMOTE_HUB_PTR(nasid, PI_INT_MASK0_A);
-		hd->irq_mask[1] = REMOTE_HUB_PTR(nasid, PI_INT_MASK1_A);
+	sn = cputosubnode(cpu);
+	if (!cputoab(cpu)) {
+		hd->irq_mask[0] = REMOTE_HUB_PI_PTR(nasid, sn, PI_INT_MASK0_A);
+		hd->irq_mask[1] = REMOTE_HUB_PI_PTR(nasid, sn, PI_INT_MASK1_A);
 	} else {
-		hd->irq_mask[0] = REMOTE_HUB_PTR(nasid, PI_INT_MASK0_B);
-		hd->irq_mask[1] = REMOTE_HUB_PTR(nasid, PI_INT_MASK1_B);
+		hd->irq_mask[0] = REMOTE_HUB_PI_PTR(nasid, sn, PI_INT_MASK0_B);
+		hd->irq_mask[1] = REMOTE_HUB_PI_PTR(nasid, sn, PI_INT_MASK1_B);
 	}
 }
 
@@ -147,7 +148,7 @@ static int hub_domain_alloc(struct irq_domain *domain, unsigned int virq,
 	info->nasid = cpu_to_node(hd->cpu);
 
 	/* Make sure it's not already pending when we connect it. */
-	REMOTE_HUB_CLR_INTR(info->nasid, swlevel);
+	REMOTE_HUB_PI_CLR_INTR(info->nasid, cputosubnode(hd->cpu), swlevel);
 
 	desc = irq_to_desc(virq);
 	desc->irq_common_data.node = info->nasid;
@@ -253,7 +254,7 @@ void install_ipi(void)
 {
 	int cpu = smp_processor_id();
 	unsigned long *mask = per_cpu(irq_enable_mask, cpu);
-	int slice = LOCAL_HUB_L(PI_CPU_NUM);
+	int slice = slicetoab(LOCAL_HUB_L(PI_CPU_NUM));
 	int resched, call;
 
 	resched = CPU_RESCHED_A_IRQ + slice;
arch/mips/sgi-ip27/ip27-smp.c +9 -7
index d49766cffd12..66c999a8b966 100644
@@ -94,15 +94,17 @@ void cpu_node_probe(void)
 
 static __init void intr_clear_all(nasid_t nasid)
 {
-	int i;
+	int i, sn, pis = system_is_ip35 ? 2 : 1;
 
-	REMOTE_HUB_S(nasid, PI_INT_MASK0_A, 0);
-	REMOTE_HUB_S(nasid, PI_INT_MASK0_B, 0);
-	REMOTE_HUB_S(nasid, PI_INT_MASK1_A, 0);
-	REMOTE_HUB_S(nasid, PI_INT_MASK1_B, 0);
+	for (sn = 0; sn < pis; sn++) {
+		REMOTE_HUB_PI_S(nasid, sn, PI_INT_MASK0_A, 0);
+		REMOTE_HUB_PI_S(nasid, sn, PI_INT_MASK0_B, 0);
+		REMOTE_HUB_PI_S(nasid, sn, PI_INT_MASK1_A, 0);
+		REMOTE_HUB_PI_S(nasid, sn, PI_INT_MASK1_B, 0);
 
-	for (i = 0; i < 128; i++)
-		REMOTE_HUB_CLR_INTR(nasid, i);
+		for (i = 0; i < 128; i++)
+			REMOTE_HUB_PI_CLR_INTR(nasid, sn, i);
+	}
 }
 
 static void ip27_send_ipi_single(int destid, unsigned int action)
arch/mips/sgi-ip27/ip27-timer.c +2 -2
index 5f4da05cb2c9..aee14a7aad8a 100644
@@ -30,7 +30,7 @@
 static int rt_next_event(unsigned long delta, struct clock_event_device *evt)
 {
 	unsigned int cpu = smp_processor_id();
-	int slice = cputoslice(cpu);
+	int slice = cputoab(cpu);
 	unsigned long cnt;
 
 	cnt = LOCAL_HUB_L(PI_RT_COUNT);
@@ -47,7 +47,7 @@ static irqreturn_t hub_rt_counter_handler(int irq, void *dev_id)
 {
 	unsigned int cpu = smp_processor_id();
 	struct clock_event_device *cd = &per_cpu(hub_rt_clockevent, cpu);
-	int slice = cputoslice(cpu);
+	int slice = cputoab(cpu);
 
 	/*
 	 * Ack
Signature · 1 line
2.47.3
author
#19 lore raw

PATCH v2 19/53 MIPS: SGI-IP27: address a CPU's own PI for NMI, IPI and RT counter

In reply to Imre Kaloz

REMOTE_HUB_SEND_INTR(), SEND_NMI() and nmi_dump_hub_irq() reach the first PI only; address a CPU's own PI. Call hub_rtc_init() once per PI; its LOCAL_HUB writes reach the calling CPU's own PI. Read the clocksource from the boot CPU's PI and enable the Bedrock NI reset for NMI.

---
 arch/mips/include/asm/sn/intr.h      |  4 +--
 arch/mips/include/asm/sn/kldir.h     |  1 +
 arch/mips/include/asm/sn/sn1/hub.h   | 11 ++++++++
 arch/mips/include/asm/sn/sn1/kldir.h | 14 ++++++++++
 arch/mips/sgi-ip27/ip27-init.c       | 14 +++++++---
 arch/mips/sgi-ip27/ip27-nmi.c        | 38 +++++++++++++++++++---------
 arch/mips/sgi-ip27/ip27-smp.c        |  4 +--
 arch/mips/sgi-ip27/ip27-timer.c      |  8 ++++--
 8 files changed, 73 insertions(+), 21 deletions(-)
 create mode 100644 arch/mips/include/asm/sn/sn1/kldir.h
arch/mips/include/asm/sn/intr.h +2 -2
index 90b613f68623..4927232fafc3 100644
@@ -14,8 +14,8 @@
 
 #define LOCAL_HUB_SEND_INTR(level)				\
 	LOCAL_HUB_S(PI_INT_PEND_MOD, (0x100 | (level)))
-#define REMOTE_HUB_SEND_INTR(hub, level)			\
-	REMOTE_HUB_S((hub), PI_INT_PEND_MOD, (0x100 | (level)))
+#define REMOTE_HUB_PI_SEND_INTR(hub, sn, level)			\
+	REMOTE_HUB_PI_S((hub), (sn), PI_INT_PEND_MOD, (0x100 | (level)))
 
 /*
  * When clearing the interrupt, make sure this clear does make it
arch/mips/include/asm/sn/kldir.h +1 -0
index f394b1e0c956..23999dd43eb2 100644
@@ -31,6 +31,7 @@ typedef struct kldir_ent_s {
 
 #ifdef CONFIG_SGI_IP27
 #include <asm/sn/sn0/kldir.h>
+#include <asm/sn/sn1/kldir.h>
 #endif
 
 #endif /* _ASM_SN_KLDIR_H */
arch/mips/include/asm/sn/sn1/hub.h +11 -0
index 71ccd2ba3698..60e0f249852f 100644
@@ -26,4 +26,15 @@
 #define LRI_SYSTEM_SIZE_IP35(id)	(((id) >> 46) & 0x3)
 #define LRI_SYSTEM_SIZE_NMODE_IP35	2
 
+/*
+ * Network interface port reset: bit 0 sends a link reset, bit 2 resets
+ * the local Bedrock.  Bit 0 of the reset enable register lets a reset
+ * arriving over the link reset this Bedrock.
+ */
+#define NI_PORT_RESET_IP35	(HUBNIBASE_IP35 + 0x000008)
+#define NI_RESET_ACTION_IP35	0x01
+#define NI_RESET_LOCAL_IP35	0x04
+#define NI_RESET_ENABLE_IP35	(HUBNIBASE_IP35 + 0x000010)
+#define NI_RESET_OK_IP35	0x01
+
 #endif /* _ASM_SN_SN1_HUB_H */
arch/mips/include/asm/sn/sn1/kldir.h new file +14 -0
new file mode 100644
index 000000000000..c95dccb3ce55
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * SN1 (Bedrock) kldir constants.
+ *
+ * Copyright (C) 2026 Imre Kaloz <[email protected]>
+ */
+#ifndef _ASM_SN_SN1_KLDIR_H
+#define _ASM_SN_SN1_KLDIR_H
+
+/* Save area of kernel NMI regs in the PROM format. */
+#define IP35_NMI_KREGS_OFFSET		0x9000
+#define IP35_NMI_KREGS_CPU_SIZE	0x400
+
+#endif /* _ASM_SN_SN1_KLDIR_H */
arch/mips/sgi-ip27/ip27-init.c +11 -3
index 108d90908763..88d79c50d9a7 100644
@@ -37,7 +37,11 @@
 
 #define CPU_NONE		(cpuid_t)-1
 
+/* A Bedrock hub has two PI register blocks; a Hub has one. */
+#define PIS_PER_HUB		2
+
 static DECLARE_BITMAP(hub_init_mask, MAX_NUMNODES);
+static DECLARE_BITMAP(pi_init_mask, MAX_NUMNODES * PIS_PER_HUB);
 nasid_t master_nasid = INVALID_NASID;
 bool system_is_ip35;
 
@@ -46,9 +50,15 @@ EXPORT_SYMBOL_GPL(sn_cpu_info);
 
 static void per_hub_init(nasid_t nasid)
 {
+	int cpu = smp_processor_id();
 	struct hub_data *hub = hub_data(nasid);
+	int subnode = cputosubnode(cpu);
 
-	cpumask_set_cpu(smp_processor_id(), &hub->h_cpus);
+	cpumask_set_cpu(cpu, &hub->h_cpus);
+
+	/* A second pass would zero the counter under a CPU already ticking. */
+	if (!test_and_set_bit(nasid * PIS_PER_HUB + subnode, pi_init_mask))
+		hub_rtc_init(nasid);
 
 	if (test_and_set_bit(nasid, hub_init_mask))
 		return;
@@ -58,8 +68,6 @@ static void per_hub_init(nasid_t nasid)
 	REMOTE_HUB_S(nasid, IIO_ICTP, 0x800);
 	REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
 
-	hub_rtc_init(nasid);
-
 	if (nasid) {
 		/* copy exception handlers from first node to current node */
 		memcpy((void *)NODE_OFFSET_TO_K0(nasid, 0),
arch/mips/sgi-ip27/ip27-nmi.c +26 -12
index 2cb17f8c7bf3..627816d5bc6f 100644
@@ -15,8 +15,9 @@
 
 #include "ip27-common.h"
 
-#define SEND_NMI(_nasid, _slice)	\
-	REMOTE_HUB_S((_nasid),  (PI_NMI_A + ((_slice) * PI_NMI_OFFSET)), 1)
+#define SEND_NMI(_nasid, _slice)					\
+	REMOTE_HUB_PI_S((_nasid), slicetosubnode(_slice),		\
+		(PI_NMI_A + (slicetoab(_slice) * PI_NMI_OFFSET)), 1)
 
 typedef unsigned long machreg_t;
 
@@ -45,12 +46,18 @@ void install_cpu_nmi_handler(int slice)
 static void nmi_cpu_eframe_save(nasid_t nasid, int slice)
 {
 	struct reg_struct *nr;
+	int kregs_offset, kregs_cpu_size;
 	int		i;
 
+	kregs_offset = system_is_ip35 ? IP35_NMI_KREGS_OFFSET :
+					  IP27_NMI_KREGS_OFFSET;
+	kregs_cpu_size = system_is_ip35 ? IP35_NMI_KREGS_CPU_SIZE :
+					    IP27_NMI_KREGS_CPU_SIZE;
+
 	/* Get the pointer to the current cpu's register set. */
 	nr = (struct reg_struct *)
-		(TO_UNCAC(TO_NODE(nasid, IP27_NMI_KREGS_OFFSET)) +
-		slice * IP27_NMI_KREGS_CPU_SIZE);
+		(TO_UNCAC(TO_NODE(nasid, kregs_offset)) +
+		slice * kregs_cpu_size);
 
 	pr_emerg("NMI nasid %d: slice %d\n", nasid, slice);
 
@@ -120,18 +127,19 @@ static void nmi_cpu_eframe_save(nasid_t nasid, int slice)
 
 static void nmi_dump_hub_irq(nasid_t nasid, int slice)
 {
+	int subnode = slicetosubnode(slice);
 	u64 mask0, mask1, pend0, pend1;
 
-	if (slice == 0) {				/* Slice A */
-		mask0 = REMOTE_HUB_L(nasid, PI_INT_MASK0_A);
-		mask1 = REMOTE_HUB_L(nasid, PI_INT_MASK1_A);
+	if (!slicetoab(slice)) {			/* Slice A */
+		mask0 = REMOTE_HUB_PI_L(nasid, subnode, PI_INT_MASK0_A);
+		mask1 = REMOTE_HUB_PI_L(nasid, subnode, PI_INT_MASK1_A);
 	} else {					/* Slice B */
-		mask0 = REMOTE_HUB_L(nasid, PI_INT_MASK0_B);
-		mask1 = REMOTE_HUB_L(nasid, PI_INT_MASK1_B);
+		mask0 = REMOTE_HUB_PI_L(nasid, subnode, PI_INT_MASK0_B);
+		mask1 = REMOTE_HUB_PI_L(nasid, subnode, PI_INT_MASK1_B);
 	}
 
-	pend0 = REMOTE_HUB_L(nasid, PI_INT_PEND0);
-	pend1 = REMOTE_HUB_L(nasid, PI_INT_PEND1);
+	pend0 = REMOTE_HUB_PI_L(nasid, subnode, PI_INT_PEND0);
+	pend1 = REMOTE_HUB_PI_L(nasid, subnode, PI_INT_PEND1);
 
 	pr_emerg("PI_INT_MASK0: %16llx PI_INT_MASK1: %16llx\n", mask0, mask1);
 	pr_emerg("PI_INT_PEND0: %16llx PI_INT_PEND1: %16llx\n", pend0, pend1);
@@ -235,5 +243,11 @@ static void nmi_dump(void)
 	 */
 	nmi_eframes_save();
 	printk_trigger_flush();
-	LOCAL_HUB_S(NI_PORT_RESET, NPR_PORTRESET | NPR_LOCALRESET);
+	if (system_is_ip35) {
+		LOCAL_HUB_S(NI_RESET_ENABLE_IP35, NI_RESET_OK_IP35);
+		LOCAL_HUB_S(NI_PORT_RESET_IP35,
+			    NI_RESET_ACTION_IP35 | NI_RESET_LOCAL_IP35);
+	} else {
+		LOCAL_HUB_S(NI_PORT_RESET, NPR_PORTRESET | NPR_LOCALRESET);
+	}
 }
arch/mips/sgi-ip27/ip27-smp.c +2 -2
index 66c999a8b966..13b85e3ba311 100644
@@ -122,13 +122,13 @@ static void ip27_send_ipi_single(int destid, unsigned int action)
 		panic("sendintr");
 	}
 
-	irq += cputoslice(destid);
+	irq += cputoab(destid);
 
 	/*
 	 * Set the interrupt bit associated with the CPU we want to
 	 * send the interrupt to.
 	 */
-	REMOTE_HUB_SEND_INTR(cpu_to_node(destid), irq);
+	REMOTE_HUB_PI_SEND_INTR(cpu_to_node(destid), cputosubnode(destid), irq);
 }
 
 static void ip27_send_ipi_mask(const struct cpumask *mask, unsigned int action)
arch/mips/sgi-ip27/ip27-timer.c +6 -2
index aee14a7aad8a..14df8608b14b 100644
@@ -100,9 +100,13 @@ static void __init hub_rt_clock_event_global_init(void)
 				   "hub-rt", &hub_rt_clockevent));
 }
 
+/*
+ * Each PI of a Bedrock hub has its own RT counter, zeroed when that PI's
+ * first CPU comes up; the timebase is the boot CPU's.
+ */
 static u64 hub_rt_read(struct clocksource *cs)
 {
-	return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT);
+	return REMOTE_HUB_PI_L(cputonasid(0), cputosubnode(0), PI_RT_COUNT);
 }
 
 struct clocksource hub_rt_clocksource = {
@@ -115,7 +119,7 @@ struct clocksource hub_rt_clocksource = {
 
 static u64 notrace hub_rt_read_sched_clock(void)
 {
-	return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT);
+	return REMOTE_HUB_PI_L(cputonasid(0), cputosubnode(0), PI_RT_COUNT);
 }
 
 static void __init hub_rt_clocksource_init(void)
Signature · 1 line
2.47.3
author
#20 lore raw

PATCH v2 20/53 MIPS: SGI-IP27: take a CPU's node from the CPU table in per_cpu_init()

In reply to Imre Kaloz

cpu_node_probe() records every CPU's node before the first secondary launches. Take it from there, so a CPU coming up inherits its node from the boot CPU's scan instead of reading the hub again.

---
 arch/mips/sgi-ip27/ip27-init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/sgi-ip27/ip27-init.c +1 -1
index 88d79c50d9a7..15811fb3cdee 100644
@@ -81,7 +81,7 @@ static void per_hub_init(nasid_t nasid)
 void per_cpu_init(void)
 {
 	int cpu = smp_processor_id();
-	nasid_t nasid = get_nasid();
+	nasid_t nasid = cputonasid(cpu);
 
 	clear_c0_status(ST0_IM);
 
Signature · 1 line
2.47.3
author
#21 lore raw

PATCH v2 21/53 MIPS: SGI-IP27: resolve the mapped-kernel node shift at runtime

In reply to Imre Kaloz

A Bedrock hub puts the nasid one bit higher in an address than a Hub does. MAPPED_KERNEL_SETUP_TLB builds its wired entry and smp_slave_setup() reaches the kernel variables before any C runs, so take the shift from the hub's Crosstalk widget ID.

---
 .../include/asm/mach-ip27/kernel-entry-init.h | 23 ++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
arch/mips/include/asm/mach-ip27/kernel-entry-init.h +20 -3
index cd50e6d3d966..1bedd3c3bc58 100644
@@ -21,6 +21,21 @@
 #define PAGE_DIRTY		(1 << 8)
 #define CACHE_CACHABLE_COW	(5 << 9)
 
+	/*
+	 * A Bedrock hub puts the nasid one bit higher in an address than a
+	 * Hub does.  Returns the shift in \shft, clobbering \tmp.
+	 */
+	.macro	GET_NASID_SHFT shft, tmp
+	.set	push
+	.set	reorder
+	GET_HUB_GEN_ASM \tmp
+	li	\shft, SN1_NASID_SHFT
+	beqz	\tmp, 1f
+	li	\shft, SN0_NASID_SHFT
+1:
+	.set	pop
+	.endm
+
 	/*
 	 * inputs are the text nasid in t1, data nasid in t2.
 	 */
@@ -33,9 +48,10 @@
 	 */
 	dli	t0, 0xffffffffc0000000
 	dmtc0	t0, CP0_ENTRYHI
+	GET_NASID_SHFT	t3, t0
 	li	t0, 0x1c000		# Offset of text into node memory
-	dsll	t1, NASID_SHFT		# Shift text nasid into place
-	dsll	t2, NASID_SHFT		# Same for data nasid
+	dsllv	t1, t1, t3		# Shift text nasid into place
+	dsllv	t2, t2, t3		# Same for data nasid
 	or	t1, t1, t0		# Physical load address of kernel text
 	or	t2, t2, t0		# Physical load address of kernel data
 	dsrl	t1, 12			# 4K pfn
@@ -78,9 +94,10 @@
 	.macro	smp_slave_setup
 #ifdef CONFIG_MAPPED_KERNEL
 	GET_NASID_ASM	t1, t0
+	GET_NASID_SHFT	t3, t0
 	dli	t0, KLDIR_OFFSET + (KLI_KERN_VARS * KLDIR_ENT_SIZE) + \
 		    KLDIR_OFF_POINTER + CAC_BASE
-	dsll	t1, NASID_SHFT
+	dsllv	t1, t1, t3
 	or	t0, t0, t1
 	ld	t0, 0(t0)			# t0 points to kern_vars struct
 	lh	t1, KV_RO_NASID_OFFSET(t0)
Signature · 1 line
2.47.3
author
#22 lore raw

PATCH v2 22/53 MIPS: SGI-IP27: load the kernel at node offset 0x40000

In reply to Imre Kaloz

A Bedrock machine's PROM owns node memory below offset 0x40000. Link both the mapped and the unmapped kernel there instead of at 0x1c000. On an Origin 200/2000 the kernel moves up by 144KB, and the 144KB below it stays reserved and unused.

---
 arch/mips/include/asm/mach-ip27/kernel-entry-init.h |  2 +-
 arch/mips/include/asm/sn/mapped_kernel.h            |  6 +++---
 arch/mips/sgi-ip27/Platform                         | 11 ++++++-----
 3 files changed, 10 insertions(+), 9 deletions(-)
arch/mips/include/asm/mach-ip27/kernel-entry-init.h +1 -1
index 1bedd3c3bc58..958f4b390df8 100644
@@ -49,7 +49,7 @@
 	dli	t0, 0xffffffffc0000000
 	dmtc0	t0, CP0_ENTRYHI
 	GET_NASID_SHFT	t3, t0
-	li	t0, 0x1c000		# Offset of text into node memory
+	li	t0, 0x40000		# Offset of text into node memory
 	dsllv	t1, t1, t3		# Shift text nasid into place
 	dsllv	t2, t2, t3		# Same for data nasid
 	or	t1, t1, t0		# Physical load address of kernel text
arch/mips/include/asm/sn/mapped_kernel.h +3 -3
index 3f1049807018..28227718e391 100644
@@ -10,7 +10,7 @@
 
 /*
  * Note on how mapped kernels work: the text and data section is
- * compiled at cksseg segment (LOADADDR = 0xc001c000), and the
+ * compiled at cksseg segment (LOADADDR = 0xc0040000), and the
  * init/setup/data section gets a 16M virtual address bump in the
  * ld.script file (so that tlblo0 and tlblo1 maps the sections).
  * The vmlinux.64 section addresses are put in the xkseg range
@@ -18,8 +18,8 @@
  * on IRIX to see where the sections go. The Origin loader loads
  * the two sections contiguously in physical memory. The loader
  * sets the entry point into kernel_entry using a xkphys address,
- * but instead of using 0xa800000001160000, it uses the address
- * 0xa800000000160000, which is where it physically loaded that
+ * but instead of using 0xa800000001184000, it uses the address
+ * 0xa800000000184000, which is where it physically loaded that
  * code. So no jumps can be done before we have switched to using
  * cksseg addresses.
  */
arch/mips/sgi-ip27/Platform +6 -5
index e734ee6abd44..b312bf69bce1 100644
@@ -1,16 +1,17 @@
 #
 # SGI-IP27 (Origin200/2000)
 #
-# Set the load address to >= 0xc000000000300000 if you want to leave space for
-# symmon, 0xc00000000001c000 for production kernels.  Note that the value must
-# be 16kb aligned or the handling of the current variable will break.
+# A Bedrock machine's PROM owns node memory below offset 0x40000, so that is
+# where the kernel loads.  Set the load address to >= 0xc000000000300000
+# instead if you want to leave space for symmon.  Note that the value must be
+# 16kb aligned or the handling of the current variable will break.
 #
 cflags-$(CONFIG_SGI_IP27)	+= -I$(srctree)/arch/mips/include/asm/mach-ip27
 ifdef CONFIG_MAPPED_KERNEL
-load-$(CONFIG_SGI_IP27)		+= 0xc00000004001c000
+load-$(CONFIG_SGI_IP27)		+= 0xc000000040040000
 OBJCOPYFLAGS			:= --change-addresses=0x3fffffff80000000
 dataoffset-$(CONFIG_SGI_IP27)	+= 0x01000000
 else
-load-$(CONFIG_SGI_IP27)		+= 0xa80000000001c000
+load-$(CONFIG_SGI_IP27)		+= 0xa800000000040000
 OBJCOPYFLAGS			:= --change-addresses=0x57ffffff80000000
 endif
Signature · 1 line
2.47.3
author
#23 lore raw

PATCH v2 23/53 MIPS: SGI-IP27: xbow_probe(): recognize KLTYPE_PBRICK_XBOW

In reply to Imre Kaloz

An IP35-family chassis records its crossbar board as KLTYPE_PBRICK_XBOW rather than the KLTYPE_MIDPLANE8 an Origin 200/2000 midplane carries, so xbow_probe() found no board record and never set up the crossbar. Fall back to the brick type when the midplane lookup misses, and warn when neither matches.

---
 arch/mips/sgi-ip27/ip27-xtalk.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
arch/mips/sgi-ip27/ip27-xtalk.c +13 -2
index 10834880c261..baa937b474a8 100644
@@ -159,8 +159,19 @@ static int xbow_probe(nasid_t nasid)
 	 * need to probe xbow
 	 */
 	brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_MIDPLANE8);
-	if (!brd)
-		return -ENODEV;
+	if (!brd) {
+		/*
+		 * An IP35-family chassis records its crossbar as
+		 * KLTYPE_PBRICK_XBOW instead.
+		 */
+		brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid),
+				  KLTYPE_PBRICK_XBOW);
+		if (!brd) {
+			pr_warn("xtalk:n%d no midplane/xbow board found\n",
+				nasid);
+			return -ENODEV;
+		}
+	}
 
 	xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW);
 	if (!xbow_p)
Signature · 1 line
2.47.3
#24 lore raw

Re: [PATCH v2 23/53] MIPS: SGI-IP27: xbow_probe(): recognize KLTYPE_PBRICK_XBOW

Quoted 16 lines · Imre Kaloz

An IP35-family chassis records its crossbar board as KLTYPE_PBRICK_XBOW rather than the KLTYPE_MIDPLANE8 an Origin 200/2000 midplane carries, so xbow_probe() found no board record and never set up the crossbar. Fall back to the brick type when the midplane lookup misses, and warn when neither matches.

---
 arch/mips/sgi-ip27/ip27-xtalk.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
arch/mips/sgi-ip27/ip27-xtalk.c +0 -0
index 10834880c261..baa937b474a8 100644

arch/mips/sgi-ip27/ip27-xtalk.c static int xbow_probe(nasid_t nasid) · line 161

Quoted 3 lines
arch/mips/sgi-ip27/ip27-xtalk.c +0 -0
@@ -159,8 +159,19 @@ static int xbow_probe(nasid_t nasid)
 	 * need to probe xbow
 	 */
 	brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_MIDPLANE8);

use

	brd = find_lboard_class(KL_CONFIG_INFO(nasid), KLCLASS_MIDPLANE);

instead, which looks for all midplane types.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
author
#25 lore raw

Re: [PATCH v2 23/53] MIPS: SGI-IP27: xbow_probe(): recognize KLTYPE_PBRICK_XBOW

Quoted 8 lines · Thomas Bogendoerfer
Quoted 1 line · Imre Kaloz

brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_MIDPLANE8);

use

	brd = find_lboard_class(KL_CONFIG_INFO(nasid), KLCLASS_MIDPLANE);

instead, which looks for all midplane types.

Indeed, KLTYPE_PBRICK_XBOW is a KLCLASS_MIDPLANE type too, so that covers the IP35 case without the fallback. Will do in v3.

I'll hold v3 until you have had a chance to go through the rest of the series.

Thanks,
Imre

author
#26 lore raw

PATCH v2 24/53 MIPS: ip27_defconfig: enable the IOC3 MFD, its cell drivers and tg3

In reply to Imre Kaloz

CONFIG_SGI_MFD_IOC3 was unset, leaving the MFD core out of the built kernel and the existing CONFIG_SGI_IOC3_ETH=y line unsatisfiable, since that driver depends on it. Enable it with the 8250 and PS/2 cell drivers, and enable tg3, which drives the Tezro's Gigabit Ethernet.

On IP27 the IOC3 sits behind a Bridge whose probe defers until its 1-wire PROM is readable, so also enable the SGI 1-wire master and the DS250x slave.

Fixes 0ce5ebd24d25 ("mfd: ioc3: Add driver for SGI IOC3 chip")
Fixes 5dc76a96e95a ("MIPS: PCI: use information from 1-wire PROM for IOC3 detection")
---
 arch/mips/configs/ip27_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
arch/mips/configs/ip27_defconfig +7 -0
index ac885ff5b712..4c8abe4611b8 100644
@@ -140,6 +140,7 @@ CONFIG_ATL2=m
 CONFIG_ATL1E=m
 CONFIG_ATL1C=m
 CONFIG_B44=m
+CONFIG_TIGON3=y
 CONFIG_BNX2X=m
 CONFIG_ENIC=m
 CONFIG_BE2NET=m
@@ -219,6 +220,7 @@ CONFIG_RTL8180=m
 CONFIG_WL1251=m
 CONFIG_WL12XX=m
 # CONFIG_INPUT is not set
+CONFIG_SERIO_SGI_IOC3=m
 CONFIG_SERIO_LIBPS2=m
 CONFIG_SERIO_RAW=m
 CONFIG_SERIO_ALTERA_PS2=m
@@ -229,6 +231,7 @@ CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_EXTENDED=y
 CONFIG_SERIAL_8250_MANY_PORTS=y
 CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_IOC3=y
 CONFIG_HW_RANDOM_TIMERIOMEM=m
 CONFIG_I2C_CHARDEV=m
 CONFIG_I2C_ALI1535=m
@@ -250,6 +253,9 @@ CONFIG_I2C_PCA_PLATFORM=m
 CONFIG_I2C_SIMTEC=m
 CONFIG_I2C_TAOS_EVM=m
 CONFIG_I2C_STUB=m
+CONFIG_W1=y
+CONFIG_W1_MASTER_SGI=y
+CONFIG_W1_SLAVE_DS250X=y
 # CONFIG_HWMON is not set
 CONFIG_THERMAL=y
 # CONFIG_VGA_ARB is not set
@@ -260,6 +266,7 @@ CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
 CONFIG_LEDS_TRIGGER_BACKLIGHT=m
 CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
+CONFIG_SGI_MFD_IOC3=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_M48T35=y
 CONFIG_UIO=y
Signature · 1 line
2.47.3
author
#27 lore raw

PATCH v2 25/53 net: ethernet: sgi: ioc3-eth: apply the DMA attributes only to 64-bit addresses

In reply to Imre Kaloz

A Bridge 64-bit direct-mapped DMA address carries the target widget and the DMA attributes. An address in a bridge's 2GB 32-bit direct window carries neither, so attributes OR-ed onto one form a 64-bit address aimed at widget 0, and every receive raises a PCI error.

Apply the attributes, and the RX barrier's upper address bits, only to 64-bit addresses, so the IOC3 can use the 32-bit window behind an XBridge or PIC.

---
 drivers/net/ethernet/sgi/ioc3-eth.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/net/ethernet/sgi/ioc3-eth.c +22 -3
index 009f37105eaf..f86dd192a3d3 100644
@@ -152,19 +152,38 @@ static inline int ioc3_alloc_skb(struct ioc3_private *ip, struct sk_buff **skb,
 }
 
 #ifdef CONFIG_PCI_XTALK_BRIDGE
+/* A Bridge 64-bit direct-mapped DMA address carries the target widget in
+ * bits 63:60 and the DMA attributes below it.  An address in the 32-bit
+ * direct window, which the IOC3 uses behind an XBridge or PIC, carries
+ * neither, so attributes OR-ed onto one form a 64-bit address aimed at
+ * widget 0.
+ */
 static inline unsigned long ioc3_map(dma_addr_t addr, unsigned long attr)
 {
+	if (!(addr & PCI64_ATTR_TARG_MASK))
+		return addr;
+
 	return (addr & ~PCI64_ATTR_BAR) | attr;
 }
 
-#define ERBAR_VAL	(ERBAR_BARRIER_BIT << ERBAR_RXBARR_SHIFT)
+/* The RX barrier's upper address bits follow the same form. */
+static inline u32 ioc3_erbar(dma_addr_t addr)
+{
+	if (!(addr & PCI64_ATTR_TARG_MASK))
+		return 0;
+
+	return ERBAR_BARRIER_BIT << ERBAR_RXBARR_SHIFT;
+}
 #else
 static inline unsigned long ioc3_map(dma_addr_t addr, unsigned long attr)
 {
 	return addr;
 }
 
-#define ERBAR_VAL	0
+static inline u32 ioc3_erbar(dma_addr_t addr)
+{
+	return 0;
+}
 #endif
 
 static int ioc3eth_nvmem_match(struct device *dev, const void *data)
@@ -727,7 +746,7 @@ static void ioc3_init(struct net_device *dev)
 	readl(&regs->emcr);
 
 	/* Misc registers  */
-	writel(ERBAR_VAL, &regs->erbar);
+	writel(ioc3_erbar(ip->rxr_dma), &regs->erbar);
 	readl(&regs->etcdc);			/* Clear on read */
 	writel(15, &regs->ercsr);		/* RX low watermark  */
 	writel(0, &regs->ertr);			/* Interrupt immediately */
Signature · 1 line
2.47.3
author
#28 lore raw

PATCH v2 26/53 MIPS: SGI-IP27: pick the XBridge and PIC DMA address form by mask

In reply to Imre Kaloz

XBridge and PIC need bit 55 set in a 64-bit direct-mapped DMA address; without it no data moves. arch_dma_set_mask() gives that form to a device with a 64-bit mask. PIC in PCI-X mode decodes only that form. PIC's PCI-X bit 33 lies outside b_wid_stat. Narrower devices use the 2GB 32-bit window, with SWIOTLB bouncing streaming buffers above it and ZONE_DMA32 serving coherent ones. The IOC3 and IOC4 take DMA unswapped and bit 55 swaps, so they stay on the window with swapping off in their slots. An MFD cell maps through its PCI parent.

The 64MB bounce pool comes from node 0 whenever DRAM passes 2GB (any multi-node Hub). A later patch flags PIC.

---
 arch/mips/Kconfig                          |  3 +
 arch/mips/include/asm/pci/bridge.h         |  7 ++
 arch/mips/pci/pci-xtalk-bridge.c           | 98 +++++++++++++++++++++-
 arch/mips/sgi-ip27/ip27-memory.c           | 18 ++++
 arch/mips/sgi-ip27/ip27-xtalk.c            | 15 +++-
 include/linux/pci_ids.h                    |  1 +
 include/linux/platform_data/xtalk-bridge.h |  2 +
 7 files changed, 139 insertions(+), 5 deletions(-)
arch/mips/Kconfig +3 -0
index b64f1a8ebf41..85f1c4bd6549 100644
@@ -771,6 +771,7 @@ config SGI_IP27
 	select NR_CPUS_DEFAULT_64
 	select PCI_DRIVERS_GENERIC
 	select PCI_XTALK_BRIDGE
+	select SWIOTLB
 	select SYS_HAS_CPU_R10000
 	select SYS_SUPPORTS_64BIT_KERNEL
 	select SYS_SUPPORTS_BIG_ENDIAN
@@ -779,6 +780,7 @@ config SGI_IP27
 	select WAR_R10000_LLSC
 	select MIPS_L1_CACHE_SHIFT_7
 	select NUMA
+	select ZONE_DMA32
 	help
 	  These are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
 	  workstations, and the IP35 machines built around the Bedrock hub
@@ -1254,6 +1256,7 @@ config PCI_GT64XXX_PCI0
 
 config PCI_XTALK_BRIDGE
 	bool
+	select ARCH_HAS_DMA_SET_MASK
 
 config NO_EXCEPT_FILL
 	bool
arch/mips/include/asm/pci/bridge.h +7 -0
index eaeafccd82c7..647ea5c9e34b 100644
@@ -413,6 +413,9 @@ struct bridge_err_cmdword {
 #define BRIDGE_STAT_PCI_GIO_N		(0x1 << 5)
 #define BRIDGE_STAT_PENDING		(0x1F << 0)
 
+/* PIC-only widget status bit, upper 32 bits of the register. */
+#define PIC_STAT_PCIX_ACTIVE		(0x1ull << 33)
+
 /* Bridge widget control register bits definition */
 #define BRIDGE_CTRL_FLASH_WR_EN		(0x1ul << 31)
 #define BRIDGE_CTRL_EN_CLK50		(0x1 << 30)
@@ -797,6 +800,7 @@ struct bridge_err_cmdword {
 #define PCI64_ATTR_PREC		0x0400000000000000
 #define PCI64_ATTR_VIRTUAL	0x0200000000000000
 #define PCI64_ATTR_BAR		0x0100000000000000
+#define PCI64_ATTR_SWAP		0x0080000000000000	/* XBridge, PIC */
 #define PCI64_ATTR_RMF_MASK	0x00ff000000000000
 #define PCI64_ATTR_RMF_SHFT	48
 
@@ -810,6 +814,9 @@ struct bridge_controller {
 	unsigned int		int_mapping[8][2];
 	u32			ioc3_sid[8];
 	nasid_t			nasid;
+	bool			is_xbridge;
+	bool			is_pic;
+	bool			is_pcix;
 };
 
 #define BRIDGE_CONTROLLER(bus) \
arch/mips/pci/pci-xtalk-bridge.c +96 -2

130 lines not on this page · raw message

arch/mips/sgi-ip27/ip27-memory.c +18 -0
index 98184dfcd8c5..a497bf0cbf37 100644
@@ -19,8 +19,10 @@
 #include <linux/nodemask.h>
 #include <linux/sizes.h>
 #include <linux/swap.h>
+#include <linux/swiotlb.h>
 #include <linux/pfn.h>
 #include <linux/highmem.h>
+#include <asm/bootinfo.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
 #include <asm/sections.h>
@@ -435,5 +437,21 @@ void __init prom_meminit(void)
 
 void __init arch_zone_limits_init(unsigned long *max_zone_pfns)
 {
+	/* The 32-bit DMA window of XBridge and PIC reaches only the first 2GB. */
+	max_zone_pfns[ZONE_DMA32] = min(max_low_pfn, PFN_DOWN(SZ_2G));
 	max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
 }
+
+/*
+ * XBridge and PIC devices on the 2GB 32-bit DMA window bounce through
+ * SWIOTLB, so cap the pool there; which widgets exist isn't known this
+ * early, so reserve it whenever node memory reaches past the window.
+ */
+void __init plat_swiotlb_setup(void)
+{
+	phys_addr_t old_limit = memblock_get_current_limit();
+
+	memblock_set_current_limit(min_t(phys_addr_t, old_limit, SZ_2G));
+	swiotlb_init(max_low_pfn > PFN_DOWN(SZ_2G), SWIOTLB_VERBOSE);
+	memblock_set_current_limit(old_limit);
+}
arch/mips/sgi-ip27/ip27-xtalk.c +12 -3
index baa937b474a8..bd2ac24452f5 100644
@@ -23,7 +23,13 @@
 #define XXBOW_WIDGET_PART_NUM	0xd000	/* Xbow in Xbridge */
 #define BASE_XBOW_PORT		8     /* Lowest external port */
 
-static void bridge_platform_create(nasid_t nasid, int widget, int masterwid)
+enum xtalk_bridge_type {
+	XTALK_BRIDGE,
+	XTALK_XBRIDGE,
+};
+
+static void bridge_platform_create(nasid_t nasid, int widget, int masterwid,
+				   enum xtalk_bridge_type type)
 {
 	struct xtalk_bridge_platform_data *bd;
 	struct sgi_w1_platform_data *wd;
@@ -85,6 +91,7 @@ static void bridge_platform_create(nasid_t nasid, int widget, int masterwid)
 	bd->intr_addr	= BIT_ULL(47) + 0x01800000 + PI_INT_PEND_MOD;
 	bd->nasid	= nasid;
 	bd->masterwid	= masterwid;
+	bd->is_xbridge	= type == XTALK_XBRIDGE;
 
 	bd->mem.name	= "Bridge PCI MEM";
 	bd->mem.start	= offset + (widget << SWIN_SIZE_BITS) + BRIDGE_DEVIO0;
@@ -136,8 +143,10 @@ static int probe_one_port(nasid_t nasid, int widget, int masterwid)
 
 	switch (partnum) {
 	case BRIDGE_WIDGET_PART_NUM:
+		bridge_platform_create(nasid, widget, masterwid, XTALK_BRIDGE);
+		break;
 	case XBRIDGE_WIDGET_PART_NUM:
-		bridge_platform_create(nasid, widget, masterwid);
+		bridge_platform_create(nasid, widget, masterwid, XTALK_XBRIDGE);
 		break;
 	default:
 		pr_info("xtalk:n%d/%d unknown widget (0x%x)\n",
@@ -228,7 +237,7 @@ static void xtalk_probe_node(nasid_t nasid)
 
 	switch (partnum) {
 	case BRIDGE_WIDGET_PART_NUM:
-		bridge_platform_create(nasid, 0x8, 0xa);
+		bridge_platform_create(nasid, 0x8, 0xa, XTALK_BRIDGE);
 		break;
 	case XBOW_WIDGET_PART_NUM:
 	case XXBOW_WIDGET_PART_NUM:
include/linux/pci_ids.h +1 -0
index 63774ae2bf71..fc92822b1509 100644
@@ -1113,6 +1113,7 @@
 #define PCI_VENDOR_ID_SGI		0x10a9
 #define PCI_DEVICE_ID_SGI_IOC3		0x0003
 #define PCI_DEVICE_ID_SGI_LITHIUM	0x1002
+#define PCI_DEVICE_ID_SGI_IOC4		0x100a
 
 #define PCI_VENDOR_ID_WINBOND		0x10ad
 #define PCI_DEVICE_ID_WINBOND_82C105	0x0105
include/linux/platform_data/xtalk-bridge.h +2 -0
index 51e5001f2c05..171b5bcf56e4 100644
@@ -17,6 +17,8 @@ struct xtalk_bridge_platform_data {
 	unsigned long io_offset;
 	nasid_t	nasid;
 	int	masterwid;
+	bool	is_xbridge;
+	bool	is_pic;
 };
 
 #endif /* PLATFORM_DATA_XTALK_BRIDGE_H */
Signature · 1 line
2.47.3
author
#29 lore raw

PATCH v2 27/53 MIPS: SGI-IP27: recognize the PXBow crossbar

In reply to Imre Kaloz

A Tezro's crossbar is a PXBow, widget part number 0xd100. Without recognizing it, xtalk_probe_node() logs the widget as unknown and never calls xbow_probe(), leaving every IO widget behind it unenumerated.

---
 arch/mips/include/asm/xtalk/xwidget.h | 7 +++++++
 arch/mips/sgi-ip27/ip27-xtalk.c       | 2 ++
 2 files changed, 9 insertions(+)
arch/mips/include/asm/xtalk/xwidget.h +7 -0
index 978877e8a090..6a98e87b4711 100644
@@ -109,6 +109,7 @@
 #define WIDGET_BDRCK_PART_NUM	0xc110
 #define WIDGET_TPU_PART_NUM	0xc202
 #define WIDGET_XXBOW_PART_NUM	0xd000
+#define WIDGET_PXBOW_PART_NUM	0xd100
 #define WIDGET_XBRDG_PART_NUM	0xd002
 #define WIDGET_NULL_PART_NUM	-1
 
@@ -183,6 +184,12 @@ static const struct widget_ident widget_idents[] __initconst __maybe_unused = {
 		"xxbow",
 		{NULL, "1.0", "2.0", NULL},
 	},
+	{
+		WIDGET_XXBOW_MFGR_NUM,
+		WIDGET_PXBOW_PART_NUM,
+		"pxbow",
+		{NULL, "1.0", NULL},
+	},
 	{
 		WIDGET_XBRDG_MFGR_NUM,
 		WIDGET_XBRDG_PART_NUM,
arch/mips/sgi-ip27/ip27-xtalk.c +2 -0
index bd2ac24452f5..105977316391 100644
@@ -21,6 +21,7 @@
 
 #define XBOW_WIDGET_PART_NUM	0x0
 #define XXBOW_WIDGET_PART_NUM	0xd000	/* Xbow in Xbridge */
+#define PXBOW_WIDGET_PART_NUM	0xd100	/* PXbow */
 #define BASE_XBOW_PORT		8     /* Lowest external port */
 
 enum xtalk_bridge_type {
@@ -241,6 +242,7 @@ static void xtalk_probe_node(nasid_t nasid)
 		break;
 	case XBOW_WIDGET_PART_NUM:
 	case XXBOW_WIDGET_PART_NUM:
+	case PXBOW_WIDGET_PART_NUM:
 		pr_info("xtalk:n%d/0 xbow widget\n", nasid);
 		xbow_probe(nasid);
 		break;
Signature · 1 line
2.47.3
author
#30 lore raw

PATCH v2 28/53 MIPS: PCI: xtalk-bridge: recognize the PIC widget's 64-bit-only registers

In reply to Imre Kaloz

PIC replicates the Bridge/XBridge register layout, twice in one widget window for its two PCI buses, and does not accept a 32-bit write to half of a 64-bit register. Flag it, widen the register accessors to the double word, and spawn a controller per bus.

---
 arch/mips/include/asm/pci/bridge.h | 70 +++++++++++++++++++++++++++---
 arch/mips/sgi-ip27/ip27-xtalk.c    | 30 ++++++++++---
 2 files changed, 89 insertions(+), 11 deletions(-)
arch/mips/include/asm/pci/bridge.h +64 -6
index 647ea5c9e34b..cbf36bcbe0b7 100644
@@ -12,6 +12,8 @@
 #ifndef _ASM_PCI_BRIDGE_H
 #define _ASM_PCI_BRIDGE_H
 
+#include <linux/build_bug.h>
+#include <linux/stddef.h>
 #include <linux/types.h>
 #include <linux/pci.h>
 #include <asm/xtalk/xwidget.h>		/* generic widget header */
@@ -39,6 +41,9 @@
 #define BRIDGE_SSRAM_64K	0x00010000	/* 64kB */
 #define BRIDGE_SSRAM_0K		0x00000000	/* 0kB */
 
+/* PIC replicates its register block twice within one widget's 16MB window. */
+#define PIC_BUS1_OFFSET		0x800000
+
 /* ========================================================================
  *    Bridge address map
  */
@@ -264,6 +269,15 @@ struct bridge_regs {
 	} b_external_flash;			/* 0xC00000 */
 };
 
+/*
+ * Pin b_device[]/b_rrb_map[]'s low-half placement: bridge_readl() and
+ * bridge_writel() rely on it.
+ */
+static_assert(offsetof(struct bridge_regs, b_device[0].reg) == 0x204);
+static_assert(offsetof(struct bridge_regs, b_device[1].reg) == 0x20c);
+static_assert(offsetof(struct bridge_regs, b_rrb_map[0].reg) == 0x284);
+static_assert(offsetof(struct bridge_regs, b_rrb_map[1].reg) == 0x28c);
+
 /*
  * Field formats for Error Command Word and Auxiliary Error Command Word
  * of bridge.
@@ -394,6 +408,7 @@ struct bridge_err_cmdword {
 /* Widget part number of bridge */
 #define BRIDGE_WIDGET_PART_NUM		0xc002
 #define XBRIDGE_WIDGET_PART_NUM		0xd002
+#define PIC_WIDGET_PART_NUM		0xd102
 
 /* Manufacturer of bridge */
 #define BRIDGE_WIDGET_MFGR_NUM		0x036
@@ -822,11 +837,54 @@ struct bridge_controller {
 #define BRIDGE_CONTROLLER(bus) \
 	((struct bridge_controller *)((bus)->sysdata))
 
-#define bridge_read(bc, reg)		__raw_readl(&bc->base->reg)
-#define bridge_write(bc, reg, val)	__raw_writel(val, &bc->base->reg)
-#define bridge_set(bc, reg, val)	\
-	__raw_writel(__raw_readl(&bc->base->reg) | (val), &bc->base->reg)
-#define bridge_clr(bc, reg, val)	\
-	__raw_writel(__raw_readl(&bc->base->reg) & ~(val), &bc->base->reg)
+/*
+ * PIC does not accept a 32-bit write to half of a 64-bit register, so
+ * widen each access to the 8-byte-aligned double word and extract or
+ * insert the 32-bit value at its byte position. The pointer is
+ * volatile-qualified because widget_cfg_t is, and b_widget sits in
+ * every bridge_regs.
+ */
+static inline u32 bridge_readl(struct bridge_controller *bc, volatile u32 *reg)
+{
+	void *dw;
+	unsigned int shift;
+
+	if (likely(!bc->is_pic))
+		return __raw_readl(reg);
+
+	dw = (void *)((unsigned long)reg & ~7UL);
+	shift = ((unsigned long)reg & 4) ? 0 : 32;
+
+	return __raw_readq(dw) >> shift;
+}
+
+static inline void bridge_writel(struct bridge_controller *bc,
+				 volatile u32 *reg, u32 val)
+{
+	void *dw;
+	unsigned int shift;
+	u64 tmp;
+
+	if (likely(!bc->is_pic)) {
+		__raw_writel(val, reg);
+		return;
+	}
+
+	dw = (void *)((unsigned long)reg & ~7UL);
+	shift = ((unsigned long)reg & 4) ? 0 : 32;
+
+	tmp = __raw_readq(dw);
+	tmp = (tmp & ~(0xffffffffULL << shift)) | ((u64)val << shift);
+	__raw_writeq(tmp, dw);
+}
+
+#define bridge_read(bc, reg)		bridge_readl(bc, &bc->base->reg)
+#define bridge_write(bc, reg, val)	bridge_writel(bc, &bc->base->reg, val)
+#define bridge_set(bc, reg, val)				\
+	bridge_writel(bc, &bc->base->reg,			\
+		      bridge_readl(bc, &bc->base->reg) | (val))
+#define bridge_clr(bc, reg, val)				\
+	bridge_writel(bc, &bc->base->reg,			\
+		      bridge_readl(bc, &bc->base->reg) & ~(val))
 
 #endif /* _ASM_PCI_BRIDGE_H */
arch/mips/sgi-ip27/ip27-xtalk.c +25 -5
index 105977316391..73b2eef96bdb 100644
@@ -27,6 +27,8 @@
 enum xtalk_bridge_type {
 	XTALK_BRIDGE,
 	XTALK_XBRIDGE,
+	XTALK_PIC_BUS0,
+	XTALK_PIC_BUS1,
 };
 
 static void bridge_platform_create(nasid_t nasid, int widget, int masterwid,
@@ -88,21 +90,32 @@ static void bridge_platform_create(nasid_t nasid, int widget, int masterwid,
 	}
 
 
-	bd->bridge_addr = RAW_NODE_SWIN_BASE(nasid, widget);
+	bd->bridge_addr = RAW_NODE_SWIN_BASE(nasid, widget) +
+			  (type == XTALK_PIC_BUS1 ? PIC_BUS1_OFFSET : 0);
 	bd->intr_addr	= BIT_ULL(47) + 0x01800000 + PI_INT_PEND_MOD;
 	bd->nasid	= nasid;
 	bd->masterwid	= masterwid;
 	bd->is_xbridge	= type == XTALK_XBRIDGE;
+	bd->is_pic	= type == XTALK_PIC_BUS0 || type == XTALK_PIC_BUS1;
 
+	/* Split a PIC's window at bus 1 or its resource request fails. */
 	bd->mem.name	= "Bridge PCI MEM";
-	bd->mem.start	= offset + (widget << SWIN_SIZE_BITS) + BRIDGE_DEVIO0;
-	bd->mem.end	= offset + (widget << SWIN_SIZE_BITS) + SWIN_SIZE - 1;
+	bd->mem.start	= offset + (widget << SWIN_SIZE_BITS) +
+			  (type == XTALK_PIC_BUS1 ? PIC_BUS1_OFFSET : 0) +
+			  BRIDGE_DEVIO0;
+	bd->mem.end	= offset + (widget << SWIN_SIZE_BITS) +
+			  (type == XTALK_PIC_BUS0 ? PIC_BUS1_OFFSET :
+						    SWIN_SIZE) - 1;
 	bd->mem.flags	= IORESOURCE_MEM;
 	bd->mem_offset	= offset;
 
 	bd->io.name	= "Bridge PCI IO";
-	bd->io.start	= offset + (widget << SWIN_SIZE_BITS) + BRIDGE_DEVIO0;
-	bd->io.end	= offset + (widget << SWIN_SIZE_BITS) + SWIN_SIZE - 1;
+	bd->io.start	= offset + (widget << SWIN_SIZE_BITS) +
+			  (type == XTALK_PIC_BUS1 ? PIC_BUS1_OFFSET : 0) +
+			  BRIDGE_DEVIO0;
+	bd->io.end	= offset + (widget << SWIN_SIZE_BITS) +
+			  (type == XTALK_PIC_BUS0 ? PIC_BUS1_OFFSET :
+						    SWIN_SIZE) - 1;
 	bd->io.flags	= IORESOURCE_IO;
 	bd->io_offset	= offset;
 
@@ -149,6 +162,13 @@ static int probe_one_port(nasid_t nasid, int widget, int masterwid)
 	case XBRIDGE_WIDGET_PART_NUM:
 		bridge_platform_create(nasid, widget, masterwid, XTALK_XBRIDGE);
 		break;
+	case PIC_WIDGET_PART_NUM:
+		/* PIC always has both buses in silicon: probe each. */
+		bridge_platform_create(nasid, widget, masterwid,
+				       XTALK_PIC_BUS0);
+		bridge_platform_create(nasid, widget, masterwid,
+				       XTALK_PIC_BUS1);
+		break;
 	default:
 		pr_info("xtalk:n%d/%d unknown widget (0x%x)\n",
 			nasid, widget, partnum);
Signature · 1 line
2.47.3
author
#31 lore raw

PATCH v2 29/53 MIPS: PCI: xtalk-bridge: match PIC's register-level differences

In reply to Imre Kaloz

PIC's config space puts the ASIC at device 0 and the slots at 1-4, its write-request RAM needs clearing, and b_int_addr[] takes a full XIO address. Handle each, and clear PIC's NO_SNOOP and RELAX_ORDER bits.

---
 arch/mips/include/asm/pci/bridge.h | 11 ++++++
 arch/mips/pci/pci-xtalk-bridge.c   | 60 +++++++++++++++++++++++-------
 2 files changed, 58 insertions(+), 13 deletions(-)
arch/mips/include/asm/pci/bridge.h +11 -0
index cbf36bcbe0b7..ec17f4bcc6e8 100644
@@ -372,6 +372,12 @@ struct bridge_err_cmdword {
 
 #define BRIDGE_ATE_RAM		0x00010000	/* Internal Addr Xlat Ram */
 
+/* PIC Write Request RAM: three 256-entry, 64-bit arrays. */
+#define PIC_WR_REQ_BUFSIZE	256
+#define PIC_WR_REQ_LOWER	0x00018000
+#define PIC_WR_REQ_UPPER	0x00018800
+#define PIC_WR_REQ_PARITY	0x00019000
+
 #define BRIDGE_TYPE0_CFG_DEV0	0x00020000	/* Type 0 Cfg, Device 0 */
 #define BRIDGE_TYPE0_CFG_SLOT_OFF	0x00001000	/* Type 0 Cfg Slot Offset (1..7) */
 #define BRIDGE_TYPE0_CFG_FUNC_OFF	0x00000100	/* Type 0 Cfg Func Offset (1..7) */
@@ -389,6 +395,7 @@ struct bridge_err_cmdword {
 /* Byte offset macros for Bridge device IO spaces */
 
 #define BRIDGE_DEV_CNT		8	/* Up to 8 devices per bridge */
+#define PIC_NSLOTS		4	/* PIC: 4 devices per bus */
 #define BRIDGE_DEVIO0		0x00200000	/* Device IO 0 Addr */
 #define BRIDGE_DEVIO1		0x00400000	/* Device IO 1 Addr */
 #define BRIDGE_DEVIO2		0x00600000	/* Device IO 2 Addr */
@@ -461,6 +468,10 @@ struct bridge_err_cmdword {
 #define BRIDGE_CTRL_WIDGET_ID(n)	((n) << 0)
 #define BRIDGE_CTRL_WIDGET_ID_MASK	(BRIDGE_CTRL_WIDGET_ID(0xf))
 
+/* PIC-only widget control bits, upper 32 bits of the register. */
+#define PIC_CTRL_NO_SNOOP		(0x1ull << 62)
+#define PIC_CTRL_RELAX_ORDER		(0x1ull << 61)
+
 /* Bridge Response buffer Error Upper Register bit fields definition */
 #define BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT (20)
 #define BRIDGE_RESP_ERRUPPR_DEVNUM_MASK (0x7 << BRIDGE_RESP_ERRUPPR_DEVNUM_SHFT)
arch/mips/pci/pci-xtalk-bridge.c +47 -13

133 lines not on this page · raw message

Signature · 1 line
2.47.3
author
#32 lore raw

PATCH v2 30/53 rtc: m48t35: support the SGI IP35 timekeeper's 1968 year base

In reply to Imre Kaloz

The M48T35 of SGI IP35-family machines counts its year from 1968. Take the epoch from a platform id table, "rtc-m48t35" for IP27 and "rtc-m48t35-ip35" for IP35, and bound the year to the part's century: on IP27 a year past 2069 now fails to set.

---
 drivers/rtc/rtc-m48t35.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)
drivers/rtc/rtc-m48t35.c +19 -14
index 92f19bf997b2..fa228a2bb527 100644
@@ -49,6 +49,7 @@ struct m48t35_priv {
 	struct m48t35_rtc __iomem *reg;
 	size_t size;
 	unsigned long baseaddr;
+	unsigned int epoch;
 	spinlock_t lock;
 };
 
@@ -86,10 +87,7 @@ static int m48t35_read_time(struct device *dev, struct rtc_time *tm)
 	 * Account for differences between how the RTC uses the values
 	 * and how they are defined in a struct rtc_time;
 	 */
-	tm->tm_year += 70;
-	if (tm->tm_year <= 69)
-		tm->tm_year += 100;
-
+	tm->tm_year += priv->epoch - 1900;
 	tm->tm_mon--;
 	return 0;
 }
@@ -108,18 +106,10 @@ static int m48t35_set_time(struct device *dev, struct rtc_time *tm)
 	min = tm->tm_min;
 	sec = tm->tm_sec;
 
-	if (yrs < 1970)
-		return -EINVAL;
-
-	yrs -= 1970;
-	if (yrs > 255)    /* They are unsigned */
-		return -EINVAL;
-
-	if (yrs > 169)
+	if (yrs < priv->epoch || yrs >= priv->epoch + 100)
 		return -EINVAL;
 
-	if (yrs >= 100)
-		yrs -= 100;
+	yrs -= priv->epoch;
 
 	sec = bin2bcd(sec);
 	min = bin2bcd(min);
@@ -149,9 +139,13 @@ static const struct rtc_class_ops m48t35_ops = {
 
 static int m48t35_probe(struct platform_device *pdev)
 {
+	const struct platform_device_id *id = platform_get_device_id(pdev);
 	struct resource *res;
 	struct m48t35_priv *priv;
 
+	if (!id)
+		return -ENODEV;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
 		return -ENODEV;
@@ -164,6 +158,7 @@ static int m48t35_probe(struct platform_device *pdev)
 				     pdev->name))
 		return -EBUSY;
 
+	priv->epoch = id->driver_data;
 	priv->baseaddr = res->start;
 	priv->reg = devm_ioremap(&pdev->dev, priv->baseaddr, priv->size);
 	if (!priv->reg)
@@ -178,11 +173,20 @@ static int m48t35_probe(struct platform_device *pdev)
 	return PTR_ERR_OR_ZERO(priv->rtc);
 }
 
+/* The year register on SGI IP35-family machines counts from 1968. */
+static const struct platform_device_id m48t35_id_table[] = {
+	{ "rtc-m48t35", 1970 },
+	{ "rtc-m48t35-ip35", 1968 },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, m48t35_id_table);
+
 static struct platform_driver m48t35_platform_driver = {
 	.driver		= {
 		.name	= "rtc-m48t35",
 	},
 	.probe		= m48t35_probe,
+	.id_table	= m48t35_id_table,
 };
 
 module_platform_driver(m48t35_platform_driver);
@@ -191,3 +195,4 @@ MODULE_AUTHOR("Thomas Bogendoerfer <[email protected]>");
 MODULE_DESCRIPTION("M48T35 RTC driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:rtc-m48t35");
+MODULE_ALIAS("platform:rtc-m48t35-ip35");
Signature · 1 line
2.47.3
#33 lore raw

Re: [PATCH v2 30/53] rtc: m48t35: support the SGI IP35 timekeeper's 1968 year base

Hello,

Quoted 43 lines · Imre Kaloz

The M48T35 of SGI IP35-family machines counts its year from 1968. Take the epoch from a platform id table, "rtc-m48t35" for IP27 and "rtc-m48t35-ip35" for IP35, and bound the year to the part's century: on IP27 a year past 2069 now fails to set.

---
 drivers/rtc/rtc-m48t35.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)
drivers/rtc/rtc-m48t35.c +2 -9
index 92f19bf997b2..fa228a2bb527 100644
@@ -49,6 +49,7 @@ struct m48t35_priv {
 	struct m48t35_rtc __iomem *reg;
 	size_t size;
 	unsigned long baseaddr;
+	unsigned int epoch;
 	spinlock_t lock;
 };
 
@@ -86,10 +87,7 @@ static int m48t35_read_time(struct device *dev, struct rtc_time *tm)
 	 * Account for differences between how the RTC uses the values
 	 * and how they are defined in a struct rtc_time;
 	 */
-	tm->tm_year += 70;
-	if (tm->tm_year <= 69)
-		tm->tm_year += 100;
-
+	tm->tm_year += priv->epoch - 1900;
 	tm->tm_mon--;
 	return 0;
 }
@@ -108,18 +106,10 @@ static int m48t35_set_time(struct device *dev, struct rtc_time *tm)
 	min = tm->tm_min;
 	sec = tm->tm_sec;
 
-	if (yrs < 1970)
-		return -EINVAL;
-
-	yrs -= 1970;
-	if (yrs > 255)    /* They are unsigned */

drivers/rtc/rtc-m48t35.c static int m48t35_set_time(struct device *dev, struct rtc_time *tm) · line 113

Quoted 10 lines
drivers/rtc/rtc-m48t35.c +2 -5
-		return -EINVAL;
-
-	if (yrs > 169)
+	if (yrs < priv->epoch || yrs >= priv->epoch + 100)
 		return -EINVAL;
 
-	if (yrs >= 100)
-		yrs -= 100;
+	yrs -= priv->epoch;
 

Instead of open coding, you should use start_secs after setting the rtc range in probe(). attached i a patch I refreshed for the devm_rtc_allocate_device/devm_rtc_register_device conversion that you can include in this series. drivers/rtc/rtc-mt6397.c is an example that should be working for you.

I never sent the patch because it is not clear from the datasheet how well leap year calculation works. My guess is that it worked in 2000 but fails in 2100.

Quoted 53 lines
drivers/rtc/rtc-m48t35.c +15 -0
 	sec = bin2bcd(sec);
 	min = bin2bcd(min);
@@ -149,9 +139,13 @@ static const struct rtc_class_ops m48t35_ops = {
 
 static int m48t35_probe(struct platform_device *pdev)
 {
+	const struct platform_device_id *id = platform_get_device_id(pdev);
 	struct resource *res;
 	struct m48t35_priv *priv;
 
+	if (!id)
+		return -ENODEV;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
 		return -ENODEV;
@@ -164,6 +158,7 @@ static int m48t35_probe(struct platform_device *pdev)
 				     pdev->name))
 		return -EBUSY;
 
+	priv->epoch = id->driver_data;
 	priv->baseaddr = res->start;
 	priv->reg = devm_ioremap(&pdev->dev, priv->baseaddr, priv->size);
 	if (!priv->reg)
@@ -178,11 +173,20 @@ static int m48t35_probe(struct platform_device *pdev)
 	return PTR_ERR_OR_ZERO(priv->rtc);
 }
 
+/* The year register on SGI IP35-family machines counts from 1968. */
+static const struct platform_device_id m48t35_id_table[] = {
+	{ "rtc-m48t35", 1970 },
+	{ "rtc-m48t35-ip35", 1968 },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, m48t35_id_table);
+
 static struct platform_driver m48t35_platform_driver = {
 	.driver		= {
 		.name	= "rtc-m48t35",
 	},
 	.probe		= m48t35_probe,
+	.id_table	= m48t35_id_table,
 };
 
 module_platform_driver(m48t35_platform_driver);
@@ -191,3 +195,4 @@ MODULE_AUTHOR("Thomas Bogendoerfer <[email protected]>");
 MODULE_DESCRIPTION("M48T35 RTC driver");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("platform:rtc-m48t35");
+MODULE_ALIAS("platform:rtc-m48t35-ip35");
Signature · 1 line
2.47.3
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

From 7aed40aa17edfdd132ad10f6fb1ca9f1f1ddac07 Mon Sep 17 00:00:00 2001
From: Alexandre Belloni <[email protected]>
Date: Tue, 13 Oct 2026 16:21:06 +0200
Subject: [PATCH] rtc: m48t35: switch to devm_rtc_allocate_device

Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows for further improvement of the driver.

---
 drivers/rtc/rtc-m48t35.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/rtc/rtc-m48t35.c +7 -3
index 92f19bf997b2..0f4a3cb1e1f0 100644
@@ -173,9 +173,13 @@ static int m48t35_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	priv->rtc = devm_rtc_device_register(&pdev->dev, "m48t35",
-				  &m48t35_ops, THIS_MODULE);
-	return PTR_ERR_OR_ZERO(priv->rtc);
+	priv->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(priv->rtc))
+		return PTR_ERR(priv->rtc);
+
+	priv->rtc->ops = &m48t35_ops;
+
+	return devm_rtc_register_device(priv->rtc);
 }
 
 static struct platform_driver m48t35_platform_driver = {
Signature · 1 line
2.56.0
author
#34 lore raw

Re: [PATCH v2 30/53] rtc: m48t35: support the SGI IP35 timekeeper's 1968 year base

Hello Alexandre,

On Tue, 13 Oct 2026, Alexandre Belloni wrote:

<snip>

Quoted 9 lines

Instead of open coding, you should use start_secs after setting the rtc range in probe(). attached i a patch I refreshed for the devm_rtc_allocate_device/devm_rtc_register_device conversion that you can include in this series. drivers/rtc/rtc-mt6397.c is an example that should be working for you.

I never sent the patch because it is not clear from the datasheet how well leap year calculation works. My guess is that it worked in 2000 but fails in 2100.

Thanks, that is cleaner. In the next posting I'll take your devm conversion first and set range_min/range_max and start_secs in probe instead of open-coding the epoch.

Thanks,
Imre

author
#35 lore raw

PATCH v2 31/53 mfd: ioc3: Add support for IOC4

In reply to Imre Kaloz

IOC4 is IOC3's successor on IP35 Origin 350-class boards. Its serial and PS/2 cores reuse IOC3's drivers and its interrupt status splits into two banks. The serial ports need IOC4 firmware revision 62 or later and are not registered on older firmware.

The serial, interrupt and GPIO register definitions in asm/sn/ioc4.h follow include/linux/ioc4.h and drivers/tty/serial/ioc4_serial.c, removed by commit f7bc6e42bf12 ("drivers: remove the SGI SN2 IOC4 base support") and commit a017ef17cfd8 ("tty/serial: remove the ioc4_serial driver").

---
 MAINTAINERS                                   |   1 +
 arch/mips/include/asm/sn/ioc4.h               | 142 ++++++++
 drivers/mfd/ioc3.c                            | 323 +++++++++++++++---
 drivers/tty/serial/8250/8250_ioc3.c           |   5 +-
 include/linux/platform_data/sgi-ioc3-serial.h |  13 +
 5 files changed, 438 insertions(+), 46 deletions(-)
 create mode 100644 arch/mips/include/asm/sn/ioc4.h
 create mode 100644 include/linux/platform_data/sgi-ioc3-serial.h
MAINTAINERS +1 -0
index f53047aa8d3c..a30c09a55c72 100644
@@ -18219,6 +18219,7 @@ F:	arch/mips/
 F:	drivers/platform/mips/
 F:	include/dt-bindings/mips/
 F:	include/linux/platform_data/pic32.h
+F:	include/linux/platform_data/sgi-ioc3-serial.h
 
 MIPS BOSTON DEVELOPMENT BOARD
 M:	Paul Burton <[email protected]>
arch/mips/include/asm/sn/ioc4.h new file +142 -0

142 lines not on this page · raw message

drivers/mfd/ioc3.c +278 -45

487 lines not on this page · raw message

drivers/tty/serial/8250/8250_ioc3.c +4 -1
index 28e28076782b..5d3c0190f19e 100644
@@ -11,6 +11,7 @@
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/io.h>
+#include <linux/platform_data/sgi-ioc3-serial.h>
 #include <linux/platform_device.h>
 
 #include "8250.h"
@@ -33,6 +34,7 @@ static void ioc3_serial_out(struct uart_port *p, unsigned int offset, u32 value)
 
 static int serial8250_ioc3_probe(struct platform_device *pdev)
 {
+	const struct ioc3_serial8250_platform_data *pdata;
 	struct ioc3_8250_data *data;
 	struct uart_8250_port up;
 	struct resource *r;
@@ -56,9 +58,10 @@ static int serial8250_ioc3_probe(struct platform_device *pdev)
 		irq = 0; /* no interrupt -> use polling */
 
 	/* Register serial ports with 8250.c */
+	pdata = dev_get_platdata(&pdev->dev);
 	memset(&up, 0, sizeof(struct uart_8250_port));
 	up.port.iotype = UPIO_MEM;
-	up.port.uartclk = IOC3_UARTCLK;
+	up.port.uartclk = pdata ? pdata->uartclk : IOC3_UARTCLK;
 	up.port.type = PORT_16550A;
 	up.port.irq = irq;
 	up.port.flags = (UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ);
include/linux/platform_data/sgi-ioc3-serial.h new file +13 -0
new file mode 100644
index 000000000000..ae4690f33125
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * SGI IOC3/IOC4 8250-compatible UART cells
+ */
+
+#ifndef PLATFORM_DATA_SGI_IOC3_SERIAL_H
+#define PLATFORM_DATA_SGI_IOC3_SERIAL_H
+
+struct ioc3_serial8250_platform_data {
+	unsigned int uartclk;
+};
+
+#endif /* PLATFORM_DATA_SGI_IOC3_SERIAL_H */
Signature · 1 line
2.47.3
maintainer
#36 lore raw

Re: [PATCH v2 31/53] mfd: ioc3: Add support for IOC4

--- checkpatch.pl: clean (0 issues) ---

Quoted 10 lines · Imre Kaloz

IOC4 is IOC3's successor on IP35 Origin 350-class boards. Its serial and PS/2 cores reuse IOC3's drivers and its interrupt status splits into two banks. The serial ports need IOC4 firmware revision 62 or later and are not registered on older firmware.

The serial, interrupt and GPIO register definitions in asm/sn/ioc4.h follow include/linux/ioc4.h and drivers/tty/serial/ioc4_serial.c, removed by commit f7bc6e42bf12 ("drivers: remove the SGI SN2 IOC4 base support") and commit a017ef17cfd8 ("tty/serial: remove the ioc4_serial driver").

Quoted 8 lines
---
 MAINTAINERS                                   |   1 +
 arch/mips/include/asm/sn/ioc4.h               | 142 ++++++++
 drivers/mfd/ioc3.c                            | 323 +++++++++++++++---
 drivers/tty/serial/8250/8250_ioc3.c           |   5 +-
 include/linux/platform_data/sgi-ioc3-serial.h |  13 +
 5 files changed, 438 insertions(+), 46 deletions(-)

Do we really need to bundle all of these changes into this commit?

This is going to be a nightmare to review!

Quoted 2 lines
 create mode 100644 arch/mips/include/asm/sn/ioc4.h
 create mode 100644 include/linux/platform_data/sgi-ioc3-serial.h
Signature · 1 line
Lee Jones
author
#37 lore raw

Re: [PATCH v2 31/53] mfd: ioc3: Add support for IOC4

Quoted 5 lines · Lee Jones
Quoted 1 line
 5 files changed, 438 insertions(+), 46 deletions(-)

Do we really need to bundle all of these changes into this commit?

This is going to be a nightmare to review!

Fair point, and sorry about that. It grew in one piece while I was bringing the hardware up, and I should have cut it up before posting.

For v3 I'll split it into five patches:

1. mfd: ioc3: Add per-variant interrupt banks
The irq_chip, domain map and chained handler move to a bank table, and ioc3_priv_data gets a variant pointer and a generic __iomem base. Only the IOC3 variant exists at this point.

2. MIPS: SGI-IP27: Add IOC4 register definitions
arch/mips/include/asm/sn/ioc4.h on its own.

3. serial: 8250_ioc3: Take the UART clock from platform data include/linux/platform_data/sgi-ioc3-serial.h and the one-line change in 8250_ioc3.c, with the MAINTAINERS entry for the header.

4. mfd: ioc3: Add support for IOC4
The IOC4 variant, its two interrupt banks, ioc4_setup() and the non-serial cells (kbd, RTC and, from patch 46, ATA).

5. mfd: ioc3: Add IOC4 serial cells ioc4_serial_setup(), the firmware revision check and the four UART cells.

Each one builds on its own, and 1 and 3 leave IOC3 boards behaving exactly as before, so they should be easy to check in isolation.

The overall shape of v3 still depends on what Thomas prefers for the series, so it will follow once he has had a chance to look.

Thanks for taking the time to go through it,

Imre

author
#38 lore raw

PATCH v2 32/53 MIPS: SGI-IP27: dispatch the early console between IOC3 and IOC4

In reply to Imre Kaloz

ip27-console.c casts the console UART to struct ioc3 unconditionally, wrong for a Tezro's IOC4, whose UARTs sit at other offsets.

console_t.type reads back 0x0300fafa there, neither chip's PCI id, so on IP35 dispatch on uart_base, which both chips populate correctly. A Hub keeps the IOC3 path.

---
 arch/mips/sgi-ip27/ip27-console.c | 47 ++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
arch/mips/sgi-ip27/ip27-console.c +46 -1
index 7737a88c6569..a1bcb4376f66 100644
@@ -12,6 +12,7 @@
 #include <asm/sn/agent.h>
 #include <asm/sn/klconfig.h>
 #include <asm/sn/ioc3.h>
+#include <asm/sn/ioc4.h>
 
 #include <linux/serial.h>
 #include <linux/serial_core.h>
@@ -32,9 +33,53 @@ static inline struct ioc3_uartregs *console_uart(void)
 	return &ioc3->sregs.uarta;
 }
 
+/*
+ * On IP35 a Tezro drives its console off IOC4, a Fuel off IOC3.
+ * console_t.type cannot tell them apart -- a Tezro reads it back as
+ * 0x0300fafa, which is neither chip's PCI id -- while uart_base is
+ * populated on both, so dispatch on whether that lands on IOC3's own UART.
+ */
+static inline bool console_is_ioc4(nasid_t nasid)
+{
+	unsigned long uart_base;
+
+	if (!system_is_ip35)
+		return false;
+
+	uart_base = KL_CONFIG_CH_CONS_INFO(nasid)->uart_base;
+	if (!uart_base)
+		return false;
+
+	/* NODE_SWIN_ADDR() aliases widget 0 away; the console sits on 0xf. */
+	if (uart_base < RAW_NODE_SWIN_BASE(nasid, 0) ||
+	    uart_base >= RAW_NODE_SWIN_BASE(nasid, SWIN_WIDGET_MASK) +
+			 SWIN_SIZE)
+		return false;
+
+	return uart_base != (unsigned long)console_uart();
+}
+
+static inline struct ioc4_uartregs *console_uart_ioc4(nasid_t nasid)
+{
+	return (struct ioc4_uartregs *)KL_CONFIG_CH_CONS_INFO(nasid)->uart_base;
+}
+
 void prom_putchar(char c)
 {
-	struct ioc3_uartregs *uart = console_uart();
+	struct ioc3_uartregs *uart;
+	nasid_t nasid;
+
+	nasid = (master_nasid == INVALID_NASID) ? get_nasid() : master_nasid;
+	if (console_is_ioc4(nasid)) {
+		struct ioc4_uartregs *ioc4_uart = console_uart_ioc4(nasid);
+
+		while ((readb(&ioc4_uart->i4u_lsr) & 0x20) == 0)
+			;
+		writeb(c, &ioc4_uart->i4u_thr);
+		return;
+	}
+
+	uart = console_uart();
 
 	while ((readb(&uart->iu_lsr) & 0x20) == 0)
 		;
Signature · 1 line
2.47.3
author
#39 lore raw

PATCH v2 33/53 MIPS: SGI-IP27: add L1 system controller support

In reply to Imre Kaloz

IP35-family (Bedrock hub) machines carry an L1 system controller on a polled UART with RFC 1662 async-HDLC framing. Add the transport, the request/response core and l1_exec_command(); on a Hub every request fails with -ENODEV.

Ported from OpenBSD sys/arch/sgi/sgi/l1.c and licensed ISC like it, keeping its notice.

---
 arch/mips/Kconfig             |   1 +
 arch/mips/include/asm/sn/l1.h |  14 ++
 arch/mips/sgi-ip27/Makefile   |   4 +-
 arch/mips/sgi-ip27/ip27-l1.c  | 423 ++++++++++++++++++++++++++++++++++
 4 files changed, 440 insertions(+), 2 deletions(-)
 create mode 100644 arch/mips/include/asm/sn/l1.h
 create mode 100644 arch/mips/sgi-ip27/ip27-l1.c
arch/mips/Kconfig +1 -0
index 85f1c4bd6549..b7026672a4c1 100644
@@ -762,6 +762,7 @@ config SGI_IP27
 	select FW_ARC64
 	select ARC_CMDLINE_ONLY
 	select BOOT_ELF64
+	select CRC_CCITT
 	select DEFAULT_SGI_PARTITION
 	select FORCE_PCI
 	select SYS_HAS_EARLY_PRINTK
arch/mips/include/asm/sn/l1.h new file +14 -0
new file mode 100644
index 000000000000..e61935e2fac8
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Entry points into the SGI L1 system controller driver.
+ *
+ * Copyright (C) 2026 Imre Kaloz <[email protected]>
+ */
+#ifndef __ASM_SN_L1_H
+#define __ASM_SN_L1_H
+
+#include <linux/types.h>
+
+int l1_exec_command(const char *cmd);
+
+#endif /* __ASM_SN_L1_H */
arch/mips/sgi-ip27/Makefile +2 -2
index 9877fcc512b1..4b6aa641ccc6 100644
@@ -4,8 +4,8 @@
 #
 
 obj-y	:= ip27-berr.o ip27-irq.o ip27-init.o ip27-klconfig.o \
-	   ip27-klnuma.o ip27-memory.o ip27-nmi.o ip27-reset.o ip27-timer.o \
-	   ip27-xtalk.o
+	   ip27-klnuma.o ip27-l1.o ip27-memory.o ip27-nmi.o ip27-reset.o \
+	   ip27-timer.o ip27-xtalk.o
 
 obj-$(CONFIG_EARLY_PRINTK)	+= ip27-console.o
 obj-$(CONFIG_SMP)		+= ip27-smp.o
arch/mips/sgi-ip27/ip27-l1.c new file +423 -0

423 lines not on this page · raw message

Signature · 1 line
2.47.3
author
#40 lore raw

PATCH v2 34/53 MIPS: SGI-IP27: wire the L1 into reset and the Ethernet address

In reply to Imre Kaloz

On Bedrock hubs restart, halt and poweroff go through the L1 system controller, and ioc3-eth takes its MAC address from the L1's board information area.

---
 arch/mips/sgi-ip27/ip27-l1.c    | 266 ++++++++++++++++++++++++++++++++
 arch/mips/sgi-ip27/ip27-reset.c |  47 +++++-
 2 files changed, 305 insertions(+), 8 deletions(-)
arch/mips/sgi-ip27/ip27-l1.c +266 -0
index da3095b66cf1..25f9be350c0b 100644
@@ -25,6 +25,8 @@
  */
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/etherdevice.h>
+#include <linux/hex.h>
 #include <linux/serial_reg.h>
 #include <linux/spinlock.h>
 #include <linux/stdarg.h>
@@ -66,6 +68,7 @@
 	 (L1_ADDRESS_BAY_LOCAL << L1_ADDRESS_BAY_SHIFT))
 
 #define L1_TASK_COMMAND		0x03
+#define L1_TASK_GENERAL		0x06
 
 /* response codes */
 #define L1_RESP_OK		((u32)0)
@@ -75,6 +78,27 @@
 /* L1_TASK_COMMAND requests */
 #define L1_REQ_EXEC_CMD		0x0000	/* interpret plaintext command */
 
+/* L1_TASK_GENERAL requests */
+#define L1_REQ_EEPROM		0x0006	/* access eeprom */
+
+/* L1_REQ_EEPROM additional argument values (non C-brick component) */
+#define L1_EEP_LOGIC		0x01	/* logic board */
+/* ia code */
+#define L1_EEP_BOARD		0x02	/* board ia */
+
+#define EEPROM_CHUNK		0x40
+
+/*
+ * Information Area type/length byte: bits 7-6 are the type (0 binary,
+ * 1 BCD, 2 packed 6-bit ascii, 3 8-bit ascii), bits 5-0 the length.
+ */
+#define IA_TYPE_SHIFT		6
+#define IA_TYPE_BINARY		0
+#define IA_TYPE_ASCII		3
+#define IA_LENGTH_MASK		0x3f
+#define IA_TL(t, l)		(((t) << IA_TYPE_SHIFT) | (l))
+#define IA_EOF			IA_TL(IA_TYPE_ASCII, 1)
+
 /* Async-HDLC framing bytes; linux/ppp_defs.h would drag in skbuff.h. */
 #define L1_FLAG			0x7e
 #define L1_ESC			0x7d
@@ -96,6 +120,10 @@
 #define L1_UART_ADDRESS(nasid, r) \
 	((u64 *)(NODE_HSPEC_BASE(nasid) + L1_RHSPEC_OFFSET + L1_UART_REG(r)))
 
+/* Board IA record buffer; the probed length is checked against it. */
+#define L1_IA_BUF_SIZE		512
+static u8 l1_ia_buf[L1_IA_BUF_SIZE];
+
 static int l1_serial_getc(nasid_t nasid)
 {
 	unsigned int n;
@@ -221,6 +249,48 @@ static int l1_packet_get(nasid_t nasid, u8 *buf, size_t buflen, size_t *rlen)
 	return 0;
 }
 
+static int l1_packet_get_int(u8 **buf, size_t *buflen, u32 *rval)
+{
+	u8 *b = *buf;
+
+	if (*buflen < 5)
+		return -EIO;
+	if (*b++ != L1_ARG_INT)
+		return -EINVAL;
+
+	*rval = get_unaligned_be32(b);
+	b += 4;
+	*buf = b;
+	*buflen -= 5;
+
+	return 0;
+}
+
+static int l1_packet_get_binary(u8 **buf, size_t *buflen, u8 **rval,
+				size_t *rlen)
+{
+	u8 *b = *buf;
+	size_t datalen;
+
+	if (*buflen < 1)
+		return -EIO;
+	if ((*b & L1_ARG_BINARY) == 0)
+		return -EINVAL;
+
+	datalen = *b & ~L1_ARG_BINARY;
+	if (*buflen < 1 + datalen)
+		return -ENOMEM;
+
+	b++;
+	*rval = b;
+	*rlen = datalen;
+	*buflen -= 1 + datalen;
+	b += datalen;
+	*buf = b;
+
+	return 0;
+}
+
 /*
  * Returns the would-be length even when the buffer is too small, and
  * SIZE_MAX for an unknown argument type.
@@ -421,3 +491,199 @@ int l1_exec_command(const char *cmd)
 	/* nothing is expected back besides the response code */
 	return rc == 0 ? 0 : -EIO;
 }
+
+/* Read a component's board IA record from EEPROM. */
+static int l1_read_board_ia(nasid_t nasid, int type, unsigned int component,
+			    u8 **ria, size_t *rialen)
+{
+	u32 address = L1_ADDRESS(type, L1_ADDRESS_LOCAL | L1_TASK_GENERAL);
+	u8 pkt[64 + EEPROM_CHUNK];
+	u8 *args, *chunk;
+	size_t arglen, chunklen, ialen, iapos;
+	u32 data;
+	int rc;
+
+	rc = l1_transact(nasid, pkt, sizeof(pkt), address, L1_REQ_EEPROM,
+			 &args, &arglen, 4,
+			 L1_ARG_INT, (u32)component,
+			 L1_ARG_INT, (u32)L1_EEP_BOARD,
+			 L1_ARG_INT, (u32)0,	/* offset */
+			 L1_ARG_INT, (u32)0);	/* size (0 = probe) */
+	if (rc < 0)
+		return rc;
+	if (rc != 1)
+		return -EIO;
+
+	rc = l1_packet_get_int(&args, &arglen, &data);
+	if (rc)
+		return -EIO;
+
+	ialen = (size_t)data;
+	if (ialen == 0 || ialen > L1_IA_BUF_SIZE)
+		return -ENOMEM;
+
+	iapos = 0;
+	while (iapos < ialen) {
+		rc = l1_transact(nasid, pkt, sizeof(pkt), address,
+				 L1_REQ_EEPROM, &args, &arglen, 4,
+				 L1_ARG_INT, (u32)component,
+				 L1_ARG_INT, (u32)L1_EEP_BOARD,
+				 L1_ARG_INT, (u32)iapos,
+				 L1_ARG_INT, (u32)EEPROM_CHUNK);
+		if (rc < 0)
+			return rc;
+		if (rc != 2)
+			return -EIO;
+
+		rc = l1_packet_get_int(&args, &arglen, &data);
+		if (rc)
+			return -EIO;
+
+		rc = l1_packet_get_binary(&args, &arglen, &chunk, &chunklen);
+		if (rc)
+			return -EIO;
+
+		/* should not happen; the bound keeps the loop finite */
+		if (chunklen == 0)
+			return -EIO;
+
+		if (chunklen > ialen - iapos)
+			chunklen = ialen - iapos;
+
+		memcpy(l1_ia_buf + iapos, chunk, chunklen);
+		iapos += chunklen;
+	}
+
+	/* the sum of all IA bytes has to be 0 mod 256 */
+	data = 0;
+	for (iapos = 0; iapos < ialen; iapos++)
+		data += l1_ia_buf[iapos];
+	if ((data & 0xff) != 0)
+		return -EINVAL;
+
+	*ria = l1_ia_buf;
+	*rialen = ialen;
+	return 0;
+}
+
+/* IA record walk helper: advance past one record, without passing EOF. */
+static size_t ia_skip(const u8 *ia, size_t iapos, size_t ialen)
+{
+	size_t npos;
+
+	if (ia[iapos] == IA_EOF)
+		return iapos;
+
+	npos = iapos + 1 + (ia[iapos] & IA_LENGTH_MASK);
+	return npos >= ialen ? iapos : npos;
+}
+
+static int l1_get_brick_ethernet_address(nasid_t nasid, u8 *enaddr)
+{
+	u8 *ia;
+	u8 group;
+	size_t iapos, ialen;
+	int i, rc;
+
+	/* assumes the local brick's L1 answers for this node */
+	rc = l1_read_board_ia(nasid, L1_TYPE_L1, L1_EEP_LOGIC, &ia, &ialen);
+	if (rc)
+		return rc;
+
+	/*
+	 * ia[0] is the board-IA format version. Below 2 the encryption-key
+	 * (G/P/Y) and Ethernet-address groups follow the fixed records
+	 * implicitly; from 2 on an extra selector record comes first: 0
+	 * keys only, 1 keys then address, 2 neither, 3 a config group.
+	 * Otherwise the walk follows l1_get_brick_ethernet_address() in
+	 * OpenBSD/sgi's l1.c.
+	 */
+	if (ia[1] < 2 || ia[1] * 8UL > ialen)
+		return -EINVAL;
+
+	/* skip the fixed part, then mfg, product, serial, part */
+	iapos = 6;
+	iapos = ia_skip(ia, iapos, ialen);
+	iapos = ia_skip(ia, iapos, ialen);
+	iapos = ia_skip(ia, iapos, ialen);
+	iapos = ia_skip(ia, iapos, ialen);
+	/* skip FRU (1 raw byte) */
+	if (iapos < ialen - 1)
+		iapos++;
+	/* skip board rev, eeprom size, temp waiver */
+	iapos = ia_skip(ia, iapos, ialen);
+	iapos = ia_skip(ia, iapos, ialen);
+	iapos = ia_skip(ia, iapos, ialen);
+
+	if (ia[0] >= 2) {
+		if (iapos + 1 >= ialen)
+			return -ENXIO;
+		group = ia[iapos + 1];
+		iapos = ia_skip(ia, iapos, ialen);
+		if (group != 1)
+			return -ENXIO;	/* no ethernet-address group here */
+		/* the three encryption-key records precede the address */
+		iapos = ia_skip(ia, iapos, ialen);
+		iapos = ia_skip(ia, iapos, ialen);
+		iapos = ia_skip(ia, iapos, ialen);
+	} else {
+		if (iapos < ialen && ia[iapos] == IA_TL(IA_TYPE_BINARY, 4)) {
+			iapos = ia_skip(ia, iapos, ialen);
+			iapos = ia_skip(ia, iapos, ialen);
+			iapos = ia_skip(ia, iapos, ialen);
+		}
+	}
+
+	if (iapos >= ialen - 1 - 12 || ia[iapos] != IA_TL(IA_TYPE_ASCII, 12))
+		return -EINVAL;
+
+	iapos++;
+	for (i = 0; i < ETH_ALEN; i++) {
+		int hi = hex_to_bin(ia[iapos + i * 2]);
+		int lo = hex_to_bin(ia[iapos + i * 2 + 1]);
+
+		if (hi < 0 || lo < 0)
+			return -EINVAL;
+		enaddr[i] = (hi << 4) | lo;
+	}
+
+	return is_valid_ether_addr(enaddr) ? 0 : -EINVAL;
+}
+
+static u8 ip27_l1_mac_addr[ETH_ALEN];
+static bool ip27_l1_mac_addr_valid;
+static bool ip27_l1_mac_addr_tried;
+
+/*
+ * A board that sources its MAC elsewhere, such as Tezro's tg3, yields
+ * nothing here, so a failure logs at debug level rather than warning.
+ */
+unsigned char *arch_get_platform_mac_address(void)
+{
+	unsigned long flags;
+	int rc;
+
+	if (!system_is_ip35)
+		return NULL;
+
+	spin_lock_irqsave(&l1_lock, flags);
+
+	if (!ip27_l1_mac_addr_tried) {
+		ip27_l1_mac_addr_tried = true;
+
+		rc = l1_get_brick_ethernet_address(get_nasid(),
+						   ip27_l1_mac_addr);
+		if (rc) {
+			pr_debug("l1: EEPROM MAC address read failed (%d)\n",
+				 rc);
+		} else {
+			ip27_l1_mac_addr_valid = true;
+			pr_info("l1: EEPROM Ethernet address %pM\n",
+				ip27_l1_mac_addr);
+		}
+	}
+
+	spin_unlock_irqrestore(&l1_lock, flags);
+
+	return ip27_l1_mac_addr_valid ? ip27_l1_mac_addr : NULL;
+}
arch/mips/sgi-ip27/ip27-reset.c +39 -8

90 lines not on this page · raw message

Signature · 1 line
2.47.3
author
#41 lore raw

PATCH v2 35/53 MIPS: PCI: xtalk-bridge: take the board part number from the L1

In reply to Imre Kaloz

An XBridge answers nothing on the b_nic 1-wire pin, so bridge_get_partnum() finds no PROM and the probe defers forever. Stop waiting on XBridge and PIC widgets; on Bedrock hubs read the assembly number from the L1 instead.

---
 arch/mips/include/asm/sn/l1.h    |  7 +++
 arch/mips/pci/pci-xtalk-bridge.c | 37 +++++++++++++-
 arch/mips/sgi-ip27/ip27-l1.c     | 83 ++++++++++++++++++++++++++++++++
 3 files changed, 125 insertions(+), 2 deletions(-)
arch/mips/include/asm/sn/l1.h +7 -0
index e61935e2fac8..1a3b7fa0e213 100644
@@ -9,6 +9,13 @@
 
 #include <linux/types.h>
 
+/*
+ * Which L1 EEPROM component id carries which board is undocumented and
+ * differs from machine to machine, so a caller walks the whole range.
+ */
+#define L1_BOARD_COMPONENT_MAX	8
+
 int l1_exec_command(const char *cmd);
+int l1_read_board_partnum(unsigned int component, char *buf, size_t len);
 
 #endif /* __ASM_SN_L1_H */
arch/mips/pci/pci-xtalk-bridge.c +35 -2
index b2c3a8b207da..40d69681227c 100644
@@ -18,7 +18,9 @@
 #include <asm/pci/bridge.h>
 #include <asm/paccess.h>
 #include <asm/sn/irq_alloc.h>
+#include <asm/sn/addrs.h>
 #include <asm/sn/ioc3.h>
+#include <asm/sn/l1.h>
 
 #define CRC16_INIT	0
 #define CRC16_VALID	0xb001
@@ -665,6 +667,29 @@ static const struct {
 	BRIDGE_BOARD_SETUP("030-1707-", bridge_setup_ip34_fuel_sysboard),
 };
 
+/*
+ * The L1 answers one board information area per EEPROM component id, and
+ * which id carries which board is undocumented. Ask for each in turn and take
+ * the first answer the table above knows.
+ */
+static int bridge_l1_partnum(char *partnum, size_t len)
+{
+	unsigned int component;
+	int i;
+
+	for (component = 0; component < L1_BOARD_COMPONENT_MAX; component++) {
+		if (l1_read_board_partnum(component, partnum, len))
+			continue;
+
+		for (i = 0; i < ARRAY_SIZE(bridge_ioc3_devid); i++)
+			if (!strncmp(partnum, bridge_ioc3_devid[i].match,
+				     strlen(bridge_ioc3_devid[i].match)))
+				return 0;
+	}
+
+	return -ENODEV;
+}
+
 static void bridge_setup_board(struct bridge_controller *bc, char *partnum)
 {
 	int i;
@@ -984,8 +1009,16 @@ static int bridge_probe(struct platform_device *pdev)
 	int err;
 
 	/* get part number from one wire prom */
-	if (bridge_get_partnum(virt_to_phys((void *)bd->bridge_addr), partnum))
-		return -EPROBE_DEFER; /* not available yet */
+	if (bridge_get_partnum(virt_to_phys((void *)bd->bridge_addr),
+			       partnum)) {
+		/* Only a classic Bridge waits for its 1-wire PROM. */
+		if (!bd->is_xbridge && !bd->is_pic)
+			return -EPROBE_DEFER; /* not available yet */
+
+		if (!IS_ENABLED(CONFIG_SGI_IP27) || !system_is_ip35 ||
+		    bridge_l1_partnum(partnum, sizeof(partnum)))
+			partnum[0] = '\0';
+	}
 
 	parent = irq_get_default_domain();
 	if (!parent)
arch/mips/sgi-ip27/ip27-l1.c +83 -0

89 lines not on this page · raw message

Signature · 1 line
2.47.3
author
#42 lore raw

PATCH v2 36/53 mfd: ioc3: Add IP34 system-board entry to ioc3_infos[]

In reply to Imre Kaloz

Register the Fuel system board's on-board IOC3 and its M48T35, whose year register counts from 1968 as on other IP35-family machines. Bridge-side detection was already merged in commit 2c4288719806 ("MIPS:
PCI: Add detection of IOC3 on IO7, IO8, IO9 and Fuel"), which matches the board part number "030-1707-"; the cell table had no entry to go with it. Without one the IOC3 falls to the CAD DUO default, which instantiates no serial cell, so Fuel comes up with no ttyS0.

Fixes 2c4288719806 ("MIPS: PCI: Add detection of IOC3 on IO7, IO8, IO9 and Fuel")
---
 drivers/mfd/ioc3.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
drivers/mfd/ioc3.c +46 -0
index 57956c00263f..95794dc9931c 100644
@@ -517,6 +517,51 @@ static int ip30_sysboard_setup(struct ioc3_priv_data *ipd)
 	return ioc3_led_setup(ipd);
 }
 
+static const struct mfd_cell ip34_m48t35_cells[] = {
+	{
+		.name = "rtc-m48t35-ip35",
+		.resources = ioc3_m48t35_resources,
+		.num_resources = ARRAY_SIZE(ioc3_m48t35_resources),
+	}
+};
+
+/*
+ * Fuel's timekeeper is the M48T35 at IOC3_BYTEBUS_DEV0. A read at IP30's
+ * DS1685 address never completes on the Fuel system board.
+ */
+static int ip34_sysboard_setup(struct ioc3_priv_data *ipd)
+{
+	int ret, io_irq;
+
+	io_irq = ioc3_map_irq(ipd->pdev, PCI_SLOT(ipd->pdev->devfn),
+			      PCI_INTERRUPT_INTB);
+	ret = ioc3_irq_domain_setup(ipd, io_irq);
+	if (ret)
+		return ret;
+
+	ret = ioc3_eth_setup(ipd);
+	if (ret)
+		return ret;
+
+	ret = ioc3_serial_setup(ipd);
+	if (ret)
+		return ret;
+
+	ret = mfd_add_devices(&ipd->pdev->dev, PLATFORM_DEVID_AUTO,
+			      ip34_m48t35_cells, ARRAY_SIZE(ip34_m48t35_cells),
+			      &ipd->pdev->resource[0], 0, ipd->domain);
+	if (ret) {
+		dev_err(&ipd->pdev->dev, "Failed to add M48T35 subdev\n");
+		return ret;
+	}
+
+	ret = ioc3_kbd_setup(ipd);
+	if (ret)
+		return ret;
+
+	return ioc3_led_setup(ipd);
+}
+
 static int ioc3_menet_setup(struct ioc3_priv_data *ipd)
 {
 	int ret, io_irq;
@@ -574,6 +619,7 @@ static struct {
 	IOC3_SID("IP27 BaseIO", IP27_BASEIO, &ip27_baseio_setup),
 	IOC3_SID("IP29 System Board", IP29_SYSBOARD, &ip27_baseio6g_setup),
 	IOC3_SID("IP30 System Board", IP30_SYSBOARD, &ip30_sysboard_setup),
+	IOC3_SID("IP34 System Board", IP34_SYSBOARD, &ip34_sysboard_setup),
 	IOC3_SID("MENET", MENET, &ioc3_menet_setup),
 	IOC3_SID("MENET4", MENET4, &ioc3_menet4_setup)
 };
Signature · 1 line
2.47.3
author
#43 lore raw

PATCH v2 37/53 mfd: ioc3: Cross the serial IRQs on the Origin 300 IO8

In reply to Imre Kaloz

On the IO8 base I/O board the 16550 at sregs.uarta raises SIO_IR_SB_INT and the one at sregs.uartb raises SIO_IR_SA_INT. With the usual mapping the console never receives, because the interrupt it enables is never asserted.

Add an IO8 entry to ioc3_infos[] that registers the serial cells with the two IRQ resources exchanged. The board was matched as CAD DUO and printed "ioc3: CAD DUO"; it now prints "ioc3: IO8" and gets its serial ports.

---
 drivers/mfd/ioc3.c | 67 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 63 insertions(+), 4 deletions(-)
drivers/mfd/ioc3.c +63 -4
index 95794dc9931c..01c919c18b06 100644
@@ -223,7 +223,37 @@ static struct mfd_cell ioc3_serial_cells[] = {
 	}
 };
 
-static int ioc3_serial_setup(struct ioc3_priv_data *ipd)
+/*
+ * The UART at sregs.uarta raises IOC3_IRQ_SERIAL_B on the IO8 and
+ * sregs.uartb raises IOC3_IRQ_SERIAL_A.
+ */
+static const struct resource ioc3_uarta_crossed_resources[] = {
+	DEFINE_RES_MEM(offsetof(struct ioc3, sregs.uarta),
+		       sizeof_field(struct ioc3, sregs.uarta)),
+	DEFINE_RES_IRQ(IOC3_IRQ_SERIAL_B)
+};
+
+static const struct resource ioc3_uartb_crossed_resources[] = {
+	DEFINE_RES_MEM(offsetof(struct ioc3, sregs.uartb),
+		       sizeof_field(struct ioc3, sregs.uartb)),
+	DEFINE_RES_IRQ(IOC3_IRQ_SERIAL_A)
+};
+
+static const struct mfd_cell ioc3_serial_crossed_cells[] = {
+	{
+		.name = "ioc3-serial8250",
+		.resources = ioc3_uarta_crossed_resources,
+		.num_resources = ARRAY_SIZE(ioc3_uarta_crossed_resources),
+	},
+	{
+		.name = "ioc3-serial8250",
+		.resources = ioc3_uartb_crossed_resources,
+		.num_resources = ARRAY_SIZE(ioc3_uartb_crossed_resources),
+	}
+};
+
+static int __ioc3_serial_setup(struct ioc3_priv_data *ipd,
+			       const struct mfd_cell *cells, int num_cells)
 {
 	struct ioc3 __iomem *regs = ipd->base;
 	int ret;
@@ -241,8 +271,8 @@ static int ioc3_serial_setup(struct ioc3_priv_data *ipd)
 	udelay(1000); /* Wait until mode switch is done */
 
 	ret = mfd_add_devices(&ipd->pdev->dev, PLATFORM_DEVID_AUTO,
-			      ioc3_serial_cells, ARRAY_SIZE(ioc3_serial_cells),
-			      &ipd->pdev->resource[0], 0, ipd->domain);
+			      cells, num_cells, &ipd->pdev->resource[0], 0,
+			      ipd->domain);
 	if (ret) {
 		dev_err(&ipd->pdev->dev, "Failed to add 16550 subdevs\n");
 		return ret;
@@ -251,6 +281,12 @@ static int ioc3_serial_setup(struct ioc3_priv_data *ipd)
 	return 0;
 }
 
+static int ioc3_serial_setup(struct ioc3_priv_data *ipd)
+{
+	return __ioc3_serial_setup(ipd, ioc3_serial_cells,
+				   ARRAY_SIZE(ioc3_serial_cells));
+}
+
 static const struct resource ioc3_kbd_resources[] = {
 	DEFINE_RES_MEM(offsetof(struct ioc3, serio),
 		       sizeof_field(struct ioc3, serio)),
@@ -601,6 +637,28 @@ static int ioc3_cad_duo_setup(struct ioc3_priv_data *ipd)
 	return ioc3_kbd_setup(ipd);
 }
 
+static int ioc3_io8_setup(struct ioc3_priv_data *ipd)
+{
+	int ret, io_irq;
+
+	io_irq = ioc3_map_irq(ipd->pdev, PCI_SLOT(ipd->pdev->devfn),
+			      PCI_INTERRUPT_INTB);
+	ret = ioc3_irq_domain_setup(ipd, io_irq);
+	if (ret)
+		return ret;
+
+	ret = ioc3_eth_setup(ipd);
+	if (ret)
+		return ret;
+
+	ret = __ioc3_serial_setup(ipd, ioc3_serial_crossed_cells,
+				  ARRAY_SIZE(ioc3_serial_crossed_cells));
+	if (ret)
+		return ret;
+
+	return ioc3_kbd_setup(ipd);
+}
+
 /* Helper macro for filling ioc3_info array */
 #define IOC3_SID(_name, _sid, _setup) \
 	{								   \
@@ -621,7 +679,8 @@ static struct {
 	IOC3_SID("IP30 System Board", IP30_SYSBOARD, &ip30_sysboard_setup),
 	IOC3_SID("IP34 System Board", IP34_SYSBOARD, &ip34_sysboard_setup),
 	IOC3_SID("MENET", MENET, &ioc3_menet_setup),
-	IOC3_SID("MENET4", MENET4, &ioc3_menet4_setup)
+	IOC3_SID("MENET4", MENET4, &ioc3_menet4_setup),
+	IOC3_SID("IO8", IO8, &ioc3_io8_setup)
 };
 #undef IOC3_SID
 
Signature · 1 line
2.47.3
author
#44 lore raw

PATCH v2 38/53 net: ethernet: sgi: ioc3-eth: fall back to the platform MAC address

In reply to Imre Kaloz

The IOC3 on Fuel's system board has no MAC PROM on its 1-wire bus, so ioc3eth_get_mac_addr() cannot succeed there and the probe defers for ever. Ask eth_platform_get_mac_address() before deferring; on IP35 machines it answers from the L1 system controller. Once deferred probing gives up with neither source answering, use a random address.

---
 drivers/net/ethernet/sgi/ioc3-eth.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/net/ethernet/sgi/ioc3-eth.c +15 -4
index f86dd192a3d3..13102177ea88 100644
@@ -850,6 +850,7 @@ static int ioc3eth_probe(struct platform_device *pdev)
 	struct ioc3_private *ip;
 	struct net_device *dev;
 	struct resource *regs;
+	bool random_mac = false;
 	u8 mac_addr[6];
 	int err;
 
@@ -858,9 +859,16 @@ static int ioc3eth_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Invalid resource\n");
 		return -EINVAL;
 	}
-	/* get mac addr from one wire prom */
-	if (ioc3eth_get_mac_addr(regs, mac_addr))
-		return -EPROBE_DEFER; /* not available yet */
+	/* get mac addr from one wire prom, or from the platform */
+	if (ioc3eth_get_mac_addr(regs, mac_addr) &&
+	    eth_platform_get_mac_address(&pdev->dev, mac_addr)) {
+		err = driver_deferred_probe_check_state(&pdev->dev);
+		if (err == -EPROBE_DEFER)
+			return err; /* not available yet */
+
+		dev_warn(&pdev->dev, "no MAC address, using a random one\n");
+		random_mac = true;
+	}
 
 	dev = alloc_etherdev(sizeof(struct ioc3_private));
 	if (!dev)
@@ -939,7 +947,10 @@ static int ioc3eth_probe(struct platform_device *pdev)
 
 	ioc3_mii_start(ip);
 	ioc3_ssram_disc(ip);
-	eth_hw_addr_set(dev, mac_addr);
+	if (random_mac)
+		eth_hw_addr_random(dev);
+	else
+		eth_hw_addr_set(dev, mac_addr);
 
 	/* The IOC3-specific entries in the device structure. */
 	dev->watchdog_timeo	= 5 * HZ;
Signature · 1 line
2.47.3
author
#45 lore raw

PATCH v2 39/53 MIPS: SGI-IP27: don't register a w1 master on an XBridge or PIC

In reply to Imre Kaloz

On an XBridge the b_nic register's 1-wire bit-bang path reads back a constant mcr, so a sgi_w1 master registered there enumerates nothing but phantom slave IDs. Move the w1 registration into bridge_w1_create() and call it for classic Bridges only. On IP35 the L1 supplies the board part number and MAC address instead.

---
 arch/mips/sgi-ip27/ip27-xtalk.c | 41 +++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 10 deletions(-)
arch/mips/sgi-ip27/ip27-xtalk.c +31 -10
index 73b2eef96bdb..091186cb7a04 100644
@@ -31,13 +31,10 @@ enum xtalk_bridge_type {
 	XTALK_PIC_BUS1,
 };
 
-static void bridge_platform_create(nasid_t nasid, int widget, int masterwid,
-				   enum xtalk_bridge_type type)
+static struct platform_device *bridge_w1_create(nasid_t nasid, int widget)
 {
-	struct xtalk_bridge_platform_data *bd;
 	struct sgi_w1_platform_data *wd;
 	struct platform_device *pdev_wd;
-	struct platform_device *pdev_bd;
 	struct resource w1_res;
 	unsigned long offset;
 
@@ -46,7 +43,7 @@ static void bridge_platform_create(nasid_t nasid, int widget, int masterwid,
 	wd = kzalloc_obj(*wd);
 	if (!wd) {
 		pr_warn("xtalk:n%d/%x bridge create out of memory\n", nasid, widget);
-		return;
+		return NULL;
 	}
 
 	snprintf(wd->dev_id, sizeof(wd->dev_id), "bridge-%012lx",
@@ -77,6 +74,35 @@ static void bridge_platform_create(nasid_t nasid, int widget, int masterwid,
 	}
 	/* platform_device_add_data() duplicates the data */
 	kfree(wd);
+	return pdev_wd;
+
+err_put_pdev_wd:
+	platform_device_put(pdev_wd);
+err_kfree_wd:
+	kfree(wd);
+	return NULL;
+}
+
+static void bridge_platform_create(nasid_t nasid, int widget, int masterwid,
+				   enum xtalk_bridge_type type)
+{
+	struct xtalk_bridge_platform_data *bd;
+	struct platform_device *pdev_wd = NULL;
+	struct platform_device *pdev_bd;
+	unsigned long offset;
+
+	offset = NODE_OFFSET(nasid);
+
+	/*
+	 * An XBridge's b_nic register reads back a constant mcr on the
+	 * 1-wire bit-bang path, so a sgi_w1 master there enumerates only
+	 * phantom slave IDs. Only a classic Bridge gets one.
+	 */
+	if (type == XTALK_BRIDGE) {
+		pdev_wd = bridge_w1_create(nasid, widget);
+		if (!pdev_wd)
+			return;
+	}
 
 	bd = kzalloc_obj(*bd);
 	if (!bd) {
@@ -139,11 +165,6 @@ static void bridge_platform_create(nasid_t nasid, int widget, int masterwid,
 err_unregister_pdev_wd:
 	platform_device_unregister(pdev_wd);
 	return;
-err_put_pdev_wd:
-	platform_device_put(pdev_wd);
-err_kfree_wd:
-	kfree(wd);
-	return;
 }
 
 static int probe_one_port(nasid_t nasid, int widget, int masterwid)
Signature · 1 line
2.47.3
author
#46 lore raw

PATCH v2 40/53 MIPS: SGI-IP27: report a Bedrock machine as SGI IP35

In reply to Imre Kaloz

get_system_type() answers "SGI Origin" on either hub generation, but a Fuel or Tezro is no Origin. Return "SGI IP35" on a Bedrock hub and in the node banner.

---
 arch/mips/sgi-ip27/ip27-init.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
arch/mips/sgi-ip27/ip27-init.c +3 -2
index 15811fb3cdee..c92f1bef692e 100644
@@ -111,7 +111,8 @@ void __init plat_mem_setup(void)
 	 * hub_rtc init and cpu clock intr enabled for later calibrate_delay.
 	 */
 	nid = get_nasid();
-	printk("IP27: Running on node %d.\n", nid);
+	pr_info("%s: Running on node %d.\n",
+		system_is_ip35 ? "IP35" : "IP27", nid);
 
 	p = LOCAL_HUB_L(PI_CPU_PRESENT_A) & 1;
 	e = LOCAL_HUB_L(PI_CPU_ENABLE_A) & 1;
@@ -150,7 +151,7 @@ void __init plat_mem_setup(void)
 
 const char *get_system_type(void)
 {
-	return "SGI Origin";
+	return system_is_ip35 ? "SGI IP35" : "SGI Origin";
 }
 
 static inline bool hub_is_bedrock(void)
Signature · 1 line
2.47.3
author
#47 lore raw

PATCH v2 41/53 MIPS: SGI-IP27: identify the machine by the L1 brick type

In reply to Imre Kaloz

On a Bedrock hub, name the machine after the brick-type code the L1 reports for its chassis. Attached graphics makes an Origin an Onyx, so a graphics-class KLCONFIG board picks between the two names. An unlisted code keeps "SGI IP35".

---
 arch/mips/include/asm/sn/l1.h  |  1 +
 arch/mips/sgi-ip27/ip27-init.c | 68 ++++++++++++++++++++++++++++++++++
 arch/mips/sgi-ip27/ip27-l1.c   | 45 ++++++++++++++++++++++
 3 files changed, 114 insertions(+)
arch/mips/include/asm/sn/l1.h +1 -0
index 1a3b7fa0e213..f9fa8a8051e6 100644
@@ -17,5 +17,6 @@
 
 int l1_exec_command(const char *cmd);
 int l1_read_board_partnum(unsigned int component, char *buf, size_t len);
+int l1_read_brick_type(void);
 
 #endif /* __ASM_SN_L1_H */
arch/mips/sgi-ip27/ip27-init.c +68 -0

92 lines not on this page · raw message

arch/mips/sgi-ip27/ip27-l1.c +45 -0

57 lines not on this page · raw message

Signature · 1 line
2.47.3
author
#48 lore raw

PATCH v2 42/53 MIPS: SGI-IP27: register the Odyssey graphics widget

In reply to Imre Kaloz

The Odyssey (VPro) graphics widget is a direct xtalk widget with no PCI bridge in front of it, so it needs a platform_device of its own rather than piggybacking on bridge_platform_create(). Its register aperture is the widget's small window, and the sgi-odyssey DRM driver binds it. The driver programs the board with the widget id of its master hub, passed as the u32 property "sgi,master-widget".

---
 arch/mips/sgi-ip27/ip27-xtalk.c | 39 +++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
arch/mips/sgi-ip27/ip27-xtalk.c +39 -0
index 091186cb7a04..b56e70db20cf 100644
@@ -7,9 +7,11 @@
  * Generic XTALK initialization code
  */
 
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/smp.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/platform_data/sgi-w1.h>
 #include <linux/platform_data/xtalk-bridge.h>
 #include <asm/sn/addrs.h>
@@ -24,6 +26,9 @@
 #define PXBOW_WIDGET_PART_NUM	0xd100	/* PXbow */
 #define BASE_XBOW_PORT		8     /* Lowest external port */
 
+/* Odyssey's register aperture, as sized by the sgi-odyssey driver. */
+#define ODYSSEY_REG_SIZE		0x00410000
+
 enum xtalk_bridge_type {
 	XTALK_BRIDGE,
 	XTALK_XBRIDGE,
@@ -167,6 +172,37 @@ static void bridge_platform_create(nasid_t nasid, int widget, int masterwid,
 	return;
 }
 
+static void odyssey_platform_create(nasid_t nasid, int widget, int masterwid)
+{
+	const struct property_entry props[] = {
+		PROPERTY_ENTRY_U32("sgi,master-widget", masterwid),
+		{ }
+	};
+	struct resource res;
+	struct platform_device_info info = {
+		.name = "sgi-odyssey",
+		.id = PLATFORM_DEVID_AUTO,
+		.res = &res,
+		.num_res = 1,
+		.properties = props,
+	};
+	struct platform_device *pdev;
+
+	memset(&res, 0, sizeof(res));
+	res.name = "sgi-odyssey";
+	res.start = NODE_OFFSET(nasid) + (widget << SWIN_SIZE_BITS);
+	res.end = res.start + ODYSSEY_REG_SIZE - 1;
+	res.flags = IORESOURCE_MEM;
+
+	pr_info("xtalk:n%d/%x odyssey widget: reg=[%pa-%pa]\n",
+		nasid, widget, &res.start, &res.end);
+
+	pdev = platform_device_register_full(&info);
+	if (IS_ERR(pdev))
+		pr_warn("xtalk:n%d/%x odyssey platform device registration failed: %ld\n",
+			nasid, widget, PTR_ERR(pdev));
+}
+
 static int probe_one_port(nasid_t nasid, int widget, int masterwid)
 {
 	widgetreg_t		widget_id;
@@ -190,6 +226,9 @@ static int probe_one_port(nasid_t nasid, int widget, int masterwid)
 		bridge_platform_create(nasid, widget, masterwid,
 				       XTALK_PIC_BUS1);
 		break;
+	case WIDGET_ODYS_PART_NUM:
+		odyssey_platform_create(nasid, widget, masterwid);
+		break;
 	default:
 		pr_info("xtalk:n%d/%d unknown widget (0x%x)\n",
 			nasid, widget, partnum);
Signature · 1 line
2.47.3
author
#49 lore raw

PATCH v2 43/53 MIPS: SGI-IP27: take the console from the KLCONFIG header on IP35

In reply to Imre Kaloz

An IP35 PROM records its console UART and baud rate in the KLCONFIG header. That UART is ttyS0 on Fuel and Tezro, so when the record is present and the command line names no console, prefer ttyS0 at that baud rate.

---
 arch/mips/sgi-ip27/ip27-init.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/mips/sgi-ip27/ip27-init.c +22 -0
index 7f16d7f437c9..e657155ef7c9 100644
@@ -6,6 +6,7 @@
  * Copyright (C) 2000 - 2001 by Kanoj Sarcar ([email protected])
  * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
  */
+#include <linux/console.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/sched.h>
@@ -164,6 +165,26 @@ static void __init ip27_set_machine_name(void)
 		gfx ? "with" : "without");
 }
 
+/*
+ * Prefer ttyS0 at the baud rate the IP35 PROM recorded for its console
+ * UART in the KLCONFIG header.
+ */
+static void __init ip27_setup_console(void)
+{
+	static char options[8];
+	console_t *cons;
+
+	if (!system_is_ip35 || strstr(arcs_cmdline, "console="))
+		return;
+
+	cons = KL_CONFIG_CH_CONS_INFO(master_nasid);
+	if (!cons->uart_base)
+		return;
+
+	snprintf(options, sizeof(options), "%u", (u16)cons->baud);
+	add_preferred_console("ttyS", 0, options);
+}
+
 void __init plat_mem_setup(void)
 {
 	u64 p, e, n_mode;
@@ -215,6 +236,7 @@ void __init plat_mem_setup(void)
 	set_io_port_base(IO_BASE);
 
 	ip27_set_machine_name();
+	ip27_setup_console();
 }
 
 const char *get_system_type(void)
Signature · 1 line
2.47.3
author
#50 lore raw

PATCH v2 44/53 MIPS: SGI-IP27: give each CPU its own topology package id

In reply to Imre Kaloz

cpu_data[].package is left at its zero-init default, so /proc/cpuinfo and cpu_core_map treat every CPU in the system as one package, though each PI slice is a separate physical processor. Derive it from the klconfig nasid and physid node_scan_cpus() already records as the CPU's slice.

---
 arch/mips/sgi-ip27/ip27-smp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/mips/sgi-ip27/ip27-smp.c +8 -0
index 13b85e3ba311..7739ac9618b8 100644
@@ -47,6 +47,13 @@ static int node_scan_cpus(nasid_t nasid, int highest)
 				set_cpu_possible(cpuid, true);
 				cputonasid(cpus_found) = nasid;
 				cputoslice(cpus_found) = acpu->cpu_info.physid;
+				/*
+				 * Each PI slice is a separate physical CPU
+				 * package; these processors have no on-die
+				 * multiprocessing, so core is 0.
+				 */
+				cpu_data[cpus_found].package =
+					(nasid << 2) | acpu->cpu_info.physid;
 				sn_cpu_info[cpus_found].p_speed =
 							acpu->cpu_speed;
 				cpus_found++;
@@ -85,6 +92,7 @@ void cpu_node_probe(void)
 		if (cputonasid(i) == master_nasid &&
 		    cputoslice(i) == LOCAL_HUB_L(PI_CPU_NUM)) {
 			swap(sn_cpu_info[0], sn_cpu_info[i]);
+			swap(cpu_data[0].package, cpu_data[i].package);
 			break;
 		}
 	}
Signature · 1 line
2.47.3
author
#51 lore raw

PATCH v2 45/53 ata: add pata_sgiioc4 driver for the SGI IOC4 ATA/ATAPI controller

In reply to Imre Kaloz

The IOC4 on Origin 350-class I-brick boards drives the DVD-ROM from an ATA/ATAPI controller at BAR0+0x100. drivers/ide/sgiioc4.c went away in v5.4.

Add a libata driver bound to an IOC4 MFD cell, with PIO4 and multiword DMA mode 2. Each taskfile register sits at the lowest address of its own 32-bit slot; the IDE driver's "+3" byte-lane correction reads zeros there.

---
 drivers/ata/Kconfig        |  10 ++
 drivers/ata/Makefile       |   1 +
 drivers/ata/pata_sgiioc4.c | 311 +++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+)
 create mode 100644 drivers/ata/pata_sgiioc4.c
drivers/ata/Kconfig +10 -0
index 28ca856ecc75..704414501f35 100644
@@ -940,6 +940,16 @@ config PATA_SERVERWORKS
 
 	  If unsure, say N.
 
+config PATA_SGIIOC4
+	tristate "SGI IOC4 ATA/ATAPI support"
+	depends on SGI_MFD_IOC3
+	help
+	  This option enables support for the ATA/ATAPI controller
+	  integrated into SGI's IOC4 I/O ASIC, found on Tezro/Origin
+	  350-class I-brick system boards.
+
+	  If unsure, say N.
+
 config PATA_SIL680
 	tristate "CMD / Silicon Image 680 PATA support"
 	depends on PCI
drivers/ata/Makefile +1 -0
index b96025abd45e..f2947a2b86be 100644
@@ -89,6 +89,7 @@ obj-$(CONFIG_PATA_RDC)		+= pata_rdc.o
 obj-$(CONFIG_PATA_SC1200)	+= pata_sc1200.o
 obj-$(CONFIG_PATA_SCH)		+= pata_sch.o
 obj-$(CONFIG_PATA_SERVERWORKS)	+= pata_serverworks.o
+obj-$(CONFIG_PATA_SGIIOC4)	+= pata_sgiioc4.o
 obj-$(CONFIG_PATA_SIL680)	+= pata_sil680.o
 obj-$(CONFIG_PATA_SIS)		+= pata_sis.o
 obj-$(CONFIG_PATA_TOSHIBA)	+= pata_piccolo.o
drivers/ata/pata_sgiioc4.c new file +311 -0

311 lines not on this page · raw message

Signature · 1 line
2.47.3
author
#52 lore raw

PATCH v2 46/53 mfd: ioc3: Add IOC4 ATA/ATAPI cell

In reply to Imre Kaloz

Add an IOC4 cell for pata_sgiioc4: a DEFINE_RES_MEM() over struct ioc4_ata_regs and a DEFINE_RES_IRQ() for other_ir bit 0 (IOC4_OTHER_IR_ATA_INT). It joins ioc4_cells[] between the kbd and rtc cells.

The ATA passthrough bit follows the drive's INTRQ line, which stays asserted until Status is read, unlike the discrete events on the rest of other_ir. Make it the one level-triggered bit of the other_ir bank. libata reads Status while servicing the interrupt, so ioc3_irq_ack()'s W1C write is the only ack needed.

---
 arch/mips/include/asm/sn/ioc4.h |  1 +
 drivers/mfd/ioc3.c              | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)
arch/mips/include/asm/sn/ioc4.h +1 -0
index 781fcfb81b5e..d23676ae82b4 100644
@@ -129,6 +129,7 @@ struct ioc4 {
 #define IOC4_OTHER_IR_GEN_INT		0xff000000	/* generic pins */
 
 #define IOC4_OTHER_IR_KBD_INT_BIT	6	/* bit index */
+#define IOC4_OTHER_IR_ATA_INT_BIT	0	/* bit index */
 
 #define IOC4_SSCR_DMA_EN	0x10000000	/* enable ring buffer DMA */
 
drivers/mfd/ioc3.c +19 -0
index 01c919c18b06..b471c90e737c 100644
@@ -850,6 +850,13 @@ static const struct ioc3_variant ioc3_variant = {
 	(IOC4_SIO_IR_PORT_INT(0) | IOC4_SIO_IR_PORT_INT(1) | \
 	 IOC4_SIO_IR_PORT_INT(2) | IOC4_SIO_IR_PORT_INT(3))
 
+/*
+ * In other_ir only ATA passthrough is level triggered. It follows the
+ * drive's INTRQ line, which stays asserted until the host reads Status;
+ * the other other_ir bits are discrete events.
+ */
+#define IOC4_OTHER_LVL_MASK	IOC4_OTHER_IR_ATA_INT
+
 #define IOC4_UART_RES(port) {						\
 	DEFINE_RES_MEM(offsetof(struct ioc4, uart[port]),		\
 		       sizeof_field(struct ioc4, uart[port])),		\
@@ -869,6 +876,12 @@ static const struct resource ioc4_kbd_resources[] = {
 	DEFINE_RES_IRQ(IOC4_IRQ_OTHER_BASE + IOC4_OTHER_IR_KBD_INT_BIT)
 };
 
+static const struct resource ioc4_ata_resources[] = {
+	DEFINE_RES_MEM(offsetof(struct ioc4, ata),
+		       sizeof_field(struct ioc4, ata)),
+	DEFINE_RES_IRQ(IOC4_IRQ_OTHER_BASE + IOC4_OTHER_IR_ATA_INT_BIT)
+};
+
 static const struct resource ioc4_rtc_resources[] = {
 	DEFINE_RES_MEM(IOC4_BYTEBUS_DEV0, M48T35_REG_SIZE)
 };
@@ -898,6 +911,11 @@ static const struct mfd_cell ioc4_cells[] = {
 		.resources = ioc4_kbd_resources,
 		.num_resources = ARRAY_SIZE(ioc4_kbd_resources),
 	},
+	{
+		.name = "pata_sgiioc4",
+		.resources = ioc4_ata_resources,
+		.num_resources = ARRAY_SIZE(ioc4_ata_resources),
+	},
 	{
 		.name = "rtc-m48t35-ip35",
 		.resources = ioc4_rtc_resources,
@@ -974,6 +992,7 @@ static const struct ioc3_irq_bank ioc4_irq_banks[] = {
 		.ir = offsetof(struct ioc4, other_ir),
 		.ies = offsetof(struct ioc4, other_ies),
 		.iec = offsetof(struct ioc4, other_iec),
+		.lvl_mask = IOC4_OTHER_LVL_MASK,
 	},
 };
 
Signature · 1 line
2.47.3
maintainer
#53 lore raw

Re: [PATCH v2 46/53] mfd: ioc3: Add IOC4 ATA/ATAPI cell

--- checkpatch.pl: clean (0 issues) ---

Quoted 61 lines · Imre Kaloz

Add an IOC4 cell for pata_sgiioc4: a DEFINE_RES_MEM() over struct ioc4_ata_regs and a DEFINE_RES_IRQ() for other_ir bit 0 (IOC4_OTHER_IR_ATA_INT). It joins ioc4_cells[] between the kbd and rtc cells.

The ATA passthrough bit follows the drive's INTRQ line, which stays asserted until Status is read, unlike the discrete events on the rest of other_ir. Make it the one level-triggered bit of the other_ir bank. libata reads Status while servicing the interrupt, so ioc3_irq_ack()'s W1C write is the only ack needed.

---
 arch/mips/include/asm/sn/ioc4.h |  1 +
 drivers/mfd/ioc3.c              | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)
arch/mips/include/asm/sn/ioc4.h +1 -0
index 781fcfb81b5e..d23676ae82b4 100644
@@ -129,6 +129,7 @@ struct ioc4 {
 #define IOC4_OTHER_IR_GEN_INT		0xff000000	/* generic pins */
 
 #define IOC4_OTHER_IR_KBD_INT_BIT	6	/* bit index */
+#define IOC4_OTHER_IR_ATA_INT_BIT	0	/* bit index */
 
 #define IOC4_SSCR_DMA_EN	0x10000000	/* enable ring buffer DMA */
 
drivers/mfd/ioc3.c +13 -0
index 01c919c18b06..b471c90e737c 100644
@@ -850,6 +850,13 @@ static const struct ioc3_variant ioc3_variant = {
 	(IOC4_SIO_IR_PORT_INT(0) | IOC4_SIO_IR_PORT_INT(1) | \
 	 IOC4_SIO_IR_PORT_INT(2) | IOC4_SIO_IR_PORT_INT(3))
 
+/*
+ * In other_ir only ATA passthrough is level triggered. It follows the
+ * drive's INTRQ line, which stays asserted until the host reads Status;
+ * the other other_ir bits are discrete events.
+ */
+#define IOC4_OTHER_LVL_MASK	IOC4_OTHER_IR_ATA_INT
+
 #define IOC4_UART_RES(port) {						\
 	DEFINE_RES_MEM(offsetof(struct ioc4, uart[port]),		\
 		       sizeof_field(struct ioc4, uart[port])),		\
@@ -869,6 +876,12 @@ static const struct resource ioc4_kbd_resources[] = {
 	DEFINE_RES_IRQ(IOC4_IRQ_OTHER_BASE + IOC4_OTHER_IR_KBD_INT_BIT)
 };
 
+static const struct resource ioc4_ata_resources[] = {
+	DEFINE_RES_MEM(offsetof(struct ioc4, ata),
+		       sizeof_field(struct ioc4, ata)),
+	DEFINE_RES_IRQ(IOC4_IRQ_OTHER_BASE + IOC4_OTHER_IR_ATA_INT_BIT)
+};
+
 static const struct resource ioc4_rtc_resources[] = {
 	DEFINE_RES_MEM(IOC4_BYTEBUS_DEV0, M48T35_REG_SIZE)
 };

drivers/mfd/ioc3.c static const struct mfd_cell ioc4_cells[] = { · line 918

Quoted 8 lines
drivers/mfd/ioc3.c +5 -0
@@ -898,6 +911,11 @@ static const struct mfd_cell ioc4_cells[] = {
 		.resources = ioc4_kbd_resources,
 		.num_resources = ARRAY_SIZE(ioc4_kbd_resources),
 	},
+	{
+		.name = "pata_sgiioc4",
+		.resources = ioc4_ata_resources,
+		.num_resources = ARRAY_SIZE(ioc4_ata_resources),
+	},

Shouldn't this have been added in Patch 31?

Quoted 14 lines
drivers/mfd/ioc3.c +1 -0
 	{
 		.name = "rtc-m48t35-ip35",
 		.resources = ioc4_rtc_resources,
@@ -974,6 +992,7 @@ static const struct ioc3_irq_bank ioc4_irq_banks[] = {
 		.ir = offsetof(struct ioc4, other_ir),
 		.ies = offsetof(struct ioc4, other_ies),
 		.iec = offsetof(struct ioc4, other_iec),
+		.lvl_mask = IOC4_OTHER_LVL_MASK,
 	},
 };
 
Signature · 1 line
2.47.3
Signature · 1 line
Lee Jones
author
#54 lore raw

Re: [PATCH v2 46/53] mfd: ioc3: Add IOC4 ATA/ATAPI cell

Quoted 7 lines · Lee Jones

drivers/mfd/ioc3.c static const struct mfd_cell ioc4_cells[] = { · line 918

Quoted 5 lines
drivers/mfd/ioc3.c +5 -0
+	{
+		.name = "pata_sgiioc4",
+		.resources = ioc4_ata_resources,
+		.num_resources = ARRAY_SIZE(ioc4_ata_resources),
+	},

Shouldn't this have been added in Patch 31?

It should have, yes. In v3 the ATA cell, its resources and the level-triggered other_ir bit move into the patch that adds the IOC4 cells (part of the split of 31 I described in my other reply) and this one goes away.

Thanks for catching it,

Imre

author
#55 lore raw

PATCH v2 47/53 MAINTAINERS: add an entry for the SGI IOC4 ATA driver

In reply to Imre Kaloz

Add an entry for drivers/ata/pata_sgiioc4.c, the libata driver for the IOC4 ATA/ATAPI controller.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index a30c09a55c72..826f0ffb71fd 100644
@@ -24925,6 +24925,12 @@ F:	include/linux/phylink.h
 F:	include/linux/sfp.h
 K:	phylink\.h|struct\s+phylink|\.phylink|>phylink_|phylink_(autoneg|clear|connect|create|destroy|disconnect|ethtool|helper|mac|mii|of|set|start|stop|test|validate)
 
+SGI IOC4 ATA DRIVER
+M:	Imre Kaloz <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/ata/pata_sgiioc4.c
+
 SHARED MEMORY COMMUNICATIONS (SMC) SOCKETS
 M:	D. Wythe <[email protected]>
 M:	Dust Li <[email protected]>
Signature · 1 line
2.47.3
maintainer
#56 lore raw

Re: [PATCH v2 47/53] MAINTAINERS: add an entry for the SGI IOC4 ATA driver

Quoted 15 lines · Imre Kaloz

Add an entry for drivers/ata/pata_sgiioc4.c, the libata driver for the IOC4 ATA/ATAPI controller.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +0 -0
index a30c09a55c72..826f0ffb71fd 100644
@@ -24925,6 +24925,12 @@ F:	include/linux/phylink.h
 F:	include/linux/sfp.h
 K:	phylink\.h|struct\s+phylink|\.phylink|>phylink_|phylink_(autoneg|clear|connect|create|destroy|disconnect|ethtool|helper|mac|mii|of|set|start|stop|test|validate)

MAINTAINERS F: include/linux/phylink.h · line 24936

Quoted 10 lines
MAINTAINERS +6 -0
 
+SGI IOC4 ATA DRIVER
+M:	Imre Kaloz <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/ata/pata_sgiioc4.c
+
 SHARED MEMORY COMMUNICATIONS (SMC) SOCKETS
 M:	D. Wythe <[email protected]>
 M:	Dust Li <[email protected]>

Please squash this into patch 45.

Also, the cover letter mentions that patch 45-47 are for libata but I did not receive patch 46. I only received the cover letter, and patches 45 and 47.

Are you planning to get all of this merged through the mips tree?

Signature · 2 lines
Damien Le Moal
Western Digital Research
author
#57 lore raw

Re: [PATCH v2 47/53] MAINTAINERS: add an entry for the SGI IOC4 ATA driver

Hi Damien,

Quoted 29 lines · Damien Le Moal
Quoted 15 lines · Imre Kaloz

Add an entry for drivers/ata/pata_sgiioc4.c, the libata driver for the IOC4 ATA/ATAPI controller.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +0 -0
index a30c09a55c72..826f0ffb71fd 100644
@@ -24925,6 +24925,12 @@ F:	include/linux/phylink.h
 F:	include/linux/sfp.h
 K:	phylink\.h|struct\s+phylink|\.phylink|>phylink_|phylink_(autoneg|clear|connect|create|destroy|disconnect|ethtool|helper|mac|mii|of|set|start|stop|test|validate)

MAINTAINERS F: include/linux/phylink.h · line 24936

Quoted 10 lines
MAINTAINERS +6 -0
 
+SGI IOC4 ATA DRIVER
+M:	Imre Kaloz <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/ata/pata_sgiioc4.c
+
 SHARED MEMORY COMMUNICATIONS (SMC) SOCKETS
 M:	D. Wythe <[email protected]>
 M:	Dust Li <[email protected]>

Please squash this into patch 45.

Quoted 4 lines

Also, the cover letter mentions that patch 45-47 are for libata but I did not receive patch 46. I only received the cover letter, and patches 45 and 47.

Are you planning to get all of this merged through the mips tree?

Will squash 47 into 45 in v3.

Sorry about 46: it only touches drivers/mfd/ioc3.c and arch/mips/include/asm/sn/ioc4.h, so get_maintainer left linux-ide off it. It adds the IOC4 ATA/ATAPI MFD cell that pata_sgiioc4 binds to:
https://lore.kernel.org/all/754bae380c938b63eeaa87e3dccf9755314675ed.1791890466.git.kaloz@kernel.org/
v3 will copy you and linux-ide on it.

As for merging: pata_sgiioc4 depends on the IOC4 support added earlier in the series (asm/sn/ioc4.h and the MFD cell), so I’d like it to go through the MIPS tree with your ack, if that works for you.

Best,
Imre

maintainer
#58 lore raw

Re: [PATCH v2 47/53] MAINTAINERS: add an entry for the SGI IOC4 ATA driver

Quoted 3 lines · Imre Kaloz

As for merging: pata_sgiioc4 depends on the IOC4 support added earlier in the series (asm/sn/ioc4.h and the MFD cell), so I’d like it to go through the MIPS tree with your ack, if that works for you.

OK for me to have this go through the mips tree.

Signature · 2 lines
Damien Le Moal
Western Digital Research
author
#59 lore raw

PATCH v2 48/53 MIPS: ip27_defconfig: update for the onboard hardware

In reply to Imre Kaloz

Drop add-in card and SoC drivers no IP27 or IP35 machine carries (wireless, PCI NICs and PHYs, FC/iSCSI/SAS HBAs, UIO drivers, I2C), the OMFS filesystem, and options for removed symbols or with unmet dependencies. Regenerate the file with make savedefconfig.

Enable USB host, storage and HID for the onboard USB of the Fuel, Tezro and Origin 300, and input for the IOC3 PS/2 ports. Set NETDEVICES, which only the iSCSI drivers selected.

---
 arch/mips/configs/ip27_defconfig | 177 +++----------------------------
 1 file changed, 13 insertions(+), 164 deletions(-)
arch/mips/configs/ip27_defconfig +13 -164
index 4c8abe4611b8..2dfa929a6553 100644
@@ -10,10 +10,7 @@ CONFIG_CPUSETS=y
 CONFIG_RELAY=y
 CONFIG_EXPERT=y
 CONFIG_SGI_IP27=y
-CONFIG_NUMA=y
-CONFIG_SMP=y
 CONFIG_HZ_1000=y
-CONFIG_PCI=y
 CONFIG_MIPS32_O32=y
 CONFIG_MIPS32_N32=y
 CONFIG_PM=y
@@ -40,7 +37,6 @@ CONFIG_INET6_AH=m
 CONFIG_INET6_ESP=m
 CONFIG_INET6_IPCOMP=m
 CONFIG_IPV6_MIP6=m
-CONFIG_IPV6_SIT=m
 CONFIG_IPV6_SIT_6RD=y
 CONFIG_IPV6_TUNNEL=m
 CONFIG_IPV6_MULTIPLE_TABLES=y
@@ -49,7 +45,6 @@ CONFIG_IPV6_MROUTE=y
 CONFIG_IPV6_PIMSM_V2=y
 CONFIG_NETWORK_SECMARK=y
 CONFIG_NET_SCHED=y
-CONFIG_NET_SCH_CBQ=m
 CONFIG_NET_SCH_HTB=m
 CONFIG_NET_SCH_HFSC=m
 CONFIG_NET_SCH_PRIO=m
@@ -59,7 +54,6 @@ CONFIG_NET_SCH_SFQ=m
 CONFIG_NET_SCH_TEQL=m
 CONFIG_NET_SCH_TBF=m
 CONFIG_NET_SCH_GRED=m
-CONFIG_NET_SCH_DSMARK=m
 CONFIG_NET_SCH_NETEM=m
 CONFIG_NET_SCH_INGRESS=m
 CONFIG_NET_CLS_BASIC=m
@@ -67,8 +61,6 @@ CONFIG_NET_CLS_ROUTE4=m
 CONFIG_NET_CLS_FW=m
 CONFIG_NET_CLS_U32=m
 CONFIG_CLS_U32_MARK=y
-CONFIG_NET_CLS_RSVP=m
-CONFIG_NET_CLS_RSVP6=m
 CONFIG_NET_CLS_FLOW=m
 CONFIG_NET_CLS_CGROUP=y
 CONFIG_NET_CLS_ACT=y
@@ -79,9 +71,7 @@ CONFIG_NET_ACT_MIRRED=m
 CONFIG_NET_ACT_NAT=m
 CONFIG_NET_ACT_PEDIT=m
 CONFIG_NET_ACT_SKBEDIT=m
-CONFIG_CFG80211=m
-CONFIG_MAC80211=m
-CONFIG_RFKILL=m
+# CONFIG_VGA_ARB is not set
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_ATA_OVER_ETH=m
 CONFIG_SCSI=y
@@ -94,21 +84,8 @@ CONFIG_SCSI_CONSTANTS=y
 CONFIG_SCSI_LOGGING=y
 CONFIG_SCSI_SCAN_ASYNC=y
 CONFIG_SCSI_SPI_ATTRS=y
-CONFIG_SCSI_FC_ATTRS=y
-CONFIG_SCSI_CXGB3_ISCSI=m
-CONFIG_SCSI_BNX2_ISCSI=m
-CONFIG_BE2ISCSI=m
-CONFIG_SCSI_HPSA=m
-CONFIG_SCSI_3W_SAS=m
-CONFIG_SCSI_AIC94XX=m
-# CONFIG_AIC94XX_DEBUG is not set
-CONFIG_SCSI_MVSAS=m
-# CONFIG_SCSI_MVSAS_DEBUG is not set
 CONFIG_SCSI_MPT2SAS=m
-CONFIG_LIBFC=m
 CONFIG_SCSI_QLOGIC_1280=y
-CONFIG_SCSI_PMCRAID=m
-CONFIG_SCSI_BFA_FC=m
 CONFIG_SCSI_DH=y
 CONFIG_SCSI_DH_RDAC=m
 CONFIG_SCSI_DH_HP_SW=m
@@ -121,8 +98,6 @@ CONFIG_MD_RAID0=y
 CONFIG_MD_RAID1=y
 CONFIG_MD_RAID10=m
 CONFIG_MD_RAID456=y
-CONFIG_MD_MULTIPATH=m
-CONFIG_MD_FAULTY=m
 CONFIG_BLK_DEV_DM=m
 CONFIG_DM_CRYPT=m
 CONFIG_DM_SNAPSHOT=m
@@ -133,146 +108,33 @@ CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_QL=m
 CONFIG_DM_MULTIPATH_ST=m
 CONFIG_DM_UEVENT=y
+CONFIG_NETDEVICES=y
 CONFIG_IFB=m
 CONFIG_MACVLAN=m
 CONFIG_VETH=m
-CONFIG_ATL2=m
-CONFIG_ATL1E=m
-CONFIG_ATL1C=m
-CONFIG_B44=m
 CONFIG_TIGON3=y
-CONFIG_BNX2X=m
-CONFIG_ENIC=m
-CONFIG_BE2NET=m
-CONFIG_E1000E=m
-CONFIG_IGB=m
-CONFIG_IGBVF=m
-CONFIG_IXGBE=m
-CONFIG_JME=m
-CONFIG_MLX4_EN=m
-# CONFIG_MLX4_DEBUG is not set
-CONFIG_KS8851_MLL=m
-CONFIG_AX88796=m
-CONFIG_AX88796_93CX6=y
-CONFIG_ETHOC=m
-CONFIG_QLA3XXX=m
-CONFIG_NETXEN_NIC=m
-CONFIG_SFC=m
 CONFIG_SGI_IOC3_ETH=y
-CONFIG_SMC91X=m
-CONFIG_SMSC911X=m
-CONFIG_NIU=m
-CONFIG_TEHUTI=m
-CONFIG_VIA_VELOCITY=m
-CONFIG_PHYLIB=y
-CONFIG_CICADA_PHY=m
-CONFIG_DAVICOM_PHY=m
-CONFIG_ICPLUS_PHY=m
-CONFIG_LSI_ET1011C_PHY=m
-CONFIG_LXT_PHY=m
-CONFIG_MARVELL_PHY=m
-CONFIG_NATIONAL_PHY=m
-CONFIG_QSEMI_PHY=m
-CONFIG_REALTEK_PHY=m
-CONFIG_SMSC_PHY=m
-CONFIG_STE10XP=m
-CONFIG_VITESSE_PHY=m
-CONFIG_ADM8211=m
-CONFIG_ATH5K=m
-CONFIG_ATH9K=m
-CONFIG_ATMEL=m
-CONFIG_PCI_ATMEL=m
-CONFIG_B43=m
-CONFIG_B43LEGACY=m
-# CONFIG_B43LEGACY_DEBUG is not set
-CONFIG_IPW2100=m
-CONFIG_IPW2100_MONITOR=y
-CONFIG_IPW2100_DEBUG=y
-CONFIG_IPW2200=m
-CONFIG_IPW2200_MONITOR=y
-CONFIG_IPW2200_PROMISCUOUS=y
-CONFIG_IPW2200_QOS=y
-CONFIG_IPW2200_DEBUG=y
-CONFIG_IWL4965=m
-CONFIG_IWL3945=m
-CONFIG_IWLWIFI=m
-CONFIG_HOSTAP=m
-CONFIG_HOSTAP_FIRMWARE=y
-CONFIG_HOSTAP_FIRMWARE_NVRAM=y
-CONFIG_HOSTAP_PLX=m
-CONFIG_HOSTAP_PCI=m
-CONFIG_HERMES=m
-# CONFIG_HERMES_CACHE_FW_ON_INIT is not set
-CONFIG_PLX_HERMES=m
-CONFIG_TMD_HERMES=m
-CONFIG_NORTEL_HERMES=m
-CONFIG_P54_COMMON=m
-CONFIG_P54_PCI=m
-CONFIG_LIBERTAS=m
-CONFIG_LIBERTAS_THINFIRM=m
-CONFIG_MWL8K=m
-CONFIG_RT2X00=m
-CONFIG_RT2400PCI=m
-CONFIG_RT2500PCI=m
-CONFIG_RT61PCI=m
-CONFIG_RT2800PCI=m
-CONFIG_RTL8180=m
-CONFIG_WL1251=m
-CONFIG_WL12XX=m
-# CONFIG_INPUT is not set
+CONFIG_INPUT_EVDEV=m
 CONFIG_SERIO_SGI_IOC3=m
-CONFIG_SERIO_LIBPS2=m
 CONFIG_SERIO_RAW=m
-CONFIG_SERIO_ALTERA_PS2=m
 # CONFIG_VT is not set
-CONFIG_NOZOMI=m
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_EXTENDED=y
 CONFIG_SERIAL_8250_MANY_PORTS=y
-CONFIG_SERIAL_8250_SHARE_IRQ=y
 CONFIG_SERIAL_8250_IOC3=y
-CONFIG_HW_RANDOM_TIMERIOMEM=m
-CONFIG_I2C_CHARDEV=m
-CONFIG_I2C_ALI1535=m
-CONFIG_I2C_ALI1563=m
-CONFIG_I2C_ALI15X3=m
-CONFIG_I2C_AMD756=m
-CONFIG_I2C_AMD8111=m
-CONFIG_I2C_I801=m
-CONFIG_I2C_ISCH=m
-CONFIG_I2C_PIIX4=m
-CONFIG_I2C_NFORCE2=m
-CONFIG_I2C_SIS5595=m
-CONFIG_I2C_SIS630=m
-CONFIG_I2C_SIS96X=m
-CONFIG_I2C_VIA=m
-CONFIG_I2C_VIAPRO=m
-CONFIG_I2C_OCORES=m
-CONFIG_I2C_PCA_PLATFORM=m
-CONFIG_I2C_SIMTEC=m
-CONFIG_I2C_TAOS_EVM=m
-CONFIG_I2C_STUB=m
 CONFIG_W1=y
 CONFIG_W1_MASTER_SGI=y
 CONFIG_W1_SLAVE_DS250X=y
 # CONFIG_HWMON is not set
 CONFIG_THERMAL=y
-# CONFIG_VGA_ARB is not set
-CONFIG_LEDS_LP3944=m
-CONFIG_LEDS_PCA955X=m
-CONFIG_LEDS_BD2802=m
-CONFIG_LEDS_TRIGGER_TIMER=m
-CONFIG_LEDS_TRIGGER_HEARTBEAT=m
-CONFIG_LEDS_TRIGGER_BACKLIGHT=m
-CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
 CONFIG_SGI_MFD_IOC3=y
+CONFIG_USB=m
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_OHCI_HCD=m
+CONFIG_USB_STORAGE=m
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_M48T35=y
 CONFIG_UIO=y
-CONFIG_UIO_AEC=m
-CONFIG_UIO_SERCOS3=m
-CONFIG_UIO_PCI_GENERIC=m
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
 CONFIG_EXT2_FS_POSIX_ACL=y
@@ -288,35 +150,22 @@ CONFIG_BTRFS_FS_POSIX_ACL=y
 CONFIG_QUOTA_NETLINK_INTERFACE=y
 CONFIG_FUSE_FS=m
 CONFIG_CUSE=m
-CONFIG_NETFS_SUPPORT=m
-CONFIG_FSCACHE=y
-CONFIG_FSCACHE_STATS=y
-CONFIG_CACHEFILES=m
 CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_TMPFS_POSIX_ACL=y
 CONFIG_SQUASHFS=m
-CONFIG_OMFS_FS=m
 CONFIG_NFS_FS=y
 CONFIG_SECURITYFS=y
 CONFIG_CRYPTO_CRYPTD=m
-CONFIG_CRYPTO_CTS=m
-CONFIG_CRYPTO_LRW=m
-CONFIG_CRYPTO_XTS=m
-CONFIG_CRYPTO_HMAC=y
-CONFIG_CRYPTO_XCBC=m
-CONFIG_CRYPTO_MD4=m
-CONFIG_CRYPTO_RMD160=m
-CONFIG_CRYPTO_SHA512=m
-CONFIG_CRYPTO_WP512=m
-CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_BLOWFISH=m
-CONFIG_CRYPTO_CAMELLIA=m
 CONFIG_CRYPTO_CAST5=m
 CONFIG_CRYPTO_CAST6=m
-CONFIG_CRYPTO_KHAZAD=m
-CONFIG_CRYPTO_SEED=m
 CONFIG_CRYPTO_SERPENT=m
-CONFIG_CRYPTO_TEA=m
 CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_XTS=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_RMD160=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_XCBC=m
 CONFIG_CRYPTO_LZO=m
Signature · 1 line
2.47.3
author
#60 lore raw

PATCH v2 49/53 MIPS: ip27_defconfig: enable pata_sgiioc4 and the DVD-ROM path

In reply to Imre Kaloz

Set CONFIG_ATA=y and CONFIG_PATA_SGIIOC4=y. Both are built in rather than modular, because ip27_defconfig lacks BLK_DEV_INITRD, so no module can load before root is mounted.

The I-brick's IOC4 ATA channel carries an ATAPI DVD-ROM drive. Change CONFIG_BLK_DEV_SR from =m to =y for the same reason, and add CONFIG_ISO9660_FS and CONFIG_UDF_FS so the disc can be mounted.

CONFIG_SCSI=y drops out of the diff: CONFIG_ATA selects SCSI, so make savedefconfig removes the explicit line.

---
 arch/mips/configs/ip27_defconfig | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/mips/configs/ip27_defconfig +5 -2
index 2dfa929a6553..2959615d656b 100644
@@ -74,10 +74,9 @@ CONFIG_NET_ACT_SKBEDIT=m
 # CONFIG_VGA_ARB is not set
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_ATA_OVER_ETH=m
-CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_CHR_DEV_ST=y
-CONFIG_BLK_DEV_SR=m
+CONFIG_BLK_DEV_SR=y
 CONFIG_CHR_DEV_SG=m
 CONFIG_CHR_DEV_SCH=m
 CONFIG_SCSI_CONSTANTS=y
@@ -91,6 +90,8 @@ CONFIG_SCSI_DH_RDAC=m
 CONFIG_SCSI_DH_HP_SW=m
 CONFIG_SCSI_DH_EMC=m
 CONFIG_SCSI_DH_ALUA=m
+CONFIG_ATA=y
+CONFIG_PATA_SGIIOC4=y
 CONFIG_MD=y
 CONFIG_BLK_DEV_MD=y
 CONFIG_MD_LINEAR=m
@@ -150,6 +151,8 @@ CONFIG_BTRFS_FS_POSIX_ACL=y
 CONFIG_QUOTA_NETLINK_INTERFACE=y
 CONFIG_FUSE_FS=m
 CONFIG_CUSE=m
+CONFIG_ISO9660_FS=y
+CONFIG_UDF_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_TMPFS_POSIX_ACL=y
Signature · 1 line
2.47.3
author
#61 lore raw

PATCH v2 50/53 MIPS: SGI-IP27: add L1 front-panel LED and display requests

In reply to Imre Kaloz

Add l1_set_leds(), which sets the Fuel and Tezro front-panel LEDs, and l1_set_display(), which writes line 2 of the Tezro's L1 display. Both can be called from a panic notifier.

---
 arch/mips/include/asm/sn/l1.h | 16 +++++++++
 arch/mips/sgi-ip27/ip27-l1.c  | 67 +++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
arch/mips/include/asm/sn/l1.h +16 -0
index f9fa8a8051e6..42611fe51a3a 100644
@@ -7,6 +7,7 @@
 #ifndef __ASM_SN_L1_H
 #define __ASM_SN_L1_H
 
+#include <linux/bits.h>
 #include <linux/types.h>
 
 /*
@@ -15,8 +16,23 @@
  */
 #define L1_BOARD_COMPONENT_MAX	8
 
+/*
+ * Front-panel LEDs of a Fuel or a deskside Tezro. ON and BLINK switch off
+ * every LED outside the mask; OFF switches off only the masked ones.
+ */
+#define L1_LED_RED		BIT(0)
+#define L1_LED_WHITE		BIT(1)
+
+#define L1_LED_ON		0
+#define L1_LED_OFF		1
+#define L1_LED_BLINK		2
+
+#define L1_DISPLAY_WIDTH	16
+
 int l1_exec_command(const char *cmd);
 int l1_read_board_partnum(unsigned int component, char *buf, size_t len);
 int l1_read_brick_type(void);
+int l1_set_leds(unsigned int mask, unsigned int state);
+int l1_set_display(const char *text);
 
 #endif /* __ASM_SN_L1_H */
arch/mips/sgi-ip27/ip27-l1.c +67 -0

92 lines not on this page · raw message

Signature · 1 line
2.47.3
author
#62 lore raw

PATCH v2 51/53 leds: Add driver for the SGI Fuel and Tezro front-panel LEDs

In reply to Imre Kaloz

The SGI Fuel and Tezro front-panel LEDs are set through the L1 system controller, whose LED request switches off every LED outside its mask, so send the pattern of both LEDs on each change. Probe takes over the PROM's state without writing it.

---
 drivers/leds/Kconfig     |  12 ++++
 drivers/leds/Makefile    |   1 +
 drivers/leds/leds-ip35.c | 144 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 157 insertions(+)
 create mode 100644 drivers/leds/leds-ip35.c
drivers/leds/Kconfig +12 -0
index d0d3182236be..9ca75364264b 100644
@@ -1035,6 +1035,18 @@ config LEDS_IP30
 	  To compile this driver as a module, choose M here: the module
 	  will be called leds-ip30.
 
+config LEDS_IP35
+	tristate "LED support for SGI Fuel and Tezro"
+	depends on LEDS_CLASS
+	depends on SGI_IP27
+	help
+	  This option enables support for the red and white front-panel
+	  LEDs of SGI Fuel and Tezro workstations, which the L1 system
+	  controller drives.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called leds-ip35.
+
 config LEDS_ACER_A500
 	tristate "Power button LED support for Acer Iconia Tab A500"
 	depends on LEDS_CLASS && MFD_ACER_A500_EC
drivers/leds/Makefile +1 -0
index a68244bd50fb..b45d1d70c431 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_LEDS_GPIO_REGISTER)	+= leds-gpio-register.o
 obj-$(CONFIG_LEDS_HP6XX)		+= leds-hp6xx.o
 obj-$(CONFIG_LEDS_INTEL_SS4200)		+= leds-ss4200.o
 obj-$(CONFIG_LEDS_IP30)			+= leds-ip30.o
+obj-$(CONFIG_LEDS_IP35)			+= leds-ip35.o
 obj-$(CONFIG_LEDS_IPAQ_MICRO)		+= leds-ipaq-micro.o
 obj-$(CONFIG_LEDS_IS31FL319X)		+= leds-is31fl319x.o
 obj-$(CONFIG_LEDS_IS31FL32XX)		+= leds-is31fl32xx.o
drivers/leds/leds-ip35.c new file +144 -0

144 lines not on this page · raw message

Signature · 1 line
2.47.3
maintainer
#63 lore raw

Re: [PATCH v2 51/53] leds: Add driver for the SGI Fuel and Tezro front-panel LEDs

--- checkpatch.pl: clean (0 issues) ---

Quoted 62 lines · Imre Kaloz

The SGI Fuel and Tezro front-panel LEDs are set through the L1 system controller, whose LED request switches off every LED outside its mask, so send the pattern of both LEDs on each change. Probe takes over the PROM's state without writing it.

---
 drivers/leds/Kconfig     |  12 ++++
 drivers/leds/Makefile    |   1 +
 drivers/leds/leds-ip35.c | 144 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 157 insertions(+)
 create mode 100644 drivers/leds/leds-ip35.c
drivers/leds/Kconfig +12 -0
index d0d3182236be..9ca75364264b 100644
@@ -1035,6 +1035,18 @@ config LEDS_IP30
 	  To compile this driver as a module, choose M here: the module
 	  will be called leds-ip30.
 
+config LEDS_IP35
+	tristate "LED support for SGI Fuel and Tezro"
+	depends on LEDS_CLASS
+	depends on SGI_IP27
+	help
+	  This option enables support for the red and white front-panel
+	  LEDs of SGI Fuel and Tezro workstations, which the L1 system
+	  controller drives.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called leds-ip35.
+
 config LEDS_ACER_A500
 	tristate "Power button LED support for Acer Iconia Tab A500"
 	depends on LEDS_CLASS && MFD_ACER_A500_EC
drivers/leds/Makefile +1 -0
index a68244bd50fb..b45d1d70c431 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_LEDS_GPIO_REGISTER)	+= leds-gpio-register.o
 obj-$(CONFIG_LEDS_HP6XX)		+= leds-hp6xx.o
 obj-$(CONFIG_LEDS_INTEL_SS4200)		+= leds-ss4200.o
 obj-$(CONFIG_LEDS_IP30)			+= leds-ip30.o
+obj-$(CONFIG_LEDS_IP35)			+= leds-ip35.o
 obj-$(CONFIG_LEDS_IPAQ_MICRO)		+= leds-ipaq-micro.o
 obj-$(CONFIG_LEDS_IS31FL319X)		+= leds-is31fl319x.o
 obj-$(CONFIG_LEDS_IS31FL32XX)		+= leds-is31fl32xx.o
drivers/leds/leds-ip35.c new file +8 -0
new file mode 100644
index 000000000000..fba918265e3d
@@ -0,0 +1,144 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * LED driver for the SGI Fuel and Tezro front panels, which the L1
+ * system controller drives.
+ *
+ * Copyright (C) 2026 Imre Kaloz <[email protected]>
+ */
+

drivers/leds/leds-ip35.c line 18

Quoted 10 lines
drivers/leds/leds-ip35.c new file +10 -0
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
+
+#include <dt-bindings/leds/common.h>
+
+#include <asm/sn/l1.h>
+
+struct ip35_leds;

Can you find another way to avoid: leds->led->leds->led->leds ...

drivers/leds/leds-ip35.c line 28

Quoted 9 lines
drivers/leds/leds-ip35.c new file +9 -0
+struct ip35_led {
+	struct led_classdev cdev;
+	struct ip35_leds *leds;
+	unsigned int mask;
+	unsigned int state;
+};
+
+struct ip35_leds {
+	struct mutex lock;	/* protects ->state of both LEDs */

Not sure that comment is required.

Quoted 5 lines
drivers/leds/leds-ip35.c new file +5 -0
+	struct ip35_led led[2];
+};
+
+/*
+ * ON and BLINK switch off every LED outside their mask, so each change

drivers/leds/leds-ip35.c line 43

Quoted 10 lines
drivers/leds/leds-ip35.c new file +10 -0
+ * sends the pattern of both LEDs. A steady LED next to a blinking one
+ * cannot be shown; the blinking one wins.
+ */
+static int ip35_led_update(struct ip35_led *led, unsigned int state)
+{
+	struct ip35_leds *leds = led->leds;
+	unsigned int old, on = 0, blink = 0;
+	int i, ret;
+
+	mutex_lock(&leds->lock);

guard(mutex)(&leds->lock) ?

drivers/leds/leds-ip35.c line 48

Quoted 5 lines
drivers/leds/leds-ip35.c new file +5 -0
+
+	old = led->state;
+	led->state = state;
+
+	for (i = 0; i < ARRAY_SIZE(leds->led); i++) {

for (int i = 0; ...

Quoted 27 lines
drivers/leds/leds-ip35.c new file +27 -0
+		if (leds->led[i].state == L1_LED_ON)
+			on |= leds->led[i].mask;
+		else if (leds->led[i].state == L1_LED_BLINK)
+			blink |= leds->led[i].mask;
+	}
+
+	if (blink)
+		ret = l1_set_leds(blink, L1_LED_BLINK);
+	else if (on)
+		ret = l1_set_leds(on, L1_LED_ON);
+	else
+		ret = l1_set_leds(L1_LED_RED | L1_LED_WHITE, L1_LED_OFF);
+
+	if (ret)
+		led->state = old;
+
+	mutex_unlock(&leds->lock);
+
+	return ret;
+}
+
+static int ip35_led_set(struct led_classdev *cdev, enum led_brightness value)
+{
+	struct ip35_led *led = container_of(cdev, struct ip35_led, cdev);
+
+	return ip35_led_update(led, value ? L1_LED_ON : L1_LED_OFF);
+}

drivers/leds/leds-ip35.c line 85

Quoted 10 lines
drivers/leds/leds-ip35.c new file +10 -0
+
+/* The L1 blinks at a fixed 2 s period of its own, whatever the delays. */
+static int ip35_led_blink_set(struct led_classdev *cdev,
+			      unsigned long *delay_on,
+			      unsigned long *delay_off)
+{
+	struct ip35_led *led = container_of(cdev, struct ip35_led, cdev);
+
+	*delay_on = 1000;
+	*delay_off = 1000;

If the hardware only supports a fixed 2s period (1000ms on / 1000ms off), shouldn't we only accept it when '*delay_on == 0 && *delay_off == 0' (or when both are already 1000) and return '-EINVAL' otherwise so the LED core falls back to software blinking for other requested rates?

Quoted 18 lines
drivers/leds/leds-ip35.c new file +18 -0
+
+	return ip35_led_update(led, L1_LED_BLINK);
+}
+
+/* The PROM leaves the white LED lit and the red one dark. */
+static const struct {
+	const char *name;
+	unsigned int mask;
+	unsigned int state;
+} ip35_led_info[] = {
+	{ "white:" LED_FUNCTION_STATUS, L1_LED_WHITE, L1_LED_ON },
+	{ "red:" LED_FUNCTION_FAULT, L1_LED_RED, L1_LED_OFF },
+};
+
+static int ip35_leds_probe(struct platform_device *pdev)
+{
+	struct ip35_leds *leds;
+	int i, ret;

drivers/leds/leds-ip35.c line 113

Quoted 10 lines
drivers/leds/leds-ip35.c new file +10 -0
+
+	leds = devm_kzalloc(&pdev->dev, sizeof(*leds), GFP_KERNEL);
+	if (!leds)
+		return -ENOMEM;
+
+	ret = devm_mutex_init(&pdev->dev, &leds->lock);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < ARRAY_SIZE(leds->led); i++) {

As above.

Quoted 15 lines
drivers/leds/leds-ip35.c new file +15 -0
+		struct ip35_led *led = &leds->led[i];
+
+		led->leds = leds;
+		led->mask = ip35_led_info[i].mask;
+		led->state = ip35_led_info[i].state;
+		led->cdev.name = ip35_led_info[i].name;
+		led->cdev.max_brightness = 1;
+		led->cdev.brightness = led->state == L1_LED_ON;
+		led->cdev.brightness_set_blocking = ip35_led_set;
+		led->cdev.blink_set = ip35_led_blink_set;
+
+		ret = devm_led_classdev_register(&pdev->dev, &led->cdev);
+		if (ret)
+			return ret;
+	}

drivers/leds/leds-ip35.c line 138

Quoted 10 lines
drivers/leds/leds-ip35.c new file +10 -0
+
+	return 0;
+}
+
+static struct platform_driver ip35_leds_driver = {
+	.probe		= ip35_leds_probe,
+	.driver		= {
+		.name	= "ip35-leds",
+	},
+};

This padding is creeping me out.

Why would you line-up things that aren't at the same level?

Quoted 9 lines
drivers/leds/leds-ip35.c new file +6 -0
+module_platform_driver(ip35_leds_driver);
+
+MODULE_AUTHOR("Imre Kaloz <[email protected]>");
+MODULE_DESCRIPTION("SGI Fuel and Tezro front-panel LED driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:ip35-leds");
Signature · 1 line
2.47.3
Signature · 1 line
Lee Jones
author
#64 lore raw

Re: [PATCH v2 51/53] leds: Add driver for the SGI Fuel and Tezro front-panel LEDs

Quoted 3 lines · Lee Jones
Quoted 1 line

+struct ip35_leds;

Can you find another way to avoid: leds->led->leds->led->leds ...

I can, and it comes out nicer too. The LED core registers the classdev with &pdev->dev as its parent, so the callbacks can get at the shared state through dev_get_drvdata(cdev->dev->parent). I'll set it with platform_set_drvdata() before the registration loop, drop the forward declaration and the back-pointer, and have the update helper take both the shared state and the LED:

static int ip35_led_update(struct ip35_leds *leds,
struct ip35_led *led, unsigned int state)

Quoted 3 lines

drivers/leds/leds-ip35.c line 28

Quoted 1 line
drivers/leds/leds-ip35.c new file +1 -0
+	struct mutex lock;	/* protects ->state of both LEDs */

Not sure that comment is required.

Agreed, gone.

Quoted 3 lines

drivers/leds/leds-ip35.c line 43

Quoted 1 line
drivers/leds/leds-ip35.c new file +1 -0
+	mutex_lock(&leds->lock);

guard(mutex)(&leds->lock) ?

Will do. The explicit mutex_unlock() goes with it.

Quoted 3 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	for (i = 0; i < ARRAY_SIZE(leds->led); i++) {

for (int i = 0; ...

Will do, here and in probe.

Quoted 8 lines

drivers/leds/leds-ip35.c line 85

Quoted 2 lines
drivers/leds/leds-ip35.c new file +2 -0
+	*delay_on = 1000;
+	*delay_off = 1000;

If the hardware only supports a fixed 2s period (1000ms on / 1000ms off), shouldn't we only accept it when '*delay_on == 0 && *delay_off == 0' (or when both are already 1000) and return '-EINVAL' otherwise so the LED core falls back to software blinking for other requested rates?

You're right, and that is the better behaviour.

Quoted 10 lines

drivers/leds/leds-ip35.c line 138

Quoted 6 lines
drivers/leds/leds-ip35.c new file +6 -0
+static struct platform_driver ip35_leds_driver = {
+	.probe		= ip35_leds_probe,
+	.driver		= {
+		.name	= "ip35-leds",
+	},
+};

This padding is creeping me out.

Why would you line-up things that aren't at the same level?

Old habits, and no good reason beyond that :) The tab alignment on .probe, .driver and .name goes; v3 will use a single space before each '='.

Thanks a lot for the thorough review,

Imre

author
#65 lore raw

PATCH v2 52/53 MIPS: SGI-IP27: show the OS state on the Fuel and Tezro front panels

In reply to Imre Kaloz

Register the front-panel LED device on a Fuel and a deskside Tezro and blink the red LED on panic. A Tezro also shows "Linux booting", "Linux running" or "Linux panic" on line 2 of its L1 display.

---
 arch/mips/sgi-ip27/ip27-init.c | 52 ++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
arch/mips/sgi-ip27/ip27-init.c +52 -0
index e657155ef7c9..f7de09515c0c 100644
@@ -13,6 +13,9 @@
 #include <linux/smp.h>
 #include <linux/mm.h>
 #include <linux/export.h>
+#include <linux/notifier.h>
+#include <linux/panic_notifier.h>
+#include <linux/platform_device.h>
 #include <linux/cpumask.h>
 #include <linux/ctype.h>
 #include <asm/bootinfo.h>
@@ -122,6 +125,8 @@ static const struct {
 	{ 'Q', "SGI Tezro Rackmount", NULL },
 };
 
+static int ip27_brick_type;
+
 static bool __init ip27_has_graphics(void)
 {
 	nasid_t nasid;
@@ -145,6 +150,7 @@ static void __init ip27_set_machine_name(void)
 	brick_type = l1_read_brick_type();
 	if (brick_type < 0)
 		return;
+	ip27_brick_type = brick_type;
 
 	gfx = ip27_has_graphics();
 
@@ -165,6 +171,52 @@ static void __init ip27_set_machine_name(void)
 		gfx ? "with" : "without");
 }
 
+/*
+ * A Fuel (brick type 'A') and a deskside Tezro ('9') have L1-driven
+ * front-panel LEDs, the Tezro also an L1 display. A blinking red LED,
+ * with the white one off, marks a panic.
+ */
+static int ip27_panel_panic(struct notifier_block *nb, unsigned long event,
+			    void *ptr)
+{
+	l1_set_leds(L1_LED_RED, L1_LED_BLINK);
+	if (ip27_brick_type == '9')
+		l1_set_display("Linux panic");
+
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block ip27_panel_panic_nb = {
+	.notifier_call = ip27_panel_panic,
+};
+
+static int __init ip27_panel_init(void)
+{
+	struct platform_device *pdev;
+
+	if (ip27_brick_type != 'A' && ip27_brick_type != '9')
+		return 0;
+
+	atomic_notifier_chain_register(&panic_notifier_list,
+				       &ip27_panel_panic_nb);
+	if (ip27_brick_type == '9')
+		l1_set_display("Linux booting");
+
+	pdev = platform_device_register_simple("ip35-leds", PLATFORM_DEVID_NONE,
+					       NULL, 0);
+	return PTR_ERR_OR_ZERO(pdev);
+}
+arch_initcall(ip27_panel_init);
+
+static int __init ip27_panel_running(void)
+{
+	if (ip27_brick_type == '9')
+		l1_set_display("Linux running");
+
+	return 0;
+}
+late_initcall_sync(ip27_panel_running);
+
 /*
  * Prefer ttyS0 at the baud rate the IP35 PROM recorded for its console
  * UART in the KLCONFIG header.
Signature · 1 line
2.47.3
author
#66 lore raw

PATCH v2 53/53 MIPS: ip27_defconfig: enable the Fuel and Tezro front-panel LEDs

In reply to Imre Kaloz

Enable the LED class with its timer, heartbeat and default-on triggers, and build the SGI Fuel and Tezro front-panel LED driver as a module.

---
 arch/mips/configs/ip27_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
arch/mips/configs/ip27_defconfig +7 -0
index 2959615d656b..74f4a88f927a 100644
@@ -133,6 +133,13 @@ CONFIG_USB=m
 CONFIG_USB_EHCI_HCD=m
 CONFIG_USB_OHCI_HCD=m
 CONFIG_USB_STORAGE=m
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_IP35=m
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_M48T35=y
 CONFIG_UIO=y
Signature · 1 line
2.47.3
maintainer
#67 lore raw
In reply to Imre Kaloz

Hello Imre,

This series is rather large.

I would recommend you to submit a minimal patch series to get the basic support for your new board, such that it can boot with a ramdisk and serial console.

Then in the next cycle, send separate series for ata, net, leds, mfc, rtc, etc.

Kind regards,
Niklas

author
#68 lore raw

Hello Niklas,

Quoted 10 lines · Niklas Cassel

Hello Imre,

This series is rather large.

I would recommend you to submit a minimal patch series to get the basic support for your new board, such that it can boot with a ramdisk and serial console.

Then in the next cycle, send separate series for ata, net, leds, mfc, rtc, etc.

Hi Niklas,

Thanks for having a look. I checked what the minimum is: 31 of the 53 patches (1, 6-24, 26-29, 31-36 and 39) boot a Tezro to a ramdisk with a serial console. Two mfd/ioc3 patches have to be part of that, as they provide the console UARTs (31 for IOC4 on the Tezro, 36 for the IOC3 on the Fuel). The rest separates cleanly into follow-ups: the remaining Bridge fixes (2-5), ioc3-eth (25, 38), rtc (30), the IO8 serial IRQs (37), machine identification and the Odyssey widget (40-44), ata (45-47, 49), the defconfig refresh (48) and the LEDs (50-53).

I’ll wait for Thomas to say whether he prefers it split that way for v3.

Thanks,
Imre

maintainer
#69 lore raw
In reply to Imre Kaloz
Quoted 2 lines · On Tue, 13 Oct 2026 15:16:20 +0200 Imre Kaloz wrote:

This series adds support for the SGI machines built around the Bedrock hub (IP35), such as Fuel and Tezro, to the IP27 platform code.

Why do we need support for machines discontinued 20+ years ago?

author
#70 lore raw
Quoted 1 line · On Tue, 20 Oct 2026 11:06:19 -0700 Jakub Kicinski wrote:

Why do we need support for machines discontinued 20+ years ago?

For netdev the question is smaller than the series: patches 25 and 38, 44 lines in ioc3-eth, a driver that is already in tree for the same part on IP27 and IP30. Patch 25 is a no-op on both of those (the bit it tests is always set behind a classic Bridge); patch 38 is a MAC-address fallback. I should have said in the cover that the series is meant to go through the MIPS tree and that I'm only after an Ack for those two -- sorry for the noise on your queue.

As for why at all: same reason IP27, IP30 and IP32 are in tree. The hardware is in use, Thomas maintains the platform, and people run and test it; "discontinued" has never been the removal criterion, lack of maintainers has. IP35 is IP27's direct successor on the same Hub/XTalk/Bridge architecture with the same IOC3, plus its successor IOC4, so most of the series is teaching existing code about one more hub generation. And these boxes still earn their keep as a stress case for arch and core code -- e.g. the kmem_cache_destroy() race that just turned up on my Ultra 45:
https://lore.kernel.org/all/atDCYwNfKW3m6YXh@thinkstation/

Imre

maintainer
#71 lore raw
Quoted 11 lines · On Tue, 20 Oct 2026 22:42:13 +0200 Imre Kaloz wrote:
Quoted 1 line · On Tue, 20 Oct 2026 11:06:19 -0700 Jakub Kicinski wrote:

Why do we need support for machines discontinued 20+ years ago?

For netdev the question is smaller than the series: patches 25 and 38, 44 lines in ioc3-eth, a driver that is already in tree for the same part on IP27 and IP30. Patch 25 is a no-op on both of those (the bit it tests is always set behind a classic Bridge); patch 38 is a MAC-address fallback. I should have said in the cover that the series is meant to go through the MIPS tree and that I'm only after an Ack for those two -- sorry for the noise on your queue.

Quoted 10 lines

As for why at all: same reason IP27, IP30 and IP32 are in tree. The hardware is in use, Thomas maintains the platform, and people run and test it; "discontinued" has never been the removal criterion, lack of maintainers has. IP35 is IP27's direct successor on the same Hub/XTalk/Bridge architecture with the same IOC3, plus its successor IOC4, so most of the series is teaching existing code about one more hub generation. And these boxes still earn their keep as a stress case for arch and core code -- e.g. the kmem_cache_destroy() race that just turned up on my Ultra 45:
https://lore.kernel.org/all/atDCYwNfKW3m6YXh@thinkstation/

I don't think you answered my question, or at least I'm too daft to catch what you mean. IP35 was not supported so nobody is using it with Linux today. You're adding the support, and since it's a platform discontinued 20 years ago there's 0 chance of real users of any of this code.

What am I missing?

author
#72 lore raw
Quoted 7 lines · On Tue, 20 Oct 2026 14:56:11 -0700 Jakub Kicinski wrote:

I don't think you answered my question, or at least I'm too daft to catch what you mean. IP35 was not supported so nobody is using it with Linux today. You're adding the support, and since it's a platform discontinued 20 years ago there's 0 chance of real users of any of this code.

What am I missing?

The users are the people running these machines, the same population as for IP27 and IP30, and the ioc3-eth driver in net/ exists for them today. The series was developed and tested on a Fuel and a Tezro in regular use, so "nobody is using it with Linux" is true only in the sense that the support isn't merged yet; that was equally true of IP30 when it went in for 5.5, and of every port before it.

The kernel's test for a platform isn't commercial relevance, it's a maintainer, which Thomas is, and testers, which this series has. If netdev doesn't want to spend time on it, say so and I'll ask Thomas to take the two ioc3-eth patches through the MIPS tree.

Imre

maintainer
#73 lore raw
Quoted 7 lines · On Wed, 21 Oct 2026 11:05:55 +0200 Imre Kaloz wrote:
Quoted 6 lines · On Tue, 20 Oct 2026 14:56:11 -0700 Jakub Kicinski wrote:

I don't think you answered my question, or at least I'm too daft to catch what you mean. IP35 was not supported so nobody is using it with Linux today. You're adding the support, and since it's a platform discontinued 20 years ago there's 0 chance of real users of any of this code.

Quoted 8 lines
Quoted 1 line

What am I missing?

The users are the people running these machines, the same population as for IP27 and IP30, and the ioc3-eth driver in net/ exists for them today. The series was developed and tested on a Fuel and a Tezro in regular use, so "nobody is using it with Linux" is true only in the sense that the support isn't merged yet; that was equally true of IP30 when it went in for 5.5, and of every port before it.

Not sure if you followed the discussions at the recent maintainer summit but we are now allowed to be more opinionated about code we merge. Merging code just to test that code seems like entertainment for the authors, not useful development.

Quoted 4 lines

The kernel's test for a platform isn't commercial relevance, it's a maintainer, which Thomas is, and testers, which this series has. If netdev doesn't want to spend time on it, say so and I'll ask Thomas to take the two ioc3-eth patches through the MIPS tree.

Not how subsystem boundaries work. You have to repost the two networking patches to get them merged via net-next. Our CIs will not trigger for partial posting to netdev.

#74 lore raw
Quoted 11 lines · Jakub Kicinski
Quoted 6 lines

The users are the people running these machines, the same population as for IP27 and IP30, and the ioc3-eth driver in net/ exists for them today. The series was developed and tested on a Fuel and a Tezro in regular use, so "nobody is using it with Linux" is true only in the sense that the support isn't merged yet; that was equally true of IP30 when it went in for 5.5, and of every port before it.

Not sure if you followed the discussions at the recent maintainer summit but we are now allowed to be more opinionated about code we merge. Merging code just to test that code seems like entertainment for the authors, not useful development.

I thought the event was by invitation only.

Anyway, this seems to me like discouraging enthusiasts who do their work
outside their day job from making contributions. Their natural target are commercially worthless systems, since working for free on commercially valuable systems would be taking away someone's bread and I think grossly undeserved support for corporations. Taking this stance effectively would be cutting Linux off from its origins and making it a commercial project.

Please let's not go down this route and only base the acceptance, or not,
of submissions on quality merits. Many of us took this route to Linux, by showing competence in public with work done for free, and some of us still enjoy such side project even if we do have a day job now that involves Linux development. Let's not close this option to people.

Maciej

maintainer
#75 lore raw
Quoted 8 lines · On Thu, 22 Oct 2026 20:28:25 +0100 (BST) Maciej W. Rozycki wrote:
Quoted 7 lines · Jakub Kicinski
Quoted 6 lines

The users are the people running these machines, the same population as for IP27 and IP30, and the ioc3-eth driver in net/ exists for them today. The series was developed and tested on a Fuel and a Tezro in regular use, so "nobody is using it with Linux" is true only in the sense that the support isn't merged yet; that was equally true of IP30 when it went in for 5.5, and of every port before it.

Quoted 6 lines
Quoted 4 lines

Not sure if you followed the discussions at the recent maintainer summit but we are now allowed to be more opinionated about code we merge. Merging code just to test that code seems like entertainment for the authors, not useful development.

I thought the event was by invitation only.

LWN posts a great summary.

Quoted 6 lines

Anyway, this seems to me like discouraging enthusiasts who do their work
outside their day job from making contributions. Their natural target are commercially worthless systems, since working for free on commercially valuable systems would be taking away someone's bread and I think grossly undeserved support for corporations. Taking this stance effectively would be cutting Linux off from its origins and making it a commercial project.

Or. Perhaps. By pushing this useless retro-hobbist hogwash you're contributing to the burn out of genuine maintainers, pushing the project into the hands of people who do have anterior motives. Who is to say..

Quoted 5 lines

Please let's not go down this route and only base the acceptance, or not,
of submissions on quality merits. Many of us took this route to Linux, by showing competence in public with work done for free, and some of us still enjoy such side project even if we do have a day job now that involves Linux development. Let's not close this option to people.

Who cares about quality of code nobody will run?