1. 17 7月, 2007 12 次提交
    • S
      introduce write_trylock_irqsave() · e1f4a88c
      Satyam Sharma 提交于
      Introduce a write_trylock_irqsave() implementation.  Similar in style to
      the implementation of spin_trylock_irqsave() in mainline.
      Signed-off-by: NSatyam Sharma <ssatyam@cse.iitk.ac.in>
      Cc: Sripathi Kodi <sripathik@in.ibm.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e1f4a88c
    • A
      Fix rmmod/read/write races in /proc entries · 786d7e16
      Alexey Dobriyan 提交于
      Fix following races:
      ===========================================
      1. Write via ->write_proc sleeps in copy_from_user(). Module disappears
         meanwhile. Or, more generically, system call done on /proc file, method
         supplied by module is called, module dissapeares meanwhile.
      
         pde = create_proc_entry()
         if (!pde)
      	return -ENOMEM;
         pde->write_proc = ...
      				open
      				write
      				copy_from_user
         pde = create_proc_entry();
         if (!pde) {
      	remove_proc_entry();
      	return -ENOMEM;
      	/* module unloaded */
         }
      				*boom*
      ==========================================
      2. bogo-revoke aka proc_kill_inodes()
      
        remove_proc_entry		vfs_read
        proc_kill_inodes		[check ->f_op validness]
      				[check ->f_op->read validness]
      				[verify_area, security permissions checks]
      	->f_op = NULL;
      				if (file->f_op->read)
      					/* ->f_op dereference, boom */
      
      NOTE, NOTE, NOTE: file_operations are proxied for regular files only. Let's
      see how this scheme behaves, then extend if needed for directories.
      Directories creators in /proc only set ->owner for them, so proxying for
      directories may be unneeded.
      
      NOTE, NOTE, NOTE: methods being proxied are ->llseek, ->read, ->write,
      ->poll, ->unlocked_ioctl, ->ioctl, ->compat_ioctl, ->open, ->release.
      If your in-tree module uses something else, yell on me. Full audit pending.
      
      [akpm@linux-foundation.org: build fix]
      Signed-off-by: NAlexey Dobriyan <adobriyan@sw.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      786d7e16
    • M
      split mmap · 0165ab44
      Miklos Szeredi 提交于
      This is a straightforward split of do_mmap_pgoff() into two functions:
      
       - do_mmap_pgoff() checks the parameters, and calculates the vma
         flags.  Then it calls
      
       - mmap_region(), which does the actual mapping
      Signed-off-by: NMiklos Szeredi <mszeredi@suse.cz>
      Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0165ab44
    • P
      slob: initial NUMA support · 6193a2ff
      Paul Mundt 提交于
      This adds preliminary NUMA support to SLOB, primarily aimed at systems with
      small nodes (tested all the way down to a 128kB SRAM block), whether
      asymmetric or otherwise.
      
      We follow the same conventions as SLAB/SLUB, preferring current node
      placement for new pages, or with explicit placement, if a node has been
      specified.  Presently on UP NUMA this has the side-effect of preferring
      node#0 allocations (since numa_node_id() == 0, though this could be
      reworked if we could hand off a pfn to determine node placement), so
      single-CPU NUMA systems will want to place smaller nodes further out in
      terms of node id.  Once a page has been bound to a node (via explicit node
      id typing), we only do block allocations from partial free pages that have
      a matching node id in the page flags.
      
      The current implementation does have some scalability problems, in that all
      partial free pages are tracked in the global freelist (with contention due
      to the single spinlock).  However, these are things that are being reworked
      for SMP scalability first, while things like per-node freelists can easily
      be built on top of this sort of functionality once it's been added.
      
      More background can be found in:
      
      	http://marc.info/?l=linux-mm&m=118117916022379&w=2
      	http://marc.info/?l=linux-mm&m=118170446306199&w=2
      	http://marc.info/?l=linux-mm&m=118187859420048&w=2
      
      and subsequent threads.
      Acked-by: NChristoph Lameter <clameter@sgi.com>
      Acked-by: NMatt Mackall <mpm@selenic.com>
      Signed-off-by: NPaul Mundt <lethal@linux-sh.org>
      Acked-by: NNick Piggin <nickpiggin@yahoo.com.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6193a2ff
    • J
      kill vmalloc_earlyreserve · 8f0accc8
      Jan Beulich 提交于
      This symbol got orphaned quite a while ago.
      Signed-off-by: NJan Beulich <jbeulich@novell.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8f0accc8
    • A
      invalidate_mapping_pages(): add cond_resched · fc9a07e7
      Andrew Morton 提交于
      invalidate_mapping_pages() can sometimes take a long time (millions of pages
      to free).  Long enough for the softlockup detector to trigger.
      
      We used to have a cond_resched() in there but I took it out because the
      drop_caches code calls invalidate_mapping_pages() under inode_lock.
      
      The patch adds a nasty flag and puts the cond_resched() back.
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fc9a07e7
    • R
      Remove the deprecated "kmem_cache_t" typedef from slab.h. · 698827fa
      Robert P. J. Day 提交于
      Given that there is no remaining usage of the deprecated kmem_cache_t
      typedef anywhere in the tree, remove that typedef.
      Signed-off-by: NRobert P. J. Day <rpjday@mindspring.com>
      Acked-by: NPekka Enberg <penberg@cs.helsinki.fi>
      Acked-by: NChristoph Lameter <clameter@sgi.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      698827fa
    • K
      change zonelist order: zonelist order selection logic · f0c0b2b8
      KAMEZAWA Hiroyuki 提交于
      Make zonelist creation policy selectable from sysctl/boot option v6.
      
      This patch makes NUMA's zonelist (of pgdat) order selectable.
      Available order are Default(automatic)/ Node-based / Zone-based.
      
      [Default Order]
      The kernel selects Node-based or Zone-based order automatically.
      
      [Node-based Order]
      This policy treats the locality of memory as the most important parameter.
      Zonelist order is created by each zone's locality. This means lower zones
      (ex. ZONE_DMA) can be used before higher zone (ex. ZONE_NORMAL) exhausion.
      IOW. ZONE_DMA will be in the middle of zonelist.
      current 2.6.21 kernel uses this.
      
      Pros.
       * A user can expect local memory as much as possible.
      Cons.
       * lower zone will be exhansted before higher zone. This may cause OOM_KILL.
      
      Maybe suitable if ZONE_DMA is relatively big and you never see OOM_KILL
      because of ZONE_DMA exhaution and you need the best locality.
      
      (example)
      assume 2 node NUMA. node(0) has ZONE_DMA/ZONE_NORMAL, node(1) has ZONE_NORMAL.
      
      *node(0)'s memory allocation order:
      
       node(0)'s NORMAL -> node(0)'s DMA -> node(1)'s NORMAL.
      
      *node(1)'s memory allocation order:
      
       node(1)'s NORMAL -> node(0)'s NORMAL -> node(0)'s DMA.
      
      [Zone-based order]
      This policy treats the zone type as the most important parameter.
      Zonelist order is created by zone-type order. This means lower zone
      never be used bofere higher zone exhaustion.
      IOW. ZONE_DMA will be always at the tail of zonelist.
      
      Pros.
       * OOM_KILL(bacause of lower zone) occurs only if the whole zones are exhausted.
      Cons.
       * memory locality may not be best.
      
      (example)
      assume 2 node NUMA. node(0) has ZONE_DMA/ZONE_NORMAL, node(1) has ZONE_NORMAL.
      
      *node(0)'s memory allocation order:
      
       node(0)'s NORMAL -> node(1)'s NORMAL -> node(0)'s DMA.
      
      *node(1)'s memory allocation order:
      
       node(1)'s NORMAL -> node(0)'s NORMAL -> node(0)'s DMA.
      
      bootoption "numa_zonelist_order=" and proc/sysctl is supporetd.
      
      command:
      %echo N > /proc/sys/vm/numa_zonelist_order
      
      Will rebuild zonelist in Node-based order.
      
      command:
      %echo Z > /proc/sys/vm/numa_zonelist_order
      
      Will rebuild zonelist in Zone-based order.
      
      Thanks to Lee Schermerhorn, he gives me much help and codes.
      
      [Lee.Schermerhorn@hp.com: add check_highest_zone to build_zonelists_in_zone_order]
      [akpm@linux-foundation.org: build fix]
      Signed-off-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Lee Schermerhorn <lee.schermerhorn@hp.com>
      Cc: Christoph Lameter <clameter@sgi.com>
      Cc: Andi Kleen <ak@suse.de>
      Cc: "jesse.barnes@intel.com" <jesse.barnes@intel.com>
      Signed-off-by: NLee Schermerhorn <lee.schermerhorn@hp.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f0c0b2b8
    • Y
      serial: convert early_uart to earlycon for 8250 · 18a8bd94
      Yinghai Lu 提交于
      Beacuse SERIAL_PORT_DFNS is removed from include/asm-i386/serial.h and
      include/asm-x86_64/serial.h.  the serial8250_ports need to be probed late in
      serial initializing stage.  the console_init=>serial8250_console_init=>
      register_console=>serial8250_console_setup will return -ENDEV, and console
      ttyS0 can not be enabled at that time.  need to wait till uart_add_one_port in
      drivers/serial/serial_core.c to call register_console to get console ttyS0.
      that is too late.
      
      Make early_uart to use early_param, so uart console can be used earlier.  Make
      it to be bootconsole with CON_BOOT flag, so can use console handover feature.
      and it will switch to corresponding normal serial console automatically.
      
      new command line will be:
      	console=uart8250,io,0x3f8,9600n8
      	console=uart8250,mmio,0xff5e0000,115200n8
      or
      	earlycon=uart8250,io,0x3f8,9600n8
      	earlycon=uart8250,mmio,0xff5e0000,115200n8
      
      it will print in very early stage:
      	Early serial console at I/O port 0x3f8 (options '9600n8')
      	console [uart0] enabled
      later for console it will print:
      	console handover: boot [uart0] -> real [ttyS0]
      
      Signed-off-by: <yinghai.lu@sun.com>
      Cc: Andi Kleen <ak@suse.de>
      Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
      Cc: Russell King <rmk@arm.linux.org.uk>
      Cc: Gerd Hoffmann <kraxel@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      18a8bd94
    • K
      lib: add idr_remove_all · 23936cc0
      Kristian Hoegsberg 提交于
      Remove all ids from the given idr tree.  idr_destroy() only frees up
      unused, cached idp_layers, but this function will remove all id mappings
      and leave all idp_layers unused.
      
      A typical clean-up sequence for objects stored in an idr tree, will use
      idr_for_each() to free all objects, if necessay, then idr_remove_all() to
      remove all ids, and idr_destroy() to free up the cached idr_layers.
      Signed-off-by: NKristian Hoegsberg <krh@redhat.com>
      Cc: Tejun Heo <htejun@gmail.com>
      Cc: Dave Airlie <airlied@linux.ie>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      23936cc0
    • K
      lib: add idr_for_each() · 96d7fa42
      Kristian Hoegsberg 提交于
      This patch adds an iterator function for the idr data structure.  Compared
      to just iterating through the idr with an integer and idr_find, this
      iterator is (almost, but not quite) linear in the number of elements, as
      opposed to the number of integers in the range covered by the idr.  This
      makes a difference for sparse idrs, but more importantly, it's a nicer way
      to iterate through the elements.
      
      The drm subsystem is moving to idr for tracking contexts and drawables, and
      with this change, we can use the idr exclusively for tracking these
      resources.
      
      [akpm@linux-foundation.org: fix comment]
      Signed-off-by: NKristian Hoegsberg <krh@redhat.com>
      Cc: Tejun Heo <htejun@gmail.com>
      Cc: Dave Airlie <airlied@linux.ie>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      96d7fa42
    • N
      LZO1X: fix lzo1x_worst_compress · f2a11b15
      Nitin Gupta 提交于
      This is a correction for a macro which gives worst case compressed data
      size by LZO1X.
      
      This patch was provided by the LZO author (Markus Oberhumer).
      Signed-off-by: NNitin Gupta <nitingupta910@gmail.com>
      Cc: "Markus F.X.J. Oberhumer" <markus@oberhumer.com>
      Cc: "Richard Purdie" <rpurdie@openedhand.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f2a11b15
  2. 16 7月, 2007 1 次提交
  3. 15 7月, 2007 7 次提交
  4. 14 7月, 2007 1 次提交
  5. 13 7月, 2007 19 次提交
    • D
      ioatdma: add the unisys "i/oat" pci vendor/device id · 3039f073
      Dan Williams 提交于
      Cc: John Magolan <john.magolan@unisys.com>
      Signed-off-by: NShannon Nelson <shannon.nelson@intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      3039f073
    • D
      md: handle_stripe5 - add request/completion logic for async read ops · b5e98d65
      Dan Williams 提交于
      When a read bio is attached to the stripe and the corresponding block is
      marked R5_UPTODATE, then a read (biofill) operation is scheduled to copy
      the data from the stripe cache to the bio buffer.  handle_stripe flags the
      blocks to be operated on with the R5_Wantfill flag.  If new read requests
      arrive while raid5_run_ops is running they will not be handled until
      handle_stripe is scheduled to run again.
      
      Changelog:
      * cleanup to_read and to_fill accounting
      * do not fail reads that have reached the cache
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-By: NNeilBrown <neilb@suse.de>
      b5e98d65
    • D
      md: handle_stripe5 - add request/completion logic for async compute ops · f38e1219
      Dan Williams 提交于
      handle_stripe will compute a block when a backing disk has failed, or when
      it determines it can save a disk read by computing the block from all the
      other up-to-date blocks.
      
      Previously a block would be computed under the lock and subsequent logic in
      handle_stripe could use the newly up-to-date block.  With the raid5_run_ops
      implementation the compute operation is carried out a later time outside
      the lock.  To preserve the old functionality we take advantage of the
      dependency chain feature of async_tx to flag the block as R5_Wantcompute
      and then let other parts of handle_stripe operate on the block as if it
      were up-to-date.  raid5_run_ops guarantees that the block will be ready
      before it is used in another operation.
      
      However, this only works in cases where the compute and the dependent
      operation are scheduled at the same time.  If a previous call to
      handle_stripe sets the R5_Wantcompute flag there is no facility to pass the
      async_tx dependency chain across successive calls to raid5_run_ops.  The
      req_compute variable protects against this case.
      
      Changelog:
      * remove the req_compute BUG_ON
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-By: NNeilBrown <neilb@suse.de>
      f38e1219
    • D
      md: raid5_run_ops - run stripe operations outside sh->lock · 91c00924
      Dan Williams 提交于
      When the raid acceleration work was proposed, Neil laid out the following
      attack plan:
      
      1/ move the xor and copy operations outside spin_lock(&sh->lock)
      2/ find/implement an asynchronous offload api
      
      The raid5_run_ops routine uses the asynchronous offload api (async_tx) and
      the stripe_operations member of a stripe_head to carry out xor+copy
      operations asynchronously, outside the lock.
      
      To perform operations outside the lock a new set of state flags is needed
      to track new requests, in-flight requests, and completed requests.  In this
      new model handle_stripe is tasked with scanning the stripe_head for work,
      updating the stripe_operations structure, and finally dropping the lock and
      calling raid5_run_ops for processing.  The following flags outline the
      requests that handle_stripe can make of raid5_run_ops:
      
      STRIPE_OP_BIOFILL
       - copy data into request buffers to satisfy a read request
      STRIPE_OP_COMPUTE_BLK
       - generate a missing block in the cache from the other blocks
      STRIPE_OP_PREXOR
       - subtract existing data as part of the read-modify-write process
      STRIPE_OP_BIODRAIN
       - copy data out of request buffers to satisfy a write request
      STRIPE_OP_POSTXOR
       - recalculate parity for new data that has entered the cache
      STRIPE_OP_CHECK
       - verify that the parity is correct
      STRIPE_OP_IO
       - submit i/o to the member disks (note this was already performed outside
         the stripe lock, but it made sense to add it as an operation type
      
      The flow is:
      1/ handle_stripe sets STRIPE_OP_* in sh->ops.pending
      2/ raid5_run_ops reads sh->ops.pending, sets sh->ops.ack, and submits the
         operation to the async_tx api
      3/ async_tx triggers the completion callback routine to set
         sh->ops.complete and release the stripe
      4/ handle_stripe runs again to finish the operation and optionally submit
         new operations that were previously blocked
      
      Note this patch just defines raid5_run_ops, subsequent commits (one per
      major operation type) modify handle_stripe to take advantage of this
      routine.
      
      Changelog:
      * removed ops_complete_biodrain in favor of ops_complete_postxor and
        ops_complete_write.
      * removed the raid5_run_ops workqueue
      * call bi_end_io for reads in ops_complete_biofill, saves a call to
        handle_stripe
      * explicitly handle the 2-disk raid5 case (xor becomes memcpy), Neil Brown
      * fix race between async engines and bi_end_io call for reads, Neil Brown
      * remove unnecessary spin_lock from ops_complete_biofill
      * remove test_and_set/test_and_clear BUG_ONs, Neil Brown
      * remove explicit interrupt handling for channel switching, this feature
        was absorbed (i.e. it is now implicit) by the async_tx api
      * use return_io in ops_complete_biofill
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-By: NNeilBrown <neilb@suse.de>
      91c00924
    • D
      raid5: refactor handle_stripe5 and handle_stripe6 (v3) · a4456856
      Dan Williams 提交于
      handle_stripe5 and handle_stripe6 have very deep logic paths handling the
      various states of a stripe_head.  By introducing the 'stripe_head_state'
      and 'r6_state' objects, large portions of the logic can be moved to
      sub-routines.
      
      'struct stripe_head_state' consumes all of the automatic variables that previously
      stood alone in handle_stripe5,6.  'struct r6_state' contains the handle_stripe6
      specific variables like p_failed and q_failed.
      
      One of the nice side effects of the 'stripe_head_state' change is that it
      allows for further reductions in code duplication between raid5 and raid6.
      The following new routines are shared between raid5 and raid6:
      
      	handle_completed_write_requests
      	handle_requests_to_failed_array
      	handle_stripe_expansion
      
      Changes:
      * v2: fixed 'conf->raid_disk-1' for the raid6 'handle_stripe_expansion' path
      * v3: removed the unused 'dirty' field from struct stripe_head_state
      * v3: coalesced open coded bi_end_io routines into return_io()
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-By: NNeilBrown <neilb@suse.de>
      a4456856
    • D
      async_tx: add the async_tx api · 9bc89cd8
      Dan Williams 提交于
      The async_tx api provides methods for describing a chain of asynchronous
      bulk memory transfers/transforms with support for inter-transactional
      dependencies.  It is implemented as a dmaengine client that smooths over
      the details of different hardware offload engine implementations.  Code
      that is written to the api can optimize for asynchronous operation and the
      api will fit the chain of operations to the available offload resources. 
       
      	I imagine that any piece of ADMA hardware would register with the
      	'async_*' subsystem, and a call to async_X would be routed as
      	appropriate, or be run in-line. - Neil Brown
      
      async_tx exploits the capabilities of struct dma_async_tx_descriptor to
      provide an api of the following general format:
      
      struct dma_async_tx_descriptor *
      async_<operation>(..., struct dma_async_tx_descriptor *depend_tx,
      			dma_async_tx_callback cb_fn, void *cb_param)
      {
      	struct dma_chan *chan = async_tx_find_channel(depend_tx, <operation>);
      	struct dma_device *device = chan ? chan->device : NULL;
      	int int_en = cb_fn ? 1 : 0;
      	struct dma_async_tx_descriptor *tx = device ?
      		device->device_prep_dma_<operation>(chan, len, int_en) : NULL;
      
      	if (tx) { /* run <operation> asynchronously */
      		...
      		tx->tx_set_dest(addr, tx, index);
      		...
      		tx->tx_set_src(addr, tx, index);
      		...
      		async_tx_submit(chan, tx, flags, depend_tx, cb_fn, cb_param);
      	} else { /* run <operation> synchronously */
      		...
      		<operation>
      		...
      		async_tx_sync_epilog(flags, depend_tx, cb_fn, cb_param);
      	}
      
      	return tx;
      }
      
      async_tx_find_channel() returns a capable channel from its pool.  The
      channel pool is organized as a per-cpu array of channel pointers.  The
      async_tx_rebalance() routine is tasked with managing these arrays.  In the
      uniprocessor case async_tx_rebalance() tries to spread responsibility
      evenly over channels of similar capabilities.  For example if there are two
      copy+xor channels, one will handle copy operations and the other will
      handle xor.  In the SMP case async_tx_rebalance() attempts to spread the
      operations evenly over the cpus, e.g. cpu0 gets copy channel0 and xor
      channel0 while cpu1 gets copy channel 1 and xor channel 1.  When a
      dependency is specified async_tx_find_channel defaults to keeping the
      operation on the same channel.  A xor->copy->xor chain will stay on one
      channel if it supports both operation types, otherwise the transaction will
      transition between a copy and a xor resource.
      
      Currently the raid5 implementation in the MD raid456 driver has been
      converted to the async_tx api.  A driver for the offload engines on the
      Intel Xscale series of I/O processors, iop-adma, is provided in a later
      commit.  With the iop-adma driver and async_tx, raid456 is able to offload
      copy, xor, and xor-zero-sum operations to hardware engines.
       
      On iop342 tiobench showed higher throughput for sequential writes (20 - 30%
      improvement) and sequential reads to a degraded array (40 - 55%
      improvement).  For the other cases performance was roughly equal, +/- a few
      percentage points.  On a x86-smp platform the performance of the async_tx
      implementation (in synchronous mode) was also +/- a few percentage points
      of the original implementation.  According to 'top' on iop342 CPU
      utilization drops from ~50% to ~15% during a 'resync' while the speed
      according to /proc/mdstat doubles from ~25 MB/s to ~50 MB/s.
       
      The tiobench command line used for testing was: tiobench --size 2048
      --block 4096 --block 131072 --dir /mnt/raid --numruns 5
      * iop342 had 1GB of memory available
      
      Details:
      * if CONFIG_DMA_ENGINE=n the asynchronous path is compiled away by making
        async_tx_find_channel a static inline routine that always returns NULL
      * when a callback is specified for a given transaction an interrupt will
        fire at operation completion time and the callback will occur in a
        tasklet.  if the the channel does not support interrupts then a live
        polling wait will be performed
      * the api is written as a dmaengine client that requests all available
        channels
      * In support of dependencies the api implicitly schedules channel-switch
        interrupts.  The interrupt triggers the cleanup tasklet which causes
        pending operations to be scheduled on the next channel
      * Xor engines treat an xor destination address differently than a software
        xor routine.  To the software routine the destination address is an implied
        source, whereas engines treat it as a write-only destination.  This patch
        modifies the xor_blocks routine to take a an explicit destination address
        to mirror the hardware.
      
      Changelog:
      * fixed a leftover debug print
      * don't allow callbacks in async_interrupt_cond
      * fixed xor_block changes
      * fixed usage of ASYNC_TX_XOR_DROP_DEST
      * drop dma mapping methods, suggested by Chris Leech
      * printk warning fixups from Andrew Morton
      * don't use inline in C files, Adrian Bunk
      * select the API when MD is enabled
      * BUG_ON xor source counts <= 1
      * implicitly handle hardware concerns like channel switching and
        interrupts, Neil Brown
      * remove the per operation type list, and distribute operation capabilities
        evenly amongst the available channels
      * simplify async_tx_find_channel to optimize the fast path
      * introduce the channel_table_initialized flag to prevent early calls to
        the api
      * reorganize the code to mimic crypto
      * include mm.h as not all archs include it in dma-mapping.h
      * make the Kconfig options non-user visible, Adrian Bunk
      * move async_tx under crypto since it is meant as 'core' functionality, and
        the two may share algorithms in the future
      * move large inline functions into c files
      * checkpatch.pl fixes
      * gpl v2 only correction
      
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-By: NNeilBrown <neilb@suse.de>
      9bc89cd8
    • D
      xor: make 'xor_blocks' a library routine for use with async_tx · 685784aa
      Dan Williams 提交于
      The async_tx api tries to use a dma engine for an operation, but will fall
      back to an optimized software routine otherwise.  Xor support is
      implemented using the raid5 xor routines.  For organizational purposes this
      routine is moved to a common area.
      
      The following fixes are also made:
      * rename xor_block => xor_blocks, suggested by Adrian Bunk
      * ensure that xor.o initializes before md.o in the built-in case
      * checkpatch.pl fixes
      * mark calibrate_xor_blocks __init, Adrian Bunk
      
      Cc: Adrian Bunk <bunk@stusta.de>
      Cc: NeilBrown <neilb@suse.de>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      685784aa
    • D
      dmaengine: make clients responsible for managing channels · d379b01e
      Dan Williams 提交于
      The current implementation assumes that a channel will only be used by one
      client at a time.  In order to enable channel sharing the dmaengine core is
      changed to a model where clients subscribe to channel-available-events.
      Instead of tracking how many channels a client wants and how many it has
      received the core just broadcasts the available channels and lets the
      clients optionally take a reference.  The core learns about the clients'
      needs at dma_event_callback time.
      
      In support of multiple operation types, clients can specify a capability
      mask to only be notified of channels that satisfy a certain set of
      capabilities.
      
      Changelog:
      * removed DMA_TX_ARRAY_INIT, no longer needed
      * dma_client_chan_free -> dma_chan_release: switch to global reference
        counting only at device unregistration time, before it was also happening
        at client unregistration time
      * clients now return dma_state_client to dmaengine (ack, dup, nak)
      * checkpatch.pl fixes
      * fixup merge with git-ioat
      
      Cc: Chris Leech <christopher.leech@intel.com>
      Signed-off-by: NShannon Nelson <shannon.nelson@intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      d379b01e
    • D
      dmaengine: refactor dmaengine around dma_async_tx_descriptor · 7405f74b
      Dan Williams 提交于
      The current dmaengine interface defines mutliple routines per operation,
      i.e. dma_async_memcpy_buf_to_buf, dma_async_memcpy_buf_to_page etc.  Adding
      more operation types (xor, crc, etc) to this model would result in an
      unmanageable number of method permutations.
      
      	Are we really going to add a set of hooks for each DMA engine
      	whizbang feature?
      		- Jeff Garzik
      
      The descriptor creation process is refactored using the new common
      dma_async_tx_descriptor structure.  Instead of per driver
      do_<operation>_<dest>_to_<src> methods, drivers integrate
      dma_async_tx_descriptor into their private software descriptor and then
      define a 'prep' routine per operation.  The prep routine allocates a
      descriptor and ensures that the tx_set_src, tx_set_dest, tx_submit routines
      are valid.  Descriptor creation and submission becomes:
      
      struct dma_device *dev;
      struct dma_chan *chan;
      struct dma_async_tx_descriptor *tx;
      
      tx = dev->device_prep_dma_<operation>(chan, len, int_flag)
      tx->tx_set_src(dma_addr_t, tx, index /* for multi-source ops */)
      tx->tx_set_dest(dma_addr_t, tx, index)
      tx->tx_submit(tx)
      
      In addition to the refactoring, dma_async_tx_descriptor also lays the
      groundwork for definining cross-channel-operation dependencies, and a
      callback facility for asynchronous notification of operation completion.
      
      Changelog:
      * drop dma mapping methods, suggested by Chris Leech
      * fix ioat_dma_dependency_added, also caught by Andrew Morton
      * fix dma_sync_wait, change from Andrew Morton
      * uninline large functions, change from Andrew Morton
      * add tx->callback = NULL to dmaengine calls to interoperate with async_tx
        calls
      * hookup ioat_tx_submit
      * convert channel capabilities to a 'cpumask_t like' bitmap
      * removed DMA_TX_ARRAY_INIT, no longer needed
      * checkpatch.pl fixes
      * make set_src, set_dest, and tx_submit descriptor specific methods
      * fixup git-ioat merge
      * move group_list and phys to dma_async_tx_descriptor
      
      Cc: Jeff Garzik <jeff@garzik.org>
      Cc: Chris Leech <christopher.leech@intel.com>
      Signed-off-by: NShannon Nelson <shannon.nelson@intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      7405f74b
    • D
      usb gadget stack: remove usb_ep_*_buffer(), part 2 · c67ab134
      David Brownell 提交于
      This patch removes controller driver infrastructure which supported
      the now-removed usb_ep_{alloc,free}_buffer() calls.
      
      As can be seen, many of the implementations of this were broken to
      various degrees.  Many didn't properly return dma-coherent mappings;
      those which did so were necessarily ugly because of bogosity in the
      underlying dma_free_coherent() calls ... which on many platforms
      can't be called from the same contexts (notably in_irq) from which
      their dma_alloc_coherent() sibling can be called.
      
      The main potential downside of removing this is that gadget drivers
      wouldn't have specific knowledge that the controller drivers have:
      endpoints that aren't dma-capable don't need any dma mappings at all.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      c67ab134
    • D
      usb gadget stack: remove usb_ep_*_buffer(), part 1 · 9d8bab58
      David Brownell 提交于
      Remove usb_ep_{alloc,free}_buffer() calls, for small dma-coherent buffers.
      This patch just removes the interface and its users; later patches will
      remove controller driver support.
      
        - This interface is invariably not implemented correctly in the
          controller drivers (e.g. using dma pools, a mechanism which
          post-dates the interface by several years).
      
        - At this point no gadget driver really *needs* to use it.  In
          current kernels, any driver that needs such a mechanism could
          allocate a dma pool themselves.
      
      Removing this interface is thus a simplification and improvement.
      
      Note that the gmidi.c driver had a bug in this area; fixed.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9d8bab58
    • C
      USB: add IAD support to usbfs and sysfs · 165fe97e
      Craig W. Nadler 提交于
      USB_IAD: Adds support for USB Interface Association Descriptors.
      
      This patch adds support to the USB host stack for parsing, storing, and
      displaying Interface Association Descriptors. In /proc/bus/usb/devices
      lines starting with A: show the fields in an IAD. In sysfs if an
      interface on a USB device is referenced by an IAD the following files
      will be added to the sysfs directory for that interface:
      iad_bFirstInterface, iad_bInterfaceCount, iad_bFunctionClass, and
      iad_bFunctionSubClass, iad_bFunctionProtocol
      Signed-off-by: NCraig W. Nadler <craig@nadler.us>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      165fe97e
    • M
      USB: Add URB_FREE_BUFFER flag and the logic behind it · 8b3b01c8
      Marcel Holtmann 提交于
      USB: Add URB_FREE_BUFFER flag for freeing the transfer buffer
      
      In some cases it is not needed that the driver keeps track of the
      transfer buffer of an URB. It can be simply freed along with the
      URB itself when the reference count goes down to zero. The new
      flag URB_FREE_BUFFER enables this behavior.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      8b3b01c8
    • A
      USB: add power/persist device attribute · b41a60ec
      Alan Stern 提交于
      This patch (as920) adds an extra level of protection to the
      USB-Persist facility.  Now it will apply by default only to hubs; for
      all other devices the user must enable it explicitly by setting the
      power/persist device attribute.
      
      The disconnect_all_children() routine in hub.c has been removed and
      its code placed inline.  This is the way it was originally as part of
      hub_pre_reset(); the revised usage in hub_reset_resume() is
      sufficiently different that the code can no longer be shared.
      Likewise, mark_children_for_reset() is now inline as part of
      hub_reset_resume().  The end result looks much cleaner than before.
      
      The sysfs interface is updated to add the new attribute file, and
      there are corresponding documentation updates.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b41a60ec
    • A
      USB: add reset_resume method · f07600cf
      Alan Stern 提交于
      This patch (as918) introduces a new USB driver method: reset_resume.
      It is called when a device needs to be reset as part of a resume
      procedure (whether because of a device quirk or because of the
      USB-Persist facility), thereby taking over a role formerly assigned to
      the post_reset method.  As a consequence, post_reset no longer needs
      an argument indicating whether it is being called as part of a
      reset-resume.  This separation of functions makes the code clearer.
      
      In addition, the pre_reset and post_reset method return types are
      changed; they now must return an error code.  The return value is
      unused at present, but at some later time we may unbind drivers and
      re-probe if they encounter an error during reset handling.
      
      The existing pre_reset and post_reset methods in the usbhid,
      usb-storage, and hub drivers are updated to match the new
      requirements.  For usbhid the post_reset routine is also used for
      reset_resume (duplicate method pointers); for the other drivers a new
      reset_resume routine is added.  The change to hub.c looks bigger than
      it really is, because mark_children_for_reset_resume() gets moved down
      next to the new hub_reset_resume() routine.
      
      A minor change to usb-storage makes the usb_stor_report_bus_reset()
      routine acquire the host lock instead of requiring the caller to hold
      it already.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      f07600cf
    • O
      USB: introduce usb_anchor · 51a2f077
      Oliver Neukum 提交于
      - introduction of usb_anchor and its methods
      Signed-off-by: NOliver Neukum <oneukum@suse.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      51a2f077
    • D
      USB: export <linux/usb_gadgetfs> as <linux/usb/gadgetfs.h> · a5262dcf
      David Brownell 提交于
      Make sure gadgetfs userspace interface is properly exported:
      
       - Move <linux/usb_gadgetfs.h> to <linux/usb/gadgetfs.h>;
       - Export it using Kbuild;
       - Add an #include guard;
       - Correct some internal documentation;
       - Update struct layout so it's the same on 32/64 bit kernels.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      a5262dcf
    • D
      USB: add USB_DEVICE_AND_INTERFACE_INFO for device matching · 8538f96a
      Daniel Drake 提交于
      Recently, the USB device matching code stopped matching generic interface
      matches against devices with vendor-specific device class values.
      
      Some drivers now need to explicitly match USB device ID's (in addition to
      generic interface info) to retain the same behaviour as before. This new macro,
      suggested by Alan Stern, makes the explicit device/interface matching a little
      simpler for those users.
      Signed-off-by: NDaniel Drake <dsd@gentoo.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8538f96a
    • A
      USB: add RESET_RESUME device quirk · 6bc6cff5
      Alan Stern 提交于
      This patch (as888) adds a new USB device quirk for devices which are
      unable to resume correctly.  By using the new code added for the
      USB-persist facility, it is a simple matter to reset these devices
      instead of resuming them.  To get things kicked off, a quirk entry is
      added for the Philips PSC805.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6bc6cff5