Am Fri, 20 Mar 2015 16:24:29 +0100 schrieb Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>: > On Fri, Mar 20, 2015 at 3:47 PM, Maxime Ripard > <maxime.ripard@xxxxxxxxxxxxxxxxxx> wrote: > > On Fri, Mar 20, 2015 at 01:37:50PM +0200, Tomi Valkeinen wrote: > >> On 15/03/15 00:02, Geert Uytterhoeven wrote: > >> > On Fri, Mar 13, 2015 at 10:31 PM, Thomas Niederprüm > >> > <niederp@xxxxxxxxxxxxxxxx> wrote: > >> >> Am Tue, 10 Mar 2015 13:28:25 +0200 > >> >> schrieb Tomi Valkeinen <tomi.valkeinen@xxxxxx>: > >> >>> Also, isn't doing __pa() for the memory returned by vmalloc > >> >>> plain wrong? > >> >> > >> >>> What was the crash about when using kmalloc? It would be good > >> >>> to fix defio, as I don't see why it should not work with > >> >>> kmalloced memory. > >> >> > >> >> The main challenge here is that the memory handed to userspace > >> >> upon mmap call needs to be page aligned. The memory returned by > >> >> kmalloc has no such alignment, but the pointer presented to the > >> >> userspace program gets aligned to next page boundary. It's not > >> >> clear to me whether there is an easy way to obtain page aligned > >> >> kmalloc memory. Memory allocated by vmalloc on the other hand > >> >> is always aligned to page boundaries. This is why I chose to go > >> >> for vmalloc. > >> > > >> > __get_free_pages()? > >> > >> I'm not that experienced with mem management, so I have to ask... > >> __get_free_pages() probably works fine, but isn't vmalloc better > >> here? > >> > >> __get_free_pages() will give you possibly a lot more memory than > >> you need. And the memory is contiguous, so it could be difficult > >> to allocate a larger memory area. The driver doesn't need > >> contiguous memory (except in the virtual sense). > > > > vmalloc also returns pages, so the size will be page-aligned. It > > doesn't make much of a difference here, since we will only use a > > single page in both case (the max resolution of these screens is > > 128x39, with one bit per pixel). > > In that case I recommend get_zeroed_page(), to avoid the vmalloc() > overhead of setting up a mapping. I looked into get_zeroed_page() too but I thought __get_free_pages() might be more future proof since get_zeroed_page() will not reserve enough memory if more than one page is needed. This might occur if a new controller pops up that has more pixels than bits in a page or the driver is used on a system with a small page size. Also get_zeroed_page() is also just calling __get_free_pages() with the order parameter set to 0. Therefore I think a call like __get_free_pages(GFP_KERNEL | __GFP_ZERO, get_order(size)) does the same as get_zeroed_page() if only one page is needed but has the ability to reserve more pages if needed. Thomas -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html