]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/log
linux-2.6-omap-h63xx.git
17 years agosg: convert the direct IO path to use the block layer
FUJITA Tomonori [Thu, 28 Aug 2008 07:17:08 +0000 (16:17 +0900)]
sg: convert the direct IO path to use the block layer

This patch converts the direct IO path (SG_FLAG_DIRECT_IO) to use the
block layer functions (blk_get_request, blk_execute_rq_nowait,
blk_rq_map_user, etc) instead of scsi_execute_async().

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Douglas Gilbert <dougg@torque.net>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agosg: convert the non-data path to use the block layer
FUJITA Tomonori [Thu, 28 Aug 2008 07:17:07 +0000 (16:17 +0900)]
sg: convert the non-data path to use the block layer

This patch converts the non data path to use the block layer functions
(blk_get_request, blk_execute_rq_nowait, etc) instead of uses
scsi_execute_async().

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Douglas Gilbert <dougg@torque.net>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: introduce struct rq_map_data to use reserved pages
FUJITA Tomonori [Thu, 28 Aug 2008 07:17:06 +0000 (16:17 +0900)]
block: introduce struct rq_map_data to use reserved pages

This patch introduces struct rq_map_data to enable bio_copy_use_iov()
use reserved pages.

Currently, bio_copy_user_iov allocates bounce pages but
drivers/scsi/sg.c wants to allocate pages by itself and use
them. struct rq_map_data can be used to pass allocated pages to
bio_copy_user_iov.

The current users of bio_copy_user_iov simply passes NULL (they don't
want to use pre-allocated pages).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Douglas Gilbert <dougg@torque.net>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: add gfp_mask argument to blk_rq_map_user and blk_rq_map_user_iov
FUJITA Tomonori [Thu, 28 Aug 2008 07:17:05 +0000 (16:17 +0900)]
block: add gfp_mask argument to blk_rq_map_user and blk_rq_map_user_iov

Currently, blk_rq_map_user and blk_rq_map_user_iov always do
GFP_KERNEL allocation.

This adds gfp_mask argument to blk_rq_map_user and blk_rq_map_user_iov
so sg can use it (sg always does GFP_ATOMIC allocation).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Douglas Gilbert <dougg@torque.net>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agocfq-iosched: fix queue depth detection
Aaron Carroll [Tue, 26 Aug 2008 13:52:36 +0000 (15:52 +0200)]
cfq-iosched: fix queue depth detection

CFQ's detection of queueing devices assumes a non-queuing device and detects
if the queue depth reaches a certain threshold.  Under some workloads (e.g.
synchronous reads), CFQ effectively forces a unit queue depth, thus defeating
the detection logic.  This leads to poor performance on queuing hardware,
since the idle window remains enabled.

This patch inverts the sense of the logic: assume a queuing-capable device,
and detect if the depth does not exceed the threshold.

Signed-off-by: Aaron Carroll <aaronc@gelato.unsw.edu.au>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: don't use bio_has_data() in the completion path
Jens Axboe [Tue, 26 Aug 2008 11:34:34 +0000 (13:34 +0200)]
block: don't use bio_has_data() in the completion path

We should just check for rq->bio, as that is really the information
we are looking for. Even if the bio attached doesn't carry data,
we still need to do IO post processing on it.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: inherit CPU completion on bio->rq and rq->rq merges
Jens Axboe [Tue, 26 Aug 2008 08:25:02 +0000 (10:25 +0200)]
block: inherit CPU completion on bio->rq and rq->rq merges

Somewhat incomplete, as we do allow merges of requests and bios
that have different completion CPUs given. This is done on the
assumption that a larger IO is still more beneficial than CPU
locality.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: add support for IO CPU affinity
Jens Axboe [Sat, 13 Sep 2008 18:26:01 +0000 (20:26 +0200)]
block: add support for IO CPU affinity

This patch adds support for controlling the IO completion CPU of
either all requests on a queue, or on a per-request basis. We export
a sysfs variable (rq_affinity) which, if set, migrates completions
of requests to the CPU that originally submitted it. A bio helper
(bio_set_completion_cpu()) is also added, so that queuers can ask
for completion on that specific CPU.

In testing, this has been show to cut the system time by as much
as 20-40% on synthetic workloads where CPU affinity is desired.

This requires a little help from the architecture, so it'll only
work as designed for archs that are using the new generic smp
helper infrastructure.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: make kblockd_schedule_work() take the queue as parameter
Jens Axboe [Mon, 28 Jul 2008 11:08:45 +0000 (13:08 +0200)]
block: make kblockd_schedule_work() take the queue as parameter

Preparatory patch for checking queuing affinity.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: split softirq handling into blk-softirq.c
Jens Axboe [Mon, 28 Jul 2008 11:06:00 +0000 (13:06 +0200)]
block: split softirq handling into blk-softirq.c

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: use linux/uaccess.h in elevator.c instead of asm variant
Jens Axboe [Tue, 26 Aug 2008 07:15:47 +0000 (09:15 +0200)]
block: use linux/uaccess.h in elevator.c instead of asm variant

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: allow disk to have extended device number
Tejun Heo [Mon, 25 Aug 2008 10:56:17 +0000 (19:56 +0900)]
block: allow disk to have extended device number

Now that disk and partition handlings are mostly unified, it's easy to
allow disk to have extended device number.  This patch makes
add_disk() use extended device number if disk->minors is zero.  Both
sd and ide-disk are updated to use this.

* sd_format_disk_name() is implemented which can generically determine
  the drive name.  This removes disk number restriction stemming from
  limited device names.

* If sd index goes over SD_MAX_DISKS (which can be increased now BTW),
  sd simply doesn't initialize minors letting block layer choose
  extended device number.

* If CONFIG_DEBUG_EXT_DEVT is set, both sd and ide-disk always set
  minors to 0 and use extended device numbers.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: replace @ext_minors with GENHD_FL_EXT_DEVT
Tejun Heo [Mon, 25 Aug 2008 10:56:16 +0000 (19:56 +0900)]
block: replace @ext_minors with GENHD_FL_EXT_DEVT

