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: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 631de370
This diff is collapsed.
...@@ -16,16 +16,19 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) ...@@ -16,16 +16,19 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
spin_lock_irq(&hwgroup->lock); spin_lock_irq(&hwgroup->lock);
if (drive->dev_flags & IDE_DFLAG_PARKED) { if (drive->dev_flags & IDE_DFLAG_PARKED) {
int reset_timer = time_before(timeout, drive->sleep); int reset_timer = time_before(timeout, drive->sleep);
int start_queue = 0;
drive->sleep = timeout; drive->sleep = timeout;
wake_up_all(&ide_park_wq); wake_up_all(&ide_park_wq);
if (reset_timer && hwgroup->sleeping && if (reset_timer && del_timer(&hwgroup->timer))
del_timer(&hwgroup->timer)) { start_queue = 1;
hwgroup->sleeping = 0; spin_unlock_irq(&hwgroup->lock);
ide_unlock_hwgroup(hwgroup);
if (start_queue) {
spin_lock_irq(q->queue_lock);
blk_start_queueing(q); blk_start_queueing(q);
spin_unlock_irq(q->queue_lock);
} }
spin_unlock_irq(&hwgroup->lock);
return; return;
} }
spin_unlock_irq(&hwgroup->lock); spin_unlock_irq(&hwgroup->lock);
......
...@@ -881,8 +881,7 @@ static int ide_init_queue(ide_drive_t *drive) ...@@ -881,8 +881,7 @@ static int ide_init_queue(ide_drive_t *drive)
* do not. * do not.
*/ */
q = blk_init_queue_node(do_ide_request, &hwif->hwgroup->lock, q = blk_init_queue_node(do_ide_request, NULL, hwif_to_node(hwif));
hwif_to_node(hwif));
if (!q) if (!q)
return 1; return 1;
......
...@@ -603,8 +603,6 @@ struct ide_drive_s { ...@@ -603,8 +603,6 @@ struct ide_drive_s {
unsigned long dev_flags; unsigned long dev_flags;
unsigned long sleep; /* sleep until this time */ unsigned long sleep; /* sleep until this time */
unsigned long service_start; /* time we started last request */
unsigned long service_time; /* service time of last request */
unsigned long timeout; /* max time to wait for irq */ unsigned long timeout; /* max time to wait for irq */
special_t special; /* special action flags */ special_t special; /* special action flags */
...@@ -872,8 +870,6 @@ typedef struct hwgroup_s { ...@@ -872,8 +870,6 @@ typedef struct hwgroup_s {
/* BOOL: protects all fields below */ /* BOOL: protects all fields below */
volatile int busy; volatile int busy;
/* BOOL: wake us up on timer expiry */
unsigned int sleeping : 1;
/* BOOL: polling active & poll_timeout field valid */ /* BOOL: polling active & poll_timeout field valid */
unsigned int polling : 1; unsigned int polling : 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment