1

I'm very new to linux device drivers and currently working on USB driver currently. I need to make USB related drivers as loadable modules and remove/re-insert them on will. But I'm facing certain issues.I'm working on Dragonboard 820 based on Qualcomm Snapdragon 820 processor(APQ8096).

Linux Kernel Version: 3.18.20

Android Version: 6.0

Insertion of drivers work first time.Here is the order of insertion.
insmod dbm.ko
insmod dbm-1_4.ko
insmod dbm-1_5.ko
insmod dwc3.ko
insmod dwc3-msm.ko
insmod dwc3-pci.ko

insmod ehci-hcd.ko
insmod ehci-pci.ko

insmod xhci-hcd.ko

insmod xhci-pci.ko
insmod xhci-plat-hcd.ko

insmod phy-msm-ssusb-qmp.ko
insmod phy-msm-qusb.ko

insmod usb-storage.ko

'lsmod' gives the following output;

root@msm8996:/system/lib/modules # lsmod Module Size Used by usb_storage 55391 0 phy_msm_qusb 18820 4 phy_msm_ssusb_qmp 17033 2 xhci_plat_hcd 6509 0 xhci_pci 4916 0 xhci_hcd 158558 2 xhci_plat_hcd,xhci_pci,[permanent] ehci_pci 4594 0 ehci_hcd 69125 1 ehci_pci dwc3_pci 2890 0 dwc3_msm 50671 0 dwc3 237561 1 dwc3_msm dbm_1_5 6526 0 dbm_1_4 6197 0 dbm 2119 3 dwc3_msm,dbm_1_5,dbm_1_4

USB works well after insertion.However while trying to remove the drivers (in the reverse order),three drivers -phy_msm_qusb,phy_msm_ssusb_qmp and xhci_hcd aren't removed and re-insertion of other drivers crashes (while re-inserting xhci_plat_hcd). If I do a forced removal of those drivers, it is highly unstable and crashes either at removal of remaining drivers or while re-inserting. So, if anyone has any input on this - that's highly appreciated.

Jay
  • 21
  • 1

1 Answers1

0

xhci_hcd is permanent and can not be unloaded with modprobe

Why is this kernel module marked at permanent on 2.6.39

maybe it is similar with phy_msm_ssusb_qmp and phy_msm_qusb if the phy stands for physical and means lowest-level firmware used by the USB host controller chips

these three modules are the lowest level that can not be altered. maybe the problem is the ordering in that the other modules are re-inserted because of the dependencies. The 'Used by' column of the lsmod output in your post says i.e. that ehci_hcd is used by ehci_pci However each loaded module is used by an (unknown) process on the system and this is the point why you can not unload the three modules anymore (locked by kernel process)

For example, in the above sample output, iptable_filter is used by one (unknown) Linux process, while ip_tables module is used by one kernel module called iptable_filter. source: http://xmodulo.com/how-to-check-kernel-module-dependencies-on-linux.html

maybe you have to accept that once loaded they stay and order the change the ordering of re-insertion according to the dependencies

another possibility is that they are buggy, see the case in Why is this kernel module marked at permanent on 2.6.39

in http://pritambankar.blogspot.de/2012/10/solution-to-problem-of-module-getting.html is a solution for permanent marked modules ( recompile using -DCC_HAVE_ASM_GOTO flag )

Community
  • 1
  • 1
ralf htp
  • 9,149
  • 4
  • 22
  • 34
  • Thanks for the reply Ralf . `xhci_hcd` is shown permanent because it lacks an exit function. If you add one, it is no longer shown permanent and you can remove it. About the other two, you are right they are being used by some unknown processes. I have been informed that these drivers are not meant to be compiled as loadable modules and hence gave up on this approach. – Jay Apr 20 '17 at 05:13