Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 369061 - >sys-kernel/gentoo-sources-2.6.38-r4 Usb storage devices freeze system
Summary: >sys-kernel/gentoo-sources-2.6.38-r4 Usb storage devices freeze system
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard: linux-2.6.39.1
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-28 17:25 UTC by Chema
Modified: 2011-06-20 13:31 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Screen just after system freeze (IMG_0114.JPG,686.78 KB, text/plain)
2011-06-17 19:44 UTC, Chema
Details
Screen just after system freeze (IMG_0114.JPG,686.78 KB, image/jpeg)
2011-06-17 19:48 UTC, Chema
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chema 2011-05-28 17:25:29 UTC
I've been all day installing diferent versions of gentoo-sources for a problem with usb storage device, such as a pendrive, a digital audio player(iAudio) or a PSP and i finally found the last working version: 2.6.38-r4

The problem is that when plugging or unplugging this devices all the system freezes and i can't do a thing (not ever REISUB works) i have to hard reset the PC

Reproducible: Always

Steps to Reproduce:
1. install sys-kernel/gentoo-sources-2.6.38-r5 or later
2. start the system (with or without X)
3. Plug and unplug several devices several times (normally it needs between 1 and 4 tries)
Actual Results:  
System freezes

Expected Results:  
Not freeze lol

emerge --info

Portage 2.1.9.49 (default/linux/amd64/10.0/desktop, gcc-4.5.2, glibc-2.13-r2, 2.6.38-gentoo-r4 x86_64)
=================================================================
System uname: Linux-2.6.38-gentoo-r4-x86_64-Intel-R-_Core-TM-_i5-2300_CPU_@_2.80GHz-with-gentoo-2.0.2
Timestamp of tree: Fri, 27 May 2011 11:45:01 +0000
ccache version 3.1.4 [enabled]
app-shells/bash:          4.2_p10
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.1-r1, 3.2
dev-util/ccache:          3.1.4
dev-util/cmake:           2.8.4-r1
sys-apps/baselayout:      2.0.2
sys-apps/openrc:          0.8.2-r1
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68                                                                                                                                                
sys-devel/automake:       1.5-r1, 1.10.3, 1.11.1-r1                                                                                                                                 
sys-devel/binutils:       2.21                                                                                                                                                      
sys-devel/gcc:            4.5.2                                                                                                                                                     
sys-devel/gcc-config:     1.4.1-r1                                                                                                                                                  
sys-devel/libtool:        2.4-r1                                                                                                                                                    
sys-devel/make:           3.82                                                                                                                                                      
sys-kernel/linux-headers: 2.6.38 (virtual/os-headers)                                                                                                                               
sys-libs/glibc:           2.13-r2                                                                                                                                                   
ACCEPT_KEYWORDS="amd64 ~amd64"                                                                                                                                                      
ACCEPT_LICENSE="* -@EULA"                                                                                                                                                           
CBUILD="x86_64-pc-linux-gnu"                                                                                                                                                        
CFLAGS="-O2 -march=native -pipe -fomit-frame-pointer"                                                                                                                               
CHOST="x86_64-pc-linux-gnu"                                                                                                                                                         
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/openvpn/easy-rsa"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -march=native -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs ccache distlocks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://www.gtlib.gatech.edu/pub/gentoo http://ftp.udc.es/gentoo/snapshots/ http://darkstar.ist.utl.pt/gentoo http://ftp.jaist.ac.jp/pub/Linux/Gentoo/ http://gentoo.virginmedia.com/ ftp://gentoo.virginmedia.com/sites/gentoo"
LANG="es_ES.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="es es_ES"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/sunrise /var/lib/layman/lcd-filtering /var/lib/layman/pcsx2 /var/lib/layman/vmware /usr/local/portage"
SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi alsa amd64 berkdb branding bzip2 cairo cddb cdparanoia cdr cli consolekit cracklib crypt cups cxx dbus desktopglobe djvu dri dts dvd dvdr dvdread emboss enca encode exif fam ffmpeg firefox flac foomaticdb fortran gdu gif glib hddtemp iconv imagemagick ipv6 java java6 jpeg kde lcdfilter lcms libnotify lm_sensors mad matroska mmx mmxext mng modules mp2 mp3 mp4 mpeg mplayer mudflap multilib musepack nls nptl nptlonly ogg opengl openmp oss pam pango pcre pdf perl png policykit ppds pppd python qt3support qt4 quicktime rar raw readline samba sdl semantic-desktop session spell sse sse2 sse3 sse4 ssl ssse3 startup-notification svg sysfs tcpd theora threads tiff truetype udev unicode usb vdpau vim-syntax vorbis x264 xcb xcomposite xft xine xml xorg xosd xpm xulrunner xv xvid zip zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="braindump flow karbon kexi kpresenter krita tables words" CAMERAS="canon ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="es es_ES" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Chris Chan 2011-05-31 07:41:05 UTC
Enable kernel logging and make sure your kernel syncs to the disk after every write, and report back with some kernel log info.
Comment 2 Chema 2011-06-01 12:13:16 UTC
Well i'll need a little help with that, i don't know how to do it.

I've enabled this in the kernel:

[*] Kernel debugging
[*]   Debug shared IRQ handlers
[*]   Detect Hard and Soft Lockups

and 

[*]     USB verbose debug messages
[*]     USB Mass Storage verbose debug

and this is my /etc/fstab

