public inbox for linux-kernel@vger.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, linuxppc-dev@ozlabs.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 15/18] ide: remove broken/dangerous HDIO_[UNREGISTER,SCAN]_HWIF ioctls
Date: Thu, 27 Mar 2008 20:38:50 +0300	[thread overview]
Message-ID: <47EBDBAA.2020308@ru.mvista.com> (raw)
In-Reply-To: <20080208004606.17746.90799.sendpatchset@localhost.localdomain>

Bartlomiej Zolnierkiewicz wrote:

> hdparm explicitely marks HDIO_[UNREGISTER,SCAN]_HWIF ioctls as DANGEROUS
> and given the number of bugs we can assume that there are no real users:

> * DMA has no chance of working because DMA resources are released by
>   ide_unregister() and they are never allocated again.

> * Since ide_init_hwif_ports() is used for ->io_ports[] setup the ioctls
>   don't work for almost all hosts with "non-standard" (== non ISA-like)
>   layout of IDE taskfile registers (there is a lot of such host drivers).

> * ide_port_init_devices() is not called when probing IDE devices so:
>   - drive->autotune is never set and IDE host/devices are not programmed
>     for the correct PIO/DMA transfer modes (=> possible data corruption)
>   - host specific I/O 32-bit and IRQ unmasking settings are not applied
>     (=> possible data corruption)
>   - host specific ->port_init_devs method is not called (=> no luck with
>     ht6560b, qd65xx and opti621 host drivers)

> * ->rw_disk method is not preserved (=> no HPT3xxN chipsets support).

> * ->serialized flag is not preserved (=> possible data corruption when
>    using icside, aec62xx (ATP850UF chipset), cmd640, cs5530, hpt366
>    (HPT3xxN chipsets), rz1000, sc1200, dtc2278 and ht6560b host drivers).

> * ->ack_intr method is not preserved (=> needed by ide-cris, buddha,
>   gayle and macide host drivers).

> * ->sata_scr[] and sata_misc[] is cleared by ide_unregister() and it
>   isn't initialized again (SiI3112 support needs them).

> * To issue an ioctl() there need to be at least one IDE device present
>   in the system.

