2006-02-01 07:27:21

by Kumar Gala

[permalink] [raw]
Subject: RFC: Compact Flash True IDE Mode Driver

I was hoping to get some comments on this work in progress driver for
using a compact flash device running in True IDE Mode connect via a MMIO
interface. The driver is working, however the embedded system I'm running
on need some HW fixes to address the fact that the byte lanes for the data
are swapped. I figured now was a good time to incorporate any changes
while I wait for the HW fixes (which will allow me to remove the
cfide_outsw & cfide_insw).

- kumar


diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 1c81174..8334baf 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -930,6 +930,12 @@ config BLK_DEV_Q40IDE
normally be on; disable it only if you are running a custom hard
drive subsystem through an expansion card.

+config BLK_DEV_CFIDE
+ tristate "Compact Flash in True IDE mode"
+ help
+ This is the IDE driver for a Memory Mapped Compact Flash Device
+ running in True IDE mode.
+
config BLK_DEV_MPC8xx_IDE
bool "MPC8xx IDE support"
depends on 8xx && IDE=y && BLK_DEV_IDE=y
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index 569fae7..09ed3aa 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -32,6 +32,7 @@ ide-core-$(CONFIG_BLK_DEV_FALCON_IDE) +=
ide-core-$(CONFIG_BLK_DEV_GAYLE) += legacy/gayle.o
ide-core-$(CONFIG_BLK_DEV_MAC_IDE) += legacy/macide.o
ide-core-$(CONFIG_BLK_DEV_Q40IDE) += legacy/q40ide.o
+ide-core-$(CONFIG_BLK_DEV_CFIDE) += legacy/cfide.o

# built-in only drivers from ppc/
ide-core-$(CONFIG_BLK_DEV_MPC8xx_IDE) += ppc/mpc8xx.o
diff --git a/drivers/ide/legacy/cfide.c b/drivers/ide/legacy/cfide.c
new file mode 100644
index 0000000..4444005
--- /dev/null
+++ b/drivers/ide/legacy/cfide.c
@@ -0,0 +1,222 @@
+/*
+ * Compact Flash Memory Mapped True IDE mode driver
+ *
+ * Maintainer: Kumar Gala <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/ide.h>
+#include <linux/ioport.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <asm/io.h>
+#include <asm/byteorder.h>
+
+static void __iomem *cfide_mapbase;
+static void __iomem *cfide_alt_mapbase;
+
+/* xxx: use standard outsw, insw when byte lanes swapped */
+static void cfide_outsw(unsigned long port, void *addr, u32 count)
+{
+ _outsw((volatile u16 __iomem *)port, addr, count);
+}
+
+static void cfide_insw(unsigned long port, void *addr, u32 count)
+{
+ _insw((volatile u16 __iomem *)port, addr, count);
+}
+
+static void cfide_outl(u32 addr, unsigned long port)
+{
+ panic("outl unsupported");
+}
+
+static void cfide_outsl(unsigned long port, void *addr, u32 count)
+{
+ panic("outsl unsupported");
+}
+
+static u32 cfide_inl(unsigned long port)
+{
+ panic("inl unsupported");
+ return 0;
+}
+
+static void cfide_insl(unsigned long port, void *addr, u32 count)
+{
+ panic("insl unsupported");
+}
+
+static ide_hwif_t *cfide_locate_hwif(void __iomem * base, void __iomem * ctrl,
+ unsigned int sz, int irq)
+{
+ unsigned long port = (unsigned long)base;
+ ide_hwif_t *hwif;
+ int index, i;
+
+ for (index = 0; index < MAX_HWIFS; ++index) {
+ hwif = ide_hwifs + index;
+ if (hwif->io_ports[IDE_DATA_OFFSET] == port)
+ goto found;
+ }
+
+ for (index = 0; index < MAX_HWIFS; ++index) {
+ hwif = ide_hwifs + index;
+ if (hwif->io_ports[IDE_DATA_OFFSET] == 0)
+ goto found;
+ }
+
+ return NULL;
+
+ found:
+
+ /* xxx: fix when byte lanes are swapped */
+ hwif->hw.io_ports[IDE_DATA_OFFSET] = port;
+ port += 3;
+ for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET; i++, port += sz)
+ hwif->hw.io_ports[i] = port;
+
+ hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl + 13;
+
+ memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
+ hwif->hw.irq = hwif->irq = irq;
+
+ hwif->hw.dma = NO_DMA;
+ hwif->hw.chipset = ide_unknown;
+
+ hwif->mmio = 2;
+ default_hwif_mmiops(hwif);
+ hwif->OUTL = cfide_outl;
+ hwif->OUTSW = cfide_outsw;
+ hwif->OUTSL = cfide_outsl;
+ hwif->INL = cfide_inl;
+ hwif->INSW = cfide_insw;
+ hwif->INSL = cfide_insl;
+
+ return hwif;
+}
+
+static int __devinit cfide_lbus_probe(struct platform_device *dev)
+{
+ struct resource *res_base, *res_alt, *res_irq;
+ ide_hwif_t *hwif;
+ int ret = 0;
+
+ /* get a pointer to the register memory */
+ res_base = platform_get_resource(dev, IORESOURCE_MEM, 0);
+ res_alt = platform_get_resource(dev, IORESOURCE_MEM, 1);
+ res_irq = platform_get_resource(dev, IORESOURCE_IRQ, 0);
+
+ if ((!res_base) || (!res_alt) || (!res_irq)) {
+ ret = -ENODEV;
+ goto out;
+ }
+
+ if (!request_mem_region
+ (res_base->start, res_base->end - res_base->start + 1, dev->name)) {
+ pr_debug("%s: request_mem_region of base failed\n", dev->name);
+ ret = -EBUSY;
+ goto out;
+ }
+
+ if (!request_mem_region
+ (res_alt->start, res_alt->end - res_alt->start + 1, dev->name)) {
+ pr_debug("%s: request_mem_region of alt failed\n", dev->name);
+ ret = -EBUSY;
+ goto out;
+ }
+
+ cfide_mapbase =
+ ioremap(res_base->start, res_base->end - res_base->start + 1);
+ if (!cfide_mapbase) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ cfide_alt_mapbase =
+ ioremap(res_alt->start, res_alt->end - res_alt->start + 1);
+
+ if (!cfide_alt_mapbase) {
+ ret = -ENOMEM;
+ goto unmap_base;
+ }
+
+ hwif = cfide_locate_hwif(cfide_mapbase, cfide_alt_mapbase, 2,
+ res_irq->start);
+
+ if (!hwif) {
+ ret = -ENODEV;
+ goto unmap_alt;
+ }
+
+ hwif->gendev.parent = &dev->dev;
+ hwif->noprobe = 0;
+
+ probe_hwif_init(hwif);
+
+ platform_set_drvdata(dev, hwif);
+
+ return 0;
+
+ unmap_alt:
+ iounmap(cfide_alt_mapbase);
+ unmap_base:
+ iounmap(cfide_mapbase);
+ out:
+ return ret;
+}
+
+static int __devexit cfide_lbus_remove(struct platform_device *dev)
+{
+ ide_hwif_t *hwif = platform_get_drvdata(dev);
+ struct resource *res_base, *res_alt;
+
+ /* get a pointer to the register memory */
+ res_base = platform_get_resource(dev, IORESOURCE_MEM, 0);
+ res_alt = platform_get_resource(dev, IORESOURCE_MEM, 1);
+
+ release_mem_region(res_base->start, res_base->end - res_base->start + 1);
+ release_mem_region(res_alt->start, res_alt->end - res_alt->start + 1);
+
+ platform_set_drvdata(dev, NULL);
+
+ /* there must be a better way */
+ ide_unregister(hwif - ide_hwifs);
+
+ iounmap(cfide_mapbase);
+ iounmap(cfide_alt_mapbase);
+
+ return 0;
+}
+
+static struct platform_driver cfide_driver = {
+ .probe = cfide_lbus_probe,
+ .remove = __devexit_p(cfide_lbus_remove),
+ .driver = {
+ .name = "mmio-cfide",
+ },
+};
+
+static int __init cfide_lbus_init(void)
+{
+ return platform_driver_register(&cfide_driver);
+}
+
+static void __exit cfide_lbus_exit(void)
+{
+ platform_driver_unregister(&cfide_driver);
+}
+
+MODULE_DESCRIPTION("MMIO based True IDE Mode Compact Flash Driver");
+MODULE_LICENSE("GPL");
+
+module_init(cfide_lbus_init);
+module_exit(cfide_lbus_exit);


