Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Sep 2007 18:46:09 -0700
From:      John-Mark Gurney <gurney_j@resnet.uoregon.edu>
To:        Prahar Shah <praharshah123@gmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: Accessing device memory from user-land application process
Message-ID:  <20070904014609.GG977@funkthat.com>
In-Reply-To: <ebd4dd8d0708302200i77e71fbaxc773da1a0642535b@mail.gmail.com>
References:  <ebd4dd8d0708302200i77e71fbaxc773da1a0642535b@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Prahar Shah wrote this message on Fri, Aug 31, 2007 at 10:30 +0530:
> I am writing a device driver in user-land process. I do a contigmalloc() to
> allocate the descriptor memory, do a vtophys() on it and mmap that memory in
> the user-land application process. I allocate buffers again using

You should be using bus_dma(9) instead of vtophys...  With bus_dma, you
won't have to restrict your driver to i386 and other platforms that
provide vtophys...

> contigmalloc(), and mmap it within the same process. I pass on a buffer each
> to the device descriptor. And my packet reception works fine.
> While processing packets, once i reset the device (all device registers and
> related memory), and repopulate buffers into the  descriptors, I
> occasionally find that while receiving a packet after reset, the buffer
> address that I read from the first descriptor is not the one that I gave to
> the descriptor after the reset. Instead, it turns out to be an older buffer
> address which as allocated to a descriptor which was supposed to be read
> next, prior to the reset.
> My doubt is, could this be a cache-coherency issue? Or could there be a
> chance that the device might be caching the buffer address available with
> the descriptors, and re-writing back to the descriptor after receiving the
> packet, and somehow these cached address are not flushed during a device
> reset?

Probably a cache issue...  If you use bus_dma, you can call
bus_dmamap_sync to deal w/ the cache issue...

> If i've missed any details, kindly let me know.
> Any help would be greatly appriciated

Good luck!

Hope this helps...

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070904014609.GG977>