1. 26 6月, 2012 4 次提交
    • G
      uas: keep track of command state, finish scsi cmd when really done. · b1d67693
      Gerd Hoffmann 提交于
      Set state bits after submitting data urbs & command urbs, so we know
      what is in flight.  Clear data bits when the data urb is finished, clear
      command bit when we see the status urb for the command.  Finish the scsi
      command after running both status and data completion handlers for the
      command.
      
      Add a cmd status logging function for debugging purposes.  Hook it into
      the error handler, so we see in the log what status a command is in
      which the scsi layer wants cancel.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b1d67693
    • G
      uas: fix sense urb handling · e9bd7e1a
      Gerd Hoffmann 提交于
      Stop reusing sense urbs, just allocate a fresh one each time and free it
      when done.
      
      Stop storing a sense urb pointer in the scsi request, all you can do
      with it is misusing.  For example requeuing the sense urb, then f*ck it
      up by picking the wrong one in case tagged requests don't finish in the
      same order you've submitted them.  Also note that (not-yet supported)
      task management ops don't have a scsi request in the first place.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9bd7e1a
    • G
      Revert "usb/uas: one only one status URB/host on stream-less connection" · db32de11
      Gerd Hoffmann 提交于
      This reverts commit ceb3f91f.
      
      IMO the real bug is assigning status urbs to scsi requests.  First there
      is no such link in the non-stream case.  Also there isn't nessesarely a
      scsi request in the first place, for example when submitting task
      management requests.
      
      This patch just papers over the real bug and introduces different status
      urb handling in the stream/non-stream case for no good reason.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      db32de11
    • G
      Revert "usb/uas: make sure data urb is gone if we receive status before that" · c621a81e
      Gerd Hoffmann 提交于
      This reverts commit e4d8318a.
      
      This patch makes uas.c call usb_unlink_urb on data urbs.  The data urbs
      get freed in the completion callback.  This is illegal according to the
      usb_unlink_urb documentation.
      
      This patch also makes the code expect the data completion callback
      being called before the status completion callback.  This isn't
      guaranteed to be the case, even though the actual data transfer should
      be finished by the time the status is received.
      
      Background:  The ehci irq handler for example only know that there are
      finished transfers, it then has go check the QHs & TDs to see which
      transfers did actually finish.  It has no way to figure in which order
      the transfers did complete.  The xhci driver can call the callbacks in
      completion order thanks to the event queue.  This does nicely explain
      why the driver is solid on a (usb2) xhci port whereas it goes crazy on
      ehci in my testing.
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c621a81e
  2. 14 6月, 2012 2 次提交
  3. 18 5月, 2012 3 次提交
  4. 10 5月, 2012 1 次提交
  5. 19 4月, 2012 1 次提交
  6. 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
  7. 31 3月, 2012 1 次提交
  8. 28 3月, 2012 1 次提交
  9. 29 2月, 2012 2 次提交
  10. 25 2月, 2012 1 次提交
  11. 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
  12. 09 2月, 2012 2 次提交
    • A
      usb-storage: reorganize target-specific code · af74d2da
      Alan Stern 提交于
      Now that usb-storage has a target_alloc() routine, this patch (as1508)
      moves some existing target-specific code out of the slave_alloc()
      routine to where it really belongs.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af74d2da
    • A
      SCSI & usb-storage: add flags for VPD pages and REPORT LUNS · 09b6b51b
      Alan Stern 提交于
      This patch (as1507) adds a skip_vpd_pages flag to struct scsi_device
      and a no_report_luns flag to struct scsi_target.  The first is used to
      control whether sd will look at VPD pages for information on block
      provisioning, limits, and characteristics.  The second prevents
      scsi_report_lun_scan() from issuing a REPORT LUNS command.
      
      The patch also modifies usb-storage to set the new flag bits for all
      USB devices and targets, and to stop adjusting the scsi_level value.
      
      Historically we have seen that USB mass-storage devices often don't
      support VPD pages or REPORT LUNS properly.  Until now we have avoided
      these things by setting the scsi_level to SCSI_2 for all USB devices.
      But this has the side effect of storing the LUN bits into the second
      byte of each CDB, and now we have a report of a device which doesn't
      like that.  The best solution is to stop abusing scsi_level and
      instead have separate flags for VPD pages and REPORT LUNS.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NPerry Wagle <wagle@mac.com>
      CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09b6b51b
  13. 03 2月, 2012 3 次提交
    • S
      usb/uas: make sure data urb is gone if we receive status before that · e4d8318a
      Sebastian Andrzej Siewior 提交于
      Just run into the following:
      - new disk arrived in the system
      - udev couldn't wait to get its hands on to to run ata_id /dev/sda
      - this sent the cdb 0xa1 to the device.
      - my UAS-gadget recevied the cdb and had no idea what to do with it. It
        decided to send a status URB back with sense set to invalid opcode.
      - the host side received it status and completed the scsi command.
      - the host sent another scsi with 4kib data buffer
      - Now I was confused why the data transfer is only 512 bytes instead of
        4kib since the host is always allocating the complete transfer in one
        go.
      - Finally the system crashed while walking through the sg list.
      
      This patch adds three new flags in order to distinguish between DATA
      URB completed and outstanding. If we receive status before data, we
      cancel data and let data complete the command.
      This solves the problem for IN and OUT transfers but does not work for
      BIDI.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      e4d8318a
    • S
      usb/uas: move UAS structs / defines into a header file · 348748b0
      Sebastian Andrzej Siewior 提交于
      The protocol specific structures and defines which are used by UAS are
      moved into a header files by this patch so it can be accessed by the UAS
      gadget as well.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      348748b0
    • S
      usb/uas: only bind if the hcd supports SG · c898add5
      Sebastian Andrzej Siewior 提交于
      The UAS driver requires SG support by the HCD operating the device. This
      patch stops UAS from operating on a HCD without sg support and prints a
      message to let him know.
      
      The spec says:
      |For [USB2] backward compatibility, the device shall present [BOT] as
      |alternate interface zero (primary) and [UAS] as alternate interface one
      |(secondary). A device which does not need backward compatibility with
      |[BOT] shall present [UAS] as alternate interface zero. In [USB2]
      |systems, the [BOT] driver or an associated filter driver may need to
      |issue a SET INTERFACE request for alternate interface one and then allow
      |the [UAS] driver to load.
      
      If the user used usb_modeswitch to switch to UAS then he can go back to
      BOT or use a different HCD. In case UAS is the only interface then there
      is currently no way out.
      In future usb_sg_wait() should be extended to provide a non-blocking
      interface so it can work with the UAS driver.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      c898add5
  14. 27 1月, 2012 1 次提交
  15. 25 1月, 2012 2 次提交
  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. 02 1月, 2012 1 次提交
  18. 22 12月, 2011 6 次提交
    • S
      usb/uas: one only one status URB/host on stream-less connection · ceb3f91f
      Sebastian Andrzej Siewior 提交于
      The status/sense URB is allocated on per-command basis. A read/write
      looks the following way on a stream-less connection:
      
      - send cmd tag X, queue status
      - receive status, oh it is a read for tag X. queue status & read
      - receive read
      - receive status, oh I'm done for tag X. Cool call complete and free
        status urb.
      
      This block repeats itself 1:1 for further commands and looks great so
      far. Lets take a look now what happens if we do allow multiple commands:
      
      - send cmd tag X, queue statusX (belongs to the command with the X tag)
      - send cmd tag Y, queue statusY (belongs to the command with the Y tag)
      - receive statusX, oh it is a read for tag X. queue statusX & a read
      - receive read
      - receive statusY, oh I'm done for tag X. Cool call complete and free statusY.
      - receive statusX, oh it is a read for tag Y. queue statusY & before we
        queue the read the the following message can be observed:
        |sd 0:0:0:0: [sda] sense urb submission failure
        followed by a second attempt with the same result.
      
      In order to address this problem we will use only one status URB for
      each scsi host in case we don't have stream support (as suggested by
      Matthew). This URB is requeued until the device removed. Nothing changes
      on stream based endpoints.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      ceb3f91f
    • S
      usb/uas: use scsi_host_find_tag() to find command from a tag · 22188f4a
      Sebastian Andrzej Siewior 提交于
      In "usb/uas: use unique tags for all LUNs" we make sure to create unique
      tags across all LUNs. This patch uses scsi_host_find_tag() to obtain the
      correct command which is associated with the tag.
      The following changes are required:
      - don't use sdev->current_cmnd anymore
        Since we can have devices which don't support command queueing we must
        ensure that we can tell the two commands apart. Even if a device
        supports comand queuing we send the INQUIRY command "untagged" for
        LUN1 while we can send a tagged command to LUN0 at the same time.
        devinfo->cmnd is used for stashing the one "untagged" command.
      - tag number is altered. If stream support is used then the tag number
        must match the stream number. Therefore we can't use tag 0 and must
        start at tag 1.
        In case we have untagged commands (at least the first command) we must
        be able to distinguish between command tag 0 (which becomes 1) and
        untagged command (which becomes curently also 1).
        The following tag numbers are used:
        0: never
        1: for untagged commands (devinfo->cmnd)
        2+: tagged commands.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      22188f4a
    • S
      usb/uas: use unique tags for all LUNs · dae51546
      Sebastian Andrzej Siewior 提交于
      I observed that on a device with multiple LUNs UAS was re-using the same
      tag number for requests which were issued at the same time to both LUNs.
      This patch uses scsi_init_shared_tag_map() to use unique tags for all
      LUNs. With this patch I haven't seen the same tag number during the init
      sequence anymore. Tag 1 is used for devices which do not adverise
      command queueing.
      This patch initilizes the queue before adding the scsi host like the
      other two user in tree.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      dae51546
    • S
      UAS: Free status URB when we can't find the SCSI tag. · 96c1eb98
      Sarah Sharp 提交于
      In the UAS status URB completion handler, we need to free the URB, no
      matter what happens.  Fix a bug where we would leak the URB (and its
      buffer) if we couldn't find a SCSI command that is associated with this
      status phase.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Matthew Wilcox <willy@linux.intel.com>
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      96c1eb98
    • S
      UAS: Use unique tags on non-streams devices. · 9eb44541
      Sarah Sharp 提交于
      UAS can work with either USB 3.0 devices that support bulk streams, or
      USB 2.0 devices that do not support bulk streams.  When we're working
      with a non-streams device, we need to be able to uniquely identify a
      SCSI command with a tag in the IU.  Devices will barf and abort all
      queued commands if they find a duplicate tag.
      
      uas_queuecommand_lck() sets cmdinfo->stream to zero if the device
      doesn't support streams, which is later passed into uas_alloc_cmd_urb()
      as the variable stream.  This means the UAS driver was setting the tag
      in all commands to zero for non-stream devices.  So the UAS driver won't
      currently work with USB 2.0 devices.
      
      Use the SCSI command tag instead of the stream ID for the command IU
      tag.  We have to add one to the SCSI command tag because SCSI tags are
      zero-based, but stream IDs are one-based, and the command tag must match
      the stream ID that we're queueing the data IUs for.  Untagged SCSI
      commands use stream ID 1.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Matthew Wilcox <willy@linux.intel.com>
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      9eb44541
    • S
      UAS: Re-add workqueue items if submission fails. · ea9da1c7
      Sarah Sharp 提交于
      If the original submission (or allocation) of the URBs for a SCSI
      command fails, the UAS driver sticks the command structure in a
      workqueue and schedules uas_do_work() to run.  That function removes the
      entire queue before walking across it and attempting to resubmit.
      
      Unfortunately, if the second submission fails, we will leak memory
      (because an allocated URB was not submitted) and possibly leave the SCSI
      command partially enqueued on some of the stream rings.  Fix this by
      checking whether the second submission failed and re-queueing the
      command to the UAS workqueue and scheduling it.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Matthew Wilcox <willy@linux.intel.com>
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      ea9da1c7
  19. 27 11月, 2011 1 次提交
  20. 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
  21. 19 11月, 2011 1 次提交
    • G
      USB: convert drivers/usb/* to use module_usb_driver() · 65db4305
      Greg Kroah-Hartman 提交于
      This converts the drivers in drivers/usb/* to use the
      module_usb_driver() macro which makes the code smaller and a bit
      simpler.
      
      Added bonus is that it removes some unneeded kernel log messages about
      drivers loading and/or unloading.
      
      Cc: Simon Arlott <cxacru@fire.lp0.eu>
      Cc: Duncan Sands <duncan.sands@free.fr>
      Cc: Matthieu CASTET <castet.matthieu@free.fr>
      Cc: Stanislaw Gruszka <stf_xl@wp.pl>
      Cc: Pete Zaitcev <zaitcev@redhat.com>
      Cc: Oliver Neukum <oliver@neukum.name>
      Cc: Juergen Stuber <starblue@users.sourceforge.net>
      Cc: Cesar Miquel <miquel@df.uba.ar>
      Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Cc: Matthew Wilcox <willy@linux.intel.com>
      Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Cc: Felipe Balbi <balbi@ti.com>
      Cc: Lucas De Marchi <lucas.demarchi@profusion.mobi>
      Cc: Michael Hund <mhund@ld-didactic.de>
      Cc: Zack Parsons <k3bacon@gmail.com>
      Cc: Melchior FRANZ <mfranz@aon.at>
      Cc: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
      Cc: Dan Carpenter <error27@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      65db4305
  22. 16 11月, 2011 3 次提交