All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Michael Schmitz <schmitzmic@gmail.com>
Cc: Linux/m68k <linux-m68k@vger.kernel.org>,
	Debian m68k <debian-68k@lists.debian.org>,
	Michael Schmitz <schmitz@debian.org>
Subject: Re: [PATCH 1/2] m68k/atari - stram: alloc ST-RAM pool even if kernel not in ST-RAM
Date: Wed, 19 Mar 2014 08:51:10 +0100	[thread overview]
Message-ID: <CAMuHMdXksY0Sfq-AN-1hi42=-yHYqgRnH0RM5z0k2oR-hPcOtQ@mail.gmail.com> (raw)
In-Reply-To: <1395213784-3249-1-git-send-email-schmitz@debian.org>

Hi Michael,

On Wed, Mar 19, 2014 at 8:23 AM, Michael Schmitz <schmitzmic@gmail.com> wrote:
> Instead of mucking around with ioremap (which appears to
> rely on the physical area being mappped by mem_init), use

That's not true. E.g. I/O memory is never mapped by mem_init().

> @@ -93,21 +92,54 @@ void __init atari_stram_init(void)
>   */
>  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);
> -
> -       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);
> +       if (kernel_in_stram) {
> +
> +               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);
> +
> +               printk("atari_stram pool: kernel in ST-RAM, using alloc_bootmem!\n");
> +
> +               printk("atari_stram pool: size = %lu bytes, resource = %pR\n",
> +                        pool_size, &stram_pool);
> +               printk("atari_stram pool: start = %p, end = %p\n",
> +                         (void *) stram_pool.start, (void *) stram_pool.end);
> +               printk("atari_stram pool: stram_virt_offset = %p\n",
> +                         (void *) stram_virt_offset);
> +       } else {
> +               /*
> +                * Skip page 0, as the fhe first 2 KiB are supervisor-only!
> +                */
> +
> +               printk("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);
> +
> +               printk("atari_stram pool: size = %lu bytes, resource = %pR\n",
> +                        pool_size, &stram_pool);
> +               printk("atari_stram pool: start = %p, end = %p\n",
> +                         (void *) stram_pool.start, (void *) stram_pool.end);
> +
> +               /* stram_virt_offset = ioremap(stram_pool.start, pool_size); */
> +               stram_virt_offset = (unsigned long) 0xFF000000;
> +
> +               printk("atari_stram pool: stram_virt_offset = %p\n",
> +                         (void *) stram_virt_offset);
> +       }

If you reorder some lines, you can share more code between the "if" and
"else" cases.

> +void *atari_stram_to_virt(unsigned long phys)
> +{
> +       return (void *)(phys + stram_virt_offset);
>  }
>
> +void *atari_stram_to_phys(unsigned long virt)

This should be "unsigned long atari_stram_to_phys(void *)",
allowing to remove a few casts in the callers...

> +{
> +       return (void *)(virt - stram_virt_offset);
> +}

>  void atari_stram_free(void *addr)
>  {
> -       unsigned long start = (unsigned long)addr;
> +       unsigned long start = (unsigned long) atari_stram_to_phys((unsigned long) addr);

... like here.

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

  parent reply	other threads:[~2014-03-19  7:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19  7:23 [PATCH 1/2] m68k/atari - stram: alloc ST-RAM pool even if kernel not in ST-RAM Michael Schmitz
2014-03-19  7:23 ` [PATCH 2/2] m68k/atari - atafb: convert allocation of fb ram to new interface Michael Schmitz
2014-03-19  8:01   ` Geert Uytterhoeven
2014-03-20  8:17     ` schmitz
2014-03-20  8:33       ` Geert Uytterhoeven
2014-03-22  1:28         ` schmitz
2014-03-22  7:36           ` schmitz
2014-03-19  7:51 ` Geert Uytterhoeven [this message]
2014-03-20  8:23   ` [PATCH 1/2] m68k/atari - stram: alloc ST-RAM pool even if kernel not in ST-RAM schmitz
2014-03-20  8:35     ` Geert Uytterhoeven
2014-03-22  1:32       ` schmitz
2014-03-23 20:02         ` Geert Uytterhoeven
2014-03-19  8:18 ` Andreas Schwab
2014-03-20  6:35 ` Patrice Mandin
2014-03-22  8:47 ` [PATCH 0/2] m68k/atari - make atafb work with kernel loaded to FastRAM Michael Schmitz
2014-03-23  0:28   ` schmitz
2014-03-22  8:47 ` [PATCH 1/2] m68k/atari - stram: alloc ST-RAM pool even if kernel not in ST-RAM Michael Schmitz
2014-03-22  8:47 ` [PATCH 2/2] m68k/atari - atafb: convert allocation of fb ram to new interface Michael Schmitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMuHMdXksY0Sfq-AN-1hi42=-yHYqgRnH0RM5z0k2oR-hPcOtQ@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=debian-68k@lists.debian.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=schmitz@debian.org \
    --cc=schmitzmic@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.