With previous changes, it's meaningless to limit the number of
partitions.  Replace @ext_minors with GENHD_FL_EXT_DEVT such that
setting the flag allows the disk to have maximum number of allowed
partitions (only limited by the number of entries in parsed_partitions
as determined by MAX_PART constant).

This kills not-too-pretty alloc_disk_ext[_node]() functions and makes
@minors parameter to alloc_disk[_node]() unnecessary.  The parameter
is left alone to avoid disturbing the users.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: make partition array dynamic
Tejun Heo [Mon, 25 Aug 2008 10:56:15 +0000 (19:56 +0900)]
block: make partition array dynamic

disk->__part used to be statically allocated to the maximum possible
number of partitions.  This patch makes partition array allocation
dynamic.  The added overhead is minimal as only real change is one
memory dereference changed to RCU one.  This saves both a bit of
memory and cpu cycles iterating through unoccupied slots and makes
increasing partition limit easier.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: move stats from disk to part0
Tejun Heo [Mon, 25 Aug 2008 10:56:14 +0000 (19:56 +0900)]
block: move stats from disk to part0

Move stats related fields - stamp, in_flight, dkstats - from disk to
part0 and unify stat handling such that...

* part_stat_*() now updates part0 together if the specified partition
  is not part0.  ie. part_stat_*() are now essentially all_stat_*().

* {disk|all}_stat_*() are gone.

* part_round_stats() is updated similary.  It handles part0 stats
  automatically and disk_round_stats() is killed.

* part_{inc|dec}_in_fligh() is implemented which automatically updates
  part0 stats for parts other than part0.

* disk_map_sector_rcu() is updated to return part0 if no part matches.
  Combined with the above changes, this makes NULL special case
  handling in callers unnecessary.

* Separate stats show code paths for disk are collapsed into part
  stats show code paths.

* Rename disk_stat_lock/unlock() to part_stat_lock/unlock()

While at it, reposition stat handling macros a bit and add missing
parentheses around macro parameters.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: kill GENHD_FL_FAIL and use part0->make_it_fail
Tejun Heo [Mon, 25 Aug 2008 10:56:13 +0000 (19:56 +0900)]
block: kill GENHD_FL_FAIL and use part0->make_it_fail

GENHD_FL_FAIL for disk is what make_it_fail is for parts.  Kill it and
use part0->make_it_fail.  Sysfs node handling is unified too.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: always set bdev->bd_part
Tejun Heo [Mon, 25 Aug 2008 10:56:12 +0000 (19:56 +0900)]
block: always set bdev->bd_part

Till now, bdev->bd_part is set only if the bdev was for parts other
than part0.  This patch makes bdev->bd_part always set so that code
paths don't have to differenciate common handling.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: move holder_dir from disk to part0
Tejun Heo [Mon, 25 Aug 2008 10:56:11 +0000 (19:56 +0900)]
block: move holder_dir from disk to part0

Move disk->holder_dir to part0->holder_dir.  Kill now mostly
superflous bdev_get_holder().

While at it, kill superflous kobject_get/put() around holder_dir,
slave_dir and cmd_filter creation and collapse
disk_sysfs_add_subdirs() into register_disk().  These serve no purpose
but obfuscating the code.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: move policy from disk to part0
Tejun Heo [Mon, 25 Aug 2008 10:56:10 +0000 (19:56 +0900)]
block: move policy from disk to part0

Move disk->policy to part0->policy.  Implement and use get_disk_ro().

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: unify sysfs size node handling
Tejun Heo [Mon, 25 Aug 2008 10:56:09 +0000 (19:56 +0900)]
block: unify sysfs size node handling

Now that capacity and __dev are moved to part0, part0 and others can
share the same method.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: move __dev from disk to part0
Tejun Heo [Fri, 29 Aug 2008 07:01:47 +0000 (09:01 +0200)]
block: move __dev from disk to part0

Move disk->__dev to part0->__dev.  This simplifies bdget_disk() and
lookup_devt() and allows common sysfs attributes to be unified.
part_to_disk() is updated to handle part0 -> disk.

Updated to include a fix from Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
he writes:

"part0 is a "special" partition and doesn't need to have capacity set - this
fixes regression caused by "block: move __dev from disk to part0" commit."

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: move capacity from disk to part0
Tejun Heo [Mon, 25 Aug 2008 10:56:07 +0000 (19:56 +0900)]
block: move capacity from disk to part0

Move disk->capacity to part0->nr_sects and convert all users who
directly accessed the field to use {get|set}_capacity().  This is done
early to allow the __dev field to be moved.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: introduce partition 0
Tejun Heo [Wed, 3 Sep 2008 07:06:42 +0000 (09:06 +0200)]
block: introduce partition 0

genhd and partition code handled disk and partitions separately.  All
information about the whole disk was in struct genhd and partitions in
struct hd_struct.  However, the whole disk (part0) and other
partitions have a lot in common and the data structures end up having
good number of common fields and thus separate code paths doing the
same thing.  Also, the partition array was indexed by partno - 1 which
gets pretty confusing at times.

This patch introduces partition 0 and makes the partition array
indexed by partno.  Following patches will unify the handling of disk
and parts piece-by-piece.

This patch also implements disk_partitionable() which tests whether a
disk is partitionable.  With coming dynamic partition array change,
the most common usage of disk_max_parts() will be testing whether a
disk is partitionable and the number of max partitions will become
much less important.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: implement and use {disk|part}_to_dev()
Tejun Heo [Mon, 25 Aug 2008 10:56:05 +0000 (19:56 +0900)]
block: implement and use {disk|part}_to_dev()

Implement {disk|part}_to_dev() and use them to access generic device
instead of directly dereferencing {disk|part}->dev.  To make sure no
user is left behind, rename generic devices fields to __dev.

This is in preparation of unifying partition 0 handling with other
partitions.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: implement CONFIG_DEBUG_BLOCK_EXT_DEVT
Tejun Heo [Mon, 25 Aug 2008 10:47:25 +0000 (19:47 +0900)]
block: implement CONFIG_DEBUG_BLOCK_EXT_DEVT

