History log of /drivers/ide/ide-io.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
782b86e2656762382ae1c2686d8d5c91f7d5eacf 05-Apr-2011 Jens Axboe <jaxboe@fusionio.com> ide: always ensure that blk_delay_queue() is called if we have pending IO

Just because we are not requeuing a request does not mean that
some aren't pending. So always issue a blk_delay_queue() if
either we are requeueing OR there's pending IO.

This fixes a boot problem for some IDE boxes.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
/drivers/ide/ide-io.c
929e27252e8ca69363f81f26af5eaba62cb4c572 30-Mar-2011 Jens Axboe <jaxboe@fusionio.com> ide: ide_requeue_and_plug() reinstate "always plug" behaviour

We see stalls if we don't always ensure that the queue gets run
again. Even if rq == NULL, we could have other pending requests
in the queue.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
/drivers/ide/ide-io.c
9ced0b95b3993660e7990cf6bf68c1a80f31544e 26-Mar-2011 Jens Axboe <jaxboe@fusionio.com> ide: ensure that we re-run the queue handler

The conversion to blk_delay_queue() missed parts of IDE.
Add a blk_delay_queue() to ensure that the request handler
gets reinvoked when it needs to.

Note that in all but one place the old plug re-run delay of
3 msecs is used, even though it probably could be shorter
for performance reasons in some of those cases.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
/drivers/ide/ide-io.c
7eaceaccab5f40bbfda044629a6298616aeaed50 10-Mar-2011 Jens Axboe <jaxboe@fusionio.com> block: remove per-queue plugging

Code has been converted over to the new explicit on-stack plugging,
and delay users have been converted to use the new API for that.
So lets kill off the old plugging along with aops->sync_page().

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
/drivers/ide/ide-io.c
0da2f50944976e890ccc9436ab88c0da87788d02 03-Sep-2010 Tejun Heo <tj@kernel.org> ide: remove unnecessary blk_queue_flushing() test in do_ide_request()

Unplugging from a request function doesn't really help much (it's
already in the request_fn) and soon block layer will be updated to mix
barrier sequence with other commands, so there's no need to treat
queue flushing any differently.

ide was the only user of blk_queue_flushing(). Remove it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
/drivers/ide/ide-io.c
4c4762d10faf93167b84ee03e4b58dd62012b06f 19-Jun-2010 Christoph Hellwig <hch@lst.de> block: fix some more cmd_type cleanup fallout

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
/drivers/ide/ide-io.c
33659ebbae262228eef4e0fe990f393d1f0ed941 07-Aug-2010 Christoph Hellwig <hch@lst.de> block: remove wrappers for request type/flags

Remove all the trivial wrappers for the cmd_type and cmd_flags fields in
struct requests. This allows much easier grepping for different request
types instead of unwinding through macros.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
/drivers/ide/ide-io.c
6072f7491f5ef391a575e18a1165e72a3eef1601 31-Mar-2010 Herbert Xu <herbert@gondor.apana.org.au> ide: Requeue request after DMA timeout

I noticed that my KVM virtual machines were experiencing IDE
issues resulting in processes stuck on waiting for buffers to
complete.

The root cause is of course race conditions in the ancient qemu
backend that I'm using. However, the fact that the guest isn't
recovering is a bug.

I've tracked it down to the change made last year to dequeue
requests at the start rather than at the end in the IDE layer.

commit 8f6205cd572fece673da0255d74843680f67f879
Author: Tejun Heo <tj@kernel.org>
Date: Fri May 8 11:53:59 2009 +0900

ide: dequeue in-flight request

The problem is that the function ide_dma_timeout_retry does not
requeue the current request, causing one request to be lost for
each DMA timeout.

This patch fixes this by requeueing the request.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/ide/ide-io.c
3503e0acbfab0dbcd24ccadd5fe841f3f8290e81 06-Jul-2009 David S. Miller <davem@davemloft.net> Revert "ide: improve handling of Power Management requests"

This reverts commit a1317f714af7aed60ddc182d0122477cbe36ee9b.
/drivers/ide/ide-io.c
5e955245d6cf49c5ed26c7add7392ff5a6762bf4 23-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: always kill the whole request on error

* Use blk_rq_bytes() instead of obsolete ide_rq_bytes() in ide_kill_rq()
and ide_floppy_do_request() for failed requests.
[ bugfix part ]

* Use blk_rq_bytes() instead of obsolete ide_rq_bytes() in ide_do_devset()
and ide_complete_drive_reset(). Then remove ide_rq_bytes().
[ cleanup part ]

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/ide/ide-io.c
789547508f22e482825f52f813b59680408ec2c7 23-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix ide_kill_rq() for special ide-{floppy,tape} driver requests

Such requests should be failed with -EIO (like all other requests
in this function) instead of being completed successfully.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/ide/ide-io.c
a1317f714af7aed60ddc182d0122477cbe36ee9b 24-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: improve handling of Power Management requests

Make hwif->rq point to PM request during PM sequence and do not allow
any other types of requests to slip in (the old comment was never correct
as there should be no such requests generated during PM sequence).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
/drivers/ide/ide-io.c
f4d3ffa52a402ec9e8699571cf3811763d284459 15-Jun-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: move ack_intr() method into 'struct ide_port_ops' (take 2)

Move the ack_intr() method into 'struct ide_port_ops', also renaming it to
test_irq() while at it...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
eba8999cefb6b61704d8fa825b7694825a087765 15-Jun-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: move IRQ clearing from ack_intr() method to clear_irq() method (take 2)

There are now two methods that clear the port interrupt: ack_intr() method,
implemented only on M680x0 machines, that is called at the start of ide_intr(),
and clear_irq() method, that is called somewhat later in this function. In
order to stop this duplication, delegate the task of clearing the interrupt
to clear_irq() method, only leaving to ack_intr() the task of testing for the
port interrupt.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
53b987d5e7e8d5be3b84522149907fa7ac95526e 15-Jun-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: call clear_irq() method in ide_timer_expiry()

Now the clear_irq() method is called only from ide_intr() but ide_timer_expiry()
also should call this method in case when drive_is_ready() succeeds...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
d614aec4752f8c61b2e7cb77806b6bd59aa50836 12-Jun-2009 Linus Torvalds <torvalds@linux-foundation.org> Merge branch 'for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6

* 'for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (29 commits)
ide: re-implement ide_pci_init_one() on top of ide_pci_init_two()
ide: unexport ide_find_dma_mode()
ide: fix PowerMac bootup oops
ide: skip probe if there are no devices on the port (v2)
sl82c105: add printk() logging facility
ide-tape: fix proc warning
ide: add IDE_DFLAG_NIEN_QUIRK device flag
ide: respect quirk_drives[] list on all controllers
hpt366: enable all quirks for devices on quirk_drives[] list
hpt366: sync quirk_drives[] list with pdc202xx_{new,old}.c
ide: remove superfluous SELECT_MASK() call from do_rw_taskfile()
ide: remove superfluous SELECT_MASK() call from ide_driveid_update()
icside: remove superfluous ->maskproc method
ide-tape: fix IDE_AFLAG_* atomic accesses
ide-tape: change IDE_AFLAG_IGNORE_DSC non-atomically
pdc202xx_old: kill resetproc() method
pdc202xx_old: don't call pdc202xx_reset() on IRQ timeout
pdc202xx_old: use ide_dma_test_irq()
ide: preserve Host Protected Area by default (v2)
ide-gd: implement block device ->set_capacity method (v2)
...
734affdcae20af4fec95e46a64fb29f063a15c19 07-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_DFLAG_NIEN_QUIRK device flag

Add IDE_DFLAG_NIEN_QUIRK device flag and use it instead of
drive->quirk_list.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
9bd7de51ee8537094656149eaf45338cadb7d7d4 22-May-2009 Jens Axboe <jens.axboe@oracle.com> Merge branch 'master' into for-2.6.31

Conflicts:
drivers/ide/ide-io.c

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
4c9773ed7946fc375edba057770f5ef16d8b44fe 22-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Merge branch 'for-linus' into for-next
e3b29f05124b07303088795396ff858811d2acb8 22-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix OOPS during ide-cd error recovery

On Tuesday 19 May 2009 20:29:28 Martin Lottermoser wrote:

> hdc: cdrom_decode_status: error=0x40 <3>{ LastFailedSense=0x04 }
> ide: failed opcode was: unknown
> hdc: DMA disabled
> ------------[ cut here ]------------
> kernel BUG at drivers/ide/ide-io.c:872!

It is possible for ide-cd to ignore ide_error()'s return value under
some circumstances. Workaround it in ide_intr() and ide_timer_expiry()
by checking if there is a device/port reset pending currently.

Fixes bug #13345:

http://bugzilla.kernel.org/show_bug.cgi?id=13345

Reported-by: Martin Lottermoser <Martin.Lottermoser@t-online.de>
Reported-and-tested-by: Modestas Vainius <modestas@vainius.eu>
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
ca1b96e00ab5d1b0838965834469a0284c81a517 17-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: replace special_t typedef by IDE_SFLAG_* flags

Replace:
- special_t typedef by IDE_SFLAG_* flags
- 'special_t special' ide_drive_t's field by 'u8 special_flags' one

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
582078ee3d7dacd74a7b3fe02ea258cadf32b602 17-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge ide_disk_special() into do_special() (v2)

While at it:
- change debug printk() level to KERN_DEBUG and use __func__
- update documentation

v2:
- fix DEBUG build (noticed by Sergei)

There should be no functional changes caused by this patch.

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
5f582c8e2193e3848039de87e6a3ace7cbc7ed88 17-May-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: BUG() on unknown flags in ide_disk_special()

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
9934c8c04561413609d2bc38c6b9f268cba774a4 08-May-2009 Tejun Heo <tj@kernel.org> block: implement and enforce request peek/start/fetch

Till now block layer allowed two separate modes of request execution.
A request is always acquired from the request queue via
elv_next_request(). After that, drivers are free to either dequeue it
or process it without dequeueing. Dequeue allows elv_next_request()
to return the next request so that multiple requests can be in flight.

Executing requests without dequeueing has its merits mostly in
allowing drivers for simpler devices which can't do sg to deal with
segments only without considering request boundary. However, the
benefit this brings is dubious and declining while the cost of the API
ambiguity is increasing. Segment based drivers are usually for very
old or limited devices and as converting to dequeueing model isn't
difficult, it doesn't justify the API overhead it puts on block layer
and its more modern users.

Previous patches converted all block low level drivers to dequeueing
model. This patch completes the API transition by...

* renaming elv_next_request() to blk_peek_request()

* renaming blkdev_dequeue_request() to blk_start_request()

* adding blk_fetch_request() which is combination of peek and start

* disallowing completion of queued (not started) requests

* applying new API to all LLDs

Renamings are for consistency and to break out of tree code so that
it's apparent that out of tree drivers need updating.

