2006-01-18 07:06:01

by Mukund JB.

[permalink] [raw]
Subject: clarity on kref needed.


Dear All,

I have gone through kref and am planning to implement then in my usb driver.
please terminate my misconceptions if any by correcting the statements below.

In the call below:
kref_init(&dev->kref);
sets the refcount in the kref to 1.

kref_put(&dev->kref);
increment the refcount.

kref_put(&dev->kref, mem_release );
What I understand is when the refcount falls back to '1', only then the mem_release() function will be called.
Is it correct? I mean, when is the mem_release () called i.e. when the refcount is '0' or '1'.

Thanks & Regards,
Mukund Jampala


2006-01-18 15:51:27

by Greg KH

[permalink] [raw]
Subject: Re: clarity on kref needed.

On Wed, Jan 18, 2006 at 12:27:45PM +0530, Mukund JB. wrote:
>
> Dear All,
>
> I have gone through kref and am planning to implement then in my usb driver.

What kind of usb driver?

> please terminate my misconceptions if any by correcting the statements below.
>
> In the call below:
> kref_init(&dev->kref);
> sets the refcount in the kref to 1.

Yes.

> kref_put(&dev->kref);
> increment the refcount.

Hm, don't you mean "kref_get()" here? If so, yes, that is correct.

> kref_put(&dev->kref, mem_release );
> What I understand is when the refcount falls back to '1', only then
> the mem_release() function will be called.

No, when it falls to 0 it will be called.

> Is it correct? I mean, when is the mem_release () called i.e. when the
> refcount is '0' or '1'.

0. There's an OLS paper from a few years ago that describes kref in
detail, as well as the in-kernel documentation of it (see the file
Documentation/kref.txt). Did you read that?

thanks,

greg k-h

2006-01-19 04:54:20

by Mukund JB.

[permalink] [raw]
Subject: RE: clarity on kref needed.


> > I have gone through kref and am planning to implement then
> in my usb driver.
>
> What kind of usb driver?
It is a finger print authentication USB driver. it doesn ot do the authgentication but transports data to the application which really does some processing.

No, I did not find any Documentation/kref.txt.
But I have read about kred in the link below:
http://developer.osdl.org/dev/robustmutexes/src/fusyn.hg/Documentation/kref.txt

Is kref depricated because I find nothing related to it in linux/Documentation/?

Thanks & Regards,
Mukund Jampala
>
> > please terminate my misconceptions if any by correcting the
> statements below.
> >
> > In the call below:
> > kref_init(&dev->kref);
> > sets the refcount in the kref to 1.
>
> Yes.
>
> > kref_put(&dev->kref);
> > increment the refcount.
>
> Hm, don't you mean "kref_get()" here? If so, yes, that is correct.
>
> > kref_put(&dev->kref, mem_release );
> > What I understand is when the refcount falls back to '1', only then
> > the mem_release() function will be called.
>
> No, when it falls to 0 it will be called.
>
> > Is it correct? I mean, when is the mem_release () called
> i.e. when the
> > refcount is '0' or '1'.
>
> 0. There's an OLS paper from a few years ago that describes kref in
> detail, as well as the in-kernel documentation of it (see the file
> Documentation/kref.txt). Did you read that?
>
> thanks,
>
> greg k-h
>

2006-01-19 05:03:38

by Greg KH

[permalink] [raw]
Subject: Re: clarity on kref needed.

On Thu, Jan 19, 2006 at 10:15:51AM +0530, Mukund JB. wrote:
>
> > > I have gone through kref and am planning to implement then
> > in my usb driver.
> >
> > What kind of usb driver?
> It is a finger print authentication USB driver. it doesn ot do the
> authgentication but transports data to the application which really
> does some processing.

You shouldn't need a kernel driver for this, it can be done in userspace
with libusb/usbfs, right?

> No, I did not find any Documentation/kref.txt.
> But I have read about kred in the link below:
> http://developer.osdl.org/dev/robustmutexes/src/fusyn.hg/Documentation/kref.txt
>
> Is kref depricated because I find nothing related to it in linux/Documentation/?

What kernel version are you looking at? Look in the kernel source tree
from kernel.org. What kernel tree are you building your driver against.

And no, it's not depreciated at all.

thanks,

greg k-h

2006-01-19 05:13:59

by Mukund JB.

[permalink] [raw]
Subject: RE: clarity on kref needed.



> -----Original Message-----
> From: Greg KH [mailto:[email protected]]
> Sent: Thursday, January 19, 2006 10:33 AM
> To: Mukund JB.
> Cc: [email protected]
> Subject: Re: clarity on kref needed.
>
>
> On Thu, Jan 19, 2006 at 10:15:51AM +0530, Mukund JB. wrote:
> >
> > > > I have gone through kref and am planning to implement then
> > > in my usb driver.
> > >
> > > What kind of usb driver?
> > It is a finger print authentication USB driver. it doesn ot do the
> > authgentication but transports data to the application which really
> > does some processing.
>
> You shouldn't need a kernel driver for this, it can be done
> in userspace
> with libusb/usbfs, right?

I mean I will register a char driver. I will just write a simple char kernel module to read data from the USB device and
zero copy it to the userspace application. I guess that is the minimum work we need to do.

Is there any other way using libusb/usbfs in which we can do this without a need of USB kernel driver?

