From: Dan Williams <dan.j.williams@intel.com>
To: arnd@arndb.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com,
tglx@linutronix.de, ross.zwisler@linux.intel.com,
akpm@linux-foundation.org
Cc: jgross@suse.com, x86@kernel.org, toshi.kani@hp.com,
linux-nvdimm@lists.01.org, mcgrof@suse.com,
konrad.wilk@oracle.com, linux-kernel@vger.kernel.org,
stefan.bader@canonical.com, luto@amacapital.net,
linux-mm@kvack.org, geert@linux-m68k.org, hmh@hmh.eng.br,
tj@kernel.org, hch@lst.de
Subject: [PATCH v2 2/4] devm: fix ioremap_cache() usage
Date: Sat, 30 May 2015 14:59:29 -0400 [thread overview]
Message-ID: <20150530185929.32590.22873.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <20150530185425.32590.3190.stgit@dwillia2-desk3.amr.corp.intel.com>
Provide devm_ioremap_cache() and fix up devm_ioremap_resource() to
actually provide cacheable mappings. On archs that implement
ioremap_cache() devm_ioremap_resource() is always silently falling back
to uncached when IORESOURCE_CACHEABLE is specified.
Cc: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
include/linux/io.h | 2 ++
lib/devres.c | 48 +++++++++++++++++++++---------------------------
2 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/include/linux/io.h b/include/linux/io.h
index 04cce4da3685..1c9ad4c6d485 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -70,6 +70,8 @@ static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
resource_size_t size);
+void __iomem *devm_ioremap_cache(struct device *dev, resource_size_t offset,
+ resource_size_t size);
void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
resource_size_t size);
void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
diff --git a/lib/devres.c b/lib/devres.c
index fbe2aac522e6..c8e75cdaf816 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -14,6 +14,8 @@ static int devm_ioremap_match(struct device *dev, void *res, void *match_data)
return *(void **)res == match_data;
}
+typedef void __iomem *(*ioremap_fn)(resource_size_t offset, unsigned long size);
+
/**
* devm_ioremap - Managed ioremap()
* @dev: Generic device to remap IO address for
@@ -22,8 +24,9 @@ static int devm_ioremap_match(struct device *dev, void *res, void *match_data)
*
* Managed ioremap(). Map is automatically unmapped on driver detach.
*/
-void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
- resource_size_t size)
+static void __iomem *devm_ioremap_type(struct device *dev,
+ resource_size_t offset, resource_size_t size,
+ ioremap_fn ioremap_type)
{
void __iomem **ptr, *addr;
@@ -31,7 +34,7 @@ void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
if (!ptr)
return NULL;
- addr = ioremap(offset, size);
+ addr = ioremap_type(offset, size);
if (addr) {
*ptr = addr;
devres_add(dev, ptr);
@@ -40,34 +43,25 @@ void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
return addr;
}
+
+void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
+ resource_size_t size)
+{
+ return devm_ioremap_type(dev, offset, size, ioremap);
+}
EXPORT_SYMBOL(devm_ioremap);
-/**
- * devm_ioremap_nocache - Managed ioremap_nocache()
- * @dev: Generic device to remap IO address for
- * @offset: BUS offset to map
- * @size: Size of map
- *
- * Managed ioremap_nocache(). Map is automatically unmapped on driver
- * detach.
- */
+void __iomem *devm_ioremap_cache(struct device *dev, resource_size_t offset,
+ resource_size_t size)
+{
+ return devm_ioremap_type(dev, offset, size, ioremap_cache);
+}
+EXPORT_SYMBOL(devm_ioremap_cache);
+
void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
resource_size_t size)
{
- void __iomem **ptr, *addr;
-
- ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
- if (!ptr)
- return NULL;
-
- addr = ioremap_nocache(offset, size);
- if (addr) {
- *ptr = addr;
- devres_add(dev, ptr);
- } else
- devres_free(ptr);
-
- return addr;
+ return devm_ioremap_type(dev, offset, size, ioremap_nocache);
}
EXPORT_SYMBOL(devm_ioremap_nocache);
@@ -154,7 +148,7 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
}
if (res->flags & IORESOURCE_CACHEABLE)
- dest_ptr = devm_ioremap(dev, res->start, size);
+ dest_ptr = devm_ioremap_cache(dev, res->start, size);
else
dest_ptr = devm_ioremap_nocache(dev, res->start, size);
--
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>
next prev parent reply other threads:[~2015-05-30 19:02 UTC|newest]
Thread overview: 19+ 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 ` [PATCH v2 1/4] arch/*/asm/io.h: add ioremap_cache() to all architectures Dan Williams
2015-06-01 22:36 ` Toshi Kani
2015-06-02 8:20 ` Arnd Bergmann
2015-06-02 8:38 ` Geert Uytterhoeven
2015-05-30 18:59 ` Dan Williams [this message]
2015-05-30 20:52 ` [PATCH v2 2/4] devm: fix ioremap_cache() usage Arnd Bergmann
2015-05-30 21:16 ` Dan Williams
2015-06-01 14:26 ` Arnd Bergmann
2015-05-30 18:59 ` [PATCH v2 3/4] arch: introduce memremap() Dan Williams
2015-05-30 21:00 ` Arnd Bergmann
2015-05-30 21:39 ` Dan Williams
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-06-01 9:19 ` Paul Bolle
2015-06-01 11:39 ` Boaz Harrosh
2015-06-01 11:44 ` Boaz Harrosh
2015-06-01 16:07 ` 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=20150530185929.32590.22873.stgit@dwillia2-desk3.amr.corp.intel.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).