Skip to contentSkip to conversation

PATCH: (Test) it8212 driver for 2.6.9rc3

PATCH Alan Cox 2 participants 7 messages Sep 30, 2004

Subsystems (2)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

This is a somewhat adjusted IT8212 driver that can work with the base 2.6.9rc3 IDE code (plus the tiny ide-probe patch). It uses a mix of tricks to avoid needing the core IDE support fixed (and in some cases to work around ide bugs/limits).

Its still being tested so its for comment/testing not general use with a view to having a nice working driver for 2.6.9 without the core IDE fixups

drivers/ide/ide-probe.c +1 -0
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.9rc3/drivers/ide/ide-probe.c linux-2.6.9rc3/drivers/ide/ide-probe.c
@@ -749,6 +749,7 @@
 			if (strcmp(hwif->drives[0].id->model, drive->id->model) == 0 &&
 			    /* Don't do this for noprobe or non ATA */
 			    strcmp(drive->id->model, "UNKNOWN") &&
+			    !strstr(drive->id->model, "Integrated Technology Express") &&
 			    /* And beware of confused Maxtor drives that go "M0000000000"
 			      "The SN# is garbage in the ID block..." [Eric] */
 			    strncmp(drive->id->serial_no, "M0000000000000000000", 20) &&
drivers/ide/Kconfig +6 -0
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.9rc3/drivers/ide/Kconfig linux-2.6.9rc3/drivers/ide/Kconfig
@@ -616,6 +616,12 @@
 	  <http://www.ite.com.tw/ia/brief_it8172bsp.htm>; picture of the
 	  board at <http://www.mvista.com/partners/semiconductor/ite.html>.
 
+config BLK_DEV_IT8212
+	tristate "IT8212 IDE support"
+	help
+	  This driver adds support for the ITE 8212 IDE RAID controller in
+	  both RAID and pass-through mode. 
+
 config BLK_DEV_NS87415
 	tristate "NS87415 chipset support"
 	help
drivers/ide/pci/it8212.c +858 -0

858 lines not on this page · raw message

drivers/ide/pci/Makefile +1 -0
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.9rc3/drivers/ide/pci/Makefile linux-2.6.9rc3/drivers/ide/pci/Makefile
@@ -13,6 +13,7 @@
 obj-$(CONFIG_BLK_DEV_HPT366)		+= hpt366.o
 #obj-$(CONFIG_BLK_DEV_HPT37X)		+= hpt37x.o
 obj-$(CONFIG_BLK_DEV_IT8172)		+= it8172.o
+obj-$(CONFIG_BLK_DEV_IT8212)		+= it8212.o
 obj-$(CONFIG_BLK_DEV_NS87415)		+= ns87415.o
 obj-$(CONFIG_BLK_DEV_OPTI621)		+= opti621.o
 obj-$(CONFIG_BLK_DEV_PDC202XX_OLD)	+= pdc202xx_old.o
include/linux/pci_ids.h +1 -0
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.9rc3/include/linux/pci_ids.h linux-2.6.9rc3/include/linux/pci_ids.h
@@ -1648,6 +1648,7 @@
 #define PCI_VENDOR_ID_ITE		0x1283
 #define PCI_DEVICE_ID_ITE_IT8172G	0x8172
 #define PCI_DEVICE_ID_ITE_IT8172G_AUDIO 0x0801
+#define PCI_DEVICE_ID_ITE_8212		0x8212
 #define PCI_DEVICE_ID_ITE_8872		0x8872
 #define PCI_DEVICE_ID_ITE_IT8330G_0	0xe886
 
#1 lore raw
Quoted 7 lines · Alan Cox

This is a somewhat adjusted IT8212 driver that can work with the base 2.6.9rc3 IDE code (plus the tiny ide-probe patch). It uses a mix of tricks to avoid needing the core IDE support fixed (and in some cases to work around ide bugs/limits).

Its still being tested so its for comment/testing not general use with a view to having a nice working driver for 2.6.9 without the core IDE fixups

Why you are doing this instead of including needed core changes in the patch and describing them in the patch description is beyond my mind.

Quoted 4 lines
+ *  ** NOTE ** - this is the "special edition" driver for the older IDE
+ *  code. It contains some uglies and has some minor limitations not found
+ *  in the 'new ide' version. As the cleanups enter mainstream IDE so the
+ *  hacks internal to this driver will vanish.

The buzzed changes you avoid to include so hard are:
- add hook for hwif->ident_quirks (4 lines of code)
- add hook for hwif->raw_taskfile (8 lines of code)
- make ide-disk allow no geometry (3 lines of code)
- allow rmmod of it8212 module
(much more LOC but no trick for it present)

First three changes are currently needed only for this driver and I suggested merging them with it8212 patch last time.

Controller hotswap fixes are being discussed on lkml.

Quoted 30 lines
drivers/ide/pci/it8212.c +30 -0
+/**
+ *	it8212_fake_geometry	-	geometry armwave for raid
+ *	@drive: drive to fake it for
+ *
+ *	IDE permits a drive to report that it has no geometry. Our
+ *	ide disk layer can't handle this and "functions non-optimally"
+ *	We fake up a geometry here until the ide-disk code patches to
+ *	handle this properly are merged, at which point to goes away
+ *
+ *	This will always be called for LBA48 assumptions as raid volumes
+ *	are always LBA48 capable.
+ */
+ 
+static void it8212_fake_geometry(ide_drive_t *drive)
+{
+	struct hd_driveid *id = drive->id;
+	unsigned long long capacity = id->lba_capacity_2;
+	unsigned int cap0 = capacity;	/* Trimmed to 32bit */
+	unsigned int cyl;
+	
+	drive->bios_sect = 63;
+	drive->bios_head = 255;
+	
+	if(cap0 != capacity)
+		drive->bios_cyl = 65536;
+	else
+	{
+		cyl = cap0 / (63 * 255);
+		if(cyl > 65535)
+			cyl = 65535;

drivers/ide/pci/it8212.c line 634

Quoted 10 lines
drivers/ide/pci/it8212.c +10 -0
+		drive->bios_cyl = cyl;
+	}
+	/* We now have a "geometry" to feed back to the ide-disk code */
+	id->cyls = drive->bios_cyl;
+	id->heads = drive->bios_head;
+	id->sectors = drive->bios_sect;
+	id->cur_cyls = id->cyls;
+	id->cur_heads = id->heads;
+	id->cur_sectors = id->sectors;
+}

trick to avoid 3 LOC change to ide-disk.c

drivers/ide/pci/it8212.c line 665

Quoted 10 lines
drivers/ide/pci/it8212.c +10 -0
+	for(i = 0; i < 1; i++) {
+		ide_drive_t *drive = &hwif->drives[i];
+		struct hd_driveid *id;
+		u16 *idbits;
+		
+		if(!drive->present)
+			continue;
+		id = drive->id;
+		idbits = (u16 *)drive->id;
+		

trick to avoid 4 LOC change to IDE core (hwif->ident_quirk hook)

Quoted 7 lines
drivers/ide/pci/it8212.c +7 -0
+			/* Non RAID volume. Fixups to stop the core code
+			   crashing the driver. Go away when ->taskfile hook
+			   is present */
+			id->field_valid &= 1;
+			id->queue_depth = 0;
+			id->command_set_1 = 0;
+			id->command_set_2 &= 0xC400;

drivers/ide/pci/it8212.c line 699

Quoted 10 lines
drivers/ide/pci/it8212.c +10 -0
+			id->cfsse &= 0xC000;
+			id->cfs_enable_1 = 0;
+			id->cfs_enable_2 &= 0xC400;
+			id->csf_default &= 0xC000;
+			id->word127 = 0;
+			id->dlf = 0;
+			id->csfo = 0;
+			id->cfa_power = 0;
+			printk(KERN_INFO "%s: Performing identify fixups.\n", 
+				drive->name);

trick to avoid 8 LOC change to IDE core (hwif->raw_taskfile hook)

And you say that you want real fixes to be included in the IDE core, so they should be tested and reviewed, not the tricky workarounds!

*sigh*

#2 lore raw

[ I was so shocked that I forgot about it ]

Please

- merge+describe needed IDE core changes
- fix coding style and whitespace damage
- kill useless DECLARE_ITE_DEV macro
- add __init to it8212_ide_init()

and I will _happily_ merge this driver into ide-dev-2.6.

Thanks,
Bartlomiej

author
#3 lore raw
Quoted 1 line · Bartlomiej Zolnierkiewicz

- merge+describe needed IDE core changes

Happily. I'm of the opinion the "ident whacking" callback isnt justified, only one driver has a need for it and that driver can do it in the iops hook.

Quoted 1 line

- fix coding style and whitespace damage

Yeah

Quoted 1 line

- kill useless DECLARE_ITE_DEV macro

I'd prefer to keep it (there are likely to be some related devices from the databook)

Quoted 1 line

- add __init to it8212_ide_init()

Good point - will fix

#4 lore raw
Quoted 5 lines · Alan Cox
Quoted 1 line · Bartlomiej Zolnierkiewicz

- merge+describe needed IDE core changes

Happily. I'm of the opinion the "ident whacking" callback isnt justified, only one driver has a need for it and that driver can do it in the iops hook.

ok, you are right

Quoted 8 lines
Quoted 1 line

- fix coding style and whitespace damage

Yeah

Quoted 1 line

- kill useless DECLARE_ITE_DEV macro

I'd prefer to keep it (there are likely to be some related devices from the databook)

you can add it when needed

Quoted 3 lines
Quoted 1 line

- add __init to it8212_ide_init()

Good point - will fix

thanks

author
#5 lore raw
Quoted 4 lines · Bartlomiej Zolnierkiewicz
Quoted 2 lines

I'd prefer to keep it (there are likely to be some related devices from the databook)

you can add it when needed

I think its needed. I'll keep it 8)

Ok first patch then. This adds raw_taskfile as a hook allowing a driver to filter, mangle (or indeed just throw debug) on taskfile commands being issued. (Note - ide_diag_taskfile has always been exported just never used by a driver and missing in the headers..)

drivers/ide/ide-taskfile.c +5 -1
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.9rc3/drivers/ide/ide-taskfile.c linux-2.6.9rc3/drivers/ide/ide-taskfile.c
@@ -555,7 +555,11 @@
 
 int ide_raw_taskfile (ide_drive_t *drive, ide_task_t *args, u8 *buf)
 {
-	return ide_diag_taskfile(drive, args, 0, buf);
+	ide_hwif_t *hwif = HWIF(drive);
+	if(hwif->raw_taskfile)
+		return hwif->raw_taskfile(drive, args, buf);
+	else
+		return ide_diag_taskfile(drive, args, 0, buf);
 }
 
 EXPORT_SYMBOL(ide_raw_taskfile);
include/linux/ide.h +4 -0
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.9rc3/include/linux/ide.h linux-2.6.9rc3/include/linux/ide.h
@@ -822,6 +822,7 @@
 #define IDE_CHIPSET_IS_PCI(c)	((IDE_CHIPSET_PCI_MASK >> (c)) & 1)
 
 struct ide_pci_device_s;
+struct ide_task_s;
 
 typedef struct hwif_s {
 	struct hwif_s *next;		/* for linked-list in ide_hwgroup_t */
@@ -886,6 +887,8 @@
 //	u8	(*ratemask)(ide_drive_t *);
 //	/* device rate limiter */
 //	u8	(*ratefilter)(ide_drive_t *, u8);
+	/* allow command filter/control */
+	int	(*raw_taskfile)(ide_drive_t *, struct ide_task_s *, u8 *);
 #endif
 
 	void (*ata_input_data)(ide_drive_t *, void *, u32);
@@ -1426,6 +1429,7 @@
 extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);
 extern ide_startstop_t task_out_intr(ide_drive_t *);
 
+extern int ide_diag_taskfile(ide_drive_t *, ide_task_t *, unsigned long, u8 *);
 extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *);
 
 int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
author
#6 lore raw
In reply to Bartlomiej Zolnierkiewicz
Quoted 2 lines · Bartlomiej Zolnierkiewicz

Why you are doing this instead of including needed core changes in the patch and describing them in the patch description is beyond my mind.

Because I'm dealing with real users who want it to work with real product and because I work for a vendor 8). Also because I need this to work on 2.4.x eventually. I'm assuming the small IDE changes won't make 2.6.9 since Linus is now close to a 2.6.9 proper. I've sent the IDE changes before, you didn't pass them on to Linus so I'm now taking the neccessary alternative steps in the short term.

Quoted 1 line

- add hook for hwif->ident_quirks (4 lines of code)

Do we need it given the existing iop hooks ?

Quoted 1 line

- add hook for hwif->raw_taskfile (8 lines of code)

Thats definitely the right approach although

Quoted 1 line

- make ide-disk allow no geometry (3 lines of code)

Actually its a few more - the size check needs fixing

But this is really irrelevant, they aren't there today, they are not there in 2.4.x, Linus isnt likely to take them in time for 2.6.9.

Quoted 2 lines

- allow rmmod of it8212 module
(much more LOC but no trick for it present)

The rmmod is no big deal, its brilliant for debug but I know of no hotswappable it8212 setup.

Quoted 2 lines

And you say that you want real fixes to be included in the IDE core, so they should be tested and reviewed, not the tricky workarounds!

Well I've submitted various IDE changes, when they appear great, until then the rest of the universe would like to use their IDE controller and its becoming present as the secondary controller on some mainboards. This patch (plus any testing bugs I find) solves the end user problem neatly.

Alan