Extended devt introduces non-contiguos device numbers.  This patch
implements a debug option which forces most devt allocations to be
from the extended area and spreads them out.  This is enabled by
default if DEBUG_KERNEL is set and achieves...

1. Detects code paths in kernel or userland which expect predetermined
   consecutive device numbers.

2. When something goes wrong, avoid corruption as adding to the minor
   of earlier partition won't lead to the wrong but valid device.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agosd/ide-disk: apply extended minors to sd and ide
Tejun Heo [Mon, 25 Aug 2008 10:47:24 +0000 (19:47 +0900)]
sd/ide-disk: apply extended minors to sd and ide

Update sd and ide-disk such that they can take advantage of extended
minors.

ide-disk already has 64 minors per device and currently doesn't use
extended minors although after this patch it can be turned on by
simply tweaking constants.

sd only had 16 minors per device causing problems on certain peculiar
configurations.  This patch lifts the restriction and enables it to
use upto 64 minors.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: adjust formatting for large minors and add ext_range sysfs attr
Tejun Heo [Mon, 25 Aug 2008 10:47:23 +0000 (19:47 +0900)]
block: adjust formatting for large minors and add ext_range sysfs attr

With extended minors and the soon-to-follow debug feature, large minor
numbers for block devices will be common.  This patch does the
followings to make printouts pretty.

* Adapt print formats such that large minors don't break the
  formatting.

* For extended MAJ:MIN, %02x%02x for MAJ:MIN used in
  printk_all_partitions() doesn't cut it anymore.  Update it such that
  %03x:%05x is used if either MAJ or MIN doesn't fit in %02x.

* Implement ext_range sysfs attribute which shows total minors the
  device can use including both conventional minor space and the
  extended one.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: implement extended dev numbers
Tejun Heo [Mon, 25 Aug 2008 10:47:22 +0000 (19:47 +0900)]
block: implement extended dev numbers

Implement extended device numbers.  A block driver can tell block
layer that it wants to use extended device numbers.  After the usual
minor space is used up, block layer automatically allocates devt's
from EXT_BLOCK_MAJOR.

Currently only one major number is allocated for this but as the
allocation is strictly on-demand, ~1mil minor space under it should
suffice unless the system actually has more than ~1mil partitions and
if that ever happens adding more majors to the extended devt area is
easy.

Due to internal implementation issues, the first partition can't be
allocated on the extended area.  In other words, genhd->minors should
at least be 1.  This limitation will be lifted by later changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: fix diskstats access
Tejun Heo [Mon, 25 Aug 2008 10:47:21 +0000 (19:47 +0900)]
block: fix diskstats access

There are two variants of stat functions - ones prefixed with double
underbars which don't care about preemption and ones without which
disable preemption before manipulating per-cpu counters.  It's unclear
whether the underbarred ones assume that preemtion is disabled on
entry as some callers don't do that.

This patch unifies diskstats access by implementing disk_stat_lock()
and disk_stat_unlock() which take care of both RCU (for partition
access) and preemption (for per-cpu counter access).  diskstats access
should always be enclosed between the two functions.  As such, there's
no need for the versions which disables preemption.  They're removed
and double underbars ones are renamed to drop the underbars.  As an
extra argument is added, there's no danger of using the old version
unconverted.

disk_stat_lock() uses get_cpu() and returns the cpu index and all
diskstat functions which access per-cpu counters now has @cpu
argument to help RT.

This change adds RCU or preemption operations at some places but also
collapses several preemption ops into one at others.  Overall, the
performance difference should be negligible as all involved ops are
very lightweight per-cpu ones.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: fix disk->part[] dereferencing race
Tejun Heo [Wed, 3 Sep 2008 07:03:02 +0000 (09:03 +0200)]
block: fix disk->part[] dereferencing race

disk->part[] is protected by its matching bdev's lock.  However,
non-critical accesses like collecting stats and printing out sysfs and
proc information used to be performed without any locking.  As
partitions can come and go dynamically, partitions can go away
underneath those non-critical accesses.  As some of those accesses are
writes, this theoretically can lead to silent corruption.

This patch fixes the race by using RCU for the partition array and dev
reference counter to hold partitions.

* Rename disk->part[] to disk->__part[] to make sure no one outside
  genhd layer proper accesses it directly.

* Use RCU for disk->__part[] dereferencing.

* Implement disk_{get|put}_part() which can be used to get and put
  partitions from gendisk respectively.

* Iterators are implemented to help iterate through all partitions
  safely.

* Functions which require RCU readlock are marked with _rcu suffix.

* Use disk_put_part() in __blkdev_put() instead of directly putting
  the contained kobject.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: don't depend on consecutive minor space
Tejun Heo [Wed, 3 Sep 2008 07:01:48 +0000 (09:01 +0200)]
block: don't depend on consecutive minor space

* Implement disk_devt() and part_devt() and use them to directly
  access devt instead of computing it from ->major and ->first_minor.

  Note that all references to ->major and ->first_minor outside of
  block layer is used to determine devt of the disk (the part0) and as
  ->major and ->first_minor will continue to represent devt for the
  disk, converting these users aren't strictly necessary.  However,
  convert them for consistency.

* Implement disk_max_parts() to avoid directly deferencing
  genhd->minors.

* Update bdget_disk() such that it doesn't assume consecutive minor
  space.

* Move devt computation from register_disk() to add_disk() and make it
  the only one (all other usages use the initially determined value).

These changes clean up the code and will help disk->part dereference
fix and extended block device numbers.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: make variable and argument names more consistent
Tejun Heo [Wed, 3 Sep 2008 07:01:09 +0000 (09:01 +0200)]
block: make variable and argument names more consistent

In hd_struct, @partno is used to denote partition number and a number
of other places use @part to denote hd_struct.  Functions use @part
and @index instead.  This causes confusion and makes it difficult to
use consistent variable names for hd_struct.  Always use @partno if a
variable represents partition number.

