Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1629230 > unrolled thread

Re: [PATCH v4 05/11] VAS: Define helpers for access MMIO regions

Started byBenjamin Herrenschmidt <benh@kernel.crashing.org>
First post2017-04-24 08:30 +0200
Last post2017-04-25 01:30 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v4 05/11] VAS: Define helpers for access MMIO regions Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-24 08:30 +0200
    Re: [PATCH v4 05/11] VAS: Define helpers for access MMIO regions Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-04-24 19:30 +0200
      Re: [PATCH v4 05/11] VAS: Define helpers for access MMIO regions Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-25 01:30 +0200

#1629230 — Re: [PATCH v4 05/11] VAS: Define helpers for access MMIO regions

FromBenjamin Herrenschmidt <benh@kernel.crashing.org>
Date2017-04-24 08:30 +0200
SubjectRe: [PATCH v4 05/11] VAS: Define helpers for access MMIO regions
Message-ID<tzFFw-3rT-11@gated-at.bofh.it>
On Thu, 2017-03-30 at 22:13 -0700, Sukadev Bhattiprolu wrote:
> +static void *map_mmio_region(char *name, uint64_t start, int len)
> +{
> +       void *map;
> +
> +       if (!request_mem_region(start, len, name)) {
> +               pr_devel("%s(): request_mem_region(0x%llx, %d) failed\n",
> +                               __func__, start, len);
> +               return NULL;
> +       }
> +
> +       map = __ioremap(start, len, pgprot_val(pgprot_cached(__pgprot(0))));
> +       if (!map) {
> +               pr_devel("%s(): ioremap(0x%llx, %d) failed\n", __func__, start,
> +                               len);
> +               return NULL;
> +       }
> +
> +       return map;
> +}

That's very wrong. I assume this never worked right ?

MMIO regions must be mapped non-cachable. Only the paste region
requires being mapped cachable. Ask Aneesh for a cleaner way of
doing it too while at it.

> +/*
> + * Unmap the MMIO regions for a window.
> + */
> +static void unmap_wc_paste_kaddr(struct vas_window *window)
> +{
> +       int len;

Don't use "wc"... that usually means "write combine".

Cheers,
Ben.

[toc] | [next] | [standalone]


#1629807

FromSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Date2017-04-24 19:30 +0200
Message-ID<tzPYd-1pP-5@gated-at.bofh.it>
In reply to#1629230
Benjamin Herrenschmidt [benh@kernel.crashing.org] wrote:
> On Thu, 2017-03-30 at 22:13 -0700, Sukadev Bhattiprolu wrote:
> > +static void *map_mmio_region(char *name, uint64_t start, int len)
> > +{
> > +       void *map;
> > +
> > +       if (!request_mem_region(start, len, name)) {
> > +               pr_devel("%s(): request_mem_region(0x%llx, %d) failed\n",
> > +                               __func__, start, len);
> > +               return NULL;
> > +       }
> > +
> > +       map = __ioremap(start, len, pgprot_val(pgprot_cached(__pgprot(0))));
> > +       if (!map) {
> > +               pr_devel("%s(): ioremap(0x%llx, %d) failed\n", __func__, start,
> > +                               len);
> > +               return NULL;
> > +       }
> > +
> > +       return map;
> > +}
> 
> That's very wrong. I assume this never worked right ?

Untl recently, only tested on simics and has been working there. On the
hardware, hitting a crash on the first mmio write...
> 
> MMIO regions must be mapped non-cachable. Only the paste region

which maybe due to this :-) Should I change to pgprot_noncached() for the
MMIO writes?

> requires being mapped cachable. Ask Aneesh for a cleaner way of
> doing it too while at it.

Ok.

> 
> > +/*
> > + * Unmap the MMIO regions for a window.
> > + */
> > +static void unmap_wc_paste_kaddr(struct vas_window *window)
> > +{
> > +       int len;
> 
> Don't use "wc"... that usually means "write combine".

Ok.

Thanks,

Sukadev

[toc] | [prev] | [next] | [standalone]


#1630118

FromBenjamin Herrenschmidt <benh@kernel.crashing.org>
Date2017-04-25 01:30 +0200
Message-ID<tzVAC-51K-1@gated-at.bofh.it>
In reply to#1629807
On Mon, 2017-04-24 at 10:25 -0700, Sukadev Bhattiprolu wrote:
> which maybe due to this :-) Should I change to pgprot_noncached() for
> the MMIO writes?

Just use normal ioremap().

> > requires being mapped cachable. Ask Aneesh for a cleaner way of
> > doing it too while at it.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web