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

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

ide: call ide_build_sglist() prior to ->dma_setup (v2)



* Re-map sg table if needed in ide_build_sglist().

* Move ide_build_sglist() call from ->dma_setup to its users.

* Un-export ide_build_sglist().

v2:
* Build fix for CONFIG_BLK_DEV_IDEDMA=n (noticed by Randy Dunlap).

There should be no functional changes caused by this patch.

Cc: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent b109f526
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -211,21 +211,16 @@ 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)
{
	int i, iswrite, count = 0;
	ide_hwif_t *hwif = drive->hwif;
	struct request *rq = hwif->rq;
	_auide_hwif *ahwif = &auide_hwif;
	struct scatterlist *sg;
	int i = hwif->sg_nents, iswrite, count = 0;

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

	hwif->sg_nents = i = ide_build_sglist(drive, rq);

	if (!i)
		return 0;

	/* fill the descriptors */
	sg = hwif->sg_table;
	while (i && sg_dma_len(sg)) {
+0 −6
Original line number Diff line number Diff line
@@ -325,12 +325,6 @@ static int icside_dma_setup(ide_drive_t *drive)
	 */
	BUG_ON(dma_channel_active(ec->dma));

	hwif->sg_nents = ide_build_sglist(drive, rq);
	if (hwif->sg_nents == 0) {
		ide_map_sg(drive, rq);
		return 1;
	}

	/*
	 * Ensure that we have the right interrupt routed.
	 */
+14 −5
Original line number Diff line number Diff line
@@ -631,18 +631,23 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
	struct ide_atapi_pc *pc;
	ide_hwif_t *hwif = drive->hwif;
	ide_expiry_t *expiry = NULL;
	struct request *rq = hwif->rq;
	unsigned int timeout;
	u32 tf_flags;
	u16 bcount;

	if (dev_is_idecd(drive)) {
		tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
		bcount = ide_cd_get_xferlen(hwif->rq);
		bcount = ide_cd_get_xferlen(rq);
		expiry = ide_cd_expiry;
		timeout = ATAPI_WAIT_PC;

		if (drive->dma)
		if (drive->dma) {
			if (ide_build_sglist(drive, rq))
				drive->dma = !hwif->dma_ops->dma_setup(drive);
			else
				drive->dma = 0;
		}
	} else {
		pc = drive->pc;

@@ -661,8 +666,12 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive)
		}

		if ((pc->flags & PC_FLAG_DMA_OK) &&
		     (drive->dev_flags & IDE_DFLAG_USING_DMA))
		     (drive->dev_flags & IDE_DFLAG_USING_DMA)) {
			if (ide_build_sglist(drive, rq))
				drive->dma = !hwif->dma_ops->dma_setup(drive);
			else
				drive->dma = 0;
		}

		if (!drive->dma)
			pc->flags &= ~PC_FLAG_DMA_OK;
+0 −4
Original line number Diff line number Diff line
@@ -120,10 +120,6 @@ int ide_build_dmatable(ide_drive_t *drive, struct request *rq)
	struct scatterlist *sg;
	u8 is_trm290 = !!(hwif->host_flags & IDE_HFLAG_TRM290);

	hwif->sg_nents = ide_build_sglist(drive, rq);
	if (hwif->sg_nents == 0)
		return 0;

	for_each_sg(hwif->sg_table, sg, hwif->sg_nents, i) {
		u32 cur_addr, cur_len, xcount, bcount;

+3 −2
Original line number Diff line number Diff line
@@ -138,14 +138,15 @@ int ide_build_sglist(ide_drive_t *drive, struct request *rq)
		hwif->sg_dma_direction = DMA_TO_DEVICE;

	i = dma_map_sg(hwif->dev, sg, hwif->sg_nents, hwif->sg_dma_direction);
	if (i) {
	if (i == 0)
		ide_map_sg(drive, rq);
	else {
		hwif->orig_sg_nents = hwif->sg_nents;
		hwif->sg_nents = i;
	}

	return i;
}
EXPORT_SYMBOL_GPL(ide_build_sglist);

/**
 *	ide_destroy_dmatable	-	clean up DMA mapping
Loading