[ Impact: block request issue API cleanup, no functional change ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Mike Miller <mike.miller@hp.com>
Cc: unsik Kim <donari75@gmail.com>
Cc: Paul Clements <paul.clements@steeleye.com>
Cc: Tim Waugh <tim@cyberelk.net>
Cc: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Laurent Vivier <Laurent@lvivier.info>
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Adrian McMenamin <adrian@mcmen.demon.co.uk>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Alex Dubov <oakad@yahoo.com>
Cc: Pierre Ossman <drzeus@drzeus.cx>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Cc: Stefan Weinhuber <wein@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
8f6205cd572fece673da0255d74843680f67f879 08-May-2009 Tejun Heo <tj@kernel.org> ide: dequeue in-flight request

ide generally has single request in flight and tracks it using
hwif->rq and all state handlers follow the following convention.

* ide_started is returned if the request is in flight.

* ide_stopped is returned if the queue needs to be restarted. The
request might or might not have been processed fully or partially.

* hwif->rq is set to NULL, when an issued request completes.

So, dequeueing model can be implemented by dequeueing after fetch,
requeueing if hwif->rq isn't NULL on ide_stopped return and doing
about the same thing on completion / port unlock paths. These changes
can be made in ide-io proper.

In addition to the above main changes, the following updates are
necessary.

* ide-cd shouldn't dequeue a request when issuing REQUEST SENSE for it
as the request is already dequeued.

* ide-atapi uses request queue as stack when issuing REQUEST SENSE to
put the REQUEST SENSE in front of the failed request. This now
needs to be done using requeueing.

[ Impact: dequeue in-flight request ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
34b7d2c957199834c474c9d46739265643f4d9c7 07-May-2009 Tejun Heo <tj@kernel.org> ide: cleanup rq->data_len usages

With recent unification of fields, it's now guaranteed that
rq->data_len always equals blk_rq_bytes(). Convert all direct users
to accessors.

[ Impact: convert direct rq->data_len usages to blk_rq_bytes() ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
9780e2dd8254351f6cbe11304849126b51dbd561 07-May-2009 Tejun Heo <tj@kernel.org> ide: convert to rq pos and nr_sectors accessors

ide doesn't manipulate request fields anymore and thus all hard and
their soft equivalents are always equal. Convert all references to
accessors.

[ Impact: use pos and nr_sectors accessors ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
5b93629b4509c03ffa87a9316412fedf6f58cb37 07-May-2009 Tejun Heo <tj@kernel.org> block: implement blk_rq_pos/[cur_]sectors() and convert obvious ones

Implement accessors - blk_rq_pos(), blk_rq_sectors() and
blk_rq_cur_sectors() which return rq->hard_sector, rq->hard_nr_sectors
and rq->hard_cur_sectors respectively and convert direct references of
the said fields to the accessors.

This is in preparation of request data length handling cleanup.

Geert : suggested adding const to struct request * parameter to accessors
Sergei : spotted error in patch description

[ Impact: cleanup ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Acked-by: Stephen Rothwell <sfr@canb.auug.org.au>
Tested-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Ackec-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
5ad960fe8d0e4f99fe2b8dded45e8251137293c9 19-Apr-2009 Tejun Heo <tj@kernel.org> ide: drop rq->data handling from ide_map_sg()

Impact: remove code path which is no longer necessary

All IDE data transfers now use rq->bio. Simplify ide_map_sg()
accordingly.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
/drivers/ide/ide-io.c
765139ef5f1a4b1d5cb1f1a7a12de7ee61f6500f 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-pm: don't abuse rq->data

Impact: cleanup rq->data usage

ide-pm uses rq->data to carry pointer to struct request_pm_state
through request queue and rq->special is used to carray pointer to
local struct ide_cmd, which isn't necessary. Use rq->special for
request_pm_state instead and use local ide_cmd in
ide_start_power_step().

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
/drivers/ide/ide-io.c
02e7cf8f848841ca21864ccd019e480b73c323b7 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-cd,atapi: use bio for internal commands

Impact: unify request data buffer handling

rq->data is used mostly to pass kernel buffer through request queue
without using bio. There are only a couple of places which still do
this in kernel and converting to bio isn't difficult.

This patch converts ide-cd and atapi to use bio instead of rq->data
for request sense and internal pc commands. With previous change to
unify sense request handling, this is relatively easily achieved by
adding blk_rq_map_kern() during sense_rq prep and PC issue.

If blk_rq_map_kern() fails for sense, the error is deferred till sense
issue and aborts the failed command which triggered the sense. Note
that this is a slim possibility as sense prep is done on each command
issue, so for the above condition to actually trigger, all preps since
the last sense issue till the issue of the request which would require
a sense should fail.

* do_request functions might sleep now. This should be okay as ide
request_fn - do_ide_request() - is invoked only from make_request
and plug work. Make sure this is the case by adding might_sleep()
to do_ide_request().

* Functions which access the read sense data before the sense request
is complete now should access bio_data(sense_rq->bio) as the sense
buffer might have been copied during blk_rq_map_kern().

* ide-tape updated to map sg.

* cdrom_do_block_pc() now doesn't have to deal with REQ_TYPE_ATA_PC
special case. Simplified.

* tp_ops->output/input_data path dropped from ide_pc_intr().

Signed-off-by: Tejun Heo <tj@kernel.org>
/drivers/ide/ide-io.c
d868ca24302e99a0e8a86071ca2c66273edf97d9 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-taskfile: don't abuse rq->buffer

Impact: rq->buffer usage cleanup

ide_raw_taskfile() directly uses rq->buffer to carry pointer to the
data buffer. This complicates both block interface and ide backend
request handling. Use blk_rq_map_kern() instead and drop special
handling for REQ_TYPE_ATA_TASKFILE from ide_map_sg().

Note that REQ_RW setting is moved upwards as blk_rq_map_kern() uses it
to initialize bio rw flag.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
/drivers/ide/ide-io.c
2c316bb57ad4e9f0f3de2d7ef1ae85530c2a7e69 19-Apr-2009 Tejun Heo <tj@kernel.org> ide: drop rq->data handling from ide_map_sg()

Impact: remove code path which is no longer necessary

All IDE data transfers now use rq->bio. Simplify ide_map_sg()
accordingly.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
/drivers/ide/ide-io.c
fc38b521dcffcb07447cd98fedc56f495c10b90d 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-pm: don't abuse rq->data

Impact: cleanup rq->data usage

ide-pm uses rq->data to carry pointer to struct request_pm_state
through request queue and rq->special is used to carray pointer to
local struct ide_cmd, which isn't necessary. Use rq->special for
request_pm_state instead and use local ide_cmd in
ide_start_power_step().

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
/drivers/ide/ide-io.c
5c4be57249e2e09136446597d2fe2a967c6ffef0 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-cd,atapi: use bio for internal commands

Impact: unify request data buffer handling

rq->data is used mostly to pass kernel buffer through request queue
without using bio. There are only a couple of places which still do
this in kernel and converting to bio isn't difficult.

This patch converts ide-cd and atapi to use bio instead of rq->data
for request sense and internal pc commands. With previous change to
unify sense request handling, this is relatively easily achieved by
adding blk_rq_map_kern() during sense_rq prep and PC issue.

If blk_rq_map_kern() fails for sense, the error is deferred till sense
issue and aborts the failed command which triggered the sense. Note
that this is a slim possibility as sense prep is done on each command
issue, so for the above condition to actually trigger, all preps since
the last sense issue till the issue of the request which would require
a sense should fail.

* do_request functions might sleep now. This should be okay as ide
request_fn - do_ide_request() - is invoked only from make_request
and plug work. Make sure this is the case by adding might_sleep()
to do_ide_request().

* Functions which access the read sense data before the sense request
is complete now should access bio_data(sense_rq->bio) as the sense
buffer might have been copied during blk_rq_map_kern().

* ide-tape updated to map sg.

* cdrom_do_block_pc() now doesn't have to deal with REQ_TYPE_ATA_PC
special case. Simplified.

* tp_ops->output/input_data path dropped from ide_pc_intr().

Signed-off-by: Tejun Heo <tj@kernel.org>
/drivers/ide/ide-io.c
eace4cb04c0edc9388e987bf9bbdef461f6daca4 19-Apr-2009 Tejun Heo <tj@kernel.org> ide-taskfile: don't abuse rq->buffer

Impact: rq->buffer usage cleanup

ide_raw_taskfile() directly uses rq->buffer to carry pointer to the
data buffer. This complicates both block interface and ide backend
request handling. Use blk_rq_map_kern() instead and drop special
handling for REQ_TYPE_ATA_TASKFILE from ide_map_sg().

Note that REQ_RW setting is moved upwards as blk_rq_map_kern() uses it
to initialize bio rw flag.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
/drivers/ide/ide-io.c
f505d49ffd25ed062e76ffd17568d3937fcd338c 18-Apr-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix barriers support

Freeing non-slab objects is bad and results in an oops. Fix it.

Reported-and-tested-by: Andrew Price <andy@andrewprice.me.uk>
Cc: Theodore Tso <tytso@mit.edu>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3153c26b54230d025c6d536e8d3015def4524906 08-Apr-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: refactor tf_read() method

Simplify tf_read() method, making it deal only with 'struct ide_taskfile' and
the validity flags that the upper layer passes, and factoring out the code that
deals with the high order bytes into ide_tf_readback() to be called from the
only two functions interested, ide_complete_cmd() and ide_dump_sector().

This should stop the needless code duplication in this method and so make
it about twice smaller than it was; along with simplifying the setup for
the method call, this should save both time and space...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
745483f10c6cefb303007c6873e2bfce54efa8ed 08-Apr-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: simplify 'struct ide_taskfile'

Make 'struct ide_taskfile' cover only 8 register values and thus put two such
fields ('tf' and 'hob') into 'struct ide_cmd', dropping unnecessary 'tf_array'
field from it.

This required changing the prototype of ide_get_lba_addr() and ide_tf_dump().

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
[bart: fix setting of ATA_LBA bit for LBA48 commands in __ide_do_rw_disk()]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
60f85019c6c8c1aebf3485a313e0da094bc95d07 08-Apr-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: replace IDE_TFLAG_* flags by IDE_VALID_*

Replace IDE_TFLAG_{IN|OUT}_* flags meaning to the taskfile register validity on
input/output by the IDE_VALID_* flags and introduce 4 symmetric 8-bit register
validity indicator subfields, 'valid.{input/output}.{tf|hob}', into the 'struct
ide_cmd' instead of using the 'tf_flags' field for that purpose (this field can
then be turned from 32-bit into 8-bit one).

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
fdd88f0af616db59a6a36bdf0185181d2b779f53 31-Mar-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: inline SELECT_DRIVE()

Since SELECT_DRIVE() has boiled down to a mere dev_select() method call, it now
makes sense to just inline it...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
35218d1ca808ed19b8c6f079ce91872b3deb2219 31-Mar-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: move data register access out of tf_{read|load}() methods (take 2)

Move IDE_FTFLAG_{IN|OUT}_DATA flag handling out of tf_{read|load}() methods
into the only two functions where these flags actually need to be handled:
do_rw_taskfile() and ide_complete_cmd()...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
ecf3a31d2a08a419bdf919456f1724f5b72bde2c 31-Mar-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: turn set_irq() method into write_devctl() method

Turn set_irq() method with its software reset hack into write_devctl() method
(for just writing a value into the device control register) at last...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
9010941c5483a7a5bb1f7d97ee62491fb078bb51 31-Mar-2009 Elias Oltmanns <eo@nebensachen.de> ide: Fix code dealing with sleeping devices in do_ide_request()

Unfortunately, I missed a catch when reviewing the patch committed as
201bffa4. Here is the fix to the currently broken handling of sleeping
devices. In particular, this is required to get the disk shock
protection code working again.

Reported-by: Christian Thaeter <ct@pipapo.org>
Cc: stable@kernel.org
Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
bf717c0a2e18dbe82eeb28e57b0abede3cdf45d6 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: keep track of number of bytes instead of sectors in struct ide_cmd

* Pass number of bytes instead of sectors to ide_init_sg_cmd().

* Pass number of bytes to process to ide_pio_sector() and rename
it to ide_pio_bytes().

* Rename ->nsect field to ->nbytes in struct ide_cmd and use
->nbytes, ->nleft and ->cursg_ofs to keep track of number of
bytes instead of sectors.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
60c0cd02b254805691cdc61101ada6af7bd56fde 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: set hwif->expiry prior to calling [__]ide_set_handler()

* Set hwif->expiry prior to calling [__]ide_set_handler()
and drop 'expiry' argument.

* Set hwif->expiry to NULL in ide_{timer_expiry,intr}()
and remove 'hwif->expiry = NULL' assignments.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
2298169418f43ba5e0919762a4bab95a1227872a 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass command to ide_map_sg()

* Set IDE_TFLAG_WRITE flag and ->rq also for ATA_CMD_PACKET
commands.

* Pass command to ->dma_setup method and update all its
implementations accordingly.

* Pass command instead of request to ide_build_sglist(),
*_build_dmatable() and ide_map_sg().

While at it:

* Fix scc_dma_setup() documentation + use ATA_DMA_WR define.

* Rename sgiioc4_build_dma_table() to sgiioc4_build_dmatable(),
change return value type to 'int' and drop unused 'ddir'
argument.

* Do some minor cleanups in [tx4939]ide_dma_setup().

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
130e886708d6e11f3d54e5d27c266578de56f343 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_end_request()

* Add ide_rq_bytes() helper.

* Add blk_noretry_request() quirk to ide_complete_rq() (currently only fs
requests can be marked as "noretry" so there is no change in behavior).

* Switch current ide_end_request() users to use ide_complete_rq().

[ No need to check for rq->nr_sectors == 0 in {ide_dma,task_pio}_intr(),
nsectors == 0 in cdrom_end_request() and err == 0 in ide_do_devset(). ]

* Remove no longer needed ide_end_request().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
ba7d479c36dde12821c01ad0696d678635b8fb92 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ide_end_rq() in ide_complete_rq()

This results in PIO->DMA retry being triggered also on completion
of requests using ide_complete_rq() instead of ide_end_request().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
f974b196f58fe042c7b2b4c0ee15d5a6112dbf40 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass number of bytes to complete to ide_complete_rq()

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
a9587fd8c48415cc93fef7f4ba7748a5d3477e7b 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove BUG() from ide_complete_rq()

It is no longer needed so remove it, also while at it dequeue the request
only on blk_end_request() success and make ide_complete_rq() return an error
value.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
89f78b3261f7e331e41753ea2459fbb9b60a6f7a 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move rq->errors quirk out from ide_end_request()

Move rq->errors quirk out from ide_end_request() to its call sites.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
6902a5331256e1b9f4cef95a1e3622252113b260 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass error value to ide_complete_rq()

Set rq->errors at ide_complete_rq() call sites and then pass
error value to ide_complete_rq().

[ Some rq->errors assignments look really wrong but this patch
leaves them alone to not introduce too many changes at once. ]

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
37245aabfa0c628ba884cd88fe5cd633b426a1b2 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: sanitize ide_end_rq()

* Move 'uptodate' quirk from ide_end_rq() to its users.

* Move quirks for blk_noretry_request() and !blk_fs_request()
requests from ide_end_rq() to ide_end_request().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1caf236dafb7291f9fdfe54b12dd945aec0dca03 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_end_rq() (v2)

* Move request dequeuing from __ide_end_request() to ide_end_request().

* Rename __ide_end_request() to ide_end_rq() and export it.

* Fix ide_end_rq() to pass original blk_end_request() return value.

* ide_end_dequeued_request() is used only in cdrom_end_request()
so inline it there and then remove the function.

v2:
* Remove needless BUG_ON() while at it (start_request()'s one is enough).

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1713788ff8e191de5da707ed8144698b32771f99 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_special_rq() BUG() on unknown requests

If unknown request reaches this function something is _seriously_ wrong.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e7fedc3ca0b8fcd3350a40c42a7100a9539e6c4a 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ide_complete_cmd() for head unload commands

Move handling of head unload commands from task_no_data_intr()
to ide_complete_cmd() and then use ide_complete_cmd() also for
head unload commands.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
0dfb991c6943c810175376b58d1c29cfe532541b 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ata_tf_protocols enums

* Add IDE_TFLAG_MULTI_PIO taskfile flag and set it for commands
using multi-PIO protocol.

* Use ata_tf_protocols enums instead of TASKFILE_* defines to
denote command's protocol and then rename ->data_phase field
to ->protocol.

* Remove no longer needed <linux/hdreg.h> includes.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
b6308ee0c55acd2e943d849773c9f0a49c516317 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move command related fields from ide_hwif_t to struct ide_cmd

* Move command related fields from ide_hwif_t to struct ide_cmd.

* Make ide_init_sg_cmd() take command and sectors number as arguments.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
22aa4b32a19b1f231d4ce7e9af6354b577a22a35 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_task_t typedef

While at it:
- rename struct ide_task_s to struct ide_cmd
- remove stale comments from idedisk_{read_native,set}_max_address()
- drop unused 'cmd' argument from ide_{cmd,task}_ioctl()
- drop unused 'task' argument from tx4939ide_tf_load_fixup()
- rename ide_complete_task() to ide_complete_cmd()
- use consistent naming for struct ide_cmd variables

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3ee38302ffc63da93eb0313053a990bb3466e275 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->end_request method

* Handle completion of private driver requests explicitly
for ide_floppy and ide_tape media in ide_kill_rq().

* Remove no longer needed ->end_request method.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
c152cc1a90f9680cefa74d9ff9ce36038081ba72 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ->end_request only for private device driver requests

* Move IDE{FLOPPY,TAPE}_ERROR_* defines to <linux/ide.h> and rename them
to IDE_DRV_ERROR_*.

* Handle ->end_request special cases for floppy/tape media in ide_kill_rq().

* Call ->end_request only for private device driver requests.

There should be no functional changes caused by this patch.

Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e3d9a73a83d98fc466dabdcfe4f4e7e4419e3f8e 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->data_phase field from ide_hwif_t

* Always use hwif->task->data_phase and remove ->data_phase
field from ide_hwif_t.

* Remove superfluous REQ_TYPE_ATA_TASKFILE check from
ide_pio_datablock() while at it.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
5e76acd588c125fbd37390e44868dcb07cadbe4a 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: no need to read Status and Error registers for "empty" taskfile requests

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
a09485df9cda49fbde2766c86eb18a9cae585162 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move request type specific code from ide_end_drive_cmd() to callers (v3)

* Move request type specific code from ide_end_drive_cmd() to callers.

* Remove stale ide_end_drive_cmd() documentation and drop no longer
used 'stat' argument. Then rename the function to ide_complete_rq().

v2:
* Fix handling of blk_pm_request() requests in task_no_data_intr().

v3:
* Some ide_no_data_taskfile() users (HPA code and HDIO_DRIVE_* ioctls
handlers) access original command later so we need to update it in
ide_complete_task().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e120237c0e4d9a83c1380f5ff7b5f2ba31f1c820 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: factor out completion of taskfile from ide_end_drive_cmd()

Factor out completion of taskfile from ide_end_drive_cmd()
to ide_complete_task().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3616b6536a74ff1c56029c17cbb3575c69c0a574 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: complete power step in ide_complete_pm_request()

* Complete power step in ide_complete_pm_request().

* Rename ide_complete_pm_request() to ide_complete_pm_rq().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
255115fb35f80735c21a1cbe9809e9795a3af26e 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: allow host drivers to specify IRQ flags

* Add ->irq_flags field to struct ide_port_info and struct ide_host.

* Update host drivers and IDE PCI code to use ->irq_flags field.

* Convert init_irq() and ide_intr() to use host->irq_flags.

This fixes handling of shared IRQs for non-PCI hosts
and removes ugly ifdeffery from core IDE code.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e354c1d8033d97a97a38a1b2cffa1bc285b92ad4 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_ARCH_LOCK (v2)

* Add ->{get,release}_lock methods to struct ide_port_info
and struct ide_host.

* Convert core IDE code, m68k IDE code and falconide support to use
->{get,release}_lock methods instead of ide_{get,release}_lock().

* Remove IDE_ARCH_LOCK.

v2:
* Build fix from Geert updating ide_{get,release}_lock() callers in
falconide.c.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michael Schmitz <schmitz@debian.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
d15a613ba01ff2b209ecad7a38ccbb23b3b06c92 27-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_ARCH_INTR (v2)

This micro-optimization is not worth it. Just always check for
existence of ->ack_intr method in ide_intr() and ide_timer_expiry().

v2:
Fix brown-paper-bag bug spotted by David D. Kilzer.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michael Schmitz <schmitz@debian.org>
Cc: "David D. Kilzer" <ddkilzer@kilzer.net>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
327fa1c29466b8fe471a91fc11e9c6171163c81a 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move error handling code to ide-eh.c (v2)

Do some CodingStyle fixups in <linux/ide.h> while at it.

v2:
Add missing <linux/delay.h> include (reported by Stephen Rothwell).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
11938c929022bb92b1a42f5e1289524a1e465dc0 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move device settings code to ide-devsets.c

Remove stale comment from ide.c while at it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
c4e66c36cce3f23d68013c4112013123ffe80bdb 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_do_park_unpark() to ide-park.c

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1bc6daae4aba9194f8ff6801af8367a1a4718965 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: factor out processing of special commands from ide_special_rq()

Factor out processing of special commands from ide_special_rq()
to ide_do_devset() and ide_do_park_unpark().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1866082339597930c5b77aad8de34ab4fbb5724f 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_do_drive_cmd()

* Use elv_add_request() instead of __elv_add_request() in ide_do_drive_cmd().

* ide_do_drive_cmd() is used only in ide-{atapi,cd}.c so inline it there.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
65ca5377322c7543163066f373ae9e6b0ad8de8a 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_dma_timeout_retry() to ide-dma.c

Move ide_dma_timeout_retry() to ide-dma.c and add static inline
version for CONFIG_BLK_DEV_IDEDMA=n.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
b6a45a0b1e9a358b81201659cf87b023e3ec73e0 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move drive_is_ready() to ide-io.c

Move drive_is_ready() to ide-io.c, then make it static.

Also make some minor CodingStyle fixups while at it.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
75a0cff4e8ed47584dd15fbde2172ebc4c051bb2 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: unexport ide_devset_execute()

There are no modular ide_devset_execute() users left so unexport it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
7a254df007b3db88bd430474030fec92e7bab22a 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_pktcmd_tf_load() to ide-atapi.c

Then make it static and remove 'dma' argument.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
849d7130001ab740a5a4778a561049841fdd77c9 05-Mar-2009 Stanislaw Gruszka <stf_xl@wp.pl> ide: allow to wrap interrupt handler

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Cc: Andrew Victor <linux@maxim.org.za>
[bart: minor checkpatch.pl / CodingStyle fixups]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e0c6dcd8d4257a129fc813ac68f20b77c6ae2a7a 05-Mar-2009 Roel Kluin <roel.kluin@gmail.com> ide: expiry() returns int, negative expiry() return values won't be noticed

bart:
It seems like the bug could cause insanely long timeouts for:
- ATA_DMA_ERR error in dma_timer_expiry()
- commands without ->expiry in tc86c001_timer_expiry()
(TC86C001 IDE controller only)

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
[bart: port it to the current tree]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
9e772d0135a5b5f8355320be429efa339700d52d 02-Feb-2009 Borislav Petkov <petkovbb@googlemail.com> ide-cd: fix DMA for non bio-backed requests

This one fixes http://bugzilla.kernel.org/show_bug.cgi?id=12320.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
c38714ed4447874db1e06908f713fe65afba4a85 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove now redundant ->cur_dev checks

* ->cur_dev should now be always valid if ->handler is set so
remove redundant checks from ide_intr() and ide_timer_expiry().

* Apply CodingStyle fixups in ide_timer_expiry() while at it.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
b1b1cd9a23dfa9b33267519ee7c228da708ddaf6 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove superfluous hwif variable assignment from ide_timer_expiry()

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
9600dcf1347d304cf4dff34ef50569d6584b6968 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make "paranoia" ->handler check in ide_intr() more strict

If ->handler is set while it shouldn't be it indicates deep problems
so BUG_ON()-ning and preventing further damage is much more appropriate
than merely printing an error message.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
627e05daa10896a8f012fa78e8434c07e9e55ea7 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->error method from struct ide_driver

* Remove (now superfluous) ->error method from struct ide_driver.

* Unexport __ide_error() and make it static.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
7f3c868ba78e486bd9d7569f884dd46d8f59bb18 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_driver_t typedef

While at it:
- s/struct ide_driver_s/struct ide_driver/
- use to_ide_driver() macro in ide-proc.c

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
898ec223fea2a2df88035e58dbf50f493577e225 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove HWIF() macro

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
b65fac32cfe3b2f98cd472fef400bd1c1340de23 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge ide_hwgroup_t with ide_hwif_t (v2)

* Merge ide_hwgroup_t with ide_hwif_t.

* Cleanup init_irq() accordingly, then remove no longer needed
ide_remove_port_from_hwgroup() and ide_ports[].

* Remove now unused HWGROUP() macro.

While at it:

* ide_dump_ata_error() fixups

v2:
* Fix ->quirk_list check in do_ide_request()
(s/hwif->cur_dev/prev_port->cur_dev).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
5b31f855f10d0053e738baa6d91fb6a3fad35119 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use lock bitops for ports serialization (v2)

* Add ->host_busy field to struct ide_host and use it's first bit
together with lock bitops to provide new ports serialization method.

* Convert core IDE code to use new ide_[un]lock_host() helpers.

This removes the need for taking hwgroup->lock if host is already
busy on serialized hosts and makes it possible to merge ide_hwgroup_t
into ide_hwif_t (done in the later patch).

* Remove no longer needed ide_hwgroup_t.busy and ide_[un]lock_hwgroup().

* Update do_ide_request() documentation.

v2:
* ide_release_lock() should be called inside IDE_HFLAG_SERIALIZE check.

* Add ide_hwif_t.busy flag and ide_[un]lock_port() for serializing
devices on a port.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
efe0397eef544ac4bcca23d39aa8d5db154952e0 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove hwgroup->hwif and {drive,hwif}->next

* Add 'int port_count' field to ide_hwgroup_t to keep the track
of the number of ports in the hwgroup. Then update init_irq()
and ide_remove_port_from_hwgroup() to use it.

* Remove no longer needed hwgroup->hwif, {drive,hwif}->next,
ide_add_drive_to_hwgroup() and ide_remove_drive_from_hwgroup()
(hwgroup->drive now only denotes the currently active device
in the hwgroup).

* Update locking documentation in <linux/ide.h>.

While at it:

* Rename ->drive field in ide_hwgroup_t to ->cur_dev.

* Use __func__ in ide_timer_expiry().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
ae86afaee6a1c77c7a06d81dcc3bf872204d3bec 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use per-port IRQ handlers

Use hwif instead of hwgroup as {request,free}_irq()'s cookie,
teach ide_intr() to return early for non-active serialized ports,
modify unexpected_intr() accordingly and then use per-port IRQ
handlers instead of per-hwgroup ones.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
bd53cbcce501b61921a1af2dddfa87c5b9923dfd 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->cur_port to struct ide_host and use it for serialized hosts

* Pass 'ide_hwif_t *' instead of 'ide_hwgroup_t *' to unexpected_intr().

* Cache pointer to the port currently being serviced in ->cur_port
and use it instead of hwif->hwgroup on serialized hosts.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
42cf2611b28602cf4c9dc7c22bc8653a10dff60d 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix setting nIEN on idle devices

Fix do_ide_request() to operate on previous device / port instead of
the current one. The original code was wrong since at least Feb 2002
(2.4.0 timeframe).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
b46f205da647608a4064ce0a0acb07a8c74c6f23 06-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix LOCKDEP warning

commit 295f00042aaf6b553b5f37348f89bab463d4a469 ("ide: don't execute
the next queued command from the hard-IRQ context") overlooked that
ide_do_drive_cmd() (used for REQUEST SENSE command handling) may still
invoke do_ide_request() (->request_fn) in the hard-IRQ context through
blk_start_queueing(). This resulted in a LOCKDEP warning after commit
b599bc7a1199419e122cb2e9ec6b0fa2cfbbc17b ("ide: use per-device request
queue locks (v2)").

Since calling blk_start_queuing() in ide_do_drive_cmd() doesn't make
much sense as the port is already marked as busy (so the execution of
the new command will be deferred anyway) then just remove it fixing
LOCKDEP warning and saving some CPU cycles at the same time.

Reported-and-tested-by: Larry Finger <Larry.Finger@lwfinger.net>
Reported-by: Grissiom <chaos.proton@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
5317464dccd0c03026d60f1e9968de4f9cd23f69 02-Jan-2009 Borislav Petkov <petkovbb@googlemail.com> ide: remove the last ide-scsi remnants

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
201bffa46466b4afdf7d29db8eca3fa5decb39c8 02-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use per-device request queue locks (v2)

* Move hack for flush requests from choose_drive() to do_ide_request().

* Add ide_plug_device() helper and convert core IDE code from using
per-hwgroup lock as a request lock to use the ->queue_lock instead.

* Remove no longer needed:
- choose_drive() function
- WAKEUP() macro
- 'sleeping' flag from ide_hwif_t
- 'service_{start,time}' fields from ide_drive_t

This patch results in much simpler and more maintainable code
(besides being a scalability improvement).

v2:
* Fixes/improvements based on review from Elias:
- take as many requests off the queue as possible
- remove now redundant BUG_ON()

Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
631de3708d595d153e8a510a3608689290f4c0ed 02-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_[un]lock_hwgroup() helpers

Add ide_[un]lock_hwgroup() inline helpers for obtaining exclusive
access to the given hwgroup and update the core code accordingly.

[ This change besides making code saner results in more efficient
use of ide_{get,release}_lock(). ]

Cc: Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
b2cfb05a701809abee591265a198afa029d68bff 02-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove "paranoia" checks for hwgroup->busy

Remove "paranoia" checks for hwgroup->busy from ide_timer_expiry()
and ide_intr(). This is a preparation for future changes.

Cc: Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
2fb211502e2c0513e12d677ed4d7891f3c5e1413 02-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE PM hack from do_ide_request()

We now tell block layer that there is still work to do using
blk_plug_device() so hack for IDE Power Management can be removed
(it was buggy for hwgroups having more than 4 devices anyway).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
295f00042aaf6b553b5f37348f89bab463d4a469 02-Jan-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: don't execute the next queued command from the hard-IRQ context (v2)

* Tell the block layer that we are not done handling requests by using
blk_plug_device() in ide_do_request() (request handling function)
and ide_timer_expiry() (timeout handler) if the queue is not empty.

* Remove optimization which directly calls ide_do_request() for the next
queued command from the ide_intr() (IRQ handler) and ide_timer_expiry().

* Remove no longer needed IRQ masking from ide_do_request() - in case of
IDE ports needing serialization disable_irq_nosync()/enable_irq() was
used for the (possibly shared) IRQ of the other IDE port.

* Put the misplaced comment in the right place in ide_do_request().

* Drop no longer needed 'int masked_irq' argument from ide_do_request().

* Merge ide_do_request() into do_ide_request().

* Remove no longer needed IDE_NO_IRQ define.

While at it:

* Don't use HWGROUP() macro in do_ide_request().

* Use __func__ in ide_intr().

This patch reduces IRQ hadling latency for IDE and improves the system-wide
handling of shared IRQs (which should result in more timeout resistant and
stable IDE systems). It also makes it possible to do some further changes
later (i.e. replace some busy-waiting delays with sleeping equivalents).

v2:
Changes per review from Elias Oltmanns:
- fix wrong goto statement in 'if (startstop == ide_stopped)' block
- use spin_unlock_irq()
- don't use obsolete HWIF() macro

Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e2984c628c924442132304ae662da433f41c05c9 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move Power Management support to ide-pm.c

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
b002415012f518e6940fabb77e35f0fb21b3640d 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove redundant code from ide_end_drive_cmd()

rq->errors is overwritten later in this function.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
f58c1ab8deebc2360cef998f169a6727c288210f 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: always set nIEN on idle devices

* Set nIEN for previous port/device in ide_do_request()
also if port uses a non-shared IRQ.

* Remove no longer needed ide_hwif_t.sharing_irq.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
46aa7af1d6bf46d0973dc9e8f13275f2c001d3dd 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix ->quirk_list checking in ide_do_request()

Fix nIEN quirk check to also omit quirky devices using pdc202xx_{new,old}
host drivers for which ->quirk_list == 2.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
08cd1dca00f7c84c8b30c2726e078529d4ebc93f 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: cleanup ide_do_request()

Both choose_drive() and PM handling code make sure that the queue
is unplugged so no need to check it again.

Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
2a2ca6a96194c4744a2adeefbc09ce881f3c5abe 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: replace the global ide_lock spinlock by per-hwgroup spinlocks (v2)

Now that (almost) all host drivers have been fixed not to abuse ide_lock
and core code usage of ide_lock has been sanitized we may safely replace
ide_lock by per-hwgroup locks.

This patch is partially based on earlier patch from Ravikiran G Thirumalai.

While at it:
- don't use deprecated HWIF() and HWGROUP() macros
- update locking documentation in ide.h

v2:
Add missing spin_lock_init(&hwgroup->lock). (Noticed by Elias Oltmanns)

Cc: Vaibhav V. Nivargi <vaibhav.nivargi@gmail.com>
Cc: Alok N. Kataria <alokk@calsoftinc.com>
Cc: Shai Fultheim <shai@scalex86.org>
Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Cc: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
6ea52226ca131a99bb619bd56fbeee566ea5a966 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use queue lock instead of ide_lock when possible

This is just a preparation for future changes and there should be no
functional changes caused by this patch since ide_lock is currently
also used as queue lock.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3c8a2cce47c6813383c9e38134e31f7e5f72e9d8 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ide_lock + __blk_end_request() -> blk_end_request()

Use blk_end_request() instead of ide_lock + __blk_end_request()
in cdrom_end_request(), cdrom_newpc_intr(), __ide_end_request(),
ide_complete_pm_request() and ide_end_drive_cmd().

[ ide_lock is currently also used as queue lock ]

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
a72b2147ec9e77be68308ba06190603550d1cb61 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: push ide_lock to __ide_end_request()

__ide_end_request() needs ide_lock only for __blk_end_request()
call so push ide_lock taking inside __ide_end_requests().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1d0bf587df5b17bb93b32d760171417883ca907f 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ide_hwgroup_t.rq doesn't need an ide_lock held

While at it:
- no need to check for hwgroup presence in ide_dump_opcode()

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3e0e29f7373ec96a1bd972790649524af7353f42 29-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: unify ide_intr()'s exit points

Just a preparation for future changes.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1a659880ee755d96eeabe64bded059abed6d5ef5 08-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Revert "ide: respect current DMA setting during resume"

This reverts commit e9eb8388306364295308132265c00bea685f409f since
it could break resume (thanks to Paul Collins for the report).

I'll look into sorting this out properly for 2.6.29
but for 2.6.28 it is the best to just revert my patch.

Reported-by: Paul Collins <paul@burly.ondioline.org>
Cc: rjw@sisk.pl
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
6b7d8fc36272169d1d07a07174f2c8a7909c025e 02-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix build for DEBUG_PM

Also while at it:

* Drop unused arguments from ide_complete_power_step().

* Move DEBUG_PM printk() from ide_end_drive_cmd() to
ide_complete_power_step().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e9eb8388306364295308132265c00bea685f409f 02-Dec-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: respect current DMA setting during resume

Respect current DMA setting during resume, otherwise PIO timings
may get destroyed if host uses shared PIO/MWDMA timings.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
f9e3326dce0ef117308872cd234b903aa19aa40f 02-Dec-2008 Michael Schmitz <schmitz@biophys.uni-duesseldorf.de> ide: fix the ide_release_lock imbalance

ide_release_lock() spits out lots of:

ide_release_lock: bug

warnings on Atari Falcon.

Fix the ide_release_lock imbalance.

Signed-off-by: Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
f73e2d13a16cc88c4faa4729967f92bfeec8a142 17-Oct-2008 Jens Axboe <jens.axboe@oracle.com> block: remove __generic_unplug_device() from exports

The only out-of-core user is IDE, and that should be using
blk_start_queueing() instead.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
4abdc6ee7c47a1a6e12f95717e461baeebee5df7 13-Oct-2008 Elias Oltmanns <eo@nebensachen.de> ide: Implement disk shock protection support (v4)

On user request (through sysfs), the IDLE IMMEDIATE command with UNLOAD
FEATURE as specified in ATA-7 is issued to the device and processing of
the request queue is stopped thereafter until the specified timeout
expires or user space asks to resume normal operation. This is supposed
to prevent the heads of a hard drive from accidentally crashing onto the
platter when a heavy shock is anticipated (like a falling laptop expected
to hit the floor). Port resets are deferred whenever a device on that
port is in the parked state.

v3:
Elias Oltmanns <eo@nebensachen.de> wrote:
[...]
> >> 1. Make sure that no negative value is being passed to
> >> jiffies_to_msecs() in ide_park_show().
> >> 2. Drop the superfluous variable hwif in ide_special_rq().
> >> 3. Skip initialisation of task and tf in ide_special_rq() if we are not
> >> handling a (un)park request.
> >
> > Well, #3 should have been done differently because we donn't want to
> > check for REQ_(UN)?PARK_HEADS more often than is necessary.
>
> While preparing the backport to 2.6.27, it has just occurred to me that
> we need to clear the IDE_DFLAG_PARKED flag in ide_disk_pre_reset()
> because this flag must not be set after *any* sort of access to the
> device.

v4:
Fix a memory leak due to a missing blk_put_request() in
issue_park_cmd(). Additionally, we should plug the queue when enqueueing
the unpark request because there is no guarantee that the park timeout
has not expired by then. Even though the chance for that to happen is
very slim, the request might end up hanging in the queue until the next
I/O operation is queued up. While at it, clean up the code a little:
- make issue_park_cmd() a function of type void since nobody cares for
the return value anyway;
- use blk_start_queueing() instead of __blk_run_queue() since we don't
have to worry about recursion;
- remove a superfluous pointer deference in task_no_data_intr().

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
Cc: Jeff Garzik <jeff@garzik.org>,
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e415e495f8294e536e09e6a15fba897cce4c0748 13-Oct-2008 Elias Oltmanns <eo@nebensachen.de> ide: Two fixes regarding memory allocation

In function ide_devset_execute() we should use __GFP_WAIT rather than
GFP_KERNEL. Also, the allocation cannot possibly fail at that point.
More importantly, there is a potential memory leak in the device probing
code. The infrastructure seems rather complex and I hope I haven't messed
anything up by trying to fix this.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
[bart: remove superfluous ide_lock taking]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
bfa7d8e55f0c5ae22ef57eb22942c74fdde7b9bd 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ->ide_dma_clear_irq() -> ->clear_irq()

* Rename ->ide_dma_clear_irq method to ->clear_irq
and move it from ide_hwif_t to struct ide_port_ops.

* Move ->waiting_for_dma check inside ->clear_irq method.

* Move ->dma_base check inside ->clear_irq method.

piix.c:
* Add ich_port_ops and remove init_hwif_ich() wrapper.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
6982daf71ca9a0b0c36043315e1968b3cb709b7c 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: convert 'pio_mode' device setting to use DS_SYNC flag

* Convert 'pio_mode' device setting to use DS_SYNC flag.

* Remove unused special_t.b.{set_tune,serviced} and ide_drive_t.tune_req.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
7f612f272ad8abe82411f368bfacf793b466e1b3 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove [ata_]select_t

* Use 'drive->dn & 1' in ide_init_disk().

* remove [ata_]select_t.

While at it:

* Use ATA_DEVICE_OBS define in ide_port_init_devices_data().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
0d346ba0730d84f04022f9f984d3f606f69cef37 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: sanitize ide*_pm_* enums

* Move ide*_pm_* enums from ide-io.c to <linux/ide.h>.

* idedisk_pm_* -> ide_pm_*

* ide_pm_state_* -> ide_pm_*

* No need to set ide_pm_* enums to the fixed values.

* Uppercase ide_pm_* enums.

* Fix/update comments.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
d1d76714e2f0c520b6c2a84ab5b050d0b3244949 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix HDIO_DRIVE_TASK[FILE] ioctls for CHS commands on LBA devices

Add IDE_DFLAG_LBA device flag and use it instead of ->select.b.lba.

Since ->tf_load uses ->select.all for ATA Device/Head register this
fixes HDIO_DRIVE_TASK[FILE] ioctls for CHS commands on LBA devices.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
c39220483ebe6871fb129d4b2236cd95290c41fc 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: DMA_PIO_RETRY -> IDE_DFLAG_DMA_PIO_RETRY

Add IDE_DFLAG_DMA_PIO_RETRY and use it instead of
ide_drive_t.state + DMA_PIO_RETRY.

There should be no functional changes cause by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
97100fc816badbbc162644cfde7ad39ae9211fb4 13-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add device flags

Add 'unsigned long dev_flags' to ide_drive_t and convert bitfields
to IDE_DFLAG_* flags.

While at it:
- IDE_DFLAG_ADDRESSING -> IDE_DFLAG_LBA48
- fixup some comments
- remove needless g->flags zeroing from ide*_probe()

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
92f1f8fd8040e7b50a67a850a935509bb01201bb 10-Oct-2008 Elias Oltmanns <eo@nebensachen.de> ide: Remove ide_spin_wait_hwgroup() and use special requests instead

Use a special request for serialisation purposes and get rid of the
awkward ide_spin_wait_hwgroup(). This also involves converting the
ide_devset structure so it can be shared by the /proc and the ioctl code.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
[bart: use rq->cmd[] directly]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
ff2779b568e70822e0ef2cc7afeeefbe7c607652 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ide_id_has_flush_cache_ext() -> ata_id_flush_ext_enabled()

* Add ata_id_flush_ext_enabled() inline helper to <linux/ata.h>.

* ide_id_has_flush_cache_ext() -> ata_id_flush_ext_enabled()

The latter one also checks if the command is marked as
supported in word 83 and validity of words 83 & 86.

Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
4b58f17d7c45a8e5f4acda641bec388398b9c0fa 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ide_id_has_flush_cache() -> ata_id_flush_enabled()

* Add ata_id_flush_enabled() inline helper to <linux/ata.h>.

* ide_id_has_flush_cache() -> ata_id_flush_enabled()

The latter one also checks if the command is marked as
supported in word 83 and validity of words 83 & 86.

Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3ceca727fe3a38dd8d7a3adf938fefda83eee8af 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: include <linux/hdreg.h> only when needed

* Include <linux/ata.h> directly in <linux/ide.h>
instead of through <linux/hdreg.h>.

* Include <linux/hdreg.h> only when needed.

Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3c619ffd48d7fdb3b17f0df67c4eb4b0bd80e253 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove no longer needed ide_drive_t fields

Remove ->remap_0_to_1 and ->sect0 (they are always zero now).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3a7d24841ad794ae64c90d7d00d62a83741912aa 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ATA_* defines instead of *_STAT and *_ERR ones

* ERR_STAT -> ATA_ERR
* INDEX_STAT -> ATA_IDX
* ECC_STAT -> ATA_CORR
* DRQ_STAT -> ATA_DRQ
* SEEK_STAT -> ATA_DSC
* WRERR_STAT -> ATA_DF
* READY_STAT -> ATA_DRDY
* BUSY_STAT -> ATA_BUSY

* MARK_ERR -> ATA_AMNF
* TRK0_ERR -> ATA_TRK0NF
* ABRT_ERR -> ATA_ABORTED
* MCR_ERR -> ATA_MCR
* ID_ERR -> ATA_IDNF
* MC_ERR -> ATA_MC
* ECC_ERR -> ATA_UNC
* ICRC_ERR -> ATA_ICRC

* BBD_ERR -> ATA_BBK

Also:

* ILI_ERR -> ATAPI_ILI
* EOM_ERR -> ATAPI_EOM
* LFS_ERR -> ATAPI_LFS

* CD -> ATAPI_COD
* IO -> ATAPI_IO

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
aaaade3f059fa1b57283d4a7c8351a42ec747bf0 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: WIN_* -> ATA_CMD_*

* Use ATA_CMD_* defines instead of WIN_* ones.

While at it:

* EXABYTE_ENABLE_NEXT -> ATA_EXABYTE_ENABLE_NEST

* SETFEATURES_{EN,DIS}_WCACHE -> SETFEATURES_WC_{ON,OFF}

* SETFEATURES_{EN,DIS}_AAM -> SETFEATURES_AAM_{ON,OFF}

* SMART_* -> ATA_SMART_*

* Remove stale comment from ide-proc.c.

Partially based on earlier work by Chris Wedgwood.

Acked-by: Chris Wedgwood <cw@f00f.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
f8881000d7cc6b8b520e8fcba95177d2cde1ae36 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove superfluous check from ide_disk_special()

This condition is checked by both ide_disk_init_mult_count()
and set_multcount() so no need to do it again in ide_disk_special().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
374e042c3e767ac2e5a40b78529220e0b3de793c 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_tp_ops (take 2)

* Add struct ide_tp_ops for transport methods.

* Add 'const struct ide_tp_ops *tp_ops' to struct ide_port_info
and ide_hwif_t.

* Set the default hwif->tp_ops in ide_init_port_data().

* Set host driver specific hwif->tp_ops in ide_init_port().

* Export ide_exec_command(), ide_read_status(), ide_read_altstatus(),
ide_read_sff_dma_status(), ide_set_irq(), ide_tf_{load,read}()
and ata_{in,out}put_data().

* Convert host drivers and core code to use struct ide_tp_ops.

* Remove no longer needed default_hwif_transport().

* Cleanup ide_hwif_t from methods that are now in struct ide_tp_ops.

While at it:

* Use struct ide_port_info in falconide.c and q40ide.c.

* Rename ata_{in,out}put_data() to ide_{in,out}put_data().

v2:

* Fix missing convertion in ns87415.c.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
6e6afb3b7401f0181da74a1add57f126946b43e6 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->set_irq method

Add ->set_irq method for setting nIEN bit of ATA Device Control
register and use it instead of ide_set_irq().

While at it:

* Use ->set_irq in init_irq() and do_reset1().

* Don't use HWIF() macro in ide_check_pm_state().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
b73c7ee25da6133f97f47ffd3557288417da7c76 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->read_status method

* Remove ide_read_status() inline helper.

* Add ->read_status method for reading ATA Status register
and use it instead of ->INB.

While at it:

* Don't use HWGROUP() macro.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
c6dfa867bb45f4bff2e48f3bc89ab1d6a7ab4c21 23-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->exec_command method

Add ->exec_command method for writing ATA Command register
and use it instead of ->OUTBSYNC.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3ef5eb424ebf0cd981192a416358fd707a9f959b 16-Jul-2008 Elias Oltmanns <eo@nebensachen.de> IDE: Remove unused code

Remove some code which has been made obsolete and hasn't worked properly
before anyway. Part of the infrastructure may be reintroduced in a
follow up patch to implement a working command aborting facility.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
Cc: "Alan Cox" <alan@lxorguk.ukuu.org.uk>
Cc: "Randy Dunlap" <randy.dunlap@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
79e36a9f54aaf4a52eb2d9520953aa3960e99294 16-Jul-2008 Elias Oltmanns <eo@nebensachen.de> IDE: Fix HDIO_DRIVE_RESET handling

Currently, the code path executing an HDIO_DRIVE_RESET ioctl is broken
in various ways. Most importantly, it is treated as an out of band
request in an illegal way which may very likely lead to system lock ups.
Use the drive's request queue to avoid this problem (and fix a locking
issue for free along the way).

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
Cc: "Alan Cox" <alan@lxorguk.ukuu.org.uk>
Cc: "Randy Dunlap" <randy.dunlap@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
63f5abb0959337db0d5bece9cefba03cdcadec51 15-Jul-2008 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> ide: remove action argument in ide_do_drive_cmd

ide_do_drive_cmd is called only with ide_preempt action argument. So
we can remove the action argument in ide_do_drive_cmd and ide_action_t
typedef.

This patch also includes two minor cleanups: 1) ide_do_drive_cmd
always succeeds so we don't need the return value; 2) the callers use
blk_rq_init before ide_do_drive_cmd so there is no need to initialize
rq->errors.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
f8c4bd0ab2b8783c0f080957781e9f70bee48eaa 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: pass 'hwif *' instead of 'drive *' to ->OUTBSYNC method

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
ed4af48fd660176680da905817f6e40d51436e4c 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move IRQ unmasking out from ->tf_load method

Move IRQ unmasking out from ->tf_load method to its users.

There should be no functional changes caused by this patch
(SELECT_MASK() is NOP except for hpt366, icside and sgiioc4).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
57279a7a401eed844ded4346c5ff512e622ac1de 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove try_to_flush_leftover_data()

Just use the new & shiny ide_pad_transfer() helper instead.

Also remove the superfluous check for 'drive->media == ide_disk'
while at it (ide_ata_error() is used only for ide_disk devices).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
124cafc5eb973e748c4ce3dc1caad29274e64613 15-Jul-2008 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> ide: remove ide_init_drive_cmd

ide_init_drive_cmd just calls blk_rq_init. This converts the users of
ide_init_drive_cmd to use blk_rq_init directly and removes
ide_init_drive_cmd.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Borislav Petkov <petkovbb@gmail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
5f2e1ceef45ac07d7c52d16de2531a56c453bb0f 15-Jul-2008 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> ide: remove ide_wait/head_wait path in ide_do_drive_cmd

Now all the users of ide_do_drive_cmd using ide_wait/head_wait are
converted to use blk_execute_rq this removes the ide_wait/head_wait
path in ide_do_drive_cmd.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Borislav Petkov <petkovbb@gmail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
c6866a6ff571eebebda45bf14b5b62188768893a 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use __generic_unplug_device() in ide_do_drive_cmd() (take 2)

* Call __elv_add_request() with 'plug' == 1 (so the device will be
plugged) and then use __generic_unplug_device() instead of calling
ide_do_request() directly.

v2:
* For blk_pm_resume_request() requests the queue is stopped so we
need to call ->request_fn explicitly.

Thanks to:
- Rafael for reporting/bisecting the bug
- Borislav/Rafael for testing the fix

This is a preparation for converting IDE to use blk_execute_rq().

Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Borislav Petkov <petkovbb@gmail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e8a96aa71355edef9f40ce01459acf25c50cb78c 15-Jul-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: set REQ_PREEMPT request flag in ide_do_drive_cmd() users

* Set REQ_PREEMPT request flag in ide_do_drive_cmd() users
for ide_preempt and ide_head_wait action types.

* Remove setting REQ_PREEMPT from ide_do_drive_cmd().

While at it:

* Set 'where' variable outside ide_lock.

This is a preparation for converting IDE to use blk_execute_rq().

There should be no functional changes caused by this patch.

Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Borislav Petkov <petkovbb@gmail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
e7b241a7715d2a0885f779f5baa63711d71b1d75 29-Apr-2008 FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> ide: use blk_rq_init() to initialize the request

This converts ide to use blk_rq_init to initialize the request.

This is a preparation for large command support, which needs to
initialize the request in a proper way (that is, just doing a memset()
will not work).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
9f87abe892f899f19df8d472f937ee955cd6264b 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_pad_transfer() helper

* Add ide_pad_transfer() helper (which uses ->{in,out}put_data methods
internally so the transfer is also padded to drive+host requirements)
and use it instead of ide_atapi_{write_zeros,discard_data}().

* Remove no longer needed ide_atapi_{write_zeros,discard_data}().

Cc: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
94cd5b62ff9bb07ef065333eb97438f115a75890 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ->tf_load and ->tf_read methods

* Add ->tf_load and ->tf_read methods to ide_hwif_t and set the default
methods in default_hwif_transport().

* Use ->tf_{load,read} instead o calling ide_tf_{load,read}() directly.

* Make ide_tf_{load,read}() static.

There should be no functional changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
d309e0bb8e5f29692f10790f3e966f05bbfc9355 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: move ide_tf_{load,read} to ide-iops.c

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
089c5c7e0089c3461545be936bcd236cbf16b79a 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: factor out debugging code from ide_tf_load()

Factor out debugging code from ide_tf_load() to ide_tf_dump() helper
and update ide_tf_load() users accordingly.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
32b3fe4fff0974d823a0c0d17d7b25690ecd5fc8 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: always use ->OUTBSYNC method for executing commands

Always use ->OUTBSYNC method for executing commands so the posting is done
if needed (this affects only pmac and scc_pata host drivers at the moment).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
9567b349f7e7dd7e2483db99ee8e4a6fe0caca38 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge ->atapi_*put_bytes and ->ata_*put_data methods

* Merge ->atapi_{in,out}put_bytes and ->ata_{in,out}put_data methods
into new ->{in,out}put_data methods which take number of bytes to
transfer as an argument and always do padding.

While at it:

* Use 'hwif' or 'drive->hwif' instead of 'HWIF(drive)'.

There should be no functional changes caused by this patch (all users
of ->ata_{in,out}put_data methods were using multiply-of-4 word counts).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
92d3ab27e8fd23d1a9dc3b69d17b2afb83e5c6f5 28-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> falconide/q40ide: add ->atapi_*put_bytes and ->ata_*put_data methods (take 2)

* Add ->atapi_{in,out}put_bytes and ->ata_{in,out}put_data methods to
falconide and q40ide host drivers (->ata_* methods are implemented on
top of ->atapi_* methods so they also do byte-swapping now).

* Cleanup atapi_{in,out}put_bytes().

v2:
* Add 'struct request *rq' argument to ->ata_{in,out}put_data methods
and don't byte-swap disk fs requests (we shouldn't un-swap fs requests
because fs itself is stored byte-swapped on the disk) - this is how
things were done before the patch (ideally device mapper should be
used instead but it would break existing setups and would have some
performance impact).

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Michael Schmitz <schmitz@debian.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Richard Zidlicky <rz@linux-m68k.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
4c3032d8a4d6c97bd6e02bcab524ef2428d89561 27-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_io_ports (take 3)

* Add struct ide_io_ports and use it instead of `unsigned long io_ports[]`
in ide_hwif_t.

* Rename io_ports[] in hw_regs_t to io_ports_array[].

* Use un-named union for 'unsigned long io_ports_array[]' and 'struct
ide_io_ports io_ports' in hw_regs_t.

* Remove IDE_*_OFFSET defines.

v2:
* scc_pata.c build fix from Stephen Rothwell.

v3:
* Fix ctl_adrr typo in Sparc-specific part of ns87415.c.
(Noticed by Andrew Morton)

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
5e37bdc081a980dd0d669e6387bcf15ca9666f81 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_dma_ops (take 3)

Add struct ide_dma_ops and convert core code + drivers to use it.

While at it:

* Drop "ide_" prefix from ->ide_dma_end and ->ide_dma_test_irq methods.

* Drop "ide_" "infixes" from DMA methods.

* au1xxx-ide.c:
- use auide_dma_{test_irq,end}() directly in auide_dma_timeout()

* pdc202xx_old.c:
- drop "old_" "infixes" from DMA methods

* siimage.c:
- add siimage_dma_test_irq() helper
- print SATA warning in siimage_init_one()

* Remove no longer needed ->init_hwif implementations.

v2:
* Changes based on review from Sergei:
- s/siimage_ide_dma_test_irq/siimage_dma_test_irq/
- s/drive->hwif/hwif/ in idefloppy_pc_intr().
- fix patch description w.r.t. au1xxx-ide changes
- fix au1xxx-ide build
- fix naming for cmd64*_dma_ops
- drop "ide_" and "old_" infixes
- s/hpt3xxx_dma_ops/hpt37x_dma_ops/
- s/hpt370x_dma_ops/hpt370_dma_ops/
- use correct DMA ops for HPT302/N, HPT371/N and HPT374
- s/it821x_smart_dma_ops/it821x_pass_through_dma_ops/

v3:
* Two bugs slipped in v2 (noticed by Sergei):
- use correct DMA ops for HPT374 (for real this time)
- handle HPT370/HPT370A properly

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
ac95beedf8bc97b24f9540d4da9952f07221c023 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_port_ops (take 2)

* Move hooks for port/host specific methods from ide_hwif_t to
'struct ide_port_ops'.

* Add 'const struct ide_port_ops *port_ops' to 'struct ide_port_info'
and ide_hwif_t.

* Update host drivers and core code accordingly.

While at it:

* Rename ata66_*() cable detect functions to *_cable_detect() to match
the standard naming. (Suggested by Sergei Shtylyov)

v2:
* Fix build for bast-ide. (Noticed by Andrew Morton)

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
784506cbddd17bcd5929f827df39b0c7014e3f1e 26-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: sanitize handling of IDE_HFLAG_NO_SET_MODE host flag

* Check for IDE_HFLAG_NO_SET_MODE host flag in ide_set_pio(),
ide_set_[pio,dma]_mode(), ide_set_xfer_rate() and set_pio_mode().

* Remove no longer needed IDE_HFLAG_NO_SET_MODE host flag checking
from ide_tune_dma().

* Remove superfluous ->set_pio_mode checking from do_special().

This is a part of preparations for adding 'struct ide_port_ops'.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
23579a2a170265aacf78069f4817a41c1d6e9323 18-Apr-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove IDE_*_REG macros

* Add IDE_{ALTSTATUS,IREASON,BCOUNTL,BCOUNTH}_OFFSET defines.

* Remove IDE_*_REG macros - this results in more readable
and slightly smaller code.

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
395d8ef5bebe547a80737692f9789d2e36da16f2 11-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-disk: fix flush requests (take 2)

commit 813a0eb233ee67d7166241a8b389b6a76f2247f9
Author: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Date: Fri Jan 25 22:17:10 2008 +0100

ide: switch idedisk_prepare_flush() to use REQ_TYPE_ATA_TASKFILE requests

...

broke flush requests.

Allocating IDE command structure on the stack for flush requests is not
a very brilliant idea:

- idedisk_prepare_flush() only prepares the request and it doesn't wait
for it to be completed

- there are can be multiple flush requests queued in the queue

Fix the problem (per hints from James Bottomley) by:
- dynamically allocating ide_task_t instance using kmalloc(..., GFP_ATOMIC)
- adding new taskfile flag (IDE_TFLAG_DYN)
- calling kfree() in ide_end_drive_command() if IDE_TFLAG_DYN is set
(while at it rename 'args' to 'task' and fix whitespace damage)

[ This will be fixed properly before 2.6.25 but this bug is rather
critical and the proper solution requires some more work + testing. ]

Thanks to Sebastian Siewior and Christoph Hellwig for reporting the
problem and testing patches (extra thanks to Sebastian for bisecting
it to the guilty commmit).

Tested-by: Sebastian Siewior <ide-bug@ml.breakpoint.cc>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3b0e044d5a881c937293a045158149514b86783c 11-Feb-2008 Kiyoshi Ueda <k-ueda@ct.jp.nec.com> ide: another possible ide panic fix for blk-end-request

I have reviewed all blk-end-request patches again to confirm whether
there are any similar problems with the last week's ide-cd panic:
http://lkml.org/lkml/2008/1/29/140

And I found a possible similar bug in ide-io change:
ide_end_drive_cmd() could be called for blk_pc_request() which could
have bios. To complete such requests correctly, we need to pass
the actual size of the request.
Otherwise, __blk_end_request() returns 1 because the request still has
bios, and the system will BUG() unnecessarily.

The following patch fixes the bug and should be applied on top of
Linus' git.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
64a57fe4393bae920d03c253173f59d8a7ec8e25 06-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_read_error() inline helper

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
c47137a99c597330b69057158b26061a360c0e09 06-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_read_[alt]status() inline helpers

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
425afb61032a245f53320b7efa0f0dfd7a23f87f 01-Feb-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix ide_intr() for non-PCI devices and CONFIG_BLK_DEV_IDEPCI=y

'hwif->pci_dev && !hwif->pci_dev->vendor' condition is never true,
check for 'hwif->chipset != ide_pci' instead.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
5e36bb6ee8d5ff6c6114b60d2aaa1c70d4275f4e 28-Jan-2008 Kiyoshi Ueda <k-ueda@ct.jp.nec.com> blk_end_request: changing ide normal caller (take 4)

This patch converts "normal" parts of ide to use blk_end_request
interfaces. Related 'uptodate' arguments are converted to 'error'.

The conversion of 'uptodate' to 'error' is done only for the internal
function, __ide_end_request().
ide_end_request() was not changed since it's exported and used
by many ide drivers.

With this patch, blkdev_dequeue_request() in __ide_end_request() is
moved to blk_end_request, since blk_end_request takes care of
dequeueing request like below:

if (!list_empty(&rq->queuelist))
blkdev_dequeue_request(rq);

In the case of ide,
o 'dequeue' variable of __ide_end_request() is 1 only when the request
is still linked to the queue (i.e. rq->queuelist is not empty)
o 'dequeue' variable of __ide_end_request() is 0 only when the request
has already been removed from the queue (i.e. rq->queuelist is empty)
So blk_end_request can handle it correctly although ide always run
thought the code above.

Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
7267c3377443322588cddaf457cf106839a60463 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove REQ_TYPE_ATA_CMD

Based on the earlier work by Tejun Heo.

All users are gone so we can finally remove it.

Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
0455fcc821e87d362f2047922c59c0f378a122b5 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix final status check in drive_cmd_intr()

Don't check for READY_STAT bit being set for PIO-in protocol (makes the
final status check in drive_cmd_intr() match the one in task_in_intr()).

Also fix function name reported by ide_error() call while at it.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
4d977e43d8ae758434e603cf2455d955f71c77c4 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: check BUSY and ERROR status bits before reading data in drive_cmd_intr()

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
18a056feccabdfa9764016a615121b194828bc72 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: don't enable local IRQs for PIO-in in driver_cmd_intr() (take 2)

Don't enable local IRQs for PIO-in protocol in driver_cmd_intr().

While at it:

* Remove redundant rq->cmd_type check.

* Read status register after enabling local IRQs for no-data protocol.

v2:
* Re-add DRQ=1 check lost in v1 (noticed by Sergei).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
145b75e9aedbe36c55e45da8564dcd0814bdd89e 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: initialize rq->cmd_type in ide_init_drive_cmd() callers

* Initialize rq->cmd_type in ide_wait_cmd(), ide_cmd_ioctl() and
set_pio_mode() (other callers were aleady over-riding rq->cmd_type).

* Remove no longer needed rq->cmd_type setup from ide_init_drive_cmd().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
2624565caacedd740fce7803fe2c162842aa5df4 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use wait_drive_not_busy() in drive_cmd_intr() (take 2)

Use wait_drive_not_busy() in drive_cmd_intr().

v2:
* Fix wait_drive_not_busy() comment (noticed by Sergei).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
657cc1a8f6cd6a9e2974cba3af9fccd8c25e06ad 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: set IDE_TFLAG_IN_* flags before queuing/executing command

* Add IDE_TFLAG_{HOB,TF,DEVICE} defines.

* Set IDE_TFLAG_IN_* flags in {do_rw,ide_no_data,ide_raw}_taskfile() users.

* Remove no longer needed ->tf_flags setup from ide_end_drive_cmd().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
49c746ee6cc791202172483277a249c12ba437d8 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: clear HOB bit for REQ_TYPE_ATA_CMD requests in ide_end_drive_cmd()

ide_dump_status() may set HOB bit before ide_end_drive_cmd() is called.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
81ca691981da718727281238b435dcf1528d2fda 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_set_irq() inline helper

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
15ce926ada545cb078711bd9a18c083c93fa01d7 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge ->dma_host_{on,off} methods into ->dma_host_set method

Merge ->dma_host_{on,off} methods into ->dma_host_set method
which takes 'int on' argument.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
4a546e046d562bcd389149591fa5a534c8f832ca 26-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->ide_dma_on and ->dma_off_quietly methods from ide_hwif_t

* Make ide_dma_off_quietly() and __ide_dma_on() always available.

* Drop "__" prefix from __ide_dma_on().

* Check for presence of ->dma_host_on instead of ->ide_dma_on.

* Convert all users of ->ide_dma_on and ->dma_off_quietly methods
to use ide_dma_on() and ide_dma_off_quietly() instead.

* Remove no longer needed ->ide_dma_on and ->dma_off_quietly methods
from ide_hwif_t.

* Make ide_dma_on() void.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
7b905994ce0bd332afc5ebc30ce9afa60d23c6e2 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: cleanup ide_set_dma()

* ->dma_off_quietly is always called before ide_set_dma()
so the call can be moved inside ide_set_dma().

* ide_dma_check() doesn't touch hardware so ->dma_off_quietly
call for 'rc == -1' case is redundant, remove it.

* '0' and '-1' are the only values returned by ide_dma_check()
so remove dead code for other cases.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
c2b57cdc1d2976444d451a2a2e43e11b61ed0638 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_tf_read() helper

* Factor out code reading taskfile registers from ide_end_drive_cmd()
to the new ide_tf_read() helper.

* Add IDE_TFLAG_IN_* taskfile flags to indicate the need to load
particular IDE taskfile register in ide_tf_read().

* Update ide_end_drive_cmd() to set respective IDE_TFLAG_IN_* taksfile flags.

* Add ide_get_lba_addr() for getting LBA sector address from taskfile struct.

* Factor out code getting sector address from ide_dump_ata_status()
to the new ide_dump_sector() function.

* Convert ide_dump_sector() to use ide_tf_read() and ide_get_lba_addr().

* Remove no longer needed ide_read_24().

The only change in functionality caused by this patch is that
ide_dump_ata_status() no longer prints "high"/"low" parts of LBA48
sector address (of course LBA48 sector address is still printed).

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
57d7366b78b74a9eef873e8212c03d8c2033a764 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove 'handler' field from ide_task_t (take 2)

* Add IDE_TFLAG_CUSTOM_HANDLER taskfile flag and use it for internal requests
which require custom handlers. Check the flag in do_rw_taskfile() and set
handler accordingly.

* Cleanup ide_init_{specify,restore,setmult}_cmd() and rename it to
ide_tf_set_{specify,restore,setmult}_cmd().

* Make {set_geometry,recal,set_multmode}_intr() static.

* Remove no longer needed 'handler' field from ide_task_t.

v2:
* 'handler' in do_rw_taskfile() must be set to NULL initially.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1192e528e064ebb9a578219731d2b0f78ca3c1ec 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ->data_phase to set ->handler in do_rw_taskfile()

* Use ->data_phase to set ->handler in do_rw_taskfile() instead of
setting ->handler in callers of ide_raw_taskfile()/do_rw_taskfile().

* Unexport task_no_data_intr() and make it static.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1edee60e9d994f2b9a79b1333be39790683541fe 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: merge flagged_taskfile() into do_rw_taskfile()

Based on the earlier work by Tejun Heo.

task->data_phase == TASKFILE_MULTI_{IN,OUT} vs drive->mult_count == 0
check is needed also for ide_taskfile_ioctl() requests that don't have
IDE_TFLAG_FLAGGED taskfile flag set.

Cc: Tejun Heo <htejun@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
866e2ec9ce525de0e7c10d02ead8d85af27adffd 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove 'tf_in_flags' field from ide_task_t

* Add IDE_TFLAG_IN_DATA taskfile flag to indicate the need of reading
IDE_DATA_REG in ide_end_drive_cmd().

Set the new flag in ide_taskfile_ioctl() if ->in_flags.b.data is set.

* Add IDE_TFLAG_FLAGGED_SET_IN_FLAGS taskfile flag to indicate the
need of modifying ->in_flags in ide_taskfile_ioctl().

Set the new flag in flagged_taskfile() and move the code modifying
->tf_in_flags to ide_taskfile_ioctl().

While at it remove the bogus comment: ->tf_in_flags (except .b.data)
have no effect on selection of registers to read.

* Remove no longer needed 'tf_in_flags' field from ide_task_t.

As the result we finally have the internals of HDIO_DRIVE_TASKFILE ioctl
separated from the core IDE code.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
ac026ff254b32915bb14ba97a23b4019d137f181 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove 'command_type' field from ide_task_t

* Add 'data_buf' and 'nsect' variables in ide_taskfile_ioctl()
to cache data buffer pointer and number of sectors to transfer
(this allows us to have only one ide_diag_taskfile() call).

* Add IDE_TFLAG_WRITE taskfile flag and use it to check whether
the REQ_RW request flag should be set.

* Move ->command_type handling from ide_diag_taskfile() to
ide_taskfile_ioctl() and use ->req_cmd instead of ->command_type.

* Add 'nsect' parameter to ide_raw_taskfile().

* Merge ide_diag_taskfile() into ide_raw_taskfile().

* Initialize ->data_phase explicitly in idedisk_prepare_flush(),
ide_start_power_step() and ide_disk_special().

* Remove no longer needed 'command_type' field from ide_task_t.

* Add #ifndef/#endif __KERNEL__ to <linux/hdreg.h> around no
longer used by kernel IDE_DRIVE_TASK_* and TASKFILE_* defines.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
7299a3918442dc9a5abb71b9f65b1dd17637c8c0 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove hwif->intrproc

Given that:

* hpt366.c::hpt3xx_intrproc() is the only user of hwif->intrproc

* hpt366.c::hpt3xx_quirkproc() sets drive->quirk_list to 1 for quirky drives
which is a value unique to hpt366 host driver

we can remove hwif->intproc and just check for drive->quirk_list == 1
in ide_do_request().

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
f919790f8c929ab1b392ad1a0c2e1b53337b5071 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove SELECT_INTERRUPT()

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
2fc573881957337c4ea1c84b92d2f27d076cad57 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_pktcmd_tf_load() helper

Add ide_pktcmd_tf_load() helper and convert ATAPI device drivers to use it.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
29ed2a5f8c4380959f18e9cbaff13bc61e09889c 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove REQ_TYPE_ATA_TASK

Based on the earlier work by Tejun Heo.

All users are gone so we can finally remove it.

Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1f2564b8b56b305ab9acf5d387abca950180dff6 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: extend timeout for REQ_TYPE_ATA_{CMD,TASK} requests

Extend timeout for REQ_TYPE_ATA_{CMD,TASK} requests from WAIT_CMD (10sec)
to WAIT_WORSTCASE (30sec, already used for REQ_TYPE_ATA_TASKFILE).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
a3bbb9d882dc94fe3a1361596ab9ce55d84059ea 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove unnecessary writes to HOB taskfile registers

* Set taskfile flags for REQ_TYPE_ATA_TASKFILE requests before
adding the request to the queue.

* Cleanup execute_drive_cmd().

* Remove unnecessary writes to HOB taskfile registers when using
LBA48 disk for the following cases:

- Power Management requests
(WIN_FLUSH_CACHE[_EXT], WIN_STANDBYNOW1, WIN_IDLEIMMEDIATE commands)

- special commands (WIN_SPECIFY, WIN_RESTORE, WIN_SETMULT)

- Host Protected Area support (WIN_READ_NATIVE_MAX, WIN_SET_MAX)

- /proc/ide/ SMART support (WIN_SMART with SMART_ENABLE,
SMART_READ_VALUES and SMART_READ_THRESHOLDS subcommands)

- write cache enabling/disabling in ide-disk
(WIN_SETFEATURES with SETFEATURES_{EN,DIS}_WCACHE)

- write cache flushing in ide-disk (WIN_FLUSH_CACHE[_EXT])

- acoustic management in ide-disk
(WIN_SETFEATURES with SETFEATURES_{EN,DIS}_AAM)

- door (un)locking in ide-disk (WIN_DOORLOCK, WIN_DOORUNLOCK)

- /proc/ide/hd?/identify support (WIN_IDENTIFY)

- ACPI _GTF taskfiles

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
868e672ac8db650dde695a5707a6caf5a757e7d9 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use IDE_TFLAG_LBA48 for REQ_TYPE_ATA_TASKFILE requests

* Use IDE_TFLAG_LBA48 for REQ_TYPE_ATA_TASKFILE requests in ide_end_drive_cmd()
to decide whether we need to read HOB taskfile registers.

* Update execute_drive_cmd() accordingly.

This is a preparation for the next patch which removes unnecessary writes to
HOB taskfile registers for some ATA commands.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
807e35d695690011faa1ce3ad67dfc23c1e39bdc 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use ide_tf_load() in execute_drive_cmd()

* Add IDE_TFLAG_OUT_DEVICE taskfile flag to indicate the need of writing
the Device register and handle it in ide_tf_load().

Update ide_tf_load() and {do_rw,flagged}_taskfile() users accordingly.

* Use struct ide_taskfile and ide_tf_load() in execute_drive_cmd().

* Make the debugging code dump all taskfile registers for both
REQ_ATA_TYPE_{CMD,TASK} requests and move it to ide_tf_load()
so it also covers REQ_ATA_TYPE_TASKFILE requests.

There should be no functionality changes caused by this patch
(unless DEBUG is defined).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
54688aa372cbc83c4361bfb9236f9bfe02168e19 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ide_cmd() helper

* Remove ide_cmd() helper.

* Clear nIEN and call SELECT_MASK() before writing taskfile registers.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
21d535c91362a1a3bbb299b2e7214c1a6971ef95 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: execute_drive_cmd() cleanup

* Rename 'args' variable in 'if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE)'
block to 'task'.

* execute_drive_cmd() is used only for REQ_TYPE_ATA_{CMD,TASK,TASKFILE} so
we can move the common code out from 'if (rq->cmd_type == REQ_TYPE_ATA_CMD)'
and 'if (rq->cmd_type == REQ_TYPE_ATA_TASK)' blocks.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
6dd87233bccc6416dac3b78ac912fd017918efe6 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix registers loading order for IDE_NSECTOR_REG in execute_drive_cmd()

Move loading of IDE_NSECTOR_REG from ide_cmd() to execute_drive_cmd()
(load the IDE_NSECTOR_REG just after IDE_FEATURE_REG).

This also allows us to drop 'nsect' argument from ide_cmd() and simplify
execute_drive_cmd() code for REQ_TYPE_ATA_CMD case a bit.

It shouldn't affect anything (just a usual paranoia to separate changes
which change the way in which hardware is accessed from code cleanups).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
46f26c362d5109459f04f99e93fc0413d88516c8 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix registers loading order for WIN_SMART in execute_drive_cmd()

Fix registers loading order for REQ_TYPE_ATA_CMD request with WIN_SMART
command in execute_drive_cmd() (load IDE_FEATURE_REG and IDE_SECTOR_REG
before loading IDE_LCYL_REG and IDE_HCYL_REG).

It shouldn't affect anything (just a usual paranoia to separate changes
which change the way in which hardware is accessed from code cleanups).

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
4ee06b7e677da4c75f2fcc5fd850543852d18bf2 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove stale ide.h "configuration options"

Remove stale ide.h "configuration options":

* INITIAL_MULT_COUNT - always defined to 0

* SUPPORT_SLOW_DATA_PORTS - unused

* OK_TO_RESET_CONTROLLER - always defined to 1

* DISABLE_IRQ_NOSYNC - always defined to 0

Leave SUPPORT_VLB_SYNC (defined to 0 for CRIS and FRV, otherwise to 1)
for now but disallow overriding it by <asm/ide.h>.

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
74095a91ed02f6727b62d4416be00a041f2d7436 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use do_rw_taskfile() in flagged_taskfile()

Based on the earlier work by Tejun Heo.

* Move setting IDE_TFLAG_LBA48 taskfile flag from do_rw_taskfile()
function to the callers.

* Add IDE_TFLAG_FLAGGED taskfile flag for flagged taskfiles coming
from ide_taskfile_ioctl(). Check it instead of ->tf_out_flags.all.

* Add IDE_TFLAG_OUT_DATA taskfile flag to indicate the need to load
IDE data register in ide_tf_load().

* Add IDE_TFLAG_OUT_* taskfile flags to indicate the need to load
particular IDE taskfile registers in ide_tf_load().

* Update do_rw_taskfile() and ide_tf_load() users to set respective
IDE_TFLAG_OUT_* taksfile flags.

* Add task_dma_ok() helper.

* Use IDE_TFLAG_FLAGGED taskfile flag to select HIHI mask in ide_tf_load().

* Use do_rw_taskfile() in flagged_taskfile().

* Remove no longer needed 'tf_out_flags' field from ide_task_t.

There should be no functionality changes caused by this patch.

Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
650d841d9e053a618dd8ce753422f91b493cf2f6 25-Jan-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add struct ide_taskfile (take 2)

* Don't set write-only ide_task_t.hobRegister[6] and ide_task_t.hobRegister[7]
in idedisk_set_max_address_ext().

* Add struct ide_taskfile and use it in ide_task_t instead of tfRegister[]
and hobRegister[].

* Remove no longer needed IDE_CONTROL_OFFSET_HOB define.

* Add #ifndef/#endif __KERNEL__ around definitions of {task,hob}_struct_t.

While at it:

* Use ATA_LBA define for LBA bit (0x40) as suggested by Tejun Heo.

v2:
* Add missing newlines. (Noticed by Sergei)

* Use ~ATA_LBA instead of 0xBF. (Noticed by Sergei)

* Use unnamed unions for error/feature and status/command.
(Suggested by Sergei).

There should be no functionality changes caused by this patch.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
b5e1a4e2869af5ffaa102535ad63d184d86e66ec 25-Jan-2008 Aristeu Rozanski <arozansk@redhat.com> ide-io: set REQ_FAILED when drive is dead

Currently it's possible to ide-cd to set an incorrect blocksize by
reading garbage if the drive is dead:

ide_cd_probe()
-> cdrom_read_toc()
-> cdrom_read_capacity()
-> cdrom_queue_packet_command()
-> ide_do_drive_cmd()
-> ide_do_request()
-> start_request()

on start_request():

/* bail early if we've exceeded max_failures */
if (drive->max_failures && (drive->failures > drive->max_failures)) {
goto kill_rq;
}
(...)
kill_rq:
ide_kill_rq(drive, rq);
return ide_stopped;

ide_kill_rq() and the next calls won't set REQ_FAILED on rq->cmd_flags and thus
cdrom_queue_packet_command() won't return an error. then:

stat = cdrom_queue_packet_command(drive, &req);
if (stat == 0) {
*capacity = 1 + be32_to_cpu(capbuf.lba);
*sectors_per_frame =
be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS;
}

cdrom_read_capacity() ends believing capbuf is valid but in fact it's just
uninitialized data. back to cdrom_read_toc():

/* Try to get the total cdrom capacity and sector size. */
stat = cdrom_read_capacity(drive, &toc->capacity, &sectors_per_frame,
sense);
if (stat)
toc->capacity = 0x1fffff;

set_capacity(info->disk, toc->capacity * sectors_per_frame);
/* Save a private copy of te TOC capacity for error handling */
drive->probed_capacity = toc->capacity * sectors_per_frame;

blk_queue_hardsect_size(drive->queue,
sectors_per_frame << SECTOR_BITS);

that will set drive->queue->hardsect_size to be the random value.
hardsect_size is used to calculate inode->i_blkbits. later on, on a read
path:

void create_empty_buffers(struct page *page,
unsigned long blocksize, unsigned long b_state)
{
struct buffer_head *bh, *head, *tail;

head = alloc_page_buffers(page, blocksize, 1);
bh = head;
do {
bh->b_state |= b_state;
tail = bh;
bh = bh->b_this_page;
} while (bh);
tail->b_this_page = head;

alloc_page_buffers() will return NULL if blocksize > 4096. blocksize is
calculed based on inode->i_blkbits. that will trigger a null
dereference on create_empty_buffers().

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
Cc: Borislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
ad0e74d3851e440e0882424577bc984c89019f52 12-Dec-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add missing checks for control register existence

Add missing checks for control register existence (some legacy m68k specific
IDE controllers don't have it). Also use drive->ctl while at it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
c1f50cbb06363b36700c0a679a5bd3ddef0a97b6 13-Nov-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use drive->select.all for REQ_TYPE_ATA_TASK in execute_drive_cmd()

Use drive->select.all for REQ_TYPE_ATA_TASK requests in execute_drive_cmd()
(the obsolete bits 7 and 5 of the Device register need to be set).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1c11d241115a352a4468a7a4884c22cf68a5c6fd 05-Nov-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: clear HOB bit for REQ_TYPE_ATA_TASK requests in ide_end_drive_cmd()

ide_dump_ata_status() may set HOB bit before ide_end_drive_cmd() is called.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
320112bd28d3c477f6990bfe8762ccb978106a08 05-Nov-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: check rq->cmd_type in drive_cmd_intr()

drive_cmd_intr() is used by both REQ_TYPE_ATA_CMD and REQ_TYPE_ATA_TASK
but commands using PIO-in protocol are valid only for REQ_TYPE_ATA_CMD
(&args[4] in case of REQ_TYPE_ATA_TASK points to a value for IDE_LCYL_REG
register instead of the data buffer). This fix allows REQ_TYPE_ATA_TASK
commands to use non-zero values for IDE_SECTOR_REG (args[3]).

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
bbc615b16d64643a3d22ab4890fde1a685e86d83 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: use __ide_end_request() in ide_end_dequeued_request()

* Remove dead code for handling IDE TCQ from ide_end_dequeued_request().

* Add 'dequeue' parameter to __ide_end_request().

* Use __ide_end_request() in ide_end_dequeued_request().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
d393aa0326436efd3cb800916b08cdac4dd1091a 20-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: take ide_lock for prefetch disable/enable in do_special()

Take ide_lock for prefetch disable/enable in do_special(),
then cleanup cmd640 and ht6560b host drivers.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
1977f032722c27ee3730284582fd3991ad9ac81b 19-Oct-2007 Jiri Slaby <jirislaby@gmail.com> remove asm/bitops.h includes

remove asm/bitops.h includes

including asm/bitops directly may cause compile errors. don't include it
and include linux/bitops instead. next patch will deny including asm header
directly.

Cc: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
/drivers/ide/ide-io.c
ed67b92385a5afddc98d5ff0894b2854c4a54dac 19-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add IDE_HFLAG_ERROR_STOPS_FIFO host flag

Add IDE_HFLAG_ERROR_STOPS_FIFO host flag and use it instead
of hwif->err_stops_fifo. As a side-effect this change fixes
hwif->err_stops_fifo not being restored by ide_hwif_restore().

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
0ae2e178652753ae1797d407755a3505f7c1d2a7 16-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: remove ->ide_dma_check (take 2)

* Add IDE_HFLAG_TRUST_BIOS_FOR_DMA host flag for host drivers that depend
on BIOS for programming device/controller for DMA. Set it in cy82c693,
generic, ns87415, opti621 and trm290 host drivers.

* Add IDE_HFLAG_VDMA host flag for host drivers using VDMA. Set it in cs5520
host driver.

* Teach ide_tune_dma() about IDE_HFLAG_TRUST_BIOS_FOR_DMA flag.

* Add generic ide_dma_check() helper and remove all open coded ->ide_dma_check
implementations. Fix all places checking for presence of ->ide_dma_check
hook to check for ->ide_dma_on instead.

* Remove no longer needed code from config_drive_for_dma().

* Make ide_tune_dma() static.

v2:
* Fix config_drive_for_dma() return values.

* Fix ide-dma.c build for CONFIG_BLK_DEV_IDEDMA_PCI=n by adding
dummy config_drive_for_dma() inline.

* Fix IDE_HFLAG_TRUST_BIOS_FOR_DMA handling in ide_dma_check().

* Fix init_hwif_it8213() comment.

There should be no functionality changes caused by this patch.

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
55c16a70041ba55e235c5944dccb9c1de0dd3ca6 25-Jul-2007 Jens Axboe <jens.axboe@oracle.com> IDE: sg chaining support

Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
bb879463b5346302a3891ebb7406247c53cebac1 14-Sep-2007 Adrian Bunk <bunk@kernel.org> remove ide_get_error_location()

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
aedea5910ce44fea79e2c517bb22e0006372156f 13-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide-pmac: remove pmac_ide_do_setfeature() (take 2)

Use ide_config_drive_speed() instead of pmac_ide_do_setfeature() and remove
the latter, also ide-iops.c::__ide_wait_stat() could be static again.

Since for IDE PMAC host driver IDE_CONTROL_REG is always true, device's
->quirk_list is always zero and ->ide_dma_host_{on,off} are nops than
the only changes in behavior are:

* if PIO mode is set then ->dma_off_queitly is called to disable DMA

* if setting transfer mode fails ide_dump_status() is called to dump status

v2:
* IDE PMAC controllers allow separate PIO and DMA timings and PPC userland
depends on this fact, and calls "hdparm -p" without calling "hdparm -d".

Therefore to compensate for DMA being disabled by ide_config_drive_speed()
for PIO modes:

- add IDE_HFLAG_SET_PIO_MODE_KEEP_DMA flag and set it in PMAC host driver

- add handling of the new flag to ide-io.c::do_special()

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
26bcb879c03254545a19c6700fe5bcef6f21e7b1 11-Oct-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_set{_max}_pio() (take 4)

* Add IDE_HFLAG_ABUSE_{PREFETCH,FAST_DEVSEL,DMA_MODES} flags
and set them in ht6560, cmd640, cmd64x and sc1200 host drivers.

* Add set_pio_mode_abuse() for checking if host driver has a non-standard
->tuneproc() implementation and use it in do_special().

* Add ide_set_pio() for setting PIO mode (it uses hwif->pio_mask to find
the maximum PIO mode supported by the host), also add ide_set_max_pio()
wrapper for ide_set_pio() to use for auto-tuning. Convert users of
->tuneproc to use ide_set{_max}_pio() where possible. This leaves only
do_special(), set_using_pio(), ide_hwif_restore() and ide_set_pio() as
a direct users of ->tuneproc.

* Remove no longer needed ide_get_best_pio_mode() calls and printk-s
reporting PIO mode selected from ->tuneproc implementations.

* Rename ->tuneproc hook to ->set_pio_mode and make 'pio' argument const.

* Remove stale comment from ide_config_drive_speed().

v2:
* Fix "ata_" prefix (Noticed by Jeff).

v3:
* Minor cleanups/fixups per Sergei's suggestions.

v4:
* Fix compile problem in drivers/ide/pci/cmd640.c
(Noticed by Andrew Morton).

* Improve some ->set_pio_mode comments.

Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
165125e1e480f9510a5ffcfbfee4e3ee38c05f23 24-Jul-2007 Jens Axboe <jens.axboe@oracle.com> [BLOCK] Get rid of request_queue_t typedef

Some of the code has been gradually transitioned to using the proper
struct request_queue, but there's lots left. So do a full sweet of
the kernel and get rid of this typedef and replace its uses with
the proper type.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
/drivers/ide/ide-io.c
8987d21ba6a426b0685257866ce366055930b57f 20-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: ide_start_power_step() fix WRT disabling DMA

* Do the same thing as probe_hwif() and always disable DMA so chipset DMA
enabled bit gets cleared (if the drive doesn't support DMA ide_set_dma()
won't try to tune it anyway).

* Add TODO comment about respecting ->using_dma setting.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
41e9d344bf52c57ec16648d08618b61d3f1d4bdc 19-Jul-2007 Jens Axboe <jens.axboe@oracle.com> IDE: fix termination of non-fs requests

ide-disk calls

ide_end_request(drive, 0, 0);

to finish an unknown request, but this doesn't work so well for non-fs
requests, since ide_end_request() internally looks at ->hard_cur_sectors
to see how much data to end. Only file system requests store a transfer
value in there, pc requests fill out ->data_len as a byte based transfer
value instead.

Since we ask to end 0 bytes of that request, it will never be terminated
and ide-disk gets stuck in a loop "handling" that same request over and
over.

Switch __ide_end_request() to take a byte based transfer count, and
adjust ide_end_request() to look at the right field to determine how
much IO to end when it's being passed in 0.

Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Tested-By: Giacomo Catenazzi <cate@debian.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
/drivers/ide/ide-io.c
c283f5dbe31920ca70b80a594a97bfaa2a28be13 09-Jul-2007 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: make void and rename ide_dma_timeout() method

Since ide_dma_timeout() method's result is discarded, make it return 'void'.
While at it, drop 'ide_' from the method's name, drop the '__' prefix from
the default method's name, and do some cleanups in this method driver-wise:

- in ide-dma.c, au1xxx-ide.c, and pdc202xx_old.c, define/use 'hwif' variable;

- in au1xxx-ide.c, get rid of commented out printk();

- in sl82c105.c, get rid of unnecessary variables.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
841d2a9bf16471716ba3a5172d24aa40a2ea9398 09-Jul-2007 Sergei Shtylyov <sshtylyov@ru.mvista.com> ide: make void and rename ide_dma_lostirq() method

Since ide_dma_lostirq() method's result is discarded, make it return 'void'.
While at it, rename the method to dma_lost_irq(), drop the '__' prefix from the
default method's name, and do some cleanups in this method driver-wise:

- in aec62xx.c, rename the method in accordance with other drivers, and get rid
of unnecessary variables there;

- in pdc202xx_old.c, define/use 'hwif' variable;

- in sgiioc4.c, rearrange the code to call the resetproc() method directly.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
793a97228d3da876f42b7fb4d4a52cc8cc86dc81 16-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: always disable DMA before tuning it

ide_start_power_step() and set_using_dma() were missing ->dma_off_quietly
call (comment in probe_hwif() states that DMA should be always cleared before
tuning is attempted). Fix it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
317a46a200e6514a1acf50ed30291160185a5c73 10-May-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: fix PIO setup on resume for ATAPI devices

PIO should be restored also for ATAPI devices during resume, fix it.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
23450319e2890986c247ec0aa1442f060e657e6d 10-Apr-2007 Suleiman Souhlal <suleiman@google.com> ide: correctly prevent IDE timer expiry function to run if request was already handled

It is possible for the timer expiry function to run even though the
request has already been handled: ide_timer_expiry() only checks that
the handler is not NULL, but it is possible that we have handled a
request (thus clearing the handler) and then started a new request
(thus starting the timer again, and setting a handler).

A simple way to exhibit this is to set the DMA timeout to 1 jiffy and
run dd: The kernel will panic after a few minutes because
ide_timer_expiry() tries to add a timer when it's already active.

To fix this, we simply add a request generation count that gets
incremented at every interrupt, and check in ide_timer_expiry() that
we have not already handled a new interrupt before running the expiry
function.

Signed-off-by: Suleiman Souhlal <suleiman@google.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
513daadd152ddbf32cb6d0447ddba3427ce5b8e8 26-Mar-2007 Suleiman Souhlal <suleiman@google.com> ide: use correct IDE error recovery

IDE error recovery is using IDLE IMMEDIATE if the drive is busy or has DRQ set.
This violates the ATA spec (can only send IDLE IMMEDIATE when drive is not
busy) and really hoses up some drives (modern drives will not be able to
recover using this error handling). The correct thing to do is issue a SRST
followed by a SET FEATURES command. This is what Western Digital recommends
for error recovery and what Western Digital says Windows does.  It also does
not violate the ATA spec as far as I can tell.

Bart:
* port the patch over the current tree
* undo the recalibration code removal
* send SET FEATURES command after checking for good drive status
* don't check whether the current request is of REQ_TYPE_ATA_{CMD,TASK}
type because we need to send SET FEATURES before handling any requests
* some pre-ATA4 drives require INITIALIZE DEVICE PARAMETERS command before
other commands (except IDENTIFY) so send SET FEATURES only if there are
no pending drive->special requests
* update comments and patch description
* any bugs introduced by this patch are mine and not Suleiman's :-)

Signed-off-by: Suleiman Souhlal <suleiman@google.com>
Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
7469aaf6a30f4187ed6de7c0aed5c2dd2d1c2d31 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: make ide_hwif_t.ide_dma_{host_off,off_quietly} void (v2)

* since ide_hwif_t.ide_dma_{host_off,off_quietly} always return '0'
make these functions void and while at it drop "ide_" prefix
* fix comment for __ide_dma_off_quietly()
* make __ide_dma_{host_off,off_quietly,off}() void and drop "__" prefix

v2:
* while at it rename atiixp_ide_dma_host_off() to atiixp_dma_host_off(),
sgiioc4_ide_dma_{host_off,off_quietly}() to sgiioc4_dma_{host_off,off_quietly}()
and sl82c105_ide_dma_off_quietly() to sl82c105_dma_off_quietly()
[ Noticed by Sergei Shtylyov <sshtylyov@ru.mvista.com>. ]

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
3608b5d71a52c053787dbad6af20c25f7e0b75a9 17-Feb-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> ide: add ide_set_dma() helper (v2)

* add ide_set_dma() helper and make ide_hwif_t.ide_dma_check return
-1 when DMA needs to be disabled (== need to call ->ide_dma_off_quietly)
0 when DMA needs to be enabled (== need to call ->ide_dma_on)
1 when DMA setting shouldn't be changed
* fix IDE code to use ide_set_dma() instead if using ->ide_dma_check directly

v2:
* updated for scc_pata

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
f0dd8712eb8cc5687b4582fbc41cfbcd55bba0d2 17-Feb-2007 Albert Lee <albertcc@tw.ibm.com> ide: clear bmdma status in ide_intr() for ICHx controllers (revised #4)

patch 1/2 (revised):
- Fix drive->waiting_for_dma to work with CDB-intr devices.
- Do the dma status clearing in ide_intr() and add a new
hwif->ide_dma_clear_irq for Intel ICHx controllers.

Revised per Alan, Sergei and Bart's advice.

Patch against 2.6.20-rc6. Tested ok on my ICH4 and pdc20275 adapters.
Please review/apply, thanks.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: "Adam W. Hawks" <awhawks@us.ibm.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
7d12e780e003f93433d49ce78cfedf4b4c52adc5 05-Oct-2006 David Howells <dhowells@redhat.com> IRQ: Maintain regs pointer globally rather than passing to IRQ handlers

Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.

The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).

Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.

Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.

I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.

This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

struct pt_regs *old_regs = set_irq_regs(regs);

And put the old one back at the end:

set_irq_regs(old_regs);

Don't pass regs through to generic_handle_irq() or __do_IRQ().

In timer_interrupt(), this sort of change will be necessary:

- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);

I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().

Some notes on the interrupt handling in the drivers:

(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.

(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.

(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.

Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
/drivers/ide/ide-io.c
8c2c0118b86183bf4826db990cae5c8a8d6c6746 03-Oct-2006 Jason Lunz <lunz@falooley.org> [PATCH] ide: reprogram disk pio timings on resume

Add a step to the IDE PM state machine that reprograms disk PIO timings
as the first step on resume. This prevents ide deadlock on
resume-from-ram on my nforce3-based laptop.

An earlier implementation was written entirely within the amd74xx ide
driver, but Alan helpfully pointed out that this is the correct thing to
do globally. Still, I'm only calling hwif->tuneproc() for disks, based
on two things:

- The existing state machine is already passed over for non-disk drives
- Previous testing on my laptop shows that the hangs are related only
to the disk - suspend/resume from a livecd showed that there's no
need for this on the cdrom.

Signed-off-by: Jason Lunz <lunz@falooley.org>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Brad Campbell <brad@wasp.net.au>
Cc: David Brownell <david-b@pacbell.net>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
ce42f19137225d01be9388a73703df40fb7af80f 03-Oct-2006 Hua Zhong <hzhong@gmail.com> [PATCH] IDE error handling fixes

In 2.6.15.1 I encountered some IDE crashes when unplugging IDE cables to
emulate disk errors. Below is a patch against 2.6.16 which I think still
applies.

1. The first BUG_ON could trigger when a PREFLUSH IO fails (it would
fail the original barrier request which hasn't been marked REQ_STARTED
yet).

2. the rq could have been dequeued already (same as 1).

3. HWGROUP(drive)->rq could be NULL because of the ide_error() several
lines earlier.

Signed-off-by: Hua Zhong <hzhong@gmail.com>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
cdd6026217c0e4cda2efce1bdc318661bef1f66f 28-Jul-2006 Jens Axboe <axboe@suse.de> [PATCH] Remove ->rq_status from struct request

After Christophs SCSI change, the only usage left is RQ_ACTIVE
and RQ_INACTIVE. The block layer sets RQ_INACTIVE right before freeing
the request, so any check for RQ_INACTIVE in a driver is a bug and
indicates use-after-free.

So kill/clean the remaining users, straight forward.

Signed-off-by: Jens Axboe <axboe@suse.de>
/drivers/ide/ide-io.c
c00895ab2f08df7044e58ee01c38bf0a661ea0eb 30-Sep-2006 Jens Axboe <axboe@kernel.dk> [PATCH] Remove ->waiting member from struct request

As the comments indicates in blkdev.h, we can fold it into ->end_io_data
usage as that is really what ->waiting is. Fixup the users of
blk_end_sync_rq().

Signed-off-by: Jens Axboe <axboe@kernel.dk>
/drivers/ide/ide-io.c
4aff5e2333c9a1609662f2091f55c3f6fffdad36 10-Aug-2006 Jens Axboe <axboe@suse.de> [PATCH] Split struct request ->flags into two parts

Right now ->flags is a bit of a mess: some are request types, and
others are just modifiers. Clean this up by splitting it into
->cmd_type and ->cmd_flags. This allows introduction of generic
Linux block message types, useful for sending generic Linux commands
to block devices.

Signed-off-by: Jens Axboe <axboe@suse.de>
/drivers/ide/ide-io.c
60be6b9a41cb0da0df7a9f11486da56baebf04cd 03-Jul-2006 Ingo Molnar <mingo@elte.hu> [PATCH] lockdep: annotate on-stack completions

lockdep needs to have the waitqueue lock initialized for on-stack waitqueues
implicitly initialized by DECLARE_COMPLETION(). Annotate on-stack completions
accordingly.

Has no effect on non-lockdep kernels.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
366c7f554e888e51b8395f9b07b273fe775c7ff3 03-Jul-2006 Ingo Molnar <mingo@elte.hu> [PATCH] lockdep: annotate enable_in_hardirq()

Make use of local_irq_enable_in_hardirq() API to annotate places that enable
hardirqs in hardirq context.

Has no effect on non-lockdep kernels.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
6ab3d5624e172c553004ecc862bfeac16d9d68b7 30-Jun-2006 Jörn Engel <joern@wohnheim.fh-wedel.de> Remove obsolete #include <linux/config.h>

Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
/drivers/ide/ide-io.c
da574af755bcb1d604e01feadf2a8c31b364447c 28-Jun-2006 Alan Cox <alan@lxorguk.ukuu.org.uk> [PATCH] ide: fix error handling for drives which clear the FIFO on error

If the controller FIFO cleared automatically on error we must not try
and drain it as this will hang some chips.

Based in concept on a broken patch from -mm some while back

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
da206c9e68cb93fcab43592d46276c02889c1250 26-Jun-2006 Linus Torvalds <torvalds@g5.osdl.org> Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial

* git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial:
typo fixes
Clean up 'inline is not at beginning' warnings for usb storage
Storage class should be first
i386: Trivial typo fixes
ixj: make ixj_set_tone_off() static
spelling fixes
fix paniced->panicked typos
Spelling fixes for Documentation/atomic_ops.txt
move acknowledgment for Mark Adler to CREDITS
remove the bouncing email address of David Campbell
178184b60979992508130741f16499c360bc9c9a 26-Jun-2006 Al Boldi <a1426z@gawab.com> [PATCH] ide-io: increase timeout value to allow for slave wakeup

During an STR resume cycle, the ide master disk times-out when there is
also a slave present (especially CD). Increasing the timeout in ide-io
from 10,000 to 100,000 fixes this problem.

Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
d6e05edc59ecd79e8badf440c0d295a979bdfa3e 26-Jun-2006 Andreas Mohr <andi@lisas.de> spelling fixes

acquired (aquired)
contiguous (contigious)
successful (succesful, succesfull)
surprise (suprise)
whether (weather)
some other misspellings

Signed-off-by: Andreas Mohr <andi@lisas.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
/drivers/ide/ide-io.c
dbe217af3be08346f4b1abb885c2d9ec29c98fac 25-Jun-2006 Alan Cox <alan@lxorguk.ukuu.org.uk> [PATCH] IDE CD end-of media error fix

This is a patch from Alan that fixes a real ide-cd.c regression causing
bogus "Media Check" failures for perfectly valid Fedora install ISOs, on
certain CD-ROM drives.

This is a forward port to 2.6.16 (from RHEL) of the minimal changes for the
end of media problem. It may not be sufficient for some controllers
(promise notably) and it does not touch the locking so the error path
locking is as horked as in mainstream.

From: Ingo Molnar <mingo@elte.hu>

I have ported the patch to 2.6.17-rc4 and tested it by provoking
end-of-media IO errors with an unaligned ISO image. Unlike the vanilla
kernel, the patched kernel interpreted the error condition correctly with
512 byte granularity:

hdc: command error: status=0x51 { DriveReady SeekComplete Error }
hdc: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
ide: failed opcode was: unknown
ATAPI device hdc:
Error: Illegal request -- (Sense key=0x05)
Illegal mode for this track or incompatible medium -- (asc=0x64, ascq=0x00)
The failed "Read 10" packet command was:
"28 00 00 04 fb 78 00 00 06 00 00 00 00 00 00 00 "
end_request: I/O error, dev hdc, sector 1306080
Buffer I/O error on device hdc, logical block 163260
Buffer I/O error on device hdc, logical block 163261
Buffer I/O error on device hdc, logical block 163262

the unpatched kernel produces an incorrect error dump:

hdc: command error: status=0x51 { DriveReady SeekComplete Error }
hdc: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
ide: failed opcode was: unknown
end_request: I/O error, dev hdc, sector 1306080
Buffer I/O error on device hdc, logical block 163260
hdc: command error: status=0x51 { DriveReady SeekComplete Error }
hdc: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
ide: failed opcode was: unknown
end_request: I/O error, dev hdc, sector 1306088
Buffer I/O error on device hdc, logical block 163261
hdc: command error: status=0x51 { DriveReady SeekComplete Error }
hdc: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
ide: failed opcode was: unknown
end_request: I/O error, dev hdc, sector 1306096
Buffer I/O error on device hdc, logical block 163262

I do not have the right type of CD-ROM drive to reproduce the end-of-media
data corruption bug myself, but this same patch in RHEL solved it.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: Jens Axboe <axboe@suse.de>
Cc: Matt Mackall <mpm@selenic.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
ad3caddaa1708e506f20b8e25a4a8ae586fc7d5b 13-Jun-2006 Jens Axboe <axboe@suse.de> [PATCH] Get rid of struct request request_pm_state member

The IDE power management can just use the ->end_io_data member to store
it's data.

Signed-off-by: Jens Axboe <axboe@suse.de>
/drivers/ide/ide-io.c
a7ff7d41fec06c518caa82a818a70610a29d0e75 03-Feb-2006 Adrian Bunk <bunk@stusta.de> [PATCH] drivers/ide/ide-io.c: make __ide_end_request() static

Since there's no longer any external user, we can make __ide_end_request()
static.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Acked-by: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
ba027def7be0d6494b72603d5758acc0fb1c7514 12-Jan-2006 Jens Axboe <axboe@suse.de> [PATCH] Revert ide softirq handling

There's a problem with the REQ_BLOCK_PC handling as well (bad ->data_len
handling) where it could actually complete a request ahead of time. I
suggest we just back this out for now, I will resubmit it later when I'm
fully confident in it.

This reverts commit 8672d57138b34447719cd7749f3d21070e1175a1

Signed-off-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
4ff57935ad0f1620269f4b08e8acfda619cc5e4b 10-Jan-2006 Jens Axboe <axboe@suse.de> [PATCH] ide: preserve errors for failed requests

To preserve the ->errors values for requests that failed, use the normal
completion path for that.

Signed-off-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
8672d57138b34447719cd7749f3d21070e1175a1 09-Jan-2006 Jens Axboe <axboe@suse.de> [IDE] Use the block layer deferred softirq request completion

This patch makes IDE use the new blk_complete_request() interface.
There's still room for improvement, as __ide_end_request() really
could drop the lock after getting HWGROUP->rq (why does it need to
hold it in the first place? If ->rq access isn't serialized, we are
screwed anyways).

Signed-off-by: Jens Axboe <axboe@suse.de>
/drivers/ide/ide-io.c
3e087b575496b8aa445192f58e7d996b1cdfa121 06-Jan-2006 Tejun Heo <htejun@gmail.com> [BLOCK] update IDE to use new blk_ordered for barriers

Update IDE to use new blk_ordered. This change makes the
following behavior changes.

* Partial completion of the barrier request is handled as
failure of the whole ordered sequence. No more partial
completion for barrier requests.

* Any failure of pre or post flush request results in failure
of the whole ordered sequence.

So, successfully completed ordered sequence guarantees that
all requests prior to the barrier made to physical medium and,
then, the while barrier request made to the physical medium.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jens Axboe <axboe@suse.de>
/drivers/ide/ide-io.c
8ffdc6550c47f75ca4e6c9f30a2a89063e035cf2 06-Jan-2006 Tejun Heo <htejun@gmail.com> [BLOCK] add @uptodate to end_that_request_last() and @error to rq_end_io_fn()

add @uptodate argument to end_that_request_last() and @error
to rq_end_io_fn(). there's no generic way to pass error code
to request completion function, making generic error handling
of non-fs request difficult (rq->errors is driver-specific and
each driver uses it differently). this patch adds @uptodate
to end_that_request_last() and @error to rq_end_io_fn().

for fs requests, this doesn't really matter, so just using the
same uptodate argument used in the last call to
end_that_request_first() should suffice. imho, this can also
help the generic command-carrying request jens is working on.

Signed-off-by: tejun heo <htejun@gmail.com>
Signed-Off-By: Jens Axboe <axboe@suse.de>
/drivers/ide/ide-io.c
071ffcc0f7dd8df871f443be3f5059f05da528e2 19-Nov-2005 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> [PATCH] ide: remove unused ide_action_t:ide_next

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
/drivers/ide/ide-io.c
867f8b4e47a17c5d68c98dc6eee12739c4490056 09-Oct-2005 Benjamin Herrenschmidt <benh@kernel.crashing.org> [PATCH] ide: Workaround PM problem

The logic in ide_do_request() doesn't guarantee that both drives will be
serviced after a call. It may "forget" to service one in some
circumstances, including when one of the drive is suspended (it will
eventually fail to service the slave when the master is suspended for
example). This prevents the wakeup requests that gets queued on wakeup
from sleep from beeing serviced in some cases when 2 drives are sharing
an IDE bus.

The problem is deep enough in the way this code works (and there are
probably a few other problematic but rare corner cases) and fixing it
would require some major rethinking of the way IDE decides which channel
to service. This is not 2.6.14 material. However, in the meantime,
Bart has accepted this simple workaround that will fix the crash on
wakeup from sleep since this specific corner case is actually hitting
users to get into 2.6.14.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
338cec3253a6d43d02e5e96abc327197565efcc8 10-Sep-2005 Adrian Bunk <bunk@stusta.de> [PATCH] merge some from Rusty's trivial patches

This patch contains the most trivial from Rusty's trivial patches:
- spelling fixes
- remove duplicate includes

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
46dacba52a19d1414ba249499a48382c16242d99 04-Sep-2005 Michal Schmidt <xschmi00@stud.feec.vutbr.cz> [PATCH] swsusp: prevent disks from spinning down and up

Stop the disks from spinning down and up on suspend.

Signed-off-by: Michal Schmidt <xschmi00@stud.feec.vutbr.cz>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
/drivers/ide/ide-io.c
1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 17-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org> Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!
/drivers/ide/ide-io.c