Joachim Worringen wrote:
> Greetings,
>
> I have two kernel modules (brought over from Linux), one being a 
> hardware driver ("D") and another a plain module "S" (actually, a socket 
> module, see project volo-gate).
>
> S depends on D as it calls its functions. This is expressed in the link 
> step via "-dy -ND". Things load fine, but problems are with D 
> attaching/detaching:
> - D does not load or even attach when S is loaded, but only when I i.e. 
> read from its /dev entry.
> - as soon as D attaches, things work well (S calling D's funcions get 
> the expected result)
> - however, D detaches after some time (the kernel seems to trigger this, 
> not D itself!), and if S calls D's functions now, it gets results 
> indicating "now hardware found" (internal state of D when not being 
> attached).
> - once I manually make D attach again, thinks work well. Both D and S 
> remain loaded all the time.
>
> This should be a pretty common problem - how is this handled properly?
>
>   Joachim
>
>   
We have this same issue with RDS (reliable datagram sockets) that runs 
over  IB. Most system do not have IB hardware, So just like you,   we 
also have two drivers. When a socket is opened, the socket driver checks 
if the HW driver has been loaded, if not it loads the driver by opening 
the device.

see rds_open()/rds_open_transport_driver()/rds_close_transport_driver()

rds_open()
{
<..........>
        /* Open the transport driver if IB HW is present */
        rw_enter(&rds_transport_lock, RW_READER);
        if (rds_transport_handle == NULL) {
                rw_exit(&rds_transport_lock);
                ret = rds_open_transport_driver();
                rw_enter(&rds_transport_lock, RW_READER);

                if (ret != 0) {
                        /* Transport driver failed to load */
                        rw_exit(&rds_transport_lock);
                        return (ret);
                }
<.....>

Rao.

_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to