From: Dan Williams <dan.j.williams@intel.com> To: Arnd Bergmann <arnd@arndb.de> Cc: Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>, Ross Zwisler <ross.zwisler@linux.intel.com>, Andrew Morton <akpm@linux-foundation.org>, Juergen Gross <jgross@suse.com>, X86 ML <x86@kernel.org>, "Kani, Toshimitsu" <toshi.kani@hp.com>, "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>, Luis Rodriguez <mcgrof@suse.com>, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Stefan Bader <stefan.bader@canonical.com>, Andy Lutomirski <luto@amacapital.net>, linux-mm@kvack.org, geert@linux-m68k.org, Henrique de Moraes Holschuh <hmh@hmh.eng.br>, Tejun Heo <tj@kernel.org>, Christoph Hellwig <hch@lst.de> Subject: Re: [PATCH v2 3/4] arch: introduce memremap() Date: Sat, 30 May 2015 14:39:48 -0700 [thread overview] Message-ID: <CAPcyv4hqQaabcOsOZA9emT5f+UF9GgD-PiYupng4HYwymcvYmQ@mail.gmail.com> (raw) In-Reply-To: <201505302300.10950.arnd@arndb.de> On Sat, May 30, 2015 at 2:00 PM, Arnd Bergmann <arnd@arndb.de> wrote: > On Saturday 30 May 2015, Dan Williams wrote: >> >> +/* >> + * memremap() is "ioremap" for cases where it is known that the resource >> + * being mapped does not have i/o side effects and the __iomem >> + * annotation is not applicable. >> + */ >> + >> +static inline void *memremap(resource_size_t offset, size_t size) >> +{ >> + return (void __force *) ioremap(offset, size); >> +} >> + >> +static inline void *memremap_nocache(resource_size_t offset, size_t size) >> +{ >> + return (void __force *) ioremap_nocache(offset, size); >> +} >> + >> +static inline void *memremap_cache(resource_size_t offset, size_t size) >> +{ >> + return (void __force *) ioremap_cache(offset, size); >> +} >> + > > There are architectures on which the result of ioremap is not necessarily > a pointer, but instead indicates that the access is to be done through > some other indirect access, or require special instructions. I think implementing > the memremap() interfaces is generally helpful, but don't rely on the > ioremap implementation. Is it enough to detect the archs where ioremap() does return an otherwise usable pointer and set ARCH_HAS_MEMREMAP, in the first take of this introduction? Regardless, it seems that drivers should have Kconfig dependency checks for archs where ioremap can not be used in this manner. > Adding both cached an uncached versions is also dangerous, because you > typically get either undefined behavior or a system checkstop when a > single page is mapped both cached and uncached at the same time. This > means that doing memremap() or memremap_nocache() on something that > may be part of the linear kernel mapping is a bug, and we should probably > check for that here. Part of the reason for relying on ioremap() was to borrow its internal checks to fail attempts that try to remap ranges that are already in the kernel linear map. Hmm, that's a guarantee x86 ioremap gives, but maybe that's not universal? > We can probably avoid having both memremap() and memremap_nocache(), > as all architectures define ioremap() and ioremap_nocache() to be the > same thing. > Ok -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com> To: Arnd Bergmann <arnd@arndb.de> Cc: Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>, Ross Zwisler <ross.zwisler@linux.intel.com>, Andrew Morton <akpm@linux-foundation.org>, Juergen Gross <jgross@suse.com>, X86 ML <x86@kernel.org>, "Kani, Toshimitsu" <toshi.kani@hp.com>, "linux-nvdimm@lists.01.org" <linux-nvdimm@ml01.01.org>, Luis Rodriguez <mcgrof@suse.com>, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Stefan Bader <stefan.bader@canonical.com>, Andy Lutomirski <luto@amacapital.net>, linux-mm@kvack.org, geert@linux-m68k.org, Henrique de Moraes Holschuh <hmh@hmh.eng.br>, Tejun Heo <tj@kernel.org>, Christoph Hellwig <hch@lst.de> Subject: Re: [PATCH v2 3/4] arch: introduce memremap() Date: Sat, 30 May 2015 14:39:48 -0700 [thread overview] Message-ID: <CAPcyv4hqQaabcOsOZA9emT5f+UF9GgD-PiYupng4HYwymcvYmQ@mail.gmail.com> (raw) In-Reply-To: <201505302300.10950.arnd@arndb.de> On Sat, May 30, 2015 at 2:00 PM, Arnd Bergmann <arnd@arndb.de> wrote: > On Saturday 30 May 2015, Dan Williams wrote: >> >> +/* >> + * memremap() is "ioremap" for cases where it is known that the resource >> + * being mapped does not have i/o side effects and the __iomem >> + * annotation is not applicable. >> + */ >> + >> +static inline void *memremap(resource_size_t offset, size_t size) >> +{ >> + return (void __force *) ioremap(offset, size); >> +} >> + >> +static inline void *memremap_nocache(resource_size_t offset, size_t size) >> +{ >> + return (void __force *) ioremap_nocache(offset, size); >> +} >> + >> +static inline void *memremap_cache(resource_size_t offset, size_t size) >> +{ >> + return (void __force *) ioremap_cache(offset, size); >> +} >> + > > There are architectures on which the result of ioremap is not necessarily > a pointer, but instead indicates that the access is to be done through > some other indirect access, or require special instructions. I think implementing > the memremap() interfaces is generally helpful, but don't rely on the > ioremap implementation. Is it enough to detect the archs where ioremap() does return an otherwise usable pointer and set ARCH_HAS_MEMREMAP, in the first take of this introduction? Regardless, it seems that drivers should have Kconfig dependency checks for archs where ioremap can not be used in this manner. > Adding both cached an uncached versions is also dangerous, because you > typically get either undefined behavior or a system checkstop when a > single page is mapped both cached and uncached at the same time. This > means that doing memremap() or memremap_nocache() on something that > may be part of the linear kernel mapping is a bug, and we should probably > check for that here. Part of the reason for relying on ioremap() was to borrow its internal checks to fail attempts that try to remap ranges that are already in the kernel linear map. Hmm, that's a guarantee x86 ioremap gives, but maybe that's not universal? > We can probably avoid having both memremap() and memremap_nocache(), > as all architectures define ioremap() and ioremap_nocache() to be the > same thing. > Ok
next prev parent reply other threads:[~2015-05-30 21:39 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-05-30 18:59 [PATCH v2 0/4] pmem api, generic ioremap_cache, and memremap Dan Williams 2015-05-30 18:59 ` Dan Williams 2015-05-30 18:59 ` [PATCH v2 1/4] arch/*/asm/io.h: add ioremap_cache() to all architectures Dan Williams 2015-05-30 18:59 ` Dan Williams 2015-06-01 22:36 ` Toshi Kani 2015-06-01 22:36 ` Toshi Kani 2015-06-02 8:20 ` Arnd Bergmann 2015-06-02 8:20 ` Arnd Bergmann 2015-06-02 8:38 ` Geert Uytterhoeven 2015-06-02 8:38 ` Geert Uytterhoeven 2015-05-30 18:59 ` [PATCH v2 2/4] devm: fix ioremap_cache() usage Dan Williams 2015-05-30 18:59 ` Dan Williams 2015-05-30 20:52 ` Arnd Bergmann 2015-05-30 20:52 ` Arnd Bergmann 2015-05-30 21:16 ` Dan Williams 2015-05-30 21:16 ` Dan Williams 2015-06-01 14:26 ` Arnd Bergmann 2015-06-01 14:26 ` Arnd Bergmann 2015-05-30 18:59 ` [PATCH v2 3/4] arch: introduce memremap() Dan Williams 2015-05-30 18:59 ` Dan Williams 2015-05-30 21:00 ` Arnd Bergmann 2015-05-30 21:00 ` Arnd Bergmann 2015-05-30 21:39 ` Dan Williams [this message] 2015-05-30 21:39 ` Dan Williams 2015-06-01 14:29 ` Arnd Bergmann 2015-06-01 14:29 ` Arnd Bergmann 2015-05-30 18:59 ` [PATCH v2 4/4] arch, x86: cache management apis for persistent memory Dan Williams 2015-05-30 18:59 ` Dan Williams 2015-06-01 9:19 ` Paul Bolle 2015-06-01 9:19 ` Paul Bolle 2015-06-01 11:39 ` Boaz Harrosh 2015-06-01 11:39 ` Boaz Harrosh 2015-06-01 11:44 ` Boaz Harrosh 2015-06-01 11:44 ` Boaz Harrosh 2015-06-01 16:07 ` Dan Williams 2015-06-01 16:07 ` Dan Williams 2015-06-01 16:22 ` Dan Williams 2015-06-01 16:22 ` Dan Williams
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=CAPcyv4hqQaabcOsOZA9emT5f+UF9GgD-PiYupng4HYwymcvYmQ@mail.gmail.com \ --to=dan.j.williams@intel.com \ --cc=akpm@linux-foundation.org \ --cc=arnd@arndb.de \ --cc=bp@alien8.de \ --cc=geert@linux-m68k.org \ --cc=hch@lst.de \ --cc=hmh@hmh.eng.br \ --cc=hpa@zytor.com \ --cc=jgross@suse.com \ --cc=konrad.wilk@oracle.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-nvdimm@lists.01.org \ --cc=luto@amacapital.net \ --cc=mcgrof@suse.com \ --cc=mingo@redhat.com \ --cc=ross.zwisler@linux.intel.com \ --cc=stefan.bader@canonical.com \ --cc=tglx@linutronix.de \ --cc=tj@kernel.org \ --cc=toshi.kani@hp.com \ --cc=x86@kernel.org \ /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: linkBe 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.