1. 14 10月, 2011 1 次提交
    • P
      usb: gadget: storage: fix mass storage gadgets to work with Synopsys UDC · fe696765
      Paul Zimmerman 提交于
      The Synopsys USB device controller requires all OUT transfer request
      lengths to be aligned to max packet size. The mass storage gadgets do
      not meet this requirement for Super Speed. The gadgets already have a
      function which performs this alignment for CBW packets, so use it for
      data packets too.
      
      The alternative would be to implement bounce buffers in the DWC3
      driver, but that could have a significant impact on performance.
      
      This version is based upon a more-correct patch written by Alan
      Stern.
      Signed-off-by: NPaul Zimmerman <paulz@synopsys.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      fe696765
  2. 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
  3. 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
  4. 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
  5. 02 7月, 2011 1 次提交
  6. 29 6月, 2011 1 次提交
  7. 16 6月, 2011 1 次提交
  8. 11 5月, 2011 1 次提交
  9. 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
  10. 14 4月, 2011 2 次提交
  11. 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
  12. 23 10月, 2010 5 次提交
  13. 11 8月, 2010 4 次提交
  14. 04 3月, 2010 1 次提交
  15. 03 3月, 2010 1 次提交
  16. 12 12月, 2009 5 次提交
  17. 10 12月, 2009 1 次提交
    • C
      vfs: Implement proper O_SYNC semantics · 6b2f3d1f
      Christoph Hellwig 提交于
      While Linux provided an O_SYNC flag basically since day 1, it took until
      Linux 2.4.0-test12pre2 to actually get it implemented for filesystems,
      since that day we had generic_osync_around with only minor changes and the
      great "For now, when the user asks for O_SYNC, we'll actually give
      O_DSYNC" comment.  This patch intends to actually give us real O_SYNC
      semantics in addition to the O_DSYNC semantics.  After Jan's O_SYNC
      patches which are required before this patch it's actually surprisingly
      simple, we just need to figure out when to set the datasync flag to
      vfs_fsync_range and when not.
      
      This patch renames the existing O_SYNC flag to O_DSYNC while keeping it's
      numerical value to keep binary compatibility, and adds a new real O_SYNC
      flag.  To guarantee backwards compatiblity it is defined as expanding to
      both the O_DSYNC and the new additional binary flag (__O_SYNC) to make
      sure we are backwards-compatible when compiled against the new headers.
      
      This also means that all places that don't care about the differences can
      just check O_DSYNC and get the right behaviour for O_SYNC, too - only
      places that actuall care need to check __O_SYNC in addition.  Drivers and
      network filesystems have been updated in a fail safe way to always do the
      full sync magic if O_DSYNC is set.  The few places setting O_SYNC for
      lower layers are kept that way for now to stay failsafe.
      
      We enforce that O_DSYNC is set when __O_SYNC is set early in the open path
      to make sure we always get these sane options.
      
      Note that parisc really screwed up their headers as they already define a
      O_DSYNC that has always been a no-op.  We try to repair it by using it for
      the new O_DSYNC and redefinining O_SYNC to send both the traditional
      O_SYNC numerical value _and_ the O_DSYNC one.
      
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Grant Grundler <grundler@parisc-linux.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Andreas Dilger <adilger@sun.com>
      Acked-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      Acked-by: NKyle McMartin <kyle@mcmartin.ca>
      Acked-by: NUlrich Drepper <drepper@redhat.com>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NJan Kara <jack@suse.cz>
      6b2f3d1f
  18. 16 6月, 2009 1 次提交
  19. 24 4月, 2009 1 次提交
    • A
      USB: g_file_storage: fix use-after-free bug when closing files · 82a10a81
      Alan Stern 提交于
      This patch (as1231) fixes a use-after-free bug in g_file_storage.  A
      device's name may not be available after the device is unregistered,
      even if the device structure itself is still allocated.  Since
      close_backing_file() prints a LUN's name for debugging, it shouldn't
      be called after the LUN has been unregistered.
      
      That whole area needed to be cleaned up; the backing files were
      getting closed in a couple of different places.  The patch fixes
      things so that they get closed in just one place, as part of the
      unbind procedure, immediately before the LUN is unregistered.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      82a10a81
  20. 25 3月, 2009 1 次提交
  21. 16 3月, 2009 1 次提交
    • J
      Use f_lock to protect f_flags · db1dd4d3
      Jonathan Corbet 提交于
      Traditionally, changes to struct file->f_flags have been done under BKL
      protection, or with no protection at all.  This patch causes all f_flags
      changes after file open/creation time to be done under protection of
      f_lock.  This allows the removal of some BKL usage and fixes a number of
      longstanding (if microscopic) races.
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Al Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: NJonathan Corbet <corbet@lwn.net>
      db1dd4d3
  22. 28 2月, 2009 1 次提交
  23. 08 1月, 2009 2 次提交
  24. 06 1月, 2009 1 次提交
    • C
      add a vfs_fsync helper · 4c728ef5
      Christoph Hellwig 提交于
      Fsync currently has a fdatawrite/fdatawait pair around the method call,
      and a mutex_lock/unlock of the inode mutex.  All callers of fsync have
      to duplicate this, but we have a few and most of them don't quite get
      it right.  This patch adds a new vfs_fsync that takes care of this.
      It's a little more complicated as usual as ->fsync might get a NULL file
      pointer and just a dentry from nfsd, but otherwise gets afile and we
      want to take the mapping and file operations from it when it is there.
      
      Notes on the fsync callers:
      
       - ecryptfs wasn't calling filemap_fdatawrite / filemap_fdatawait on the
         	lower file
       - coda wasn't calling filemap_fdatawrite / filemap_fdatawait on the host
      	file, and returning 0 when ->fsync was missing
       - shm wasn't calling either filemap_fdatawrite / filemap_fdatawait nor
         taking i_mutex.  Now given that shared memory doesn't have disk
         backing not doing anything in fsync seems fine and I left it out of
         the vfs_fsync conversion for now, but in that case we might just
         not pass it through to the lower file at all but just call the no-op
         simple_sync_file directly.
      
      [and now actually export vfs_fsync]
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      4c728ef5
  25. 18 10月, 2008 1 次提交