diff options
author | Michal Sojka <sojkam1@fel.cvut.cz> | 2017-03-16 14:50:08 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-04-08 18:13:27 +0200 |
commit | 171058fb0883247b3a484a542b5dc89753c57cb5 (patch) | |
tree | e6e8a904b46946078f856a878c0fa7539466c93f /drivers/uio/uio.c | |
parent | 8b932edfb8788862f10434c1018ad8a6078e0115 (diff) | |
download | linux-171058fb0883247b3a484a542b5dc89753c57cb5.tar.bz2 |
uio: Allow handling of non page-aligned memory regions
Since commit b65502879556 ("uio: we cannot mmap unaligned page
contents") addresses and sizes of UIO memory regions must be
page-aligned. If the address in the BAR register is not
page-aligned (which is the case of the mf264 card), the mentioned
commit forces the UIO driver to round the address down to the page
size. Then, there is no easy way for user-space to learn the offset of
the actual memory region within the page, because the offset seen in
/sys/class/uio/uio?/maps/map?/offset is calculated from the rounded
address and thus it is always zero.
Fix that problem by including the offset in struct uio_mem. UIO
drivers can set this field and userspace can read its value from
/sys/class/uio/uio?/maps/map?/offset.
The following commits update the uio_mf264 driver to set this new offs
field.
Drivers for hardware with page-aligned BARs need not to be modified
provided that they initialize struct uio_info (which contains uio_mem)
with zeros.
Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/uio/uio.c')
-rw-r--r-- | drivers/uio/uio.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 60ce7fd54e89..1c196f87e9d9 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -66,7 +66,7 @@ static ssize_t map_size_show(struct uio_mem *mem, char *buf) static ssize_t map_offset_show(struct uio_mem *mem, char *buf) { - return sprintf(buf, "0x%llx\n", (unsigned long long)mem->addr & ~PAGE_MASK); + return sprintf(buf, "0x%llx\n", (unsigned long long)mem->offs); } struct map_sysfs_entry { |