2008-12-05 18:35:24

by Parav Pandit

[permalink] [raw]
Subject: mechanism to syncronise device access from user and kernel

Hi,

I have a device whose registers are accessed by driver as well as user space application via mmap() area.

How to synchronize the access (avoid race condition) between user space driver and kernel mode driver, in single CPU and multi-CPU systems?

Regards,
Parav Pandit




2008-12-06 01:10:22

by Robert Hancock

[permalink] [raw]
Subject: Re: mechanism to syncronise device access from user and kernel

Parav Pandit wrote:
> Hi,
>
> I have a device whose registers are accessed by driver as well as user space application via mmap() area.
>
> How to synchronize the access (avoid race condition) between user space driver and kernel mode driver, in single CPU and multi-CPU systems?

This doesn't seem like the best idea in the first place.. certainly not
if unprivileged processes can get access to the registers, as there's no
way to require them to follow the synchronization process. Generally a
given set of registers should be driven by a kernel driver or a
userspace process, not both.

2008-12-06 12:40:46

by Matthew Garrett

[permalink] [raw]
Subject: Re: mechanism to syncronise device access from user and kernel

On Fri, Dec 05, 2008 at 10:28:27AM -0800, Parav Pandit wrote:
> Hi,
>
> I have a device whose registers are accessed by driver as well as user space application via mmap() area.
>
> How to synchronize the access (avoid race condition) between user space driver and kernel mode driver, in single CPU and multi-CPU systems?

Rewrite userspace to use the kernel driver?

--
Matthew Garrett | [email protected]