-1

I have added some printk(KERN_ALERT "sample\n"); into a driver module. These prints appear if i manually insmod the driver. But if the same driver is loaded during boot, the messages do not appear.

I am sure that the same module is loaded during boot because I have changed the module author name so that it appears when i do $modinfo. The module is in kernel source path and I have compiled and $make module_install.

I am running ubuntu 10.04 and kernel version 3.14.2 what am i missing?

Thanks.

Pang
  • 9,564
  • 146
  • 81
  • 122
rohith_kugve
  • 27
  • 1
  • 4
  • *"I am running ubuntu 10.04 and kernel version 3.14.2"* -- That doesn't sound right. 10.04 LTS uses 2.6.30something. And why is the tag for `ubuntu-11.04? – sawdust Oct 24 '15 at 05:46
  • Essentially this sounds like an init timing issue. Who wrote this driver? Are there **printk()** statements that report the driver **probe()** was entered and exited successfully? Are there proper checks on every return code in the **init()** routine? Try replacing the **module_init()** statement to **late_initcall()**. – sawdust Oct 24 '15 at 05:57
  • I have compiled and installed kernel 3.14.2 on ubuntu 10.04. Tag was a mistake, will remove it. – rohith_kugve Oct 24 '15 at 05:57
  • This is actually a virtual machine and I have added prints in virtio_net.c. If i rmmod and insmod the same virtio_net.ko , prints appear on probe and every xmit. But if the driver is running from the boot time, they dont. – rohith_kugve Oct 24 '15 at 06:00
  • if your driver would be dependent on some other module which would have not be available at boot time, so your driver will fail at initialization only and there will not be any prints. – AnshuMan Gupta Oct 25 '15 at 13:13

2 Answers2

1

Ok now I know what was the mistake. I did not create an inintramfs with the new modules. So it was loading old drivers during boot form old initramfs. Thanks all.

rohith_kugve
  • 27
  • 1
  • 4
0

@silly_walker, If console is not initialized printk is of no use because where else it can redirect output to?, printk() can only output only when console is initialized. If you really want to output very early in the boot process, try using "early_printk()". Go through the below link,

http://www.makelinux.net/books/lkd2/ch18lev1sec3

Hope this solves your issue!!!

Gautham Kantharaju
  • 1,735
  • 1
  • 21
  • 24
  • Thanks, but the prints that are supposed to appear well after the initilization dont appear too. This is a network driver and I have a printk in the xmit function. It is supposed to print everytime there is a packet transmission. – rohith_kugve Oct 24 '15 at 04:49
  • *"printk is of no use because where else it can redirect output to?"* -- The output goes to a memory buffer until the console device is initialized. Then the buffer is output. If `earlyprintk` is configured and enabled, then this output is not buffered, but output by the earlycon device. This earlycon device is retired after the actual console has been initialized. – sawdust Oct 24 '15 at 06:04
  • @sawdust, Thank you for the explanation. – Gautham Kantharaju Oct 25 '15 at 13:02