Also, print out functions use @f or @part for seq_file argument.  Use
@seqf uniformly instead.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: misc updates
Tejun Heo [Mon, 25 Aug 2008 10:47:17 +0000 (19:47 +0900)]
block: misc updates

This patch makes the following misc updates in preparation for
disk->part dereference fix and extended block devt support.

* implment part_to_disk()

* fix comment about gendisk->part indexing

* rename get_part() to disk_map_sector()

* don't use n which is always zero while printing disk information in
  diskstats_show()

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: update add_partition() error handling
Tejun Heo [Mon, 25 Aug 2008 10:30:16 +0000 (19:30 +0900)]
block: update add_partition() error handling

d805dda4 tried to fix error case handling in add_partition() but had a
few problems.

* disk->part[] entry is set early and left dangling if operation
  fails.

* Once device initialized, the last put_device() is responsible for
  freeing all the resources.  The failure path freed part_stats and p
  regardless of put_device() causing double free.

* holders subdir holds reference to the disk device, so failure path
  should remove it to release resources properly which was missing.

This patch fixes the above problems and while at it move partition
slot busy check into add_partition() for completeness and inlines
holders subdirectory creation.  Using separate function for it just
obfuscates the code.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Abdel Benamrouche <draconux@gmail.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: allow deleting zero length partition
Tejun Heo [Mon, 25 Aug 2008 10:30:15 +0000 (19:30 +0900)]
block: allow deleting zero length partition

delete_partition() was noop for zero length partition.  As the
addition code allows creating zero lenght partition and deletion is
assumed to always succeed, this causes memory leak for zero length
partitions.  Allow zero length partitions to end their meaningless
lives.

While at it, allow deleting zero lenght partition via
BLKPG_DEL_PARTITION ioctl too.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: use class_dev_iterator instead of class_for_each_device()
Tejun Heo [Wed, 3 Sep 2008 06:57:12 +0000 (08:57 +0200)]
block: use class_dev_iterator instead of class_for_each_device()

Recent block_class iteration updates 5c6f35c5..27f3025 converted all
class device iteration to class_for_each_device() and
class_find_device(), which are correct but pain in the ass to use.
This pach converts them to newly introduced class_dev_iterator so that
they can use more natural control structures instead of separate
callbacks and struct to pass parameters to them.

This results in smaller and easier code.

This patch also restores the original behavior of not printing header
in /proc/partitions if there's no partition to print.  This is trivial
but still user-visible behavior.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: don't grab block_class_lock unnecessarily
Tejun Heo [Wed, 3 Sep 2008 06:53:37 +0000 (08:53 +0200)]
block: don't grab block_class_lock unnecessarily

block_class_lock protects major_names array and bdev_map and doesn't
have anything to do with block class devices.  Don't grab them while
iterating over block class devices.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: fix partition info printouts
Tejun Heo [Mon, 25 Aug 2008 10:30:12 +0000 (19:30 +0900)]
block: fix partition info printouts

Recent block_class iteration updates 5c6f35c5..27f3025 broke partition
info printouts.

* printk_all_partitions(): Partition print out stops when it meets a
  partition hole.  Partition printing inner loop should continue
  instead of exiting on empty partition slot.

* /proc/partitions and /proc/diskstats: If all information can't be
  read in single read(), the information is truncated.  This is
  because find_start() doesn't actually update the counter containing
  the initial seek.  It runs to the end and ends up always reporting
  EOF on the second read.

This patch fixes both problems.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agodriver-core: use klist for class device list and implement iterator
Tejun Heo [Mon, 25 Aug 2008 17:50:19 +0000 (19:50 +0200)]
driver-core: use klist for class device list and implement iterator

Iterating over entries using callback usually isn't too fun especially
when the entry being iterated over can't be manipulated freely.  This
patch converts class->p->class_devices to klist and implements class
device iterator so that the users can freely build their own control
structure.  The users are also free to call back into class code
without worrying about locking.

class_for_each_device() and class_find_device() are converted to use
the new iterators, so their users don't have to worry about locking
anymore either.

Note: This depends on klist-dont-iterate-over-deleted-entries patch
because class_intf->add/remove_dev() depends on proper synchronization
with device removal.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoklist: don't iterate over deleted entries
Tejun Heo [Mon, 25 Aug 2008 17:50:16 +0000 (19:50 +0200)]
klist: don't iterate over deleted entries

A klist entry is kept on the list till all its current iterations are
finished; however, a new iteration after deletion also iterates over
deleted entries as long as their reference count stays above zero.
This causes problems for cases where there are users which iterate
over the list while synchronized against list manipulations and
natuarally expect already deleted entries to not show up during
iteration.

This patch implements dead flag which gets set on deletion so that
iteration can skip already deleted entries.  The dead flag piggy backs
on the lowest bit of knode->n_klist and only visible to klist
implementation proper.

While at it, drop klist_iter->i_head as it's redundant and doesn't
offer anything in semantics or performance wise as klist_iter->i_klist
is dereferenced on every iteration anyway.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoAdd some block/ source files to the kernel-api docbook. Fix kernel-doc notation in...
Randy Dunlap [Tue, 19 Aug 2008 18:13:11 +0000 (20:13 +0200)]
Add some block/ source files to the kernel-api docbook. Fix kernel-doc notation in them as needed. Fix changed function parameter names. Fix typos/spellos. In comments, change REQ_SPECIAL to REQ_TYPE_SPECIAL and REQ_BLOCK_PC to REQ_TYPE_BLOCK_PC.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: make bi_phys_segments an unsigned int instead of short
Jens Axboe [Fri, 15 Aug 2008 08:56:11 +0000 (10:56 +0200)]
block: make bi_phys_segments an unsigned int instead of short

raid5 can overflow with more than 255 stripes, and we can increase it
to an int for free on both 32 and 64-bit archs due to the padding.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: raid fixups for removal of bi_hw_segments
Jens Axboe [Fri, 15 Aug 2008 08:41:18 +0000 (10:41 +0200)]
block: raid fixups for removal of bi_hw_segments

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agodrop vmerge accounting
Mikulas Patocka [Fri, 15 Aug 2008 08:20:02 +0000 (10:20 +0200)]
drop vmerge accounting