/dev/sda1               /boot           ext2            defaults,noatime,nodiratime        1 2       
/dev/sda5               /               ext4            defaults,noatime,exec,nodiratime,commit=1       0 1
/dev/sda6               /var            ext4            defaults,noatime,barrier=0,nodiratime,commit=1  0 1
/dev/sda7               /usr/src        ext4            defaults,noatime,nodiratime,commit=1        0 1
/dev/sda8               /usr/portage    ext4            defaults,noatime,nodiratime        0 1       
/dev/sda9               /usr/portage/distfiles  ext4    defaults,noatime,nodiratime        0 1       
/dev/sda2               none            swap            sw              0 0
/dev/sda10              /home           ext4            defaults,auto,user,rw,exec,noatime,nodiratime,commit=1      0 1
tmpfs                   /dev/shm        tmpfs           nodev,nosuid,noexec     0 0


I see USB debug messages with watch -n 0,1 "dmesg|tail -n 60" but i don't see anything wrong and i can't save it into a file.

Besides, /var/log/messages don't show anything, only garbage like this

^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^
Comment 3 G.K.MacGregor 2011-06-02 19:29:35 UTC
Got bitten by this bug after upgrading to the newly stabled gentoo-sources-2.6.38-r6; the presence of a USB mass storage device will most of the time cause a kernel panic, whether it be present during bootup or plugged in later.

I found this thread elsewhere...

https://bbs.archlinux.org/viewtopic.php?id=119034

...and like the people over there I have an AMD quad-core CPU. Reading that thread, I'm not clear on whether the finger points to that version of the kernel, udev, or both.
Comment 4 Mike Pagano gentoo-dev 2011-06-06 19:36:01 UTC
Can you please test with vanilla-sources-2.6.38.8 or gentoo-sources-2.6.38-r7 (both of which I just committed) ?
Comment 5 G.K.MacGregor 2011-06-07 20:11:48 UTC
(In reply to comment #4)
> Can you please test with vanilla-sources-2.6.38.8 or gentoo-sources-2.6.38-r7
> (both of which I just committed) ?

gentoo-sources-2.6.38-r7 seems to solve it for me!

2.6.38-r6 would cause a kernel panic about 1 in 3 times a USB mass storage device was detected. With 2.6.38-r7, using my external hard drive and also my mobile phone and MP3 player which appear as mass storage devices, I've plugged and unplugged them several dozen times and no panic or crash has occured.
Comment 6 Mike Pagano gentoo-dev 2011-06-07 20:42:30 UTC
Thanks, I'll roll a new 2.6.39 which also contains this fix in a few days.
Comment 7 Mike Pagano gentoo-dev 2011-06-08 18:23:17 UTC
gentoo-sources-2.6.39-r1 released with the patch for this issue.
Comment 8 Chema 2011-06-09 14:25:07 UTC
Sorry but this isn't fixed for me, i've tried with 38-r7 and 39-r1 and it's always the same.

Only with 38-r4 or less the system doesn't freeze
Comment 9 Chema 2011-06-11 18:59:45 UTC
Well, do i need to do something to get this fixed? maybe there is some kind of procedure that i'm missing in updating the kernel?
Comment 10 Chema 2011-06-17 19:44:27 UTC
Created attachment 277407 [details]
Screen just after system freeze

It says something of blk-core.c
Comment 11 Chema 2011-06-17 19:46:48 UTC
I attached a screen of my system just after the freeze and i think i finally got something.

I hope this is of some use to you. 

Thanks.
Comment 12 Chema 2011-06-17 19:48:03 UTC
Created attachment 277409 [details]
Screen just after system freeze

Sorry wrong content type
Comment 13 colo-des 2011-06-19 21:07:26 UTC
The solution is:

# eselect kernel list
Available kernel symlink targets:
  [1]   linux-2.6.38-gentoo-r4
  [2]   linux-2.6.38-gentoo-r5
  [3]   linux-2.6.38-gentoo-r6
  [4]   linux-2.6.38-gentoo-r7
  [5]   linux-2.6.39-gentoo-r1 *

# nano -w /usr/src/linux-2.6.39-gentoo-r1/drivers/scsi/scsi_sysfs.c
ctrl+w: struct device_attribute dev_attr_hstate =
static struct device_attribute dev_attr_hstate =

ctrl+w: struct attribute_group scsi_shost_attr_group =
static struct attribute_group scsi_shost_attr_group =

# cd /usr/src/linux
# make
# make modules_install
# mount /boot
# make install
# umount /boot
# shutdown -r now

This is the patch:
https://patchwork.kernel.org/patch/487421/

For the next release "2.6.39-r2" seem to be included.
https://lwn.net/Articles/447767/

Greetings
Comment 14 colo-des 2011-06-19 23:58:48 UTC
Well, it seems that after using it a while, the problem returned 
then I started looking for another patch has come out and meet me 
with this set of patches:
http://kernel.org/pub/linux/kernel/v2.6/stable-review/patch-2.6.39.2-rc1.gz

Then apply the changes to two files scsi_scan.c scsi_sysfs.c
and now I can say I made a thousand proofs of connecting and disconnecting 
USB sticks and so far I have not had more kernel panic.

# nano -w /usr/src/linux-2.6.39-gentoo-r1/drivers/scsi/scsi_scan.c
ctrl+w: sdev->request_queue->queuedata = sdev;
and one line up...
blk_get_queue(sdev->request_queue);

# nano -w /usr/src/linux-2.6.39-gentoo-r1/drivers/scsi/scsi_sysfs.c
ctrl+w: /* NULL queue means the device can't be used */
and one line up...
blk_put_queue(sdev->request_queue);

# cd /usr/src/linux
# make
# mount /boot
# make install
# umount /boot
# shutdown -r now

Greetings
Comment 15 Chema 2011-06-20 13:31:06 UTC
Oh man, i love you LOL

After applying the modifications suggested by Néstor A. Marchesini the bug is gone!!!