Hi Alan,Nick
Thanks for your inputs. I was able to solve the problem of mapping kernel buffer to user space. Just FYI, I am working on a sh4 based architecture proprietary board with Linux kernel 2.6.17.3
Initially I was adopting the following approach:
1.The kernel thread was copying some data and waiting on a semaphore for the user task to make an ioctl into the kernel space and relieve the wait.
2. Then the user task was getting spawned and taking the data from kernel.
---> This was resulting in some initial data drop coz the kernel task was overwhelming and outspeeding the user task (Maybe someone can explain how)
How I solved the problem?
Instead of making the kernel wait for the user task, I reversed the sequence and did not let the kernel task be activated till the user task was spawned and waiting in kernel space(after making ioctl) for the kernel task. Then I started the kernel task and the problem of data dropping was resolved.
In continuation to this, I have another query:
As mentioned above, If there is a kernel task waiting on a semaphore (maybe even in hung state) and I wish to kill the kernel task from user space by making an ioctl call into the kernel, then how is it possible? Is it feasible at all?
Regards,
Bhuvan
On 20 Apr, 14:20, Bhuvan Kumar MITTAL <[email protected]> wrote:
> Hi,
> I am working on an audio device driver development on Linux. I have
> a kernel buffer which I have mapped to user space using mmap call from
> user space. My problem is that the data which comes to the kernel
> buffer is getting dropped in user space and I get only 50-60% of the
> data which is randomly ordered. The user to kernel level buffer
> address translation code is fine and I suspect this data dropping is
> occurring coz the kernel buffer is cacheable. Please suggest me some
> way of making the entire buffer non cacheable. I am stuck on this for quite a while now.
You can use rdmsr() in your driver to check if the page attribute table MSR is available, then find and/or add the right entry in the table to set in each page's flags. This is documented in the Intel
IA-32 Intel Architecture Software Developer's Manuals at intel.com.
-----Original Message-----
From: Nick Piggin [mailto:[email protected]]
Sent: Monday, April 23, 2007 9:56 AM
To: Bhuvan Kumar MITTAL
Cc: 'Alan Cox'; [email protected]
Subject: Re: How to make mmap'ed kernel buffer non-cacheable
Bhuvan Kumar MITTAL wrote:
> Hi Alan,
>
> I believe that dma_alloc_coherent will mark the kernel buffer as uncached at alocation time.
> But that is not my intention. I have mapped some user space memory to the kernel buffer and I wish to ensure that the contents of both are coherent and correctly ordered.
>
> In other words I wish to flush the contents of the kernel buffer to user space as soon as new data is available in my kernel buffer. How to do that? Will doing mysnc from the user space help?
msync is only for pagecache. If you modify user mapped RAM from the kernel, or wish
to read user modified RAM from the kernel, you should issue a flush_dcache_page after
and before, respectively. See Documentation/cachetlb.h.
Does that fix it? What are the details of your platform?
--
SUSE Labs, Novell Inc.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]