1. 16 9月, 2014 1 次提交
    • A
      scsi: don't store LUN bits in CDB[1] for USB mass-storage devices · 50c4e964
      Alan Stern 提交于
      The SCSI specification requires that the second Command Data Byte
      should contain the LUN value in its high-order bits if the recipient
      device reports SCSI level 2 or below.  Nevertheless, some USB
      mass-storage devices use those bits for other purposes in
      vendor-specific commands.  Currently Linux has no way to send such
      commands, because the SCSI stack always overwrites the LUN bits.
      
      Testing shows that Windows 7 and XP do not store the LUN bits in the
      CDB when sending commands to a USB device.  This doesn't matter if the
      device uses the Bulk-Only or UAS transports (which virtually all
      modern USB mass-storage devices do), as these have a separate
      mechanism for sending the LUN value.
      
      Therefore this patch introduces a flag in the Scsi_Host structure to
      inform the SCSI midlayer that a transport does not require the LUN
      bits to be stored in the CDB, and it makes usb-storage set this flag
      for all devices using the Bulk-Only transport.  (UAS is handled by a
      separate driver, but it doesn't really matter because no SCSI-2 or
      lower device is at all likely to use UAS.)
      
      The patch also cleans up the code responsible for storing the LUN
      value by adding a bitflag to the scsi_device structure.  The test for
      whether to stick the LUN value in the CDB can be made when the device
      is probed, and stored for future use rather than being made over and
      over in the fast path.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NTiziano Bacocco <tiziano.bacocco@gmail.com>
      Acked-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Acked-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      50c4e964
  2. 18 7月, 2014 1 次提交
  3. 05 3月, 2014 2 次提交
  4. 09 1月, 2014 1 次提交
  5. 20 4月, 2013 2 次提交
    • G
      USB: storage: convert to use module_usb_driver() · 4601de80
      Greg Kroah-Hartman 提交于
      Now that Joe cleaned up the init/exit functions, we can just get rid of
      them entirely and use the proper macro that almost all other USB drivers
      now use.
      
      Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Cc: Joe Perches <joe@perches.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4601de80
    • J
      usb: storage: Convert US_DEBUGP to usb_stor_dbg · 191648d0
      Joe Perches 提交于
      Use a more current logging style with dev_printk
      where possible.
      
      o Convert uses of US_DEBUGP to usb_stor_dbg
      o Add "struct us_data *" to usb_stor_dbg uses
      o usb_stor_dbg now uses struct device */dev_vprint_emit
      o Removed embedded function names
      o Coalesce formats
      o Remove trailing whitespace
      o Remove useless OOM messages
      o Remove useless function entry/exit logging
      o Convert some US_DEBUGP uses to dev_info and dev_dbg
      
      Object size is slightly reduced when debugging
      is enabled, slightly increased with no debugging
      because some initialization and removal messages
      are now always emitted.
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      191648d0
  6. 05 2月, 2013 1 次提交
  7. 21 1月, 2013 1 次提交
  8. 27 11月, 2012 1 次提交
  9. 06 9月, 2012 1 次提交
  10. 20 7月, 2012 1 次提交
  11. 17 7月, 2012 1 次提交
  12. 18 5月, 2012 3 次提交
  13. 07 4月, 2012 1 次提交
    • M
      usb: storage: fix lockdep warning inside usb_stor_pre_reset(v2) · c825bab0
      Ming Lei 提交于
      This patch fixes one lockdep warning[1] inside usb_stor_pre_reset.
      
      If the current configuration includes multiple mass storage interfaces,
      the 'AA' lockdep warning will be triggered since the lock class of
      'us->dev_mutex' is acquired two times in .reset path. It isn't
      a real deadlock, so just take the lockdep_set_class annotation to
      remove the warning.
      
      [1], lockdep warning log
      :[ INFO: possible recursive locking detected ]
      :3.3.0-0.rc5.git3.1.fc17.x86_64 #1 Tainted: G        W
      :---------------------------------------------
      :usb-storage/14846 is trying to acquire lock:
      : (&(us->dev_mutex)){+.+.+.}, at: [<ffffffffa0481c0c>] usb_stor_pre_reset+0x1c/0x20 [usb_storage]
      :but task is already holding lock:
      : (&(us->dev_mutex)){+.+.+.}, at: [<ffffffffa0481c0c>] usb_stor_pre_reset+0x1c/0x20 [usb_storage]
      :other info that might help us debug this:
      : Possible unsafe locking scenario:
      :       CPU0
      :       ----
      :  lock(&(us->dev_mutex));
      :  lock(&(us->dev_mutex));
      : *** DEADLOCK ***
      : May be due to missing lock nesting notation
      :2 locks held by usb-storage/14846:
      : #0:  (&__lockdep_no_validate__){......}, at: [<ffffffff8147e6a5>] usb_lock_device_for_reset+0x95/0x100
      : #1:  (&(us->dev_mutex)){+.+.+.}, at: [<ffffffffa0481c0c>] usb_stor_pre_reset+0x1c/0x20 [usb_storage]
      :stack backtrace:
      :Pid: 14846, comm: usb-storage Tainted: G        W 3.3.0-0.rc5.git3.1.fc17.x86_64 #1
      :Call Trace:
      : [<ffffffff810cbdaf>] __lock_acquire+0x168f/0x1bb0
      : [<ffffffff81021083>] ? native_sched_clock+0x13/0x80
      : [<ffffffff810210f9>] ? sched_clock+0x9/0x10
      : [<ffffffff810210f9>] ? sched_clock+0x9/0x10
      : [<ffffffff810a2975>] ? sched_clock_local+0x25/0xa0
      : [<ffffffff810cc9a1>] lock_acquire+0xa1/0x1e0
      : [<ffffffffa0481c0c>] ? usb_stor_pre_reset+0x1c/0x20 [usb_storage]
      : [<ffffffff81699c86>] mutex_lock_nested+0x76/0x3a0
      : [<ffffffffa0481c0c>] ? usb_stor_pre_reset+0x1c/0x20 [usb_storage]
      : [<ffffffffa0481c0c>] ? usb_stor_pre_reset+0x1c/0x20 [usb_storage]
      : [<ffffffffa0481c0c>] usb_stor_pre_reset+0x1c/0x20 [usb_storage]
      : [<ffffffff8148184d>] usb_reset_device+0x7d/0x190
      : [<ffffffffa048119c>] usb_stor_port_reset+0x7c/0x80 [usb_storage]
      : [<ffffffffa0481234>] usb_stor_invoke_transport+0x94/0x560 [usb_storage]
      : [<ffffffff810cd3b2>] ? mark_held_locks+0xb2/0x130
      : [<ffffffff8169dbd0>] ? _raw_spin_unlock_irq+0x30/0x50
      : [<ffffffffa047fe3e>] usb_stor_transparent_scsi_command+0xe/0x10 [usb_storage]
      : [<ffffffffa0481ae3>] usb_stor_control_thread+0x173/0x280 [usb_storage]
      : [<ffffffffa0481970>] ? fill_inquiry_response+0x20/0x20 [usb_storage]
      : [<ffffffff8108a3f7>] kthread+0xb7/0xc0
      : [<ffffffff816a7d34>] kernel_thread_helper+0x4/0x10
      : [<ffffffff8169e0f4>] ? retint_restore_args+0x13/0x13
      : [<ffffffff8108a340>] ? kthread_worker_fn+0x1a0/0x1a0
      : [<ffffffff816a7d30>] ? gs_change+0x13/0x13
      Reported-By: NDave Jones <davej@redhat.com>
      Signed-off-by: NMing Lei <tom.leiming@gmail.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c825bab0
  14. 22 2月, 2012 1 次提交
    • A
      usb-storage: fix freezing of the scanning thread · bb94a406
      Alan Stern 提交于
      This patch (as1521b) fixes the interaction between usb-storage's
      scanning thread and the freezer.  The current implementation has a
      race: If the device is unplugged shortly after being plugged in and
      just as a system sleep begins, the scanning thread may get frozen
      before the khubd task.  Khubd won't be able to freeze until the
      disconnect processing is complete, and the disconnect processing can't
      proceed until the scanning thread finishes, so the sleep transition
      will fail.
      
      The implementation in the 3.2 kernel suffers from an additional
      problem.  There the scanning thread calls set_freezable_with_signal(),
      and the signals sent by the freezer will mess up the thread's I/O
      delays, which are all interruptible.
      
      The solution to both problems is the same: Replace the kernel thread
      used for scanning with a delayed-work routine on the system freezable
      work queue.  Freezable work queues have the nice property that you can
      cancel a work item even while the work queue is frozen, and no signals
      are needed.
      
      The 3.2 version of this patch solves the problem in Bugzilla #42730.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NSeth Forshee <seth.forshee@canonical.com>
      CC: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb94a406
  15. 25 1月, 2012 1 次提交
  16. 05 1月, 2012 1 次提交
    • H
      usb: usb-storage doesn't support dynamic id currently, the patch disables the... · 1a3a026b
      Huajun Li 提交于
      usb: usb-storage doesn't support dynamic id currently, the patch disables the feature to fix an oops
      
      Echo vendor and product number of a non usb-storage device to
      usb-storage driver's new_id, then plug in the device to host and you
      will find following oops msg, the root cause is usb_stor_probe1()
      refers invalid id entry if giving a dynamic id, so just disable the
      feature.
      
      [ 3105.018012] general protection fault: 0000 [#1] SMP DEBUG_PAGEALLOC
      [ 3105.018062] CPU 0
      [ 3105.018075] Modules linked in: usb_storage usb_libusual bluetooth
      dm_crypt binfmt_misc snd_hda_codec_analog snd_hda_intel snd_hda_codec
      snd_hwdep hp_wmi ppdev sparse_keymap snd_pcm snd_seq_midi snd_rawmidi
      snd_seq_midi_event snd_seq snd_timer snd_seq_device psmouse snd
      serio_raw tpm_infineon soundcore i915 snd_page_alloc tpm_tis
      parport_pc tpm tpm_bios drm_kms_helper drm i2c_algo_bit video lp
      parport usbhid hid sg sr_mod sd_mod ehci_hcd uhci_hcd usbcore e1000e
      usb_common floppy
      [ 3105.018408]
      [ 3105.018419] Pid: 189, comm: khubd Tainted: G          I  3.2.0-rc7+
      #29 Hewlett-Packard HP Compaq dc7800p Convertible Minitower/0AACh
      [ 3105.018481] RIP: 0010:[<ffffffffa045830d>]  [<ffffffffa045830d>]
      usb_stor_probe1+0x2fd/0xc20 [usb_storage]
      [ 3105.018536] RSP: 0018:ffff880056a3d830  EFLAGS: 00010286
      [ 3105.018562] RAX: ffff880065f4e648 RBX: ffff88006bb28000 RCX: 0000000000000000
      [ 3105.018597] RDX: ffff88006f23c7b0 RSI: 0000000000000001 RDI: 0000000000000206
      [ 3105.018632] RBP: ffff880056a3d900 R08: 0000000000000000 R09: ffff880067365000
      [ 3105.018665] R10: 00000000000002ac R11: 0000000000000010 R12: ffff6000b41a7340
      [ 3105.018698] R13: ffff880065f4ef60 R14: ffff88006bb28b88 R15: ffff88006f23d270
      [ 3105.018733] FS:  0000000000000000(0000) GS:ffff88007a200000(0000)
      knlGS:0000000000000000
      [ 3105.018773] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      [ 3105.018801] CR2: 00007fc99c8c4650 CR3: 0000000001e05000 CR4: 00000000000006f0
      [ 3105.018835] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [ 3105.018870] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
      [ 3105.018906] Process khubd (pid: 189, threadinfo ffff880056a3c000,
      task ffff88005677a400)
      [ 3105.018945] Stack:
      [ 3105.018959]  0000000000000000 0000000000000000 ffff880056a3d8d0
      0000000000000002
      [ 3105.019011]  0000000000000000 ffff880056a3d918 ffff880000000000
      0000000000000002
      [ 3105.019058]  ffff880056a3d8d0 0000000000000012 ffff880056a3d8d0
      0000000000000006
      [ 3105.019105] Call Trace:
      [ 3105.019128]  [<ffffffffa0458cd4>] storage_probe+0xa4/0xe0 [usb_storage]
      [ 3105.019173]  [<ffffffffa0097822>] usb_probe_interface+0x172/0x330 [usbcore]
      [ 3105.019211]  [<ffffffff815fda67>] driver_probe_device+0x257/0x3b0
      [ 3105.019243]  [<ffffffff815fdd43>] __device_attach+0x73/0x90
      [ 3105.019272]  [<ffffffff815fdcd0>] ? __driver_attach+0x110/0x110
      [ 3105.019303]  [<ffffffff815fb93c>] bus_for_each_drv+0x9c/0xf0
      [ 3105.019334]  [<ffffffff815fd6c7>] device_attach+0xf7/0x120
      [ 3105.019364]  [<ffffffff815fc905>] bus_probe_device+0x45/0x80
      [ 3105.019396]  [<ffffffff815f98a6>] device_add+0x876/0x990
      [ 3105.019434]  [<ffffffffa0094e42>] usb_set_configuration+0x822/0x9e0 [usbcore]
      [ 3105.019479]  [<ffffffffa00a3492>] generic_probe+0x62/0xf0 [usbcore]
      [ 3105.019518]  [<ffffffffa0097a46>] usb_probe_device+0x66/0xb0 [usbcore]
      [ 3105.019555]  [<ffffffff815fda67>] driver_probe_device+0x257/0x3b0
      [ 3105.019589]  [<ffffffff815fdd43>] __device_attach+0x73/0x90
      [ 3105.019617]  [<ffffffff815fdcd0>] ? __driver_attach+0x110/0x110
      [ 3105.019648]  [<ffffffff815fb93c>] bus_for_each_drv+0x9c/0xf0
      [ 3105.019680]  [<ffffffff815fd6c7>] device_attach+0xf7/0x120
      [ 3105.019709]  [<ffffffff815fc905>] bus_probe_device+0x45/0x80
      [ 3105.021040] usb usb6: usb auto-resume
      [ 3105.021045] usb usb6: wakeup_rh
      [ 3105.024849]  [<ffffffff815f98a6>] device_add+0x876/0x990
      [ 3105.025086]  [<ffffffffa0088987>] usb_new_device+0x1e7/0x2b0 [usbcore]
      [ 3105.025086]  [<ffffffffa008a4d7>] hub_thread+0xb27/0x1ec0 [usbcore]
      [ 3105.025086]  [<ffffffff810d5200>] ? wake_up_bit+0x50/0x50
      [ 3105.025086]  [<ffffffffa00899b0>] ? usb_remote_wakeup+0xa0/0xa0 [usbcore]
      [ 3105.025086]  [<ffffffff810d49b8>] kthread+0xd8/0xf0
      [ 3105.025086]  [<ffffffff81939884>] kernel_thread_helper+0x4/0x10
      [ 3105.025086]  [<ffffffff8192a8c0>] ? _raw_spin_unlock_irq+0x50/0x80
      [ 3105.025086]  [<ffffffff8192b1b4>] ? retint_restore_args+0x13/0x13
      [ 3105.025086]  [<ffffffff810d48e0>] ? __init_kthread_worker+0x80/0x80
      [ 3105.025086]  [<ffffffff81939880>] ? gs_change+0x13/0x13
      [ 3105.025086] Code: 00 48 83 05 cd ad 00 00 01 48 83 05 cd ad 00 00
      01 4c 8b ab 30 0c 00 00 48 8b 50 08 48 83 c0 30 48 89 45 a0 4c 89 a3
      40 0c 00 00 <41> 0f b6 44 24 10 48 89 55 a8 3c ff 0f 84 b8 04 00 00 48
      83 05
      [ 3105.025086] RIP  [<ffffffffa045830d>] usb_stor_probe1+0x2fd/0xc20
      [usb_storage]
      [ 3105.025086]  RSP <ffff880056a3d830>
      [ 3105.060037] hub 6-0:1.0: hub_resume
      [ 3105.062616] usb usb5: usb auto-resume
      [ 3105.064317] ehci_hcd 0000:00:1d.7: resume root hub
      [ 3105.094809] ---[ end trace a7919e7f17c0a727 ]---
      [ 3105.130069] hub 5-0:1.0: hub_resume
      [ 3105.132131] usb usb4: usb auto-resume
      [ 3105.132136] usb usb4: wakeup_rh
      [ 3105.180059] hub 4-0:1.0: hub_resume
      [ 3106.290052] usb usb6: suspend_rh (auto-stop)
      [ 3106.290077] usb usb4: suspend_rh (auto-stop)
      Signed-off-by: NHuajun Li <huajun.li.lee@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      1a3a026b
  17. 22 11月, 2011 1 次提交
    • T
      usb_storage: don't use set_freezable_with_signal() · ec012476
      Tejun Heo 提交于
      The current implementation of set_freezable_with_signal() is buggy and
      tricky to get right.  usb-storage is the only user and its use can be
      avoided trivially.
      
      All usb-storage wants is to be able to sleep with timeout and get
      woken up if freezing() becomes true.  This can be trivially
      implemented by doing interruptible wait w/ freezing() included in the
      wait condition.  There's no reason to use set_freezable_with_signal().
      
      Perform interruptible wait on freezing() instead of using
      set_freezable_with_signal(), which is scheduled for removal.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
      Cc: Seth Forshee <seth.forshee@canonical.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      ec012476
  18. 23 8月, 2011 1 次提交
    • S
      usb_storage: Don't freeze in usb-stor-scan · f02fe890
      Seth Forshee 提交于
      Scanning cannot be run during suspend or hibernation, but if
      usb-stor-scan freezes another thread waiting on scanning to
      complete may fail to freeze.
      
      However, if usb-stor-scan is left freezable without ever actually
      freezing then the freezer will wait on it to exit, and threads
      waiting for scanning to finish will no longer be blocked. One
      problem with this approach is that usb-stor-scan has a delay to
      wait for devices to settle (which is currently the only point where
      it can freeze). To work around this we can request that the freezer
      send a fake signal when freezing, then use interruptible sleep to
      wake the thread early when freezing happens.
      
      To make this happen, the following changes are made to
      usb-stor-scan:
      
       * Use set_freezable_with_signal() instead of set_freezable() to
         request a fake signal when freezing
      
       * Use wait_event_interruptible_timeout() instead of
         wait_event_freezable_timeout() to avoid freezing
      Signed-off-by: NSeth Forshee <seth.forshee@canonical.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f02fe890
  19. 08 6月, 2011 1 次提交
    • A
      usb-storage: redo incorrect reads · 21c13a4f
      Alan Stern 提交于
      Some USB mass-storage devices have bugs that cause them not to handle
      the first READ(10) command they receive correctly.  The Corsair
      Padlock v2 returns completely bogus data for its first read (possibly
      it returns the data in encrypted form even though the device is
      supposed to be unlocked).  The Feiya SD/SDHC card reader fails to
      complete the first READ(10) command after it is plugged in or after a
      new card is inserted, returning a status code that indicates it thinks
      the command was invalid, which prevents the kernel from retrying the
      read.
      
      Since the first read of a new device or a new medium is for the
      partition sector, the kernel is unable to retrieve the device's
      partition table.  Users have to manually issue an "hdparm -z" or
      "blockdev --rereadpt" command before they can access the device.
      
      This patch (as1470) works around the problem.  It adds a new quirk
      flag, US_FL_INVALID_READ10, indicating that the first READ(10) should
      always be retried immediately, as should any failing READ(10) commands
      (provided the preceding READ(10) command succeeded, to avoid getting
      stuck in a loop).  The patch also adds appropriate unusual_devs
      entries containing the new flag.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: NSven Geggus <sven-usbst@geggus.net>
      Tested-by: NPaul Hartman <paul.hartman+linux@gmail.com>
      CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      CC: <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      21c13a4f
  20. 20 5月, 2011 1 次提交
  21. 23 10月, 2010 1 次提交
  22. 11 8月, 2010 1 次提交
    • A
      USB: usb-storage: implement autosuspend · f283925f
      Alan Stern 提交于
      This patch (as1400) adds runtime-PM support to usb-storage.  It
      utilizes the SCSI layer's runtime-PM implementation, so its scope is
      limited.  Currently the only effect is that disk-like devices (such as
      card readers or flash drives) will be autosuspended if they aren't
      mounted and their device files aren't open.  This would apply, for
      example, to card readers that don't contain a memory card.
      
      Unfortunately this won't interact very well with the removable-media
      polling normally carried out by hal or DeviceKit.  Maybe those
      programs can be changed to use a longer polling interval, or maybe the
      default autosuspend time for usb-storage should be set to something
      below 1 second.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: James Bottomley <James.Bottomley@suse.de>
      Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f283925f
  23. 21 5月, 2010 4 次提交
  24. 27 2月, 2010 1 次提交
    • L
      Lower USB storage settling delay to something more reasonable · a4a47bc0
      Linus Torvalds 提交于
      The five-second delay can be rather annoying, and makes the system
      appear much less responsive when you connect a USB drive.
      
      It's also not entirely clear that it is needed - the settling delay has
      at least historically been an issue on some Apple iPods, for example,
      and some devices have been reported to need even more than the old 5s
      delay.
      
      But before we penalize them all, let's see how bad it really is.  Some
      of the reasons for long delays seem to be actual historical kernel bugs
      that should probably never have been papered over with a delay in the
      first place (there's a Ubuntu bug report for 2.6.20 about a NULL pointer
      dereference unless 'delay_use' is 8 or more, for example).
      
      It also looks like some distros have already shipped with delay_use=0,
      so the five second default may well be totally historical.
      
      In other words: "Let's see if anybody screams".
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a4a47bc0
  25. 21 1月, 2010 1 次提交
  26. 12 12月, 2009 5 次提交
  27. 25 3月, 2009 3 次提交