LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 10/15] ide: add ide_set_dma() helper
Date: Sat, 20 Jan 2007 23:22:06 +0300	[thread overview]
Message-ID: <45B279EE.5080807@ru.mvista.com> (raw)
In-Reply-To: <20070119003206.14846.59852.sendpatchset@localhost.localdomain>

Hello again. :-)

Bartlomiej Zolnierkiewicz wrote:
> [PATCH] ide: add ide_set_dma() helper

> * add ide_set_dma() helper and make ide_hwif_t.ide_dma_check return
>   -1 when DMA needs to be disabled (== need to call ->ide_dma_off_quietly)
>    0 when DMA needs to be enabled  (== need to call ->ide_dma_on)
>    1 when DMA setting shouldn't be changed
> * fix IDE code to use ide_set_dma() instead if using ->ide_dma_check directly

    Here are a few comments related to the code being patched:

> Index: b/drivers/ide/pci/alim15x3.c
> ===================================================================
> --- a/drivers/ide/pci/alim15x3.c
> +++ b/drivers/ide/pci/alim15x3.c
> @@ -507,17 +507,15 @@ static int config_chipset_for_dma (ide_d
>   *
>   *	Configure a drive for DMA operation. If DMA is not possible we
>   *	drop the drive into PIO mode instead.
> - *
> - *	FIXME: exactly what are we trying to return here
>   */
> - 
> +
>  static int ali15x3_config_drive_for_dma(ide_drive_t *drive)
>  {
>  	ide_hwif_t *hwif	= HWIF(drive);
>  	struct hd_driveid *id	= drive->id;
>  
>  	if ((m5229_revision<=0x20) && (drive->media!=ide_disk))
> -		return hwif->ide_dma_off_quietly(drive);
> +		goto no_dma_set;

    Isn't it better to just return -1?

> @@ -552,9 +550,10 @@ try_dma_modes:
>  ata_pio:
>  		hwif->tuneproc(drive, 255);
>  no_dma_set:
> -		return hwif->ide_dma_off_quietly(drive);
> +		return -1;
>  	}
> -	return hwif->ide_dma_on(drive);
> +
> +	return 0;
>  }

    Ugh, this code looks like it's asking to be converted into calling 
ide_use_dma(). instead all of that...

