kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Send/receive ATA cmds from a linux kernel module
@ 2017-01-30 19:38 Siddhartha Baral
  2017-02-02  7:11 ` Greg KH
  0 siblings, 1 reply; 10+ messages in thread
From: Siddhartha Baral @ 2017-01-30 19:38 UTC (permalink / raw)
  To: kernelnewbies

Hi All,

          I am trying to write a linux kernel module which can send/receive
ATA SMART cmds to a HDD. The kernel module will take a set of actions based
on the responses it receives from the HDD. I went through the ATA smart
cmds spec and the "smartctl" user space code which sends the ATA cmds from
user space via SG_IO ioctl cmd. I am not able to figure out how to open
/dev/sda from kernel and achieve similar functionalities line "smartctl"
tool from a kernel module.

   1.

   Can someone point me to any sample code which tries to send ATA smart
   cmds from a kernel module instead of user space via ioctl?
   2.

   Seems like I need to use some exported API from SG driver or libata. is
   this the right direction?
   3.

   Please feel free to suggest how can I achieve this.

Thanks, Sid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170130/90b72956/attachment.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Send/receive ATA cmds from a linux kernel module
  2017-01-30 19:38 Send/receive ATA cmds from a linux kernel module Siddhartha Baral
@ 2017-02-02  7:11 ` Greg KH
  2017-02-02 14:54   ` Siddhartha Baral
  0 siblings, 1 reply; 10+ messages in thread
From: Greg KH @ 2017-02-02  7:11 UTC (permalink / raw)
  To: kernelnewbies

On Mon, Jan 30, 2017 at 01:38:01PM -0600, Siddhartha Baral wrote:
> Hi All,
> 
> ? ? ? ? ? I am trying to write a linux kernel module which can send/receive ATA
> SMART cmds to a HDD.

First off, why?  What problem are you trying to solve that you have
decided that this is the correct solution?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Send/receive ATA cmds from a linux kernel module
  2017-02-02  7:11 ` Greg KH
@ 2017-02-02 14:54   ` Siddhartha Baral
  2017-02-02 15:03     ` Greg KH
  2017-02-02 16:28     ` valdis.kletnieks at vt.edu
  0 siblings, 2 replies; 10+ messages in thread
From: Siddhartha Baral @ 2017-02-02 14:54 UTC (permalink / raw)
  To: kernelnewbies

Hi Greg,
            I am trying to add a new thermal zone driver for HDD which will
be part of the thermal framework in the kernel.

Thanks,
Sid

On Thu, Feb 2, 2017 at 1:11 AM, Greg KH <greg@kroah.com> wrote:

> On Mon, Jan 30, 2017 at 01:38:01PM -0600, Siddhartha Baral wrote:
> > Hi All,
> >
> >           I am trying to write a linux kernel module which can
> send/receive ATA
> > SMART cmds to a HDD.
>
> First off, why?  What problem are you trying to solve that you have
> decided that this is the correct solution?
>
> thanks,
>
> greg k-h
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170202/e43ea842/attachment.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Send/receive ATA cmds from a linux kernel module
  2017-02-02 14:54   ` Siddhartha Baral
@ 2017-02-02 15:03     ` Greg KH
  2017-02-02 16:28     ` valdis.kletnieks at vt.edu
  1 sibling, 0 replies; 10+ messages in thread
From: Greg KH @ 2017-02-02 15:03 UTC (permalink / raw)
  To: kernelnewbies

On Thu, Feb 02, 2017 at 08:54:27AM -0600, Siddhartha Baral wrote:
> Hi Greg,
> ? ? ? ? ? ? I am trying to add a new thermal zone driver for HDD which will be
> part of the thermal framework in the kernel.

Why does it have to be in the kernel?  Why can't you do it all from
userspace?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Send/receive ATA cmds from a linux kernel module
  2017-02-02 14:54   ` Siddhartha Baral
  2017-02-02 15:03     ` Greg KH
@ 2017-02-02 16:28     ` valdis.kletnieks at vt.edu
  2017-02-02 16:32       ` Siddhartha Baral
  1 sibling, 1 reply; 10+ messages in thread
From: valdis.kletnieks at vt.edu @ 2017-02-02 16:28 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 02 Feb 2017 08:54:27 -0600, Siddhartha Baral said:

>             I am trying to add a new thermal zone driver for HDD which will
> be part of the thermal framework in the kernel.

First Law of Systems Programming:

Never test for an error condition you don't know how to handle anyhow.

If the disk reports that it is over-temperature, *what can you do about it*?