2006-02-06 04:12:48

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: RFC: Compact Flash True IDE Mode Driver

On Wed, 2006-02-01 at 01:19 -0600, Kumar Gala wrote:
> I was hoping to get some comments on this work in progress driver for
> using a compact flash device running in True IDE Mode connect via a MMIO
> interface. The driver is working, however the embedded system I'm running
> on need some HW fixes to address the fact that the byte lanes for the data
> are swapped. I figured now was a good time to incorporate any changes
> while I wait for the HW fixes (which will allow me to remove the
> cfide_outsw & cfide_insw).

Your driver basically boils down to a simple IDE host driver configured
by platform functions. I suggest you remove "compact flash" here and
have the platform resource optinally be either PIO or MMIO and you
magically get a "generic" IDE driver useable by a lot of simple embedded
machines (it assumes all timing related things have been handled by the
firmware). Want to be sneakier ? Add a timing setup callback to the
platform data you pass to it and you get one that can even do PIO
modes :)

Ben.


Subject: Re: RFC: Compact Flash True IDE Mode Driver

Hi,

On 2/1/06, Kumar Gala <[email protected]> wrote:
> I was hoping to get some comments on this work in progress driver for
> using a compact flash device running in True IDE Mode connect via a MMIO
> interface. The driver is working, however the embedded system I'm running
> on need some HW fixes to address the fact that the byte lanes for the data
> are swapped. I figured now was a good time to incorporate any changes
> while I wait for the HW fixes (which will allow me to remove the
> cfide_outsw & cfide_insw).
>
> - kumar
>
>
> diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
> index 1c81174..8334baf 100644
> --- a/drivers/ide/Kconfig
> +++ b/drivers/ide/Kconfig
> @@ -930,6 +930,12 @@ config BLK_DEV_Q40IDE
> normally be on; disable it only if you are running a custom hard
> drive subsystem through an expansion card.
>
> +config BLK_DEV_CFIDE
> + tristate "Compact Flash in True IDE mode"

depends on?

> + help
> + This is the IDE driver for a Memory Mapped Compact Flash Device
> + running in True IDE mode.
> +
> config BLK_DEV_MPC8xx_IDE
> bool "MPC8xx IDE support"
> depends on 8xx && IDE=y && BLK_DEV_IDE=y
> diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
> index 569fae7..09ed3aa 100644
> --- a/drivers/ide/Makefile
> +++ b/drivers/ide/Makefile
> @@ -32,6 +32,7 @@ ide-core-$(CONFIG_BLK_DEV_FALCON_IDE) +=
> ide-core-$(CONFIG_BLK_DEV_GAYLE) += legacy/gayle.o
> ide-core-$(CONFIG_BLK_DEV_MAC_IDE) += legacy/macide.o
> ide-core-$(CONFIG_BLK_DEV_Q40IDE) += legacy/q40ide.o
> +ide-core-$(CONFIG_BLK_DEV_CFIDE) += legacy/cfide.o

Won't fly. As comment in Makefile states "ide-core" is for
built-in only drivers. Please see how ide-cs is handled.

> # built-in only drivers from ppc/
> ide-core-$(CONFIG_BLK_DEV_MPC8xx_IDE) += ppc/mpc8xx.o
> diff --git a/drivers/ide/legacy/cfide.c b/drivers/ide/legacy/cfide.c
> new file mode 100644
> index 0000000..4444005
> --- /dev/null
> +++ b/drivers/ide/legacy/cfide.c
> @@ -0,0 +1,222 @@
> +/*
> + * Compact Flash Memory Mapped True IDE mode driver
> + *
> + * Maintainer: Kumar Gala <[email protected]>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation; either version 2 of the License, or (at your
> + * option) any later version.
> + */
> +
> +#include <linux/config.h>

Is this needed?

> +#include <linux/types.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/ide.h>
> +#include <linux/ioport.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <asm/io.h>
> +#include <asm/byteorder.h>

ditto

> +static void __iomem *cfide_mapbase;
> +static void __iomem *cfide_alt_mapbase;
> +
> +/* xxx: use standard outsw, insw when byte lanes swapped */
> +static void cfide_outsw(unsigned long port, void *addr, u32 count)
> +{
> + _outsw((volatile u16 __iomem *)port, addr, count);
> +}
> +
> +static void cfide_insw(unsigned long port, void *addr, u32 count)
> +{
> + _insw((volatile u16 __iomem *)port, addr, count);
> +}
> +
> +static void cfide_outl(u32 addr, unsigned long port)
> +{
> + panic("outl unsupported");
> +}

Can be removed as it is not used in any code-path for this controller.

> +static void cfide_outsl(unsigned long port, void *addr, u32 count)
> +{
> + panic("outsl unsupported");
> +}

This will panic as soon as somebody tries to enable 32-bit I/O
using hdparm. Please add ide_hwif_t.no_io_32bit flag and teach
ide-disk.c:ide_disk_setup() about it (separate patch).

> +static u32 cfide_inl(unsigned long port)
> +{
> + panic("inl unsupported");
> + return 0;
> +}

same problem as with cfide_outl()

> +static void cfide_insl(unsigned long port, void *addr, u32 count)
> +{
> + panic("insl unsupported");
> +}

same problem as with cfide_outsl()

> +static ide_hwif_t *cfide_locate_hwif(void __iomem * base, void __iomem * ctrl,
> + unsigned int sz, int irq)

__devinit

> +{
> + unsigned long port = (unsigned long)base;
> + ide_hwif_t *hwif;
> + int index, i;
> +
> + for (index = 0; index < MAX_HWIFS; ++index) {
> + hwif = ide_hwifs + index;
> + if (hwif->io_ports[IDE_DATA_OFFSET] == port)
> + goto found;
> + }
> +
> + for (index = 0; index < MAX_HWIFS; ++index) {
> + hwif = ide_hwifs + index;
> + if (hwif->io_ports[IDE_DATA_OFFSET] == 0)
> + goto found;
> + }
> +
> + return NULL;

This is the same as in icside.c/rapide.c,
it really should be generic helper (separate patch)

> + found:
> +
> + /* xxx: fix when byte lanes are swapped */
> + hwif->hw.io_ports[IDE_DATA_OFFSET] = port;
> + port += 3;
> + for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET; i++, port += sz)
> + hwif->hw.io_ports[i] = port;
> +
> + hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl + 13;
> +
> + memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
> + hwif->hw.irq = hwif->irq = irq;
> +
> + hwif->hw.dma = NO_DMA;
> + hwif->hw.chipset = ide_unknown;

Please use ide_generic or add new type,
ide_unknown indicates that this slot is free.

> + hwif->mmio = 2;
> + default_hwif_mmiops(hwif);
> + hwif->OUTL = cfide_outl;

= NULL;

> + hwif->OUTSW = cfide_outsw;
> + hwif->OUTSL = cfide_outsl;

ditto

> + hwif->INL = cfide_inl;

ditto

> + hwif->INSW = cfide_insw;
> + hwif->INSL = cfide_insl;

ditto

> + return hwif;
> +}
> +
> +static int __devinit cfide_lbus_probe(struct platform_device *dev)
> +{
> + struct resource *res_base, *res_alt, *res_irq;
> + ide_hwif_t *hwif;
> + int ret = 0;
> +
> + /* get a pointer to the register memory */
> + res_base = platform_get_resource(dev, IORESOURCE_MEM, 0);
> + res_alt = platform_get_resource(dev, IORESOURCE_MEM, 1);
> + res_irq = platform_get_resource(dev, IORESOURCE_IRQ, 0);
> +
> + if ((!res_base) || (!res_alt) || (!res_irq)) {
> + ret = -ENODEV;
> + goto out;
> + }
> +
> + if (!request_mem_region
> + (res_base->start, res_base->end - res_base->start + 1, dev->name)) {
> + pr_debug("%s: request_mem_region of base failed\n", dev->name);
> + ret = -EBUSY;
> + goto out;
> + }
> +
> + if (!request_mem_region
> + (res_alt->start, res_alt->end - res_alt->start + 1, dev->name)) {
> + pr_debug("%s: request_mem_region of alt failed\n", dev->name);
> + ret = -EBUSY;
> + goto out;

res_base needs to be freed

> + }
> +
> + cfide_mapbase =
> + ioremap(res_base->start, res_base->end - res_base->start + 1);
> + if (!cfide_mapbase) {
> + ret = -ENOMEM;
> + goto out;

res_base and res_alt need to be freed

> + }
> +
> + cfide_alt_mapbase =
> + ioremap(res_alt->start, res_alt->end - res_alt->start + 1);
> +
> + if (!cfide_alt_mapbase) {
> + ret = -ENOMEM;
> + goto unmap_base;
> + }
> +
> + hwif = cfide_locate_hwif(cfide_mapbase, cfide_alt_mapbase, 2,
> + res_irq->start);
> +
> + if (!hwif) {
> + ret = -ENODEV;
> + goto unmap_alt;
> + }
> +
> + hwif->gendev.parent = &dev->dev;
> + hwif->noprobe = 0;
> +
> + probe_hwif_init(hwif);

create_proc_ide_interfaces() is missing

> + platform_set_drvdata(dev, hwif);
> +
> + return 0;
> +
> + unmap_alt:
> + iounmap(cfide_alt_mapbase);
> + unmap_base:
> + iounmap(cfide_mapbase);
> + out:
> + return ret;
> +}
> +
> +static int __devexit cfide_lbus_remove(struct platform_device *dev)
> +{
> + ide_hwif_t *hwif = platform_get_drvdata(dev);
> + struct resource *res_base, *res_alt;
> +
> + /* get a pointer to the register memory */
> + res_base = platform_get_resource(dev, IORESOURCE_MEM, 0);
> + res_alt = platform_get_resource(dev, IORESOURCE_MEM, 1);
> +
> + release_mem_region(res_base->start, res_base->end - res_base->start + 1);
> + release_mem_region(res_alt->start, res_alt->end - res_alt->start + 1);
> +
> + platform_set_drvdata(dev, NULL);
> +
> + /* there must be a better way */

yes, fixing IDE unplug :)

> + ide_unregister(hwif - ide_hwifs);

Otherwise driver looks pretty decent and with the above changes
it gets my ACK. Additional enhancements as suggested by Ben
would be nice but obviously they are not needed for a start

Thanks,
Bartlomiej

2006-02-13 16:38:48

by Kumar Gala

[permalink] [raw]
Subject: Re: RFC: Compact Flash True IDE Mode Driver

On Mon, 13 Feb 2006, Bartlomiej Zolnierkiewicz wrote:

> Hi,
>
> On 2/1/06, Kumar Gala <[email protected]> wrote:
> > I was hoping to get some comments on this work in progress driver for
> > using a compact flash device running in True IDE Mode connect via a MMIO
> > interface. The driver is working, however the embedded system I'm running
> > on need some HW fixes to address the fact that the byte lanes for the data
> > are swapped. I figured now was a good time to incorporate any changes
> > while I wait for the HW fixes (which will allow me to remove the
> > cfide_outsw & cfide_insw).
> >
> > - kumar
> >
> >
> > diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
> > index 1c81174..8334baf 100644
> > --- a/drivers/ide/Kconfig
> > +++ b/drivers/ide/Kconfig
> > @@ -930,6 +930,12 @@ config BLK_DEV_Q40IDE
> > normally be on; disable it only if you are running a custom hard
> > drive subsystem through an expansion card.
> >
> > +config BLK_DEV_CFIDE
> > + tristate "Compact Flash in True IDE mode"
>
> depends on?

It really doesn't depend on anything.

>
> > + help
> > + This is the IDE driver for a Memory Mapped Compact Flash Device
> > + running in True IDE mode.
> > +
> > config BLK_DEV_MPC8xx_IDE
> > bool "MPC8xx IDE support"
> > depends on 8xx && IDE=y && BLK_DEV_IDE=y
> > diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
> > index 569fae7..09ed3aa 100644
> > --- a/drivers/ide/Makefile
> > +++ b/drivers/ide/Makefile
> > @@ -32,6 +32,7 @@ ide-core-$(CONFIG_BLK_DEV_FALCON_IDE) +=
> > ide-core-$(CONFIG_BLK_DEV_GAYLE) += legacy/gayle.o
> > ide-core-$(CONFIG_BLK_DEV_MAC_IDE) += legacy/macide.o
> > ide-core-$(CONFIG_BLK_DEV_Q40IDE) += legacy/q40ide.o
> > +ide-core-$(CONFIG_BLK_DEV_CFIDE) += legacy/cfide.o
>
> Won't fly. As comment in Makefile states "ide-core" is for
> built-in only drivers. Please see how ide-cs is handled.

Gotcha, will move to ide/legacy/Makefile

>
> > # built-in only drivers from ppc/
> > ide-core-$(CONFIG_BLK_DEV_MPC8xx_IDE) += ppc/mpc8xx.o
> > diff --git a/drivers/ide/legacy/cfide.c b/drivers/ide/legacy/cfide.c
> > new file mode 100644
> > index 0000000..4444005
> > --- /dev/null
> > +++ b/drivers/ide/legacy/cfide.c
> > @@ -0,0 +1,222 @@
> > +/*
> > + * Compact Flash Memory Mapped True IDE mode driver
> > + *
> > + * Maintainer: Kumar Gala <[email protected]>
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms of the GNU General Public License as published by the
> > + * Free Software Foundation; either version 2 of the License, or (at your
> > + * option) any later version.
> > + */
> > +
> > +#include <linux/config.h>
>
> Is this needed?
>
> > +#include <linux/types.h>
> > +#include <linux/init.h>
> > +#include <linux/kernel.h>
> > +#include <linux/ide.h>
> > +#include <linux/ioport.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <asm/io.h>
> > +#include <asm/byteorder.h>
>
> ditto
>
> > +static void __iomem *cfide_mapbase;
> > +static void __iomem *cfide_alt_mapbase;
> > +
> > +/* xxx: use standard outsw, insw when byte lanes swapped */
> > +static void cfide_outsw(unsigned long port, void *addr, u32 count)
> > +{
> > + _outsw((volatile u16 __iomem *)port, addr, count);
> > +}
> > +
> > +static void cfide_insw(unsigned long port, void *addr, u32 count)
> > +{
> > + _insw((volatile u16 __iomem *)port, addr, count);
> > +}
> > +
> > +static void cfide_outl(u32 addr, unsigned long port)
> > +{
> > + panic("outl unsupported");
> > +}
>
> Can be removed as it is not used in any code-path for this controller.
>
> > +static void cfide_outsl(unsigned long port, void *addr, u32 count)
> > +{
> > + panic("outsl unsupported");
> > +}
>
> This will panic as soon as somebody tries to enable 32-bit I/O
> using hdparm. Please add ide_hwif_t.no_io_32bit flag and teach
> ide-disk.c:ide_disk_setup() about it (separate patch).

I'm not sure I follow this, can you expand.

>
> > +static u32 cfide_inl(unsigned long port)
> > +{
> > + panic("inl unsupported");
> > + return 0;
> > +}
>
> same problem as with cfide_outl()
>
> > +static void cfide_insl(unsigned long port, void *addr, u32 count)
> > +{
> > + panic("insl unsupported");
> > +}
>
> same problem as with cfide_outsl()
>
> > +static ide_hwif_t *cfide_locate_hwif(void __iomem * base, void __iomem * ctrl,
> > + unsigned int sz, int irq)
>
> __devinit
>
> > +{
> > + unsigned long port = (unsigned long)base;
> > + ide_hwif_t *hwif;
> > + int index, i;
> > +
> > + for (index = 0; index < MAX_HWIFS; ++index) {
> > + hwif = ide_hwifs + index;
> > + if (hwif->io_ports[IDE_DATA_OFFSET] == port)
> > + goto found;
> > + }
> > +
> > + for (index = 0; index < MAX_HWIFS; ++index) {
> > + hwif = ide_hwifs + index;
> > + if (hwif->io_ports[IDE_DATA_OFFSET] == 0)
> > + goto found;
> > + }
> > +
> > + return NULL;
>
> This is the same as in icside.c/rapide.c,
> it really should be generic helper (separate patch)

Suggesitions, on where that should live, ide-probe.c?

>
> > + found:
> > +
> > + /* xxx: fix when byte lanes are swapped */
> > + hwif->hw.io_ports[IDE_DATA_OFFSET] = port;
> > + port += 3;
> > + for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET; i++, port += sz)
> > + hwif->hw.io_ports[i] = port;
> > +
> > + hwif->hw.io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl + 13;
> > +
> > + memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
> > + hwif->hw.irq = hwif->irq = irq;
> > +
> > + hwif->hw.dma = NO_DMA;
> > + hwif->hw.chipset = ide_unknown;
>
> Please use ide_generic or add new type,
> ide_unknown indicates that this slot is free.
>
> > + hwif->mmio = 2;
> > + default_hwif_mmiops(hwif);
> > + hwif->OUTL = cfide_outl;
>
> = NULL;
>
> > + hwif->OUTSW = cfide_outsw;
> > + hwif->OUTSL = cfide_outsl;
>
> ditto
>
> > + hwif->INL = cfide_inl;
>
> ditto
>
> > + hwif->INSW = cfide_insw;
> > + hwif->INSL = cfide_insl;
>
> ditto
>
> > + return hwif;
> > +}
> > +
> > +static int __devinit cfide_lbus_probe(struct platform_device *dev)
> > +{
> > + struct resource *res_base, *res_alt, *res_irq;
> > + ide_hwif_t *hwif;
> > + int ret = 0;
> > +
> > + /* get a pointer to the register memory */
> > + res_base = platform_get_resource(dev, IORESOURCE_MEM, 0);
> > + res_alt = platform_get_resource(dev, IORESOURCE_MEM, 1);
> > + res_irq = platform_get_resource(dev, IORESOURCE_IRQ, 0);
> > +
> > + if ((!res_base) || (!res_alt) || (!res_irq)) {
> > + ret = -ENODEV;
> > + goto out;
> > + }
> > +
> > + if (!request_mem_region
> > + (res_base->start, res_base->end - res_base->start + 1, dev->name)) {
> > + pr_debug("%s: request_mem_region of base failed\n", dev->name);
> > + ret = -EBUSY;
> > + goto out;
> > + }
> > +
> > + if (!request_mem_region
> > + (res_alt->start, res_alt->end - res_alt->start + 1, dev->name)) {
> > + pr_debug("%s: request_mem_region of alt failed\n", dev->name);
> > + ret = -EBUSY;
> > + goto out;
>
> res_base needs to be freed
>
> > + }
> > +
> > + cfide_mapbase =
> > + ioremap(res_base->start, res_base->end - res_base->start + 1);
> > + if (!cfide_mapbase) {
> > + ret = -ENOMEM;
> > + goto out;
>
> res_base and res_alt need to be freed
>
> > + }
> > +
> > + cfide_alt_mapbase =
> > + ioremap(res_alt->start, res_alt->end - res_alt->start + 1);
> > +
> > + if (!cfide_alt_mapbase) {
> > + ret = -ENOMEM;
> > + goto unmap_base;
> > + }
> > +
> > + hwif = cfide_locate_hwif(cfide_mapbase, cfide_alt_mapbase, 2,
> > + res_irq->start);
> > +
> > + if (!hwif) {
> > + ret = -ENODEV;
> > + goto unmap_alt;
> > + }
> > +
> > + hwif->gendev.parent = &dev->dev;
> > + hwif->noprobe = 0;
> > +
> > + probe_hwif_init(hwif);
>
> create_proc_ide_interfaces() is missing
>
> > + platform_set_drvdata(dev, hwif);
> > +
> > + return 0;
> > +
> > + unmap_alt:
> > + iounmap(cfide_alt_mapbase);
> > + unmap_base:
> > + iounmap(cfide_mapbase);
> > + out:
> > + return ret;
> > +}
> > +
> > +static int __devexit cfide_lbus_remove(struct platform_device *dev)
> > +{
> > + ide_hwif_t *hwif = platform_get_drvdata(dev);
> > + struct resource *res_base, *res_alt;
> > +
> > + /* get a pointer to the register memory */
> > + res_base = platform_get_resource(dev, IORESOURCE_MEM, 0);
> > + res_alt = platform_get_resource(dev, IORESOURCE_MEM, 1);
> > +
> > + release_mem_region(res_base->start, res_base->end - res_base->start + 1);
> > + release_mem_region(res_alt->start, res_alt->end - res_alt->start + 1);
> > +
> > + platform_set_drvdata(dev, NULL);
> > +
> > + /* there must be a better way */
>
> yes, fixing IDE unplug :)
>
> > + ide_unregister(hwif - ide_hwifs);
>
> Otherwise driver looks pretty decent and with the above changes
> it gets my ACK. Additional enhancements as suggested by Ben
> would be nice but obviously they are not needed for a start

Everything else makes sense and I'll make those changes, plus some based
on Ben's comments. If you can let me know about the two questions
(expanding on ide_hwif_t.no_io_32bit and where to but a generic version of
cfide_locate_hwif).

thanks

- kumar

Subject: Re: RFC: Compact Flash True IDE Mode Driver

On 2/13/06, Kumar Gala <[email protected]> wrote:

> > > +static void cfide_outsl(unsigned long port, void *addr, u32 count)
> > > +{
> > > + panic("outsl unsupported");
> > > +}
> >
> > This will panic as soon as somebody tries to enable 32-bit I/O
> > using hdparm. Please add ide_hwif_t.no_io_32bit flag and teach
> > ide-disk.c:ide_disk_setup() about it (separate patch).
>
> I'm not sure I follow this, can you expand.

Do "hdparm -c 2 /dev/hdx" first and then read/write to the device
and you should see it. :)

We need to make "hdparm -c 2" (and "hdparm -c 3") unsupported
(see how "io_32bit" setting is handled in ide_add_generic_settings()
and how it can be read-only or read-write setting depending on the
value of drive->no_io_32bit).

To do this we need to set drive->no_io_32bit to 1 (see how
ide_disk_setup() handles it). Unfortunately 32-bit I/O capability
is based on capabilities of both host and device so we have to
add new flag hwif->no_io_32bit to indicate that host doesn't
support 32-bit I/O.

> > > +static ide_hwif_t *cfide_locate_hwif(void __iomem * base, void __iomem * ctrl,
> > > + unsigned int sz, int irq)
> >
> > __devinit
> >
> > > +{
> > > + unsigned long port = (unsigned long)base;
> > > + ide_hwif_t *hwif;
> > > + int index, i;
> > > +
> > > + for (index = 0; index < MAX_HWIFS; ++index) {
> > > + hwif = ide_hwifs + index;
> > > + if (hwif->io_ports[IDE_DATA_OFFSET] == port)
> > > + goto found;
> > > + }
> > > +
> > > + for (index = 0; index < MAX_HWIFS; ++index) {
> > > + hwif = ide_hwifs + index;
> > > + if (hwif->io_ports[IDE_DATA_OFFSET] == 0)
> > > + goto found;
> > > + }
> > > +
> > > + return NULL;
> >
> > This is the same as in icside.c/rapide.c,
> > it really should be generic helper (separate patch)
>
> Suggesitions, on where that should live, ide-probe.c?

ide.c, no rush for this one as I have patch ready
(only needs to find it... sigh...)

> > Otherwise driver looks pretty decent and with the above changes
> > it gets my ACK. Additional enhancements as suggested by Ben
> > would be nice but obviously they are not needed for a start
>
> Everything else makes sense and I'll make those changes, plus some based
> on Ben's comments. If you can let me know about the two questions
> (expanding on ide_hwif_t.no_io_32bit and where to but a generic version of
> cfide_locate_hwif).

Thanks,
Bartlomiej

2006-02-13 19:45:20

by Kumar Gala

[permalink] [raw]
Subject: Re: RFC: Compact Flash True IDE Mode Driver


On Feb 13, 2006, at 10:53 AM, Bartlomiej Zolnierkiewicz wrote:

> On 2/13/06, Kumar Gala <[email protected]> wrote:
>
>>>> +static void cfide_outsl(unsigned long port, void *addr, u32 count)
>>>> +{
>>>> + panic("outsl unsupported");
>>>> +}
>>>
>>> This will panic as soon as somebody tries to enable 32-bit I/O
>>> using hdparm. Please add ide_hwif_t.no_io_32bit flag and teach
>>> ide-disk.c:ide_disk_setup() about it (separate patch).
>>
>> I'm not sure I follow this, can you expand.
>
> Do "hdparm -c 2 /dev/hdx" first and then read/write to the device
> and you should see it. :)
>
> We need to make "hdparm -c 2" (and "hdparm -c 3") unsupported
> (see how "io_32bit" setting is handled in ide_add_generic_settings()
> and how it can be read-only or read-write setting depending on the
> value of drive->no_io_32bit).
>
> To do this we need to set drive->no_io_32bit to 1 (see how
> ide_disk_setup() handles it). Unfortunately 32-bit I/O capability
> is based on capabilities of both host and device so we have to
> add new flag hwif->no_io_32bit to indicate that host doesn't
> support 32-bit I/O.

This all make sense, should I check for hwif->no_io_32bit in
idedisk_setup() and set drive->no_io_32bit to 1 if hwif->no_io_32bit
is 1 or do this the test in ide_add_generic_settings()?

- kumar

Subject: Re: RFC: Compact Flash True IDE Mode Driver

On 2/13/06, Kumar Gala <[email protected]> wrote:
>
> On Feb 13, 2006, at 10:53 AM, Bartlomiej Zolnierkiewicz wrote:
>
> > On 2/13/06, Kumar Gala <[email protected]> wrote:
> >
> >>>> +static void cfide_outsl(unsigned long port, void *addr, u32 count)
> >>>> +{
> >>>> + panic("outsl unsupported");
> >>>> +}
> >>>
> >>> This will panic as soon as somebody tries to enable 32-bit I/O
> >>> using hdparm. Please add ide_hwif_t.no_io_32bit flag and teach
> >>> ide-disk.c:ide_disk_setup() about it (separate patch).
> >>
> >> I'm not sure I follow this, can you expand.
> >
> > Do "hdparm -c 2 /dev/hdx" first and then read/write to the device
> > and you should see it. :)
> >
> > We need to make "hdparm -c 2" (and "hdparm -c 3") unsupported
> > (see how "io_32bit" setting is handled in ide_add_generic_settings()
> > and how it can be read-only or read-write setting depending on the
> > value of drive->no_io_32bit).
> >
> > To do this we need to set drive->no_io_32bit to 1 (see how
> > ide_disk_setup() handles it). Unfortunately 32-bit I/O capability
> > is based on capabilities of both host and device so we have to
> > add new flag hwif->no_io_32bit to indicate that host doesn't
> > support 32-bit I/O.
>
> This all make sense, should I check for hwif->no_io_32bit in
> idedisk_setup() and set drive->no_io_32bit to 1 if hwif->no_io_32bit
> is 1 or do this the test in ide_add_generic_settings()?

Good question. idedisk_setup() seems more logical but in the current
model "io_32bit" setting is still accessible without ide-disk driver through
/proc/ide/ interface so...

Moreover the current drive->no_io_32bit code in ide-disk is wrong:
* it shouldn't be overriding drive->no_io_32bit flag if it is 1
* doing this in ide-disk may be too late w.r.t. ide_add_generic_settings()

Therefore your previous suggestion is the right one - the best place
to deal with ->no_io_32bit is ide-probe.c - doing this for all drives at
the end of probe_hwif() should fix all above issues.

Thanks,
Bartlomiej

2006-02-13 22:13:05

by Kumar Gala

[permalink] [raw]
Subject: Re: RFC: Compact Flash True IDE Mode Driver


On Feb 13, 2006, at 2:21 PM, Bartlomiej Zolnierkiewicz wrote:

> On 2/13/06, Kumar Gala <[email protected]> wrote:
>>
>> On Feb 13, 2006, at 10:53 AM, Bartlomiej Zolnierkiewicz wrote:
>>
>>> On 2/13/06, Kumar Gala <[email protected]> wrote:
>>>
>>>>>> +static void cfide_outsl(unsigned long port, void *addr, u32
>>>>>> count)
>>>>>> +{
>>>>>> + panic("outsl unsupported");
>>>>>> +}
>>>>>
>>>>> This will panic as soon as somebody tries to enable 32-bit I/O
>>>>> using hdparm. Please add ide_hwif_t.no_io_32bit flag and teach
>>>>> ide-disk.c:ide_disk_setup() about it (separate patch).
>>>>
>>>> I'm not sure I follow this, can you expand.
>>>
>>> Do "hdparm -c 2 /dev/hdx" first and then read/write to the device
>>> and you should see it. :)
>>>
>>> We need to make "hdparm -c 2" (and "hdparm -c 3") unsupported
>>> (see how "io_32bit" setting is handled in ide_add_generic_settings()
>>> and how it can be read-only or read-write setting depending on the
>>> value of drive->no_io_32bit).
>>>
>>> To do this we need to set drive->no_io_32bit to 1 (see how
>>> ide_disk_setup() handles it). Unfortunately 32-bit I/O capability
>>> is based on capabilities of both host and device so we have to
>>> add new flag hwif->no_io_32bit to indicate that host doesn't
>>> support 32-bit I/O.
>>
>> This all make sense, should I check for hwif->no_io_32bit in
>> idedisk_setup() and set drive->no_io_32bit to 1 if hwif->no_io_32bit
>> is 1 or do this the test in ide_add_generic_settings()?
>
> Good question. idedisk_setup() seems more logical but in the current
> model "io_32bit" setting is still accessible without ide-disk
> driver through
> /proc/ide/ interface so...
>
> Moreover the current drive->no_io_32bit code in ide-disk is wrong:
> * it shouldn't be overriding drive->no_io_32bit flag if it is 1
> * doing this in ide-disk may be too late w.r.t.
> ide_add_generic_settings()
>
> Therefore your previous suggestion is the right one - the best place
> to deal with ->no_io_32bit is ide-probe.c - doing this for all
> drives at
> the end of probe_hwif() should fix all above issues.

Now I'm confused. If I understand the code, what I want is for the
"io_32bit" setting to have its RW field set to SETTING_READ, such
that drive->no_io_32bit can NOT be changed. Additionally, I want it
set to 1 if hwif->no_io_32bit is 1.

Are you saying that at the end of probe_hwif() I should iterate over
the drives for that hwif and set drive->no_io_32bit to 1 if hwif-
>no_io_32bit is 1? If so, can I do this in the last loop that
already exists that iterates over the drives?

Will I not also want to test hwif->no_io_32bit in idedisk_setup() to
ensure that it can only set driver->no_io_32bit to 0 if hwif-
>no_io32bit is 0?

- kumar

Subject: Re: RFC: Compact Flash True IDE Mode Driver

On 2/13/06, Kumar Gala <[email protected]> wrote:
>
> On Feb 13, 2006, at 2:21 PM, Bartlomiej Zolnierkiewicz wrote:
>
> > On 2/13/06, Kumar Gala <[email protected]> wrote:
> >>
> >> On Feb 13, 2006, at 10:53 AM, Bartlomiej Zolnierkiewicz wrote:
> >>
> >>> On 2/13/06, Kumar Gala <[email protected]> wrote:
> >>>
> >>>>>> +static void cfide_outsl(unsigned long port, void *addr, u32
> >>>>>> count)
> >>>>>> +{
> >>>>>> + panic("outsl unsupported");
> >>>>>> +}
> >>>>>
> >>>>> This will panic as soon as somebody tries to enable 32-bit I/O
> >>>>> using hdparm. Please add ide_hwif_t.no_io_32bit flag and teach
> >>>>> ide-disk.c:ide_disk_setup() about it (separate patch).
> >>>>
> >>>> I'm not sure I follow this, can you expand.
> >>>
> >>> Do "hdparm -c 2 /dev/hdx" first and then read/write to the device
> >>> and you should see it. :)
> >>>
> >>> We need to make "hdparm -c 2" (and "hdparm -c 3") unsupported
> >>> (see how "io_32bit" setting is handled in ide_add_generic_settings()
> >>> and how it can be read-only or read-write setting depending on the
> >>> value of drive->no_io_32bit).
> >>>
> >>> To do this we need to set drive->no_io_32bit to 1 (see how
> >>> ide_disk_setup() handles it). Unfortunately 32-bit I/O capability
> >>> is based on capabilities of both host and device so we have to
> >>> add new flag hwif->no_io_32bit to indicate that host doesn't
> >>> support 32-bit I/O.
> >>
> >> This all make sense, should I check for hwif->no_io_32bit in
> >> idedisk_setup() and set drive->no_io_32bit to 1 if hwif->no_io_32bit
> >> is 1 or do this the test in ide_add_generic_settings()?
> >
> > Good question. idedisk_setup() seems more logical but in the current
> > model "io_32bit" setting is still accessible without ide-disk
> > driver through
> > /proc/ide/ interface so...
> >
> > Moreover the current drive->no_io_32bit code in ide-disk is wrong:
> > * it shouldn't be overriding drive->no_io_32bit flag if it is 1
> > * doing this in ide-disk may be too late w.r.t.
> > ide_add_generic_settings()
> >
> > Therefore your previous suggestion is the right one - the best place
> > to deal with ->no_io_32bit is ide-probe.c - doing this for all
> > drives at
> > the end of probe_hwif() should fix all above issues.
>
> Now I'm confused. If I understand the code, what I want is for the
> "io_32bit" setting to have its RW field set to SETTING_READ, such
> that drive->no_io_32bit can NOT be changed. Additionally, I want it
> set to 1 if hwif->no_io_32bit is 1.

Yes.

> Are you saying that at the end of probe_hwif() I should iterate over
> the drives for that hwif and set drive->no_io_32bit to 1 if hwif-
> >no_io_32bit is 1? If so, can I do this in the last loop that
> already exists that iterates over the drives?

Well, no - this loop is for tuning and is already over-complicated.

> Will I not also want to test hwif->no_io_32bit in idedisk_setup() to
> ensure that it can only set driver->no_io_32bit to 0 if hwif-
> >no_io32bit is 0?

No, you want to move this code to ide-probe.c because of the
reason given in my last mail: setting drive->no_io_32bit in ide-disk
is too late w.r.t. ide_add_generic_settings():

init_gendisk()->hwif_init()->ide_add_generic_settings()

so drive->no_io_32bit flag needs to be set earlier
(probe_hwif() is OK).

And yes, this IDE stuff is complicated... :)

Bartlomiej

2006-02-14 14:56:48

by Kumar Gala

[permalink] [raw]
Subject: Re: RFC: Compact Flash True IDE Mode Driver

>> Now I'm confused. If I understand the code, what I want is for the
>> "io_32bit" setting to have its RW field set to SETTING_READ, such
>> that drive->no_io_32bit can NOT be changed. Additionally, I want it
>> set to 1 if hwif->no_io_32bit is 1.
>
> Yes.
>
>> Are you saying that at the end of probe_hwif() I should iterate over
>> the drives for that hwif and set drive->no_io_32bit to 1 if hwif-
>>> no_io_32bit is 1? If so, can I do this in the last loop that
>> already exists that iterates over the drives?
>
> Well, no - this loop is for tuning and is already over-complicated.
>
>> Will I not also want to test hwif->no_io_32bit in idedisk_setup() to
>> ensure that it can only set driver->no_io_32bit to 0 if hwif-
>>> no_io32bit is 0?
>
> No, you want to move this code to ide-probe.c because of the
> reason given in my last mail: setting drive->no_io_32bit in ide-disk
> is too late w.r.t. ide_add_generic_settings():
>
> init_gendisk()->hwif_init()->ide_add_generic_settings()
>
> so drive->no_io_32bit flag needs to be set earlier
> (probe_hwif() is OK).

Will drive->id->dword_io be valid by the end of probe_hwif()?

> And yes, this IDE stuff is complicated... :)

That it is ;)

- kumar

Subject: Re: RFC: Compact Flash True IDE Mode Driver

On 2/14/06, Kumar Gala <[email protected]> wrote:
> >> Now I'm confused. If I understand the code, what I want is for the
> >> "io_32bit" setting to have its RW field set to SETTING_READ, such
> >> that drive->no_io_32bit can NOT be changed. Additionally, I want it
> >> set to 1 if hwif->no_io_32bit is 1.
> >
> > Yes.
> >
> >> Are you saying that at the end of probe_hwif() I should iterate over
> >> the drives for that hwif and set drive->no_io_32bit to 1 if hwif-
> >>> no_io_32bit is 1? If so, can I do this in the last loop that
> >> already exists that iterates over the drives?
> >
> > Well, no - this loop is for tuning and is already over-complicated.
> >
> >> Will I not also want to test hwif->no_io_32bit in idedisk_setup() to
> >> ensure that it can only set driver->no_io_32bit to 0 if hwif-
> >>> no_io32bit is 0?
> >
> > No, you want to move this code to ide-probe.c because of the
> > reason given in my last mail: setting drive->no_io_32bit in ide-disk
> > is too late w.r.t. ide_add_generic_settings():
> >
> > init_gendisk()->hwif_init()->ide_add_generic_settings()
> >
> > so drive->no_io_32bit flag needs to be set earlier
> > (probe_hwif() is OK).
>
> Will drive->id->dword_io be valid by the end of probe_hwif()?

Yes.

> > And yes, this IDE stuff is complicated... :)
>
> That it is ;)
>
> - kumar

2006-02-14 16:16:35

by Kumar Gala

[permalink] [raw]
Subject: Re: RFC: Compact Flash True IDE Mode Driver

If this looks good, I'll send a more official patch with an signed-off-by.

- k

diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 09086b8..359f659 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -977,8 +977,6 @@ static void idedisk_setup (ide_drive_t *
ide_dma_verbose(drive);
printk("\n");

- drive->no_io_32bit = id->dword_io ? 1 : 0;
-
/* write cache enabled? */
if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5)))
drive->wcache = 1;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 427d1c2..1b7b4c5 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -858,6 +858,15 @@ static void probe_hwif(ide_hwif_t *hwif)
}
}
}
+
+ for (unit = 0; unit < MAX_DRIVES; ++unit) {
+ ide_drive_t *drive = &hwif->drives[unit];
+
+ if (hwif->no_io_32bit)
+ drive->no_io_32bit = 1;
+ else
+ drive->no_io_32bit = drive->id->dword_io ? 1 : 0;
+ }
}

static int hwif_init(ide_hwif_t *hwif);
diff --git a/include/linux/ide.h b/include/linux/ide.h
index a7fc4cc..8d2db41 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -792,6 +792,7 @@ typedef struct hwif_s {
unsigned no_dsc : 1; /* 0 default, 1 dsc_overlap disabled */
unsigned auto_poll : 1; /* supports nop auto-poll */
unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
+ unsigned no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */

struct device gendev;
struct completion gendev_rel_comp; /* To deal with device release() */

Subject: Re: RFC: Compact Flash True IDE Mode Driver

On 2/14/06, Kumar Gala <[email protected]> wrote:
> If this looks good, I'll send a more official patch with an signed-off-by.

Looks good but please add some description and Signed-off-by.

Acked-by: Bartlomiej Zolnierkiewicz <[email protected]>

You can send final patch to akpm for inclusion into -mm.

> - k
>
> diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
> index 09086b8..359f659 100644
> --- a/drivers/ide/ide-disk.c
> +++ b/drivers/ide/ide-disk.c
> @@ -977,8 +977,6 @@ static void idedisk_setup (ide_drive_t *
> ide_dma_verbose(drive);
> printk("\n");
>
> - drive->no_io_32bit = id->dword_io ? 1 : 0;
> -
> /* write cache enabled? */
> if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5)))
> drive->wcache = 1;
> diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
> index 427d1c2..1b7b4c5 100644
> --- a/drivers/ide/ide-probe.c
> +++ b/drivers/ide/ide-probe.c
> @@ -858,6 +858,15 @@ static void probe_hwif(ide_hwif_t *hwif)
> }
> }
> }
> +
> + for (unit = 0; unit < MAX_DRIVES; ++unit) {
> + ide_drive_t *drive = &hwif->drives[unit];
> +
> + if (hwif->no_io_32bit)
> + drive->no_io_32bit = 1;
> + else
> + drive->no_io_32bit = drive->id->dword_io ? 1 : 0;
> + }
> }
>
> static int hwif_init(ide_hwif_t *hwif);
> diff --git a/include/linux/ide.h b/include/linux/ide.h
> index a7fc4cc..8d2db41 100644
> --- a/include/linux/ide.h
> +++ b/include/linux/ide.h
> @@ -792,6 +792,7 @@ typedef struct hwif_s {
> unsigned no_dsc : 1; /* 0 default, 1 dsc_overlap disabled */
> unsigned auto_poll : 1; /* supports nop auto-poll */
> unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
> + unsigned no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */
>
> struct device gendev;
> struct completion gendev_rel_comp; /* To deal with device release() */

2006-02-14 16:55:07

by Alan

[permalink] [raw]
Subject: Re: RFC: Compact Flash True IDE Mode Driver

On Llu, 2006-02-13 at 11:35 +0100, Bartlomiej Zolnierkiewicz wrote:
> > +static void cfide_outsl(unsigned long port, void *addr, u32 count)
> > +{
> > + panic("outsl unsupported");
> > +}
>
> This will panic as soon as somebody tries to enable 32-bit I/O
> using hdparm. Please add ide_hwif_t.no_io_32bit flag and teach
> ide-disk.c:ide_disk_setup() about it (separate patch).

Seems a lot of effort for little reward. Just make cfide_outsl generate
word sized I/O instead. Ditto insl. Or even leave the panic. Only
superusers can hack around with that value and they can equally crash
the box a thousand other ways.

Alan

2006-02-14 16:57:38

by Kumar Gala

[permalink] [raw]
Subject: Re: RFC: Compact Flash True IDE Mode Driver

On Tue, 14 Feb 2006, Alan Cox wrote:

> On Llu, 2006-02-13 at 11:35 +0100, Bartlomiej Zolnierkiewicz wrote:
> > > +static void cfide_outsl(unsigned long port, void *addr, u32 count)
> > > +{
> > > + panic("outsl unsupported");
> > > +}
> >
> > This will panic as soon as somebody tries to enable 32-bit I/O
> > using hdparm. Please add ide_hwif_t.no_io_32bit flag and teach
> > ide-disk.c:ide_disk_setup() about it (separate patch).
>
> Seems a lot of effort for little reward. Just make cfide_outsl generate
> word sized I/O instead. Ditto insl. Or even leave the panic. Only
> superusers can hack around with that value and they can equally crash
> the box a thousand other ways.

Well, there's a patch now and its pretty simple. Now we have one less way
superuser can kill things ;)

- k