> Index: b/drivers/ide/pci/cs5520.c
> ===================================================================
> --- a/drivers/ide/pci/cs5520.c
> +++ b/drivers/ide/pci/cs5520.c
> @@ -132,12 +132,11 @@ static void cs5520_tune_drive(ide_drive_
>  
>  static int cs5520_config_drive_xfer_rate(ide_drive_t *drive)
>  {
> -	ide_hwif_t *hwif = HWIF(drive);
> -
>  	/* Tune the drive for PIO modes up to PIO 4 */	
>  	cs5520_tune_drive(drive, 4);

    Ugh. Why not ask drive? :-/

>  	/* Then tell the core to use DMA operations */
> -	return hwif->ide_dma_on(drive);
> +	return 0;

    That must be the famous VDMA thing... :-)
    I wonder if it *actually* works on HPT36x/37x which seem to have support 
for it...

> Index: b/drivers/ide/pci/jmicron.c
> ===================================================================
> --- a/drivers/ide/pci/jmicron.c
> +++ b/drivers/ide/pci/jmicron.c
> @@ -164,14 +164,12 @@ static int config_chipset_for_dma (ide_d
>  
>  static int jmicron_config_drive_for_dma (ide_drive_t *drive)
>  {
> -	ide_hwif_t *hwif	= drive->hwif;
> +	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
> +		return 0;
>  
> -	if (ide_use_dma(drive)) {
> -		if (config_chipset_for_dma(drive))
> -			return hwif->ide_dma_on(drive);
> -	}
>  	config_jmicron_chipset_for_pio(drive, 1);

    The 2nd argument of that funtion is useless -- it basically does nothing 
if 0 is passed. Another case of mindless copy-paste. :-)

> Index: b/drivers/ide/pci/pdc202xx_old.c
> ===================================================================
> --- a/drivers/ide/pci/pdc202xx_old.c
> +++ b/drivers/ide/pci/pdc202xx_old.c
> @@ -332,17 +332,15 @@ chipset_is_set:
>  
>  static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive)
>  {
> -	ide_hwif_t *hwif	= HWIF(drive);
> -
>  	drive->init_speed = 0;
>  
>  	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
> -		return hwif->ide_dma_on(drive);
> +		return 0;
>  
>  	if (ide_use_fast_pio(drive))
> -		hwif->tuneproc(drive, 5);
> +		config_chipset_for_pio(drive, 5);

    That part is obsoleted by my recent fix...

> Index: b/drivers/ide/pci/piix.c
> ===================================================================
> --- a/drivers/ide/pci/piix.c
> +++ b/drivers/ide/pci/piix.c
> @@ -386,20 +386,18 @@ static int piix_config_drive_for_dma (id
>   
>  static int piix_config_drive_xfer_rate (ide_drive_t *drive)
>  {
> -	ide_hwif_t *hwif	= HWIF(drive);
> -
>  	drive->init_speed = 0;
>  
>  	if (ide_use_dma(drive) && piix_config_drive_for_dma(drive))
> -		return hwif->ide_dma_on(drive);
> +		return 0;
>  
>  	if (ide_use_fast_pio(drive)) {
>  		/* Find best PIO mode. */
> -		(void) hwif->speedproc(drive, XFER_PIO_0 +
> -				       ide_get_best_pio_mode(drive, 255, 4, NULL));
> +		u8 pio = ide_get_best_pio_mode(drive, 255, 4, NULL);
> +		(void)piix_tune_chipset(drive, XFER_PIO_0 + pio);
>  	}

    Will try to fix the tuneproc() nuisance RSN. :-)

> Index: b/drivers/ide/pci/serverworks.c
> ===================================================================
> --- a/drivers/ide/pci/serverworks.c
> +++ b/drivers/ide/pci/serverworks.c
> @@ -315,17 +315,15 @@ static int config_chipset_for_dma (ide_d
>  
>  static int svwks_config_drive_xfer_rate (ide_drive_t *drive)
>  {
> -	ide_hwif_t *hwif	= HWIF(drive);
> -
>  	drive->init_speed = 0;
>  
>  	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
> -		return hwif->ide_dma_on(drive);
> +		return 0;
>  
>  	if (ide_use_fast_pio(drive))
>  		config_chipset_for_pio(drive);

    I have no idea why that function is so huge in this driver, i.e. why all 
this code is not in svwks_tune_chipset()...

> -	return hwif->ide_dma_off_quietly(drive);
> +	return -1;
>  }
>  
>  static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const char *name)
> Index: b/drivers/ide/pci/sl82c105.c
> ===================================================================
> --- a/drivers/ide/pci/sl82c105.c
> +++ b/drivers/ide/pci/sl82c105.c
> @@ -161,14 +161,14 @@ static int sl82c105_check_drive (ide_dri
>  		if (id->field_valid & 2) {
>  			if ((id->dma_mword & hwif->mwdma_mask) ||
>  			    (id->dma_1word & hwif->swdma_mask))

    Ugh. This driver claims the full MW/SW DMA support while actually only 
supports MWDMA2.

> -				return hwif->ide_dma_on(drive);
> +				return 0;
>  		}
>  
>  		if (__ide_dma_good_drive(drive))
> -			return hwif->ide_dma_on(drive);
> +			return 0;
>  	} while (0);

    This also asks to be converted into ide_use_dma() call. The patch is 
cooking...

> -	return hwif->ide_dma_off_quietly(drive);
> +	return -1;
>  }
>  
>  /*
> Index: b/drivers/ide/pci/slc90e66.c
> ===================================================================
> --- a/drivers/ide/pci/slc90e66.c
> +++ b/drivers/ide/pci/slc90e66.c
> @@ -179,19 +179,17 @@ static int slc90e66_config_drive_for_dma
>  
>  static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive)
>  {
> -	ide_hwif_t *hwif	= HWIF(drive);
> -
>  	drive->init_speed = 0;
>  
>  	if (ide_use_dma(drive) && slc90e66_config_drive_for_dma(drive))
> -		return hwif->ide_dma_on(drive);
> +		return 0;
>  
>  	if (ide_use_fast_pio(drive)) {
> -		(void) hwif->speedproc(drive, XFER_PIO_0 +
> -				       ide_get_best_pio_mode(drive, 255, 4, NULL));
> +		u8 pio = ide_get_best_pio_mode(drive, 255, 4, NULL);
> +		(void)slc90e66_tune_chipset(drive, XFER_PIO_0 + pio);
>  	}

    The same promise about tuneproc() in this driver... :-)

MBR, Sergei

  reply	other threads:[~2007-01-20 20:22 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-19  0:30 [PATCH 0/15] IDE quilt tree updated Bartlomiej Zolnierkiewicz
2007-01-19  0:31 ` [PATCH 1/15] ACPI support for IDE devices Bartlomiej Zolnierkiewicz
2007-01-19  0:31 ` [PATCH 2/15] via82cxxx/pata_via: correct PCI_DEVICE_ID_VIA_SATA_EIDE ID and add support for CX700 and 8237S Bartlomiej Zolnierkiewicz
2007-01-19  0:31 ` [PATCH 3/15] it8213: fix build and ->ultra_mask Bartlomiej Zolnierkiewicz
2007-01-19  0:31 ` [PATCH 4/15] ide: convert ide_hwif_t.mmio into flag Bartlomiej Zolnierkiewicz
2007-01-19  0:31 ` [PATCH 5/15] hpt34x: hpt34x_tune_chipset() (->speedproc) fix Bartlomiej Zolnierkiewicz
2007-01-19  0:31 ` [PATCH 6/15] atiixp/jmicron/triflex: fix PIO fallback Bartlomiej Zolnierkiewicz
2007-01-19  0:31 ` [PATCH 7/15] piix: cleanup Bartlomiej Zolnierkiewicz
2007-01-19  0:31 ` [PATCH 8/15] ide: disable DMA in ->ide_dma_check for "no IORDY" case Bartlomiej Zolnierkiewicz
2007-01-19 16:26   ` Sergei Shtylyov
     [not found]     ` <58cb370e0701191047h524434eobdb9d86ed614bc71@mail.gmail.com>
2007-01-19 19:11       ` Bartlomiej Zolnierkiewicz
2007-01-19 19:35         ` Sergei Shtylyov
     [not found]           ` <58cb370e0701191200i10119313i4aacae9c504a02e4@mail.gmail.com>
2007-01-19 21:43             ` Bartlomiej Zolnierkiewicz
2007-01-20 17:09               ` Sergei Shtylyov
     [not found]                 ` <58cb370e0701200947p578f4d74g1fee511ded6c9a77@mail.gmail.com>
2007-01-20 18:21                   ` Bartlomiej Zolnierkiewicz
2007-01-20 18:41                     ` Sergei Shtylyov
2007-01-25 17:03                     ` Sergei Shtylyov
2007-01-19  0:32 ` [PATCH 9/15] sgiioc4: fix sgiioc4_ide_dma_check() to enable/disable DMA properly Bartlomiej Zolnierkiewicz
2007-01-19  0:32 ` [PATCH 10/15] ide: add ide_set_dma() helper Bartlomiej Zolnierkiewicz
2007-01-20 20:22   ` Sergei Shtylyov [this message]
2007-01-19  0:32 ` [PATCH 11/15] ide: make ide_hwif_t.ide_dma_{host_off,off_quietly} void Bartlomiej Zolnierkiewicz
2007-01-20 20:56   ` Sergei Shtylyov
     [not found]     ` <58cb370e0702021206h205ff983r88fb4bdbea42ed9f@mail.gmail.com>
2007-02-02 22:39       ` Bartlomiej Zolnierkiewicz
2007-01-19  0:32 ` [PATCH 12/15] ide: make ide_hwif_t.ide_dma_host_on void Bartlomiej Zolnierkiewicz
2007-01-20 20:46   ` Sergei Shtylyov
     [not found]     ` <58cb370e0702021128g15cac87ar507c20e78ded9464@mail.gmail.com>
2007-02-02 21:16       ` Bartlomiej Zolnierkiewicz
2007-03-26 17:19   ` Sergei Shtylyov
2007-04-20 20:36     ` Sergei Shtylyov
2007-01-19  0:32 ` [PATCH 13/15] ide: fix UDMA/MWDMA/SWDMA masks Bartlomiej Zolnierkiewicz
2007-01-22 16:19   ` Sergei Shtylyov
     [not found]     ` <58cb370e0702021606v4efa6143lf060e6aab9782c35@mail.gmail.com>
2007-02-03  0:39       ` Bartlomiej Zolnierkiewicz
2007-02-03 16:30         ` Sergei Shtylyov
2007-01-22 18:17   ` Sergei Shtylyov
2007-01-22 18:46     ` Alan
2007-01-22 20:28       ` Sergei Shtylyov
2007-01-22 21:31         ` Alan
2007-01-22 22:39           ` Jeff Garzik
2007-01-23 14:51           ` Sergei Shtylyov
2007-01-25 15:40             ` Sergei Shtylyov
2007-01-31 20:38       ` Sergei Shtylyov
2007-01-31 23:24         ` Alan
     [not found]     ` <58cb370e0702021606m4eb6f682xfa4bf769d398cf9@mail.gmail.com>
2007-02-03  0:50       ` Bartlomiej Zolnierkiewicz
2007-01-19  0:32 ` [PATCH 14/15] ide: rework the code for selecting the best DMA transfer mode Bartlomiej Zolnierkiewicz
2007-01-22 19:48   ` Sergei Shtylyov
     [not found]     ` <58cb370e0702021207o435f39cdsf3abb0d55829fc45@mail.gmail.com>
2007-02-02 23:57       ` Bartlomiej Zolnierkiewicz
2007-01-19  0:32 ` [PATCH 15/15] ide: add ide_tune_dma() helper Bartlomiej Zolnierkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45B279EE.5080807@ru.mvista.com \
    --to=sshtylyov@ru.mvista.com \
    --cc=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 10/15] ide: add ide_set_dma() helper' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).