Date: Tue, 10 Jan 2012 11:58:00 GMT From: Robert Nagy <robert@nerd.hu> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/163986: avoid reloading modules in devd for usb devices Message-ID: <201201101158.q0ABw0Ml070166@red.freebsd.org> Resent-Message-ID: <201201101200.q0AC0OXl058469@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 163986 >Category: misc >Synopsis: avoid reloading modules in devd for usb devices >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Jan 10 12:00:24 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Robert Nagy >Release: FreeBSD 9.0-RC3 amd64 >Organization: >Environment: FreeBSD x200s.humppa.hu 9.0-RC3 FreeBSD 9.0-RC3 #0: Sun Dec 4 08:56:36 UTC 2011 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: devd tries to reload kernel modules which are loaded already because of multiple already-attached devices in a system. e.g.: umodem, ng_ubt. This causes a lot of error messages on boot which is quiet annoying. >How-To-Repeat: boot any machine with multiple usb devices attached to it >Fix: Only try to load the module if it's not loaded already. The attached patch adds a quiet feature to kldstat's -n flag so that we can rely on just the return values of kldstat and load based on that in the action fields of /etc/devd/usb.conf. The diff does not actually include the generated usb.conf because that would have been too big for the attachment. Patch attached with submission follows: Index: sbin/kldstat/kldstat.c =================================================================== --- sbin/kldstat/kldstat.c (revision 229928) +++ sbin/kldstat/kldstat.c (working copy) @@ -146,8 +146,12 @@ } if (filename != NULL) { - if ((fileid = kldfind(filename)) < 0) - err(1, "can't find file %s", filename); + if ((fileid = kldfind(filename)) < 0) { + if (!quiet) + warn("can't find file %s", filename); + return 1; + } else if (quiet) + return 0; } printf("Id Refs Address%*c Size Name\n", POINTER_WIDTH - 7, ' '); Index: sbin/kldstat/kldstat.8 =================================================================== --- sbin/kldstat/kldstat.8 (revision 229928) +++ sbin/kldstat/kldstat.8 (working copy) @@ -35,10 +35,12 @@ .Nm .Op Fl v .Op Fl i Ar id -.Op Fl n Ar filename .Nm .Op Fl q .Op Fl m Ar modname +.Nm +.Op Fl qv +.Op Fl n Ar filename .Sh DESCRIPTION The .Nm Index: tools/tools/bus_autoconf/bus_usb.c =================================================================== --- tools/tools/bus_autoconf/bus_usb.c (revision 229928) +++ tools/tools/bus_autoconf/bus_usb.c (working copy) @@ -317,8 +317,8 @@ printf(" match \"intprotocol\" \"0x%02x\";\n", id->bInterfaceProtocol); } - printf(" action \"kldload %s\";\n" - "};\n\n", id->module_name); + printf(" action \"kldstat -qn %s || kldload %s\";\n" + "};\n\n", id->module_name, id->module_name); return (n); } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201101158.q0ABw0Ml070166>