<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Loadable DLKM &amp;quot;module_attach()&amp;quot; function only called once in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499672#M653683</link>
    <description>&lt;BR /&gt;The probe function is registered AND activated. This is a requirement for dynamic DLKMs (as you cited in your previous post).&lt;BR /&gt;&lt;BR /&gt;I didn't add a printf for this to keep it simple and because this routine does NOT return a value.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here's the load function:&lt;BR /&gt;&lt;BR /&gt;static int dlclass_load(void *arg)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;/* Register with WSIO */&lt;BR /&gt;if (!wsio_install_driver(&amp;amp;dlclass_wsio_info))&lt;BR /&gt;{&lt;BR /&gt;...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;/* Attach to PCI chain */&lt;BR /&gt;status = mod_wsio_attach_list_add(MOD_WSIO_PCI, &amp;amp;dlclass_attach);&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;/* Register Probe function */&lt;BR /&gt;status = wsio_register_dev_probe(DRV_NAME, dlclass_probe, "dlclass");&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;/* Activate Probe function */&lt;BR /&gt;wsio_activate_probe("dlclass", dlclass_wsio_info.drv_info);&lt;BR /&gt;&lt;BR /&gt;return 0;&lt;BR /&gt;&lt;BR /&gt;} /* End of LOAD */&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 18 Sep 2009 10:10:53 GMT</pubDate>
    <dc:creator>kobylka</dc:creator>
    <dc:date>2009-09-18T10:10:53Z</dc:date>
    <item>
      <title>Loadable DLKM "module_attach()" function only called once</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499666#M653677</link>
      <description>Hi all!&lt;BR /&gt;&lt;BR /&gt;I'm developing a PCI LAN driver for HP-UX 11i v1 on HP9000 in form of a "dynamically-configured DLKM" module. The installation of a "dynamically-configured DLKM" module can be summarized into the following steps:&lt;BR /&gt;&lt;BR /&gt;1. Compile (make &amp;amp;&amp;amp; cc)&lt;BR /&gt;2. Install (kminstall -a module_name)&lt;BR /&gt;3. Configure (config -M module_name)&lt;BR /&gt;4. Update (kmupdate -M module_name)&lt;BR /&gt;&lt;BR /&gt;Steps 3. and 4. are often done in a single step:&lt;BR /&gt;&lt;BR /&gt;config -M module_name -u&lt;BR /&gt;&lt;BR /&gt;When a module update is requested (step 4.) the DLKM system loads the module, calls its LOAD function, calls its ATTACH function (if registered in LOAD function), and calls the UNLOAD function to unload the module.&lt;BR /&gt;&lt;BR /&gt;After that, when loading the module using&lt;BR /&gt;&lt;BR /&gt;kmadmin -L module_name&lt;BR /&gt;&lt;BR /&gt;its ATTACH function won't be called anymore (despite of being registered in the LOAD function). After subsequent tests with other dynamically-configured DLKM modules it was found that this is the normal behaviour.&lt;BR /&gt;&lt;BR /&gt;The module can be unloaded and loaded again as much as one likes, only its LOAD function will be called but its ATTACH function won't be called anymore.&lt;BR /&gt;&lt;BR /&gt;Consequences of this are that a driver won't be able to use the devices it claimed (in ATTACH function during step 4.) nor the memory it reserved for this devices (must be freed in UNLOAD function during step 4.) rendering the whole "dynamically-configured DLKM" system useless for interface/monolithic drivers.&lt;BR /&gt;&lt;BR /&gt;For statically-configured DLKM this is not an issue because the module is never unloaded.&lt;BR /&gt;&lt;BR /&gt;Now the question...&lt;BR /&gt;&lt;BR /&gt;Am I missing something?&lt;BR /&gt;Any compilation flag to solve this?&lt;BR /&gt;Any additional master/system file parameter required?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;&lt;BR /&gt;Kobylka&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hardware:&lt;BR /&gt;Visualize C3700&lt;BR /&gt;&lt;BR /&gt;% uname -mrs&lt;BR /&gt;HP-UX B.11.11 9000/785&lt;BR /&gt;%&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Sep 2009 15:33:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499666#M653677</guid>
      <dc:creator>kobylka</dc:creator>
      <dc:date>2009-09-17T15:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Loadable DLKM "module_attach()" function only called once</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499667#M653678</link>
      <description>When you say "registered in the LOAD function" -- do you mean that you're adding the attach function to the WSIO attach list and then doing a wsio_register_dev_probe() followed by wsio_activate_probe()?&lt;BR /&gt;&lt;BR /&gt;[i.e. are you following the guidelines for WSIO interface Drivers at: &lt;A href="http://docs.hp.com/en/dlkm-62001/ch01s03.html#chddgghj" target="_blank"&gt;http://docs.hp.com/en/dlkm-62001/ch01s03.html#chddgghj&lt;/A&gt; ]?</description>
      <pubDate>Thu, 17 Sep 2009 17:10:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499667#M653678</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2009-09-17T17:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Loadable DLKM "module_attach()" function only called once</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499668#M653679</link>
      <description>Thanks for your reply.&lt;BR /&gt;&lt;BR /&gt;With "registered in the LOAD function" I mean that the drivers attach function is attached to the WSIO PCI queue/chain (it's a PCI LAN card) using the specific interface for dynamically configured DLKMs&lt;BR /&gt;("HP-UX 11i v1 DDG - HP 9000 Computer Systems - Edition 5" Chapter 16. p.451):&lt;BR /&gt;&lt;BR /&gt;"New support functions have been added to WSIO to allow interface drivers to add and remove their _attach() functions from the attach list. These functions are:&lt;BR /&gt;&lt;BR /&gt;int mod_wsio_attach_list_add(list_type, &amp;amp;attach_func);&lt;BR /&gt;&lt;BR /&gt;int mod_wsio_attach_list_remove(list_type, &amp;amp;attach_func);&lt;BR /&gt;&lt;BR /&gt;The list_type specifies the attach list to use; valid entries are MOD_WSIO_CORE, MOD_WSIO_PCI, and MOD_WSIO_EISA. Both functions return 0 on success and 1 on failure."&lt;BR /&gt;&lt;BR /&gt;The first is called in the LOAD function, the second in the UNLOAD function. Thus the driver_attach() function should be called every time the module loads, not only once during kmupdate (step 4.).&lt;BR /&gt;&lt;BR /&gt;For now I'm not using a device probe routine.&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Kobylka</description>
      <pubDate>Thu, 17 Sep 2009 18:21:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499668#M653679</guid>
      <dc:creator>kobylka</dc:creator>
      <dc:date>2009-09-17T18:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Loadable DLKM "module_attach()" function only called once</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499669#M653680</link>
      <description>Ok... well, from the doc I cited - that's your problem then:&lt;BR /&gt;&lt;BR /&gt;--begin quote---&lt;BR /&gt;&lt;BR /&gt;Device probes are normally associated with interface drivers during the initialization of the WSIO Context Dependent Input/Output (CDIO) at boot time. Since this is only done once, loadable interface drivers must explicitly connect the device probe to the driver's drv_info structure:&lt;BR /&gt;&lt;BR /&gt;void wsio_activate_probe(char *probe_name, struct drv_info *drv_infop);&lt;BR /&gt;&lt;BR /&gt;probe_name is the name of the probe as registered by wsio_register_dev_probe() or wsio_register_probe_func(). drv_infop is a pointer to the drv_info structure for this driver. In general, use a probe provided by the system. For example, parallel_scsi_probe or side_probe. See the HP-UX Driver Development Guide for complete information.&lt;BR /&gt;&lt;BR /&gt;--end quote---&lt;BR /&gt;&lt;BR /&gt;and in the same code:&lt;BR /&gt;&lt;BR /&gt;--- begin quote---&lt;BR /&gt; /* The following step is only required for dynamically&lt;BR /&gt;     * loaded modules: attach the probe function to the&lt;BR /&gt;     * drv_info structure */&lt;BR /&gt;    wsio_activate_probe("probe_name", wsio_info.drv_info);&lt;BR /&gt;&lt;BR /&gt;--- end quote ---&lt;BR /&gt;&lt;BR /&gt;You certainly need to do what you're doing, but that's the minimum for static and dynamic drivers. Dynamic drivers such as yours need the extra step of the probe functionality, from what I can tell.</description>
      <pubDate>Thu, 17 Sep 2009 18:42:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499669#M653680</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2009-09-17T18:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Loadable DLKM "module_attach()" function only called once</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499670#M653681</link>
      <description>&lt;BR /&gt;I followed your advice and added a probe function to my driver, but didn't work. The same behaviour as with the PCI attach function occurs here with the probe function, that is, the probe function is only called once when updating the module (kmupdate) as part of the module installation.&lt;BR /&gt;&lt;BR /&gt;To clarify the problem I modified the example dlclass.c DLKM (dynamically configured) module to print debug info. The following output corresponds to the kmupdate step:&lt;BR /&gt;&lt;BR /&gt;Only with PCI attach function&lt;BR /&gt;----------------------------------------&lt;BR /&gt;&lt;BR /&gt;dlclass&amp;gt; Loading&lt;BR /&gt;dlclass&amp;gt; Attached PCI function!&lt;BR /&gt;dlclass&amp;gt; Attaching &amp;lt;-- PCI attach function&lt;BR /&gt;Found device!&lt;BR /&gt;10/1/6/0 dlclass &amp;lt;-- Claimed device&lt;BR /&gt;dlclass&amp;gt; Unloading&lt;BR /&gt;dlclass&amp;gt; Deattached PCI function!&lt;BR /&gt;&lt;BR /&gt;After that, trying to load the module results in:&lt;BR /&gt;&lt;BR /&gt;[243] kmadmin -L dlclass&lt;BR /&gt;kmadmin: Module dlclass loaded, ID = 8&lt;BR /&gt;[244]&lt;BR /&gt;&lt;BR /&gt;dlclass&amp;gt; Loading&lt;BR /&gt;dlclass&amp;gt; Attached PCI function!&lt;BR /&gt;&lt;BR /&gt;No PCI attach function is called (no matter how often it gets loaded/unloaded).&lt;BR /&gt;&lt;BR /&gt;Adding a probe function follows the same behaviour. During module installation (kmupdate step):&lt;BR /&gt;&lt;BR /&gt;With PCI attach and Probe functions&lt;BR /&gt;--------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;dlclass&amp;gt; Loading&lt;BR /&gt;dlclass&amp;gt; Attached PCI function!&lt;BR /&gt;dlclass&amp;gt; Registered probe function!&lt;BR /&gt;dlclass&amp;gt; Attaching &amp;lt;-- PCI attach function&lt;BR /&gt;Found device!&lt;BR /&gt;10/1/6/0 dlclass &amp;lt;-- Claimed device&lt;BR /&gt;dlclass&amp;gt; Probing &amp;lt;-- Probe function&lt;BR /&gt;dlclass&amp;gt; PROBE_FIRST&lt;BR /&gt;dlclass&amp;gt; Unloading&lt;BR /&gt;dlclass&amp;gt; Unregistered probe function!&lt;BR /&gt;dlclass&amp;gt; Deattached PCI function!&lt;BR /&gt;&lt;BR /&gt;After that, trying to load the module results in:&lt;BR /&gt;&lt;BR /&gt;[245] kmadmin -L dlclass&lt;BR /&gt;kmadmin: Module dlclass loaded, ID = 8&lt;BR /&gt;[246]&lt;BR /&gt;&lt;BR /&gt;dlclass&amp;gt; Loading&lt;BR /&gt;dlclass&amp;gt; Attached PCI function!&lt;BR /&gt;dlclass&amp;gt; Registered probe function!&lt;BR /&gt;&lt;BR /&gt;No PCI attach and no Probe functions are called.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Kobylka</description>
      <pubDate>Fri, 18 Sep 2009 08:26:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499670#M653681</guid>
      <dc:creator>kobylka</dc:creator>
      <dc:date>2009-09-18T08:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Loadable DLKM "module_attach()" function only called once</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499671#M653682</link>
      <description>Ok... I see a "Registered Probe function" there, did you not issue a printf for when you call wsio_activate_probe() as well [I would have had a "Activating Probe function"] or are you not calling to activate?</description>
      <pubDate>Fri, 18 Sep 2009 09:55:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499671#M653682</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2009-09-18T09:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Loadable DLKM "module_attach()" function only called once</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499672#M653683</link>
      <description>&lt;BR /&gt;The probe function is registered AND activated. This is a requirement for dynamic DLKMs (as you cited in your previous post).&lt;BR /&gt;&lt;BR /&gt;I didn't add a printf for this to keep it simple and because this routine does NOT return a value.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here's the load function:&lt;BR /&gt;&lt;BR /&gt;static int dlclass_load(void *arg)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;/* Register with WSIO */&lt;BR /&gt;if (!wsio_install_driver(&amp;amp;dlclass_wsio_info))&lt;BR /&gt;{&lt;BR /&gt;...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;/* Attach to PCI chain */&lt;BR /&gt;status = mod_wsio_attach_list_add(MOD_WSIO_PCI, &amp;amp;dlclass_attach);&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;/* Register Probe function */&lt;BR /&gt;status = wsio_register_dev_probe(DRV_NAME, dlclass_probe, "dlclass");&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;/* Activate Probe function */&lt;BR /&gt;wsio_activate_probe("dlclass", dlclass_wsio_info.drv_info);&lt;BR /&gt;&lt;BR /&gt;return 0;&lt;BR /&gt;&lt;BR /&gt;} /* End of LOAD */&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Sep 2009 10:10:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499672#M653683</guid>
      <dc:creator>kobylka</dc:creator>
      <dc:date>2009-09-18T10:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Loadable DLKM "module_attach()" function only called once</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499673#M653684</link>
      <description>Ok... since I only know what you tell me, I have to be paranoid and ask these things.&lt;BR /&gt;&lt;BR /&gt;Just to eliminate another possibility -- what do you get if you:&lt;BR /&gt;&lt;BR /&gt;printf("Drv class: %s\n", dlclass_wsio_info.drv_info-&amp;gt;name);&lt;BR /&gt;&lt;BR /&gt;status = wsio_register_dev_probe(DRV_NAME, dlclass_probe, dlclass_wsio_info.drv_info-&amp;gt;name);&lt;BR /&gt;&lt;BR /&gt;printf("Register status: %d.\n", status);&lt;BR /&gt;&lt;BR /&gt;wsio_activate_probe(dlclass_wsio_info.drv_info-&amp;gt;name, dlclass_wsio_info.drv_info);&lt;BR /&gt;&lt;BR /&gt;?&lt;BR /&gt;&lt;BR /&gt;I just want to be sure that WSIO and you agree on the name field of the drv_info structure since that's what the probe is supposed to match.</description>
      <pubDate>Fri, 18 Sep 2009 10:56:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499673#M653684</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2009-09-18T10:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Loadable DLKM "module_attach()" function only called once</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499674#M653685</link>
      <description>No prob, ask as much as you like, I will try to answer as best as I can. With your code the result is the same (during kmupdate step in module installation):&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;dlclass&amp;gt; Loading&lt;BR /&gt;dlclass&amp;gt; Attached PCI function!&lt;BR /&gt;Drv class: dlclass&lt;BR /&gt;Register status: 0.&lt;BR /&gt;dlclass&amp;gt; Attaching&lt;BR /&gt;Found device!&lt;BR /&gt;10/1/6/0 dlclass&lt;BR /&gt;dlclass&amp;gt; Probing&lt;BR /&gt;dlclass&amp;gt; PROBE_FIRST&lt;BR /&gt;dlclass&amp;gt; Unloading&lt;BR /&gt;dlclass&amp;gt; Unregistered probe function!&lt;BR /&gt;dlclass&amp;gt; Deattached PCI function!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Attach and probe functions are called correctly. When loading again:&lt;BR /&gt;&lt;BR /&gt;[221] % kmadmin -L dlclass&lt;BR /&gt;kmadmin: Module dlclass loaded, ID = 8&lt;BR /&gt;[222] %&lt;BR /&gt;&lt;BR /&gt;dlclass&amp;gt; Loading&lt;BR /&gt;dlclass&amp;gt; Attached PCI function!&lt;BR /&gt;Drv class: dlclass&lt;BR /&gt;Register status: 0.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;No attach, no probe. The driver is coded following strictly the DDG and DDR to not incur in such subtle errors. If there would have been an error setting up the names in&lt;BR /&gt;&lt;BR /&gt;wsio_register_dev_probe()&lt;BR /&gt;&lt;BR /&gt;and/or&lt;BR /&gt;&lt;BR /&gt;wsio_activate_probe()&lt;BR /&gt;&lt;BR /&gt;the probe function would not have been called (no match would have been found).&lt;BR /&gt;&lt;BR /&gt;Full code for the modified dlclass driver is attached so you can see exactly what is going on.&lt;BR /&gt;&lt;BR /&gt;I think the main question here is why the PCI attach function is only called once during module installation. This way you can claim your devices and initialize needed memory, yes, but it will all get lost because an immediate unload follows (as part of the module installation too, so no way to control it). The side effect is that there will be claimed devices but no way to access them (pci attach function won't be called anymore).&lt;BR /&gt;&lt;BR /&gt;This doesn't make any sense EXCEPT that the dynamic-configured flavour of DLKMs are only suitable for non interface/monolithic drivers, just for pseudo or normal device drivers, those that do not touch real hardware.&lt;BR /&gt;&lt;BR /&gt;I really appreciate your effort and interest, Don Morris. Thank you ;)&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Sep 2009 11:44:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/loadable-dlkm-quot-module-attach-quot-function-only-called-once/m-p/4499674#M653685</guid>
      <dc:creator>kobylka</dc:creator>
      <dc:date>2009-09-18T11:44:19Z</dc:date>
    </item>
  </channel>
</rss>

