[Debian-eeepc-devel] Bug#665960: [PATCH] init: Do not try to unload or load the module pciehp if it is built in (was: Bug#665960: pciehp warnings at boot: please solve internally and don't warn the user)

Paul Menzel pm.debian at googlemail.com
Wed Aug 1 12:27:22 UTC 2012


user debian-eeepc-devel at lists.alioth.debian.org
usertags 665960 features
found 665960 1.1.0
tags 665960 patch
quit

Am Dienstag, den 27.03.2012, 15:38 +0100 schrieb Ben Hutchings:
> On Tue, 2012-03-27 at 19:34 +0800, jidanni at jidanni.org wrote:
> > Package: eeepc-acpi-scripts
> > Version: 1.1.12
> > Severity: wishlist
> > File: /etc/init.d/eeepc-acpi-scripts
> > 
> > We read in /usr/share/doc/eeepc-acpi-scripts/NEWS.Debian.gz:
> > 
> >   eeepc-acpi-scripts (1.1.0) unstable; urgency=low
> > 
> >   * There is no longer any need for pciehp to be listed in /etc/modules.
> >     With a new-enough kernel, it is no longer required; there is a script,
> >     run during startup, which will load it if an older kernel is in use.
> > 
> > Therefore can you just check internally without spewing all these
> > messages at us:
> [...]
> 
> The file /lib/modules/$(uname -r)/modules.builtin lists all the would-be
> modules that are built-in.

Ben, thank you for your suggestion. Please find a patch attached. You
can apply it by saving the *whole* to `foo.mbox` message and doing the
following.

        $ git am --scissors foo.mbox


Thanks,

Paul


PS: Bob, thank you for your follow up. To not break threading, please
import the messages next time by using the link on the bug report page
or by doing `bts show --mbox 665960`. That would be awesome.

--- 8< ---- >8 ---
Date: Wed, 1 Aug 2012 13:00:44 +0200
Subject: [PATCH] init: Do not try to unload or load the module pciehp if it is built in

Without this predicate [1] users are confused by the following warnings [2].

        $ more /sys/class/dmi/id/product_name # Eee PC 701 4G
        701
        $ uname -r
        3.2.0-3-686-pae
        $ more /etc/os-release
        PRETTY_NAME="Debian GNU/Linux wheezy/sid"
        NAME="Debian GNU/Linux"
        ID=debian
        ANSI_COLOR="1;31"
        $ sudo service eeepc-acpi-scripts start
        Loading EeePC support modules.../etc/init.d/eeepc-acpi-scripts: 61: [: grep: unexpected operator
        done.
        Setting super hybrid engine according to configuration...(model not supported)...done.

Please note that basically only the following conditional statement was
added and the other lines intended.

        if [ ! "grep -q pciehp.ko /lib/modules/$(uname -r)/modules.builtin" ]; then
        […]
        fi

Closes: #665960

[1] https://en.wikipedia.org/wiki/If-then-else
[2] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=665960
---
 debian/eeepc-acpi-scripts.init |   63 +++++++++++++++++++++-------------------
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git a/debian/eeepc-acpi-scripts.init b/debian/eeepc-acpi-scripts.init
index d892ce9..9391ddf 100644
--- a/debian/eeepc-acpi-scripts.init
+++ b/debian/eeepc-acpi-scripts.init
@@ -58,36 +58,39 @@ case "$1" in
 
     log_action_begin_msg 'Loading EeePC support modules'
 
-    # Load pciehp if required.
-    # There are three recognised cases:
-    # - kernel 2.6.26 & older: two parameters required
-    # - kernel 2.6.27 & .28  : one of those parameters has been removed
-    # - kernel 2.6.29 & newer: hotplugging is handled in eeepc-laptop except on the
-    #                          EeePC 900A model
-    # - kernel 2.6.32 & newer: eeepc-laptop also works on the EeePC 900A
-    if [ -d /sys/module/pciehp ]; then
-      # Hmm, already present
-      if [ "$KERNEL" -ge 29 -a "`cat /sys/class/dmi/id/product_name`" != "900A" ]; then
-        # 2.6.29 and newer on all but the EeePC 900A - unload pciehp if loaded
-        log_warning_msg 'Module "pciehp" is loaded; trying to unload'
-        maybe_warn modprobe -r pciehp
-      elif [ "$KERNEL" -ge 32 ]; then
-        # 2.6.32 and newer on all EeePC models - unload pciehp if loaded
-        log_warning_msg 'Module "pciehp" is loaded; trying to unload'
-        maybe_warn modprobe -r pciehp
-      fi
-    else
-      # Load it if needed
-      if [ "$KERNEL" -lt 27 ]; then
-        # 2.6.26 and older
-        load_module pciehp pciehp_force=1 pciehp_slot_with_bus=1
-      elif [ "$KERNEL" -lt 29 ]; then
-        # 2.6.27 and 2.6.28
-        load_module pciehp pciehp_force=1
-      elif [ "$KERNEL" -lt 32 -a "`cat /sys/class/dmi/id/product_name`" = "900A" ]; then
-        # 2.6.29 to 2.6.31 on the EeePC 900A
-        load_module pciehp pciehp_force=1
-      fi
+    # Only try to unload or load pciehp if it is a module, i. e. not built into the running kernel.
+    if [ ! "grep -q pciehp.ko /lib/modules/$(uname -r)/modules.builtin" ]; then
+        # Load pciehp if required.
+        # There are three recognised cases:
+        # - kernel 2.6.26 & older: two parameters required
+        # - kernel 2.6.27 & .28  : one of those parameters has been removed
+        # - kernel 2.6.29 & newer: hotplugging is handled in eeepc-laptop except on the
+        #                          EeePC 900A model
+        # - kernel 2.6.32 & newer: eeepc-laptop also works on the EeePC 900A
+        if [ -d /sys/module/pciehp ]; then
+          # Hmm, already present
+          if [ "$KERNEL" -ge 29 -a "`cat /sys/class/dmi/id/product_name`" != "900A" ]; then
+            # 2.6.29 and newer on all but the EeePC 900A - unload pciehp if loaded
+            log_warning_msg 'Module "pciehp" is loaded; trying to unload'
+            maybe_warn modprobe -r pciehp
+          elif [ "$KERNEL" -ge 32 ]; then
+            # 2.6.32 and newer on all EeePC models - unload pciehp if loaded
+            log_warning_msg 'Module "pciehp" is loaded; trying to unload'
+            maybe_warn modprobe -r pciehp
+          fi
+        else
+          # Load it if needed
+          if [ "$KERNEL" -lt 27 ]; then
+            # 2.6.26 and older
+            load_module pciehp pciehp_force=1 pciehp_slot_with_bus=1
+          elif [ "$KERNEL" -lt 29 ]; then
+            # 2.6.27 and 2.6.28
+            load_module pciehp pciehp_force=1
+          elif [ "$KERNEL" -lt 32 -a "`cat /sys/class/dmi/id/product_name`" = "900A" ]; then
+            # 2.6.29 to 2.6.31 on the EeePC 900A
+            load_module pciehp pciehp_force=1
+          fi
+        fi
     fi
 
     # Load rfkill-input if possible, i.e. kernel is 2.6.28, .29 or .30.
-- 
1.7.10.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/debian-eeepc-devel/attachments/20120801/5699efe9/attachment.pgp>


More information about the Debian-eeepc-devel mailing list