public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Detecting kernel shutdown in a kernel driver
@ 2005-02-10 20:05 Simon White
  2005-02-10 21:48 ` Stephen Hemminger
  2005-02-11 15:14 ` Andi Kleen
  0 siblings, 2 replies; 3+ messages in thread
From: Simon White @ 2005-02-10 20:05 UTC (permalink / raw)
  To: linux-kernel

Hi,

I've been writing a device driver for a piece of hardware that we recently found the pci bridge has an issue on software reset (kernel 2.6.8.1, hardware reset is fine).  The bridge appears to corrupt the subvendor/device ids on next boot.  We have found a software work around in that I can write to the bridge on module exit and it will always detect correctly next boot (through module_exit when rmmod'd).

However on shutting down a machine with the module loaded it never works next time, so is module_exit actually called?

Secondly I searched through some code and on google to determine if I could detect a shutdown notification in the kernel.  I thougt I'd found something using:

static struct pci_driver hsid_driver =
{
    .name     = HSID_NAME,
    .id_table = id_table,
    .probe    = hsid_probe,
    .driver   =
    {
        .shutdown = hsid_shutdown,
    },
};

However that also appears not to work.  I wondered what the correct solution was for detecting system shutdown in the kernel even if the application using the device has locked up on un-interruptible sleep, so I may try to clean the hardware up a little.

Thankyou for any assistance,
Simon

Please CC me.

-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm


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

* Re: Detecting kernel shutdown in a kernel driver
  2005-02-10 20:05 Detecting kernel shutdown in a kernel driver Simon White
@ 2005-02-10 21:48 ` Stephen Hemminger
  2005-02-11 15:14 ` Andi Kleen
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2005-02-10 21:48 UTC (permalink / raw)
  To: Simon White; +Cc: linux-kernel

On Thu, 10 Feb 2005 15:05:37 -0500
"Simon White" <s_a_white@email.com> wrote:

> Hi,
> 
> I've been writing a device driver for a piece of hardware that we recently found the pci bridge has an issue on software reset (kernel 2.6.8.1, hardware reset is fine).  The bridge appears to corrupt the subvendor/device ids on next boot.  We have found a software work around in that I can write to the bridge on module exit and it will always detect correctly next boot (through module_exit when rmmod'd).
> 
> However on shutting down a machine with the module loaded it never works next time, so is module_exit actually called?

(Line wrap your mail please)

> Secondly I searched through some code and on google to determine if I could detect a shutdown notification in the kernel.  I thougt I'd found something using:
> 
> static struct pci_driver hsid_driver =
> {
>     .name     = HSID_NAME,
>     .id_table = id_table,
>     .probe    = hsid_probe,
>     .driver   =
>     {
>         .shutdown = hsid_shutdown,
>     },
> };
> 
> However that also appears not to work.  I wondered what the correct solution was for detecting system shutdown in the kernel even if the application using the device has locked up on un-interruptible sleep, so I may try to clean the hardware up a little.
> 
> Thankyou for any assistance,
> Simon

How about the following, you probably still need pci_hook to handle PCI hot plug,
but you hardware probably doesn't do bus hot plug anyway.

------------

static int hsid_notify(struct notifier_block *this, unsigned long code, void *unused)
{
        if (code==SYS_DOWN || code==SYS_HALT) {
 		bang_the_bridge();
        }

        return NOTIFY_DONE;
}


static struct notifier_block hsid_notifier = {
	.notifier_call	= hsid_notify,
};


hsid_module_init()
	...
	register_reboot_notifier(&hsid_notifier);


hsid_module_exit()
	...
	unregister_reboot_notifier(&hsid_notifier);

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

* Re: Detecting kernel shutdown in a kernel driver
  2005-02-10 20:05 Detecting kernel shutdown in a kernel driver Simon White
  2005-02-10 21:48 ` Stephen Hemminger
@ 2005-02-11 15:14 ` Andi Kleen
  1 sibling, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2005-02-11 15:14 UTC (permalink / raw)
  To: Simon White; +Cc: linux-kernel

"Simon White" <s_a_white@email.com> writes:

> Hi,
>
> I've been writing a device driver for a piece of hardware that we recently found the pci bridge has an issue on software reset (kernel 2.6.8.1, hardware reset is fine).  The bridge appears to corrupt the subvendor/device ids on next boot.  We have found a software work around in that I can write to the bridge on module exit and it will always detect correctly next boot (through module_exit when rmmod'd).
>
> However on shutting down a machine with the module loaded it never works next time, so is module_exit actually called?

It's only called when the module is explicitely unloaded.

You can use register_reboot_notifier() though.

-Andi

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

end of thread, other threads:[~2005-02-11 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-10 20:05 Detecting kernel shutdown in a kernel driver Simon White
2005-02-10 21:48 ` Stephen Hemminger
2005-02-11 15:14 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox