Re: IDE problem [PATCH]

From: Andrzej Krzysztofowicz (ankry@green.mif.pg.gda.pl)
Date: Thu May 18 2000 - 03:25:16 EST


> This is not a bug but a protection for legacy ISA/VLB and early PCI that
> is basically ISA enhanced. This preserves the defalt loading of the
> first SIX hwif's for classic assignment.

They cannot be used (even two of them) with current ide driver.
If CONFIG_BLK_DEV_IDEPCI=n you always get *fake* message:
  idex: ports already in use, skipping probe

The i386 IDE implementation uses only nine ports.
io_ports[IDE_IRQ_OFFSET] should never be used and initialized to 0.
However, it is NOT.
"hw" is a local variable in an inline function and
ide_init_hwif_ports() for i386 leaves io_ports[IDE_IRQ_OFFSET] untouched,
containing a random value (same for ALL hwifs). Depending on compiler it may
be set to 0 but is not guaranteed.

As a result an attempt to register all ports including
io_ports[IDE_IRQ_OFFSET] gives you an error (port already registered for
the first hwif). Note, that registering 0xc020 as io_ports[IDE_IRQ_OFFSET]
for i386 is obviously NOT correct.

> The double memset could choke small memory systems, IMHO.

It is not double. The "hw" declared ide_init_default_hwifs() is nowhere
initialized. And it is only a few bytes 36(i386)-104(sparc64).

> Explain some more please.

At the moment I see minimum three ways of fixing this:
- memset(&hw, 0, sizeof(hw_regs_t)) in hwinf initialization
  ... as I (maybe unfortunately) suggested
- io_ports[IDE_IRQ_OFFSET] = 0 in ide_init_hwif_ports() for architectures
  (i386,alpha,etc.) which do not use it.
- #if defined(CONFIG_AMIGA) || defined(CONFIG_MAC)
  around io_ports[IDE_IRQ_OFFSET] checking/registering/unregistering
  (when calling ide_*_region()).

But at present IDE in gcc-2.7.2.3 compiled non-PCI kernels just DOESN'T WORK.

Andrzej

> > Problem description:
> >
> > When
> > CONFIG_BLK_DEV_IDE=y
> > # CONFIG_BLK_DEV_IDEPCI is not set
> > there is a problem using more than one IDE interface on kernels: 2.3.99pre9-2
> > and/or 2.2.15+ide.2.2.15.20000504.patch (i386, gcc-2.7.2.3).
> >
> > Boot messages:
> >
> > ide1: ports already in use, skipping probe
> > ide2: ports already in use, skipping probe
> > ide3: ports already in use, skipping probe
> > ide4: ports already in use, skipping probe
> > ide5: ports already in use, skipping probe
> > ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
> >
> > are related to non-initialized (random value) hwif->io_ports[IDE_IRQ_OFFSET],
> > in ide_init_hwif_ports(). This port should not be used for i386:
> >
> > 01f0-01f7 : ide0
> > 03c0-03df : vga+
> > 03f6-03f6 : ide0
> > c020-c020 : ide0 <------- port may be different ...
> > 0cf8-0cff : PCI conf1
> > ffa0-ffaf : Acer Laboratories Inc. [ALi] M5229 IDE
> >
> > The following patch fixes this problem in 2.3.99pre9-2 for i386 and,
> > possibly, for similar (in IDE implementation) architectures
> > (ia64/alpha/sparc/sparc64/sh). I do not know whether this problem touches
> > other architectures.
> > Same problem may appear in ide_register()/ide_setup()
> >
> > The patch also contains some cleaning 0 -> NULL for pointers.
> > BTW, I wonder if IDE support compiles for arm because of this mismatch in
> > ide_init_hwif_ports() (last parameter).
> >
> > Regards
> > Andrzej
> > ******************** patch ******************************
> > diff -u --recursive linux-2.3.99pre9-2/include/asm-alpha/ide.h linux/include/asm-alpha/ide.h
> > --- linux-2.3.99pre9-2/include/asm-alpha/ide.h Wed May 17 22:48:15 2000
> > +++ linux/include/asm-alpha/ide.h Wed May 17 22:53:03 2000
> > @@ -74,7 +74,8 @@
> > int index;
> >
> > for (index = 0; index < MAX_HWIFS; index++) {
> > - ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, 0);
> > + memset(&hw, 0, sizeof(hw_regs_t));
> > + ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
> > hw.irq = ide_default_irq(ide_default_io_base(index));
> > ide_register_hw(&hw, NULL);
> > }
> > diff -u --recursive linux-2.3.99pre9-2/include/asm-i386/ide.h linux/include/asm-i386/ide.h
> > --- linux-2.3.99pre9-2/include/asm-i386/ide.h Wed May 17 08:30:45 2000
> > +++ linux/include/asm-i386/ide.h Wed May 17 22:46:03 2000
> > @@ -78,6 +78,7 @@
> > int index;
> >
> > for(index = 0; index < MAX_HWIFS; index++) {
> > + memset(&hw, 0, sizeof(hw_regs_t));
> > ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
> > hw.irq = ide_default_irq(ide_default_io_base(index));
> > ide_register_hw(&hw, NULL);

[rest of the patch skipped]

-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Technical University of Gdansk

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 23 2000 - 21:00:14 EST