Skip to contentSkip to conversation

m68k: amiga: lower min_low_pfn to make RAM DMA-able

PATCH In review Steffen A. Mork 2 participants 2 messages Nov 5 – Dec 3 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: amiga: lower min_low_pfn to make RAM DMA-able

With reference to the patch by Denis Ahrens for the MVME16x platform, this patch works in the same way for the Amiga. Currently, all DMA-capable SCSI controllers have ceased to function due to the same underlying issue. While the wd33c93=nodma parameter can be used as a workaround for the wd33c93 driver on the Amiga 3000, other drivers —- such as the zorro_esp driver (tested on a Blizzard 2060) -— fail completely once memory has been released by free_initmem().

Applying this patch restores proper functionality to both the Amiga 3000 SCSI controller (without requiring the wd33c93=nodma parameter) and the Blizzard 2060.

---
 arch/m68k/amiga/config.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
arch/m68k/amiga/config.c +36 -0
index 6e89e7f7e98b..c48aa3dbd837 100644
@@ -24,6 +24,7 @@
 #include <linux/interrupt.h>
 #include <linux/zorro.h>
 #include <linux/module.h>
+#include <linux/memblock.h>
 #include <linux/keyboard.h>
 
 #include <asm/bootinfo.h>
@@ -854,3 +855,38 @@ static void amiga_get_hardware_list(struct seq_file *m)
 #ifdef CONFIG_VT
 EXPORT_SYMBOL_GPL(key_maps);
 #endif
+
+/*
+ * Make all system RAM available for DMA.
+ *
+ * paging_init() sets min_low_pfn to the first free page
+ * after the kernel image. free_initmem() later releases
+ * the init sections, but min_low_pfn remains unchanged.
+ *
+ * This prevents dma_capable() from mapping those pages.
+ */
+static int __init amiga_init_dma_pfn_limit(void)
+{
+	unsigned long pfn = ULONG_MAX;
+	int i;
+
+	for (i = 0; i < m68k_num_memory; i++) {
+		unsigned long mem_pfn;
+
+		mem_pfn = m68k_memory[i].addr >> PAGE_SHIFT;
+
+		if (mem_pfn < pfn)
+			pfn = mem_pfn;
+	}
+
+	if (pfn >= min_low_pfn)
+		return 0;
+
+	pr_info("Amiga: lowering min_low_pfn 0x%lx -> 0x%lx\n",
+		min_low_pfn, pfn);
+
+	min_low_pfn = pfn;
+
+	return 0;
+}
+arch_initcall(amiga_init_dma_pfn_limit);
Signature · 1 line
2.43.0
#1 lore raw

Hi Steffen,

Quoted 8 lines · Steffen A. Mork

With reference to the patch by Denis Ahrens for the MVME16x platform, this patch works in the same way for the Amiga. Currently, all DMA-capable SCSI controllers have ceased to function due to the same underlying issue. While the wd33c93=nodma parameter can be used as a workaround for the wd33c93 driver on the Amiga 3000, other drivers —- such as the zorro_esp driver (tested on a Blizzard 2060) -— fail completely once memory has been released by free_initmem().

Can you check if the following works for you?:

  --- a/arch/m68k/mm/motorola.c
  +++ b/arch/m68k/mm/motorola.c
  @@ void __init paging_init(void)
          unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
          unsigned long min_addr, max_addr;
          unsigned long addr;
          int i;
  @@
          high_memory = phys_to_virt(max_addr) + 1;

- min_low_pfn = availmem >> PAGE_SHIFT;

  +       min_low_pfn = min_addr >> PAGE_SHIFT;
          max_pfn = max_low_pfn = (max_addr >> PAGE_SHIFT) + 1;

Cheers,

Daniel