IDE hackery: lock fixes and hotplug controller stuff
Apply this patch at your peril. Its a work in progress but my IDE exposure meter is beeping and the sick bucket needs emptying 8)
- Fix the drivers list locking by using a semaphore/spinlock combo
to give us the semantics we need to clean up the cases that drop it unsafely
- Assorted code commenting so I can figure out what it does
- Remove unsafe and essentially unfixable proc code for flipping
between ide-cd and ide-scsi. Its no longer relevant with SG_IO.
- Document the lock order
- ide_unregister is now ide_unregister_hwif and takes a hwif.
Cleaned up callers.
- Added hwif->remove callback so a driver can free resources
on unload
- Fixed holes in the proc/config locking
- Disallow users unregistering pci hotplug hwifs (FIXME: should
have a "user added" flag instead)
- Fixed hang in ide-disk when it saw invalid geometry (locking)
- Added "device has gone away" iops back
- Quietened the Probing IDE/Wait for ready messages
- Added check for drives that go M00000000000000000
- IT8212 driver. Still needs work for non pass through. Alas
I had to give the 8212D back so only have 8212H now (without the raid stuff)
- Added pci IDE helpers to do hot unplug
drivers/ide/ide.c +207 -106
@@ -320,13 +320,19 @@#endif } -/* -* ide_system_bus_speed() returns what we think is the system VESA/PCI -* bus speed (in MHz). This is used for calculating interface PIO timings. -* The default is 40 for known PCI systems, 50 otherwise. -* The "idebus=xx" parameter can be used to override this value. -* The actual value to be used is computed/displayed the first time through. +/** +* ide_system_bus_speed - guess bus speed +* +* ide_system_bus_speed() returns what we think is the system VESA/PCI +* bus speed (in MHz). This is used for calculating interface PIO timings. +* The default is 40 for known PCI systems, 50 otherwise. +* The "idebus=xx" parameter can be used to override this value. +* The actual value to be used is computed/displayed the first time +* through. Drivers should only use this as a last resort. +* +* Returns a guessed speed in Mhz */ +int ide_system_bus_speed (void ) {if (!system_bus_speed) {
@@ -347,10 +353,15 @@return system_bus_speed; } -/* -* current_capacity() returns the capacity (in sectors) of a drive -* according to its current geometry/LBA settings. +/** +* current_capacity - drive capacity +* @drive: drive to query +* +* Return the current capacity (in sectors) of a drive according to +* its current geometry/LBA settings. Empty removables are reported +* as size zero */ +sector_t current_capacity (ide_drive_t *drive) {if (!drive->present)
@@ -360,9 +371,17 @@EXPORT_SYMBOL (current_capacity); -/* -* Error reporting, in human readable form (luxurious, but a memory hog). +/** +* ide_dump_status - translate ATA error +* @drive: drive the error occured on +* @msg: information string +* @stat: status byte +* +* Error reporting, in human readable form (luxurious, but a memory hog). +* Combines the drive name, message and status byte to provide a +* user understandable explanation of the device error. */ +u8 ide_dump_status (ide_drive_t *drive,const char *msg,u8 stat) {ide_hwif_t *hwif =HWIF (drive);
@@ -371,7 +390,6 @@local_irq_set (flags);printk (KERN_WARNING "%s: %s: status=0x%02x" , drive->name, msg, stat); -#if FANCY_STATUS_DUMPS printk (" { " );if (stat &BUSY_STAT ) {printk ("Busy " );
@@ -385,12 +403,10 @@if (stat &ERR_STAT )printk ("Error " ); }printk ("}" ); -#endif /* FANCY_STATUS_DUMPS */ printk ("\n" );if ((stat & (BUSY_STAT |ERR_STAT )) ==ERR_STAT ) { err = hwif->INB (IDE_ERROR_REG );printk ("%s: %s: error=0x%02x" , drive->name, msg, err); -#if FANCY_STATUS_DUMPS if (drive->media == ide_disk) {printk (" { " );if (err &ABRT_ERR )printk ("DriveStatusError " );
@@ -434,7 +450,6 @@printk (", sector=%llu" , (unsigned long long )HWGROUP (drive)->rq->sector); } } -#endif /* FANCY_STATUS_DUMPS */ printk ("\n" ); }local_irq_restore (flags);
@@ -448,31 +463,46 @@return -ENXIO ; } +/* +* drives_lock protects the list of drives, drivers lock the +* list of drivers. Currently nobody takes both at once. +* drivers_sem guards the drivers_list for readers that may +* sleep. It must be taken before drivers_lock. Take drivers_sem +* before ide_setting_sem and idecfg_sem before either of the +* others. +*/ +static spinlock_t drives_lock =SPIN_LOCK_UNLOCKED ; +static DECLARE_MUTEX (drivers_sem);static spinlock_t drivers_lock =SPIN_LOCK_UNLOCKED ; +static LIST_HEAD (drivers); -/* Iterator */ +/* Iterator for the driver list. */ +static void *m_start (struct seq_file *m,loff_t *pos) {struct list_head *p;loff_t l = *pos; -spin_lock (&drivers_lock); +down (&drivers_sem);list_for_each (p, &drivers)if (!l--)return list_entry (p, ide_driver_t, drivers);return NULL ; } +static void *m_next (struct seq_file *m,void *v,loff_t *pos) {struct list_head *p = ((ide_driver_t *)v)->drivers.next; (*pos)++;return p==&drivers ?NULL :list_entry (p, ide_driver_t, drivers); } +static void m_stop (struct seq_file *m,void *v) { -spin_unlock (&drivers_lock); +up (&drivers_sem); } +static int show_driver (struct seq_file *m,void *v) {ide_driver_t *driver = v;
@@ -515,6 +545,7 @@* MMIO leaves it to the controller driver, * PIO will migrate this way over time. */ +int ide_hwif_request_regions (ide_hwif_t *hwif) {unsigned long addr;
@@ -564,6 +595,7 @@* importantly our caller should be doing this so we need to * restructure this as a helper function for drivers. */ +void ide_hwif_release_regions (ide_hwif_t *hwif) {u32 i =0 ;
@@ -581,7 +613,15 @@release_region (hwif->io_ports[i],1 ); } -/* restore hwif to a sane state */ +/** +* ide_hwif_restore - restore hwif to template +* @hwif: hwif to update +* @tmp_hwif: template +* +* Restore hwif to a default state by copying most settngs +* from the template. +*/ +static void ide_hwif_restore (ide_hwif_t *hwif,ide_hwif_t *tmp_hwif) { hwif->hwgroup = tmp_hwif->hwgroup;
@@ -678,15 +718,15 @@ }/** -* ide_unregister - free an ide interface -* @index: index of interface (will change soon to a pointer) +* ide_unregister_hwif - free an ide interface +* @hwif: interface to unregister * * Perform the final unregister of an IDE interface. At the moment * we don't refcount interfaces so this will also get split up. * * Locking: * The caller must not hold the IDE locks -* The drive present/vanishing is not yet properly locked +* The drive present/vanishing is not yet perfectly locked * Take care with the callbacks. These have been split to avoid * deadlocking the IDE layer. The shutdown callback is called * before we take the lock and free resources. It is up to the
@@ -699,26 +739,21 @@* This is raving bonkers. */ -void ide_unregister (unsigned int index) +void ide_unregister_hwif (ide_hwif_t *hwif) {ide_drive_t *drive; -ide_hwif_t *hwif, *g, *tmp_hwif; +ide_hwif_t *g;ide_hwgroup_t *hwgroup;int irq_count =0 , unit, i; +int index; +static ide_hwif_t tmp_hwif;/* Serialized by locking */ -BUG_ON (index >=MAX_HWIFS ); - - tmp_hwif =kmalloc (sizeof (*tmp_hwif),GFP_KERNEL |__GFP_NOFAIL); -if (!tmp_hwif) { -printk (KERN_ERR "%s: unable to allocate memory\n" , __FUNCTION__); -return ; - } - + index = hwif->index; +BUG_ON (in_interrupt ());BUG_ON (irqs_disabled ());down (&ide_cfg_sem);spin_lock_irq (&ide_lock); - hwif = &ide_hwifs[index];if (!hwif->present) goto abort;for (unit =0 ; unit <MAX_DRIVES ; ++unit) {
@@ -729,6 +764,7 @@ goto abort; drive->dead =1 ; } +/* Protect against new users (in part) */ hwif->present =0 ;spin_unlock_irq (&ide_lock);
@@ -757,6 +793,12 @@if (irq_count ==1 )free_irq (hwif->irq, hwgroup); +/* +* Let the driver free up private objects +*/ +if (hwif->remove) + hwif->remove (hwif); +spin_lock_irq (&ide_lock);/* * Note that we only release the standard ports,
@@ -845,8 +887,16 @@put_disk (disk); }unregister_blkdev (hwif->major, hwif->name); +spin_lock_irq (&ide_lock); +/* +* Let the driver free up private objects +*/ + +if (hwif->remove) + hwif->remove (hwif); +if (hwif->dma_base) { (void )ide_release_dma (hwif);
@@ -860,22 +910,20 @@ }/* copy original settings */ - *tmp_hwif = *hwif; + tmp_hwif = *hwif;/* restore hwif data to pristine status */ init_hwif_data (hwif, index);init_hwif_default (hwif, index); -ide_hwif_restore (hwif, tmp_hwif); +ide_hwif_restore (hwif, &tmp_hwif); abort:spin_unlock_irq (&ide_lock);up (&ide_cfg_sem); - -kfree (tmp_hwif); } -EXPORT_SYMBOL (ide_unregister); +EXPORT_SYMBOL (ide_unregister_hwif);/**
@@ -931,10 +979,17 @@*/ } -/* -* Register an IDE interface, specifying exactly the registers etc -* Set init=1 iff calling before probes have taken place. +/** +* ide_register_hw - register IDE interface +* @hw: hardware registers +* @hwifp: pointer to returned hwif +* +* Register an IDE interface, specifying exactly the registers etc +* Set init=1 iff calling before probes have taken place. +* +* Returns -1 on error. */ +int ide_register_hw (hw_regs_t *hw,ide_hwif_t **hwifp) {int index, retry =1 ;
@@ -955,12 +1010,15 @@ goto found; }for (index =0 ; index <MAX_HWIFS ; index++) -ide_unregister (index); + { + hwif = &ide_hwifs[index]; +ide_unregister_hwif (hwif); + } }while (retry--);return -1 ; found:if (hwif->present) -ide_unregister (index); +ide_unregister_hwif (hwif);else if (!hwif->hold) {init_hwif_data (hwif, index);init_hwif_default (hwif, index);
@@ -1008,21 +1066,21 @@* @set: setting * * Removes the setting named from the device if it is present. -* The function takes the settings_lock to protect against -* parallel changes. This function must not be called from IRQ -* context. Returns 0 on success or -1 on failure. +* This function must not be called from IRQ context. Returns 0 +* on success or -1 on failure. * * BUGS: This code is seriously over-engineered. There is also * magic about how the driver specific features are setup. If * a driver is attached we assume the driver settings are auto * remove. +* +* The caller must hold settings_lock */ int ide_add_setting (ide_drive_t *drive,const char *name,int rw,int read_ioctl,int write_ioctl,int data_type,int min,int max,int mul_factor,int div_factor,void *data,ide_procset_t *set) {ide_settings_t **p = (ide_settings_t **) &drive->settings, *setting =NULL ; -down (&ide_setting_sem);while ((*p) &&strcmp ((*p)->name, name) <0 ) p = &((*p)->next);if ((setting =kmalloc (sizeof (*setting),GFP_KERNEL )) ==NULL )
@@ -1046,10 +1104,8 @@if (drive->driver != &idedefault_driver) setting->auto_remove =1 ; *p = setting; -up (&ide_setting_sem);return 0 ; abort: -up (&ide_setting_sem);if (setting)kfree (setting);return -1 ;
@@ -1058,7 +1114,7 @@EXPORT_SYMBOL (ide_add_setting);/** -* __ide_remove_setting - remove an ide setting option +* ide_remove_setting - remove an ide setting option * @drive: drive to use * @name: setting name *
@@ -1066,7 +1122,7 @@* The caller must hold the setting semaphore. */ -static void __ide_remove_setting (ide_drive_t *drive,char *name) +static void ide_remove_setting (ide_drive_t *drive,char *name) {ide_settings_t **p, *setting;
@@ -1144,7 +1200,7 @@ setting = drive->settings;while (setting) {if (setting->auto_remove) { -__ide_remove_setting (drive, setting->name); +ide_remove_setting (drive, setting->name); goto repeat; } setting = setting->next;
@@ -1188,6 +1244,15 @@return val; } +/** +* ide_spin_wait_hwgroup - wait for group +* @drive: drive in the group +* +* Wait for an IDE device group to go non busy and then return +* holding the ide_lock which guards the hwgroup->busy status +* and right to use it. +*/ +int ide_spin_wait_hwgroup (ide_drive_t *drive) {ide_hwgroup_t *hwgroup =HWGROUP (drive);
@@ -1229,6 +1294,7 @@* to the driver to change settings, and then wait on a sema for completion. * The current scheme of polling is kludgy, though safe enough. */ +int ide_write_setting (ide_drive_t *drive,ide_settings_t *setting,int val) {int i;
@@ -1322,25 +1388,19 @@return err; } -int ide_atapi_to_scsi (ide_drive_t *drive,int arg) -{ -if (drive->media == ide_disk) { - drive->scsi =0 ; -return 0 ; - } - -if (DRIVER (drive)->cleanup (drive)) { - drive->scsi =0 ; -return 0 ; - } - - drive->scsi = (u8 ) arg; -ata_attach (drive); -return 0 ; -} +/** +* ide_add_generic_settings - generic /proc settings +* @drive: drive being configured +* +* Add the generic parts of the system settings to the /proc files +* for this IDE device. The caller must not be holding the settings_sem +* .lock +*/ +void ide_add_generic_settings (ide_drive_t *drive) { +down (&ide_setting_sem);/* * drive setting name read/write access read ioctl write ioctl data type min max mul_factor div_factor data pointer set function */
@@ -1353,10 +1413,17 @@ide_add_setting (drive,"init_speed" ,SETTING_RW ,-1 ,-1 ,TYPE_BYTE ,0 ,70 ,1 ,1 , &drive->init_speed,NULL );ide_add_setting (drive,"current_speed" ,SETTING_RW ,-1 ,-1 ,TYPE_BYTE ,0 ,70 ,1 ,1 , &drive->current_speed, set_xfer_rate);ide_add_setting (drive,"number" ,SETTING_RW ,-1 ,-1 ,TYPE_BYTE ,0 ,3 ,1 ,1 , &drive->dn,NULL ); -if (drive->media != ide_disk) -ide_add_setting (drive,"ide-scsi" ,SETTING_RW ,-1 ,HDIO_SET_IDE_SCSI ,TYPE_BYTE ,0 ,1 ,1 ,1 , &drive->scsi, ide_atapi_to_scsi); + +up (&ide_setting_sem); } +/** +* system_bus_clock - clock guess +* +* External version of the bus clock guess used by old old IDE drivers +* for things like VLB timings. Should not be used. +*/ +int system_bus_clock (void ) {return ((int ) ((!system_bus_speed) ?ide_system_bus_speed () : system_bus_speed ));
@@ -1364,52 +1431,42 @@EXPORT_SYMBOL (system_bus_clock); -/* -* Locking is badly broken here - since way back. That sucker is -* root-only, but that's not an excuse... The real question is what -* exclusion rules do we want here. +/** +* ata_attach - attach an ATA/ATAPI device +* @drive: drive to attach +* +* Takes a drive that is as yet not assigned to any midlayer IDE +* module and figures out which driver would like to own it. If +* nobody claims the driver then it is automatically attached +* to the default driver used for unclaimed objects. +* +* A return of zero indicates attachment to a driver, of one +* attachment to the default driver +* +* Takes the driver list lock and the ide_settings semaphore. */ -int ide_replace_subdriver (ide_drive_t *drive,const char *driver) -{ -if (!drive->present || drive->usage || drive->dead) - goto abort; -if (DRIVER (drive)->cleanup (drive)) - goto abort; -strlcpy (drive->driver_req, driver,sizeof (drive->driver_req)); -if (ata_attach (drive)) { -spin_lock (&drives_lock); -list_del_init (&drive->list); -spin_unlock (&drives_lock); - drive->driver_req[0 ] =0 ; -ata_attach (drive); - }else { - drive->driver_req[0 ] =0 ; - } -if (DRIVER (drive)!= &idedefault_driver && !strcmp (DRIVER (drive)->name, driver)) -return 0 ; -abort: -return 1 ; -} - +int ata_attach (ide_drive_t *drive) {struct list_head *p; -spin_lock (&drivers_lock); +down (&drivers_sem); +down (&ide_setting_sem);list_for_each (p, &drivers) {ide_driver_t *driver =list_entry (p, ide_driver_t, drivers);if (!try_module_get (driver->owner))continue ; -spin_unlock (&drivers_lock);if (driver->attach (drive) ==0 ) {module_put (driver->owner); drive->gendev.driver = &driver->gen_driver; +up (&ide_setting_sem); +up (&drivers_sem);return 0 ; } -spin_lock (&drivers_lock);module_put (driver->owner); } drive->gendev.driver = &idedefault_driver.gen_driver; -spin_unlock (&drivers_lock); +up (&ide_setting_sem); +up (&drivers_sem);if (idedefault_driver.attach (drive) !=0 )panic ("ide: default attach failed" );return 1 ;
@@ -1549,8 +1606,11 @@ }case HDIO_UNREGISTER_HWIF :if (!capable (CAP_SYS_RAWIO ))return -EACCES ; -/* (arg > MAX_HWIFS) checked in function */ -ide_unregister (arg); +if (arg >MAX_HWIFS || arg <0 ) +return -EINVAL ; +if (ide_hwifs[arg].pci_dev) +return -EINVAL ; +ide_unregister_hwif (&ide_hwifs[arg]);return 0 ;case HDIO_SET_NICE :if (!capable (CAP_SYS_ADMIN ))return -EACCES ;
@@ -2199,9 +2259,23 @@EXPORT_SYMBOL (ide_register_subdriver); +/** +* ide_unregister_subdriver - disconnect drive from driver +* @drive: drive to unplug +* +* Disconnect a drive from the driver it was attached to and then +* clean up the various proc files and other objects attached to it. +* Takes ide_sem, ide_lock, and drive_lock. Caller must hold none of +* the locks. +* +* No locking versus subdriver unload because we are moving to the +* default driver anyway. Wants double checking. +*/ +int ide_unregister_subdriver (ide_drive_t *drive) {unsigned long flags; +ide_proc_entry_t *dir;down (&ide_setting_sem);spin_lock_irqsave (&ide_lock, flags);
@@ -2210,13 +2284,14 @@up (&ide_setting_sem);return 1 ; } + dir =DRIVER (drive)->proc; + drive->driver = &idedefault_driver; +spin_unlock_irqrestore (&ide_lock, flags);#ifdef CONFIG_PROC_FS -ide_remove_proc_entries (drive->proc,DRIVER (drive)->proc); +ide_remove_proc_entries (drive->proc, dir);ide_remove_proc_entries (drive->proc, generic_subdriver_entries);#endif auto_remove_settings (drive); - drive->driver = &idedefault_driver; -spin_unlock_irqrestore (&ide_lock, flags);up (&ide_setting_sem);spin_lock (&drives_lock);list_del_init (&drive->list);
@@ -2234,6 +2309,18 @@return 0 ; } +/** +* ide_register_driver - new driver loaded +* @driver: the IDE driver module +* +* Register a new driver module and then scan the devices +* on the IDE bus in case any should be attached to the +* driver we have just attached. If so attach them +* +* Takes the drivers and drives lock. Should take the +* ide_sem but doesn't - FIXME +*/ +int ide_register_driver (ide_driver_t *driver) {struct list_head list;
@@ -2242,9 +2329,11 @@setup_driver_defaults (driver); +down (&drivers_sem);spin_lock (&drivers_lock);list_add (&driver->drivers, &drivers);spin_unlock (&drivers_lock); +up (&drivers_sem);INIT_LIST_HEAD (&list);spin_lock (&drives_lock);
@@ -2265,13 +2354,25 @@EXPORT_SYMBOL (ide_register_driver); +/** +* ide_unregister_driver - IDE module unload +* @driver: IDE driver module +* +* Unload a driver module and reattach any devices to whatever +* driver claims them next (typically the default driver). Takes +* the drivers lock, and called functions will take the +* IDE setting semaphore. +*/ +void ide_unregister_driver (ide_driver_t *driver) {ide_drive_t *drive; +down (&drivers_sem);spin_lock (&drivers_lock);list_del (&driver->drivers);spin_unlock (&drivers_lock); +up (&drivers_sem);driver_unregister (&driver->gen_driver);
@@ -2385,7 +2486,7 @@int index;for (index =0 ; index <MAX_HWIFS ; ++index) { -ide_unregister (index); +ide_unregister_hwif (&ide_hwifs[index]);if (ide_hwifs[index].dma_base) (void )ide_release_dma (&ide_hwifs[index]); }
drivers/ide/ide-disk.c +3 -5
@@ -1723,11 +1723,10 @@if ((!drive->head || drive->head >16 ) && !drive->select.b.lba) {printk (KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n" , drive->name, drive->head); -ide_cacheflush_p (drive); -ide_unregister_subdriver (drive); -DRIVER (drive)->busy--; - goto failed; + drive->attach =0 ; } +else + drive->attach =1 ;DRIVER (drive)->busy--; g->minors =1 <<PARTN_BITS ;strcpy (g->devfs_name, drive->devfs_name);
@@ -1735,7 +1734,6 @@ g->flags = drive->removable ?GENHD_FL_REMOVABLE :0 ;set_capacity (g,current_capacity (drive)); g->fops = &idedisk_ops; - drive->attach =1 ;add_disk (g);return 0 ; failed:
drivers/ide/ide-iops.c +68 -0
74 lines not on this page · raw message
drivers/ide/ide-probe.c +16 -6
@@ -635,12 +635,11 @@device_register (&hwif->gendev); } -#ifdef CONFIG_PPC static int wait_hwif_ready (ide_hwif_t *hwif) {int rc; -printk (KERN_INFO "Probing IDE interface %s...\n" , hwif->name); +printk (KERN_DEBUG "Probing IDE interface %s...\n" , hwif->name);/* Let HW settle down a bit from whatever init state we * come from */
@@ -671,7 +670,6 @@return rc; } -#endif /* * This routine only knows how to look for drive units 0 and 1
@@ -717,7 +715,6 @@local_irq_set (flags); -#ifdef CONFIG_PPC /* This is needed on some PPCs and a bunch of BIOS-less embedded * platforms. Typical cases are: *
@@ -738,8 +735,7 @@* BenH. */ if (wait_hwif_ready (hwif)) -printk (KERN_WARNING "%s: Wait for ready failed before probe !\n" , hwif->name); -#endif /* CONFIG_PPC */ +printk (KERN_DEBUG "%s: Wait for ready failed before probe !\n" , hwif->name);/* * Second drive should only exist if first drive was found,
@@ -749,6 +745,20 @@ide_drive_t *drive = &hwif->drives[unit]; drive->dn = (hwif->channel ?2 :0 ) + unit; (void )probe_for_drive (drive); +if (drive->present && hwif->present && unit ==1 ) + { +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" ) && +/* 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 ) && +strncmp (hwif->drives[0 ].id->serial_no, drive->id->serial_no,20 ) ==0 ) + { +printk (KERN_WARNING "ide-probe: ignoring undecoded slave\n" ); + drive->present =0 ; + } + }if (drive->present && !hwif->present) { hwif->present =1 ; if (hwif->chipset != ide_4drives ||
drivers/ide/ide-proc.c +1 -19
@@ -573,24 +573,6 @@PROC_IDE_READ_RETURN (page,start,off,count,eof,len); } -static int proc_ide_write_driver - (struct file *file,const char __user *buffer,unsigned long count,void *data) -{ -ide_drive_t *drive = (ide_drive_t *) data; -char name[32 ]; - -if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; -if (count >31 ) - count =31 ; -if (copy_from_user (name, buffer, count)) -return -EFAULT ; - name[count] ='\0' ; -if (ide_replace_subdriver (drive, name)) -return -EINVAL ; -return count; -} -static int proc_ide_read_media (char *page,char **start,off_t off,int count,int *eof,void *data) {
@@ -616,7 +598,7 @@ }static ide_proc_entry_t generic_drive_entries[] = { - {"driver" ,S_IFREG |S_IRUGO , proc_ide_read_driver, proc_ide_write_driver }, + {"driver" ,S_IFREG |S_IRUGO , proc_ide_read_driver,NULL }, {"identify" ,S_IFREG |S_IRUSR , proc_ide_read_identify,NULL }, {"media" ,S_IFREG |S_IRUGO , proc_ide_read_media,NULL }, {"model" ,S_IFREG |S_IRUGO , proc_ide_read_dmodel,NULL },
drivers/ide/Kconfig +6 -0
@@ -621,6 +621,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/legacy/ide-cs.c +12 -6
@@ -90,6 +90,7 @@int ndev;dev_node_t node;int hd; +ide_hwif_t *hwif; } ide_info_t;static void ide_release (dev_link_t *);
@@ -199,14 +200,14 @@ }/* ide_detach */ -static int idecs_register (unsigned long io,unsigned long ctl,unsigned long irq) +static int idecs_register (unsigned long io,unsigned long ctl,unsigned long irq,ide_hwif_t **hwif) {hw_regs_t hw;memset (&hw,0 ,sizeof (hw));ide_init_hwif_ports (&hw, io, ctl,NULL ); hw.irq = irq; hw.chipset = ide_pci; -return ide_register_hw (&hw,NULL ); +return ide_register_hw (&hw, hwif); }/*======================================================================
@@ -224,6 +225,7 @@ {client_handle_t handle = link->handle;ide_info_t *info = link->priv; +ide_hwif_t *hwif;tuple_t tuple;struct {u_short buf[128 ];
@@ -343,14 +345,17 @@if (is_kme)outb (0x81 , ctl_base+1 ); -/* retry registration in case device is still spinning up */ +/* retry registration in case device is still spinning up ++ FIXME: now handled by IDE layer... ?? */ +for (hd =-1 , i =0 ; i <10 ; i++) { - hd =idecs_register (io_base, ctl_base, link->irq.AssignedIRQ); + hd =idecs_register (io_base, ctl_base, link->irq.AssignedIRQ, &hwif);if (hd >=0 )break ;if (link->io.NumPorts1 ==0x20 ) {outb (0x02 , ctl_base +0x10 ); hd =idecs_register (io_base +0x10 , ctl_base +0x10 , - link->irq.AssignedIRQ); + link->irq.AssignedIRQ, &hwif);if (hd >=0 ) { io_base +=0x10 ; ctl_base +=0x10 ;
@@ -373,6 +378,7 @@ info->node.major = ide_major[hd]; info->node.minor =0 ; info->hd = hd; + info->hwif = hwif; link->dev = &info->node; printk(KERN_INFO "ide-cs: %s: Vcc = %d.%d, Vpp = %d.%d\n", info->node.dev_name, link->conf.Vcc / 10, link->conf.Vcc % 10,
@@ -411,7 +417,7 @@if (info->ndev) {/* FIXME: if this fails we need to queue the cleanup somehow -- need to investigate the required PCMCIA magic */ -ide_unregister (info->hd); +ide_unregister_hwif (info->hwif);/* deal with brain dead IDE resource management */ request_region (link->io.BasePort1, link->io.NumPorts1, info->node.dev_name);
drivers/ide/pci/it8212.c +758 -0
758 lines not on this page · raw message
drivers/ide/pci/Makefile +1 -0
@@ -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
drivers/ide/setup-pci.c +41 -1
60 lines not on this page · raw message
include/linux/ide.h +6 -6
@@ -909,10 +909,8 @@int (*quirkproc)(ide_drive_t *);/* driver soft-power interface */ int (*busproc)(ide_drive_t *,int ); -// /* host rate limiter */ -// u8 (*ratemask)(ide_drive_t *); -// /* device rate limiter */ -// u8 (*ratefilter)(ide_drive_t *, u8); +/* hwif remove hook, called on unload/pci remove paths*/ +void (*remove)(struct hwif_s *);#endif #if 0
@@ -1503,9 +1501,11 @@extern void ide_pci_unregister_driver (struct pci_driver *driver);extern void ide_pci_setup_ports (struct pci_dev *dev,struct ide_pci_device_s *d,int autodma,int pciirq,ata_index_t *index);extern void ide_setup_pci_noise (struct pci_dev *dev,struct ide_pci_device_s *d); +extern void ide_pci_remove_hwifs (struct pci_dev *dev);extern void default_hwif_iops (ide_hwif_t *);extern void default_hwif_mmiops (ide_hwif_t *); +extern void removed_hwif_iops (ide_hwif_t *);extern void default_hwif_transport (ide_hwif_t *);int ide_register_driver (ide_driver_t *driver);
@@ -1603,8 +1603,8 @@#endif extern int ide_hwif_request_regions (ide_hwif_t *hwif); -extern void ide_hwif_release_regions (ide_hwif_t * hwif); -extern void ide_unregister (unsigned int index); +extern void ide_hwif_release_regions (ide_hwif_t *hwif); +extern void ide_unregister_hwif (ide_hwif_t *hwif);extern int probe_hwif_init (ide_hwif_t *);
include/linux/pci_ids.h +1 -0
@@ -1638,6 +1638,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
Hi,
Quoted 2 lines · Alan Cox
Apply this patch at your peril. Its a work in progress but my IDE exposure meter is beeping and the sick bucket needs emptying 8)
Could you please split it off on separate patches?
- it is easier for everybody to review and comment them
- some changes just can't defend themselves when are not the part of the bigger patch
Quoted 2 lines
(quoted diff) +0
-1- Remove unsafe and essentially unfixable proc code for flippingbetween ide-cd and ide-scsi. Its no longer relevant with
SG_IO.
Shouldn't we deprecate it first...?
Review
Quoted 1 line
(quoted diff) +0
-1- Added pci IDE helpers to do hot unplug
Locking for ide_hwifs[] should be added first...
[ I'm still on vacations but I'm watching what's going on... ] Bartlomiej
Quoted 5 lines · Bartlomiej Zolnierkiewicz
Quoted 2 lines · Alan Cox
Apply this patch at your peril. Its a work in progress but my IDE exposure meter is beeping and the sick bucket needs emptying 8)
Could you please split it off on separate patches?
Its almost entirely interdependant (8212 aside). I will split it up a bit more once its ready for submission but that may take a while. In part I don't know what the final patch sets will need to be, because I'm still mapping some of the locking or lack thereof.
Quoted 4 lines
Quoted 2 lines
(quoted diff) +0
-1- Remove unsafe and essentially unfixable proc code for flippingbetween ide-cd and ide-scsi. Its no longer relevant with
SG_IO.Shouldn't we deprecate it first...?
It doesn't work now so it clearly isnt being used 8). We hold the lock because its a proc function and we then replace the proc functions in the attach method -> deadlock. It is also incredibly hard to fix without a major rewrite.
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +0
-1- Added pci IDE helpers to do hot unplugLocking for ide_hwifs[] should be added first...
I'm not sure its needed because the cfg sem covers it. I'm still trying to prove that at the moment and it may as you say need a new lock. The pci IDE helpers for hot unplug just use the same services as the pcmcia one so aren't that hard. Neither work at the moment but pcmcia ide_cs hasn't worked for me in 2.6 yet. I still don't know why and clearly I need to before I can submit stuff ..
I've not tackled the drive level hotswap forward port yet either, that is a lot less pressing than hangs on module loads and the pcmcia problem.
Alan
Quoted 3 lines · Alan Cox
- IT8212 driver. Still needs work for non pass through. Alas I had to give the 8212D back so only have 8212H now (without the raid stuff)
What do those numbers refer to? Card model numbers? On ITE's site I can only see an IT8212F which has RAID and an IT8211F that doesn't.
I got my IT8212F card from Novatech. A generic card with no obviously recognisable name and, IMO anyway, quite a reasonable price. That is assuming it really does everything that they say it can.
http://www.novatech.co.uk/novatech/specpage.html?NOV-ATA133
It certainly works quite well in pass through mode. *8)
Signature · 1 line
Ian.
Quoted 2 lines · Ian Hastie
What do those numbers refer to? Card model numbers? On ITE's site I can only see an IT8212F which has RAID and an IT8211F that doesn't.
Product rather than chip numbers I think
Quoted 3 lines
I got my IT8212F card from Novatech. A generic card with no obviously recognisable name and, IMO anyway, quite a reasonable price. That is assuming it really does everything that they say it can.
Thanks will investigate. I need to see what happens if I turn the firmware bits on with my card and then reboot the microprocessor - see if its just bios crippled
Quoted 1 line
It certainly works quite well in pass through mode. *8)
But it has the raid mode stuff ?
Quoted 10 lines · Alan Cox
Quoted 2 lines · Ian Hastie
What do those numbers refer to? Card model numbers? On ITE's site I can only see an IT8212F which has RAID and an IT8211F that doesn't.
Product rather than chip numbers I think
Quoted 3 lines
I got my IT8212F card from Novatech. A generic card with no obviously recognisable name and, IMO anyway, quite a reasonable price. That is assuming it really does everything that they say it can.
Quoted 7 lines
Thanks will investigate. I need to see what happens if I turn the firmware bits on with my card and then reboot the microprocessor - see if its just bios crippled
Quoted 1 line
It certainly works quite well in pass through mode. *8)
But it has the raid mode stuff ?
Yes it does. It's certainly sold as a RAID card and it does have a RAID setup menu. I haven't had the opportunity to use it fully as the discs I needed to use on it were already set up for software RAID. Maybe I'll have a couple spare(!) discs to play with if I upgrade to SATA.
It seems that the operation depends on the firmware, or should that be BIOS, you load onto the card. There's this from the IT8212 FAQ,
http://www.ite.com.tw/faq/it8212.html
1. Could I use IT8212 for CD-ROM?
Ans: IT8212 supports either RAID controller (which supports hard drives only) or pure IDE controller (which supports hard drives and CDROM) with different BIOS code. Please update your BIOS ROM with ATAPI BIOS.
There are certainly two files available
http://www.ite.com.tw/pc/bios_8212Raid-093015-02.zip
and
http://www.ite.com.tw/pc/bios_8212ATAPI-093015-02.zip
Signature · 1 line
Ian.
working sata raid - which controller?
In reply to Ian HastieHi Guys,
We are purchasing a new test server and I need to know which controllers are sata raid based and are hardware raid and not software raid. We currently use promise fast trak tx4's and have found in linux there is no mirroring support and it does not actively mirror data between the two disks.
00:09.0 RAID bus controller: Promise Technology, Inc.: Unknown device 3319 (rev 02)
Subsystem: Promise Technology, Inc.: Unknown device 3319
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr-
Stepping- SERR- FastB2B-
Status: Cap+ 66Mhz+ UDF- FastB2B- ParErr- DEVSEL=medium >TAbort-
<TAbort- <MAbort- >SERR- <PERR-
There is a function in win32 land you can run to "synch" the drives but we can't find an equivalent in linux and would prefer hardware. Cost is not a problem.
Thanks
Re: working sata raid - which controller?
I really need to do a FAQ page on this...
Quoted 2 lines · Paul
We are purchasing a new test server and I need to know which controllers are sata raid based and are hardware raid and not software raid. We currently
3ware and a few Adaptecs are the main SATA hardware RAID.
Quoted 2 lines
use promise fast trak tx4's and have found in linux there is no mirroring support and it does not actively mirror data between the two disks.
Sure it does. md mirrors quite nicely.
Jeff
Quoted 11 lines · Alan Cox
Quoted 5 lines · Bartlomiej Zolnierkiewicz
Quoted 2 lines · Alan Cox
(quoted diff) +0
-1- Remove unsafe and essentially unfixable proc code for flippingbetween ide-cd and ide-scsi. Its no longer relevant with
SG_IO.Shouldn't we deprecate it first...?
It doesn't work now so it clearly isnt being used 8). We hold the lock because its a proc function and we then replace the proc functions in the attach method -> deadlock. It is also incredibly hard to fix without a major rewrite.
It is a correct analysis for /proc/ide/hdx/settings:ide-scsi but not for /proc/ide/hdx/driver which works just fine (modulo being racy) and your patch removes both interfaces...
Bartlomiej
Quoted 3 lines · Bartlomiej Zolnierkiewicz
It is a correct analysis for /proc/ide/hdx/settings:ide-scsi but not for
/proc/ide/hdx/driverwhich works just fine (modulo being racy) and your patch removes both interfaces...
I see no viable way to fix it, and I see nobody using it so it should die. If someone does want to keep it then they can rewrite the ide layer to make it work.
BTW I've been over the proc stuff and fixed that up including all the locking. I can now happily insmod it8212, rmmod it8212, insmod it8212 etc and the /proc files behave. I did have to make a couple of tweaks to cover the locking cases not covered.
I also have the it8212 working in smart but non raid now. Seems issuing an LBA 48 cache flush (0xEF) crashes the firmware which is why it died on load for some users. To do that I've added hwif->raw_taskfile() so that an interface can filter commands.
Next stop disk hot plugging.
Alan
Quoted 8 lines · Alan Cox
Quoted 3 lines · Bartlomiej Zolnierkiewicz
It is a correct analysis for /proc/ide/hdx/settings:ide-scsi but not for
/proc/ide/hdx/driverwhich works just fine (modulo being racy) and your patch removes both interfaces...I see no viable way to fix it, and I see nobody using it so it should die. If someone does want to keep it then they can rewrite the ide layer to make it work.
"driver" interface _works_ (tested earlier today with 2.6.8-rc3-bk3) and how do you know that there are no users of it, from the magic ball?
Also aren't you the one who has made "ide-scsi" interface non-functional by introducing ide_setting_sem, he? 8)
http://lkml.org/lkml/2003/2/18/146
I fully agree that both interfaces should be removed nowadays but this should be done with some (minimal) care...
Quoted 4 lines
I also have the it8212 working in smart but non raid now. Seems issuing an LBA 48 cache flush (
0xEF) crashes the firmware which is why it died on load for some users. To do that I've addedhwif->raw_taskfile()so that an interface can filter commands.
Ouch, they should really fix this in the firmware.
Bartlomiej
Quoted 4 lines · Bartlomiej Zolnierkiewicz
Also aren't you the one who has made "ide-scsi" interface non-functional by introducing
ide_setting_sem, he? 8)
Yeah I also removed ide-scsi interface from the -ac patches in 2.4 8)
Quoted 6 lines
Quoted 4 lines
I also have the it8212 working in smart but non raid now. Seems issuing an LBA 48 cache flush (
0xEF) crashes the firmware which is why it died on load for some users. To do that I've addedhwif->raw_taskfile()so that an interface can filter commands.Ouch, they should really fix this in the firmware.
Agreed. I need to verify its not our fault yet. Either way it'll need to stay there because most people have older firmware. One thing I need to look at is how to find firmware versions as it seems 1.2 doesnt do LBA48
Alan
Quoted 4 lines · Ian Hastie
Yes it does. It's certainly sold as a RAID card and it does have a RAID setup menu. I haven't had the opportunity to use it fully as the discs I needed to use on it were already set up for software RAID. Maybe I'll have a couple spare(!) discs to play with if I upgrade to SATA.
Much obliged - I got one from Novatech and I've been doing a bit more hammering on it. For non raid configurations but in smart mode my card now seems to be working. Its in part dependant on a core IDE change however so I'll push the relevant bits to Bart in order.
I've not tried raid yet (case logistics) but will do so very soon.