ide: fix HDIO_DRIVE_TASK[FILE] ioctls for CHS commands on LBA devices
PATCH 1/9 ide: fix HDIO_DRIVE_TASK[FILE] ioctls for CHS commands on LBA devices
Add IDE_DFLAG_LBA device flag and use it instead of ->select.b.lba.
Since ->tf_load uses ->select.all for ATA Device/Head register this fixes HDIO_DRIVE_TASK[FILE] ioctls for CHS commands on LBA devices.
---
moar patches (on top of pata tree + previous 9)
drivers/ide/ide-disk.c | 33 ++++++++++++++++++++------------- drivers/ide/ide-io.c | 4 ++-- include/linux/ide.h | 1 + 3 files changed, 23 insertions(+), 15 deletions(-)
drivers/ide/ide-disk.c +20 -13
@@ -156,7 +156,7 @@ static ide_startstop_t __ide_do_rw_disk(memset (&task,0 ,sizeof (task)); task.tf_flags =IDE_TFLAG_TF |IDE_TFLAG_DEVICE ; -if (drive->select.b.lba) { +if (drive->dev_flags &IDE_DFLAG_LBA ) {if (lba48) {pr_debug ("%s: LBA=0x%012llx\n" , drive->name, (unsigned long long )block);
@@ -181,6 +181,8 @@ static ide_startstop_t __ide_do_rw_disk( tf->lbah = block >>=8 ; tf->device = (block >>8 ) &0xf ; } + + tf->device |=ATA_LBA ; }else {unsigned int sect, head, cyl, track;
@@ -378,28 +380,32 @@ static void idedisk_check_hpa(ide_drive_static void init_idedisk_capacity (ide_drive_t *drive) {u16 *id = drive->id; -/* -* If this drive supports the Host Protected Area feature set, -* then we may need to change our opinion about the drive's capacity. -*/ -int hpa =ata_id_hpa_enabled (id); +int lba;if (ata_id_lba48_enabled (id)) {/* drive speaks 48-bit LBA */ - drive->select.b.lba =1 ; + lba =1 ; drive->capacity64 =ata_id_u64 (id,ATA_ID_LBA_CAPACITY_2 ); -if (hpa) -idedisk_check_hpa (drive); }else if (ata_id_has_lba (id) &&ata_id_is_lba_capacity_ok (id)) {/* drive speaks 28-bit LBA */ - drive->select.b.lba =1 ; + lba =1 ; drive->capacity64 =ata_id_u32 (id,ATA_ID_LBA_CAPACITY ); -if (hpa) -idedisk_check_hpa (drive); }else {/* drive speaks boring old 28-bit CHS */ + lba =0 ; drive->capacity64 = drive->cyl * drive->head * drive->sect; } + +if (lba) { + drive->dev_flags |=IDE_DFLAG_LBA ; + +/* +* If this device supports the Host Protected Area feature set, +* then we may need to change our opinion about its capacity. +*/ +if (ata_id_hpa_enabled (id)) +idedisk_check_hpa (drive); + } }static sector_t idedisk_capacity (ide_drive_t *drive)
@@ -1105,7 +1111,8 @@ static int ide_disk_probe(ide_drive_t *d drive->driver_data = idkp;idedisk_setup (drive); -if ((!drive->head || drive->head >16 ) && !drive->select.b.lba) { +if ((drive->dev_flags &IDE_DFLAG_LBA ) ==0 && + (drive->head ==0 || drive->head >16 )) {printk (KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n" , drive->name, drive->head); drive->dev_flags &= ~IDE_DFLAG_ATTACH ;
drivers/ide/ide-io.c +2 -2
@@ -383,7 +383,7 @@ static ide_startstop_t ide_ata_error(ide }else if (stat &ATA_ERR ) {/* err has different meaning on cdrom and tape */ if (err ==ATA_ABORTED ) { -if (drive->select.b.lba && +if ((drive->dev_flags &IDE_DFLAG_LBA ) &&/* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */ hwif->tp_ops->read_status (hwif) ==ATA_CMD_INIT_DEV_PARAMS )return ide_stopped;
@@ -513,7 +513,7 @@ static void ide_tf_set_specify_cmd(ide_d tf->lbal = drive->sect; tf->lbam = drive->cyl; tf->lbah = drive->cyl >>8 ; - tf->device = ((drive->head -1 ) | drive->select.all) & ~ATA_LBA ; + tf->device = (drive->head -1 ) | drive->select.all; tf->command =ATA_CMD_INIT_DEV_PARAMS ; }
include/linux/ide.h +1 -0
@@ -500,6 +500,7 @@ enum {IDE_DFLAG_NOWERR = (1 <<24 ),/* retrying in PIO */ IDE_DFLAG_DMA_PIO_RETRY = (1 <<25 ), + IDE_DFLAG_LBA = (1 << 26), }; struct ide_drive_s {
PATCH 2/9 ide: sanitize ide*_pm_* enums
* Move ide*_pm_* enums from ide-io.c to <linux/ide.h>.
* idedisk_pm_* -> ide_pm_*
* ide_pm_state_* -> ide_pm_*
* No need to set ide_pm_* enums to the fixed values.
* Uppercase ide_pm_* enums.
* Fix/update comments.
--- drivers/ide/ide-io.c | 62 ++++++++++++++++++--------------------------------- drivers/ide/ide.c | 4 +-- include/linux/ide.h | 34 +++++++++++++-------------- 3 files changed, 40 insertions(+), 60 deletions(-)
drivers/ide/ide-io.c +22 -40
@@ -132,21 +132,6 @@ int ide_end_request (ide_drive_t *drive, }EXPORT_SYMBOL (ide_end_request); -/* -* Power Management state machine. This one is rather trivial for now, -* we should probably add more, like switching back to PIO on suspend -* to help some BIOSes, re-do the door locking on resume, etc... -*/ - -enum { - ide_pm_flush_cache = ide_pm_state_start_suspend, - idedisk_pm_standby, - - idedisk_pm_restore_pio = ide_pm_state_start_resume, - idedisk_pm_idle, - ide_pm_restore_dma, -}; -static void ide_complete_power_step (ide_drive_t *drive,struct request *rq,u8 stat,u8 error) {struct request_pm_state *pm = rq->data;
@@ -155,20 +140,20 @@ static void ide_complete_power_step(ide_return ;switch (pm->pm_step) { -case ide_pm_flush_cache:/* Suspend step 1 (flush cache) complete */ +case IDE_PM_FLUSH_CACHE :/* Suspend step 1 (flush cache) */ if (pm->pm_state ==PM_EVENT_FREEZE ) - pm->pm_step = ide_pm_state_completed; + pm->pm_step =IDE_PM_COMPLETED ;else - pm->pm_step = idedisk_pm_standby; + pm->pm_step =IDE_PM_STANDBY ;break ; -case idedisk_pm_standby:/* Suspend step 2 (standby) complete */ - pm->pm_step = ide_pm_state_completed; +case IDE_PM_STANDBY :/* Suspend step 2 (standby) */ + pm->pm_step =IDE_PM_COMPLETED ;break ; -case idedisk_pm_restore_pio:/* Resume step 1 complete */ - pm->pm_step = idedisk_pm_idle; +case IDE_PM_RESTORE_PIO :/* Resume step 1 (restore PIO) */ + pm->pm_step =IDE_PM_IDLE ;break ; -case idedisk_pm_idle:/* Resume step 2 (idle) complete */ - pm->pm_step = ide_pm_restore_dma; +case IDE_PM_IDLE :/* Resume step 2 (idle)*/ + pm->pm_step =IDE_PM_RESTORE_DMA ;break ; } }
@@ -181,7 +166,7 @@ static ide_startstop_t ide_start_power_smemset (args,0 ,sizeof (*args));switch (pm->pm_step) { -case ide_pm_flush_cache:/* Suspend step 1 (flush cache) */ +case IDE_PM_FLUSH_CACHE :/* Suspend step 1 (flush cache) */ if (drive->media != ide_disk)break ;/* Not supported? Switch to next step now. */
@@ -195,27 +180,23 @@ static ide_startstop_t ide_start_power_selse args->tf.command =ATA_CMD_FLUSH ; goto out_do_tf; - -case idedisk_pm_standby:/* Suspend step 2 (standby) */ +case IDE_PM_STANDBY :/* Suspend step 2 (standby) */ args->tf.command =ATA_CMD_STANDBYNOW1 ; goto out_do_tf; - -case idedisk_pm_restore_pio:/* Resume step 1 (restore PIO) */ +case IDE_PM_RESTORE_PIO :/* Resume step 1 (restore PIO) */ ide_set_max_pio (drive);/* -* skip idedisk_pm_idle for ATAPI devices +* skip IDE_PM_IDLE for ATAPI devices */ if (drive->media != ide_disk) - pm->pm_step = ide_pm_restore_dma; + pm->pm_step =IDE_PM_RESTORE_DMA ;else ide_complete_power_step (drive, rq,0 ,0 );return ide_stopped; - -case idedisk_pm_idle:/* Resume step 2 (idle) */ +case IDE_PM_IDLE :/* Resume step 2 (idle) */ args->tf.command =ATA_CMD_IDLEIMMEDIATE ; goto out_do_tf; - -case ide_pm_restore_dma:/* Resume step 3 (restore DMA) */ +case IDE_PM_RESTORE_DMA :/* Resume step 3 (restore DMA) */ /* * Right now, all we do is call ide_set_dma(drive), * we could be smarter and check for current xfer_speed
@@ -229,7 +210,8 @@ static ide_startstop_t ide_start_power_side_set_dma (drive);break ; } - pm->pm_step = ide_pm_state_completed; + + pm->pm_step =IDE_PM_COMPLETED ;return ide_stopped; out_do_tf:
@@ -345,7 +327,7 @@ void ide_end_drive_cmd (ide_drive_t *dri drive->name, rq->pm->pm_step, stat, err);#endif ide_complete_power_step (drive, rq, stat, err); -if (pm->pm_step == ide_pm_state_completed) +if (pm->pm_step ==IDE_PM_COMPLETED )ide_complete_pm_request (drive, rq);return ; }
@@ -778,11 +760,11 @@ static void ide_check_pm_state(ide_drivestruct request_pm_state *pm = rq->data;if (blk_pm_suspend_request (rq) && - pm->pm_step == ide_pm_state_start_suspend) + pm->pm_step ==IDE_PM_START_SUSPEND )/* Mark drive blocked when starting the suspend sequence. */ drive->dev_flags |=IDE_DFLAG_BLOCKED ;else if (blk_pm_resume_request (rq) && - pm->pm_step == ide_pm_state_start_resume) { + pm->pm_step ==IDE_PM_START_RESUME ) {/* * The first thing we do on wakeup is to wait for BSY bit to * go away (with a looong timeout) as a drive on this hwif may
@@ -862,7 +844,7 @@ static ide_startstop_t start_request (id#endif startstop =ide_start_power_step (drive, rq);if (startstop == ide_stopped && - pm->pm_step == ide_pm_state_completed) + pm->pm_step ==IDE_PM_COMPLETED )ide_complete_pm_request (drive, rq);return startstop; }else if (!rq->rq_disk &&blk_special_request (rq))
drivers/ide/ide.c +2 -2
@@ -388,7 +388,7 @@ static int generic_ide_suspend(struct de rq->cmd_type =REQ_TYPE_PM_SUSPEND ; rq->special = &args; rq->data = &rqpm; - rqpm.pm_step = ide_pm_state_start_suspend; + rqpm.pm_step =IDE_PM_START_SUSPEND ;if (mesg.event ==PM_EVENT_PRETHAW ) mesg.event =PM_EVENT_FREEZE ; rqpm.pm_state = mesg.event;
@@ -427,7 +427,7 @@ static int generic_ide_resume(struct dev rq->cmd_flags |=REQ_PREEMPT ; rq->special = &args; rq->data = &rqpm; - rqpm.pm_step = ide_pm_state_start_resume; + rqpm.pm_step =IDE_PM_START_RESUME ; rqpm.pm_state =PM_EVENT_ON ; err =blk_execute_rq (drive->queue,NULL , rq,1 );
include/linux/ide.h +16 -18
@@ -957,36 +957,34 @@ static inline void ide_proc_unregister_d#endif /* -* Power Management step value (rq->pm->pm_step). +* Power Management state machine (rq->pm->pm_step). * -* The step value starts at 0 (ide_pm_state_start_suspend) for a -* suspend operation or 1000 (ide_pm_state_start_resume) for a -* resume operation. -* -* For each step, the core calls the subdriver start_power_step() first. +* For each step, the core calls ide_start_power_step() first. * This can return: * - ide_stopped : In this case, the core calls us back again unless * step have been set to ide_power_state_completed. * - ide_started : In this case, the channel is left busy until an * async event (interrupt) occurs. -* Typically, start_power_step() will issue a taskfile request with +* Typically, ide_start_power_step() will issue a taskfile request with * do_rw_taskfile(). * -* Upon reception of the interrupt, the core will call complete_power_step() +* Upon reception of the interrupt, the core will call ide_complete_power_step() * with the error code if any. This routine should update the step value * and return. It should not start a new request. The core will call -* start_power_step for the new step value, unless step have been set to -* ide_power_state_completed. -* -* Subdrivers are expected to define their own additional power -* steps from 1..999 for suspend and from 1001..1999 for resume, -* other values are reserved for future use. +* ide_start_power_step() for the new step value, unless step have been +* set to IDE_PM_COMPLETED. */ -enum { - ide_pm_state_completed =-1 , - ide_pm_state_start_suspend =0 , - ide_pm_state_start_resume =1000 , +IDE_PM_START_SUSPEND , +IDE_PM_FLUSH_CACHE =IDE_PM_START_SUSPEND , +IDE_PM_STANDBY , + +IDE_PM_START_RESUME , +IDE_PM_RESTORE_PIO =IDE_PM_START_RESUME , +IDE_PM_IDLE , +IDE_PM_RESTORE_DMA , + +IDE_PM_COMPLETED , };/*
PATCH 3/9 cy82c693: remove dead CY82C693_SETDMA_CLOCK code
In reply to Bartlomiej ZolnierkiewiczRemove dead CY82C693_SETDMA_CLOCK code and now not needed init_chipset_cy82c693().
--- drivers/ide/pci/cy82c693.c | 60 --------------------------------------------- 1 file changed, 60 deletions(-)
drivers/ide/pci/cy82c693.c +0 -60
@@ -50,18 +50,12 @@#define DRV_NAME "cy82c693" -/* the current version */ -#define CY82_VERSION "CY82C693U driver v0.34 99-13-12 Andreas S. Krebs ([email protected])" -/* * The following are used to debug the driver. */ #define CY82C693_DEBUG_LOGS 0#define CY82C693_DEBUG_INFO 0 -/* define CY82C693_SETDMA_CLOCK to set DMA Controller Clock Speed to ATCLK */ -#undef CY82C693_SETDMA_CLOCK -/* * NOTE: the value for busmaster timeout is tricky and I got it by * trial and error! By using a to low value will cause DMA timeouts
@@ -89,7 +83,6 @@#define CY82_INDEX_PORT 0x22#define CY82_DATA_PORT 0x23 -#define CY82_INDEX_CTRLREG1 0x01#define CY82_INDEX_CHANNEL0 0x30#define CY82_INDEX_CHANNEL1 0x31#define CY82_INDEX_TIMEOUT 0x32
@@ -329,58 +322,6 @@ static void cy82c693_set_pio_mode(ide_dr#endif /* CY82C693_DEBUG_INFO */ } -/* -* this function is called during init and is used to setup the cy82c693 chip -*/ -static unsigned int init_chipset_cy82c693 (struct pci_dev *dev) -{ -if (PCI_FUNC (dev->devfn) !=1 ) -return 0 ; - -#ifdef CY82C693_SETDMA_CLOCK -u8 data =0 ; -#endif /* CY82C693_SETDMA_CLOCK */ - -/* write info about this verion of the driver */ - printk(KERN_INFO CY82_VERSION "\n"); - -#ifdef CY82C693_SETDMA_CLOCK -/* okay let's set the DMA clock speed */ - -outb (CY82_INDEX_CTRLREG1 ,CY82_INDEX_PORT ); - data =inb (CY82_DATA_PORT ); - -#if CY82C693_DEBUG_INFO - printk(KERN_INFO DRV_NAME ": Peripheral Configuration Register: 0x%X\n", - data); -#endif /* CY82C693_DEBUG_INFO */ - -/* -* for some reason sometimes the DMA controller -* speed is set to ATCLK/2 ???? - we fix this here -* -* note: i don't know what causes this strange behaviour, -* but even changing the dma speed doesn't solve it :-( -* the ide performance is still only half the normal speed -* -* if anybody knows what goes wrong with my machine, please -* let me know - ASK -*/ - - data |=0x03 ; - -outb (CY82_INDEX_CTRLREG1 ,CY82_INDEX_PORT ); -outb (data,CY82_DATA_PORT ); - -#if CY82C693_DEBUG_INFO -printk (KERN_INFO ": New Peripheral Configuration Register: 0x%X\n" , - data); -#endif /* CY82C693_DEBUG_INFO */ - -#endif /* CY82C693_SETDMA_CLOCK */ -return 0 ; -} -static void __devinit init_iops_cy82c693 (ide_hwif_t *hwif) {static ide_hwif_t *primary;
@@ -401,7 +342,6 @@ static const struct ide_port_ops cy82c69static const struct ide_port_info cy82c693_chipset__devinitdata = { .name =DRV_NAME , - .init_chipset = init_chipset_cy82c693, .init_iops = init_iops_cy82c693, .port_ops = &cy82c693_port_ops, .chipset = ide_cy82c693,
PATCH 4/9 cy82c693: remove no longer needed CY82C693_DEBUG_LOGS code
In reply to Bartlomiej ZolnierkiewiczHaving CY82C693_DEBUG_INFO is enough nowadays.
--- drivers/ide/pci/cy82c693.c | 51 --------------------------------------------- 1 file changed, 51 deletions(-)
drivers/ide/pci/cy82c693.c +0 -51
@@ -53,7 +53,6 @@/* * The following are used to debug the driver. */ -#define CY82C693_DEBUG_LOGS 0#define CY82C693_DEBUG_INFO 0/*
@@ -172,17 +171,6 @@ static void cy82c693_set_dma_mode(ide_dr index = hwif->channel ?CY82_INDEX_CHANNEL1 :CY82_INDEX_CHANNEL0 ; -#if CY82C693_DEBUG_LOGS -/* for debug let's show the previous values */ - -outb (index,CY82_INDEX_PORT ); - data =inb (CY82_DATA_PORT ); - -printk (KERN_INFO "%s (ch=%d, dev=%d): DMA mode is %d (single=%d)\n" , - drive->name,HWIF (drive)->channel, drive->select.b.unit, - (data&0x3 ), ((data>>2 )&1 )); -#endif /* CY82C693_DEBUG_LOGS */ - data = (mode &3 ) | (single <<2 );outb (index,CY82_INDEX_PORT );
@@ -232,45 +220,6 @@ static void cy82c693_set_pio_mode(ide_dr } } -#if CY82C693_DEBUG_LOGS -/* for debug let's show the register values */ - -if (drive->select.b.unit ==0 ) { -/* -* get master drive registers -* address setup control register -* is 32 bit !!! -*/ -pci_read_config_dword (dev,CY82_IDE_ADDRSETUP , &addrCtrl); - addrCtrl &=0x0F ; - -/* now let's get the remaining registers */ -pci_read_config_byte (dev,CY82_IDE_MASTER_IOR , &pclk.time_16r); -pci_read_config_byte (dev,CY82_IDE_MASTER_IOW , &pclk.time_16w); -pci_read_config_byte (dev,CY82_IDE_MASTER_8BIT , &pclk.time_8); - }else { -/* -* set slave drive registers -* address setup control register -* is 32 bit !!! -*/ -pci_read_config_dword (dev,CY82_IDE_ADDRSETUP , &addrCtrl); - - addrCtrl &=0xF0 ; - addrCtrl >>=4 ; - -/* now let's get the remaining registers */ -pci_read_config_byte (dev,CY82_IDE_SLAVE_IOR , &pclk.time_16r); -pci_read_config_byte (dev,CY82_IDE_SLAVE_IOW , &pclk.time_16w); -pci_read_config_byte (dev,CY82_IDE_SLAVE_8BIT , &pclk.time_8); - } - -printk (KERN_INFO "%s (ch=%d, dev=%d): PIO timing is " -"(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n" , - drive->name, hwif->channel, drive->select.b.unit, - addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8); -#endif /* CY82C693_DEBUG_LOGS */ -/* let's calc the values for this PIO mode */ compute_clocks (pio, &pclk);
PATCH 5/9 ide: use 'drive->dn & 1' instead of drive->select.b.unit
In reply to Bartlomiej Zolnierkiewicz* Call ide_port_init_devices() in ide_host_register() also if 'struct ide_port_info *d' is not available.
* Init drive->dn in ide_port_init_devices() instead of ide_probe_port() so it is valid also in ->init_dev.
* Pass device number to ide_dev_apply_params().
* Use 'drive->dn & 1' instead of drive->select.b.unit.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-dma.c | 2 +- drivers/ide/ide-probe.c | 26 ++++++++++++++------------ drivers/ide/ide.c | 6 +++--- drivers/ide/legacy/ali14xx.c | 2 +- drivers/ide/legacy/qd65xx.c | 2 +- drivers/ide/pci/aec62xx.c | 2 +- drivers/ide/pci/alim15x3.c | 7 +++---- drivers/ide/pci/cmd640.c | 4 ++-- drivers/ide/pci/cs5535.c | 2 +- drivers/ide/pci/cy82c693.c | 7 +++---- drivers/ide/pci/it821x.c | 36 ++++++++++++++++-------------------- drivers/ide/pci/ns87415.c | 4 ++-- drivers/ide/pci/opti621.c | 2 +- drivers/ide/pci/sc1200.c | 3 +-- drivers/ide/pci/scc_pata.c | 2 +- drivers/ide/pci/serverworks.c | 2 +- drivers/ide/pci/siimage.c | 9 +++++---- drivers/ide/pci/triflex.c | 9 ++++----- drivers/ide/ppc/pmac.c | 11 +++++------ 19 files changed, 66 insertions(+), 72 deletions(-)
drivers/ide/ide-dma.c +1 -1
@@ -370,7 +370,7 @@ static int dma_timer_expiry (ide_drive_tvoid ide_dma_host_set (ide_drive_t *drive,int on) {ide_hwif_t *hwif =HWIF (drive); -u8 unit = (drive->select.b.unit &0x01 ); +u8 unit = drive->dn &1 ;u8 dma_stat = hwif->tp_ops->read_sff_dma_status (hwif);if (on)
drivers/ide/ide-probe.c +14 -12
@@ -447,7 +447,7 @@ static int do_probe (ide_drive_t *drive,msleep (50 );if (ide_read_device (drive) != drive->select.all && present ==0 ) { -if (drive->select.b.unit !=0 ) { +if (drive->dn &1 ) {/* exit with drive0 selected */ SELECT_DRIVE (&hwif->drives[0 ]);/* allow ATA_BUSY to assert & clear */
@@ -493,7 +493,7 @@ static int do_probe (ide_drive_t *drive,/* not present or maybe ATAPI */ rc =3 ; } -if (drive->select.b.unit !=0 ) { +if (drive->dn &1 ) {/* exit with drive0 selected */ SELECT_DRIVE (&hwif->drives[0 ]);msleep (50 );
@@ -798,7 +798,7 @@ static int ide_probe_port(ide_hwif_t *hw*/ for (unit =0 ; unit <MAX_DRIVES ; ++unit) {ide_drive_t *drive = &hwif->drives[unit]; - drive->dn = (hwif->channel ?2 :0 ) + unit; + (void )probe_for_drive (drive);if (drive->dev_flags &IDE_DFLAG_PRESENT ) rc =0 ;
@@ -1357,6 +1357,8 @@ static void ide_port_init_devices(ide_hwfor (i =0 ; i <MAX_DRIVES ; i++) {ide_drive_t *drive = &hwif->drives[i]; + drive->dn = i + hwif->channel *2 ; +if (hwif->host_flags &IDE_HFLAG_IO_32BIT ) drive->io_32bit =1 ;if (hwif->host_flags &IDE_HFLAG_UNMASK_IRQS )
@@ -1627,18 +1629,18 @@ int ide_host_register(struct ide_host *hif (d ==NULL ) { mate =NULL ; -continue ; - } + }else { +if ((i &1 ) && mate) { + hwif->mate = mate; + mate->mate = hwif; + } -if ((i &1 ) && mate) { - hwif->mate = mate; - mate->mate = hwif; - } + mate = (i &1 ) ?NULL : hwif; - mate = (i &1 ) ?NULL : hwif; +ide_init_port (hwif, i &1 , d); +ide_port_cable_detect (hwif); + } -ide_init_port (hwif, i &1 , d); -ide_port_cable_detect (hwif);ide_port_init_devices (hwif); }
drivers/ide/ide.c +3 -3
@@ -713,9 +713,9 @@ static int ide_set_disk_chs(const char *module_param_call (chs, ide_set_disk_chs,NULL ,NULL ,0 );MODULE_PARM_DESC (chs,"force device as a disk (using CHS)" ); -static void ide_dev_apply_params (ide_drive_t *drive) +static void ide_dev_apply_params (ide_drive_t *drive,u8 unit) { -int i = drive->hwif->index *MAX_DRIVES + drive->select.b.unit; +int i = drive->hwif->index *MAX_DRIVES + unit;if (ide_nodma & (1 << i)) {printk (KERN_INFO "ide: disallowing DMA for %s\n" , drive->name);
@@ -791,7 +791,7 @@ void ide_port_apply_params(ide_hwif_t *h }for (i =0 ; i <MAX_DRIVES ; i++) -ide_dev_apply_params (&hwif->drives[i]); +ide_dev_apply_params (&hwif->drives[i], i); }/*
drivers/ide/legacy/ali14xx.c +1 -1
@@ -131,7 +131,7 @@ static void ali14xx_set_pio_mode(ide_dri drive->name, pio, time1, time2, param1, param2, param3, param4);/* stuff timing parameters into controller registers */ - driveNum = (HWIF (drive)->index <<1 ) + drive->select.b.unit; + driveNum = (drive->hwif->index <<1 ) + (drive->dn &1 );spin_lock_irqsave (&ali14xx_lock, flags);outb_p (regOn, basePort);outReg (param1, regTab[driveNum].reg1);
drivers/ide/legacy/qd65xx.c +1 -1
@@ -305,7 +305,7 @@ static void __init qd6580_init_dev(ide_d }else t2 = t1 = hwif->channel ?QD6580_DEF_DATA2 :QD6580_DEF_DATA ; - drive->drive_data = drive->select.b.unit ? t2 : t1; + drive->drive_data = (drive->dn &1 ) ? t2 : t1; }static const struct ide_port_ops qd6500_port_ops = {
drivers/ide/pci/aec62xx.c +1 -1
@@ -115,7 +115,7 @@ static void aec6260_set_mode(ide_drive_tstruct pci_dev *dev =to_pci_dev (hwif->dev);struct ide_host *host =pci_get_drvdata (dev);struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; -u8 unit = (drive->select.b.unit &0x01 ); +u8 unit = drive->dn &1 ;u8 tmp1 =0 , tmp2 =0 ;u8 ultra =0 , drive_conf =0 , ultra_conf =0 ;unsigned long flags;
drivers/ide/pci/alim15x3.c +3 -4
@@ -77,8 +77,7 @@ static void ali_set_pio_mode(ide_drive_tint bus_speed = ide_pci_clk ? ide_pci_clk :33 ;int port = hwif->channel ?0x5c :0x58 ;int portFIFO = hwif->channel ?0x55 :0x54 ; -u8 cd_dma_fifo =0 ; -int unit = drive->select.b.unit &1 ; +u8 cd_dma_fifo =0 , unit = drive->dn &1 ;if ((s_clc = (s_time * bus_speed +999 ) /1000 ) >=8 ) s_clc =0 ;
@@ -112,7 +111,7 @@ static void ali_set_pio_mode(ide_drive_t }pci_write_config_byte (dev, port, s_clc); -pci_write_config_byte (dev, port+drive->select.b.unit+2 , (a_clc <<4 ) | r_clc); +pci_write_config_byte (dev, port + unit +2 , (a_clc <<4 ) | r_clc);local_irq_restore (flags); }
@@ -154,7 +153,7 @@ static void ali_set_dma_mode(ide_drive_tide_hwif_t *hwif =HWIF (drive);struct pci_dev *dev =to_pci_dev (hwif->dev);u8 speed1 = speed; -u8 unit = (drive->select.b.unit &0x01 ); +u8 unit = drive->dn &1 ;u8 tmpbyte =0x00 ;int m5229_udma = (hwif->channel) ?0x57 :0x56 ;
drivers/ide/pci/cmd640.c +2 -2
@@ -468,7 +468,7 @@ static void program_drive_counts(ide_dri*/ if (index >1 ) {ide_hwif_t *hwif = drive->hwif; -ide_drive_t *peer = &hwif->drives[!drive->select.b.unit]; +ide_drive_t *peer = &hwif->drives[!(drive->dn &1 )];unsigned int mate = index ^1 ;if (peer->dev_flags &IDE_DFLAG_PRESENT ) {
@@ -607,7 +607,7 @@ static void cmd640_set_pio_mode(ide_drivstatic void cmd640_init_dev (ide_drive_t *drive) { -unsigned int i = drive->hwif->channel *2 + drive->select.b.unit; +unsigned int i = drive->hwif->channel *2 + (drive->dn &1 );#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED /*
drivers/ide/pci/cs5535.c +1 -1
@@ -76,7 +76,7 @@ static unsigned int cs5535_udma_timings[static void cs5535_set_speed (ide_drive_t *drive,const u8 speed) {u32 reg =0 , dummy; -int unit = drive->select.b.unit; +u8 unit = drive->dn &1 ;/* Set the PIO timings */ if (speed <XFER_SW_DMA_0 ) {
drivers/ide/pci/cy82c693.c +3 -4
@@ -178,8 +178,7 @@ static void cy82c693_set_dma_mode(ide_dr#if CY82C693_DEBUG_INFO printk (KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n" , - drive->name,HWIF (drive)->channel, drive->select.b.unit, - mode &3 , single); + drive->name, hwif->channel, drive->dn &1 , mode &3 , single);#endif /* CY82C693_DEBUG_INFO */ /*
@@ -224,7 +223,7 @@ static void cy82c693_set_pio_mode(ide_drcompute_clocks (pio, &pclk);/* now let's write the clocks registers */ -if (drive->select.b.unit ==0 ) { +if ((drive->dn &1 ) ==0 ) {/* * set master drive * address setup control register
@@ -266,7 +265,7 @@ static void cy82c693_set_pio_mode(ide_dr#if CY82C693_DEBUG_INFO printk (KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to " "(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n" , - drive->name, hwif->channel, drive->select.b.unit, + drive->name, hwif->channel, drive->dn &1 , addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8);#endif /* CY82C693_DEBUG_INFO */ }
drivers/ide/pci/it821x.c +16 -20
@@ -138,8 +138,7 @@ static void it821x_program_udma(ide_drivstruct pci_dev *dev =to_pci_dev (hwif->dev);struct it821x_dev *itdev =ide_get_hwifdata (hwif);int channel = hwif->channel; -int unit = drive->select.b.unit; -u8 conf; +u8 unit = drive->dn &1 , conf;/* Program UDMA timing bits */ if (itdev->clock_mode ==ATA_66 )
@@ -168,13 +167,11 @@ static void it821x_clock_strategy(ide_dride_hwif_t *hwif = drive->hwif;struct pci_dev *dev =to_pci_dev (hwif->dev);struct it821x_dev *itdev =ide_get_hwifdata (hwif); +ide_drive_t *pair; +int clock, altclock, sel =0 ; +u8 unit = drive->dn &1 , v; -u8 unit = drive->select.b.unit; -ide_drive_t *pair = &hwif->drives[1 -unit]; - -int clock, altclock; -u8 v; -int sel =0 ; + pair = &hwif->drives[1 - unit];if (itdev->want[0 ][0 ] > itdev->want[1 ][0 ]) { clock = itdev->want[0 ][1 ];
@@ -240,16 +237,17 @@ static void it821x_clock_strategy(ide_drstatic void it821x_set_pio_mode (ide_drive_t *drive,const u8 pio) { -ide_hwif_t *hwif = drive->hwif; +ide_hwif_t *hwif = drive->hwif;struct it821x_dev *itdev =ide_get_hwifdata (hwif); -int unit = drive->select.b.unit; -ide_drive_t *pair = &hwif->drives[1 - unit]; -u8 set_pio = pio; +ide_drive_t *pair; +u8 unit = drive->dn &1 , set_pio = pio;/* Spec says 89 ref driver uses 88 */ static u16 pio_timings[]= {0xAA88 ,0xA382 ,0xA181 ,0x3332 ,0x3121 };static u8 pio_want[] = {ATA_66 ,ATA_66 ,ATA_66 ,ATA_66 ,ATA_ANY }; + pair = &hwif->drives[1 - unit]; +/* * Compute the best PIO mode we can for a given device. We must * pick a speed that does not cause problems with the other device
@@ -286,9 +284,7 @@ static void it821x_tune_mwdma (ide_driveide_hwif_t *hwif = drive->hwif;struct pci_dev *dev =to_pci_dev (hwif->dev);struct it821x_dev *itdev = (void *)ide_get_hwifdata (hwif); -int unit = drive->select.b.unit; -int channel = hwif->channel; -u8 conf; +u8 unit = drive->dn &1 , channel = hwif->channel, conf;static u16 dma[] = {0x8866 ,0x3222 ,0x3121 };static u8 mwdma_want[] = {ATA_ANY ,ATA_66 ,ATA_ANY };
@@ -325,9 +321,7 @@ static void it821x_tune_udma (ide_drive_ide_hwif_t *hwif = drive->hwif;struct pci_dev *dev =to_pci_dev (hwif->dev);struct it821x_dev *itdev =ide_get_hwifdata (hwif); -int unit = drive->select.b.unit; -int channel = hwif->channel; -u8 conf; +u8 unit = drive->dn &1 , channel = hwif->channel, conf;static u16 udma[] = {0x4433 ,0x4231 ,0x3121 ,0x2121 ,0x1111 ,0x2211 ,0x1111 };static u8 udma_want[] = {ATA_ANY ,ATA_50 ,ATA_ANY ,ATA_66 ,ATA_66 ,ATA_50 ,ATA_66 };
@@ -369,7 +363,8 @@ static void it821x_dma_start(ide_drive_t {ide_hwif_t *hwif = drive->hwif;struct it821x_dev *itdev =ide_get_hwifdata (hwif); -int unit = drive->select.b.unit; +u8 unit = drive->dn &1 ; +if (itdev->mwdma[unit] !=MWDMA_OFF )it821x_program (drive, itdev->mwdma[unit]);else if (itdev->udma[unit] !=UDMA_OFF && itdev->timing10)
@@ -389,9 +384,10 @@ static void it821x_dma_start(ide_drive_tstatic int it821x_dma_end (ide_drive_t *drive) {ide_hwif_t *hwif = drive->hwif; -int unit = drive->select.b.unit;struct it821x_dev *itdev =ide_get_hwifdata (hwif);int ret =__ide_dma_end (drive); +u8 unit = drive->dn &1 ; +if (itdev->mwdma[unit] !=MWDMA_OFF )it821x_program (drive, itdev->pio[unit]);return ret;
drivers/ide/pci/ns87415.c +2 -2
@@ -160,8 +160,8 @@ static void ns87415_prepare_drive (ide_d new |= bit;/* Select PIO or DMA, DMA may only be selected for one drive/channel. */ - bit =1 << (20 + drive->select.b.unit + (hwif->channel <<1 )); - other =1 << (20 + (1 - drive->select.b.unit) + (hwif->channel <<1 )); + bit =1 << (20 + (drive->dn &1 ) + (hwif->channel <<1 )); + other =1 << (20 + (1 - (drive->dn &1 )) + (hwif->channel <<1 )); new = use_dma ? ((new & ~other) | bit) : (new & ~bit);if (new != *old) {
drivers/ide/pci/opti621.c +1 -1
@@ -179,7 +179,7 @@ static void opti621_set_pio_mode(ide_dri misc = addr_timings[clk][addr_pio];/* select Index-0/1 for Register-A/B */ -write_reg (drive->select.b.unit,MISC_REG ); +write_reg (drive->dn &1 ,MISC_REG );/* set read cycle timings */ write_reg (tim,READ_REG );/* set write cycle timings */
drivers/ide/pci/sc1200.c +1 -2
@@ -126,7 +126,6 @@ static void sc1200_set_dma_mode(ide_driv {ide_hwif_t *hwif =HWIF (drive);struct pci_dev *dev =to_pci_dev (hwif->dev); -int unit = drive->select.b.unit;unsigned int reg, timings;unsigned short pci_clock;unsigned int basereg = hwif->channel ?0x50 :0x40 ;
@@ -155,7 +154,7 @@ static void sc1200_set_dma_mode(ide_drivelse timings = mwdma_timing[pci_clock][mode -XFER_MW_DMA_0 ]; -if (unit ==0 ) {/* are we configuring drive0? */ +if ((drive->dn &1 ) ==0 ) {pci_read_config_dword (dev, basereg +4 , ®); timings |= reg &0x80000000 ;/* preserve PIO format bit */ pci_write_config_dword (dev, basereg +4 , timings);
drivers/ide/pci/scc_pata.c +1 -1
@@ -291,7 +291,7 @@ static void scc_set_dma_mode(ide_drive_tstatic void scc_dma_host_set (ide_drive_t *drive,int on) {ide_hwif_t *hwif = drive->hwif; -u8 unit = (drive->select.b.unit &0x01 ); +u8 unit = drive->dn &1 ;u8 dma_stat =scc_ide_inb (hwif->dma_base +4 );if (on)
drivers/ide/pci/serverworks.c +1 -1
@@ -153,7 +153,7 @@ static void svwks_set_dma_mode(ide_driveide_hwif_t *hwif =HWIF (drive);struct pci_dev *dev =to_pci_dev (hwif->dev); -u8 unit = (drive->select.b.unit &0x01 ); +u8 unit = drive->dn &1 ;u8 ultra_enable =0 , ultra_timing =0 , dma_timing =0 ;
drivers/ide/pci/siimage.c +5 -4
@@ -116,13 +116,14 @@ static inline unsigned long siimage_seld {ide_hwif_t *hwif =HWIF (drive);unsigned long base = (unsigned long )hwif->hwif_data; +u8 unit = drive->dn &1 ; base +=0xA0 + r;if (hwif->host_flags &IDE_HFLAG_MMIO ) base += hwif->channel <<6 ;else base += hwif->channel <<4 ; - base |= drive->select.b.unit << drive->select.b.unit; + base |= unit << unit;return base; }
@@ -255,7 +256,7 @@ static void sil_set_pio_mode(ide_drive_tu8 addr_mask = hwif->channel ? (mmio ?0xF4 :0x84 ) : (mmio ?0xB4 :0x80 );u8 mode =0 ; -u8 unit = drive->select.b.unit; +u8 unit = drive->dn &1 ;/* trim *taskfile* PIO to the slowest of the master/slave */ if (pair) {
@@ -301,9 +302,9 @@ static void sil_set_dma_mode(ide_drive_tide_hwif_t *hwif =HWIF (drive);struct pci_dev *dev =to_pci_dev (hwif->dev); -u16 ultra =0 , multi =0 ; -u8 mode =0 , unit = drive->select.b.unit;unsigned long base = (unsigned long )hwif->hwif_data; +u16 ultra =0 , multi =0 ; +u8 mode =0 , unit = drive->dn &1 ;u8 mmio = (hwif->host_flags &IDE_HFLAG_MMIO ) ?1 :0 ;u8 scsc =0 , addr_mask = hwif->channel ? (mmio ?0xF4 :0x84 ) : (mmio ?0xB4 :0x80 );
drivers/ide/pci/triflex.c +4 -5
@@ -38,13 +38,12 @@ static void triflex_set_mode(ide_drive_t {ide_hwif_t *hwif =HWIF (drive);struct pci_dev *dev =to_pci_dev (hwif->dev); -u8 channel_offset = hwif->channel ?0x74 :0x70 ; -u16 timing =0 ;u32 triflex_timings =0 ; -u8 unit = (drive->select.b.unit &0x01 ); - +u16 timing =0 ; +u8 channel_offset = hwif->channel ?0x74 :0x70 , unit = drive->dn &1 ; +pci_read_config_dword (dev, channel_offset, &triflex_timings); - +switch (speed) {case XFER_MW_DMA_2 : timing =0x0103 ;
drivers/ide/ppc/pmac.c +5 -6
@@ -433,7 +433,7 @@ pmac_ide_selectproc(ide_drive_t *drive)if (pmif ==NULL )return ; -if (drive->select.b.unit &0x01 ) +if (drive->dn &1 )writel (pmif->timings[1 ],PMAC_IDE_REG (IDE_TIMING_CONFIG ));else writel (pmif->timings[0 ],PMAC_IDE_REG (IDE_TIMING_CONFIG ));
@@ -455,7 +455,7 @@ pmac_ide_kauai_selectproc(ide_drive_t *dif (pmif ==NULL )return ; -if (drive->select.b.unit &0x01 ) { +if (drive->dn &1 ) {writel (pmif->timings[1 ],PMAC_IDE_REG (IDE_KAUAI_PIO_CONFIG ));writel (pmif->timings[3 ],PMAC_IDE_REG (IDE_KAUAI_ULTRA_CONFIG )); }else {
@@ -528,7 +528,7 @@ pmac_ide_set_pio_mode(ide_drive_t *drivereturn ;/* which drive is it ? */ - timings = &pmif->timings[drive->select.b.unit &0x01 ]; + timings = &pmif->timings[drive->dn &1 ]; t = *timings; cycle_time =ide_pio_cycle_time (drive, pio);
@@ -805,9 +805,9 @@ static void pmac_ide_set_dma_mode(ide_dride_hwif_t *hwif = drive->hwif;pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent); -int unit = (drive->select.b.unit &0x01 );int ret =0 ;u32 *timings, *timings2, tl[2 ]; +u8 unit = drive->dn &1 ; timings = &pmif->timings[unit]; timings2 = &pmif->timings[unit+2 ];
@@ -1558,8 +1558,7 @@ pmac_ide_dma_setup(ide_drive_t *drive)pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)dev_get_drvdata (hwif->gendev.parent);struct request *rq =HWGROUP (drive)->rq; -u8 unit = (drive->select.b.unit &0x01 ); -u8 ata4; +u8 unit = drive->dn &1 , ata4;if (pmif ==NULL )return 1 ;
PATCH 6/9 ide: remove [ata_]select_t
In reply to Bartlomiej Zolnierkiewicz* Use 'drive->dn & 1' in ide_init_disk().
* remove [ata_]select_t.
While at it:
* Use ATA_DEVICE_OBS define in ide_port_init_devices_data().
--- drivers/ide/h8300/ide-h8300.c | 2 +- drivers/ide/ide-io.c | 2 +- drivers/ide/ide-iops.c | 2 +- drivers/ide/ide-probe.c | 4 ++-- drivers/ide/ide.c | 2 +- drivers/ide/legacy/ide-4drives.c | 2 +- drivers/ide/pci/scc_pata.c | 2 +- include/linux/ide.h | 32 +------------------------------- 8 files changed, 9 insertions(+), 39 deletions(-)
drivers/ide/h8300/ide-h8300.c +1 -1
@@ -80,7 +80,7 @@ static void h8300_tf_load(ide_drive_t *doutb (tf->lbah, io_ports->lbah_addr);if (task->tf_flags &IDE_TFLAG_OUT_DEVICE ) -outb ((tf->device &HIHI ) | drive->select.all, +outb ((tf->device &HIHI ) | drive->select, io_ports->device_addr); }
drivers/ide/ide-io.c +1 -1
@@ -495,7 +495,7 @@ static void ide_tf_set_specify_cmd(ide_d tf->lbal = drive->sect; tf->lbam = drive->cyl; tf->lbah = drive->cyl >>8 ; - tf->device = (drive->head -1 ) | drive->select.all; + tf->device = (drive->head -1 ) | drive->select; tf->command =ATA_CMD_INIT_DEV_PARAMS ; }
drivers/ide/ide-iops.c +1 -1
@@ -181,7 +181,7 @@ void ide_tf_load(ide_drive_t *drive, idetf_outb (tf->lbah, io_ports->lbah_addr);if (task->tf_flags &IDE_TFLAG_OUT_DEVICE ) -tf_outb ((tf->device &HIHI ) | drive->select.all, +tf_outb ((tf->device &HIHI ) | drive->select, io_ports->device_addr); }EXPORT_SYMBOL_GPL (ide_tf_load);
drivers/ide/ide-probe.c +2 -2
@@ -446,7 +446,7 @@ static int do_probe (ide_drive_t *drive,SELECT_DRIVE (drive);msleep (50 ); -if (ide_read_device (drive) != drive->select.all && present ==0 ) { +if (ide_read_device (drive) != drive->select && present ==0 ) {if (drive->dn &1 ) {/* exit with drive0 selected */ SELECT_DRIVE (&hwif->drives[0 ]);
@@ -1211,7 +1211,7 @@ EXPORT_SYMBOL_GPL(ide_unregister_region)void ide_init_disk (struct gendisk *disk,ide_drive_t *drive) {ide_hwif_t *hwif = drive->hwif; -unsigned int unit = (drive->select.all >>4 ) &1 ; +unsigned int unit = drive->dn &1 ; disk->major = hwif->major; disk->first_minor = unit <<PARTN_BITS ;
drivers/ide/ide.c +1 -1
@@ -114,7 +114,7 @@ static void ide_port_init_devices_data(imemset (drive,0 ,sizeof (*drive)); drive->media = ide_disk; - drive->select.all = (unit<<4 )|0xa0 ; + drive->select = (unit <<4 ) |ATA_DEVICE_OBS ; drive->hwif = hwif; drive->ready_stat =ATA_DRDY ; drive->bad_wstat =BAD_W_STAT ;
drivers/ide/legacy/ide-4drives.c +1 -1
@@ -14,7 +14,7 @@ MODULE_PARM_DESC(probe, "probe for generstatic void ide_4drives_init_dev (ide_drive_t *drive) {if (drive->hwif->channel) - drive->select.all ^=0x20 ; + drive->select ^=0x20 ; }static const struct ide_port_ops ide_4drives_port_ops = {
drivers/ide/pci/scc_pata.c +1 -1
@@ -705,7 +705,7 @@ static void scc_tf_load(ide_drive_t *driscc_ide_outb (tf->lbah, io_ports->lbah_addr);if (task->tf_flags &IDE_TFLAG_OUT_DEVICE ) -scc_ide_outb ((tf->device &HIHI ) | drive->select.all, +scc_ide_outb ((tf->device &HIHI ) | drive->select, io_ports->device_addr); }
include/linux/ide.h +1 -31
@@ -279,36 +279,6 @@ typedef union { } special_t;/* -* ATA-IDE Select Register, aka Device-Head -* -* head : always zeros here -* unit : drive select number: 0/1 -* bit5 : always 1 -* lba : using LBA instead of CHS -* bit7 : always 1 -*/ -typedef union { -unsigned all :8 ; -struct { -#if defined(__LITTLE_ENDIAN_BITFIELD) -unsigned head :4 ; -unsigned unit :1 ; -unsigned bit5 :1 ; -unsigned lba :1 ; -unsigned bit7 :1 ; -#elif defined(__BIG_ENDIAN_BITFIELD) -unsigned bit7 :1 ; -unsigned lba :1 ; -unsigned bit5 :1 ; -unsigned unit :1 ; -unsigned head :4 ; -#else -#error "Please fix <asm/byteorder.h>" -#endif - } b; -}select_t ,ata_select_t ; - -/* * Status returned from various ide_ functions */ typedef enum {
@@ -527,8 +497,8 @@ struct ide_drive_s {unsigned long timeout;/* max time to wait for irq */ special_t special;/* special action flags */ -select_t select;/* basic drive/head select reg value */ +u8 select;/* basic drive/head select reg value */ u8 retry_pio;/* retrying dma capable host in pio */ u8 waiting_for_dma;/* dma currently in progress */
PATCH 7/9 ide: convert 'pio_mode' device setting to use DS_SYNC flag
In reply to Bartlomiej Zolnierkiewicz* Convert 'pio_mode' device setting to use DS_SYNC flag.
* Remove unused special_t.b.{set_tune,serviced} and ide_drive_t.tune_req.
--- drivers/ide/ide-io.c | 68 +++------------------------------------------------ drivers/ide/ide.c | 58 +++++++++++++++++++++++++++++++++---------- include/linux/ide.h | 7 ----- 3 files changed, 51 insertions(+), 82 deletions(-)
drivers/ide/ide-io.c +5 -63
@@ -543,30 +543,6 @@ static ide_startstop_t ide_disk_special(return ide_started; } -/* -* handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away -*/ -static int set_pio_mode_abuse (ide_hwif_t *hwif,u8 req_pio) -{ -switch (req_pio) { -case 202 : -case 201 : -case 200 : -case 102 : -case 101 : -case 100 : -return (hwif->host_flags &IDE_HFLAG_ABUSE_DMA_MODES ) ?1 :0 ; -case 9 : -case 8 : -return (hwif->host_flags &IDE_HFLAG_ABUSE_PREFETCH ) ?1 :0 ; -case 7 : -case 6 : -return (hwif->host_flags &IDE_HFLAG_ABUSE_FAST_DEVSEL ) ?1 :0 ; -default : -return 0 ; - } -} -/** * do_special - issue some special commands * @drive: drive the command is for
@@ -584,46 +560,12 @@ static ide_startstop_t do_special (ide_d#ifdef DEBUG printk ("%s: do_special: 0x%02x\n" , drive->name, s->all);#endif -if (s->b.set_tune) { -ide_hwif_t *hwif = drive->hwif; -const struct ide_port_ops *port_ops = hwif->port_ops; -u8 req_pio = drive->tune_req; - - s->b.set_tune =0 ; - -if (set_pio_mode_abuse (drive->hwif, req_pio)) { -/* -* take ide_lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT -*/ -if (req_pio ==8 || req_pio ==9 ) { -unsigned long flags; +if (drive->media == ide_disk) +return ide_disk_special (drive); -spin_lock_irqsave (&ide_lock, flags); - port_ops->set_pio_mode (drive, req_pio); -spin_unlock_irqrestore (&ide_lock, flags); - }else - port_ops->set_pio_mode (drive, req_pio); - }else { -int keep_dma = - !!(drive->dev_flags &IDE_DFLAG_USING_DMA ); - -ide_set_pio (drive, req_pio); - -if (hwif->host_flags &IDE_HFLAG_SET_PIO_MODE_KEEP_DMA ) { -if (keep_dma) -ide_dma_on (drive); - } - } - -return ide_stopped; - }else { -if (drive->media == ide_disk) -return ide_disk_special (drive); - - s->all =0 ; - drive->mult_req =0 ; -return ide_stopped; - } + s->all =0 ; + drive->mult_req =0 ; +return ide_stopped; }void ide_map_sg (ide_drive_t *drive,struct request *rq)
drivers/ide/ide.c +45 -13
78 lines not on this page · raw message
include/linux/ide.h +1 -6
@@ -262,8 +262,6 @@ static inline int __ide_default_irq(unsi* set_geometry : respecify drive geometry * recalibrate : seek to cyl 0 * set_multmode : set multmode count -* set_tune : tune interface for drive -* serviced : service command * reserved : unused */ typedef union {
@@ -272,9 +270,7 @@ typedef union { unsigned set_geometry : 1; unsigned recalibrate : 1; unsigned set_multmode : 1; - unsigned set_tune : 1; - unsigned serviced : 1; - unsigned reserved : 3; + unsigned reserved : 5; } b; } special_t;
@@ -512,7 +508,6 @@ struct ide_drive_s {u8 ready_stat;/* min status value for drive ready */ u8 mult_count;/* current multiple sector setting */ u8 mult_req;/* requested multiple sector setting */ -u8 tune_req;/* requested drive tuning setting */ u8 io_32bit;/* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ u8 bad_wstat;/* used for ignoring ATA_DF */ u8 head;/* "real" number of heads */
PATCH 8/9 ide: factor out reset error reporting from reset_pollfunc()
In reply to Bartlomiej ZolnierkiewiczFactor out reset error reporting from reset_pollfunc() to ide_reset_report_error() helper.
While at it:
- fix KERN_* printk() levels
- remove 'switch ()'
--- drivers/ide/ide-iops.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
drivers/ide/ide-iops.c +21 -19
@@ -940,6 +940,25 @@ static ide_startstop_t atapi_reset_pollfreturn ide_stopped; } +static void ide_reset_report_error (ide_hwif_t *hwif,u8 err) +{ +static const char *err_master_vals[] = + {NULL ,"passed" ,"formatter device error" , +"sector buffer error" ,"ECC circuitry error" , +"controlling MPU error" }; + +u8 err_master = err &0x7f ; + +printk (KERN_ERR "%s: reset: master: " , hwif->name); +if (err_master && err_master <6 ) +printk (KERN_CONT "%s" , err_master_vals[err_master]); +else +printk (KERN_CONT "error (0x%02x?)" , err); +if (err &0x80 ) +printk (KERN_CONT "; slave: failed" ); +printk (KERN_CONT "\n" ); +} +/* * reset_pollfunc() gets invoked to poll the interface for completion every 50ms * during an ide reset operation. If the drives have not yet responded,
@@ -975,31 +994,14 @@ static ide_startstop_t reset_pollfunc (i drive->failures++; err = -EIO ; }else { -printk ("%s: reset: " , hwif->name); tmp =ide_read_error (drive);if (tmp ==1 ) { -printk ("success\n" ); +printk (KERN_INFO "%s: reset: success\n" , hwif->name); drive->failures =0 ; }else { +ide_reset_report_error (hwif, tmp); drive->failures++; -printk ("master: " ); -switch (tmp &0x7f ) { -case 1 :printk ("passed" ); -break ; -case 2 :printk ("formatter device error" ); -break ; -case 3 :printk ("sector buffer error" ); -break ; -case 4 :printk ("ECC circuitry error" ); -break ; -case 5 :printk ("controlling MPU error" ); -break ; -default :printk ("error (0x%02x?)" , tmp); - } -if (tmp &0x80 ) -printk ("; slave: failed" ); -printk ("\n" ); err = -EIO ; } }
PATCH 9/9 ide: merge all TASKFILE_NO_DATA data phase handlers into taskfile_no_intr()
In reply to Bartlomiej Zolnierkiewicz* Add 'struct task_s' to ide_hwif_t and init it to the current command in do_rw_taskfile().
* Merge all TASKFILE_NO_DATA data phase handlers into taskfile_no_intr().
--- drivers/ide/ide-taskfile.c | 105 +++++----------------- include/linux/ide.h | 211 ++++++++++++++++++++++----------------------- 2 files changed, 131 insertions(+), 185 deletions(-)
drivers/ide/ide-taskfile.c +25 -80
@@ -53,9 +53,6 @@ int taskfile_lib_get_identify (ide_drive }static ide_startstop_t task_no_data_intr (ide_drive_t *); -static ide_startstop_t set_geometry_intr (ide_drive_t *); -static ide_startstop_t recal_intr (ide_drive_t *); -static ide_startstop_t set_multmode_intr (ide_drive_t *);static ide_startstop_t pre_task_out_intr (ide_drive_t *,struct request *);static ide_startstop_t task_in_intr (ide_drive_t *);
@@ -79,6 +76,8 @@ ide_startstop_t do_rw_taskfile (ide_drivif (task->tf_flags &IDE_TFLAG_FLAGGED ) task->tf_flags |=IDE_TFLAG_FLAGGED_SET_IN_FLAGS ; +memcpy (&hwif->task, task,sizeof (*task)); +if ((task->tf_flags &IDE_TFLAG_DMA_PIO_FALLBACK ) ==0 ) {ide_tf_dump (drive->name, tf); tp_ops->set_irq (hwif,1 );
@@ -99,19 +98,6 @@ ide_startstop_t do_rw_taskfile (ide_drivcase TASKFILE_NO_DATA :if (handler ==NULL ) handler = task_no_data_intr; -if (task->tf_flags &IDE_TFLAG_CUSTOM_HANDLER ) { -switch (tf->command) { -case ATA_CMD_INIT_DEV_PARAMS : - handler = set_geometry_intr; -break ; -case ATA_CMD_RESTORE : - handler = recal_intr; -break ; -case ATA_CMD_SET_MULTI : - handler = set_multmode_intr; -break ; - } - }ide_execute_command (drive, tf->command, handler,WAIT_WORSTCASE ,NULL );return ide_started;
@@ -127,33 +113,15 @@ ide_startstop_t do_rw_taskfile (ide_drivEXPORT_SYMBOL_GPL (do_rw_taskfile);/* -* set_multmode_intr() is invoked on completion of a ATA_CMD_SET_MULTI cmd. -*/ -static ide_startstop_t set_multmode_intr (ide_drive_t *drive) -{ -ide_hwif_t *hwif = drive->hwif; -u8 stat; - -local_irq_enable_in_hardirq (); - stat = hwif->tp_ops->read_status (hwif); - -if (OK_STAT (stat,ATA_DRDY ,BAD_STAT )) - drive->mult_count = drive->mult_req; -else { - drive->mult_req = drive->mult_count =0 ; - drive->special.b.recalibrate =1 ; - (void )ide_dump_status (drive,"set_multmode" , stat); - } -return ide_stopped; -} - -/* -* set_geometry_intr() is invoked on completion of a ATA_CMD_INIT_DEV_PARAMS cmd. +* Handler for commands without a data phase */ -static ide_startstop_t set_geometry_intr (ide_drive_t *drive) +static ide_startstop_t task_no_data_intr (ide_drive_t *drive) {ide_hwif_t *hwif = drive->hwif; -int retries =5 ; +ide_task_t *task = &hwif->task; +struct ide_taskfile *tf = &task->tf; +int custom = (task->tf_flags &IDE_TFLAG_CUSTOM_HANDLER ) ?1 :0 ; +int retries = (custom && tf->command ==ATA_CMD_INIT_DEV_PARAMS ) ?5 :1 ;u8 stat;local_irq_enable_in_hardirq ();
@@ -165,50 +133,27 @@ static ide_startstop_t set_geometry_intrudelay (10 ); }; -if (OK_STAT (stat,ATA_DRDY ,BAD_STAT )) -return ide_stopped; - -if (stat & (ATA_ERR |ATA_DRQ )) -return ide_error (drive,"set_geometry_intr" , stat); - -ide_set_handler (drive, &set_geometry_intr,WAIT_WORSTCASE ,NULL ); -return ide_started; -} - -/* -* recal_intr() is invoked on completion of a ATA_CMD_RESTORE (recalibrate) cmd. -*/ -static ide_startstop_t recal_intr (ide_drive_t *drive) -{ -ide_hwif_t *hwif = drive->hwif; -u8 stat; - -local_irq_enable_in_hardirq (); - stat = hwif->tp_ops->read_status (hwif); - -if (!OK_STAT (stat,ATA_DRDY ,BAD_STAT )) -return ide_error (drive,"recal_intr" , stat); -return ide_stopped; -} - -/* -* Handler for commands without a data phase -*/ -static ide_startstop_t task_no_data_intr (ide_drive_t *drive) -{ -ide_hwif_t *hwif = drive->hwif; -ide_task_t *args = hwif->hwgroup->rq->special; -u8 stat; - -local_irq_enable_in_hardirq (); - stat = hwif->tp_ops->read_status (hwif); - -if (!OK_STAT (stat,ATA_DRDY ,BAD_STAT )) +if (!OK_STAT (stat,ATA_DRDY ,BAD_STAT )) { +if (custom && tf->command ==ATA_CMD_SET_MULTI ) { + drive->mult_req = drive->mult_count =0 ; + drive->special.b.recalibrate =1 ; + (void )ide_dump_status (drive, __func__, stat); +return ide_stopped; + }else if (custom && tf->command ==ATA_CMD_INIT_DEV_PARAMS ) { +if ((stat & (ATA_ERR |ATA_DRQ )) ==0 ) { +ide_set_handler (drive, &task_no_data_intr, +WAIT_WORSTCASE ,NULL ); +return ide_started; + } + }return ide_error (drive,"task_no_data_intr" , stat);/* calls ide_end_drive_cmd */ + } -if (args) +if (!custom)ide_end_drive_cmd (drive, stat,ide_read_error (drive)); +else if (tf->command ==ATA_CMD_SET_MULTI ) + drive->mult_count = drive->mult_req;return ide_stopped; }
include/linux/ide.h +106 -105
235 lines not on this page · raw message
Re: [PATCH 6/9] ide: remove [ata_]select_t
In reply to Bartlomiej ZolnierkiewiczHello.
Quoted 9 lines · Bartlomiej Zolnierkiewicz
* Use '
drive->dn& 1' inide_init_disk().* remove [ata_]select_t.
While at it:
* Use
ATA_DEVICE_OBSdefine inide_port_init_devices_data().Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>
MBR, Sergei