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

Commit 0ae2e178 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: remove ->ide_dma_check (take 2)



* Add IDE_HFLAG_TRUST_BIOS_FOR_DMA host flag for host drivers that depend
  on BIOS for programming device/controller for DMA.  Set it in cy82c693,
  generic, ns87415, opti621 and trm290 host drivers.

* Add IDE_HFLAG_VDMA host flag for host drivers using VDMA.  Set it in cs5520
  host driver.

* Teach ide_tune_dma() about IDE_HFLAG_TRUST_BIOS_FOR_DMA flag.

* Add generic ide_dma_check() helper and remove all open coded ->ide_dma_check
  implementations.  Fix all places checking for presence of ->ide_dma_check
  hook to check for ->ide_dma_on instead.

* Remove no longer needed code from config_drive_for_dma().

* Make ide_tune_dma() static.

v2:
* Fix config_drive_for_dma() return values.

* Fix ide-dma.c build for CONFIG_BLK_DEV_IDEDMA_PCI=n by adding
  dummy config_drive_for_dma() inline.

* Fix IDE_HFLAG_TRUST_BIOS_FOR_DMA handling in ide_dma_check().

* Fix init_hwif_it8213() comment.

There should be no functionality changes caused by this patch.

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent b8b739d3
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -309,14 +309,6 @@ static int icside_dma_on(ide_drive_t *drive)
	return 0;
}

static int icside_dma_check(ide_drive_t *drive)
{
	if (ide_tune_dma(drive))
		return 0;

	return -1;
}

static int icside_dma_end(ide_drive_t *drive)
{
	ide_hwif_t *hwif = HWIF(drive);
@@ -434,7 +426,6 @@ static void icside_dma_init(ide_hwif_t *hwif)
	hwif->set_dma_mode	= icside_set_dma_mode;
	hwif->autodma		= 1;

	hwif->ide_dma_check	= icside_dma_check;
	hwif->dma_host_off	= icside_dma_host_off;
	hwif->dma_off_quietly	= icside_dma_off_quietly;
	hwif->dma_host_on	= icside_dma_host_on;
+0 −12
Original line number Diff line number Diff line
@@ -664,7 +664,6 @@ cris_ide_inb(unsigned long reg)
	return (unsigned char)cris_ide_inw(reg);
}

static int cris_dma_check (ide_drive_t *drive);
static int cris_dma_end (ide_drive_t *drive);
static int cris_dma_setup (ide_drive_t *drive);
static void cris_dma_exec_cmd (ide_drive_t *drive, u8 command);
@@ -792,7 +791,6 @@ init_e100_ide (void)
		hwif->ata_output_data = &cris_ide_output_data;
		hwif->atapi_input_bytes = &cris_atapi_input_bytes;
		hwif->atapi_output_bytes = &cris_atapi_output_bytes;
		hwif->ide_dma_check = &cris_dma_check;
		hwif->ide_dma_end = &cris_dma_end;
		hwif->dma_setup = &cris_dma_setup;
		hwif->dma_exec_cmd = &cris_dma_exec_cmd;
@@ -1020,16 +1018,6 @@ static ide_startstop_t cris_dma_intr (ide_drive_t *drive)
 * the caller should revert to PIO for the current request.
 */

static int cris_dma_check(ide_drive_t *drive)
{
	if (ide_tune_dma(drive))
		return 0;

	ide_set_max_pio(drive);

	return -1;
}

static int cris_dma_end(ide_drive_t *drive)
{
	drive->waiting_for_dma = 0;
+45 −30
Original line number Diff line number Diff line
@@ -338,20 +338,16 @@ static int config_drive_for_dma (ide_drive_t *drive)
	ide_hwif_t *hwif = drive->hwif;
	struct hd_driveid *id = drive->id;

	/* consult the list of known "bad" drives */
	if (__ide_dma_bad_drive(drive))
		return -1;

	if (drive->media != ide_disk && hwif->atapi_dma == 0)
		return -1;
		return 0;

	if ((id->capability & 1) && drive->autodma) {
	/*
	 * Enable DMA on any drive that has
	 * UltraDMA (mode 0/1/2/3/4/5/6) enabled
	 */
	if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f))
			return 0;
		return 1;

	/*
	 * Enable DMA on any drive that has mode2 DMA
	 * (multi or single) enabled
@@ -359,14 +355,13 @@ static int config_drive_for_dma (ide_drive_t *drive)
	if (id->field_valid & 2)	/* regular DMA */
		if ((id->dma_mword & 0x404) == 0x404 ||
		    (id->dma_1word & 0x404) == 0x404)
				return 0;
			return 1;

	/* Consult the list of known "good" drives */
	if (ide_dma_good_drive(drive))
			return 0;
	}
		return 1;

	return -1;
	return 0;
}

