• Kernel uses only half of Mac IIci memory with built-in video

    From Brad Boyer@21:1/5 to Stan Johnson on Fri Mar 12 02:50:01 2021
    On Thu, Mar 11, 2021 at 11:39:41AM -0700, Stan Johnson wrote:
    When booting modern kernels (4.x or 5.x) on a Mac IIci, the kernel sees
    only half of installed memory if the built-in video is used. Using a
    Nubus video card, all of the installed memory is seen. This may be a
    Penguin issue, though it's not clear why the kernel is ignoring
    available memory. I'm documenting it here in case anyone has an idea
    how to fix it.

    I'm not sure how to fix it, but I suspect this is changed due to the
    way some of the memory management code now works. With built-in video
    on an RBV model like the IIci, the video chip steals RAM out of the
    first bank (at physical address 0). That means the first bank isn't
    entirely usable for the kernel. With this in mind, it's both simpler
    and faster to put the kernel into the second bank. However, newer
    kernels can't cleanly handle adding the first bank (which has lower
    physical addresses) to usable memory after the second bank. I'm
    pretty sure that used to work. It's somewhat similar to the problem
    between the fast and slow RAM on the Atari systems.

    Brad Boyer
    flar@allandria.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Schmitz@21:1/5 to Brad Boyer on Sun Mar 14 20:30:02 2021
    Hi Brad,

    On 12/03/21 2:18 pm, Brad Boyer wrote:
    On Thu, Mar 11, 2021 at 11:39:41AM -0700, Stan Johnson wrote:
    When booting modern kernels (4.x or 5.x) on a Mac IIci, the kernel sees
    only half of installed memory if the built-in video is used. Using a
    Nubus video card, all of the installed memory is seen. This may be a
    Penguin issue, though it's not clear why the kernel is ignoring
    available memory. I'm documenting it here in case anyone has an idea
    how to fix it.
    I'm not sure how to fix it, but I suspect this is changed due to the
    way some of the memory management code now works. With built-in video
    on an RBV model like the IIci, the video chip steals RAM out of the
    first bank (at physical address 0). That means the first bank isn't
    entirely usable for the kernel. With this in mind, it's both simpler
    and faster to put the kernel into the second bank. However, newer
    kernels can't cleanly handle adding the first bank (which has lower
    physical addresses) to usable memory after the second bank. I'm
    pretty sure that used to work. It's somewhat similar to the problem
    between the fast and slow RAM on the Atari systems.

    I'm pretty sure this has never worked. Though there ought to be a way to
    make use of RAM in bank 0 for video as long as the kernel is loaded at
    address 0 in that bank. Or if that's not possible, use the same trick as
    I do on Atari - ioremap some of the bank 0 memory for use by video, and
    make sure the video driver uses a dedicated low memory pool allocator
    for that ioremapped RAM.

    Cheers,

        Michael



    Brad Boyer
    flar@allandria.com


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brad Boyer@21:1/5 to Michael Schmitz on Sun Mar 14 22:20:01 2021
    On Mon, Mar 15, 2021 at 08:28:37AM +1300, Michael Schmitz wrote:
    I'm pretty sure this has never worked. Though there ought to be a way to
    make use of RAM in bank 0 for video as long as the kernel is loaded at address 0 in that bank. Or if that's not possible, use the same trick as I
    do on Atari - ioremap some of the bank 0 memory for use by video, and make sure the video driver uses a dedicated low memory pool allocator for that ioremapped RAM.

    OK, I wasn't sure if it used to work. I own both a IIci and IIsi, but I
    never got Linux up and running on either. I bought both of them just
    about when I stopped having as much time to work on such things.

    I believe one of the headaches is that the address is non-programmable
    and requires the framebuffer not just to be in bank A, but to start at
    address 0 which means we can't put the kernel at address 0. So we
    instead put it at the beginning of bank B if RBV video is going to be
    used. The RBV chip doesn't have a way to specify the buffer address
    (the official Apple documentation is quite clear that RBV has no
    control over the framebuffer location). The other chip that does that
    part is also the main memory mapping logic for all onboard devices and
    has a completely static mapping for this sort of thing as far as I know.
    The documentation I've found never explicitly says the address 0 is
    hard-coded, but it never says it can be changed either.

    A second headache is that we don't have real video drivers for anything
    on Mac (other than valkyrie which is only found on one or two very late
    m68k models and is a shared driver with some ppc models). The macfb
    driver mostly just takes information passed in by Penguin and uses
    that. It only has enough logic beyond that to change the color palettes
    on some of the more common hardware.

    On the Atari, is the rest of the low memory usable if the kernel isn't
    there? I seem to recall it is only accessible by that special allocator
    in that case, not as generic memory. I'm not sure of anything else we
    have on a Mac that would be able to use that sort of thing.

    Brad Boyer
    flar@allandria.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Schmitz@21:1/5 to Brad Boyer on Mon Mar 15 02:40:01 2021
    Hi Brad,

    On 15/03/21 10:13 am, Brad Boyer wrote:
    On Mon, Mar 15, 2021 at 08:28:37AM +1300, Michael Schmitz wrote:
    I'm pretty sure this has never worked. Though there ought to be a way to
    make use of RAM in bank 0 for video as long as the kernel is loaded at
    address 0 in that bank. Or if that's not possible, use the same trick as I >> do on Atari - ioremap some of the bank 0 memory for use by video, and make >> sure the video driver uses a dedicated low memory pool allocator for that
    ioremapped RAM.
    OK, I wasn't sure if it used to work. I own both a IIci and IIsi, but I
    never got Linux up and running on either. I bought both of them just
    about when I stopped having as much time to work on such things.

    I believe one of the headaches is that the address is non-programmable
    and requires the framebuffer not just to be in bank A, but to start at address 0 which means we can't put the kernel at address 0. So we
    instead put it at the beginning of bank B if RBV video is going to be
    used. The RBV chip doesn't have a way to specify the buffer address
    (the official Apple documentation is quite clear that RBV has no
    control over the framebuffer location). The other chip that does that
    part is also the main memory mapping logic for all onboard devices and
    has a completely static mapping for this sort of thing as far as I know.
    The documentation I've found never explicitly says the address 0 is hard-coded, but it never says it can be changed either.
    Only leaves the option of using a dedicated pool of ioremapped memory
    and a special allocator. That is, unless someone manages to rewrite the
    m68k MMU code to allow RAM chunks to be listed and mapped in any order.
    We now use a memory model that should allow that, but the code that maps virtual addresses to physical addresses and vice versa (without walking
    the page tables) isn't there yet. It's been a while since I looked
    though ...

    A second headache is that we don't have real video drivers for anything
    on Mac (other than valkyrie which is only found on one or two very late
    m68k models and is a shared driver with some ppc models). The macfb
    driver mostly just takes information passed in by Penguin and uses
    that. It only has enough logic beyond that to change the color palettes
    on some of the more common hardware.

    On the Atari, is the rest of the low memory usable if the kernel isn't
    there? I seem to recall it is only accessible by that special allocator
    No, none of the RAM in the low memory chunk is mapped for use as normal
    memory.
    in that case, not as generic memory. I'm not sure of anything else we
    have on a Mac that would be able to use that sort of thing.

    The only other use is for DMA buffers (floppy and SCSI controllers,
    probably also DMA for the sound chip). DMA on Macs is weird (though can probably address the entire memory, not just the low 24 address bits, so
    the problem never arose on MAC as far as I recall).

    Cheers,

        Michael



    Brad Boyer
    flar@allandria.com


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brad Boyer@21:1/5 to Michael Schmitz on Mon Mar 15 06:40:02 2021
    On Mon, Mar 15, 2021 at 02:33:26PM +1300, Michael Schmitz wrote:
    On 15/03/21 10:13 am, Brad Boyer wrote:
    I believe one of the headaches is that the address is non-programmable
    and requires the framebuffer not just to be in bank A, but to start at >address 0 which means we can't put the kernel at address 0. So we
    instead put it at the beginning of bank B if RBV video is going to be
    used. The RBV chip doesn't have a way to specify the buffer address
    (the official Apple documentation is quite clear that RBV has no
    control over the framebuffer location). The other chip that does that
    part is also the main memory mapping logic for all onboard devices and
    has a completely static mapping for this sort of thing as far as I know. >The documentation I've found never explicitly says the address 0 is >hard-coded, but it never says it can be changed either.
    Only leaves the option of using a dedicated pool of ioremapped memory and a special allocator. That is, unless someone manages to rewrite the m68k MMU code to allow RAM chunks to be listed and mapped in any order. We now use a memory model that should allow that, but the code that maps virtual
    addresses to physical addresses and vice versa (without walking the page tables) isn't there yet. It's been a while since I looked though ...

    OK. Today it's kind of implied because macfb.c passes whatever address
    it got from Penguin to ioremap. Perhaps we could find some other use
    for the rest of the RAM in that bank (a IIsi has a fixed 1MB there,
    but it was possible to put a lot more than that in bank A on a IIci).

    I do remember some of that mapping code being very simple in the past,
    but I haven't looked much at the code as it is today.

    in that case, not as generic memory. I'm not sure of anything else we
    have on a Mac that would be able to use that sort of thing.

    The only other use is for DMA buffers (floppy and SCSI controllers, probably also DMA for the sound chip). DMA on Macs is weird (though can probably address the entire memory, not just the low 24 address bits, so the problem never arose on MAC as far as I recall).

    I don't believe there are any working sound drivers for m68k macs,
    and the only working floppy driver we have is swim.c which is not
    capable of doing DMA (no model it supports can do DMA to floppy).
    The only SCSI drivers we have (mac_scsi and mac_esp) don't support
    DMA even though some models (not including the RBV systems) have
    that capability.

    The only drivers I found using DMA on m68k macs are the on-board
    ethernet ports (macmace.c and macsonic.c). Both appear to allow
    arbitrary DMA buffers. The SCSIDMA chip (only in the IIfx) should
    allow 32-bit addresses, but we don't support using real DMA (the
    driver only knows how to do PDMA). The AV models (the ones with
    PSC) have 9 DMA channels, but we don't support real DMA for
    anything other than ethernet. The other channels are for things
    that are supported without DMA (serial and SCSI) or are not
    supported at all (floppy and sound - these models have a floppy
    controller and sound chip not found on any other model). None of
    that hardware can be present on a system with RBV.

    At one point Apple even wrote a technote claiming that it was a
    good thing none of their hardware could do DMA. It was titled
    "I was a teenage DMA junkie", but I don't think it's available
    online these days.

    Brad Boyer
    flar@allandria.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geert Uytterhoeven@21:1/5 to flar@allandria.com on Mon Mar 15 09:20:01 2021
    Hi Brad,

    On Fri, Mar 12, 2021 at 2:46 AM Brad Boyer <flar@allandria.com> wrote:
    On Thu, Mar 11, 2021 at 11:39:41AM -0700, Stan Johnson wrote:
    When booting modern kernels (4.x or 5.x) on a Mac IIci, the kernel sees only half of installed memory if the built-in video is used. Using a
    Nubus video card, all of the installed memory is seen. This may be a Penguin issue, though it's not clear why the kernel is ignoring
    available memory. I'm documenting it here in case anyone has an idea
    how to fix it.

    I'm not sure how to fix it, but I suspect this is changed due to the
    way some of the memory management code now works. With built-in video
    on an RBV model like the IIci, the video chip steals RAM out of the
    first bank (at physical address 0). That means the first bank isn't
    entirely usable for the kernel. With this in mind, it's both simpler
    and faster to put the kernel into the second bank. However, newer
    kernels can't cleanly handle adding the first bank (which has lower
    physical addresses) to usable memory after the second bank. I'm
    pretty sure that used to work. It's somewhat similar to the problem
    between the fast and slow RAM on the Atari systems.

    Yes, we used to have that feature, but it was lost when switching to the generic memory handling code shared by all architectures.
    Two of the main differences between m68k platforms and the ia32 PC
    platform are that (a) physical RAM doesn't always start at address
    zero, and (b) physical RAM isn't always contiguous. As supporting these differences required non-linear mappings anyway, it was easy to support rearranging blocks, too.

    Gr{oetje,eeting}s,

    Geert

    --
    Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Schwab@21:1/5 to Geert Uytterhoeven on Mon Mar 15 10:30:01 2021
    On Mär 15 2021, Geert Uytterhoeven wrote:

    Two of the main differences between m68k platforms and the ia32 PC
    platform are that (a) physical RAM doesn't always start at address
    zero,

    That is shared with a lot of platforms.

    Andreas.

    --
    Andreas Schwab, schwab@linux-m68k.org
    GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
    "And now for something completely different."

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geert Uytterhoeven@21:1/5 to schwab@linux-m68k.org on Mon Mar 15 10:20:02 2021
    Hi Andreas,

    On Mon, Mar 15, 2021 at 9:57 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
    On Mär 15 2021, Geert Uytterhoeven wrote:
    Two of the main differences between m68k platforms and the ia32 PC
    platform are that (a) physical RAM doesn't always start at address
    zero,

    That is shared with a lot of platforms.

    Sure. But I meant from a (Linux) historical point of view, when Linux supported only ia32.

    Gr{oetje,eeting}s,

    Geert

    --
    Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Finn Thain@21:1/5 to Brad Boyer on Tue Mar 16 08:10:02 2021
    On Sun, 14 Mar 2021, Brad Boyer wrote:

    Perhaps we could find some other use for the rest of the RAM in that
    bank (a IIsi has a fixed 1MB there, but it was possible to put a lot
    more than that in bank A on a IIci).


    I didn't know that the IIsi limited video RAM to 1 MB. It's unsurprising though, considering the drawbacks of RAM based video.

    The Guide to Macintosh Family Hardware says, regarding the IIci,

    The built-in video circuits use a screen buffer in RAM bank A. The
    effect of the video RAM cycles can decrease the processor's access to
    bank A by as little as 6% or as much as 65%, depending on the type of
    video display in use: larger displays and display modes with more bits
    per pixel have a greater effect.

    Back in the day, IIci owners would install a NuBus video board to avoid
    the performance penalty. IIci owners without a Nubus video board would
    avoid putting expensive RAM in bank A.

    Because Linux is so demanding, I'd expect IIci users would upgrade both
    RAM and video hardware. For Linux on the IIsi, the amount of lost bank A
    RAM is neglible -- probably only hundreds of KiB.

    So for RBV systems with on-board video disabled, we just need Penguin to
    do the right thing -- the RAM from both banks can be made available to the kernel and macfb should use the Nubus card. I may be missing something but
    I don't see why Linux wouldn't work as is.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Finn Thain@21:1/5 to Stan Johnson on Tue Mar 16 08:10:02 2021
    On Mon, 15 Mar 2021, Stan Johnson wrote:


    The issue appears not to be limited to built-in video. With 16 MiB in
    Bank A (4 x 4 MiB), 64 MiB in Bank B (4 x 16 MiB), a RasterOps
    ColorBoard 264 in the Nubus slot nearest the PDS slot (which contains a
    32K cache card), and a Farallon Ethernet card in the middle Nubus slot,
    Linux 4.1.167 sees only 64 MiB of memory, presumably all from Bank B.
    Mac OS 7.5.5 and 8.1 see 80 MiB, as does NetBSD 9.1.


    I would also try a recent mainline build. Here's a build with
    CONFIG_FLATMEM=y.

    https://www.telegraphics.com.au/~fthain/build/linux-m68k-image-5.11.0-mac.tar.gz
    https://www.telegraphics.com.au/~fthain/build/vmlinux-5.11.0-mac

    MD5 (linux-m68k-image-5.11.0-mac.tar.gz) = 43de77ea582f227723a858d121164992
    MD5 (vmlinux-5.11.0-mac) = 7846d66dc23b72eed8c1597c643615c1

    (The old 4.1.167 build that I made has too many backported patches to be
    called "4.1.167" and not enough backported fixes to be representative of mainline. A good compromise is 4.14.221-mac-backport+ on sourceforge.)

    With 16 MiB in each bank, using a Mac II video card and an Asante 10/100 Ethernet card, Linux sees all 32 MiB (I didn't test this combination
    with 80 MiB or 128 MiB).

    Unfortunately, while the Asante 10/100 card works fine in Mac OS, I
    couldn't find an appropriate Linux driver (I think it used to use an SMC driver, but I couldn't find one in modern kernels that works).

    Linux probably has a driver for the SMC chip but it has no driver for that particular card.

    And the RasterOps card is a better video card than the Mac II (Toby)
    video card, though I think the RasterOps card may be causing a "failed
    to turn off interrupts, booting anyway" message in Penguin while booting Linux (possibly causing the memory issue?).


    You can ignore the "failed to turn off interrupts" message (that is, until
    you see Linux fail to start).

    On a different IIci, with 64 MiB in each bank, using a Mac II video card
    and a Farallon Ethermac II-C card, Linux sees all 128 MiB (with no
    "failed to turn off interrupts..." message).


    It would be interesting to see the list of RAM segments that Penguin
    generates on these machines (you can get Penguin to log them without
    starting the kernel).

    Maybe Mac OS reserves memory from Bank A for video unless the ROM
    recognizes a known Apple video card (such as the Mac II video card)?

    Penguin on the 80 MB machine might work better if you swapped out the
    RasterOps board in favour of a Mac II video board... it's probably worth trying.

    Are these machines running the same version of Mac OS? Penguin has some
    funky IIci video driver patching code that might be affected by ROM
    version or MacOS version.

    Does anyone know whether there's a way to have Penguin send a custom
    list of free memory ranges to Linux?


    Not AFAIK.

    If anyone wants to do any further testing, I'd be happy to help.


    The complete Penguin logs may shed some light on the pertinent differences between the 80 MB machine and the 32 MB machine.

    In particular, if you see "Bootstrap logical 2" it would indicate that
    Penguin is performing a "rbv boot". From the source code--

    /* Get new_copy_and_go_ptr physical to logical translation, i.e. where the
    * bootstrap code will be located when the MMU is disabled. This is only
    * neccessary when logical(0) != physical(0) (a 'rbv boot' where the video
    * circuitry claims RAM to drive the display).
    * Should it be a rbv boot then we'll have to copy our bootstrap code
    * to the video base since this is where we'll have address 0.
    * If we have a logical video address equal to the physical address then
    * this not a 'real' RBV boot but a boot with no memory in bank A and
    * an external video card. This makes it possible to use the video base
    * as the boot code placement, alone, since the MMU does not affect the logical<->
    * physical mapping.
    */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brad Boyer@21:1/5 to Finn Thain on Tue Mar 16 12:10:02 2021
    On Tue, Mar 16, 2021 at 05:56:02PM +1100, Finn Thain wrote:
    I didn't know that the IIsi limited video RAM to 1 MB. It's unsurprising though, considering the drawbacks of RAM based video.

    It really doesn't have anything to do with the video. It's just that
    the first bank is soldered on instead of being normal SIMM slots. I
    believe the max settings on RBV end up being something like 320kB
    usage for video on both models. I'm pretty sure RBV maxes out at
    8-bit color. However, it's true that wouldn't leave much wasted on a
    IIsi if we can't use the rest of it.

    Brad Boyer
    flar@allandria.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Finn Thain@21:1/5 to Stan Johnson on Thu Mar 18 05:50:02 2021
    On Tue, 16 Mar 2021, Stan Johnson wrote:


    This is getting complicated quickly, and some of my earlier conclusions
    were wrong.


    Yes, it's getting complicated. But it should not be necessary to rearrange
    RAM or video cards to avoid a crash from v5.11...

    I suspect that v5.10 (with CONFIG_DISCONTIGMEM=y) would probably behave
    the same as v4.14.167-mac-backport+ (that is, no crash). Here's a build
    that will allow you to confirm that.

    https://www.telegraphics.com.au/~fthain/build/linux-m68k-image-5.10.0-mac.tar.gz
    https://www.telegraphics.com.au/~fthain/build/vmlinux-5.10.0-mac

    MD5 (linux-m68k-image-5.10.0-mac.tar.gz) = 3d3158ba5c48ef017fbe36a6308786a5
    MD5 (vmlinux-5.10.0-mac) = 02fb433fb59b1f500c5bba46a614c646

    I have these two Mac IIci systems:

    System A: 128 MB (64 MB in each bank), Mac II Video Card, Farallon
    EtherMac II-C

    System B: 80 MB (16 MB in Bank A, 64 MB in Bank B), Mac II Video Card, Farallon EtherMac II-C

    When either System A or System B is using built-in video, Linux 4.14.167-mac-backport+ sees only the memory that is in Bank B.

    I would expect to see the same from any Linux build (?). IIUC, this configuration would cause Penguin to log "RBV boot, logical 0x00000000 at 0x...".

    When System B uses a RasterOps video card, only the memory in Bank B is
    seen (even if the amount of memory in Banks A and B is the same). I'm
    not able to get System B to see all memory except when using the Mac II
    video card and with the same amount of memory in Banks A and B.


    It's odd that RasterOps vs. Apple Nubus video card would have an affect on
    the bootloader. In the Penguin source code, I do see some direct
    interaction with Apple's video drivers. This does seem a little fragile.
    But I'd need to study this code before I could claim to understand it.

    Using the 5.11.0-mac kernel with CONFIG_FLATMEM=y, System B crashes, but System A works. With 16 MB in both Banks A and B, System B doesn't
    crash, either, and 5.11.0-mac sees all 32 MB (see attached serial
    console log for System B, first boot crashes with 80 MB, second boot
    works with 32 MB). So where 4.14.167-mac-backport+ saw only the memory
    in Bank B, 5.11.0-mac crashes (I didn't try 5.11.0-mac without the CONFIG_FLATMEM=y option).


    Am I right in thinking that Linux only crashes when Penguin loads the
    kernel into Bank A (i.e. Penguin says "The kernel will be located at
    physical 0x00001000") and the kernel then goes and drops that segment
    (i.e. Linux says "Ignoring memory chunk at 0x0:0x1000000 before the first chunk")?

    ... It would be interesting to see the list of RAM segments that
    Penguin generates on these machines (you can get Penguin to log them without starting the kernel).

    Maybe Mac OS reserves memory from Bank A for video unless the ROM
    recognizes a known Apple video card (such as the Mac II video card)?

    Penguin on the 80 MB machine might work better if you swapped out the RasterOps board in favour of a Mac II video board... it's probably
    worth trying.

    Are these machines running the same version of Mac OS? Penguin has
    some funky IIci video driver patching code that might be affected by
    ROM version or MacOS version. ...

    Yes, both are running Mac OS 7.5.5. The attached Penguin output is for 5.11.0-mac from System B; Penguin-1.txt is with 80 MB (crashes), Penguin-2.txt is with 32 MB (16 MB in each Bank) (works).


    Thanks for collecting these logs. The Penguin logs show that rbv_boot is
    false, indicating that the on-board video is not in use, as described.

    So I think the important question is, why does Penguin fail to sort the segments in this case? That is, why did Penguin produce this list:

    Physical RAM: 80 MB
    ...
    BI_MEMCHUNK[0].addr = 0x04000000
    BI_MEMCHUNK[0].size = 0x04000000
    BI_MEMCHUNK[1].addr = 0x00000000
    BI_MEMCHUNK[1].size = 0x01000000

    rather than a sorted list, something like the other example:

    Physical RAM: 32 MB
    ...
    BI_MEMCHUNK[0].addr = 0x00000000
    BI_MEMCHUNK[0].size = 0x01000000
    BI_MEMCHUNK[1].addr = 0x04000000
    BI_MEMCHUNK[1].size = 0x01000000

    -Stan Johnson


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Finn Thain@21:1/5 to Finn Thain on Fri Mar 19 01:00:02 2021
    On Thu, 18 Mar 2021, Finn Thain wrote:

    Am I right in thinking that Linux only crashes when Penguin loads the
    kernel into Bank A (i.e. Penguin says "The kernel will be located at
    physical 0x00001000") and the kernel then goes and drops that segment
    (i.e. Linux says "Ignoring memory chunk at 0x0:0x1000000 before the
    first chunk")?

    After re-reading your message, I think I got that wrong -- you said that "Penguin-1.txt is with 80 MB (crashes)". So I don't have a good
    explanation for the v5.11 crash.


    Thanks for collecting these logs. The Penguin logs show that rbv_boot is false, indicating that the on-board video is not in use, as described.

    So I think the important question is, why does Penguin fail to sort the segments in this case? That is, why did Penguin produce this list:

    Physical RAM: 80 MB
    ...
    BI_MEMCHUNK[0].addr = 0x04000000
    BI_MEMCHUNK[0].size = 0x04000000
    BI_MEMCHUNK[1].addr = 0x00000000
    BI_MEMCHUNK[1].size = 0x01000000

    rather than a sorted list, something like the other example:

    Physical RAM: 32 MB
    ...
    BI_MEMCHUNK[0].addr = 0x00000000
    BI_MEMCHUNK[0].size = 0x01000000
    BI_MEMCHUNK[1].addr = 0x04000000
    BI_MEMCHUNK[1].size = 0x01000000


    After looking at the Penguin source code, I understand how this happens. Penguin sorts the pysical memory chunks by size, not by address, except on 68020, where it sorts by address.

    If you move the 64 MB to bank A and the 16 MB to bank B, does that solve
    the problem? (Please also try v5.10 before you make that change.)

    AIUI, Penguin needs a large physically contiguous region, so it used the largest pysical RAM chunk (which was bank B). But that alone doesn't
    really justify the weird sort order.

    Laurent, can you comment on this? In particular, does EMILE sort memory
    chunks the way Penguin does?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Laurent Vivier@21:1/5 to All on Fri Mar 19 09:50:01 2021
    Le 19/03/2021 à 00:49, Finn Thain a écrit :

    On Thu, 18 Mar 2021, Finn Thain wrote:

    Am I right in thinking that Linux only crashes when Penguin loads the
    kernel into Bank A (i.e. Penguin says "The kernel will be located at
    physical 0x00001000") and the kernel then goes and drops that segment
    (i.e. Linux says "Ignoring memory chunk at 0x0:0x1000000 before the
    first chunk")?

    After re-reading your message, I think I got that wrong -- you said that "Penguin-1.txt is with 80 MB (crashes)". So I don't have a good
    explanation for the v5.11 crash.


    Thanks for collecting these logs. The Penguin logs show that rbv_boot is
    false, indicating that the on-board video is not in use, as described.

    So I think the important question is, why does Penguin fail to sort the
    segments in this case? That is, why did Penguin produce this list:

    Physical RAM: 80 MB
    ...
    BI_MEMCHUNK[0].addr = 0x04000000
    BI_MEMCHUNK[0].size = 0x04000000
    BI_MEMCHUNK[1].addr = 0x00000000
    BI_MEMCHUNK[1].size = 0x01000000

    rather than a sorted list, something like the other example:

    Physical RAM: 32 MB
    ...
    BI_MEMCHUNK[0].addr = 0x00000000
    BI_MEMCHUNK[0].size = 0x01000000
    BI_MEMCHUNK[1].addr = 0x04000000
    BI_MEMCHUNK[1].size = 0x01000000


    After looking at the Penguin source code, I understand how this happens. Penguin sorts the pysical memory chunks by size, not by address, except on 68020, where it sorts by address.

    If you move the 64 MB to bank A and the 16 MB to bank B, does that solve
    the problem? (Please also try v5.10 before you make that change.)

    AIUI, Penguin needs a large physically contiguous region, so it used the largest pysical RAM chunk (which was bank B). But that alone doesn't
    really justify the weird sort order.

    Laurent, can you comment on this? In particular, does EMILE sort memory chunks the way Penguin does?


    Yes, EMILE sorts the memory bank, the bigger first.

    https://github.com/vivier/EMILE/blob/master/second/bootinfo.c#L67

    Thanks,
    Laurent

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Schmitz@21:1/5 to All on Fri Mar 19 21:50:01 2021
    Hi Finn,

    Am 19.03.21 um 12:49 schrieb Finn Thain:
    AIUI, Penguin needs a large physically contiguous region, so it used the largest pysical RAM chunk (which was bank B). But that alone doesn't
    really justify the weird sort order.

    If Penguin then loads the kernel in that same chunk, there really is no
    other choice? (The kernel expects the memory chunk it runs from to be
    listed first in the bootinfo struct).

    I wonder about the 020 sorting scheme though - is there a hardware rule
    that says the first chunk must be the largest on 020?

    Cheers,

        Michael

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Finn Thain@21:1/5 to Michael Schmitz on Sun Mar 21 02:40:01 2021
    On Sat, 20 Mar 2021, Michael Schmitz wrote:

    Hi Finn,

    Am 19.03.21 um 12:49 schrieb Finn Thain:
    AIUI, Penguin needs a large physically contiguous region, so it used
    the largest pysical RAM chunk (which was bank B). But that alone
    doesn't really justify the weird sort order.

    If Penguin then loads the kernel in that same chunk, there really is no
    other choice? (The kernel expects the memory chunk it runs from to be
    listed first in the bootinfo struct).


    But finding the largest chunk and putting it first doesn't imply sorting
    the whole list of bootinfo memory chunks by size. Moreover, the kernel now apprently requires chunks to be sorted by physical address, not by size.

    Why not sort chunks by physical address and omit any chunks prior to the largest one, to satisfy both requirements? Then ask users to re-arrange
    RAM SIMMs such that bank A is the largest.

    I wonder about the 020 sorting scheme though - is there a hardware rule
    that says the first chunk must be the largest on 020?


    The Penguin-19 source code says,

    /* Hack for 020/68851. Kernel "head.S" does not handle
    * 020 with > 1 memory segment and kernel not in first
    * segment. Force kernel into first memory segment on
    * these (020) machines.
    */

    This "hack" first appeared in Penguin-14. The file Penguin.doc says,

    Status: Changed 980301

    New setting - "68020: Don't force kernel into bank A".
    Normally the 020's requires the kernel to be placed in
    bank A memory. The Penguin will force the kernel to be put
    in that bank on these machines. This setting will ignore
    the "forcing" and put the kernel in the bank with the
    largest amount of memory available.
    NOTE: Current kernels will fail if the kernel is not
    forced into bank A. Emergency setting if all else fails.
    Only available on 020's.

    That suggests that the bank A requirement comes from a kernel limitation, perhaps stemming from a 68551 quirk (?).

    Looking at MMU code in head.S in current kernels, mmu_map_tt() seems to
    contain the only special case for '020. But mmu_map_tt() is only used for
    Nubus slot space. So I'm none the wiser.

    Perhaps we need to look at head.S from before 1998 to figure out what
    motivated Penguin's '020 special case and the option to disable it?

    Cheers,

    hael





    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geert Uytterhoeven@21:1/5 to fthain@telegraphics.com.au on Sun Mar 21 15:40:01 2021
    Hi Finn,

    On Sun, Mar 21, 2021 at 2:31 AM Finn Thain <fthain@telegraphics.com.au> wrote:
    On Sat, 20 Mar 2021, Michael Schmitz wrote:
    Am 19.03.21 um 12:49 schrieb Finn Thain:
    AIUI, Penguin needs a large physically contiguous region, so it used
    the largest pysical RAM chunk (which was bank B). But that alone
    doesn't really justify the weird sort order.

    If Penguin then loads the kernel in that same chunk, there really is no other choice? (The kernel expects the memory chunk it runs from to be listed first in the bootinfo struct).


    But finding the largest chunk and putting it first doesn't imply sorting
    the whole list of bootinfo memory chunks by size. Moreover, the kernel now apprently requires chunks to be sorted by physical address, not by size.

    Why not sort chunks by physical address and omit any chunks prior to the largest one, to satisfy both requirements? Then ask users to re-arrange
    RAM SIMMs such that bank A is the largest.

    I wonder about the 020 sorting scheme though - is there a hardware rule that says the first chunk must be the largest on 020?


    The Penguin-19 source code says,

    /* Hack for 020/68851. Kernel "head.S" does not handle
    * 020 with > 1 memory segment and kernel not in first
    * segment. Force kernel into first memory segment on
    * these (020) machines.
    */

    This "hack" first appeared in Penguin-14. The file Penguin.doc says,

    Status: Changed 980301

    New setting - "68020: Don't force kernel into bank A".
    Normally the 020's requires the kernel to be placed in
    bank A memory. The Penguin will force the kernel to be put
    in that bank on these machines. This setting will ignore
    the "forcing" and put the kernel in the bank with the
    largest amount of memory available.
    NOTE: Current kernels will fail if the kernel is not
    forced into bank A. Emergency setting if all else fails.
    Only available on 020's.

    That suggests that the bank A requirement comes from a kernel limitation, perhaps stemming from a 68551 quirk (?).

    Looking at MMU code in head.S in current kernels, mmu_map_tt() seems to contain the only special case for '020. But mmu_map_tt() is only used for Nubus slot space. So I'm none the wiser.

    Perhaps we need to look at head.S from before 1998 to figure out what motivated Penguin's '020 special case and the option to disable it?

    Current head.S requires the kernel to fit in the first memory chunk,
    in 4, 8, or 16 MiB, cfr. 486df8bc4627bdfc ("m68k: Increase initial
    mapping to 8 or 16 MiB if possible").

    Gr{oetje,eeting}s,

    Geert

    --
    Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Schmitz@21:1/5 to Finn Thain on Mon Mar 22 02:20:02 2021
    Hi Finn,

    On 21/03/21 2:31 pm, Finn Thain wrote:

    If Penguin then loads the kernel in that same chunk, there really is no
    other choice? (The kernel expects the memory chunk it runs from to be
    listed first in the bootinfo struct).

    But finding the largest chunk and putting it first doesn't imply sorting
    the whole list of bootinfo memory chunks by size. Moreover, the kernel now apprently requires chunks to be sorted by physical address, not by size.

    I see.  You are correct - the only constraint really is that the largest
    chunk (with the kernel in it) come first.

    The remaining chunks do not have to be sorted by size but could appear
    in any order. I guess once the RAM chunk list has been sorted, it was
    most convenient to use that sorted list directly for the bootinfo records.


    Why not sort chunks by physical address and omit any chunks prior to the largest one, to satisfy both requirements? Then ask users to re-arrange
    RAM SIMMs such that bank A is the largest.

    Yes, that could be done. I don't think the kernel would mind any RAM
    banks not passed in the bootinfo struct (to wit, IIRC amiboot has a
    'memfile' option to allow exclusion of RAM chunks from bootinfo, to skip
    RAM that's slow or unreliable).

    A warning from Penguin with advice to rearrange the largest RAM into
    bank A (if possible) would certainly be more visible to the user than
    the one-line warning early in the kernel boot log.

    Does any of this help with the problem of RBV Macs? Video RAM must start
    at address 0x0, and reordering RAM to have the largest chunk at that
    address would occupy the RBV video range and render RBV unusable? Can
    you even rearrange RAM in these machines?


    I wonder about the 020 sorting scheme though - is there a hardware rule
    that says the first chunk must be the largest on 020?

    The Penguin-19 source code says,

    /* Hack for 020/68851. Kernel "head.S" does not handle
    * 020 with > 1 memory segment and kernel not in first
    * segment. Force kernel into first memory segment on
    * these (020) machines.
    */

    This "hack" first appeared in Penguin-14. The file Penguin.doc says,

    Status: Changed 980301

    New setting - "68020: Don't force kernel into bank A".
    Normally the 020's requires the kernel to be placed in
    bank A memory. The Penguin will force the kernel to be put
    in that bank on these machines. This setting will ignore
    the "forcing" and put the kernel in the bank with the
    largest amount of memory available.
    NOTE: Current kernels will fail if the kernel is not
    forced into bank A. Emergency setting if all else fails.
    Only available on 020's.

    That suggests that the bank A requirement comes from a kernel limitation, perhaps stemming from a 68551 quirk (?).
    The 68020/68851 combo is functionally equivalent to the 68030 as far as
    I recall. I don't think such a limitation exists today in today's head.S.

    Looking at MMU code in head.S in current kernels, mmu_map_tt() seems to contain the only special case for '020. But mmu_map_tt() is only used for Nubus slot space. So I'm none the wiser.
    Yes, and what mmu_map_tt falls back to on 020 is the same code that gets otherwise used on 030 and 020 alike. I can't see a reason why this hack
    would still be necessary.
    Perhaps we need to look at head.S from before 1998 to figure out what motivated Penguin's '020 special case and the option to disable it?

    I know the head.S MMU code was completely rewritten around that time to accommodate changes needed for the Mac port. What we used before on
    Atari and Amiga bears little to no relation to what we have now. My
    guess is that 030 (has transparent translation register) and 020 (does
    not have tt1) used distinct code paths before the rewrite, but share
    much of the code now.

    I haven't found a kernel source that old on my system so I can't verify
    my recollection of this though. Geert has a git tree somewhere that
    contains all the ancient history, might be worth checking.

    Cheers,

        Michael

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brad Boyer@21:1/5 to Michael Schmitz on Mon Mar 22 06:30:01 2021
    On Mon, Mar 22, 2021 at 02:19:10PM +1300, Michael Schmitz wrote:
    Does any of this help with the problem of RBV Macs? Video RAM must start at address 0x0, and reordering RAM to have the largest chunk at that address would occupy the RBV video range and render RBV unusable? Can you even rearrange RAM in these machines?

    You can rearrange the RAM in a IIci, but not in a IIsi. The IIsi has
    the first bank soldered in and so is always 1MB. Incidentally this
    means that if you have more than 2MB (which would be a requirement
    for running Linux in any case) then bank B would have to be bigger.

    Brad Boyer
    flar@allandria.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Finn Thain@21:1/5 to Michael Schmitz on Mon Mar 22 06:30:01 2021
    This message is in MIME format. The first part should be readable text,
    while the remaining parts are likely unreadable without MIME-aware tools.

    On Mon, 22 Mar 2021, Michael Schmitz wrote:

    On 21/03/21 2:31 pm, Finn Thain wrote:

    If Penguin then loads the kernel in that same chunk, there really is
    no other choice? (The kernel expects the memory chunk it runs from
    to be listed first in the bootinfo struct).

    But finding the largest chunk and putting it first doesn't imply
    sorting the whole list of bootinfo memory chunks by size. Moreover,
    the kernel now apprently requires chunks to be sorted by physical
    address, not by size.

    I see.  You are correct - the only constraint really is that the largest chunk (with the kernel in it) come first.

    The remaining chunks do not have to be sorted by size but could appear
    in any order.

    It seems that I misunderstood the "Ignoring memory chunk" warning. I
    thought that all chunks had to be sorted by physical address. But the
    actual requirement in arch/m68k/mm/motorola.c is only that
    m68k_memory[0].addr < m68k_memory[i].addr, where i > 0.

    The other constraints (thanks to Geert for pointing them out) come from arch/m68k/kernel/head.S. The first chunk has to contain the kernel and
    have size >= 4 MB (preferably 8 or 16 MB).

    I guess once the RAM chunk list has been sorted, it was most convenient
    to use that sorted list directly for the bootinfo records.


    A constraint that says the first chunk must be the largest one is
    undesirable because if the largest chunk has higher address than some
    other large chunk, the latter would become inaccessible.

    A similar problem arises when you have only two chunks of equal size.
    Sorting by size doesn't help and the bootloader could theoretically end up putting the kernel in bank B, leaving bank A unavailable.


    Why not sort chunks by physical address and omit any chunks prior to
    the largest one, to satisfy both requirements? Then ask users to re-arrange RAM SIMMs such that bank A is the largest.

    Yes, that could be done. I don't think the kernel would mind any RAM
    banks not passed in the bootinfo struct (to wit, IIRC amiboot has a 'memfile' option to allow exclusion of RAM chunks from bootinfo, to skip
    RAM that's slow or unreliable).


    Based on the commit that Geert cited, I'd be inclined to sort chunks by physical address, find the lowest chunk having size >= 16 MB and put that
    one and the higher ones into bootinfo. (Or failing that, find the one
    having size >= 8 MB, or failing that, 4 MB.)

    A full sort isn't really needed here but does offer some determinism. Are there implications for mm data structures? E.g. memblock_add_node() is
    called for each chunk, and if the chunks are in the "wrong" order, perhaps that would affect mm algorithms (?)

    A warning from Penguin with advice to rearrange the largest RAM into
    bank A (if possible) would certainly be more visible to the user than
    the one-line warning early in the kernel boot log.


    I agree. The existing warning isn't very helpful.

    Does any of this help with the problem of RBV Macs? Video RAM must start
    at address 0x0, and reordering RAM to have the largest chunk at that
    address would occupy the RBV video range and render RBV unusable? Can
    you even rearrange RAM in these machines?


    I've argued elsewhere in this thread that the bank A issue in RBV Macs
    doesn't matter that much.

    If on-board video is enabled, bank A is slowed down. That suggests to me
    that bank A is probably not that useful for Linux and is probably
    relatively small anyway. As Brad said, bank A is always 1 MB on a IIsi. So
    I don't mind if Linux ignores it in this case.

    If on-board video is disabled, we can treat both banks in an RBV Mac the
    same (like we would a non-RBV Mac).


    I wonder about the 020 sorting scheme though - is there a hardware
    rule that says the first chunk must be the largest on 020?

    The Penguin-19 source code says,

    /* Hack for 020/68851. Kernel "head.S" does not handle
    * 020 with > 1 memory segment and kernel not in first
    * segment. Force kernel into first memory segment on
    * these (020) machines.
    */

    This "hack" first appeared in Penguin-14. The file Penguin.doc says,

    Status: Changed 980301

    New setting - "68020: Don't force kernel into bank A".
    Normally the 020's requires the kernel to be placed in
    bank A memory. The Penguin will force the kernel to be put
    in that bank on these machines. This setting will ignore
    the "forcing" and put the kernel in the bank with the
    largest amount of memory available.
    NOTE: Current kernels will fail if the kernel is not
    forced into bank A. Emergency setting if all else fails.
    Only available on 020's.

    That suggests that the bank A requirement comes from a kernel limitation, perhaps stemming from a 68551 quirk (?).
    The 68020/68851 combo is functionally equivalent to the 68030 as far as
    I recall. I don't think such a limitation exists today in today's
    head.S.

    Looking at MMU code in head.S in current kernels, mmu_map_tt() seems
    to contain the only special case for '020. But mmu_map_tt() is only
    used for Nubus slot space. So I'm none the wiser.
    Yes, and what mmu_map_tt falls back to on 020 is the same code that gets otherwise used on 030 and 020 alike. I can't see a reason why this hack would still be necessary.

    It appears that EMILE does not have this hack for 68020/68851. (I assume
    EMILE has been tested on 68020/68851.)

    Perhaps we need to look at head.S from before 1998 to figure out what motivated Penguin's '020 special case and the option to disable it?

    I know the head.S MMU code was completely rewritten around that time to accommodate changes needed for the Mac port. What we used before on
    Atari and Amiga bears little to no relation to what we have now. My
    guess is that 030 (has transparent translation register) and 020 (does
    not have tt1) used distinct code paths before the rewrite, but share
    much of the code now.

    I haven't found a kernel source that old on my system so I can't verify
    my recollection of this though. Geert has a git tree somewhere that
    contains all the ancient history, might be worth checking.


    Maybe that rewrite happened around the "pre2.05" release... https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/arch/m68k/kernel/head.S?h=2.0&id=37147b87dddfc389e97d99f078be5a0f1012ba74

    Unfortunately, even in the oldest head.S at that link, it's not obvious to
    me why 68020/68851 and 68030 would execute different code paths. It's easy
    to believe that the Penguin hack for 68020/68851 was incomplete (should
    have been extended to 68030).

    But that's academic. If we change the bootloader to fix the issue that
    Stan reported and if it remains backwards compatible with Linux v2.2.25
    (or Debian 3) I'd be happy with that.

    Cheers,

        Michael




    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geert Uytterhoeven@21:1/5 to schmitzmic@gmail.com on Mon Mar 22 09:00:01 2021
    Hi Michael,

    On Mon, Mar 22, 2021 at 2:19 AM Michael Schmitz <schmitzmic@gmail.com> wrote:
    On 21/03/21 2:31 pm, Finn Thain wrote:
    This "hack" first appeared in Penguin-14. The file Penguin.doc says,

    Status: Changed 980301

    New setting - "68020: Don't force kernel into bank A".
    Normally the 020's requires the kernel to be placed in
    bank A memory. The Penguin will force the kernel to be put
    in that bank on these machines. This setting will ignore
    the "forcing" and put the kernel in the bank with the
    largest amount of memory available.
    NOTE: Current kernels will fail if the kernel is not
    forced into bank A. Emergency setting if all else fails.
    Only available on 020's.

    That suggests that the bank A requirement comes from a kernel limitation, perhaps stemming from a 68551 quirk (?).
    The 68020/68851 combo is functionally equivalent to the 68030 as far as
    I recall. I don't think such a limitation exists today in today's head.S.

    Looking at MMU code in head.S in current kernels, mmu_map_tt() seems to contain the only special case for '020. But mmu_map_tt() is only used for Nubus slot space. So I'm none the wiser.
    Yes, and what mmu_map_tt falls back to on 020 is the same code that gets otherwise used on 030 and 020 alike. I can't see a reason why this hack
    would still be necessary.
    Perhaps we need to look at head.S from before 1998 to figure out what motivated Penguin's '020 special case and the option to disable it?

    I know the head.S MMU code was completely rewritten around that time to accommodate changes needed for the Mac port. What we used before on
    Atari and Amiga bears little to no relation to what we have now. My
    guess is that 030 (has transparent translation register) and 020 (does
    not have tt1) used distinct code paths before the rewrite, but share
    much of the code now.

    But the 68020 does have early termination pages, which map (IIRC) 2 MiB
    at once. In the early days, 2 MiB should have been fine to map the kernel.
    As that's the only mechanism used by head.S, perhaps the real reason for picking the largest chunk on Mac is that you cannot map contiguously
    using early termination pages a series of discontiguous 1 MiB banks?

    Gr{oetje,eeting}s,

    Geert

    --
    Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Schmitz@21:1/5 to Finn Thain on Mon Mar 22 22:50:01 2021
    This is a multi-part message in MIME format.
    Hi Finn,

    On 22/03/21 6:24 pm, Finn Thain wrote:
    I guess once the RAM chunk list has been sorted, it was most convenient
    to use that sorted list directly for the bootinfo records.

    A constraint that says the first chunk must be the largest one is
    undesirable because if the largest chunk has higher address than some
    other large chunk, the latter would become inaccessible.

    A similar problem arises when you have only two chunks of equal size.
    Sorting by size doesn't help and the bootloader could theoretically end up putting the kernel in bank B, leaving bank A unavailable.
    Can't fault your reasoning there. The use case of multiple large chunks
    present (and only the largest one used unless banks are rearranged)
    might have been rare back in '98.

    Why not sort chunks by physical address and omit any chunks prior to
    the largest one, to satisfy both requirements? Then ask users to
    re-arrange RAM SIMMs such that bank A is the largest.
    Yes, that could be done. I don't think the kernel would mind any RAM
    banks not passed in the bootinfo struct (to wit, IIRC amiboot has a
    'memfile' option to allow exclusion of RAM chunks from bootinfo, to skip
    RAM that's slow or unreliable).

    Based on the commit that Geert cited, I'd be inclined to sort chunks by physical address, find the lowest chunk having size >= 16 MB and put that
    one and the higher ones into bootinfo. (Or failing that, find the one
    having size >= 8 MB, or failing that, 4 MB.)

    Do you know the size of the uncompressed kernel at that stage? That way,
    you could skip all RAM banks smaller than that size (plus some margin
    for the initial mappings, one 4k page for each 4 MB of chunk size plus
    required number of pointer table pages) and use the first one (lowest
    address one) that satisfies such a minimum size criterion.

    In this way, you won't lose all of the smaller but still useful banks,
    just in case a user arranged the banks in ascending size order.

    (Skipping the lower address banks isn't strictly required BTW - the
    kernel will warn and ignore them as it used to. No harm done.)

    A full sort isn't really needed here but does offer some determinism. Are there implications for mm data structures? E.g. memblock_add_node() is
    called for each chunk, and if the chunks are in the "wrong" order, perhaps that would affect mm algorithms (?)
    There is no checks about order that I would have seen. But the reason
    why memory with lower addresses than mapped by head.S can't be used
    still isn't clear to me. Best leave the rest of the chunk list in
    address order.
    Does any of this help with the problem of RBV Macs? Video RAM must start
    at address 0x0, and reordering RAM to have the largest chunk at that
    address would occupy the RBV video range and render RBV unusable? Can
    you even rearrange RAM in these machines?

    I've argued elsewhere in this thread that the bank A issue in RBV Macs doesn't matter that much.

    If on-board video is enabled, bank A is slowed down. That suggests to me
    that bank A is probably not that useful for Linux and is probably
    relatively small anyway. As Brad said, bank A is always 1 MB on a IIsi. So
    I don't mind if Linux ignores it in this case.
    Probably good cause to only use it for video RAM through a separate
    allocator and pool (if a user absolutely insists and someone writes a
    patch that you would accept). We can't share it with the kernel anyway
    at present (and with a fixed size of 1 MB, it would be useless for
    modern times kernels).
    Perhaps we need to look at head.S from before 1998 to figure out what
    motivated Penguin's '020 special case and the option to disable it?
    I know the head.S MMU code was completely rewritten around that time to
    accommodate changes needed for the Mac port. What we used before on
    Atari and Amiga bears little to no relation to what we have now. My
    guess is that 030 (has transparent translation register) and 020 (does
    not have tt1) used distinct code paths before the rewrite, but share
    much of the code now.

    I haven't found a kernel source that old on my system so I can't verify
    my recollection of this though. Geert has a git tree somewhere that
    contains all the ancient history, might be worth checking.

    Maybe that rewrite happened around the "pre2.05" release... https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/arch/m68k/kernel/head.S?h=2.0&id=37147b87dddfc389e97d99f078be5a0f1012ba74

    Unfortunately, even in the oldest head.S at that link, it's not obvious to
    me why 68020/68851 and 68030 would execute different code paths. It's easy
    to believe that the Penguin hack for 68020/68851 was incomplete (should
    have been extended to 68030).

    I think I've found the difference: commit 75ce89a86b88c2dd77a0d2697c1ecaf9c53016ce (the earliest//I found) has
    head.S set up a page descriptor entry at the pointer table level (i.e.
    'early termination' descriptor). That maps 32 MB in one go, regardless
    of size and alignment of that chunk, which would not have mattered for
    Atari and Amiga (as far as I know, the RAM banks are far enough apart
    for such mappings not to overlap) but might have caused trouble on Mac
    if the RAM banks fall within 32 MB and the kernel runs from the second
    bank (which then isn't 32 MB aligned).

    Today's head.S only uses early termination only if both size and
    alignment match.

    As you said, there is no distinction made between 020 and 030 in that
    code, so the same hack should have been applied to 030. Maybe the MacII
    (were there other 020 Macs?) was the only one with RAM banks A and B
    spaced closer than 32 MB?

    But that's academic. If we change the bootloader to fix the issue that
    Stan reported and if it remains backwards compatible with Linux v2.2.25
    (or Debian 3) I'd be happy with that.

    I'm quite certain that today's head.S needs no more 020 hacks and ought
    to work on MacII if you can fit enough RAM in bank B to hold the kernel.
    But finding a MacII to test this on is more than a little academic indeed.

    Let's fix the meminfo chunk ordering and see whether that fixes Stan's
    issues. I have no doubt that as long as the long-standing constraint
    about the first chunk holding the kernel isn't violated, old kernels
    will continue to boot OK.

    Cheers,

        Michael



    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <p>Hi Finn,<br>
    </p>
    <div class="moz-cite-prefix">On 22/03/21 6:24 pm, Finn Thain wrote:
    </div>
    <blockquote type="cite"
    cite="mid:6637ea42-44f7-8f4f-69d2-1eae9ebbe9c6@telegraphics.com.au">
    <blockquote type="cite">
    <pre class="moz-quote-pre" wrap="">I guess once the RAM chunk list has been sorted, it was most convenient
    to use that sorted list directly for the bootinfo records.

    </pre>
    </blockquote>
    <pre class="moz-quote-pre" wrap="">
    A constraint that says the first chunk must be the largest one is
    undesirable because if the largest chunk has higher address than some
    other large chunk, the latter would become inaccessible.

    A similar problem arises when you have only two chunks of equal size.
    Sorting by size doesn't help and the bootloader could theoretically end up putting the kernel in bank B, leaving bank A unavailable.</pre>
    </blockquote>
    Can't fault your reasoning there. The use case of multiple large
    chunks present (and only the largest one used unless banks are
    rearranged) might have been rare back in '98.<br>
    <blockquote type="cite"
    cite="mid:6637ea42-44f7-8f4f-69d2-1eae9ebbe9c6@telegraphics.com.au">
    <pre class="moz-quote-pre" wrap="">

    </pre>
    <blockquote type="cite">
    <blockquote type="cite">
    <pre class="moz-quote-pre" wrap="">
    Why not sort chunks by physical address and omit any chunks prior to
    the largest one, to satisfy both requirements? Then ask users to
    re-arrange RAM SIMMs such that bank A is the largest.
    </pre>
    </blockquote>
    <pre class="moz-quote-pre" wrap="">
    Yes, that could be done. I don't think the kernel would mind any RAM
    banks not passed in the bootinfo struct (to wit, IIRC amiboot has a
    'memfile' option to allow exclusion of RAM chunks from bootinfo, to skip
    RAM that's slow or unreliable).

    </pre>
    </blockquote>
    <pre class="moz-quote-pre" wrap="">
    Based on the commit that Geert cited, I'd be inclined to sort chunks by physical address, find the lowest chunk having size &gt;= 16 MB and put that one and the higher ones into bootinfo. (Or failing that, find the one
    having size &gt;= 8 MB, or failing that, 4 MB.)</pre>
    </blockquote>
    <p>Do you know the size of the uncompressed kernel at that stage?
    That way, you could skip all RAM banks smaller than that size
    (plus some margin for the initial mappings, one 4k page for each 4
    MB of chunk size plus required number of pointer table pages) and
    use the first one (lowest address one) that satisfies such a
    minimum size criterion. <br>
    </p>
    <p>In this way, you won't lose all of the smaller but still useful
    banks, just in case a user arranged the banks in ascending size
    order. <br>
    </p>
    <p>(Skipping the lower address banks isn't strictly required BTW -
    the kernel will warn and ignore them as it used to. No harm done.)<br>
    </p>
    <blockquote type="cite"
    cite="mid:6637ea42-44f7-8f4f-69d2-1eae9ebbe9c6@telegraphics.com.au">
    <pre class="moz-quote-pre" wrap="">A full sort isn't really needed here but does offer some determinism. Are
    there implications for mm data structures? E.g. memblock_add_node() is
    called for each chunk, and if the chunks are in the "wrong" order, perhaps
    that would affect mm algorithms (?)</pre>
    </blockquote>
    There is no checks about order that I would have seen. But the
    reason why memory with lower addresses than mapped by head.S can't
    be used still isn't clear to me. Best leave the rest of the chunk
    list in address order. <br>
    <blockquote type="cite"
    cite="mid:6637ea42-44f7-8f4f-69d2-1eae9ebbe9c6@telegraphics.com.au">
    <blockquote type="cite">
    <pre class="moz-quote-pre" wrap="">Does any of this help with the problem of RBV Macs? Video RAM must start
    at address 0x0, and reordering RAM to have the largest chunk at that
    address would occupy the RBV video range and render RBV unusable? Can
    you even rearrange RAM in these machines?

    </pre>
    </blockquote>
    <pre class="moz-quote-pre" wrap="">
    I've argued elsewhere in this thread that the bank A issue in RBV Macs
    doesn't matter that much.

    If on-board video is enabled, bank A is slowed down. That suggests to me
    that bank A is probably not that useful for Linux and is probably
    relatively small anyway. As Brad said, bank A is always 1 MB on a IIsi. So
    I don't mind if Linux ignores it in this case.</pre>
    </blockquote>
    Probably good cause to only use it for video RAM through a separate
    allocator and pool (if a user absolutely insists and someone writes
    a patch that you would accept). We can't share it with the kernel
    anyway at present (and with a fixed size of 1 MB, it would be
    useless for modern times kernels).
    <blockquote type="cite"
    cite="mid:6637ea42-44f7-8f4f-69d2-1eae9ebbe9c6@telegraphics.com.au">
    <blockquote type="cite">
    <blockquote type="cite">
    <pre class="moz-quote-pre" wrap="">Perhaps we need to look at head.S from before 1998 to figure out what
    motivated Penguin's '020 special case and the option to disable it?
    </pre>
    </blockquote>
    <pre class="moz-quote-pre" wrap="">
    I know the head.S MMU code was completely rewritten around that time to accommodate changes needed for the Mac port. What we used before on
    Atari and Amiga bears little to no relation to what we have now. My
    guess is that 030 (has transparent translation register) and 020 (does
    not have tt1) used distinct code paths before the rewrite, but share
    much of the code now.

    I haven't found a kernel source that old on my system so I can't verify
    my recollection of this though. Geert has a git tree somewhere that
    contains all the ancient history, might be worth checking.

    </pre>
    </blockquote>
    <pre class="moz-quote-pre" wrap="">
    Maybe that rewrite happened around the "pre2.05" release...
    <a class="moz-txt-link-freetext" href="https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/arch/m68k/kernel/head.S?h=2.0&amp;id=37147b87dddfc389e97d99f078be5a0f1012ba74">https://git.kernel.org/pub/scm/linux/kernel/git/history/
    history.git/commit/arch/m68k/kernel/head.S?h=2.0&amp;id=37147b87dddfc389e97d99f078be5a0f1012ba74</a>

    Unfortunately, even in the oldest head.S at that link, it's not obvious to
    me why 68020/68851 and 68030 would execute different code paths. It's easy
    to believe that the Penguin hack for 68020/68851 was incomplete (should
    have been extended to 68030).</pre>
    </blockquote>
    <p>I think I've found the difference: commit
    75ce89a86b88c2dd77a0d2697c1ecaf9c53016ce (the earliest<i> </i>I
    found) has head.S set up a page descriptor entry at the pointer
    table level (i.e. 'early termination' descriptor). That maps 32 MB
    in one go, regardless of size and alignment of that chunk, which
    would not have mattered for Atari and Amiga (as far as I know, the
    RAM banks are far enough apart for such mappings not to overlap)
    but might have caused trouble on Mac if the RAM banks fall within
    32 MB and the kernel runs from the second bank (which then isn't
    32 MB aligned). <br>
    </p>
    <p>Today's head.S only uses early termination only if both size and
    alignment match. <br>
    </p>
    <p>As you said, there is no distinction made between 020 and 030 in
    that code, so the same hack should have been applied to 030. Maybe
    the MacII (were there other 020 Macs?) was the only one with RAM
    banks A and B spaced closer than 32 MB? <br>
    </p>
    <blockquote type="cite"
    cite="mid:6637ea42-44f7-8f4f-69d2-1eae9ebbe9c6@telegraphics.com.au">
    <pre class="moz-quote-pre" wrap="">But that's academic. If we change the bootloader to fix the issue that
    Stan reported and if it remains backwards compatible with Linux v2.2.25
    (or Debian 3) I'd be happy with that.</pre>
    </blockquote>
    <p>I'm quite certain that today's head.S needs no more 020 hacks and
    ought to work on MacII if you can fit enough RAM in bank B to hold
    the kernel. But finding a MacII to test this on is more than a
    little academic indeed. <br>
    </p>
    <p>Let's fix the meminfo chunk ordering and see whether that fixes
    Stan's issues. I have no doubt that as long as the long-standing
    constraint about the first chunk holding the kernel isn't
    violated, old kernels will continue to boot OK. <br>
    </p>
    <p>Cheers,</p>
    <p>    Michael</p>
    <p><br>
    </p>
    </body>
    </html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Finn Thain@21:1/5 to Geert Uytterhoeven on Tue Mar 23 09:00:01 2021
    On Mon, 22 Mar 2021, Geert Uytterhoeven wrote:


    I know the head.S MMU code was completely rewritten around that time
    to accommodate changes needed for the Mac port. What we used before on Atari and Amiga bears little to no relation to what we have now. My
    guess is that 030 (has transparent translation register) and 020 (does
    not have tt1) used distinct code paths before the rewrite, but share
    much of the code now.

    But the 68020 does have early termination pages, which map (IIRC) 2 MiB
    at once. In the early days, 2 MiB should have been fine to map the
    kernel. As that's the only mechanism used by head.S, perhaps the real
    reason for picking the largest chunk on Mac is that you cannot map contiguously using early termination pages a series of discontiguous 1
    MiB banks?


    Perhaps other bootloaders make allowance for 1 MiB banks when running on
    early MMUs but I don't think Penguin does.

    Source/asm.a appears to disable the MMU before copying the kernel and
    initrd into the first chunk of RAM. (On Mac II the lowest chunk is the
    first one. On the other Mac models, the largest one is the first one.)

    Anyway, surely this test for CPU_68020 in Source/mmu_support.c in Penguin
    is bogus. This must have to do with some quirk of the Mac II logic board
    and not the type of MMU or CPU.

    So, why sort chunks by address on Mac II? Beats me. I guess I'll have to
    dig out my Mac II and try EMILE, which doesn't have that hack.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Geert Uytterhoeven@21:1/5 to schmitzmic@gmail.com on Tue Mar 23 09:40:02 2021
    Hi Michael,

    On Mon, Mar 22, 2021 at 10:48 PM Michael Schmitz <schmitzmic@gmail.com> wrote:
    Based on the commit that Geert cited, I'd be inclined to sort chunks by physical address, find the lowest chunk having size >= 16 MB and put that
    one and the higher ones into bootinfo. (Or failing that, find the one
    having size >= 8 MB, or failing that, 4 MB.)

    Do you know the size of the uncompressed kernel at that stage? That way, you could skip all RAM banks smaller than that size (plus some margin for the initial mappings, one 4k page for each 4 MB of chunk size plus required number of pointer table pages)
    and use the first one (lowest address one) that satisfies such a minimum size criterion.

    In this way, you won't lose all of the smaller but still useful banks, just in case a user arranged the banks in ascending size order.

    (Skipping the lower address banks isn't strictly required BTW - the kernel will warn and ignore them as it used to. No harm done.)

    A full sort isn't really needed here but does offer some determinism. Are there implications for mm data structures? E.g. memblock_add_node() is
    called for each chunk, and if the chunks are in the "wrong" order, perhaps that would affect mm algorithms (?)

    There is no checks about order that I would have seen. But the reason why memory with lower addresses than mapped by head.S can't be used still isn't clear to me. Best leave the rest of the chunk list in address order.

    Because the logic handling physical pages is basically a data structure
    like (simplied) pages[address - base], with base the address of the first chunk. So you can't have a negative index.

    Gr{oetje,eeting}s,

    Geert

    --
    Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brad Boyer@21:1/5 to Finn Thain on Tue Mar 23 10:00:02 2021
    On Tue, Mar 23, 2021 at 06:50:05PM +1100, Finn Thain wrote:
    Anyway, surely this test for CPU_68020 in Source/mmu_support.c in Penguin
    is bogus. This must have to do with some quirk of the Mac II logic board
    and not the type of MMU or CPU.

    So, why sort chunks by address on Mac II? Beats me. I guess I'll have to
    dig out my Mac II and try EMILE, which doesn't have that hack.

    Apparently there was a bug in the original Mac II ROM that couldn't
    handle more than 4MB in bank A. That would mean that anyone who had
    more than 8MB had the larger modules in bank B. The claim online is
    that it is possible to replace the ROM chips with a fixed version
    (which happens to be the part also found in a Mac IIx) to enable
    using larger modules in both banks. It was also supported to replace
    the IWM chip with a SWIM chip as long as you had also replaced the
    ROM chips with the newer ones. In any case, both the II and IIx need
    some funny PAL enhanced SIMMs to use larger sizes. They fixed that
    in the IIcx and SE/30, which are the same basic logical design.

    However, I would have thought this would lead to the opposite solution.

    Brad Boyer
    flar@allandria.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Brad Boyer@21:1/5 to Michael Schmitz on Tue Mar 23 10:40:01 2021
    On Tue, Mar 23, 2021 at 10:48:07AM +1300, Michael Schmitz wrote:
    As you said, there is no distinction made between 020 and 030 in that code, so the same hack should have been applied to 030. Maybe the MacII (were
    there other 020 Macs?) was the only one with RAM banks A and B spaced closer than 32 MB?

    The only other 68020 mac is the Macintosh LC, but Apple didn't put a
    socket for the 68851 on it like there is on the Mac II. That means that
    there's no way to get a real MMU to run a normal Linux kernel.

    The logic of the II, IIx, IIcx, and SE/30 are basically identical.
    Obviously there are some differences (like the SE/30 leaving off a
    bunch of the NuBus logic due to only having a PDS slot), but they
    use the same basic addressing layout. The Guide to the Macintosh
    Family Hardware explains how to control the GLUE chip which
    determines what shows up at various addresses on these 4 models
    (and specifically not on anything else). Bit 4 in VIA1 regA is
    the vOverlay bit and can force the ROM to show up in place of the
    RAM. Bits 6 and 7 in VIA2 regA tell GLUE where to map bank B,
    although it's documented as specifying the size of the chips in
    bank A. By using these bits (the four values are for 256kb, 1Mb,
    4Mb, or 16Mb chips leading to offsets of 1MB, 4MB, 16MB, or 64MB).
    The ROM will always have used this to pack the two banks together
    in the physical address space.

    Something amusing I noticed in the Guide when reading through the
    description of memory mapping is that apparently they used an MMU
    mapping to make the RBV video buffer (which it does say is fixed
    at physical address 0x00000000) show up as if it was a NuBus slot,
    although one that doesn't physically exist on a IIci and can't
    be emulated by a PDS card or the NuBus adapter card in a IIsi.
    The implication is that the official RBV driver pretends to be a
    NuBus device driver.

    Brad Boyer
    flar@allandria.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Finn Thain@21:1/5 to Brad Boyer on Wed Mar 24 02:10:02 2021
    On Tue, 23 Mar 2021, Brad Boyer wrote:

    On Tue, Mar 23, 2021 at 06:50:05PM +1100, Finn Thain wrote:
    Anyway, surely this test for CPU_68020 in Source/mmu_support.c in
    Penguin is bogus. This must have to do with some quirk of the Mac II
    logic board and not the type of MMU or CPU.

    So, why sort chunks by address on Mac II? Beats me. I guess I'll have
    to dig out my Mac II and try EMILE, which doesn't have that hack.

    Apparently there was a bug in the original Mac II ROM that couldn't
    handle more than 4MB in bank A. That would mean that anyone who had more
    than 8MB had the larger modules in bank B.

    Right. And, of course, the original Mac II is not the only model where
    bank B might be larger than bank A.

    Also, I found that it's not just the IIsi that has a small bank A that's
    all soldered-in. The IIvi/vx and Quadra 700 are in the same category.

    It appears that both Penguin and EMILE are likely to disappoint on these systems.

    It's a pity bootloaders don't share more code. I think there's a good
    argument for fixing this in EMILE and then wrapping a MacOS GUI around it,
    that could supercede Penguin eventually.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Finn Thain@21:1/5 to Michael Schmitz on Wed Mar 24 02:10:02 2021
    This message is in MIME format. The first part should be readable text,
    while the remaining parts are likely unreadable without MIME-aware tools.

    On Tue, 23 Mar 2021, Michael Schmitz wrote:

    On 22/03/21 6:24 pm, Finn Thain wrote:
    I guess once the RAM chunk list has been sorted, it was most
    convenient to use that sorted list directly for the bootinfo
    records.

    A constraint that says the first chunk must be the largest one is undesirable because if the largest chunk has higher address than some other large chunk, the latter would become inaccessible.

    A similar problem arises when you have only two chunks of equal size. Sorting by size doesn't help and the bootloader could theoretically
    end up putting the kernel in bank B, leaving bank A unavailable.

    Can't fault your reasoning there. The use case of multiple large chunks present (and only the largest one used unless banks are rearranged)
    might have been rare back in '98.


    The larger-bank-B issue would have to be an old one but it only affects a
    few models.

    The equal-sized-banks problem is only theoretical at this stage. Penguin
    uses a stable sorting algorithm for the RAM chunks which means that if
    banks A and B had equal size, there would be no re-ordering at all. (I'm ignoring Penguin's Mac II hack here.)

    That means RAM chunks would remain in logical address sequence. I wonder whether that sequence could differ between the ROM execution environment
    (for EMILE) and that of MacOS applications (for Penguin)...

    Why not sort chunks by physical address and omit any chunks prior
    to the largest one, to satisfy both requirements? Then ask users
    to re-arrange RAM SIMMs such that bank A is the largest.

    Yes, that could be done. I don't think the kernel would mind any RAM banks not passed in the bootinfo struct (to wit, IIRC amiboot has a 'memfile' option to allow exclusion of RAM chunks from bootinfo, to
    skip RAM that's slow or unreliable).

    Based on the commit that Geert cited, I'd be inclined to sort chunks
    by physical address, find the lowest chunk having size >= 16 MB and
    put that one and the higher ones into bootinfo. (Or failing that, find
    the one having size >= 8 MB, or failing that, 4 MB.)

    Do you know the size of the uncompressed kernel at that stage? That way,
    you could skip all RAM banks smaller than that size (plus some margin
    for the initial mappings, one 4k page for each 4 MB of chunk size plus required number of pointer table pages) and use the first one (lowest address one) that satisfies such a minimum size criterion.

    In this way, you won't lose all of the smaller but still useful banks,
    just in case a user arranged the banks in ascending size order.


    Right. The difficulty is the "some margin" part, which seems fairly complicated.

    (Skipping the lower address banks isn't strictly required BTW - the
    kernel will warn and ignore them as it used to. No harm done.)

    [...]

    Does any of this help with the problem of RBV Macs? Video RAM must
    start at address 0x0, and reordering RAM to have the largest chunk
    at that address would occupy the RBV video range and render RBV unusable? Can you even rearrange RAM in these machines?

    I've argued elsewhere in this thread that the bank A issue in RBV Macs doesn't matter that much.

    If on-board video is enabled, bank A is slowed down. That suggests to
    me that bank A is probably not that useful for Linux and is probably relatively small anyway. As Brad said, bank A is always 1 MB on a
    IIsi. So I don't mind if Linux ignores it in this case.

    Probably good cause to only use it for video RAM through a separate allocator and pool (if a user absolutely insists and someone writes a
    patch that you would accept). We can't share it with the kernel anyway
    at present (and with a fixed size of 1 MB, it would be useless for
    modern times kernels).


    I don't understand Linux MM in sufficient depth to comment.

    Anyway, Penguin does take pains to support booting from bank A when
    on-board video is enabled in RBV machines. (The performance penalty can be minimized: for 1 bpp, 640 x 480, 67 Hz the penalty is only 6% of the full bandwidth of bank A RAM. And the framebuffer would only cost 64 KiB. So
    there is value in supporting this configuration.)

    [...]

    I think I've found the difference: commit 75ce89a86b88c2dd77a0d2697c1ecaf9c53016ce (the earliest//I found) has
    head.S set up a page descriptor entry at the pointer table level (i.e. 'early termination' descriptor). That maps 32 MB in one go, regardless
    of size and alignment of that chunk, which would not have mattered for
    Atari and Amiga (as far as I know, the RAM banks are far enough apart
    for such mappings not to overlap) but might have caused trouble on Mac
    if the RAM banks fall within 32 MB and the kernel runs from the second
    bank (which then isn't 32 MB aligned).


    I didn't find that commit. But it certainly sounds like you've put your
    finger on the underlying issue. Thanks for solving this mystery!

    Today's head.S only uses early termination only if both size and
    alignment match.


    OK.

    As you said, there is no distinction made between 020 and 030 in that
    code, so the same hack should have been applied to 030. Maybe the MacII (were there other 020 Macs?) was the only one with RAM banks A and B
    spaced closer than 32 MB?


    Brad has already dug up the answer for that question (thanks, Brad).

    But that's academic. If we change the bootloader to fix the issue that Stan reported and if it remains backwards compatible with Linux
    v2.2.25 (or Debian 3) I'd be happy with that.

    I'm quite certain that today's head.S needs no more 020 hacks and ought
    to work on MacII if you can fit enough RAM in bank B to hold the kernel.
    But finding a MacII to test this on is more than a little academic
    indeed.


    I have most of the affected models but they probably need new capacitors
    etc.

    Let's fix the meminfo chunk ordering and see whether that fixes Stan's issues. I have no doubt that as long as the long-standing constraint
    about the first chunk holding the kernel isn't violated, old kernels
    will continue to boot OK.


    Good to know.

    Cheers,

        Michael




    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)