Skip to content

Instantly share code, notes, and snippets.

@nsafran1217
Last active March 10, 2026 02:12
Show Gist options
  • Select an option

  • Save nsafran1217/4fe85709845425e60c359cbea0f4a42d to your computer and use it in GitHub Desktop.

Select an option

Save nsafran1217/4fe85709845425e60c359cbea0f4a42d to your computer and use it in GitHub Desktop.
SN2 Altix Kernel Patches
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_dma.c b/arch/ia64/sn/pci/pcibr/pcibr_dma.c
index 1e863b277ac9..6b632c290af2 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_dma.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_dma.c
@@ -235,7 +235,7 @@ pcibr_dma_unmap(struct pci_dev *hwdev, dma_addr_t dma_handle, int direction)
* unlike the PIC Device(x) Write Request Buffer Flush register.
*/
-void sn_dma_flush(u64 addr)
+void sn_dma_flush(unsigned long addr)
{
nasid_t nasid;
int is_tio;
--- a/drivers/tty/serial/sn_console.c 2026-03-10 02:01:29.574046221 +0000
+++ b/drivers/tty/serial/sn_console.c 2026-03-10 02:07:36.770519083 +0000
@@ -328,6 +328,8 @@
*/
static void snp_start_tx(struct uart_port *port)
{
+ if (uart_circ_empty(&port->state->xmit))
+ return;
if (sal_console_port.sc_ops->sal_wakeup_transmit)
sal_console_port.sc_ops->sal_wakeup_transmit(&sal_console_port,
TRANSMIT_BUFFERED);
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index d63809a6adfa..2446ffa0957a 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -195,6 +195,9 @@ sn_io_slot_fixup(struct pci_dev *dev)
if (res->parent && res->parent->child)
release_resource(res);
+ /* Ensure resource is marked as assigned so parent lookups succeed */
+ res->flags &= ~IORESOURCE_UNSET;
+
if (res->flags & IORESOURCE_IO)
insert_resource(&ioport_resource, res);
else
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 2446ffa0957a..b3c5e7a1d4f2 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -149,6 +149,7 @@ void
sn_io_slot_fixup(struct pci_dev *dev)
{
int idx;
+ int ret;
struct resource *res;
unsigned long size;
struct pcidev_info *pcidev_info;
@@ -198,10 +199,24 @@ sn_io_slot_fixup(struct pci_dev *dev)
/* Ensure resource is marked as assigned so parent lookups succeed */
res->flags &= ~IORESOURCE_UNSET;
- if (res->flags & IORESOURCE_IO)
- insert_resource(&ioport_resource, res);
- else
- insert_resource(&iomem_resource, res);
+ if (res->flags & IORESOURCE_IO) {
+ ret = insert_resource(&ioport_resource, res);
+ if (ret) {
+ dev_warn(&dev->dev,
+ "SN: failed to insert IO resource %d %pR, forcing parent\n",
+ idx, res);
+ res->parent = &ioport_resource;
+ }
+ } else {
+ ret = insert_resource(&iomem_resource, res);
+ if (ret) {
+ dev_warn(&dev->dev,
+ "SN: failed to insert MEM resource %d %pR, forcing parent\n",
+ idx, res);
+ res->parent = &iomem_resource;
+ }
+ }
+
/*
* If ROM, mark as shadowed in PROM.
*/
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -29,6 +29,7 @@
#include <linux/nodemask.h>
#include <linux/pm.h>
#include <linux/efi.h>
+#include <linux/vmalloc.h>
#include <asm/io.h>
#include <asm/sal.h>
@@ -784,3 +785,21 @@
}
EXPORT_SYMBOL(sn_prom_feature_available);
+/*
+ * SN2-specific module_alloc: allocate executable vmalloc memory WITHOUT
+ * VM_FLUSH_RESET_PERMS.
+ *
+ * That flag is useless on ia64 (set_memory_nx, set_memory_rw, and
+ * set_direct_map_*_noflush are all no-ops). But it causes
+ * vm_remove_mappings() to force immediate global TLB flushes during
+ * vfree. On SN2, these extra SHUB PTC.GA broadcasts during module
+ * init section cleanup interfere with concurrent PIO/MMIO traffic.
+ *
+ * See commit 868b104d7379 ("vmalloc: New flag for flush reset").
+ */
+void *module_alloc(unsigned long size)
+{
+ return __vmalloc_node_range(size, 1, VMALLOC_START, VMALLOC_END,
+ GFP_KERNEL, PAGE_KERNEL, 0,
+ NUMA_NO_NODE, __builtin_return_address(0));
+}
diff --git a/arch/ia64/sn/kernel/iomv.c b/arch/ia64/sn/kernel/iomv.c
index 2b22a71663c1..749a2cf399c0 100644
--- a/arch/ia64/sn/kernel/iomv.c
+++ b/arch/ia64/sn/kernel/iomv.c
@@ -75,6 +75,10 @@ void __sn_mmiowb(void)
volatile unsigned long *adr = pda->pio_write_status_addr;
unsigned long val = pda->pio_write_status_val;
+ /*fix for commit 49ca6462fc9e0f5a67cd96eeddd844efc3fb33b9*/
+ if (adr == NULL)
+ return;
+
while ((*adr & SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK) != val)
cpu_relax();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment