ide: use do_rw_taskfile() for ATA_CMD_PACKET commands
* Pass command to ide_issue_pc() and update ->do_request methods in ide-{cd,floppy,tape}.c accordingly. * Convert ide_pktcmd_tf_load() to ide_init_packet_cmd() which just initializes command structure and use do_rw_taskfile() to load ATA_CMD_PACKET commands. While at it: * Rename ide{floppy,tape}_issue_pc() to ide_{floppy,tape}_issue_pc(). 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>
This commit is contained in:
@@ -487,23 +487,15 @@ next_irq:
|
|||||||
return ide_started;
|
return ide_started;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount)
|
static void ide_init_packet_cmd(struct ide_cmd *cmd, u32 tf_flags,
|
||||||
|
u16 bcount, u8 dma)
|
||||||
{
|
{
|
||||||
ide_hwif_t *hwif = drive->hwif;
|
cmd->protocol = dma ? ATAPI_PROT_DMA : ATAPI_PROT_PIO;
|
||||||
struct ide_cmd cmd;
|
cmd->tf_flags |= IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM |
|
||||||
u8 dma = drive->dma;
|
IDE_TFLAG_OUT_FEATURE | tf_flags;
|
||||||
|
cmd->tf.feature = dma; /* Use PIO/DMA */
|
||||||
memset(&cmd, 0, sizeof(cmd));
|
cmd->tf.lbam = bcount & 0xff;
|
||||||
cmd.tf_flags = IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM |
|
cmd->tf.lbah = (bcount >> 8) & 0xff;
|
||||||
IDE_TFLAG_OUT_FEATURE | tf_flags;
|
|
||||||
cmd.tf.feature = dma; /* Use PIO/DMA */
|
|
||||||
cmd.tf.lbam = bcount & 0xff;
|
|
||||||
cmd.tf.lbah = (bcount >> 8) & 0xff;
|
|
||||||
|
|
||||||
ide_tf_dump(drive->name, &cmd.tf);
|
|
||||||
hwif->tp_ops->set_irq(hwif, 1);
|
|
||||||
SELECT_MASK(drive, 0);
|
|
||||||
hwif->tp_ops->tf_load(drive, &cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 ide_read_ireason(ide_drive_t *drive)
|
static u8 ide_read_ireason(ide_drive_t *drive)
|
||||||
@@ -634,24 +626,17 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
|
|||||||
return ide_started;
|
return ide_started;
|
||||||
}
|
}
|
||||||
|
|
||||||
ide_startstop_t ide_issue_pc(ide_drive_t *drive)
|
ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd)
|
||||||
{
|
{
|
||||||
struct ide_atapi_pc *pc;
|
struct ide_atapi_pc *pc;
|
||||||
ide_hwif_t *hwif = drive->hwif;
|
ide_hwif_t *hwif = drive->hwif;
|
||||||
const struct ide_dma_ops *dma_ops = hwif->dma_ops;
|
const struct ide_dma_ops *dma_ops = hwif->dma_ops;
|
||||||
struct ide_cmd *cmd = &hwif->cmd;
|
|
||||||
ide_expiry_t *expiry = NULL;
|
ide_expiry_t *expiry = NULL;
|
||||||
struct request *rq = hwif->rq;
|
struct request *rq = hwif->rq;
|
||||||
unsigned int timeout;
|
unsigned int timeout;
|
||||||
u32 tf_flags;
|
u32 tf_flags;
|
||||||
u16 bcount;
|
u16 bcount;
|
||||||
|
|
||||||
if (drive->media != ide_floppy) {
|
|
||||||
if (rq_data_dir(rq))
|
|
||||||
cmd->tf_flags |= IDE_TFLAG_WRITE;
|
|
||||||
cmd->rq = rq;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dev_is_idecd(drive)) {
|
if (dev_is_idecd(drive)) {
|
||||||
tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
|
tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
|
||||||
bcount = ide_cd_get_xferlen(rq);
|
bcount = ide_cd_get_xferlen(rq);
|
||||||
@@ -696,7 +681,9 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
|
|||||||
: WAIT_TAPE_CMD;
|
: WAIT_TAPE_CMD;
|
||||||
}
|
}
|
||||||
|
|
||||||
ide_pktcmd_tf_load(drive, tf_flags, bcount);
|
ide_init_packet_cmd(cmd, tf_flags, bcount, drive->dma);
|
||||||
|
|
||||||
|
(void)do_rw_taskfile(drive, cmd);
|
||||||
|
|
||||||
/* Issue the packet command */
|
/* Issue the packet command */
|
||||||
if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
|
if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
|
||||||
|
@@ -1066,6 +1066,8 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
|
|||||||
static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
|
static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
|
||||||
sector_t block)
|
sector_t block)
|
||||||
{
|
{
|
||||||
|
struct ide_cmd cmd;
|
||||||
|
|
||||||
ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, block: %llu",
|
ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, block: %llu",
|
||||||
rq->cmd[0], (unsigned long long)block);
|
rq->cmd[0], (unsigned long long)block);
|
||||||
|
|
||||||
@@ -1094,7 +1096,14 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
|
|||||||
return ide_stopped;
|
return ide_stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ide_issue_pc(drive);
|
memset(&cmd, 0, sizeof(cmd));
|
||||||
|
|
||||||
|
if (rq_data_dir(rq))
|
||||||
|
cmd.tf_flags |= IDE_TFLAG_WRITE;
|
||||||
|
|
||||||
|
cmd.rq = rq;
|
||||||
|
|
||||||
|
return ide_issue_pc(drive, &cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -130,8 +130,9 @@ static void ide_floppy_report_error(struct ide_disk_obj *floppy,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
|
static ide_startstop_t ide_floppy_issue_pc(ide_drive_t *drive,
|
||||||
struct ide_atapi_pc *pc)
|
struct ide_cmd *cmd,
|
||||||
|
struct ide_atapi_pc *pc)
|
||||||
{
|
{
|
||||||
struct ide_disk_obj *floppy = drive->driver_data;
|
struct ide_disk_obj *floppy = drive->driver_data;
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
|
|||||||
|
|
||||||
pc->retries++;
|
pc->retries++;
|
||||||
|
|
||||||
return ide_issue_pc(drive);
|
return ide_issue_pc(drive, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc)
|
void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc)
|
||||||
@@ -244,7 +245,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
|
|||||||
{
|
{
|
||||||
struct ide_disk_obj *floppy = drive->driver_data;
|
struct ide_disk_obj *floppy = drive->driver_data;
|
||||||
ide_hwif_t *hwif = drive->hwif;
|
ide_hwif_t *hwif = drive->hwif;
|
||||||
struct ide_cmd *cmd = &hwif->cmd;
|
struct ide_cmd cmd;
|
||||||
struct ide_atapi_pc *pc;
|
struct ide_atapi_pc *pc;
|
||||||
|
|
||||||
if (drive->debug_mask & IDE_DBG_RQ)
|
if (drive->debug_mask & IDE_DBG_RQ)
|
||||||
@@ -285,21 +286,24 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
|
|||||||
goto out_end;
|
goto out_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(&cmd, 0, sizeof(cmd));
|
||||||
|
|
||||||
if (rq_data_dir(rq))
|
if (rq_data_dir(rq))
|
||||||
cmd->tf_flags |= IDE_TFLAG_WRITE;
|
cmd.tf_flags |= IDE_TFLAG_WRITE;
|
||||||
cmd->rq = rq;
|
|
||||||
|
cmd.rq = rq;
|
||||||
|
|
||||||
if (blk_fs_request(rq) || pc->req_xfer) {
|
if (blk_fs_request(rq) || pc->req_xfer) {
|
||||||
ide_init_sg_cmd(cmd, rq->nr_sectors);
|
ide_init_sg_cmd(&cmd, rq->nr_sectors);
|
||||||
ide_map_sg(drive, cmd);
|
ide_map_sg(drive, &cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
pc->sg = hwif->sg_table;
|
pc->sg = hwif->sg_table;
|
||||||
pc->sg_cnt = cmd->sg_nents;
|
pc->sg_cnt = cmd.sg_nents;
|
||||||
|
|
||||||
pc->rq = rq;
|
pc->rq = rq;
|
||||||
|
|
||||||
return idefloppy_issue_pc(drive, pc);
|
return ide_floppy_issue_pc(drive, &cmd, pc);
|
||||||
out_end:
|
out_end:
|
||||||
drive->failed_pc = NULL;
|
drive->failed_pc = NULL;
|
||||||
if (blk_fs_request(rq) == 0 && rq->errors == 0)
|
if (blk_fs_request(rq) == 0 && rq->errors == 0)
|
||||||
|
@@ -580,7 +580,7 @@ static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
|
|||||||
*
|
*
|
||||||
* The handling will be done in three stages:
|
* The handling will be done in three stages:
|
||||||
*
|
*
|
||||||
* 1. idetape_issue_pc will send the packet command to the drive, and will set
|
* 1. ide_tape_issue_pc will send the packet command to the drive, and will set
|
||||||
* the interrupt handler to ide_pc_intr.
|
* the interrupt handler to ide_pc_intr.
|
||||||
*
|
*
|
||||||
* 2. On each interrupt, ide_pc_intr will be called. This step will be
|
* 2. On each interrupt, ide_pc_intr will be called. This step will be
|
||||||
@@ -608,8 +608,9 @@ static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
|
|||||||
* request.
|
* request.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
|
static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive,
|
||||||
struct ide_atapi_pc *pc)
|
struct ide_cmd *cmd,
|
||||||
|
struct ide_atapi_pc *pc)
|
||||||
{
|
{
|
||||||
idetape_tape_t *tape = drive->driver_data;
|
idetape_tape_t *tape = drive->driver_data;
|
||||||
|
|
||||||
@@ -654,7 +655,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
|
|||||||
|
|
||||||
pc->retries++;
|
pc->retries++;
|
||||||
|
|
||||||
return ide_issue_pc(drive);
|
return ide_issue_pc(drive, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A mode sense command is used to "sense" tape parameters. */
|
/* A mode sense command is used to "sense" tape parameters. */
|
||||||
@@ -749,6 +750,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
|
|||||||
idetape_tape_t *tape = drive->driver_data;
|
idetape_tape_t *tape = drive->driver_data;
|
||||||
struct ide_atapi_pc *pc = NULL;
|
struct ide_atapi_pc *pc = NULL;
|
||||||
struct request *postponed_rq = tape->postponed_rq;
|
struct request *postponed_rq = tape->postponed_rq;
|
||||||
|
struct ide_cmd cmd;
|
||||||
u8 stat;
|
u8 stat;
|
||||||
|
|
||||||
debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %lu,"
|
debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %lu,"
|
||||||
@@ -844,7 +846,14 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
|
|||||||
BUG();
|
BUG();
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return idetape_issue_pc(drive, pc);
|
memset(&cmd, 0, sizeof(cmd));
|
||||||
|
|
||||||
|
if (rq_data_dir(rq))
|
||||||
|
cmd.tf_flags |= IDE_TFLAG_WRITE;
|
||||||
|
|
||||||
|
cmd.rq = rq;
|
||||||
|
|
||||||
|
return ide_tape_issue_pc(drive, &cmd, pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -100,13 +100,14 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
|
|||||||
ide_execute_command(drive, tf->command, handler,
|
ide_execute_command(drive, tf->command, handler,
|
||||||
WAIT_WORSTCASE, NULL);
|
WAIT_WORSTCASE, NULL);
|
||||||
return ide_started;
|
return ide_started;
|
||||||
default:
|
case ATA_PROT_DMA:
|
||||||
if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 ||
|
if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 ||
|
||||||
ide_build_sglist(drive, cmd) == 0 ||
|
ide_build_sglist(drive, cmd) == 0 ||
|
||||||
dma_ops->dma_setup(drive, cmd))
|
dma_ops->dma_setup(drive, cmd))
|
||||||
return ide_stopped;
|
return ide_stopped;
|
||||||
dma_ops->dma_exec_cmd(drive, tf->command);
|
dma_ops->dma_exec_cmd(drive, tf->command);
|
||||||
dma_ops->dma_start(drive);
|
dma_ops->dma_start(drive);
|
||||||
|
default:
|
||||||
return ide_started;
|
return ide_started;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1226,7 +1226,7 @@ int ide_cd_expiry(ide_drive_t *);
|
|||||||
|
|
||||||
int ide_cd_get_xferlen(struct request *);
|
int ide_cd_get_xferlen(struct request *);
|
||||||
|
|
||||||
ide_startstop_t ide_issue_pc(ide_drive_t *);
|
ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_cmd *);
|
||||||
|
|
||||||
ide_startstop_t do_rw_taskfile(ide_drive_t *, struct ide_cmd *);
|
ide_startstop_t do_rw_taskfile(ide_drive_t *, struct ide_cmd *);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user