All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ross Zwisler <zwisler@gmail.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>,
	Linux ACPI <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: Re: [PATCH 1/6] pmem: add force casts to avoid __iomem annotation
Date: Fri, 29 May 2015 05:39:44 -0600	[thread overview]
Message-ID: <1432899584.4282.2.camel@gmail.com> (raw)
In-Reply-To: <CAPcyv4iY5DSw-wf5kaKOXZk0qx9CZttU9X35i+gGwd6EYB=hbw@mail.gmail.com>

On Thu, 2015-05-28 at 15:47 -0700, Dan Williams wrote:
> On Thu, May 28, 2015 at 3:35 PM, Ross Zwisler
> <ross.zwisler@linux.intel.com> wrote:
> > Even though we use ioremap_nocache() to map our persistent memory 
> > in the
> > pmem driver, the memory we are mapping behaves like normal memory 
> > and
> > not I/O memory in that it can be accessed using regular memcpy()
> > operations and doesn't need to go through memcpy_toio() and
> > memcpy_fromio().  Force casting the pointers received from
> > ioremap_nocache() and given to iounmap() gives us the correct 
> > behavior
> > and makes sparse happy.
> > 
> > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: linux-nvdimm@lists.01.org
> > ---
> >  drivers/block/nd/pmem.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/block/nd/pmem.c b/drivers/block/nd/pmem.c
> > index 5e8c9c629f22..a8712e41e7f5 100644
> > --- a/drivers/block/nd/pmem.c
> > +++ b/drivers/block/nd/pmem.c
> > @@ -163,7 +163,8 @@ static struct pmem_device *pmem_alloc(struct 
> > device *dev, struct resource *res,
> >          * of the CPU caches in case of a crash.
> >          */
> >         err = -ENOMEM;
> > -       pmem->virt_addr = ioremap_nocache(pmem->phys_addr, pmem
> > ->size);
> > +       pmem->virt_addr = (__force void *)ioremap_nocache(pmem
> > ->phys_addr,
> > +                       pmem->size);
> 
> I think I'd rather see casting when ->virt_addr is used (the
> __io_virt() helper can be used to make this a tad cleaner), or 
> provide
> ioremap apis that don't attach __iomem to their return value. 
>  Because
> in this and other cases ioremap() is being on non "i/o" memory.

