Skip to contentSkip to conversation

Atari kernel-in-FastRAM patches v3

PATCH Applied Michael Schmitz 2 participants 13 messages Mar 31, 2014 – May 28, 2014

Subsystems (5)
lore
Share & tools
lore
author maintainer
#6 lore raw

PATCH v3 4/4 m68k/atari - atari_scsi: use correct virt/phys translation for DMA buffer

In reply to Michael Schmitz

With the kernel running from FastRAM instead of ST-RAM, none of ST-RAM is mapped by mem_init, and DMA-addressable buffer must be mapped by ioremap.

Use platform specific virt/phys translation helpers for this case.

---
 drivers/scsi/atari_scsi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/atari_scsi.c +1 -1
index 296c936..a8d721f 100644
@@ -639,7 +639,7 @@ static int __init atari_scsi_detect(struct scsi_host_template *host)
 					"double buffer\n");
 			return 0;
 		}
-		atari_dma_phys_buffer = virt_to_phys(atari_dma_buffer);
+		atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer);
 		atari_dma_orig_addr = 0;
 	}
 #endif
Signature · 1 line
1.7.0.4

Michael Schmitz

author maintainer
#0 lore raw

v3 cover Atari kernel-in-FastRAM patches v3

Hi Geert,

changes to stram.c and atafb.c patches as requested. The external_addr case is still untested - may have other bugs that I've not seen when changing the external_addr types.

CC to the relevant lists for floppy and SCSI patches.

Cheers,

Michael

author maintainer
#1 lore raw

PATCH v3 1/4 m68k/atari - stram: alloc ST-RAM pool even if kernel not in ST-RAM

With the kernel loaded to FastRAM (TT-RAM), none of the ST-RAM address range is mapped by init_mem, and ST-RAM is not accessible through the normal allocation pathways as a result.

Implement ST-RAM pool allocation to be based on physical addresses always (it already was when the kernel was loaded in ST-RAM). Return kernel virtual addresses as per normal.

The current test for the kernel residing in ST-RAM always returns true. Use the bootinfo memory chunk order instead - with the kernel in FastRAM, ST-RAM (phys. 0x0) is not the first chunk.

In case the kernel is running from FastRAM, delay mapping of ST-RAM pool until after mem_init.

Provide helper functions for those users of ST-RAM that need to be aware of the backing physical addresses.

Kudos to Geert for his hints on getting this started.

---
 arch/m68k/atari/stram.c             |   71 ++++++++++++++++++++++++++--------
 arch/m68k/include/asm/atari_stram.h |    2 +
 2 files changed, 56 insertions(+), 17 deletions(-)