Remove hw_segments field from struct bio and struct request. Without virtual
merge accounting they have no purpose.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: drop virtual merging accounting
Mikulas Patocka [Fri, 15 Aug 2008 08:15:19 +0000 (10:15 +0200)]
block: drop virtual merging accounting

Remove virtual merge accounting.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: update documentation for deadline fifo_batch tunable
Aaron Carroll [Thu, 14 Aug 2008 08:17:15 +0000 (18:17 +1000)]
block: update documentation for deadline fifo_batch tunable

Update the description of fifo_batch to match the current implementation,
and include a description of how to tune it.

Signed-off-by: Aaron Carroll <aaronc@gelato.unsw.edu.au>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agodeadline-iosched: non-functional fixes
Aaron Carroll [Thu, 14 Aug 2008 08:17:14 +0000 (18:17 +1000)]
deadline-iosched: non-functional fixes

* convert goto to simpler while loop;
 * use rq_end_sector() instead of computing manually;
 * fix false comments;
 * remove spurious whitespace;
 * convert rq_rb_root macro to an inline function.

Signed-off-by: Aaron Carroll <aaronc@gelato.unsw.edu.au>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agodeadline-iosched: allow non-sequential batching
Aaron Carroll [Thu, 14 Aug 2008 08:17:13 +0000 (18:17 +1000)]
deadline-iosched: allow non-sequential batching

Deadline currently only batches sector-contiguous requests, so except
for a few circumstances (e.g. requests in a single direction), it is
essentially first come first served.  This is bad for throughput, so
change it to CSCAN, which means requests in a batch do not need to be
sequential and are issued in increasing sector order.

Signed-off-by: Aaron Carroll <aaronc@gelato.unsw.edu.au>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agovirtio_blk: use a wrapper function to access io context information of IO requests
Fernando Luis Vázquez Cao [Thu, 14 Aug 2008 07:59:13 +0000 (09:59 +0200)]
virtio_blk: use a wrapper function to access io context information of IO requests

struct request has an ioprio member but it is never updated because
currently bios do not hold io context information. The implication of
this is that virtio_blk ends up passing useless information to the
backend driver.

That said, some IO schedulers such as CFQ do store io context
information in struct request, but use private members for that, which
means that that information cannot be directly accessed in a IO
scheduler-independent way.

This patch adds a function to obtain the ioprio of a request. We should
avoid accessing ioprio directly and use this function instead, so that
its users do not have to care about future changes in block layer
structures or what the currently active IO controller is.

This patch does not introduce any functional changes but paves the way
for future clean-ups and enhancements.

Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoKill REQ_TYPE_FLUSH
David Woodhouse [Wed, 13 Aug 2008 11:35:09 +0000 (12:35 +0100)]
Kill REQ_TYPE_FLUSH

It was only used by ps3disk, and it should probably have been
REQ_TYPE_LINUX_BLOCK + REQ_LB_OP_FLUSH.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoAllow elevators to sort/merge discard requests
David Woodhouse [Sat, 9 Aug 2008 15:42:20 +0000 (16:42 +0100)]
Allow elevators to sort/merge discard requests

But blkdev_issue_discard() still emits requests which are interpreted as
soft barriers, because naïve callers might otherwise issue subsequent
writes to those same sectors, which might cross on the queue (if they're
reallocated quickly enough).

Callers still _can_ issue non-barrier discard requests, but they have to
take care of queue ordering for themselves.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoAdd BLKDISCARD ioctl to allow userspace to discard sectors
David Woodhouse [Mon, 11 Aug 2008 14:58:42 +0000 (15:58 +0100)]
Add BLKDISCARD ioctl to allow userspace to discard sectors

We may well want mkfs tools to use this to mark the whole device as
unwanted before they format it, for example.

The ioctl takes a pair of uint64_ts, which are start offset and length
in _bytes_. Although at the moment it might make sense for them both to
be in 512-byte sectors, I don't want to limit the ABI to that.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoUse WRITE_BARRIER in blkdev_issue_flush(), not (1<<BIO_RW_BARRIER)
OGAWA Hirofumi [Mon, 11 Aug 2008 16:07:08 +0000 (17:07 +0100)]
Use WRITE_BARRIER in blkdev_issue_flush(), not (1<<BIO_RW_BARRIER)

Barriers should be submitted with the WRITE flag set.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblktrace: simplify flags handling in __blk_add_trace
David Woodhouse [Sun, 10 Aug 2008 11:33:00 +0000 (12:33 +0100)]
blktrace: simplify flags handling in __blk_add_trace

Let the compiler see what's going on, and it can all get a lot simpler.
On PPC64 this reduces the size of the code calculating these bits by
about 60%. On x86_64 it's less of a win -- only 40%.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblktrace: support discard requests
David Woodhouse [Sun, 10 Aug 2008 10:21:57 +0000 (11:21 +0100)]
blktrace: support discard requests

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoSupport 'discard sectors' operation.
David Woodhouse [Tue, 5 Aug 2008 17:08:56 +0000 (18:08 +0100)]
Support 'discard sectors' operation.

We can benefit from knowing that the file system no longer cares about
the contents of certain sectors, by throwing them away immediately and
then never having to garbage collect them, and using the extra free
space to make our operations more efficient. Do so.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoSupport 'discard sectors' operation in translation layer support core
David Woodhouse [Tue, 5 Aug 2008 17:08:25 +0000 (18:08 +0100)]
Support 'discard sectors' operation in translation layer support core

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoLet the block device know when sectors can be discarded
David Woodhouse [Tue, 5 Aug 2008 17:05:46 +0000 (18:05 +0100)]
Let the block device know when sectors can be discarded

[hirofumi@mail.parknet.co.jp: discard _after_ checking for corrupt chains]

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoAdd 'discard' request handling
David Woodhouse [Tue, 5 Aug 2008 17:01:53 +0000 (18:01 +0100)]
Add 'discard' request handling