The reason that I thought this was cleaner was that now when you look
at the pmem->virt_addr definition it is just a clean void* with no
annotations.  This correctly describes the memory to the user (it's
usable as regular memory, it's in the kernel address space, etc.).

Having the pointer itself annotated with __iomem feels weird to me
because a random well meaning user could incorrectly try to use it as
I/O memory.

WARNING: multiple messages have this Message-ID (diff)
From: Ross Zwisler <zwisler@gmail.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>,
	Linux ACPI <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-nvdimm@lists.01.org" <linux-nvdimm@ml01.01.org>
Subject: Re: [PATCH 1/6] pmem: add force casts to avoid __iomem annotation
Date: Fri, 29 May 2015 05:39:44 -0600	[thread overview]
Message-ID: <1432899584.4282.2.camel@gmail.com> (raw)
In-Reply-To: <CAPcyv4iY5DSw-wf5kaKOXZk0qx9CZttU9X35i+gGwd6EYB=hbw@mail.gmail.com>

On Thu, 2015-05-28 at 15:47 -0700, Dan Williams wrote:
> On Thu, May 28, 2015 at 3:35 PM, Ross Zwisler
> <ross.zwisler@linux.intel.com> wrote:
> > Even though we use ioremap_nocache() to map our persistent memory 
> > in the
> > pmem driver, the memory we are mapping behaves like normal memory 
> > and
> > not I/O memory in that it can be accessed using regular memcpy()
> > operations and doesn't need to go through memcpy_toio() and
> > memcpy_fromio().  Force casting the pointers received from
> > ioremap_nocache() and given to iounmap() gives us the correct 
> > behavior
> > and makes sparse happy.
> > 
> > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: linux-nvdimm@lists.01.org
> > ---
> >  drivers/block/nd/pmem.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/block/nd/pmem.c b/drivers/block/nd/pmem.c
> > index 5e8c9c629f22..a8712e41e7f5 100644
> > --- a/drivers/block/nd/pmem.c
> > +++ b/drivers/block/nd/pmem.c
> > @@ -163,7 +163,8 @@ static struct pmem_device *pmem_alloc(struct 
> > device *dev, struct resource *res,
> >          * of the CPU caches in case of a crash.
> >          */
> >         err = -ENOMEM;
> > -       pmem->virt_addr = ioremap_nocache(pmem->phys_addr, pmem
> > ->size);
> > +       pmem->virt_addr = (__force void *)ioremap_nocache(pmem
> > ->phys_addr,
> > +                       pmem->size);
> 
> I think I'd rather see casting when ->virt_addr is used (the
> __io_virt() helper can be used to make this a tad cleaner), or 
> provide
> ioremap apis that don't attach __iomem to their return value. 
>  Because
> in this and other cases ioremap() is being on non "i/o" memory.

The reason that I thought this was cleaner was that now when you look
at the pmem->virt_addr definition it is just a clean void* with no
annotations.  This correctly describes the memory to the user (it's
usable as regular memory, it's in the kernel address space, etc.).

Having the pointer itself annotated with __iomem feels weird to me
because a random well meaning user could incorrectly try to use it as
I/O memory.

  reply	other threads:[~2015-05-29 11:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28 22:35 [PATCH 0/6] I/O path improvements for ND_BLK and PMEM Ross Zwisler
2015-05-28 22:35 ` Ross Zwisler
2015-05-28 22:35 ` [PATCH 1/6] pmem: add force casts to avoid __iomem annotation Ross Zwisler
2015-05-28 22:35   ` Ross Zwisler
2015-05-28 22:47   ` Dan Williams
2015-05-28 22:47     ` Dan Williams
2015-05-29 11:39     ` Ross Zwisler [this message]
2015-05-29 11:39       ` Ross Zwisler
2015-05-29 12:53       ` Dan Williams
2015-05-29 12:53         ` Dan Williams
2015-05-29 13:22         ` Dan Williams
2015-05-29 13:22           ` Dan Williams
2015-05-28 22:35 ` [PATCH 2/6] nfit: Fix up address spaces, sparse warnings Ross Zwisler
2015-05-28 22:35   ` Ross Zwisler
2015-05-28 22:40   ` Dan Williams
2015-05-28 22:40     ` Dan Williams
2015-05-28 22:35 ` [PATCH 3/6] x86, pmem: add PMEM API for persistent memory Ross Zwisler
2015-05-28 22:35   ` Ross Zwisler
2015-05-28 23:20   ` H. Peter Anvin
2015-05-29  0:02     ` Dan Williams
2015-05-29  4:19       ` H. Peter Anvin
2015-05-29 12:11         ` Ross Zwisler
2015-05-29 12:07     ` Ross Zwisler
2015-05-29 15:48       ` Dan Williams
2015-05-28 22:35 ` [PATCH 4/6] pmem, nd_blk: update I/O paths to use PMEM API Ross Zwisler
2015-05-28 22:35   ` Ross Zwisler
2015-05-29 14:11   ` Dan Williams
2015-05-29 14:11     ` Dan Williams
2015-05-28 22:35 ` [PATCH 5/6] nd_blk: add support for flush hints Ross Zwisler
2015-05-28 22:35   ` Ross Zwisler
     [not found] ` <1432852553-24865-1-git-send-email-ross.zwisler-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-05-28 22:35   ` [PATCH 6/6] nd_blk: add support for NVDIMM flags Ross Zwisler
2015-05-28 22:35     ` Ross Zwisler
2015-05-28 22:35     ` Ross Zwisler

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=1432899584.4282.2.camel@gmail.com \
    --to=zwisler@gmail.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=ross.zwisler@linux.intel.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.