> > No, I did not find any Documentation/kref.txt.
> > But I have read about kred in the link below:
> >
> http://developer.osdl.org/dev/robustmutexes/src/fusyn.hg/Docum
entation/kref.txt
> >
> >Is kref depricated because I find nothing related to it in linux/Documentation/?

> What kernel version are you looking at? Look in the kernel source tree
> from kernel.org. What kernel tree are you building your driver against.

I am planning it for 2.6.11.12.

Regards,
Mukund Jampala

2006-01-19 05:32:52

by Greg KH

[permalink] [raw]
Subject: Re: clarity on kref needed.

On Thu, Jan 19, 2006 at 10:35:37AM +0530, Mukund JB. wrote:
>
>
> > -----Original Message-----
> > From: Greg KH [mailto:[email protected]]
> > Sent: Thursday, January 19, 2006 10:33 AM
> > To: Mukund JB.
> > Cc: [email protected]
> > Subject: Re: clarity on kref needed.
> >
> >
> > On Thu, Jan 19, 2006 at 10:15:51AM +0530, Mukund JB. wrote:
> > >
> > > > > I have gone through kref and am planning to implement then
> > > > in my usb driver.
> > > >
> > > > What kind of usb driver?
> > > It is a finger print authentication USB driver. it doesn ot do the
> > > authgentication but transports data to the application which really
> > > does some processing.
> >
> > You shouldn't need a kernel driver for this, it can be done
> > in userspace
> > with libusb/usbfs, right?
>
> I mean I will register a char driver. I will just write a simple char
> kernel module to read data from the USB device and zero copy it to the
> userspace application. I guess that is the minimum work we need to do.

You can do that from userspace with libusb/usbfs with no kernel driver
needed. Why not do that instead?

> Is there any other way using libusb/usbfs in which we can do this
> without a need of USB kernel driver?

Yes, use libusb/usbfs :)

> > > No, I did not find any Documentation/kref.txt.
> > > But I have read about kred in the link below:
> > >
> > http://developer.osdl.org/dev/robustmutexes/src/fusyn.hg/Docum
> entation/kref.txt
> > >
> > >Is kref depricated because I find nothing related to it in linux/Documentation/?
>
> > What kernel version are you looking at? Look in the kernel source tree
> > from kernel.org. What kernel tree are you building your driver against.
>
> I am planning it for 2.6.11.12.

That's a pretty old kernel version, why not use the latest version?

thanks,

greg k-h

2006-01-19 07:09:03

by Mukund JB.

[permalink] [raw]
Subject: RE: clarity on kref needed.


Can you give me some pointers & documentation links for HOWTO using libusb/usbfs instead of a kernel driver.

Regards,
Mukund Jampala

> -----Original Message-----
> From: Greg KH [mailto:[email protected]]
> Sent: Thursday, January 19, 2006 11:03 AM
> To: Mukund JB.
> Cc: [email protected]
> Subject: Re: clarity on kref needed.
>
>
> On Thu, Jan 19, 2006 at 10:35:37AM +0530, Mukund JB. wrote:
> >
> >
> > > -----Original Message-----
> > > From: Greg KH [mailto:[email protected]]
> > > Sent: Thursday, January 19, 2006 10:33 AM
> > > To: Mukund JB.
> > > Cc: [email protected]
> > > Subject: Re: clarity on kref needed.
> > >
> > >
> > > On Thu, Jan 19, 2006 at 10:15:51AM +0530, Mukund JB. wrote:
> > > >
> > > > > > I have gone through kref and am planning to implement then
> > > > > in my usb driver.
> > > > >
> > > > > What kind of usb driver?
> > > > It is a finger print authentication USB driver. it
> doesn ot do the
> > > > authgentication but transports data to the application
> which really
> > > > does some processing.
> > >
> > > You shouldn't need a kernel driver for this, it can be done
> > > in userspace
> > > with libusb/usbfs, right?
> >
> > I mean I will register a char driver. I will just write a
> simple char
> > kernel module to read data from the USB device and zero
> copy it to the
> > userspace application. I guess that is the minimum work we
> need to do.
>
> You can do that from userspace with libusb/usbfs with no kernel driver
> needed. Why not do that instead?
>
> > Is there any other way using libusb/usbfs in which we can do this
> > without a need of USB kernel driver?
>
> Yes, use libusb/usbfs :)
>
> > > > No, I did not find any Documentation/kref.txt.
> > > > But I have read about kred in the link below:
> > > >
> > > http://developer.osdl.org/dev/robustmutexes/src/fusyn.hg/Docum
> > entation/kref.txt
> > > >
> > > >Is kref depricated because I find nothing related to it
> in linux/Documentation/?
> >
> > > What kernel version are you looking at? Look in the
> kernel source tree
> > > from kernel.org. What kernel tree are you building your
> driver against.
> >
> > I am planning it for 2.6.11.12.
>
> That's a pretty old kernel version, why not use the latest version?
>
> thanks,
>
> greg k-h
>

2006-01-19 16:16:50

by Greg KH

[permalink] [raw]
Subject: Re: clarity on kref needed.

On Thu, Jan 19, 2006 at 12:30:40PM +0530, Mukund JB. wrote:
>
> Can you give me some pointers & documentation links for HOWTO using
> libusb/usbfs instead of a kernel driver.

Try reading the libusb documentation. If you have further questions,
try the libusb developer mailing list.

good luck,

greg k-h