Some block devices benefit from a hint that they can forget the contents
of certain sectors. Add basic support for this to the block core, along
with a 'blkdev_issue_discard()' helper function which issues such
requests.

The caller doesn't get to provide an end_io functio, since
blkdev_issue_discard() will automatically split the request up into
multiple bios if appropriate. Neither does the function wait for
completion -- it's expected that callers won't care about when, or even
_if_, the request completes. It's only a hint to the device anyway. By
definition, the file system doesn't _care_ about these sectors any more.

[With feedback from OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> and
Jens Axboe <jens.axboe@oracle.com]

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoFix up comments about matching flags between bio and rq
David Woodhouse [Sat, 9 Aug 2008 15:22:17 +0000 (16:22 +0100)]
Fix up comments about matching flags between bio and rq

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agohighmem: use bio_has_data() in the bounce path
Jens Axboe [Thu, 14 Aug 2008 11:12:15 +0000 (13:12 +0200)]
highmem: use bio_has_data() in the bounce path

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: use bio_has_data() in the IO completion path
Jens Axboe [Fri, 8 Aug 2008 09:06:45 +0000 (11:06 +0200)]
block: use bio_has_data() in the IO completion path

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: use bio_has_data() to check for data carrying bio
Jens Axboe [Fri, 8 Aug 2008 09:04:44 +0000 (11:04 +0200)]
block: use bio_has_data() to check for data carrying bio

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoblock: add bio_has_data() to detect whether a bio carries data or not
Jens Axboe [Fri, 8 Aug 2008 09:17:12 +0000 (11:17 +0200)]
block: add bio_has_data() to detect whether a bio carries data or not

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoSG_IO block filter whitelist missing MMC SET READ AHEAD command
xiphmont@xiph.org [Fri, 22 Aug 2008 09:12:21 +0000 (11:12 +0200)]
SG_IO block filter whitelist missing MMC SET READ AHEAD command

I have another request for the block filter SG_IO command whitelist,
specifically the MMC streaming command set SET READ AHEAD command.
The command applies only to MMC CDROM/DVDROM drives with the streaming
optional feature set.  The command is useful to cdparanoia in that it
allows explicit cache control side effects that are, on many drives,
cdparanoia's most efficient way to flush/disable the media cache on
cdrom drives. I am aware of no reason why it should not be accessible
from usespace.

Also note that the command is already fully accessible through the
SCSI-native version of the SG_IO ioctl as well as the traditional SG
interface.  The command is only being refused on block devices.  That
means that on a typical stock distro, the command is available through
/dev/sg* but not /dev/scd* although both are typically available and
accessible.  Filtering the command is not providing any protection,
only a confusing inconsistency.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
17 years agoBlackfin arch: fix define error in BF561 memory map macros
Graf Yang [Thu, 9 Oct 2008 06:17:47 +0000 (14:17 +0800)]
Blackfin arch: fix define error in BF561 memory map macros

Signed-off-by: Graf Yang <graf.yang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoBlackfin arch: Make L2 SRAM cacheable
Sonic Zhang [Thu, 9 Oct 2008 06:11:57 +0000 (14:11 +0800)]
Blackfin arch: Make L2 SRAM cacheable

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoBlackfin arch: flags of UART3 mem resource is missing
Sonic Zhang [Thu, 9 Oct 2008 05:55:33 +0000 (13:55 +0800)]
Blackfin arch: flags of UART3 mem resource is missing

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoBlackfin arch: Fix bug - kernel build with config kernel debugging with remote gdb...
Sonic Zhang [Thu, 9 Oct 2008 06:04:41 +0000 (14:04 +0800)]
Blackfin arch: Fix bug - kernel build with config kernel debugging with remote gdb fails

 Add some comment and fix duplicated VEC_EXCPT02

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoInput: ads7846 - fix cache line sharing issue
Dmitry Torokhov [Thu, 9 Oct 2008 04:52:23 +0000 (00:52 -0400)]
Input: ads7846 - fix cache line sharing issue

We had a report a while back that the ads7846 driver had some issues
when used with DMA-based SPI controllers (like atmel_spi) on systems
where main memory is not DMA-coherent (most non-x86 boards). Allocate
memory potentially used for DMA separately to avoid cache line issues.

Reported-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
17 years agoInput: cm109 - add missing newlines to messages
Daniel Gimpelevich [Thu, 9 Oct 2008 04:44:47 +0000 (00:44 -0400)]
Input: cm109 - add missing newlines to messages

Recent conversion from err(), warn(), info() to dev_* variants caused loss
of newlines at the end of messages, add them back.

Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
17 years agoBlackfin arch: Fix BUG -- BF533 + 0.5 silicon + MPU + UART PIO -> crash
Michael Hennerich [Thu, 9 Oct 2008 04:31:03 +0000 (12:31 +0800)]
Blackfin arch: Fix BUG -- BF533 + 0.5 silicon + MPU + UART PIO -> crash

Apply ANOMALY_05000283 & ANOMALY_05000315
Workaround also to the EXCEPTION path.

Cover evt_ivhw also with ANOMALY_05000315
The Workaround needs to be prior to accesses (either read or write) to
any system MMR.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoBlackfin arch: add support for BF52x-0.2, BF533-0.6, and BF54x-0.2
Mike Frysinger [Thu, 9 Oct 2008 04:06:27 +0000 (12:06 +0800)]
Blackfin arch: add support for BF52x-0.2, BF533-0.6, and BF54x-0.2

Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoBlackfin arch: fix default silicon rev selection so it works for all supported parts
Mike Frysinger [Thu, 9 Oct 2008 04:05:31 +0000 (12:05 +0800)]
Blackfin arch: fix default silicon rev selection so it works for all supported parts

Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoBlackfin arch: BF561 is supported, no longer a work in progress
Mike Frysinger [Thu, 9 Oct 2008 04:03:22 +0000 (12:03 +0800)]
Blackfin arch: BF561 is supported, no longer a work in progress

Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoBlackfin arch: Make sure we program the correct values in only when necessary for...
Robin Getz [Thu, 9 Oct 2008 03:59:46 +0000 (11:59 +0800)]
Blackfin arch: Make sure we program the correct values in only when necessary for MUSB driver

Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoInput: document i8042.debug in kernel-parameters.txt
Jiri Kosina [Mon, 6 Oct 2008 06:51:09 +0000 (02:51 -0400)]
Input: document i8042.debug in kernel-parameters.txt

