Re: User space <==> kernel space for device wakeups.

2014-10-09 Thread buyitian

> My case was: I have a hall sensor connected to Beaglebone black, And 
> Userspace needed a wakeup once the interrupt occur (example: every rising 
> edge of GPIO). Before that, the program will register (ioctl) the User space 
> task pointer with my kernel module, then my kernel module start sending 
> signal for every interrupt occur. We can consider roughly around 100 to 200 
> interrupts per second maximum. ( I have not done this, but may be we can 
> consider kernel will get notified when userspace program stops. so that it 
> will not send any signal). So for this case, any other alternative 

Once kernel gets interrupt, it can use netlink to notify user space, if you are 
using Android, it is using UEVENT.


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread manty kuma
Hi All,

Thank you for the replies. I understand that I can use netlink sockets.
Also, i have gone through various other possible ways :
http://people.ee.ethz.ch/~arkeller/linux/kernel_user_space_howto.html

I am looking for a simpler solution which uses existing information of sys
entries. That is, I am looking for a sys entry which is incremented for
every device wakeup or some other sys entry that I can use to get notified
on wakeup.

Greg,
>> Really?  My device can "wakeup" thousands of times a second, what are
you going to do with that type of information?

I am talking of device as a whole not individual devices in the device. In
kernel log, we can see a print stating
"PM: suspend of devices complete after xxx msecs" --> *Prints from
kernel/kernel/power/main.c*

Similarly I get a print for resume stating
"PM: resume of devices complete after xxx msecs" --> *Prints from
kernel/kernel/power/main.c*
Ideally after the above print of resume i want my stats to be printed..
Programatically after dpm_resume_end().

Best Regards,
Manty

On Thu, Oct 9, 2014 at 3:30 AM, Jinqiang Zeng 
wrote:

> 2014-10-08 0:39 GMT-07:00 manty kuma :
> > Hi,
> > I want a user process to be notified on device wakeup so that I can print
> > some related information.
> >
> > Which framework to use for this?(events, .. ??)
>
> You can use netlink and  uevent to do this job.
>
> But  just as Greg has pointed out, if your device notify  frequently,
> your system will get slow down obviously.
>
> >
> > One idea I get is to log the info into  and poll(implement my
> poll)
> > on it for data. This is my last option.
> >
> > Are there any better ways?
> >
> > Best Regards,
> > Manty
> >
> > ___
> > Kernelnewbies mailing list
> > Kernelnewbies@kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Jinqiang Zeng
2014-10-08 0:39 GMT-07:00 manty kuma :
> Hi,
> I want a user process to be notified on device wakeup so that I can print
> some related information.
>
> Which framework to use for this?(events, .. ??)

You can use netlink and  uevent to do this job.

But  just as Greg has pointed out, if your device notify  frequently,
your system will get slow down obviously.

>
> One idea I get is to log the info into  and poll(implement my poll)
> on it for data. This is my last option.
>
> Are there any better ways?
>
> Best Regards,
> Manty
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Jeshwanth Kumar N K
On Wed, Oct 8, 2014 at 11:02 PM, Greg Kroah-Hartman  wrote:

> On Wed, Oct 08, 2014 at 10:23:32PM +0530, Jeshwanth Kumar N K wrote:
> > My case was: I have a hall sensor connected to Beaglebone black, And
> Userspace
> > needed a wakeup once the interrupt occur (example: every rising edge of
> GPIO).
> > Before that, the program will register (ioctl) the User space task
> pointer with
> > my kernel module, then my kernel module start sending signal for every
> > interrupt occur. We can consider roughly around 100 to 200 interrupts per
> > second maximum. ( I have not done this, but may be we can consider
> kernel will
> > get notified when userspace program stops. so that it will not send any
> > signal). So for this case, any other alternative implementation ?
>
> select() on the GPIO sysfs file instead of a custom ioctl?
>
> And what do you do in userspace with that information?
>
> greg k-h
>

With hall sensor input I can get the position of motor, and in userspace I
drive the motor (brushless) for next position by passing the values to
sysfs attribute of PWM driver. It's a closed loop, until I drive the PWM I
will not get an interrupt. But what solution I had was, anyway PWM driver
is available, my sensor driver sends the current position to the PWM driver
(altered), then it will send to the motor directly (no need to user space
intervention in driving PWM), But controlling through application in
userspace like start/stop/speed etc. But I have not implemented and tested
this.

-- 
Regards
Jeshwanth Kumar N K
Bangalore, India
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Greg Kroah-Hartman
On Wed, Oct 08, 2014 at 10:23:32PM +0530, Jeshwanth Kumar N K wrote:
> My case was: I have a hall sensor connected to Beaglebone black, And Userspace
> needed a wakeup once the interrupt occur (example: every rising edge of GPIO).
> Before that, the program will register (ioctl) the User space task pointer 
> with
> my kernel module, then my kernel module start sending signal for every
> interrupt occur. We can consider roughly around 100 to 200 interrupts per
> second maximum. ( I have not done this, but may be we can consider kernel will
> get notified when userspace program stops. so that it will not send any
> signal). So for this case, any other alternative implementation ?

select() on the GPIO sysfs file instead of a custom ioctl?

And what do you do in userspace with that information?

greg k-h

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Jeshwanth Kumar N K
On Wed, Oct 8, 2014 at 10:08 PM, Greg Kroah-Hartman  wrote:

>
> A: No.
> Q: Should I include quotations after my reply?
>
> http://daringfireball.net/2007/07/on_top
>
> On Wed, Oct 08, 2014 at 10:01:43PM +0530, Jeshwanth Kumar N K wrote:
> > Greg, then what will you suggest for my case? I mean any alternative ?
>
> What "case"?  What problem are you trying to solve?
>
> greg k-h
>


