2014-10-07 15:40:47

by Cristian Stoica

[permalink] [raw]
Subject: [PATCH 1/2] devres: support sizes greater than an unsigned long

As in 4f452e8aa492c0b8028ca9b4bdb4d018ba28c6c7, use resource_size_t
to accomodate sizes greater than the size of an unsigned long int on
platforms that have more than 32 bit physical addresses.

Signed-off-by: Cristian Stoica <[email protected]>
---
include/linux/io.h | 4 ++--
lib/devres.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/io.h b/include/linux/io.h
index d5fc9b8..fa02e55 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -61,9 +61,9 @@ static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
#define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)

void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
- unsigned long size);
+ resource_size_t size);
void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
- unsigned long size);
+ resource_size_t size);
void devm_iounmap(struct device *dev, void __iomem *addr);
int check_signature(const volatile void __iomem *io_addr,
const unsigned char *signature, int length);
diff --git a/lib/devres.c b/lib/devres.c
index f4a195a..0f1dd2e 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -23,7 +23,7 @@ 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,
- unsigned long size)
+ resource_size_t size)
{
void __iomem **ptr, *addr;

@@ -52,7 +52,7 @@ EXPORT_SYMBOL(devm_ioremap);
* detach.
*/
void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
- unsigned long size)
+ resource_size_t size)
{
void __iomem **ptr, *addr;

--
1.8.3.1


2014-10-07 15:40:37

by Cristian Stoica

[permalink] [raw]
Subject: [PATCH 2/2] uio: support memory sizes larger than 32 bits

This is a completion to 27a90700a4275c5178b883b65927affdafa5185c
The size field is also increased to allow values larger than 32 bits
on platforms that have more than 32 bit physical addresses.

Signed-off-by: Cristian Stoica <[email protected]>
---
Documentation/DocBook/uio-howto.tmpl | 2 +-
drivers/uio/uio.c | 2 +-
include/linux/uio_driver.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
index bbe9c1f..1fdc246 100644
--- a/Documentation/DocBook/uio-howto.tmpl
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -540,7 +540,7 @@ appears in sysfs.
</para></listitem>

<listitem><para>
-<varname>unsigned long size</varname>: Fill in the size of the
+<varname>resource_size_t size</varname>: Fill in the size of the
memory block that <varname>addr</varname> points to. If <varname>size</varname>
is zero, the mapping is considered unused. Note that you
<emphasis>must</emphasis> initialize <varname>size</varname> with zero for
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index a673e5b..eaa7347 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -73,7 +73,7 @@ static ssize_t map_addr_show(struct uio_mem *mem, char *buf)

static ssize_t map_size_show(struct uio_mem *mem, char *buf)
{
- return sprintf(buf, "0x%lx\n", mem->size);
+ return sprintf(buf, "0x%llx\n", (unsigned long long)mem->size);
}

static ssize_t map_offset_show(struct uio_mem *mem, char *buf)
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 1ad4724..df6e42e 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -35,7 +35,7 @@ struct uio_map;
struct uio_mem {
const char *name;
phys_addr_t addr;
- unsigned long size;
+ resource_size_t size;
int memtype;
void __iomem *internal_addr;
struct uio_map *map;
--
1.8.3.1

2014-10-09 08:56:32

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH 2/2] uio: support memory sizes larger than 32 bits

On Tue, Oct 7, 2014 at 5:25 PM, Cristian Stoica
<[email protected]> wrote:
> This is a completion to 27a90700a4275c5178b883b65927affdafa5185c
> The size field is also increased to allow values larger than 32 bits
> on platforms that have more than 32 bit physical addresses.
>
> Signed-off-by: Cristian Stoica <[email protected]>
> ---
> Documentation/DocBook/uio-howto.tmpl | 2 +-
> drivers/uio/uio.c | 2 +-
> include/linux/uio_driver.h | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
> index bbe9c1f..1fdc246 100644
> --- a/Documentation/DocBook/uio-howto.tmpl
> +++ b/Documentation/DocBook/uio-howto.tmpl
> @@ -540,7 +540,7 @@ appears in sysfs.
> </para></listitem>
>
> <listitem><para>
> -<varname>unsigned long size</varname>: Fill in the size of the
> +<varname>resource_size_t size</varname>: Fill in the size of the
> memory block that <varname>addr</varname> points to. If <varname>size</varname>
> is zero, the mapping is considered unused. Note that you
> <emphasis>must</emphasis> initialize <varname>size</varname> with zero for
> diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
> index a673e5b..eaa7347 100644
> --- a/drivers/uio/uio.c
> +++ b/drivers/uio/uio.c
> @@ -73,7 +73,7 @@ static ssize_t map_addr_show(struct uio_mem *mem, char *buf)
>
> static ssize_t map_size_show(struct uio_mem *mem, char *buf)
> {
> - return sprintf(buf, "0x%lx\n", mem->size);
> + return sprintf(buf, "0x%llx\n", (unsigned long long)mem->size);

We have special printk format strings to handle resource_size_t, please
see Documentation/printk-formats.txt.

> }
>
> static ssize_t map_offset_show(struct uio_mem *mem, char *buf)
> diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
> index 1ad4724..df6e42e 100644
> --- a/include/linux/uio_driver.h
> +++ b/include/linux/uio_driver.h
> @@ -35,7 +35,7 @@ struct uio_map;
> struct uio_mem {
> const char *name;
> phys_addr_t addr;
> - unsigned long size;
> + resource_size_t size;
> int memtype;
> void __iomem *internal_addr;
> struct uio_map *map;
> --
> 1.8.3.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/



--
Thanks,
//richard

2014-10-09 12:02:23

by Cristian Stoica

[permalink] [raw]
Subject: [v2 PATCH 2/2] uio: support memory sizes larger than 32 bits

This is a completion to 27a90700a4275c5178b883b65927affdafa5185c
The size field is also increased to allow values larger than 32 bits
on platforms that have more than 32 bit physical addresses.

Signed-off-by: Cristian Stoica <[email protected]>
---
Documentation/DocBook/uio-howto.tmpl | 2 +-
drivers/uio/uio.c | 4 ++--
include/linux/uio_driver.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
index bbe9c1f..1fdc246 100644
--- a/Documentation/DocBook/uio-howto.tmpl
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -540,7 +540,7 @@ appears in sysfs.
</para></listitem>

<listitem><para>
-<varname>unsigned long size</varname>: Fill in the size of the
+<varname>resource_size_t size</varname>: Fill in the size of the
memory block that <varname>addr</varname> points to. If <varname>size</varname>
is zero, the mapping is considered unused. Note that you
<emphasis>must</emphasis> initialize <varname>size</varname> with zero for
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index a673e5b..696ebab 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -68,12 +68,12 @@ static ssize_t map_name_show(struct uio_mem *mem, char *buf)

static ssize_t map_addr_show(struct uio_mem *mem, char *buf)
{
- return sprintf(buf, "0x%llx\n", (unsigned long long)mem->addr);
+ return sprintf(buf, "%pa\n", &mem->addr);
}

static ssize_t map_size_show(struct uio_mem *mem, char *buf)
{
- return sprintf(buf, "0x%lx\n", mem->size);
+ return sprintf(buf, "%pa\n", &mem->size);
}

static ssize_t map_offset_show(struct uio_mem *mem, char *buf)
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 1ad4724..df6e42e 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -35,7 +35,7 @@ struct uio_map;
struct uio_mem {
const char *name;
phys_addr_t addr;
- unsigned long size;
+ resource_size_t size;
int memtype;
void __iomem *internal_addr;
struct uio_map *map;
--
1.8.3.1