> * ->cable_detect method is not preserved + it is not called when probing
>   IDE devices so cable detection is broken (however since DMA support is
>   also broken it doesn't really matter ;-).

> * Some objects which may have already been freed in ide_unregister()
>   are restored by ide_hwif_restore() (i.e. ->hwgroup).

> * ide_register_hw() may unregister unrelated IDE ports if free ide_hwifs[]
>   slot cannot be found.

> * When IDE host drivers are modular unregistered port may be re-used by
>   different host driver that owned it first causing subtle bugs.

> Since we now have a proper warm-plug support remove these ioctls,
> then remove no longer needed:
> - ide_register_hw() and ide_hwif_restore() functions
> - 'init_default' and 'restore' arguments of ide_unregister()
> - zeroeing of hwif->{dma,extra}_* fields in ide_unregister()

> As an added bonus IDE core code size shrinks by ~3kB (x86-32).

> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>

> Index: b/drivers/ide/ide-pnp.c
> ===================================================================
> --- a/drivers/ide/ide-pnp.c
> +++ b/drivers/ide/ide-pnp.c
[...]
> @@ -655,52 +530,6 @@ void ide_init_port_hw(ide_hwif_t *hwif, 
>  }
>  EXPORT_SYMBOL_GPL(ide_init_port_hw);
>  
> -/**
> - *	ide_register_hw		-	register IDE interface
> - *	@hw: hardware registers
> - *	@quirkproc: quirkproc function
> - *	@hwifp: pointer to returned hwif
> - *
> - *	Register an IDE interface, specifying exactly the registers etc.
> - *
> - *	Returns -1 on error.
> - */
> -
> -static int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
> -			   ide_hwif_t **hwifp)
> -{
> -	int index, retry = 1;
> -	ide_hwif_t *hwif;
> -	u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
> -
> -	do {
> -		hwif = ide_find_port(hw->io_ports[IDE_DATA_OFFSET]);
> -		index = hwif->index;
> -		if (hwif)
> -			goto found;

    Hm, I remember there was a patch that fixed the above bug where hwif is 
dereferenced before being checked for NULL, I wonder how come it was lost?

WBR, Sergei

  reply	other threads:[~2008-03-27 17:37 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-08  0:44 [PATCH 00/18] ide: warm-plug support for IDE devices and other goodies Bartlomiej Zolnierkiewicz
2008-02-08  0:44 ` [PATCH 01/18] ide-generic: set hwif->chipset Bartlomiej Zolnierkiewicz
2008-02-08  0:44 ` [PATCH 02/18] ide: fix ide_find_port() Bartlomiej Zolnierkiewicz
2008-02-08 17:23   ` Sergei Shtylyov
2008-02-08  0:44 ` [PATCH 03/18] ide: use ide_find_port() instead of ide_deprecated_find_port() Bartlomiej Zolnierkiewicz
2008-02-08  0:44 ` [PATCH 04/18] ide-acpi: add missing drive->acpidata zeroing Bartlomiej Zolnierkiewicz
2008-02-08  0:44 ` [PATCH 05/18] ide: factor out cable detection from ide_init_port() Bartlomiej Zolnierkiewicz
2008-02-08 17:18   ` Sergei Shtylyov
2008-02-08  0:45 ` [PATCH 06/18] ide: factor out code unregistering devices from ide_unregister() Bartlomiej Zolnierkiewicz
2008-02-09 18:07   ` Sergei Shtylyov
2008-02-08  0:45 ` [PATCH 07/18] ide: factor out devices init from ide_init_port_data() Bartlomiej Zolnierkiewicz
2008-02-09 18:10   ` Sergei Shtylyov
2008-02-08  0:45 ` [PATCH 08/18] ide: move ide_port_setup_devices() call to ide_device_add_all() Bartlomiej Zolnierkiewicz
2008-02-08 17:20   ` Sergei Shtylyov
2008-02-08  0:45 ` [PATCH 09/18] ide: rework PowerMac media-bay support Bartlomiej Zolnierkiewicz
2008-02-13  7:29   ` Michael Ellerman
2008-02-13 12:26     ` Bartlomiej Zolnierkiewicz
2008-02-08  0:45 ` [PATCH 10/18] ide: add warm-plug support for IDE devices Bartlomiej Zolnierkiewicz
2008-02-08  0:45 ` [PATCH 11/18] ide-generic: add ide_generic class and attribute for adding new interfaces Bartlomiej Zolnierkiewicz
2008-02-08  0:45 ` [PATCH 12/18] ide: remove needless CONFIG_BLK_DEV_HD hack from init_hwif() Bartlomiej Zolnierkiewicz
2008-02-08  0:45 ` [PATCH 13/18] ide: remove CONFIG_BLK_DEV_HD_IDE config option Bartlomiej Zolnierkiewicz
2008-02-08  0:45 ` [PATCH 14/18] ide: remove obsoleted "idex=base[,ctl[,irq]]" kernel parameters Bartlomiej Zolnierkiewicz
2008-02-08  0:46 ` [PATCH 15/18] ide: remove broken/dangerous HDIO_[UNREGISTER,SCAN]_HWIF ioctls Bartlomiej Zolnierkiewicz
2008-03-27 17:38   ` Sergei Shtylyov [this message]
2008-03-28 19:14     ` Mark Lord
2008-03-29 16:10       ` Bartlomiej Zolnierkiewicz
2008-03-29 16:03     ` Bartlomiej Zolnierkiewicz
2008-02-08  0:46 ` [PATCH 16/18] ide: remove ->hold field from ide_hwif_t Bartlomiej Zolnierkiewicz
2008-02-08  0:46 ` [PATCH 17/18] ide: remove init_hwif_default() Bartlomiej Zolnierkiewicz
2008-02-08  0:46 ` [PATCH 18/18] ide: remove ide_init_hwif_ports() Bartlomiej Zolnierkiewicz
2008-02-08  8:40 ` [PATCH 00/18] ide: warm-plug support for IDE devices and other goodies Benjamin Herrenschmidt
2008-02-12 11:49   ` Gabriel Paubert
2008-02-12 12:30     ` Gabriel Paubert
2008-02-13 10:08       ` Gabriel Paubert
2008-02-12 20:59     ` Benjamin Herrenschmidt
2008-02-12 21:04   ` Benjamin Herrenschmidt
2008-02-12 21:41     ` Alan Cox
2008-02-12 22:00       ` Benjamin Herrenschmidt
2008-02-12 21:54     ` 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=47EBDBAA.2020308@ru.mvista.com \
    --to=sshtylyov@ru.mvista.com \
    --cc=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox