Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Thomas Koeller <thomas.koeller@baslerweb.com>
To: "Linux/MIPS Development" <linux-mips@linux-mips.org>,
	linux-kernel@vger.kernel.org
Subject: vmap() problem, possible bug?
Date: Fri, 20 May 2005 15:23:52 +0200	[thread overview]
Message-ID: <200505201523.52194.thomas.koeller@baslerweb.com> (raw)

Hi,

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 linux-mips.org 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,
		       pkt->copy_size);
		free_pages((unsigned long) pkt->copy_src, page_order);
		vunmap(dst);
	} 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?

tk
-- 
--------------------------------------------------

Thomas Koeller, Software Development
Basler Vision Technologies

thomas dot koeller at baslerweb dot com
http://www.baslerweb.com

==============================

                 reply	other threads:[~2005-05-20 13:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200505201523.52194.thomas.koeller@baslerweb.com \
    --to=thomas.koeller@baslerweb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    /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