Re: [PATCH v2 2/4] driver core: enable drivers to use deferred probefrom init

Tetsuo Handa
2014-08-10T13:43:30Z

Greg KH wrote:
> Why doesn't it work? Doesn't modprobe come right back and the init
> sequence still takes a while to run? What exactly fails?

I guess ...

> @@ -5429,9 +5429,19 @@ mptsas_init(void)
> return error;
> }
>
> +static struct task_struct *init_thread;
> +
> +static int __init
> +mptsas_init(void)
> +{
> + init_thread = kthread_run(mptsas_real_init, NULL, "mptsas_init");
> + return 0;
> +}
> +
> static void __exit
> mptsas_exit(void)
> {
> + kthread_stop(init_thread);
> pci_unregister_driver(&mptsas_driver);
> sas_release_transport(mptsas_transport_template);
>
>

kthread_run() can fail. sas_attach_transport() and/or pci_register_driver()
in mptsas_real_init() can fail. Caller process may fail to continue if
sas_attach_transport() and pci_register_driver() in mptsas_real_init() has
not completed yet.

kthread_stop() must not be called when kthread_run() failed.
pci_unregister_driver() and/or sas_release_transport() must not be called
when mptsas_real_init() did not return 0 (or has not returned 0 yet).