i8042.debug parameter was missing in Documentation/kernel-parameters.txt.
Add it.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
17 years agoInput: keyboard - fix potential out of bound access to key_map
Dmitry Torokhov [Thu, 9 Oct 2008 03:42:26 +0000 (23:42 -0400)]
Input: keyboard - fix potential out of bound access to key_map

Reported-by: Michal Roszkowski <michal@roszkowski.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
17 years agoBlackfin arch: Fix BUG: anomaly_threshold is used with ANOMALY_05000363
Michael Hennerich [Thu, 9 Oct 2008 03:11:11 +0000 (11:11 +0800)]
Blackfin arch: Fix BUG: anomaly_threshold is used with ANOMALY_05000363

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
17 years agoIB/mlx4: Set RLKEY bit for kernel QPs
Vladimir Sokolovsky [Thu, 9 Oct 2008 03:09:01 +0000 (20:09 -0700)]
IB/mlx4: Set RLKEY bit for kernel QPs

Set RLKEY bit in the HW context for kernel QPs so that kernel QPs can
use the reserved L_Key for memory reference.

Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
17 years agojme: Fix warnings with CONFIG_PM disabled.
David S. Miller [Thu, 9 Oct 2008 02:54:31 +0000 (19:54 -0700)]
jme: Fix warnings with CONFIG_PM disabled.

drivers/net/jme.c:1598: warning: ‘jme_set_100m_half’ defined but not used
drivers/net/jme.c:1618: warning: ‘jme_wait_link’ defined but not used

Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agojme: Advances version number
Guo-Fu Tseng [Thu, 9 Oct 2008 02:50:44 +0000 (19:50 -0700)]
jme: Advances version number

Advances the driver version after modification.

Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agojme: Faulty IRQ handle bug fix
akeemting [Thu, 9 Oct 2008 02:50:03 +0000 (19:50 -0700)]
jme: Faulty IRQ handle bug fix

Fix IRQ handle bug when interrupt mode.

The driver was incorrectly handled and returned IRQ_HANDLED
while the device is not generating the interrupt.
It happened due to faulty determination of interrupt status register.

Found by: "Ethan" <ethanhsiao@jmicron.com>
Fixed by: "akeemting" <akeem@jmicron.com>
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agojme: Added half-duplex mode and IPv6 RSS fix
Guo-Fu Tseng [Thu, 9 Oct 2008 02:48:58 +0000 (19:48 -0700)]
jme: Added half-duplex mode and IPv6 RSS fix

1. Set bit 5 of GPREG1 to 1 to enable hardware workaround for half-duplex
   mode. Which the MAC processor generates CRS/COL by itself instead of
   receive it from PHY processor.

2. Set bit 6 of GPREG1 to 1 to enable hardware workaround that masks the
   MAC processor working right while calculating IPv6 RSS in 10/100
   mode.

3. Group the workaround codes all together.

Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agocxgb3: Add 1G fiber support
Divy Le Ray [Thu, 9 Oct 2008 00:40:28 +0000 (17:40 -0700)]
cxgb3: Add 1G fiber support

Add support for 1G optical Vitesse PHY.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agocxgb3: Support for Aeluros 2005 PHY
Divy Le Ray [Thu, 9 Oct 2008 00:40:07 +0000 (17:40 -0700)]
cxgb3: Support for Aeluros 2005 PHY

Add support for SR PHY.
Auto-detect phy module type, and report type changes.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agocxgb3: commnonize LASI phy code
Divy Le Ray [Thu, 9 Oct 2008 00:39:31 +0000 (17:39 -0700)]
cxgb3: commnonize LASI phy code

Add generic code to manage interrupt driven PHYs.
Do not reset the phy after link parameters update,
the new values might get lost.
Return early from link change notification
when the link parameters remain unchanged.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agocxgb3: More flexible support for PHY interrupts.
Divy Le Ray [Thu, 9 Oct 2008 00:39:00 +0000 (17:39 -0700)]
cxgb3: More flexible support for PHY interrupts.

Do not require PHY interrupts to be connected to GPIs in ascending order.
Base interrupt availability both on PHYs supporting them and on GPIs being
hooked up.  Allows boards to specify interrupt GPIs though the PHYs don't
use them.

Remove spurious PHY interrupts due to clearing T3DBG interrupts before
setting their polarity.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agocxgb3: simplify port type struct and usage
Divy Le Ray [Thu, 9 Oct 2008 00:38:29 +0000 (17:38 -0700)]
cxgb3: simplify port type struct and usage

Second step in overall phy layer reorganization.
Clean up the port_type_info structure.
Support coextistence of clause 22 and clause 45 MDIO devices.
Select the type of MDIO transaction on a per transaction basis.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agocxgb3: allow for PHY reset status
Divy Le Ray [Thu, 9 Oct 2008 00:38:01 +0000 (17:38 -0700)]
cxgb3: allow for PHY reset status

First step towards overall PHY layering re-organization.
Allow a status return when a PHY is reset.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agocxgb3: Allocate multiqueues at init time
Divy Le Ray [Thu, 9 Oct 2008 00:37:33 +0000 (17:37 -0700)]
cxgb3: Allocate multiqueues at init time

Allocate a queue set per core, up to the maximum of available qsets.
Share the queue sets on multi port adapters.
Rename MSI-X interrupt vectors ethX-N, N being the queue set number.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agocxgb3: reset the adapter on fatal error
Divy Le Ray [Thu, 9 Oct 2008 00:36:03 +0000 (17:36 -0700)]
cxgb3: reset the adapter on fatal error

when a fatal error occurs, bring ports down, reset the chip,
and bring ports back up.

