linux/drivers/ata
Bartlomiej Zolnierkiewicz 60c3be387b ata_piix: parallel scanning on PATA needs an extra locking
Commit log for commit 517d3cc15b
("[libata] ata_piix: Enable parallel scan") says:

    This patch turns on parallel scanning for the ata_piix driver.
    This driver is used on most netbooks (no AHCI for cheap storage it seems).
    The scan is the dominating time factor in the kernel boot for these
    devices; with this flag it gets cut in half for the device I used
    for testing (eeepc).
    Alan took a look at the driver source and concluded that it ought to be safe
    to do for this driver.  Alan has also checked with the hardware team.

and it is all true but once we put all things together additional
constraints for PATA controllers show up (some hardware registers
have per-host not per-port atomicity) and we risk misprogramming
the controller.

I used the following test to check whether the issue is real:

  @@ -736,8 +736,20 @@ static void piix_set_piomode(struct ata_
   			(timings[pio][1] << 8);
   	}
   	pci_write_config_word(dev, master_port, master_data);
  -	if (is_slave)
  +	if (is_slave) {
  +		if (ap->port_no == 0) {
  +			u8 tmp = slave_data;
  +
  +			while (slave_data == tmp) {
  +				pci_read_config_byte(dev, slave_port, &tmp);
  +				msleep(50);
  +			}
  +
  +			dev_printk(KERN_ERR, &dev->dev, "PATA parallel scan "
  +				   "race detected\n");
  +		}
   		pci_write_config_byte(dev, slave_port, slave_data);
  +	}

   	/* Ensure the UDMA bit is off - it will be turned back on if
   	   UDMA is selected */

and it indeed triggered the error message.

Lets fix all such races by adding an extra locking to ->set_piomode
and ->set_dmamode methods for PATA controllers.

[ Alan: would be better to take the host lock in libata-core for these
  cases so that we fix all the adapters in one swoop.  "Looks fine as a
  temproary quickfix tho" ]

Cc: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Cc: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-08-31 17:25:00 -10:00
..
ahci.c ahci: add workaround for on-board 5723s on some gigabyte boards 2009-08-12 06:21:32 -04:00
ata_generic.c
ata_piix.c ata_piix: parallel scanning on PATA needs an extra locking 2009-08-31 17:25:00 -10:00
Kconfig [libata] PATA driver for CF interface on AT91SAM9260 SoC 2009-06-23 01:54:24 -04:00
libata-acpi.c trivial: fix typos s/paramter/parameter/ and s/excute/execute/ in documentation and source comments. 2009-06-12 18:01:46 +02:00
libata-core.c libata: OCZ Vertex can't do HPA 2009-08-12 06:17:33 -04:00
libata-eh.c libata: add missing NULL pointer check to ata_eh_reset() 2009-07-28 21:05:41 -04:00
libata-pmp.c
libata-scsi.c
libata-sff.c libata-sff: avoid byte swapping in ata_sff_data_xfer() 2009-06-10 07:50:16 -04:00
libata.h
Makefile [libata] PATA driver for CF interface on AT91SAM9260 SoC 2009-06-23 01:54:24 -04:00
pata_acpi.c
pata_ali.c [libata] pata_ali: Use IGN_SIMPLEX 2009-06-05 17:10:54 -04:00
pata_amd.c
pata_artop.c
pata_at32.c
pata_at91.c pata_at91: fix resource release 2009-08-12 06:16:47 -04:00
pata_atiixp.c pata_atiixp: fix second channel support 2009-08-12 06:17:29 -04:00
pata_bf54x.c
pata_cmd64x.c
pata_cmd640.c
pata_cs5520.c
pata_cs5530.c
pata_cs5535.c
pata_cs5536.c
pata_cypress.c
pata_efar.c pata_efar: fix PIO2 underclocking 2009-06-05 14:40:52 -04:00
pata_hpt3x2n.c
pata_hpt3x3.c
pata_hpt37x.c
pata_hpt366.c
pata_icside.c
pata_isapnp.c
pata_it821x.c
pata_it8213.c
pata_ixp4xx_cf.c
pata_jmicron.c
pata_legacy.c
pata_marvell.c
pata_mpc52xx.c powerpc/5xxx: Add common mpc5xxx_get_bus_frequency() function 2009-06-17 00:30:22 -06:00
pata_mpiix.c
pata_netcell.c pata_netcell: Fix typo 2009-06-08 09:12:28 -07:00
pata_ninja32.c
pata_ns87410.c
pata_ns87415.c
pata_octeon_cf.c libata: remove superfluous NULL pointer checks 2009-07-28 21:06:13 -04:00
pata_of_platform.c
pata_oldpiix.c
pata_opti.c
pata_optidma.c
pata_palmld.c
pata_pcmcia.c pata_pcmcia: add CNF-CDROM-ID 2009-07-28 21:05:18 -04:00
pata_pdc202xx_old.c
pata_pdc2027x.c
pata_platform.c
pata_qdi.c
pata_radisys.c
pata_rb532_cf.c
pata_rz1000.c
pata_sc1200.c
pata_scc.c
pata_sch.c
pata_serverworks.c
pata_sil680.c
pata_sis.c
pata_sl82c105.c
pata_triflex.c
pata_via.c
pata_winbond.c
pdc_adma.c
sata_fsl.c sata_fsl: Add power mgmt support 2009-06-23 01:54:27 -04:00
sata_inic162x.c
sata_mv.c libata: remove superfluous NULL pointer checks 2009-07-28 21:06:13 -04:00
sata_nv.c sata_nv: MSI support, disabled by default 2009-08-12 06:20:29 -04:00
sata_promise.c
sata_promise.h
sata_qstor.c
sata_sil24.c
sata_sil.c libata: remove superfluous NULL pointer checks 2009-07-28 21:06:13 -04:00
sata_sis.c
sata_svw.c
sata_sx4.c sata_sx4: speed up ECC initialization 2009-06-10 07:50:17 -04:00
sata_uli.c
sata_via.c
sata_vsc.c
sis.h