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

Commit 29e744d0 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: add ide_tune_dma() helper



After reworking the code responsible for selecting the best DMA
transfer mode it is now possible to add generic ide_tune_dma() helper.

Convert some IDE PCI host drivers to use it (the ones left need more work).

Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 2d5eaa6d
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -779,6 +779,26 @@ u8 ide_max_dma_mode(ide_drive_t *drive)

EXPORT_SYMBOL_GPL(ide_max_dma_mode);

int ide_tune_dma(ide_drive_t *drive)
{
	u8 speed;

	/* TODO: use only ide_max_dma_mode() */
	if (!ide_use_dma(drive))
		return 0;

	speed = ide_max_dma_mode(drive);

	if (!speed)
		return 0;

	drive->hwif->speedproc(drive, speed);

	return ide_dma_enable(drive);
}

EXPORT_SYMBOL_GPL(ide_tune_dma);

void ide_dma_verbose(ide_drive_t *drive)
{
	struct hd_driveid *id	= drive->id;
+1 −12
Original line number Diff line number Diff line
@@ -155,17 +155,6 @@ static int aec62xx_tune_chipset (ide_drive_t *drive, u8 speed)
	}
}

static int config_chipset_for_dma (ide_drive_t *drive)
{
	u8 speed = ide_max_dma_mode(drive);

	if (!(speed))
		return 0;

	(void) aec62xx_tune_chipset(drive, speed);
	return ide_dma_enable(drive);
}

static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio)
{
	pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
@@ -174,7 +163,7 @@ static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio)

static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive)
{
	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
	if (ide_tune_dma(drive))
		return 0;

	if (ide_use_fast_pio(drive))
+1 −21
Original line number Diff line number Diff line
@@ -206,26 +206,6 @@ static int atiixp_speedproc(ide_drive_t *drive, u8 xferspeed)
	return ide_config_drive_speed(drive, speed);
}

/**
 *	atiixp_config_drive_for_dma	-	configure drive for DMA
 *	@drive: IDE drive to configure
 *
 *	Set up a ATIIXP interface channel for the best available speed.
 *	We prefer UDMA if it is available and then MWDMA. If DMA is
 *	not available we switch to PIO and return 0.
 */

static int atiixp_config_drive_for_dma(ide_drive_t *drive)
{
	u8 speed = ide_max_dma_mode(drive);

	if (!speed)
		return 0;

	(void) atiixp_speedproc(drive, speed);
	return ide_dma_enable(drive);
}

/**
 *	atiixp_dma_check	-	set up an IDE device
 *	@drive: IDE drive to configure
@@ -240,7 +220,7 @@ static int atiixp_dma_check(ide_drive_t *drive)

	drive->init_speed = 0;

	if (ide_use_dma(drive) && atiixp_config_drive_for_dma(drive))
	if (ide_tune_dma(drive))
		return 0;

	if (ide_use_fast_pio(drive)) {
+1 −14
Original line number Diff line number Diff line
@@ -164,26 +164,13 @@ static void cs5535_tuneproc(ide_drive_t *drive, u8 xferspeed)
	cs5535_set_speed(drive, xferspeed);
}

static int cs5535_config_drive_for_dma(ide_drive_t *drive)
{
	u8 speed = ide_max_dma_mode(drive);

	/* If no DMA speed was available then let dma_check hit pio */
	if (!speed) {
		return 0;
	}

	cs5535_set_drive(drive, speed);
	return ide_dma_enable(drive);
}

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

	drive->init_speed = 0;

	if (ide_use_dma(drive) && cs5535_config_drive_for_dma(drive))
	if (ide_tune_dma(drive))
		return 0;

	if (ide_use_fast_pio(drive)) {
+1 −19
Original line number Diff line number Diff line
@@ -84,29 +84,11 @@ static void hpt34x_tune_drive (ide_drive_t *drive, u8 pio)
	(void) hpt34x_tune_chipset(drive, (XFER_PIO_0 + pio));
}

/*
 * This allows the configuration of ide_pci chipset registers
 * for cards that learn about the drive's UDMA, DMA, PIO capabilities
 * after the drive is reported by the OS.  Initially for designed for
 * HPT343 UDMA chipset by HighPoint|Triones Technologies, Inc.
 */

static int config_chipset_for_dma (ide_drive_t *drive)
{
	u8 speed = ide_max_dma_mode(drive);

	if (!(speed))
		return 0;

	(void) hpt34x_tune_chipset(drive, speed);
	return ide_dma_enable(drive);
}

static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive)
{
	drive->init_speed = 0;

	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
	if (ide_tune_dma(drive))
#ifndef CONFIG_HPT34X_AUTODMA
		return -1;
#else
Loading