aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-04-17 16:37:20 -0400
committerJens Axboe <axboe@fb.com>2015-05-05 15:40:42 -0400
commita7928c1578c550bd6f4dec62d65132e6db226c57 (patch)
tree1a9a13abf0679e7dc4e1e5124cd4fcb3c0ac1265 /drivers/ide
parentac7cdff00a33d48d27217560fa3b16d802e5f535 (diff)
block: move PM request support to IDE
This removes the request types and hacks from the block code and into the old IDE driver. There is a small amunt of code duplication due to this, but it's not too bad. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-eh.c2
-rw-r--r--drivers/ide/ide-io.c8
-rw-r--r--drivers/ide/ide-pm.c56
-rw-r--r--drivers/ide/ide-taskfile.c2
4 files changed, 49 insertions, 19 deletions
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c
index 19d809c48a8d..d6da011299f5 100644
--- a/drivers/ide/ide-eh.c
+++ b/drivers/ide/ide-eh.c
@@ -129,7 +129,7 @@ ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat)
129 129
130 if (cmd) 130 if (cmd)
131 ide_complete_cmd(drive, cmd, stat, err); 131 ide_complete_cmd(drive, cmd, stat, err);
132 } else if (blk_pm_request(rq)) { 132 } else if (ata_pm_request(rq)) {
133 rq->errors = 1; 133 rq->errors = 1;
134 ide_complete_pm_rq(drive, rq); 134 ide_complete_pm_rq(drive, rq);
135 return ide_stopped; 135 return ide_stopped;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 8e55abd03a24..669ea1e45795 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -320,7 +320,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
320 goto kill_rq; 320 goto kill_rq;
321 } 321 }
322 322
323 if (blk_pm_request(rq)) 323 if (ata_pm_request(rq))
324 ide_check_pm_state(drive, rq); 324 ide_check_pm_state(drive, rq);
325 325
326 drive->hwif->tp_ops->dev_select(drive); 326 drive->hwif->tp_ops->dev_select(drive);
@@ -342,8 +342,8 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
342 342
343 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) 343 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE)
344 return execute_drive_cmd(drive, rq); 344 return execute_drive_cmd(drive, rq);
345 else if (blk_pm_request(rq)) { 345 else if (ata_pm_request(rq)) {
346 struct request_pm_state *pm = rq->special; 346 struct ide_pm_state *pm = rq->special;
347#ifdef DEBUG_PM 347#ifdef DEBUG_PM
348 printk("%s: start_power_step(step: %d)\n", 348 printk("%s: start_power_step(step: %d)\n",
349 drive->name, pm->pm_step); 349 drive->name, pm->pm_step);
@@ -538,7 +538,7 @@ repeat:
538 * state machine. 538 * state machine.
539 */ 539 */
540 if ((drive->dev_flags & IDE_DFLAG_BLOCKED) && 540 if ((drive->dev_flags & IDE_DFLAG_BLOCKED) &&
541 blk_pm_request(rq) == 0 && 541 ata_pm_request(rq) == 0 &&
542 (rq->cmd_flags & REQ_PREEMPT) == 0) { 542 (rq->cmd_flags & REQ_PREEMPT) == 0) {
543 /* there should be no pending command at this point */ 543 /* there should be no pending command at this point */
544 ide_unlock_port(hwif); 544 ide_unlock_port(hwif);
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index 8d1e32d7cd97..081e43458d50 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -8,7 +8,7 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
8 ide_drive_t *pair = ide_get_pair_dev(drive); 8 ide_drive_t *pair = ide_get_pair_dev(drive);
9 ide_hwif_t *hwif = drive->hwif; 9 ide_hwif_t *hwif = drive->hwif;
10 struct request *rq; 10 struct request *rq;
11 struct request_pm_state rqpm; 11 struct ide_pm_state rqpm;
12 int ret; 12 int ret;
13 13
14 if (ide_port_acpi(hwif)) { 14 if (ide_port_acpi(hwif)) {
@@ -19,7 +19,7 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
19 19
20 memset(&rqpm, 0, sizeof(rqpm)); 20 memset(&rqpm, 0, sizeof(rqpm));
21 rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 21 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
22 rq->cmd_type = REQ_TYPE_PM_SUSPEND; 22 rq->cmd_type = REQ_TYPE_ATA_PM_SUSPEND;
23 rq->special = &rqpm; 23 rq->special = &rqpm;
24 rqpm.pm_step = IDE_PM_START_SUSPEND; 24 rqpm.pm_step = IDE_PM_START_SUSPEND;
25 if (mesg.event == PM_EVENT_PRETHAW) 25 if (mesg.event == PM_EVENT_PRETHAW)
@@ -38,13 +38,43 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
38 return ret; 38 return ret;
39} 39}
40 40
41static void ide_end_sync_rq(struct request *rq, int error)
42{
43 complete(rq->end_io_data);
44}
45
46static int ide_pm_execute_rq(struct request *rq)
47{
48 struct request_queue *q = rq->q;
49 DECLARE_COMPLETION_ONSTACK(wait);
50
51 rq->end_io_data = &wait;
52 rq->end_io = ide_end_sync_rq;
53
54 spin_lock_irq(q->queue_lock);
55 if (unlikely(blk_queue_dying(q))) {
56 rq->cmd_flags |= REQ_QUIET;
57 rq->errors = -ENXIO;
58 __blk_end_request_all(rq, rq->errors);
59 spin_unlock_irq(q->queue_lock);
60 return -ENXIO;
61 }
62 __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT);
63 __blk_run_queue_uncond(q);
64 spin_unlock_irq(q->queue_lock);
65
66 wait_for_completion_io(&wait);
67
68 return rq->errors ? -EIO : 0;
69}
70
41int generic_ide_resume(struct device *dev) 71int generic_ide_resume(struct device *dev)
42{ 72{
43 ide_drive_t *drive = to_ide_device(dev); 73 ide_drive_t *drive = to_ide_device(dev);
44 ide_drive_t *pair = ide_get_pair_dev(drive); 74 ide_drive_t *pair = ide_get_pair_dev(drive);
45 ide_hwif_t *hwif = drive->hwif; 75 ide_hwif_t *hwif = drive->hwif;
46 struct request *rq; 76 struct request *rq;
47 struct request_pm_state rqpm; 77 struct ide_pm_state rqpm;
48 int err; 78 int err;
49 79
50 if (ide_port_acpi(hwif)) { 80 if (ide_port_acpi(hwif)) {
@@ -59,13 +89,13 @@ int generic_ide_resume(struct device *dev)
59 89
60 memset(&rqpm, 0, sizeof(rqpm)); 90 memset(&rqpm, 0, sizeof(rqpm));
61 rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 91 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
62 rq->cmd_type = REQ_TYPE_PM_RESUME; 92 rq->cmd_type = REQ_TYPE_ATA_PM_RESUME;
63 rq->cmd_flags |= REQ_PREEMPT; 93 rq->cmd_flags |= REQ_PREEMPT;
64 rq->special = &rqpm; 94 rq->special = &rqpm;
65 rqpm.pm_step = IDE_PM_START_RESUME; 95 rqpm.pm_step = IDE_PM_START_RESUME;
66 rqpm.pm_state = PM_EVENT_ON; 96 rqpm.pm_state = PM_EVENT_ON;
67 97
68 err = blk_execute_rq(drive->queue, NULL, rq, 1); 98 err = ide_pm_execute_rq(rq);
69 blk_put_request(rq); 99 blk_put_request(rq);
70 100
71 if (err == 0 && dev->driver) { 101 if (err == 0 && dev->driver) {
@@ -80,7 +110,7 @@ int generic_ide_resume(struct device *dev)
80 110
81void ide_complete_power_step(ide_drive_t *drive, struct request *rq) 111void ide_complete_power_step(ide_drive_t *drive, struct request *rq)
82{ 112{
83 struct request_pm_state *pm = rq->special; 113 struct ide_pm_state *pm = rq->special;
84 114
85#ifdef DEBUG_PM 115#ifdef DEBUG_PM
86 printk(KERN_INFO "%s: complete_power_step(step: %d)\n", 116 printk(KERN_INFO "%s: complete_power_step(step: %d)\n",
@@ -110,7 +140,7 @@ void ide_complete_power_step(ide_drive_t *drive, struct request *rq)
110 140
111ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq) 141ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *rq)
112{ 142{
113 struct request_pm_state *pm = rq->special; 143 struct ide_pm_state *pm = rq->special;
114 struct ide_cmd cmd = { }; 144 struct ide_cmd cmd = { };
115 145
116 switch (pm->pm_step) { 146 switch (pm->pm_step) {
@@ -182,7 +212,7 @@ out_do_tf:
182void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq) 212void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
183{ 213{
184 struct request_queue *q = drive->queue; 214 struct request_queue *q = drive->queue;
185 struct request_pm_state *pm = rq->special; 215 struct ide_pm_state *pm = rq->special;
186 unsigned long flags; 216 unsigned long flags;
187 217
188 ide_complete_power_step(drive, rq); 218 ide_complete_power_step(drive, rq);
@@ -191,10 +221,10 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
191 221
192#ifdef DEBUG_PM 222#ifdef DEBUG_PM
193 printk("%s: completing PM request, %s\n", drive->name, 223 printk("%s: completing PM request, %s\n", drive->name,
194 (rq->cmd_type == REQ_TYPE_PM_SUSPEND) ? "suspend" : "resume"); 224 (rq->cmd_type == REQ_TYPE_ATA_PM_SUSPEND) ? "suspend" : "resume");
195#endif 225#endif
196 spin_lock_irqsave(q->queue_lock, flags); 226 spin_lock_irqsave(q->queue_lock, flags);
197 if (rq->cmd_type == REQ_TYPE_PM_SUSPEND) 227 if (rq->cmd_type == REQ_TYPE_ATA_PM_SUSPEND)
198 blk_stop_queue(q); 228 blk_stop_queue(q);
199 else 229 else
200 drive->dev_flags &= ~IDE_DFLAG_BLOCKED; 230 drive->dev_flags &= ~IDE_DFLAG_BLOCKED;
@@ -208,13 +238,13 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
208 238
209void ide_check_pm_state(ide_drive_t *drive, struct request *rq) 239void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
210{ 240{
211 struct request_pm_state *pm = rq->special; 241 struct ide_pm_state *pm = rq->special;
212 242
213 if (rq->cmd_type == REQ_TYPE_PM_SUSPEND && 243 if (rq->cmd_type == REQ_TYPE_ATA_PM_SUSPEND &&
214 pm->pm_step == IDE_PM_START_SUSPEND) 244 pm->pm_step == IDE_PM_START_SUSPEND)
215 /* Mark drive blocked when starting the suspend sequence. */ 245 /* Mark drive blocked when starting the suspend sequence. */
216 drive->dev_flags |= IDE_DFLAG_BLOCKED; 246 drive->dev_flags |= IDE_DFLAG_BLOCKED;
217 else if (rq->cmd_type == REQ_TYPE_PM_RESUME && 247 else if (rq->cmd_type == REQ_TYPE_ATA_PM_RESUME &&
218 pm->pm_step == IDE_PM_START_RESUME) { 248 pm->pm_step == IDE_PM_START_RESUME) {
219 /* 249 /*
220 * The first thing we do on wakeup is to wait for BSY bit to 250 * The first thing we do on wakeup is to wait for BSY bit to
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index dabb88b1cbec..0979e126fff1 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -186,7 +186,7 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive)
186 tf->command == ATA_CMD_CHK_POWER) { 186 tf->command == ATA_CMD_CHK_POWER) {
187 struct request *rq = hwif->rq; 187 struct request *rq = hwif->rq;
188 188
189 if (blk_pm_request(rq)) 189 if (ata_pm_request(rq))
190 ide_complete_pm_rq(drive, rq); 190 ide_complete_pm_rq(drive, rq);
191 else 191 else
192 ide_finish_cmd(drive, cmd, stat); 192 ide_finish_cmd(drive, cmd, stat);