• Michal Sojka's avatar
    uio: Allow handling of non page-aligned memory regions · 171058fb
    Michal Sojka authored
    Since commit b6550287 ("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: default avatarMichal Sojka <sojkam1@fel.cvut.cz>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    171058fb
uio.c 19.8 KB