1. 10 9月, 2012 2 次提交
  2. 12 4月, 2012 1 次提交
    • A
      USB: gadget: storage gadgets send wrong error code for unknown commands · c85dcdac
      Alan Stern 提交于
      This patch (as1539) fixes a minor bug in the mass-storage gadget
      drivers.  When an unknown command is received, the error code sent
      back is "Invalid Field in CDB" rather than "Invalid Command".  This is
      because the bitmask of CDB bytes allowed to be nonzero is incorrect.
      
      When handling an unknown command, we don't care which command bytes
      are nonzero.  All the bits in the mask should be set, not just eight
      of them.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: <Michal Nazarewicz <mina86@mina86.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      c85dcdac
  3. 29 2月, 2012 2 次提交
  4. 13 1月, 2012 1 次提交
  5. 12 12月, 2011 2 次提交
    • M
      usb: gadget: rename usb_gadget_driver::speed to max_speed · 7177aed4
      Michal Nazarewicz 提交于
      This commit renames the “speed” field of the usb_gadget_driver
      structure to “max_speed”.  This is so that to make it more
      apparent that the field represents the maximum speed gadget
      driver can support.
      
      This also make the field look more like fields with the same
      name in usb_gadget and usb_composite_driver structures.  All
      of those represent the *maximal* speed given entity supports.
      
      After this commit, there are the following fields in various
      structures:
      * usb_gadget::speed - the current connection speed,
      * usb_gadget::max_speed - maximal speed UDC supports,
      * usb_gadget_driver::max_speed - maximal speed gadget driver
        supports, and
      * usb_composite_driver::max_speed - maximal speed composite
        gadget supports.
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      7177aed4
    • Y
      usb: gadget: mass_storage: support multi-luns with different logic block size · 144974e7
      Yuping Luo 提交于
      With Peiyu's patch "gadget: mass_storage: adapt logic block size to bound block
      devices" (http://www.spinics.net/lists/linux-usb/msg50791.html), now mass storage
      can adjust logic block size dynamically based on real devices.
      Then there is one issue caused by it, if two luns have different logic block size,
      mass storage can't work.
      Let's check the current software flow:
      1. get_next_command(): call received_cbw();
      2. received_cbw(): update common->lun = cbw->Lun, but common->curlen is not updated;
      3. do_scsi_command(): in READ_X and WRITE_X commands, common->data_size_from_cmnd is
      updated by common->curlun->blkbits;
      4. check_command(): update common->curlun according to common->lun
      As you can see, the step 3 uses wrong common->curlun, then wrong common->curlun->blkbits.
      If the two luns have same blkbits, there isn't issue. Otherwise, both will fail.
      This patch moves the common->curlun update to step 1, then make sure step 3 gets right
      blkbits and data_size_from_cmnd.
      
      Cc: Peiyu Li <peiyu.li@csr.com>
      Signed-off-by: NYuPing Luo <yuping.luo@csr.com>
      Signed-off-by: NBarry Song <Baohua.Song@csr.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      144974e7
  6. 15 11月, 2011 2 次提交
  7. 01 11月, 2011 1 次提交
  8. 19 10月, 2011 1 次提交
    • Y
      usb: gadget: file_storage: fix race on unloading · 91960c2e
      Yauheni Kaliuta 提交于
      There is a race, reproduced rarely if you unload the module
      when host finishes mass storage device initialization (reading
      partition table and so on): fsg_unbind() code first closes
      lun files then waits for worker thread to finish its work, as
      the result the thread may operate on already closed device
      with an oops and backtrace:
      
      [  484.937225] [<b00e403c>] (touch_atime+0x4/0x140) from [<b00a1498>] (generic_file_aio_read+0x678/0x6f0)
      [  484.946563] [<b00a1498>] (generic_file_aio_read+0x678/0x6f0) from [<b00d08c4>] (do_sync_read+0xb0/0xf4)
      [  484.955963] [<b00d08c4>] (do_sync_read+0xb0/0xf4) from [<b00d1478>] (vfs_read+0xac/0x144)
      [  484.964172] [<b00d1478>] (vfs_read+0xac/0x144) from [<af24c6a8>] (fsg_setup+0x7f4/0x900 [g_file_storage])
      [  484.973785] [<af24c6a8>] (fsg_setup+0x7f4/0x900 [g_file_storage]) from [<af24da14>] (fsg_main_thread+0x85c/0x175c [g_file_storage])
      [  484.985626] [<af24da14>] (fsg_main_thread+0x85c/0x175c [g_file_storage]) from [<b0077c48>] (kthread+0x7c/0x84)
      [  484.995666] [<b0077c48>] (kthread+0x7c/0x84) from [<b002f950>] (kernel_thread_exit+0x0/0x8)
      [  485.004028] Code: eaffffd0 e28dd008 e8bd8df0 e92d40f7 (e591400c)
      
      Change the order in unbind: wait for the thread first, then close
      the files.
      Signed-off-by: NYauheni Kaliuta <yauheni.kaliuta@nokia.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      91960c2e
  9. 14 10月, 2011 2 次提交
  10. 18 9月, 2011 1 次提交
    • M
      usb: Provide usb_speed_string() function · e538dfda
      Michal Nazarewicz 提交于
      In a few places in the kernel, the code prints
      a human-readable USB device speed (eg. "high speed").
      This involves a switch statement sometimes wrapped
      around in ({ ... }) block leading to code repetition.
      
      To mitigate this issue, this commit introduces
      usb_speed_string() function, which returns
      a human-readable name of provided speed.
      
      It also changes a few places switch was used to use
      this new function.  This changes a bit the way the
      speed is printed in few instances at the same time
      standardising it.
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e538dfda
  11. 09 9月, 2011 3 次提交
    • P
      usb: gadget: storage: make FSG_NUM_BUFFERS variable size · 6532c7fd
      Per Forlin 提交于
      FSG_NUM_BUFFERS is set to 2 as default.
      Usually 2 buffers are enough to establish a good buffering pipeline.
      The number may be increased in order to compensate a for bursty VFS
      behaviour.
      
      Here follows a description of system that may require more than
      2 buffers.
       * CPU ondemand governor active
       * latency cost for wake up and/or frequency change
       * DMA for IO
      
      Use case description.
       * Data transfer from MMC via VFS to USB.
       * DMA shuffles data from MMC and to USB.
       * The CPU wakes up every now and then to pass data in and out from VFS,
         which cause the bursty VFS behaviour.
      
      Test set up
       * Running dd on the host reading from the mass storage device
       * cmdline: dd if=/dev/sdb of=/dev/null bs=4k count=$((256*100))
       * Caches are dropped on the host and on the device before each run
      
      Measurements on a Snowball board with ondemand_governor active.
      
      FSG_NUM_BUFFERS 2
      104857600 bytes (105 MB) copied, 5.62173 s, 18.7 MB/s
      104857600 bytes (105 MB) copied, 5.61811 s, 18.7 MB/s
      104857600 bytes (105 MB) copied, 5.57817 s, 18.8 MB/s
      
      FSG_NUM_BUFFERS 4
      104857600 bytes (105 MB) copied, 5.26839 s, 19.9 MB/s
      104857600 bytes (105 MB) copied, 5.2691 s, 19.9 MB/s
      104857600 bytes (105 MB) copied, 5.2711 s, 19.9 MB/s
      
      There may not be one optimal number for all boards. This is why
      the number is added to Kconfig. If selecting USB_GADGET_DEBUG_FILES
      this value may be set by a module parameter as well.
      Signed-off-by: NPer Forlin <per.forlin@linaro.org>
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      6532c7fd
    • A
      USB: gadget: storage: remove alignment assumption · 04eee25b
      Alan Stern 提交于
      This patch (as1481) fixes a problem affecting g_file_storage and
      g_mass_storage when running at SuperSpeed.  The two drivers currently
      assume that the bulk-out maxpacket size can evenly divide the SCSI
      block size, which is 512 bytes.  But SuperSpeed bulk endpoints have a
      maxpacket size of 1024, so the assumption is no longer true.
      
      This patch removes that assumption from the drivers, by getting rid of
      a small optimization (they try to align VFS reads and writes on page
      cache boundaries).  If a command's starting logical block address is
      512 bytes below the end of a page, it's not okay to issue a USB
      command for just those 512 bytes when the maxpacket size is 1024 -- it
      would result in either babble (for an OUT transfer) or a short packet
      (for an IN transfer).
      
      Also, for backward compatibility, the test for writes extending beyond
      the end of the backing storage has to be changed.  If the host tries
      to do this, we should accept the data that fits in the backing storage
      and ignore the rest.  Because the storage's end may not align with a
      USB packet boundary, this means we may have to accept a USB OUT
      transfer that extends beyond the end of the storage and then write out
      only the part of the data that fits.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      04eee25b
    • P
      usb: gadget: storage: adapt logic block size to bound block devices · 3f565a36
      Peiyu Li 提交于
      Now the mass storage driver has fixed logic block size of 512 bytes.
      
      The mass storage gadget read/write bound devices only through VFS, so the
      bottom level devices actually are just RAW devices to the driver and connected
      PC. As a RAW, hosts can always format, read and write it right in 512 bytes
      logic block and don't care about the actual logic block size of devices bound
      to the gadget.
      
      But if we want to share the bound block device partition between target board
      and PC, in case the logic block size of the bound block device is 4KB, we
      execute the following steps:
      
      1. connect a board with mass storage gadget to PC(the board has set one
      	partition of on-board block device as file name of the mass storage)
      2. PC format the mass storage to VFAT by default logic block size and
      	read/write it
      3. disconnect boards from PC
      4. target board mount the partition as VFAT
      
      Step 4 will fail since kernel on target thinks the logic block size of the
      bound partition as 4KB.
      A typical error is "FAT: logical sector size too small for device (logical
      sector size = 512)"
      
      If we execute opposite steps:
      1. format the partition to VFAT on target board and read/write this partition
      2. connect the board to Windows PC as usb mass storage gadget, windows will
      	think the disk is not formatted
      
      So the conclusion is that only as a gadget, the mass storage driver has no any
      problem.  But being shared VFAT or other filesystem on PC and target board, it
      will fail.
      
      This patch adapts logic block size to bound block devices and fix the issue.
      
      Cc: Michal Nazarewicz <mina86@mina86.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NPeiyu Li <peiyu.li@csr.com>
      Signed-off-by: NXianglong Du <xianglong.du@csr.com>
      Signed-off-by: NHuayi Li <huayi.li@csr.com>
      Signed-off-by: NBarry Song <Baohua.Song@csr.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      3f565a36
  12. 24 8月, 2011 1 次提交
    • K
      USB: use usb_endpoint_maxp() instead of le16_to_cpu() · 29cc8897
      Kuninori Morimoto 提交于
      Now ${LINUX}/drivers/usb/* can use usb_endpoint_maxp(desc) to get maximum packet size
      instead of le16_to_cpu(desc->wMaxPacketSize).
      This patch fix it up
      
      Cc: Armin Fuerst <fuerst@in.tum.de>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Johannes Erdfelt <johannes@erdfelt.com>
      Cc: Vojtech Pavlik <vojtech@suse.cz>
      Cc: Oliver Neukum <oliver@neukum.name>
      Cc: David Kubicek <dave@awk.cz>
      Cc: Johan Hovold <jhovold@gmail.com>
      Cc: Brad Hards <bhards@bigpond.net.au>
      Acked-by: NFelipe Balbi <balbi@ti.com>
      Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
      Cc: Thomas Dahlmann <dahlmann.thomas@arcor.de>
      Cc: David Brownell <david-b@pacbell.net>
      Cc: David Lopo <dlopo@chipidea.mips.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Michal Nazarewicz <m.nazarewicz@samsung.com>
      Cc: Xie Xiaobo <X.Xie@freescale.com>
      Cc: Li Yang <leoli@freescale.com>
      Cc: Jiang Bo <tanya.jiang@freescale.com>
      Cc: Yuan-hsin Chen <yhchen@faraday-tech.com>
      Cc: Darius Augulis <augulis.darius@gmail.com>
      Cc: Xiaochen Shen <xiaochen.shen@intel.com>
      Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Cc: OKI SEMICONDUCTOR, <toshiharu-linux@dsn.okisemi.com>
      Cc: Robert Jarzmik <robert.jarzmik@free.fr>
      Cc: Ben Dooks <ben@simtec.co.uk>
      Cc: Thomas Abraham <thomas.ab@samsung.com>
      Cc: Herbert Pötzl <herbert@13thfloor.at>
      Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
      Cc: Roman Weissgaerber <weissg@vienna.at>
      Acked-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: Tony Olech <tony.olech@elandigitalsystems.com>
      Cc: Florian Floe Echtler <echtler@fs.tum.de>
      Cc: Christian Lucht <lucht@codemercs.com>
      Cc: Juergen Stuber <starblue@sourceforge.net>
      Cc: Georges Toth <g.toth@e-biz.lu>
      Cc: Bill Ryder <bryder@sgi.com>
      Cc: Kuba Ober <kuba@mareimbrium.org>
      Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      29cc8897
  13. 02 7月, 2011 1 次提交
  14. 29 6月, 2011 1 次提交
  15. 16 6月, 2011 1 次提交
  16. 11 5月, 2011 1 次提交
  17. 15 4月, 2011 1 次提交
    • G
      Revert "usb: usb_storage: do not align length of request for CBW to maxp size" · 98346f7d
      Greg Kroah-Hartman 提交于
      This reverts commit 806e8f8f.
      
      To quote Alan Stern:
      	The necessity for this patch has been under discussion.
      
      	It turns out the UDC that Mian has been working on and Felipe's
      	UDC have contradictory requirements.  Mian's UDC driver wants a
      	bulk-OUT transfer length to be shorter than the maxpacket size
      	if a short packet is expected, whereas Felipe's UDC hardware
      	always needs bulk-OUT transfer lengths to be evenly divisible by
      	the maxpacket size.
      
      	Mian has agreed to go back over the driver to resolve this
      	conflict.  This means we probably will not want this patch after
      	all.  (In fact, we may ultimately decide to change the gadget
      	framework to require that bulk-OUT transfer lengths _always_ be
      	divisible by the maxpacket size -- only the g_file_storage and
      	g_mass_storage gadgets would need to be changed.)
      
      Cc: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
      Cc: Michal Nazarewicz <mina86@mina86.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      98346f7d
  18. 14 4月, 2011 2 次提交
  19. 11 11月, 2010 1 次提交
    • M
      USB: gadget: file_storage: put_device() in error recovery · d9385b63
      Michal Nazarewicz 提交于
      This commit fixes some issues with File-backed Storage Gadget
      error recovery when registering LUN's devices.
      
      First of all, when device_register() fails the device still
      needs to be put.  However, because lun_release() decreases
      fsg->ref reference counter the counter must be incremented
      beforehand.
      
      Second of all, after any of the device_create_file()s fails,
      device_unregister() is called which in turn (indirectly) calls
      lun_release() which decrements fsg->ref.  So, again, the
      reference counter must be incremented beforehand.
      
      Lastly, if the first or the second device_create_file()
      succeeds, the files are never removed.  To fix it,
      device_remove_file() needs to be called.  This is done by
      simply marking LUN as registered prior to creating files so
      that fsg_unbind() can handle removing files.
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Reported-by: NRahul Ruikar <rahul.ruikar@gmail.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d9385b63
  20. 23 10月, 2010 5 次提交
  21. 11 8月, 2010 4 次提交
  22. 04 3月, 2010 1 次提交
  23. 03 3月, 2010 1 次提交
  24. 12 12月, 2009 2 次提交