Re: deferred attach (Solaris 8)



In article <1172746393.308142.110570@xxxxxxxxxxxxxxxxxxxxxxxxxx>,
oaksoy@xxxxxxxxx writes:
Hi,

That would appear to contradict the attach(9E) manpage:

The attach(9E) function is called once for each instance of
the device on the system with cmd set to DDI_ATTACH. Until
attach(9E) succeeds, the only driver entry point which may
be called is getinfo(9E). See the Writing Device Drivers for
more information.


I have Solaris 8, and on the manpage for attach, it says

"... until attach(9E) succeeds, the only driver entry points which may
be called are open(9E) and getinfo(9E)."


If it can happen, I suspect it's because the attach and open can
be done by different threads, so the open can be called before the
attach has returned. However, the evidence is contradictory.

This is what I do not understand. The 'system' calls _init, and
_attach when it decides to load the driver, following an 'open' call
to this device. So there's only one thread in this situation.

That's not a safe assumption.

A bit of playing around with Dtrace in Solaris 10 shows that your
thread which calls open(2) is the thread which goes off to load
the driver, but isn't the thread which calls into any of the
driver functions, so that's being done by other thread(s) (at least
in the case of a STREAMS driver, and this is not unexpected as
threads in the STREAMS framework routinely pass work between each
other). Since I can't compile Dtrace fbt probes for a module which
isn't yet loaded, it's difficult to catch the thread which calls
the driver's attach(9E) function (would have to look into the
driver framework to find where it's called from, which I haven't
done).

In the case of an open(2) call when the module is already loaded,
then your thread which called open(2) actually calls the driver's
open function each time I tried it (although this probably won't
be guaranteed).

--
Andrew Gabriel
[email address is not usable -- followup in the newsgroup]
.



Relevant Pages

  • Re: MOUHID attaching problem
    ... driver passes AttachDevice function in CDevice.cpp. ... UHCD driver DLL attach ... InitializeUHCI ++ ... CHub(Root tier 0)::AllocateDeviceArray - attempting to allocate 1 devices ...
    (microsoft.public.windowsce.platbuilder)
  • [PATCH 2.6.10-rc1 0/4] driver-model: manual device attach
    ... These are the manual device attach patches I was talking about in the ... dev.autoattach is read/write integer sysctl node which controls ... driver-model's behavior regarding device - driver association. ...
    (Linux-Kernel)
  • Re: Adding a driver
    ... Are you trying to load a 32 bit driver in a 64 bit OS or v/v? ... I restarted the machine and ran my install script hoping my attach ... Is the a function I can call to probe the PCI bus just to check my my ...
    (comp.unix.solaris)
  • Problems installing X25 9.1 on Solaris 8
    ... Driver successfully added to system but failed to attach ... Warning: Driver successfully added to system but failed to attach ... Installation of was successful. ...
    (SunManagers)
  • HP-UX driver attach routine not called, ioscan does not help
    ... An HP-UX 11.0 DLKM PCI interface device driver I have written does not ... attach() is still not called. ... the loadand attachroutines that I am using to track down the ...
    (comp.sys.hp.hpux)