arch/m68k/atari/stram.c +54 -17
index 0810c8d..5f8cb5a 100644
@@ -47,6 +47,7 @@ static struct resource stram_pool = {
 
 static unsigned long pool_size = 1024*1024;
 
+static unsigned long stram_virt_offset;
 
 static int __init atari_stram_setup(char *arg)
 {
@@ -67,14 +68,12 @@ early_param("stram_pool", atari_stram_setup);
 void __init atari_stram_init(void)
 {
 	int i;
-	void *stram_start;
 
 	/*
 	 * determine whether kernel code resides in ST-RAM
 	 * (then ST-RAM is the first memory block at virtual 0x0)
 	 */
-	stram_start = phys_to_virt(0);
-	kernel_in_stram = (stram_start == 0);
+	kernel_in_stram = (m68k_memory[0].addr == 0);
 
 	for (i = 0; i < m68k_num_memory; ++i) {
 		if (m68k_memory[i].addr == 0) {
@@ -89,24 +88,62 @@ void __init atari_stram_init(void)
 
 /*
  * This function is called from setup_arch() to reserve the pages needed for
- * ST-RAM management.
+ * ST-RAM management, if the kernel resides in ST-RAM.
  */
 void __init atari_stram_reserve_pages(void *start_mem)
 {
-	/*
-	 * always reserve first page of ST-RAM, the first 2 KiB are
-	 * supervisor-only!
-	 */
-	if (!kernel_in_stram)
-		reserve_bootmem(0, PAGE_SIZE, BOOTMEM_DEFAULT);
+	if (kernel_in_stram) {
+		pr_debug("atari_stram pool: kernel in ST-RAM, using alloc_bootmem!\n");
+		stram_pool.start = (resource_size_t)alloc_bootmem_low_pages(pool_size);
+		stram_pool.end = stram_pool.start + pool_size - 1;
+		request_resource(&iomem_resource, &stram_pool);
+		stram_virt_offset = 0;
+		pr_debug("atari_stram pool: size = %lu bytes, resource = %pR\n",
+			pool_size, &stram_pool);
+		pr_debug("atari_stram pool: stram_virt_offset = %lx\n",
+			stram_virt_offset);
+	}
+}
 
-	stram_pool.start = (resource_size_t)alloc_bootmem_low_pages(pool_size);
-	stram_pool.end = stram_pool.start + pool_size - 1;
-	request_resource(&iomem_resource, &stram_pool);
 
-	pr_debug("atari_stram pool: size = %lu bytes, resource = %pR\n",
-		 pool_size, &stram_pool);
+/*
+ * This function is called as arch initcall to reserve the pages needed for
+ * ST-RAM management, if the kernel does not reside in ST-RAM.
+ */
+int __init atari_stram_map_pages(void)
+{
+	if (!kernel_in_stram) {
+		/*
+		 * Skip page 0, as the fhe first 2 KiB are supervisor-only!
+		 */
+		pr_debug("atari_stram pool: kernel not in ST-RAM, using ioremap!\n");
+		stram_pool.start = PAGE_SIZE;
+		stram_pool.end = stram_pool.start + pool_size - 1;
+		request_resource(&iomem_resource, &stram_pool);
+		stram_virt_offset = (unsigned long) ioremap(stram_pool.start,
+				resource_size(&stram_pool)) - stram_pool.start;
+		pr_debug("atari_stram pool: size = %lu bytes, resource = %pR\n",
+			pool_size, &stram_pool);
+		pr_debug("atari_stram pool: stram_virt_offset = %lx\n",
+			stram_virt_offset);
+	}
+	return 0;
+}
+arch_initcall(atari_stram_map_pages);
+
+
+void *atari_stram_to_virt(unsigned long phys)
+{
+	return (void *)(phys + stram_virt_offset);
+}
+EXPORT_SYMBOL(atari_stram_to_virt);
+
+
+unsigned long atari_stram_to_phys(void *virt)
+{
+	return (unsigned long)(virt - stram_virt_offset);
 }
+EXPORT_SYMBOL(atari_stram_to_phys);
 
 
 void *atari_stram_alloc(unsigned long size, const char *owner)
@@ -134,14 +171,14 @@ void *atari_stram_alloc(unsigned long size, const char *owner)
 	}
 
 	pr_debug("atari_stram_alloc: returning %pR\n", res);
-	return (void *)res->start;
+	return atari_stram_to_virt(res->start);
 }
 EXPORT_SYMBOL(atari_stram_alloc);
 
 
 void atari_stram_free(void *addr)
 {
-	unsigned long start = (unsigned long)addr;
+	unsigned long start = atari_stram_to_phys(addr);
 	struct resource *res;
 	unsigned long size;
 
arch/m68k/include/asm/atari_stram.h +2 -0
index 62e2759..4e771c2 100644
@@ -8,6 +8,8 @@
 /* public interface */
 void *atari_stram_alloc(unsigned long size, const char *owner);
 void atari_stram_free(void *);
+void *atari_stram_to_virt(unsigned long phys);
+unsigned long atari_stram_to_phys(void *);
 
 /* functions called internally by other parts of the kernel */
 void atari_stram_init(void);
Signature · 1 line
1.7.0.4
author maintainer
#2 lore raw

PATCH v3 2/4 m68k/atari - atafb: convert allocation of fb ram to new interface

In reply to Michael Schmitz

The new atari_stram_alloc interface returns kernel virtual addresses even if the kernel runs in FastRAM. These addresses are not guaranteed to be identical with the physical addresses. Since ST-RAM mappings have not been set up by mem_init, virt_to_phys() and its cousin do not work and the atari_stram_to_phys() etc. helpers must be used to determine physical addresses.

fb.fix->smem_start needs physical addresses, fb.par->screen_base needs virtual addresses. Take care of the virt-to-phys conversion both on fb init and par changes.

---
 drivers/video/atafb.c |   49 ++++++++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 23 deletions(-)
drivers/video/atafb.c +26 -23
index e21d1f5..bde9c31 100644
@@ -191,7 +191,7 @@ static struct fb_info fb_info = {
 };
 
 static void *screen_base;	/* base address of screen */
-static void *real_screen_base;	/* (only for Overscan) */
+static unsigned long phys_screen_base;	/* (only for Overscan) */
 
 static int screen_len;
 
@@ -213,7 +213,8 @@ static unsigned int external_yres;
  */
 static unsigned int external_depth;
 static int external_pmode;
-static void *external_addr;
+static void *external_screen_base;
+static unsigned long external_addr;
 static unsigned long external_len;
 static unsigned long external_vgaiobase;
 static unsigned int external_bitspercol = 6;
@@ -592,7 +593,7 @@ static int tt_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
 	int mode;
 
 	strcpy(fix->id, "Atari Builtin");
-	fix->smem_start = (unsigned long)real_screen_base;
+	fix->smem_start = phys_screen_base;
 	fix->smem_len = screen_len;
 	fix->type = FB_TYPE_INTERLEAVED_PLANES;
 	fix->type_aux = 2;
@@ -790,7 +791,7 @@ static void tt_get_par(struct atafb_par *par)
 	addr = ((shifter.bas_hi & 0xff) << 16) |
 	       ((shifter.bas_md & 0xff) << 8)  |
 	       ((shifter.bas_lo & 0xff));
-	par->screen_base = phys_to_virt(addr);
+	par->screen_base = atari_stram_to_virt(addr);
 }
 
 static void tt_set_par(struct atafb_par *par)
@@ -888,7 +889,7 @@ static int falcon_encode_fix(struct fb_fix_screeninfo *fix,
 			     struct atafb_par *par)
 {
 	strcpy(fix->id, "Atari Builtin");
-	fix->smem_start = (unsigned long)real_screen_base;
+	fix->smem_start = phys_screen_base;
 	fix->smem_len = screen_len;
 	fix->type = FB_TYPE_INTERLEAVED_PLANES;
 	fix->type_aux = 2;
@@ -1584,7 +1585,7 @@ static void falcon_get_par(struct atafb_par *par)
 	addr = (shifter.bas_hi & 0xff) << 16 |
 	       (shifter.bas_md & 0xff) << 8  |
 	       (shifter.bas_lo & 0xff);
-	par->screen_base = phys_to_virt(addr);
+	par->screen_base = atari_stram_to_virt(addr);
 
 	/* derived parameters */
 	hw->ste_mode = (hw->f_shift & 0x510) == 0 && hw->st_shift == 0x100;
@@ -1814,7 +1815,7 @@ static int stste_encode_fix(struct fb_fix_screeninfo *fix,
 	int mode;
 
 	strcpy(fix->id, "Atari Builtin");
-	fix->smem_start = (unsigned long)real_screen_base;
+	fix->smem_start = phys_screen_base;
 	fix->smem_len = screen_len;
 	fix->type = FB_TYPE_INTERLEAVED_PLANES;
 	fix->type_aux = 2;
@@ -1980,7 +1981,7 @@ static void stste_get_par(struct atafb_par *par)
 	       ((shifter.bas_md & 0xff) << 8);
 	if (ATARIHW_PRESENT(EXTD_SHIFTER))
 		addr |= (shifter.bas_lo & 0xff);
-	par->screen_base = phys_to_virt(addr);
+	par->screen_base = atari_stram_to_virt(addr);
 }
 
 static void stste_set_par(struct atafb_par *par)
@@ -2039,7 +2040,7 @@ static int stste_detect(void)
 static void stste_set_screen_base(void *s_base)
 {
 	unsigned long addr;
-	addr = virt_to_phys(s_base);
+	addr = atari_stram_to_phys(s_base);
 	/* Setup Screen Memory */
 	shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16);
 	shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8);
@@ -2113,7 +2114,7 @@ static void st_ovsc_switch(void)
 static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
 {
 	strcpy(fix->id, "Unknown Extern");
-	fix->smem_start = (unsigned long)external_addr;
+	fix->smem_start = external_addr;
 	fix->smem_len = PAGE_ALIGN(external_len);
 	if (external_depth == 1) {
 		fix->type = FB_TYPE_PACKED_PIXELS;
@@ -2213,7 +2214,7 @@ static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
 
 static void ext_get_par(struct atafb_par *par)
 {
-	par->screen_base = external_addr;
+	par->screen_base =external_screen_base;
 }
 
 static void ext_set_par(struct atafb_par *par)
@@ -2286,7 +2287,7 @@ static void set_screen_base(void *s_base)
 {
 	unsigned long addr;
 
-	addr = virt_to_phys(s_base);
+	addr = atari_stram_to_phys(s_base);
 	/* Setup Screen Memory */
 	shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16);
 	shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8);
@@ -2433,7 +2434,9 @@ static void atafb_set_disp(struct fb_info *info)
 	atafb_get_var(&info->var, info);
 	atafb_get_fix(&info->fix, info);
 
-	info->screen_base = (void *)info->fix.smem_start;
+	/* Note: smem_start derives from phys_screen_base, not screen_base! */
+	info->screen_base = (external_addr ? external_screen_base :
+				atari_stram_to_virt(info->fix.smem_start));
 }
 
 static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
@@ -2904,7 +2907,7 @@ static void __init atafb_setup_ext(char *spec)
 	external_yres = yres;
 	external_depth = depth;
 	external_pmode = planes;
-	external_addr = (void *)addr;
+	external_addr = addr;
 	external_len = len;
 
 	if (external_card_type == IS_MV300) {
@@ -3166,30 +3169,30 @@ int __init atafb_init(void)
 		memset(screen_base, 0, mem_req);
 		pad = -(unsigned long)screen_base & (PAGE_SIZE - 1);
 		screen_base += pad;
-		real_screen_base = screen_base + ovsc_offset;
+		phys_screen_base = atari_stram_to_phys(screen_base + ovsc_offset);
 		screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK;
 		st_ovsc_switch();
 		if (CPU_IS_040_OR_060) {
 			/* On a '040+, the cache mode of video RAM must be set to
 			 * write-through also for internal video hardware! */
-			cache_push(virt_to_phys(screen_base), screen_len);
+			cache_push(atari_stram_to_phys(screen_base), screen_len);
 			kernel_set_cachemode(screen_base, screen_len,
 					     IOMAP_WRITETHROUGH);
 		}
-		printk("atafb: screen_base %p real_screen_base %p screen_len %d\n",
-			screen_base, real_screen_base, screen_len);
+		printk("atafb: screen_base %p phys_screen_base %lx screen_len %d\n",
+			screen_base, phys_screen_base, screen_len);
 #ifdef ATAFB_EXT
 	} else {
 		/* Map the video memory (physical address given) to somewhere
 		 * in the kernel address space.
 		 */
-		external_addr = ioremap_writethrough((unsigned long)external_addr,
+		external_screen_base = ioremap_writethrough((unsigned long)external_addr,
 						     external_len);
 		if (external_vgaiobase)
 			external_vgaiobase =
 			  (unsigned long)ioremap(external_vgaiobase, 0x10000);
-		screen_base =
-		real_screen_base = external_addr;
+		screen_base = external_screen_base;
+		phys_screen_base = external_addr;
 		screen_len = external_len & PAGE_MASK;
 		memset (screen_base, 0, external_len);
 	}
@@ -3235,8 +3238,8 @@ int __init atafb_init(void)
 	if (register_framebuffer(&fb_info) < 0) {
 #ifdef ATAFB_EXT
 		if (external_addr) {
-			iounmap(external_addr);
-			external_addr = NULL;
+			iounmap(external_screen_base);
+			external_addr = 0;
 		}
 		if (external_vgaiobase) {
 			iounmap((void*)external_vgaiobase);
Signature · 1 line
1.7.0.4
author maintainer
#5 lore raw

PATCH v3 3/4 m68k/atari - ataflop: use correct virt/phys translation for DMA buffer

In reply to Michael Schmitz

With the kernel running from FastRAM instead of ST-RAM, none of ST-RAM is mapped by mem_init, and DMA-addressable buffer must be mapped by ioremap.

Use platform specific virt/phys translation helpers for this case.

---
 drivers/block/ataflop.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/block/ataflop.c +1 -1
index 0e30c6e..f54655a 100644
@@ -1952,7 +1952,7 @@ static int __init atari_floppy_init (void)
 		goto Enomem;
 	}
 	TrackBuffer = DMABuffer + 512;
-	PhysDMABuffer = virt_to_phys(DMABuffer);
+	PhysDMABuffer = atari_stram_to_phys(DMABuffer);
 	PhysTrackBuffer = virt_to_phys(TrackBuffer);
 	BufferDrive = BufferSide = BufferTrack = -1;
 
Signature · 1 line
1.7.0.4
#3 lore raw

Re: [PATCH v3 2/4] m68k/atari - atafb: convert allocation of fb ram to new interface

In reply to Michael Schmitz

Hi Michael,

Quoted 6 lines · Michael Schmitz

The new atari_stram_alloc interface returns kernel virtual addresses even if the kernel runs in FastRAM. These addresses are not guaranteed to be identical with the physical addresses. Since ST-RAM mappings have not been set up by mem_init, virt_to_phys() and its cousin do not work and the atari_stram_to_phys() etc. helpers must be used to determine physical addresses.

Thanks!

drivers/video/atafb.c static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) · line 2217

Quoted 6 lines
drivers/video/atafb.c +1 -1
@@ -2213,7 +2214,7 @@ static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
 
 static void ext_get_par(struct atafb_par *par)
 {
-       par->screen_base = external_addr;
+       par->screen_base =external_screen_base;

I'll add the missing space after "=".

drivers/video/atafb.c int __init atafb_init(void) · line 3190

Quoted 2 lines
drivers/video/atafb.c +1 -0
+               external_screen_base = ioremap_writethrough((unsigned long)external_addr,
                                                     external_len);

I'll remove the now superfluous cast.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#4 lore raw

Re: [PATCH v3 2/4] m68k/atari - atafb: convert allocation of fb ram to new interface

Hi Geert,

Quoted 21 lines · Geert Uytterhoeven

Hi Michael,

Quoted 6 lines · Michael Schmitz

The new atari_stram_alloc interface returns kernel virtual addresses even if the kernel runs in FastRAM. These addresses are not guaranteed to be identical with the physical addresses. Since ST-RAM mappings have not been set up by mem_init, virt_to_phys() and its cousin do not work and the atari_stram_to_phys() etc. helpers must be used to determine physical addresses.

Thanks!

drivers/video/atafb.c static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) · line 2217

Quoted 6 lines
drivers/video/atafb.c +1 -1
@@ -2213,7 +2214,7 @@ static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
 
 static void ext_get_par(struct atafb_par *par)
 {
-       par->screen_base = external_addr;
+       par->screen_base =external_screen_base;

I'll add the missing space after "=".

Quoted 4 lines

drivers/video/atafb.c int __init atafb_init(void) · line 3190

Quoted 2 lines
drivers/video/atafb.c +1 -0
+               external_screen_base = ioremap_writethrough((unsigned long)external_addr,
                                                     external_len);

I'll remove the now superfluous cast.

Thanks, much appreciated!

Cheers,

Michael

maintainer Applied
#7 lore raw
In reply to Michael Schmitz

Hi Michael,

Quoted 5 lines · Michael Schmitz

changes to stram.c and atafb.c patches as requested. The external_addr case is still untested - may have other bugs that I've not seen when changing the external_addr types.

CC to the relevant lists for floppy and SCSI patches.

Thanks, applied and queued for 3.16.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#8 lore raw

Hi Geert,

Quoted 10 lines · Geert Uytterhoeven

Hi Michael,

Quoted 5 lines · Michael Schmitz

changes to stram.c and atafb.c patches as requested. The external_addr case is still untested - may have other bugs that I've not seen when changing the external_addr types.

CC to the relevant lists for floppy and SCSI patches.

Thanks, applied and queued for 3.16.

Thank you - anyone testing these please note that the Falcon SCSI DMA dribble buffer handling in the SCSI patch is still faulty. You should _not_ attempt to use SCSI when running the kernel in FastRAM.

Cheers,

Michael

author maintainer
#9 lore raw
Quoted 13 lines · Michael Schmitz

Hi Geert,

Quoted 8 lines · Geert Uytterhoeven

Hi Michael,

Quoted 4 lines · Michael Schmitz

changes to stram.c and atafb.c patches as requested. The external_addr case is still untested - may have other bugs that I've not seen when changing the external_addr types.

Quoted 10 lines
Quoted 4 lines
Quoted 2 lines

CC to the relevant lists for floppy and SCSI patches.

Thanks, applied and queued for 3.16.

Thank you - anyone testing these please note that the Falcon SCSI DMA dribble buffer handling in the SCSI patch is still faulty. You should _not_ attempt to use SCSI when running the kernel in FastRAM.

Found the error, most likely - when the kernel runs in FastRAM, m68k_num_memory is == 1. Is there a way to access the bootinfo view of the number of memory chunks after the MMU init code has tweaked m68k_num_memory, Geert?

Cheers,

Michael

#10 lore raw

Hi Michael,

Quoted 8 lines
Quoted 3 lines

Thank you - anyone testing these please note that the Falcon SCSI DMA dribble buffer handling in the SCSI patch is still faulty. You should _not_ attempt to use SCSI when running the kernel in FastRAM.

Found the error, most likely - when the kernel runs in FastRAM, m68k_num_memory is == 1. Is there a way to access the bootinfo view of the number of memory chunks after the MMU init code has tweaked m68k_num_memory, Geert?

You mean the ones that were removed due to "Ignoring memory chunk"?

No, bootinfo is gone, unless saved for kexec with CONFIG_BOOTINFO_PROC=y.

What exactly is the issue?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#11 lore raw

Hi Geert,

Quoted 6 lines
Quoted 4 lines

Found the error, most likely - when the kernel runs in FastRAM, m68k_num_memory is == 1. Is there a way to access the bootinfo view of the number of memory chunks after the MMU init code has tweaked m68k_num_memory, Geert?

You mean the ones that were removed due to "Ignoring memory chunk"?

These ones exactly.

Quoted 3 lines

No, bootinfo is gone, unless saved for kexec with CONFIG_BOOTINFO_PROC=y.

What exactly is the issue?

When deciding whether a ST-RAM DMA buffer needs to be allocated, the Atari SCSI driver checks whether there's more than a single chunk of RAM (there's always ST-RAM, so the second one indicates FastRAM). That's no longer a good test now with the kernel capable of running from FastRAM (and the ST-RAM chunk being dropped in MM init).

Maybe we need another variable to hold the number of memory chunks before adjustment. Or look at size or physical base address of the first chunk...

Cheers,

Michael

Quoted 10 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#12 lore raw

Hi Michael,

Quoted 9 lines · Michael Schmitz

When deciding whether a ST-RAM DMA buffer needs to be allocated, the Atari SCSI driver checks whether there's more than a single chunk of RAM (there's always ST-RAM, so the second one indicates FastRAM). That's no longer a good test now with the kernel capable of running from FastRAM (and the ST-RAM chunk being dropped in MM init).

Maybe we need another variable to hold the number of memory chunks before adjustment. Or look at size or physical base address of the first chunk...

That's why DMA masks have been invented. The one in atari_scsi.c seems to have the bits inverted, compared to all other places in the kernel.

But indeed, that doesn't help for the initial check:

        if (MACH_IS_ATARI && ATARIHW_PRESENT(ST_SCSI) &&
            !ATARIHW_PRESENT(EXTD_DMA) && m68k_num_memory > 1) {
                atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
                if (!atari_dma_buffer) {
                        printk(KERN_ERR "atari_scsi_detect: can't
allocate ST-RAM "
                                        "double buffer\n");
                        return 0;
                }
                atari_dma_phys_buffer = virt_to_phys(atari_dma_buffer);
                atari_dma_orig_addr = 0;
        }

You can loop over m68k_memory[], and check if any chunk lies outside the first 16 MiB?

If everything fails, you can allocate it unconditionally (it's just one 4 KiB page).

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds