X-Git-Url: https://pere.pagekite.me/gitweb/homepage.git/blobdiff_plain/6245bdf42ac4fb7e7c72f04b4fb9da450fc11d85..2dd35d1d62851ab01fd6df1483462219c4884416:/blog/tags/debian/index.html diff --git a/blog/tags/debian/index.html b/blog/tags/debian/index.html index 7b7eea1325..bb01d60574 100644 --- a/blog/tags/debian/index.html +++ b/blog/tags/debian/index.html @@ -3684,6 +3684,104 @@ RHEL6 with glxgears. No idea why.

+
+ +
+
+ Which module is loaded for a given PCI and USB device? +
+
+ 2011-01-23 00:20 +
+ +
+ +

In the +discover-data +package in Debian, there is a script to report useful information +about the running hardware for use when people report missing +information. One part of this script that I find very useful when +debugging hardware problems, is the part mapping loaded kernel module +to the PCI device it claims. It allow me to quickly see if the kernel +module I expect is driving the hardware I am struggling with. To see +the output, make sure discover-data is installed and run +/usr/share/bug/discover-data 3>&1. The relevant output on +one of my machines like this:

+ +
+loaded modules:
+10de:03eb i2c_nforce2
+10de:03f1 ohci_hcd
+10de:03f2 ehci_hcd
+10de:03f0 snd_hda_intel
+10de:03ec pata_amd
+10de:03f6 sata_nv
+1022:1103 k8temp
+109e:036e bttv
+109e:0878 snd_bt87x
+11ab:4364 sky2
+
+ +

The code in question look like this, slightly modified for +readability and to drop the output to file descriptor 3:

+ +
+if [ -d /sys/bus/pci/devices/ ] ; then
+    echo loaded pci modules:
+    (
+        cd /sys/bus/pci/devices/
+        for address in * ; do
+            if [ -d "$address/driver/module" ] ; then
+                module=`cd $address/driver/module ; pwd -P | xargs basename`
+                if grep -q "^$module " /proc/modules ; then
+                    address=$(echo $address |sed s/0000://)
+		    id=`lspci -n -s $address | tail -n 1 | awk '{print $3}'`
+                    echo "$id $module"
+                fi
+            fi
+        done
+    )
+    echo
+fi
+
+ +

Similar code could be used to extract USB device module +mappings:

+ +
+if [ -d /sys/bus/usb/devices/ ] ; then
+    echo loaded usb modules:
+    (
+        cd /sys/bus/usb/devices/
+        for address in * ; do
+            if [ -d "$address/driver/module" ] ; then
+                module=`cd $address/driver/module ; pwd -P | xargs basename`
+                if grep -q "^$module " /proc/modules ; then
+                    address=$(echo $address |sed s/0000://)
+                    id=$(lsusb -s $address | tail -n 1 | awk '{print $6}')
+                    if [ "$id" ] ; then
+                        echo "$id $module"
+                    fi
+                fi
+            fi
+        done
+    )
+    echo
+fi
+
+ +

This might perhaps be something to include in other tools as +well.

+ +
+
+ + + + Tags: debian, english. + +
+

RSS Feed

@@ -3699,7 +3797,7 @@ RHEL6 with glxgears. No idea why.

  • 2011
  • @@ -3787,19 +3885,19 @@ RHEL6 with glxgears. No idea why.

  • bootsystem (10)
  • -
  • debian (46)
  • +
  • debian (47)
  • -
  • debian edu (57)
  • +
  • debian edu (58)
  • digistan (7)
  • -
  • english (84)
  • +
  • english (85)
  • fiksgatami (1)
  • fildeling (11)
  • -
  • intervju (3)
  • +
  • intervju (4)
  • kart (5)
  • @@ -3811,7 +3909,7 @@ RHEL6 with glxgears. No idea why.

  • multimedia (11)
  • -
  • norsk (104)
  • +
  • norsk (105)
  • nuug (116)