mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Sojka <sojkam1@fel.cvut.cz>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, lisovy@gmail.com
Subject: Re: [PATCH 1/3] uio: Allow handling of non page-aligned memory regions
Date: Thu, 16 Mar 2017 15:26:38 +0100	[thread overview]
Message-ID: <8760j9qov5.fsf@steelpick.2x.cz> (raw)
In-Reply-To: <20170316140739.GC30080@kroah.com>

On Thu, Mar 16 2017, Greg KH wrote:
> On Thu, Mar 16, 2017 at 02:33:25PM +0100, Michal Sojka wrote:
>> On Thu, Mar 16 2017, Greg KH wrote:
>> > On Thu, Mar 16, 2017 at 01:45:50PM +0100, Michal Sojka wrote:
>> >> On Thu, Mar 16 2017, Greg KH wrote:
>> >> > On Tue, Mar 07, 2017 at 03:09:46PM +0100, Michal Sojka wrote:
>> >> >> 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,
>> >> >> 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 the sysfs 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 its value is reported via sysfs.
>> >> >
>> >> > It is, where?
>> >> 
>> >> /sys/class/uio/uio0/maps/map0/offset
>> >
>> > Did you change the Documentation/ABI entry for it?
>> 
>> No, because it seems that UIO is not documented there.
>
> Wow, it really isn't, that sucks, I messed up :(
>
> But, the uio-howto.rst file should probably be updated, right?

I checked that and the document is correct. The relevant part is:

> -  ``offset``: The offset, in bytes, that has to be added to the pointer
>    returned by :c:func:`mmap()` to get to the actual device memory.
>    This is important if the device's memory is not page aligned.
>    Remember that pointers returned by :c:func:`mmap()` are always
>    page aligned, so it is good style to always add this offset.

So, as described in the commit, the only problem was that without my
patch the offset has either been zero or mmap() failed. Now, mmap() can
succeed even if offset is non-zero.

-Michal

  reply	other threads:[~2017-03-16 14:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07 14:09 Michal Sojka
2017-03-07 14:09 ` [PATCH 2/3] uio_mf624: Refactor memory info initialization Michal Sojka
2017-03-16  8:20   ` Greg KH
2017-03-07 14:09 ` [PATCH 3/3] uio_mf624: Align memory regions to page size Michal Sojka
2017-03-16  8:20 ` [PATCH 1/3] uio: Allow handling of non page-aligned memory regions Greg KH
2017-03-16 12:45   ` Michal Sojka
2017-03-16 13:25     ` Greg KH
2017-03-16 13:33       ` Michal Sojka
2017-03-16 14:07         ` Greg KH
2017-03-16 14:26           ` Michal Sojka [this message]
2017-03-16 13:50       ` [PATCH v2 " Michal Sojka
2017-03-16 13:50         ` [PATCH v2 2/3] uio_mf624: Refactor memory info initialization Michal Sojka
2017-03-16 13:50         ` [PATCH v2 3/3] uio_mf624: Align memory regions to page size and set correct offsets Michal Sojka

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=8760j9qov5.fsf@steelpick.2x.cz \
    --to=sojkam1@fel.cvut.cz \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lisovy@gmail.com \
    /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

all inboxes | Powered by JetHome®