linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Monkey-patching libahci
@ 2014-07-14 18:30 Ian Pilcher
  0 siblings, 0 replies; only message in thread
From: Ian Pilcher @ 2014-07-14 18:30 UTC (permalink / raw)
  To: linux-ide

I have a Thecus N5550 NAS with an ICH10R AHCI controller.  5 of the AHCI
ports are used for "data" drives, and each of these has an activity LED
which is driven by one of the ICH GPIOs.  (The other AHCI port is used
by the internal SATA DOM.)

In order to make the LEDs actually blink, I am wrapping libahci's
qc_issue function to blink the LED that corresponds to a given command's
port (if any):


https://github.com/ipilcher/n5550/blob/master/modules/n5550_ahci_leds.c#L177

I "hook in" the wrapper function by ensuring that my module is loaded
immediately after libahci (via modprobe configuration) and directly
modifying ahci_ops.qc_issue.  I do everything I can think of to make
sure that no other libahci users are loaded while I'm making the
changes.


https://github.com/ipilcher/n5550/blob/master/modules/n5550_ahci_leds.c#L207

I also prevent my module from being unloaded when any other libahci
users are loaded.  The module keeps an additional reference to itself,
which is released when the hook is successfully disabled via sysfs.


https://github.com/ipilcher/n5550/blob/master/modules/n5550_ahci_leds.c#L79

This definitely works, and it allows me to use pre-packaged kernels on
this system (ELRepo kernel-lt on CentOS 6 and hopefully the CentOSPlus
kernel on CentOS 7), but it sure does feel ugly and hackish.

Short of patching and rebuilding the libahci or ahci modules, is there a
better way to do this?  (Keeping in mind that I'm not worried about
supporting any other hardware configuration.)

Thanks!

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
-------- "I grew up before Mark Zuckerberg invented friendship" --------
========================================================================


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-14 18:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-14 18:30 Monkey-patching libahci Ian Pilcher

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).