Oh, correct. 2nd time I am warned on this (may be practise by using
outlook). Will reply bottom now onwards - sorry.

My case was: I have a hall sensor connected to Beaglebone black, And
Userspace needed a wakeup once the interrupt occur (example: every rising
edge of GPIO). Before that, the program will register (ioctl) the User
space task pointer with my kernel module, then my kernel module start
sending signal for every interrupt occur. We can consider roughly around
100 to 200 interrupts per second maximum. ( I have not done this, but may
be we can consider kernel will get notified when userspace program stops.
so that it will not send any signal). So for this case, any other
alternative implementation ?

Thanks

-- 
Regards
Jeshwanth Kumar N K
Bangalore, India
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Greg Kroah-Hartman

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Wed, Oct 08, 2014 at 10:01:43PM +0530, Jeshwanth Kumar N K wrote:
> Greg, then what will you suggest for my case? I mean any alternative ?

What "case"?  What problem are you trying to solve?

greg k-h

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Jeshwanth Kumar N K
Greg, then what will you suggest for my case? I mean any alternative ?

Thanks

On Wed, Oct 8, 2014 at 9:55 PM, Greg Kroah-Hartman  wrote:

> On Wed, Oct 08, 2014 at 05:57:50PM +0200, Kristof Provost wrote:
> > On 2014-10-08 21:14:43 (+0530), Jeshwanth Kumar N K <
> jeshkumar...@gmail.com> wrote:
> > > Wayback when I was working on some project to wake up userspace
> program for
> > > every rising edge in GPIO pin (hall sensor), I use to send signal to
> the
> > > PID from kernel, before that userspace has to register its PID with
> kernel
> > > module.
> > >
> > I've seen a certain vendor[1] do something similar. They saved the task
> > pointer for whichever process made the magical ioctl() call and used it
> > to send signals from the interrupt handler. It worked, right up to the
> > point where the process went away and then the kernel panicked.
>
> Exactly, don't do that :)
>
> Finding out the real problem that is attempting to be solved would be
> good...
>
> greg k-h
>



-- 
Regards
Jeshwanth Kumar N K
Bangalore, India
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Greg Kroah-Hartman
On Wed, Oct 08, 2014 at 05:57:50PM +0200, Kristof Provost wrote:
> On 2014-10-08 21:14:43 (+0530), Jeshwanth Kumar N K  
> wrote:
> > Wayback when I was working on some project to wake up userspace program for
> > every rising edge in GPIO pin (hall sensor), I use to send signal to the
> > PID from kernel, before that userspace has to register its PID with kernel
> > module. 
> > 
> I've seen a certain vendor[1] do something similar. They saved the task
> pointer for whichever process made the magical ioctl() call and used it
> to send signals from the interrupt handler. It worked, right up to the
> point where the process went away and then the kernel panicked.

Exactly, don't do that :)

Finding out the real problem that is attempting to be solved would be
good...

greg k-h

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Kristof Provost
On 2014-10-08 21:14:43 (+0530), Jeshwanth Kumar N K  
wrote:
> Wayback when I was working on some project to wake up userspace program for
> every rising edge in GPIO pin (hall sensor), I use to send signal to the
> PID from kernel, before that userspace has to register its PID with kernel
> module. 
> 
I've seen a certain vendor[1] do something similar. They saved the task
pointer for whichever process made the magical ioctl() call and used it
to send signals from the interrupt handler. It worked, right up to the
point where the process went away and then the kernel panicked.

Regards,
Kristof

[1] Who shall remain nameless here. Naming them would only give people
the impression that other vendors might be better.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Jeshwanth Kumar N K
Wayback when I was working on some project to wake up userspace program for
every rising edge in GPIO pin (hall sensor), I use to send signal to the
PID from kernel, before that userspace has to register its PID with kernel
module. Max interrupts I have tested is some 100 times per second I.e. 100
times wakes up userspace application per second. It was working quite
well.. But today also I don't know what other thing can be used for this
case, as it is asynchronous.

Sent from my Android phone with Gmail. Please excuse my brevity.
On 08-Oct-2014 7:03 pm, "Greg KH"  wrote:

> On Wed, Oct 08, 2014 at 04:39:17PM +0900, manty kuma wrote:
> > Hi,
> > I want a user process to be notified on device wakeup so that I can
> print some
> > related information.
>
> Really?  My device can "wakeup" thousands of times a second, what are
> you going to do with that type of information?
>
> > Which framework to use for this?(events, .. ??)
> >
> > One idea I get is to log the info into  and poll(implement my
> poll) on
> > it for data. This is my last option.
> >
> > Are there any better ways?
>
> What problem are you trying to solve here?
>
> thanks,
>
> greg k-h
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: User space <==> kernel space for device wakeups.

2014-10-08 Thread Greg KH
On Wed, Oct 08, 2014 at 04:39:17PM +0900, manty kuma wrote:
> Hi,
> I want a user process to be notified on device wakeup so that I can print some
> related information.

Really?  My device can "wakeup" thousands of times a second, what are
you going to do with that type of information?

> Which framework to use for this?(events, .. ??)
> 
> One idea I get is to log the info into  and poll(implement my poll) 
> on
> it for data. This is my last option.
> 
> Are there any better ways?

What problem are you trying to solve here?

thanks,

greg k-h

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


User space <==> kernel space for device wakeups.

2014-10-08 Thread manty kuma
Hi,
I want a user process to be notified on device wakeup so that I can print
some related information.

Which framework to use for this?(events, .. ??)

One idea I get is to log the info into  and poll(implement my
poll) on it for data. This is my last option.

Are there any better ways?

Best Regards,
Manty
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies