Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752269AbdCPO0n (ORCPT ); Thu, 16 Mar 2017 10:26:43 -0400 Received: from max.feld.cvut.cz ([147.32.192.36]:58290 "EHLO max.feld.cvut.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbdCPO0m (ORCPT ); Thu, 16 Mar 2017 10:26:42 -0400 From: Michal Sojka To: Greg KH Cc: linux-kernel@vger.kernel.org, lisovy@gmail.com Subject: Re: [PATCH 1/3] uio: Allow handling of non page-aligned memory regions In-Reply-To: <20170316140739.GC30080@kroah.com> References: <20170307140948.30099-1-sojkam1@fel.cvut.cz> <20170316082012.GA23493@kroah.com> <87k27pqtj5.fsf@steelpick.2x.cz> <20170316132548.GB10184@kroah.com> <87h92tqrbu.fsf@steelpick.2x.cz> <20170316140739.GC30080@kroah.com> Date: Thu, 16 Mar 2017 15:26:38 +0100 Message-ID: <8760j9qov5.fsf@steelpick.2x.cz> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1962 Lines: 43 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