| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ATAPI support. |
|---|
| 3 | 4 | */ |
|---|
| .. | .. |
|---|
| 94 | 95 | |
|---|
| 95 | 96 | rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, 0); |
|---|
| 96 | 97 | ide_req(rq)->type = ATA_PRIV_MISC; |
|---|
| 97 | | - rq->special = (char *)pc; |
|---|
| 98 | + ide_req(rq)->special = pc; |
|---|
| 98 | 99 | |
|---|
| 99 | 100 | if (buf && bufflen) { |
|---|
| 100 | 101 | error = blk_rq_map_kern(drive->queue, rq, buf, bufflen, |
|---|
| .. | .. |
|---|
| 172 | 173 | void ide_prep_sense(ide_drive_t *drive, struct request *rq) |
|---|
| 173 | 174 | { |
|---|
| 174 | 175 | struct request_sense *sense = &drive->sense_data; |
|---|
| 175 | | - struct request *sense_rq = drive->sense_rq; |
|---|
| 176 | | - struct scsi_request *req = scsi_req(sense_rq); |
|---|
| 176 | + struct request *sense_rq; |
|---|
| 177 | + struct scsi_request *req; |
|---|
| 177 | 178 | unsigned int cmd_len, sense_len; |
|---|
| 178 | 179 | int err; |
|---|
| 179 | 180 | |
|---|
| .. | .. |
|---|
| 196 | 197 | if (ata_sense_request(rq) || drive->sense_rq_armed) |
|---|
| 197 | 198 | return; |
|---|
| 198 | 199 | |
|---|
| 200 | + sense_rq = drive->sense_rq; |
|---|
| 201 | + if (!sense_rq) { |
|---|
| 202 | + sense_rq = blk_mq_alloc_request(drive->queue, REQ_OP_DRV_IN, |
|---|
| 203 | + BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT); |
|---|
| 204 | + drive->sense_rq = sense_rq; |
|---|
| 205 | + } |
|---|
| 206 | + req = scsi_req(sense_rq); |
|---|
| 207 | + |
|---|
| 199 | 208 | memset(sense, 0, sizeof(*sense)); |
|---|
| 200 | 209 | |
|---|
| 201 | | - blk_rq_init(rq->q, sense_rq); |
|---|
| 202 | 210 | scsi_req_init(req); |
|---|
| 203 | 211 | |
|---|
| 204 | 212 | err = blk_rq_map_kern(drive->queue, sense_rq, sense, sense_len, |
|---|
| .. | .. |
|---|
| 207 | 215 | if (printk_ratelimit()) |
|---|
| 208 | 216 | printk(KERN_WARNING PFX "%s: failed to map sense " |
|---|
| 209 | 217 | "buffer\n", drive->name); |
|---|
| 218 | + blk_mq_free_request(sense_rq); |
|---|
| 219 | + drive->sense_rq = NULL; |
|---|
| 210 | 220 | return; |
|---|
| 211 | 221 | } |
|---|
| 212 | 222 | |
|---|
| .. | .. |
|---|
| 225 | 235 | |
|---|
| 226 | 236 | int ide_queue_sense_rq(ide_drive_t *drive, void *special) |
|---|
| 227 | 237 | { |
|---|
| 238 | + ide_hwif_t *hwif = drive->hwif; |
|---|
| 239 | + struct request *sense_rq; |
|---|
| 240 | + unsigned long flags; |
|---|
| 241 | + |
|---|
| 242 | + spin_lock_irqsave(&hwif->lock, flags); |
|---|
| 243 | + |
|---|
| 228 | 244 | /* deferred failure from ide_prep_sense() */ |
|---|
| 229 | 245 | if (!drive->sense_rq_armed) { |
|---|
| 230 | 246 | printk(KERN_WARNING PFX "%s: error queuing a sense request\n", |
|---|
| 231 | 247 | drive->name); |
|---|
| 248 | + spin_unlock_irqrestore(&hwif->lock, flags); |
|---|
| 232 | 249 | return -ENOMEM; |
|---|
| 233 | 250 | } |
|---|
| 234 | 251 | |
|---|
| 235 | | - drive->sense_rq->special = special; |
|---|
| 252 | + sense_rq = drive->sense_rq; |
|---|
| 253 | + ide_req(sense_rq)->special = special; |
|---|
| 236 | 254 | drive->sense_rq_armed = false; |
|---|
| 237 | 255 | |
|---|
| 238 | 256 | drive->hwif->rq = NULL; |
|---|
| 239 | 257 | |
|---|
| 240 | | - elv_add_request(drive->queue, drive->sense_rq, ELEVATOR_INSERT_FRONT); |
|---|
| 258 | + ide_insert_request_head(drive, sense_rq); |
|---|
| 259 | + spin_unlock_irqrestore(&hwif->lock, flags); |
|---|
| 241 | 260 | return 0; |
|---|
| 242 | 261 | } |
|---|
| 243 | 262 | EXPORT_SYMBOL_GPL(ide_queue_sense_rq); |
|---|
| .. | .. |
|---|
| 269 | 288 | */ |
|---|
| 270 | 289 | drive->hwif->rq = NULL; |
|---|
| 271 | 290 | ide_requeue_and_plug(drive, failed_rq); |
|---|
| 272 | | - if (ide_queue_sense_rq(drive, pc)) { |
|---|
| 273 | | - blk_start_request(failed_rq); |
|---|
| 291 | + if (ide_queue_sense_rq(drive, pc)) |
|---|
| 274 | 292 | ide_complete_rq(drive, BLK_STS_IOERR, blk_rq_bytes(failed_rq)); |
|---|
| 275 | | - } |
|---|
| 276 | 293 | } |
|---|
| 277 | 294 | EXPORT_SYMBOL_GPL(ide_retry_pc); |
|---|
| 278 | 295 | |
|---|
| .. | .. |
|---|
| 591 | 608 | |
|---|
| 592 | 609 | static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) |
|---|
| 593 | 610 | { |
|---|
| 594 | | - struct ide_atapi_pc *uninitialized_var(pc); |
|---|
| 611 | + struct ide_atapi_pc *pc; |
|---|
| 595 | 612 | ide_hwif_t *hwif = drive->hwif; |
|---|
| 596 | 613 | struct request *rq = hwif->rq; |
|---|
| 597 | 614 | ide_expiry_t *expiry; |
|---|