[Top] [All Lists]

vmap() problem, possible bug?

To: "Linux/MIPS Development" <>,
Subject: vmap() problem, possible bug?
From: Thomas Koeller <>
Date: Fri, 20 May 2005 15:23:52 +0200
Organization: Basler AG
Original-recipient: rfc822;
User-agent: KMail/1.6.2

writing a device driver I came across something that looks
to me like a bug in the vmap() function. I am using kernel
2.6.11-rc1 (from cvs, but the problem is
probably not mips-specific).

My driver transfers large amounts of data using DMA to a
buffer passed in from userland and translated to a page
list via get_user_pages(). Due to alignment restrictions
imposed by the DMA hardware, I have to use a temporary
buffer page for a part of the data buffer, and to copy
the data from this page to the actual buffer using
memcpy(). To be able to to so, I am using vmap() to create
a temporary mapping for the part of the buffer where the
data is to be copied, do the copy, and then call vunmap()
to remove the mapping:

if (pkt->copy_size) {
        const unsigned int page_order =
                (pkt->copy_size > PAGE_SIZE) ? 1 : 0;
        void * const dst = vmap(pkt->copy_pg, 0x1 << page_order,
                                VM_MAP, PAGE_USERIO);

        if (dst) {
                memcpy(dst + pkt->copy_offs, pkt->copy_src,
                free_pages((unsigned long) pkt->copy_src, page_order);
        } else {
                pkt->pset->status = XICAP_BUFSTAT_VMERR;

The code above is executed once for every data buffer
processed. It works as expected most of the time, but
every once in a while the data copied is not written to
the correct location, but to the previously processed
buffer instead. It looks as if the mapping established
for that buffer had survived the vunmap() / vmap() sequence.

In case it matters, my system is single core (not SMP).
Any ideas, anybody?


Thomas Koeller, Software Development
Basler Vision Technologies

thomas dot koeller at baslerweb dot com


<Prev in Thread] Current Thread [Next in Thread>
  • vmap() problem, possible bug?, Thomas Koeller <=