Factorize code used for both EEH and fatal error recovery.
Fix timer usage when bringing up/resetting sge queue sets.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agodsa: Need to select PHYLIB.
David S. Miller [Thu, 9 Oct 2008 00:33:01 +0000 (17:33 -0700)]
dsa: Need to select PHYLIB.

Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agodsa: add support for the Marvell 88E6060 switch chip
Lennert Buytenhek [Tue, 7 Oct 2008 13:46:22 +0000 (13:46 +0000)]
dsa: add support for the Marvell 88E6060 switch chip

Add support for the Marvell 88E6060 switch chip.  This chip only
supports the Header and Trailer tagging formats, and we use it in
Trailer mode since that mode is slightly easier to handle than
Header mode.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agodsa: add support for Trailer tagging format
Lennert Buytenhek [Tue, 7 Oct 2008 13:46:07 +0000 (13:46 +0000)]
dsa: add support for Trailer tagging format

This adds support for the Trailer switch tagging format.  This is
another tagging that doesn't explicitly mark tagged packets with a
distinct ethertype, so that we need to add a similar hack in the
receive path as for the Original DSA tagging format.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agodsa: add support for the Marvell 88E6131 switch chip
Lennert Buytenhek [Tue, 7 Oct 2008 13:45:18 +0000 (13:45 +0000)]
dsa: add support for the Marvell 88E6131 switch chip

Add support for the Marvell 88E6131 switch chip.  This chip only
supports the original (ethertype-less) DSA tagging format.

On the 88E6131, there is a PHY Polling Unit (PPU) which has exclusive
access to each of the PHYs's MII management registers.  If we want to
talk to the PHYs from software, we have to disable the PPU and wait
for it to complete its current transaction before we can do so, and we
need to re-enable the PPU afterwards to make sure that the switch will
notice changes in link state and speed on the individual ports as they
occur.

Since disabling the PPU is rather slow, and since MII management
accesses are typically done in bursts, this patch keeps the PPU disabled
for 10ms after a software access completes.  This makes handling the
PPU slightly more complex, but speeds up something like running ethtool
on one of the switch slave interfaces from ~300ms to ~30ms on typical
hardware.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agodsa: add support for original DSA tagging format
Lennert Buytenhek [Tue, 7 Oct 2008 13:45:02 +0000 (13:45 +0000)]
dsa: add support for original DSA tagging format

Most of the DSA switches currently in the field do not support the
Ethertype DSA tagging format that one of the previous patches added
support for, but only the original DSA tagging format.

The original DSA tagging format carries the same information as the
Ethertype DSA tagging format, but with the difference that it does not
have an ethertype field.  In other words, when receiving a packet that
is tagged with an original DSA tag, there is no way of telling in
eth_type_trans() that this packet is in fact a DSA-tagged packet.

This patch adds a hook into eth_type_trans() which is only compiled in
if support for a switch chip that doesn't support Ethertype DSA is
selected, and which checks whether there is a DSA switch driver
instance attached to this network device which uses the old tag format.
If so, it sets the protocol field to ETH_P_DSA without looking at the
packet, so that the packet ends up in the right place.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agonet: Distributed Switch Architecture protocol support
Lennert Buytenhek [Tue, 7 Oct 2008 13:44:02 +0000 (13:44 +0000)]
net: Distributed Switch Architecture protocol support

Distributed Switch Architecture is a protocol for managing hardware
switch chips.  It consists of a set of MII management registers and
commands to configure the switch, and an ethernet header format to
signal which of the ports of the switch a packet was received from
or is intended to be sent to.

The switches that this driver supports are typically embedded in
access points and routers, and a typical setup with a DSA switch
looks something like this:

+-----------+       +-----------+
|           | RGMII |           |
|           +-------+           +------ 1000baseT MDI ("WAN")
|           |       |  6-port   +------ 1000baseT MDI ("LAN1")
|    CPU    |       |  ethernet +------ 1000baseT MDI ("LAN2")
|           |MIImgmt|  switch   +------ 1000baseT MDI ("LAN3")
|           +-------+  w/5 PHYs +------ 1000baseT MDI ("LAN4")
|           |       |           |
+-----------+       +-----------+

The switch driver presents each port on the switch as a separate
network interface to Linux, polls the switch to maintain software
link state of those ports, forwards MII management interface
accesses to those network interfaces (e.g. as done by ethtool) to
the switch, and exposes the switch's hardware statistics counters
via the appropriate Linux kernel interfaces.

This initial patch supports the MII management interface register
layout of the Marvell 88E612388E6161 and 88E6165 switch chips, and
supports the "Ethertype DSA" packet tagging format.

(There is no officially registered ethertype for the Ethertype DSA
packet format, so we just grab a random one.  The ethertype to use
is programmed into the switch, and the switch driver uses the value
of ETH_P_EDSA for this, so this define can be changed at any time in
the future if the one we chose is allocated to another protocol or
if Ethertype DSA gets its own officially registered ethertype, and
everything will continue to work.)

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Tested-by: Nicolas Pitre <nico@marvell.com>
Tested-by: Byron Bradley <byron.bbradley@gmail.com>
Tested-by: Tim Ellis <tim.ellis@mac.com>
Tested-by: Peter van Valderen <linux@ddcrew.com>
Tested-by: Dirk Teurlings <dirk@upexia.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years ago8139too: move wmb before TX DMA start
Andreas Oberritter [Wed, 8 Oct 2008 06:14:16 +0000 (06:14 +0000)]
8139too: move wmb before TX DMA start

The write barrier should be used before starting a DMA transfer. This fixes
a problem, where almost all packets received on another machine had garbled
content. Tested with an RTL8100C on a MIPS machine.

Signed-off-by: Andreas Oberritter <obi@linuxtv.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
17 years agonetdev: uniquify the tx_timeout name
Arjan van de Ven [Sun, 5 Oct 2008 07:35:05 +0000 (07:35 +0000)]
netdev: uniquify the tx_timeout name

there's several drivers that have use "tx_timeout" for the .. tx
timeout function.  All fine with that, they're static, however for
doing stats on how often which driver hits the timeout it's a tad
unfortunate. The patch below gives the ones I found in the
kerneloops.org database unique names.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>