Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22981694 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

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: default avatarBorislav Petkov <petkovbb@gmail.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 130e8867
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -191,17 +191,18 @@ static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed)
/**
 *	ali15x3_dma_setup	-	begin a DMA phase
 *	@drive:	target device
 *	@cmd: command
 *
 *	Returns 1 if the DMA cannot be performed, zero on success.
 */

static int ali15x3_dma_setup(ide_drive_t *drive)
static int ali15x3_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
{
	if (m5229_revision < 0xC2 && drive->media != ide_disk) {
		if (rq_data_dir(drive->hwif->rq))
		if (cmd->tf_flags & IDE_TFLAG_WRITE)
			return 1;	/* try PIO instead of DMA */
	}
	return ide_dma_setup(drive);
	return ide_dma_setup(drive, cmd);
}

/**
+6 −9
Original line number Diff line number Diff line
@@ -209,15 +209,14 @@ static void auide_set_dma_mode(ide_drive_t *drive, const u8 speed)
 */

#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
static int auide_build_dmatable(ide_drive_t *drive)
static int auide_build_dmatable(ide_drive_t *drive, struct ide_cmd *cmd)
{
	ide_hwif_t *hwif = drive->hwif;
	struct request *rq = hwif->rq;
	_auide_hwif *ahwif = &auide_hwif;
	struct scatterlist *sg;
	int i = hwif->cmd.sg_nents, iswrite, count = 0;
	int i = cmd->sg_nents, count = 0;
	int iswrite = !!(cmd->tf_flags & IDE_TFLAG_WRITE);

	iswrite = (rq_data_dir(rq) == WRITE);
	/* Save for interrupt context */
	ahwif->drive = drive;

@@ -298,12 +297,10 @@ static void auide_dma_exec_cmd(ide_drive_t *drive, u8 command)
			    (2*WAIT_CMD), NULL);
}

static int auide_dma_setup(ide_drive_t *drive)
static int auide_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
{
	struct request *rq = drive->hwif->rq;

	if (!auide_build_dmatable(drive)) {
		ide_map_sg(drive, rq);
	if (auide_build_dmatable(drive, cmd) == 0) {
		ide_map_sg(drive, cmd);
		return 1;
	}

+3 −4
Original line number Diff line number Diff line
@@ -307,15 +307,14 @@ static void icside_dma_start(ide_drive_t *drive)
	enable_dma(ec->dma);
}

static int icside_dma_setup(ide_drive_t *drive)
static int icside_dma_setup(ide_drive_t *drive, struct ide_cmd *cmd)
{
	ide_hwif_t *hwif = drive->hwif;
	struct expansion_card *ec = ECARD_DEV(hwif->dev);
	struct icside_state *state = ecard_get_drvdata(ec);
	struct request *rq = hwif->rq;
	unsigned int dma_mode;

	if (rq_data_dir(rq))
	if (cmd->tf_flags & IDE_TFLAG_WRITE)
		dma_mode = DMA_MODE_WRITE;
	else
		dma_mode = DMA_MODE_READ;
@@ -344,7 +343,7 @@ static int icside_dma_setup(ide_drive_t *drive)
	 * Tell the DMA engine about the SG table and
	 * data direction.
	 */
	set_dma_sg(ec->dma, hwif->sg_table, hwif->cmd.sg_nents);
	set_dma_sg(ec->dma, hwif->sg_table, cmd->sg_nents);
	set_dma_mode(ec->dma, dma_mode);

	drive->waiting_for_dma = 1;
+12 −4
Original line number Diff line number Diff line
@@ -638,12 +638,20 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
{
	struct ide_atapi_pc *pc;
	ide_hwif_t *hwif = drive->hwif;
	const struct ide_dma_ops *dma_ops = hwif->dma_ops;
	struct ide_cmd *cmd = &hwif->cmd;
	ide_expiry_t *expiry = NULL;
	struct request *rq = hwif->rq;
	unsigned int timeout;
	u32 tf_flags;
	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)) {
		tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
		bcount = ide_cd_get_xferlen(rq);
@@ -651,8 +659,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
		timeout = ATAPI_WAIT_PC;

		if (drive->dma) {
			if (ide_build_sglist(drive, rq))
				drive->dma = !hwif->dma_ops->dma_setup(drive);
			if (ide_build_sglist(drive, cmd))
				drive->dma = !dma_ops->dma_setup(drive, cmd);
			else
				drive->dma = 0;
		}
@@ -675,8 +683,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)

		if ((pc->flags & PC_FLAG_DMA_OK) &&
		     (drive->dev_flags & IDE_DFLAG_USING_DMA)) {
			if (ide_build_sglist(drive, rq))
				drive->dma = !hwif->dma_ops->dma_setup(drive);
			if (ide_build_sglist(drive, cmd))
				drive->dma = !dma_ops->dma_setup(drive, cmd);
			else
				drive->dma = 0;
		}
+5 −5
Original line number Diff line number Diff line
@@ -99,11 +99,6 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
	memset(&cmd, 0, sizeof(cmd));
	cmd.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;

	if (dma == 0) {
		ide_init_sg_cmd(&cmd, nsectors);
		ide_map_sg(drive, rq);
	}

	if (drive->dev_flags & IDE_DFLAG_LBA) {
		if (lba48) {
			pr_debug("%s: LBA=0x%012llx\n", drive->name,
@@ -156,6 +151,11 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
	ide_tf_set_cmd(drive, &cmd, dma);
	cmd.rq = rq;

	if (dma == 0) {
		ide_init_sg_cmd(&cmd, nsectors);
		ide_map_sg(drive, &cmd);
	}

	rc = do_rw_taskfile(drive, &cmd);

	if (rc == ide_stopped && dma) {
Loading