If a CPU gets too hot you can reduce the clock frequency.  You don't
have that sort of option on a disk drive - especially from inside the
kernel.  You can't change its rotation rate, and throttling I/O won't
significantly change the temperature (but can hang the system if writeback
of dirty pages stops....)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 484 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170202/f3fd7ce4/attachment.bin 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Send/receive ATA cmds from a linux kernel module
  2017-02-02 16:28     ` valdis.kletnieks at vt.edu
@ 2017-02-02 16:32       ` Siddhartha Baral
  2017-02-02 16:57         ` Greg KH
  0 siblings, 1 reply; 10+ messages in thread
From: Siddhartha Baral @ 2017-02-02 16:32 UTC (permalink / raw)
  To: kernelnewbies

We have a separate cooling device for HDD.

On Thu, Feb 2, 2017 at 10:28 AM, <valdis.kletnieks@vt.edu> wrote:

> On Thu, 02 Feb 2017 08:54:27 -0600, Siddhartha Baral said:
>
> >             I am trying to add a new thermal zone driver for HDD which
> will
> > be part of the thermal framework in the kernel.
>
> First Law of Systems Programming:
>
> Never test for an error condition you don't know how to handle anyhow.
>
> If the disk reports that it is over-temperature, *what can you do about
> it*?
>
> If a CPU gets too hot you can reduce the clock frequency.  You don't
> have that sort of option on a disk drive - especially from inside the
> kernel.  You can't change its rotation rate, and throttling I/O won't
> significantly change the temperature (but can hang the system if writeback
> of dirty pages stops....)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170202/bf97f296/attachment-0001.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Send/receive ATA cmds from a linux kernel module
  2017-02-02 16:32       ` Siddhartha Baral
@ 2017-02-02 16:57         ` Greg KH
  2017-02-02 17:27           ` Siddhartha Baral
  0 siblings, 1 reply; 10+ messages in thread
From: Greg KH @ 2017-02-02 16:57 UTC (permalink / raw)
  To: kernelnewbies

On Thu, Feb 02, 2017 at 10:32:56AM -0600, Siddhartha Baral wrote:
> We have a separate cooling device for HDD.

Why aren't you controlling that from userspace as well?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Send/receive ATA cmds from a linux kernel module
  2017-02-02 16:57         ` Greg KH
@ 2017-02-02 17:27           ` Siddhartha Baral
  2017-02-02 17:35             ` Greg KH
  0 siblings, 1 reply; 10+ messages in thread
From: Siddhartha Baral @ 2017-02-02 17:27 UTC (permalink / raw)
  To: kernelnewbies

I think it needs a much bigger change i.e need to move the framework to
kernel space to control this from user space.
In short, I need to get this done in kernel as I want this module to fit in
the current framework. Please suggest if you have any implementation
specific idea for this.

Thanks,
Sid


On Thu, Feb 2, 2017 at 10:57 AM, Greg KH <greg@kroah.com> wrote:

> On Thu, Feb 02, 2017 at 10:32:56AM -0600, Siddhartha Baral wrote:
> > We have a separate cooling device for HDD.
>
> Why aren't you controlling that from userspace as well?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170202/4c8bae90/attachment.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Send/receive ATA cmds from a linux kernel module
  2017-02-02 17:27           ` Siddhartha Baral
@ 2017-02-02 17:35             ` Greg KH
  2017-02-02 17:39               ` Siddhartha Baral
  0 siblings, 1 reply; 10+ messages in thread
From: Greg KH @ 2017-02-02 17:35 UTC (permalink / raw)
  To: kernelnewbies

On Thu, Feb 02, 2017 at 11:27:26AM -0600, Siddhartha Baral wrote:
> I think it needs a much bigger change i.e need to move the framework to kernel
> space to control this from user space.

I don't understand, what framework do you have to move?  Userspace can
read the temperature and then do whatever it wants to do (i.e. send
commands to your cooling system).

> In short, I need to get this done in kernel as I want this module to fit in the
> current framework. Please suggest if you have any implementation specific idea
> for this.

Do you have a pointer to your code somewhere that we can see what you
are doing and have tried that did not work out?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Send/receive ATA cmds from a linux kernel module
  2017-02-02 17:35             ` Greg KH
@ 2017-02-02 17:39               ` Siddhartha Baral
  0 siblings, 0 replies; 10+ messages in thread
From: Siddhartha Baral @ 2017-02-02 17:39 UTC (permalink / raw)
  To: kernelnewbies

I don't have any code yet and was doing the design analysis part. I will
try some experimental stuff soon and then move from there I guess. BTW,
thanks for your time!

On Thu, Feb 2, 2017 at 11:35 AM, Greg KH <greg@kroah.com> wrote:

> On Thu, Feb 02, 2017 at 11:27:26AM -0600, Siddhartha Baral wrote:
> > I think it needs a much bigger change i.e need to move the framework to
> kernel
> > space to control this from user space.
>
> I don't understand, what framework do you have to move?  Userspace can
> read the temperature and then do whatever it wants to do (i.e. send
> commands to your cooling system).
>
> > In short, I need to get this done in kernel as I want this module to fit
> in the
> > current framework. Please suggest if you have any implementation
> specific idea
> > for this.
>
> Do you have a pointer to your code somewhere that we can see what you
> are doing and have tried that did not work out?
>
> thanks,
>
> greg k-h
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170202/caf2fc4a/attachment.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-02-02 17:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-30 19:38 Send/receive ATA cmds from a linux kernel module Siddhartha Baral
2017-02-02  7:11 ` Greg KH
2017-02-02 14:54   ` Siddhartha Baral
2017-02-02 15:03     ` Greg KH
2017-02-02 16:28     ` valdis.kletnieks at vt.edu
2017-02-02 16:32       ` Siddhartha Baral
2017-02-02 16:57         ` Greg KH
2017-02-02 17:27           ` Siddhartha Baral
2017-02-02 17:35             ` Greg KH
2017-02-02 17:39               ` Siddhartha Baral

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).