/**
@@ -627,6 +622,8 @@ static int __ide_dma_test_irq(ide_drive_t *drive)
			drive->name, __FUNCTION__);
	return 0;
}
#else
static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; }
#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */

int __ide_dma_bad_drive (ide_drive_t *drive)
@@ -758,7 +755,7 @@ u8 ide_find_dma_mode(ide_drive_t *drive, u8 req_mode)

EXPORT_SYMBOL_GPL(ide_find_dma_mode);

int ide_tune_dma(ide_drive_t *drive)
static int ide_tune_dma(ide_drive_t *drive)
{
	u8 speed;

@@ -769,6 +766,9 @@ int ide_tune_dma(ide_drive_t *drive)
	if (__ide_dma_bad_drive(drive))
		return 0;

	if (drive->hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA)
		return config_drive_for_dma(drive);

	speed = ide_max_dma_mode(drive);

	if (!speed)
@@ -785,6 +785,23 @@ int ide_tune_dma(ide_drive_t *drive)

EXPORT_SYMBOL_GPL(ide_tune_dma);

static int ide_dma_check(ide_drive_t *drive)
{
	ide_hwif_t *hwif = drive->hwif;
	int vdma = (hwif->host_flags & IDE_HFLAG_VDMA)? 1 : 0;

	if (!vdma && ide_tune_dma(drive))
		return 0;

	/* TODO: always do PIO fallback */
	if (hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA)
		return -1;

	ide_set_max_pio(drive);

	return vdma ? 0 : -1;
}

void ide_dma_verbose(ide_drive_t *drive)
{
	struct hd_driveid *id	= drive->id;
@@ -842,7 +859,7 @@ int ide_set_dma(ide_drive_t *drive)
	ide_hwif_t *hwif = drive->hwif;
	int rc;

	rc = hwif->ide_dma_check(drive);
	rc = ide_dma_check(drive);

	switch(rc) {
	case -1: /* DMA needs to be disabled */
@@ -1019,8 +1036,6 @@ void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_p
		hwif->ide_dma_on = &__ide_dma_on;
	if (!hwif->dma_host_on)
		hwif->dma_host_on = &ide_dma_host_on;
	if (!hwif->ide_dma_check)
		hwif->ide_dma_check = &config_drive_for_dma;
	if (!hwif->dma_setup)
		hwif->dma_setup = &ide_dma_setup;
	if (!hwif->dma_exec_cmd)
+2 −2
Original line number Diff line number Diff line
@@ -219,11 +219,11 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *

	case ide_pm_restore_dma:	/* Resume step 3 (restore DMA) */
		/*
		 * Right now, all we do is call hwif->ide_dma_check(drive),
		 * Right now, all we do is call ide_set_dma(drive),
		 * we could be smarter and check for current xfer_speed
		 * in struct drive etc...
		 */
		if (drive->hwif->ide_dma_check == NULL)
		if (drive->hwif->ide_dma_on == NULL)
			break;
		drive->hwif->dma_off_quietly(drive);
		/*
+2 −2
Original line number Diff line number Diff line
@@ -776,7 +776,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
//		msleep(50);

#ifdef CONFIG_BLK_DEV_IDEDMA
	if (hwif->ide_dma_check)	 /* check if host supports DMA */
	if (hwif->ide_dma_on)	/* check if host supports DMA */
		hwif->dma_host_off(drive);
#endif

@@ -830,7 +830,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
#ifdef CONFIG_BLK_DEV_IDEDMA
	if (speed >= XFER_SW_DMA_0)
		hwif->dma_host_on(drive);
	else if (hwif->ide_dma_check)	/* check if host supports DMA */
	else if (hwif->ide_dma_on)	/* check if host supports DMA */
		hwif->dma_off_quietly(drive);
#endif

Loading