From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org, linux-mm@kvack.org
Subject: Re: [PATCH 3/5] io-mapping: Always create a struct to hold metadata about the io-mapping
Date: Thu, 09 Apr 2015 10:58:41 +0300 [thread overview]
Message-ID: <1428566321.2910.23.camel@jlahtine-mobl1> (raw)
In-Reply-To: <1428424299-13721-4-git-send-email-chris@chris-wilson.co.uk>
On ti, 2015-04-07 at 17:31 +0100, Chris Wilson wrote:
> Currently, we only allocate a structure to hold metadata if we need to
> allocate an ioremap for every access, such as on x86-32. However, it
> would be useful to store basic information about the io-mapping, such as
> its page protection, on all platforms.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: linux-mm@kvack.org
> ---
> include/linux/io-mapping.h | 52 ++++++++++++++++++++++++++++------------------
> 1 file changed, 32 insertions(+), 20 deletions(-)
>
> diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h
> index 657fab4efab3..e053011f50bb 100644
> --- a/include/linux/io-mapping.h
> +++ b/include/linux/io-mapping.h
> @@ -31,16 +31,17 @@
> * See Documentation/io-mapping.txt
> */
>
> -#ifdef CONFIG_HAVE_ATOMIC_IOMAP
> -
> -#include <asm/iomap.h>
> -
> struct io_mapping {
> resource_size_t base;
> unsigned long size;
> pgprot_t prot;
> + void __iomem *iomem;
> };
>
> +
> +#ifdef CONFIG_HAVE_ATOMIC_IOMAP
> +
> +#include <asm/iomap.h>
> /*
> * For small address space machines, mapping large objects
> * into the kernel virtual space isn't practical. Where
> @@ -119,48 +120,59 @@ io_mapping_unmap(void __iomem *vaddr)
> #else
>
> #include <linux/uaccess.h>
> -
> -/* this struct isn't actually defined anywhere */
> -struct io_mapping;
> +#include <asm/pgtable_types.h>
>
> /* Create the io_mapping object*/
> static inline struct io_mapping *
> io_mapping_create_wc(resource_size_t base, unsigned long size)
> {
> - return (struct io_mapping __force *) ioremap_wc(base, size);
> + struct io_mapping *iomap;
> +
> + iomap = kmalloc(sizeof(*iomap), GFP_KERNEL);
> + if (!iomap)
> + return NULL;
> +
> + iomap->base = base;
> + iomap->size = size;
> + iomap->iomem = ioremap_wc(base, size);
> + iomap->prot = pgprot_writecombine(PAGE_KERNEL_IO);
> +
> + return iomap;
> }
>
> static inline void
> io_mapping_free(struct io_mapping *mapping)
> {
> - iounmap((void __force __iomem *) mapping);
> + iounmap(mapping->iomem);
> + kfree(mapping);
> }
>
> -/* Atomic map/unmap */
> +/* Non-atomic map/unmap */
> static inline void __iomem *
> -io_mapping_map_atomic_wc(struct io_mapping *mapping,
> - unsigned long offset)
> +io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
> {
> - pagefault_disable();
> - return ((char __force __iomem *) mapping) + offset;
> + return mapping->iomem + offset;
> }
>
> static inline void
> -io_mapping_unmap_atomic(void __iomem *vaddr)
> +io_mapping_unmap(void __iomem *vaddr)
> {
> - pagefault_enable();
> }
>
> -/* Non-atomic map/unmap */
> +/* Atomic map/unmap */
> static inline void __iomem *
> -io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset)
> +io_mapping_map_atomic_wc(struct io_mapping *mapping,
> + unsigned long offset)
> {
> - return ((char __force __iomem *) mapping) + offset;
> + pagefault_disable();
> + return io_mapping_map_wc(mapping, offset);
> }
>
> static inline void
> -io_mapping_unmap(void __iomem *vaddr)
> +io_mapping_unmap_atomic(void __iomem *vaddr)
> {
> + io_mapping_unmap(vaddr);
> + pagefault_enable();
> }
>
> #endif /* HAVE_ATOMIC_IOMAP */
--
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-04-09 7:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1428424299-13721-1-git-send-email-chris@chris-wilson.co.uk>
2015-04-07 16:31 ` [PATCH 2/5] mm: Refactor remap_pfn_range() Chris Wilson
2015-04-07 20:27 ` Andrew Morton
2015-04-08 9:45 ` Peter Zijlstra
2015-04-09 8:32 ` Joonas Lahtinen
2015-04-07 16:31 ` [PATCH 3/5] io-mapping: Always create a struct to hold metadata about the io-mapping Chris Wilson
2015-04-09 7:58 ` Joonas Lahtinen [this message]
2015-04-07 16:31 ` [PATCH 4/5] mm: Export remap_io_mapping() Chris Wilson
2015-04-09 8:18 ` Joonas Lahtinen
2015-04-07 16:31 ` [PATCH 5/5] drm/i915: Use remap_io_mapping() to prefault all PTE in a single pass Chris Wilson
2015-04-09 8:00 ` Joonas Lahtinen
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=1428566321.2910.23.camel@jlahtine-mobl1 \
--to=joonas.lahtinen@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-mm@kvack.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).