From 9666f4009c22f6520ac3fb8a19c9e32ab973e828 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 4 May 2007 21:27:47 +0200 Subject: [PATCH 01/14] libata: reimplement suspend/resume support using sdev->manage_start_stop Reimplement suspend/resume support using sdev->manage_start_stop. * Device suspend/resume is now SCSI layer's responsibility and the code is simplified a lot. * DPM is dropped. This also simplifies code a lot. Suspend/resume status is port-wide now. * ata_scsi_device_suspend/resume() and ata_dev_ready() removed. * Resume now has to wait for disk to spin up before proceeding. I couldn't find easy way out as libata is in EH waiting for the disk to be ready and sd is waiting for EH to complete to issue START_STOP. * sdev->manage_start_stop is set to 1 in ata_scsi_slave_config(). This fixes spindown on shutdown and suspend-to-disk. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/ahci.c | 4 - drivers/ata/ata_generic.c | 6 +- drivers/ata/ata_piix.c | 4 - drivers/ata/libata-core.c | 39 +----- drivers/ata/libata-eh.c | 237 +------------------------------- drivers/ata/libata-scsi.c | 129 +---------------- drivers/ata/pata_ali.c | 4 - drivers/ata/pata_amd.c | 4 - drivers/ata/pata_atiixp.c | 4 - drivers/ata/pata_cmd640.c | 4 - drivers/ata/pata_cmd64x.c | 4 - drivers/ata/pata_cs5520.c | 4 - drivers/ata/pata_cs5530.c | 4 - drivers/ata/pata_cs5535.c | 4 - drivers/ata/pata_cypress.c | 4 - drivers/ata/pata_efar.c | 4 - drivers/ata/pata_hpt366.c | 4 - drivers/ata/pata_hpt3x3.c | 4 - drivers/ata/pata_it8213.c | 4 - drivers/ata/pata_it821x.c | 4 - drivers/ata/pata_ixp4xx_cf.c | 2 +- drivers/ata/pata_jmicron.c | 4 - drivers/ata/pata_marvell.c | 4 - drivers/ata/pata_mpc52xx.c | 4 - drivers/ata/pata_mpiix.c | 4 - drivers/ata/pata_netcell.c | 4 - drivers/ata/pata_ns87410.c | 4 - drivers/ata/pata_oldpiix.c | 4 - drivers/ata/pata_opti.c | 4 - drivers/ata/pata_optidma.c | 4 - drivers/ata/pata_pdc202xx_old.c | 4 - drivers/ata/pata_radisys.c | 4 - drivers/ata/pata_rz1000.c | 6 +- drivers/ata/pata_sc1200.c | 4 - drivers/ata/pata_scc.c | 4 - drivers/ata/pata_serverworks.c | 4 - drivers/ata/pata_sil680.c | 4 - drivers/ata/pata_sis.c | 4 - drivers/ata/pata_triflex.c | 4 - drivers/ata/pata_via.c | 4 - drivers/ata/sata_inic162x.c | 4 - drivers/ata/sata_nv.c | 8 -- drivers/ata/sata_sil.c | 4 - drivers/ata/sata_sil24.c | 4 - include/linux/libata.h | 14 +- 45 files changed, 14 insertions(+), 575 deletions(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index d9617892fc23..1ab8a8fdeaac 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -250,10 +250,6 @@ static struct scsi_host_template ahci_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static const struct ata_port_operations ahci_ops = { diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c index 92a491ddd030..0f19e3223358 100644 --- a/drivers/ata/ata_generic.c +++ b/drivers/ata/ata_generic.c @@ -54,7 +54,7 @@ static int generic_set_mode(struct ata_port *ap, struct ata_device **unused) for (i = 0; i < ATA_MAX_DEVICES; i++) { struct ata_device *dev = &ap->device[i]; - if (ata_dev_ready(dev)) { + if (ata_dev_enabled(dev)) { /* We don't really care */ dev->pio_mode = XFER_PIO_0; dev->dma_mode = XFER_MW_DMA_0; @@ -90,10 +90,6 @@ static struct scsi_host_template generic_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations generic_port_ops = { diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 4a795fdb6a02..4f5a0dc7fb9c 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -275,10 +275,6 @@ static struct scsi_host_template piix_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static const struct ata_port_operations piix_pata_ops = { diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 4595d1f8cf60..2e2a2fa8e9e9 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2860,7 +2860,7 @@ int ata_do_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev) dev = &ap->device[i]; /* don't update suspended devices' xfer mode */ - if (!ata_dev_ready(dev)) + if (!ata_dev_enabled(dev)) continue; rc = ata_dev_set_mode(dev); @@ -5845,37 +5845,11 @@ static int ata_host_request_pm(struct ata_host *host, pm_message_t mesg, */ int ata_host_suspend(struct ata_host *host, pm_message_t mesg) { - int i, j, rc; + int rc; rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); - if (rc) - goto fail; - - /* EH is quiescent now. Fail if we have any ready device. - * This happens if hotplug occurs between completion of device - * suspension and here. - */ - for (i = 0; i < host->n_ports; i++) { - struct ata_port *ap = host->ports[i]; - - for (j = 0; j < ATA_MAX_DEVICES; j++) { - struct ata_device *dev = &ap->device[j]; - - if (ata_dev_ready(dev)) { - ata_port_printk(ap, KERN_WARNING, - "suspend failed, device %d " - "still active\n", dev->devno); - rc = -EBUSY; - goto fail; - } - } - } - - host->dev->power.power_state = mesg; - return 0; - - fail: - ata_host_resume(host); + if (rc == 0) + host->dev->power.power_state = mesg; return rc; } @@ -6889,11 +6863,6 @@ EXPORT_SYMBOL_GPL(ata_pci_default_filter); EXPORT_SYMBOL_GPL(ata_pci_clear_simplex); #endif /* CONFIG_PCI */ -#ifdef CONFIG_PM -EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); -EXPORT_SYMBOL_GPL(ata_scsi_device_resume); -#endif /* CONFIG_PM */ - EXPORT_SYMBOL_GPL(ata_eng_timeout); EXPORT_SYMBOL_GPL(ata_port_schedule_eh); EXPORT_SYMBOL_GPL(ata_port_abort); diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 8256655ce7d9..412d6049afa3 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -77,29 +77,12 @@ static void ata_eh_finish(struct ata_port *ap); #ifdef CONFIG_PM static void ata_eh_handle_port_suspend(struct ata_port *ap); static void ata_eh_handle_port_resume(struct ata_port *ap); -static int ata_eh_suspend(struct ata_port *ap, - struct ata_device **r_failed_dev); -static void ata_eh_prep_resume(struct ata_port *ap); -static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev); #else /* CONFIG_PM */ static void ata_eh_handle_port_suspend(struct ata_port *ap) { } static void ata_eh_handle_port_resume(struct ata_port *ap) { } - -static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev) -{ - return 0; -} - -static void ata_eh_prep_resume(struct ata_port *ap) -{ } - -static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev) -{ - return 0; -} #endif /* CONFIG_PM */ static void ata_ering_record(struct ata_ering *ering, int is_io, @@ -1791,7 +1774,7 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, if (ehc->i.flags & ATA_EHI_DID_RESET) readid_flags |= ATA_READID_POSTRESET; - if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) { + if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) { if (ata_port_offline(ap)) { rc = -EIO; goto err; @@ -1872,166 +1855,6 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, return rc; } -#ifdef CONFIG_PM -/** - * ata_eh_suspend - handle suspend EH action - * @ap: target host port - * @r_failed_dev: result parameter to indicate failing device - * - * Handle suspend EH action. Disk devices are spinned down and - * other types of devices are just marked suspended. Once - * suspended, no EH action to the device is allowed until it is - * resumed. - * - * LOCKING: - * Kernel thread context (may sleep). - * - * RETURNS: - * 0 on success, -errno otherwise - */ -static int ata_eh_suspend(struct ata_port *ap, struct ata_device **r_failed_dev) -{ - struct ata_device *dev; - int i, rc = 0; - - DPRINTK("ENTER\n"); - - for (i = 0; i < ATA_MAX_DEVICES; i++) { - unsigned long flags; - unsigned int action, err_mask; - - dev = &ap->device[i]; - action = ata_eh_dev_action(dev); - - if (!ata_dev_enabled(dev) || !(action & ATA_EH_SUSPEND)) - continue; - - WARN_ON(dev->flags & ATA_DFLAG_SUSPENDED); - - ata_eh_about_to_do(ap, dev, ATA_EH_SUSPEND); - - if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) { - /* flush cache */ - rc = ata_flush_cache(dev); - if (rc) - break; - - /* spin down */ - err_mask = ata_do_simple_cmd(dev, ATA_CMD_STANDBYNOW1); - if (err_mask) { - ata_dev_printk(dev, KERN_ERR, "failed to " - "spin down (err_mask=0x%x)\n", - err_mask); - rc = -EIO; - break; - } - } - - spin_lock_irqsave(ap->lock, flags); - dev->flags |= ATA_DFLAG_SUSPENDED; - spin_unlock_irqrestore(ap->lock, flags); - - ata_eh_done(ap, dev, ATA_EH_SUSPEND); - } - - if (rc) - *r_failed_dev = dev; - - DPRINTK("EXIT\n"); - return rc; -} - -/** - * ata_eh_prep_resume - prep for resume EH action - * @ap: target host port - * - * Clear SUSPENDED in preparation for scheduled resume actions. - * This allows other parts of EH to access the devices being - * resumed. - * - * LOCKING: - * Kernel thread context (may sleep). - */ -static void ata_eh_prep_resume(struct ata_port *ap) -{ - struct ata_device *dev; - unsigned long flags; - int i; - - DPRINTK("ENTER\n"); - - for (i = 0; i < ATA_MAX_DEVICES; i++) { - unsigned int action; - - dev = &ap->device[i]; - action = ata_eh_dev_action(dev); - - if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME)) - continue; - - spin_lock_irqsave(ap->lock, flags); - dev->flags &= ~ATA_DFLAG_SUSPENDED; - spin_unlock_irqrestore(ap->lock, flags); - } - - DPRINTK("EXIT\n"); -} - -/** - * ata_eh_resume - handle resume EH action - * @ap: target host port - * @r_failed_dev: result parameter to indicate failing device - * - * Handle resume EH action. Target devices are already reset and - * revalidated. Spinning up is the only operation left. - * - * LOCKING: - * Kernel thread context (may sleep). - * - * RETURNS: - * 0 on success, -errno otherwise - */ -static int ata_eh_resume(struct ata_port *ap, struct ata_device **r_failed_dev) -{ - struct ata_device *dev; - int i, rc = 0; - - DPRINTK("ENTER\n"); - - for (i = 0; i < ATA_MAX_DEVICES; i++) { - unsigned int action, err_mask; - - dev = &ap->device[i]; - action = ata_eh_dev_action(dev); - - if (!ata_dev_enabled(dev) || !(action & ATA_EH_RESUME)) - continue; - - ata_eh_about_to_do(ap, dev, ATA_EH_RESUME); - - if (dev->class == ATA_DEV_ATA && !(action & ATA_EH_PM_FREEZE)) { - err_mask = ata_do_simple_cmd(dev, - ATA_CMD_IDLEIMMEDIATE); - if (err_mask) { - ata_dev_printk(dev, KERN_ERR, "failed to " - "spin up (err_mask=0x%x)\n", - err_mask); - rc = -EIO; - break; - } - } - - ata_eh_done(ap, dev, ATA_EH_RESUME); - } - - if (rc) - *r_failed_dev = dev; - - DPRINTK("EXIT\n"); - return 0; -} -#endif /* CONFIG_PM */ - static int ata_port_nr_enabled(struct ata_port *ap) { int i, cnt = 0; @@ -2057,17 +1880,6 @@ static int ata_eh_skip_recovery(struct ata_port *ap) struct ata_eh_context *ehc = &ap->eh_context; int i; - /* skip if all possible devices are suspended */ - for (i = 0; i < ata_port_max_devices(ap); i++) { - struct ata_device *dev = &ap->device[i]; - - if (!(dev->flags & ATA_DFLAG_SUSPENDED)) - break; - } - - if (i == ata_port_max_devices(ap)) - return 1; - /* thaw frozen port, resume link and recover failed devices */ if ((ap->pflags & ATA_PFLAG_FROZEN) || (ehc->i.flags & ATA_EHI_RESUME_LINK) || ata_port_nr_enabled(ap)) @@ -2147,9 +1959,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, if (ap->pflags & ATA_PFLAG_UNLOADING) goto out; - /* prep for resume */ - ata_eh_prep_resume(ap); - /* skip EH if possible. */ if (ata_eh_skip_recovery(ap)) ehc->i.action = 0; @@ -2177,11 +1986,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, if (rc) goto dev_fail; - /* resume devices */ - rc = ata_eh_resume(ap, &dev); - if (rc) - goto dev_fail; - /* configure transfer mode if necessary */ if (ehc->i.flags & ATA_EHI_SETMODE) { rc = ata_set_mode(ap, &dev); @@ -2190,11 +1994,6 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ehc->i.flags &= ~ATA_EHI_SETMODE; } - /* suspend devices */ - rc = ata_eh_suspend(ap, &dev); - if (rc) - goto dev_fail; - goto out; dev_fail: @@ -2390,22 +2189,13 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap) * * Resume @ap. * - * This function also waits upto one second until all devices - * hanging off this port requests resume EH action. This is to - * prevent invoking EH and thus reset multiple times on resume. - * - * On DPM resume, where some of devices might not be resumed - * together, this may delay port resume upto one second, but such - * DPM resumes are rare and 1 sec delay isn't too bad. - * * LOCKING: * Kernel thread context (may sleep). */ static void ata_eh_handle_port_resume(struct ata_port *ap) { - unsigned long timeout; unsigned long flags; - int i, rc = 0; + int rc = 0; /* are we resuming? */ spin_lock_irqsave(ap->lock, flags); @@ -2416,31 +2206,12 @@ static void ata_eh_handle_port_resume(struct ata_port *ap) } spin_unlock_irqrestore(ap->lock, flags); - /* spurious? */ - if (!(ap->pflags & ATA_PFLAG_SUSPENDED)) - goto done; + WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); if (ap->ops->port_resume) rc = ap->ops->port_resume(ap); - /* give devices time to request EH */ - timeout = jiffies + HZ; /* 1s max */ - while (1) { - for (i = 0; i < ATA_MAX_DEVICES; i++) { - struct ata_device *dev = &ap->device[i]; - unsigned int action = ata_eh_dev_action(dev); - - if ((dev->flags & ATA_DFLAG_SUSPENDED) && - !(action & ATA_EH_RESUME)) - break; - } - - if (i == ATA_MAX_DEVICES || time_after(jiffies, timeout)) - break; - msleep(10); - } - - done: + /* report result */ spin_lock_irqsave(ap->lock, flags); ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); if (ap->pm_result) { diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 9afba2ba489e..8f800196d596 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -510,133 +510,6 @@ static void ata_dump_status(unsigned id, struct ata_taskfile *tf) } } -#ifdef CONFIG_PM -/** - * ata_scsi_device_suspend - suspend ATA device associated with sdev - * @sdev: the SCSI device to suspend - * @mesg: target power management message - * - * Request suspend EH action on the ATA device associated with - * @sdev and wait for the operation to complete. - * - * LOCKING: - * Kernel thread context (may sleep). - * - * RETURNS: - * 0 on success, -errno otherwise. - */ -int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t mesg) -{ - struct ata_port *ap = ata_shost_to_port(sdev->host); - struct ata_device *dev = ata_scsi_find_dev(ap, sdev); - unsigned long flags; - unsigned int action; - int rc = 0; - - if (!dev) - goto out; - - spin_lock_irqsave(ap->lock, flags); - - /* wait for the previous resume to complete */ - while (dev->flags & ATA_DFLAG_SUSPENDED) { - spin_unlock_irqrestore(ap->lock, flags); - ata_port_wait_eh(ap); - spin_lock_irqsave(ap->lock, flags); - } - - /* if @sdev is already detached, nothing to do */ - if (sdev->sdev_state == SDEV_OFFLINE || - sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL) - goto out_unlock; - - /* request suspend */ - action = ATA_EH_SUSPEND; - if (mesg.event != PM_EVENT_SUSPEND) - action |= ATA_EH_PM_FREEZE; - ap->eh_info.dev_action[dev->devno] |= action; - ap->eh_info.flags |= ATA_EHI_QUIET; - ata_port_schedule_eh(ap); - - spin_unlock_irqrestore(ap->lock, flags); - - /* wait for EH to do the job */ - ata_port_wait_eh(ap); - - spin_lock_irqsave(ap->lock, flags); - - /* If @sdev is still attached but the associated ATA device - * isn't suspended, the operation failed. - */ - if (sdev->sdev_state != SDEV_OFFLINE && - sdev->sdev_state != SDEV_CANCEL && sdev->sdev_state != SDEV_DEL && - !(dev->flags & ATA_DFLAG_SUSPENDED)) - rc = -EIO; - - out_unlock: - spin_unlock_irqrestore(ap->lock, flags); - out: - if (rc == 0) - sdev->sdev_gendev.power.power_state = mesg; - return rc; -} - -/** - * ata_scsi_device_resume - resume ATA device associated with sdev - * @sdev: the SCSI device to resume - * - * Request resume EH action on the ATA device associated with - * @sdev and return immediately. This enables parallel - * wakeup/spinup of devices. - * - * LOCKING: - * Kernel thread context (may sleep). - * - * RETURNS: - * 0. - */ -int ata_scsi_device_resume(struct scsi_device *sdev) -{ - struct ata_port *ap = ata_shost_to_port(sdev->host); - struct ata_device *dev = ata_scsi_find_dev(ap, sdev); - struct ata_eh_info *ehi = &ap->eh_info; - unsigned long flags; - unsigned int action; - - if (!dev) - goto out; - - spin_lock_irqsave(ap->lock, flags); - - /* if @sdev is already detached, nothing to do */ - if (sdev->sdev_state == SDEV_OFFLINE || - sdev->sdev_state == SDEV_CANCEL || sdev->sdev_state == SDEV_DEL) - goto out_unlock; - - /* request resume */ - action = ATA_EH_RESUME; - if (sdev->sdev_gendev.power.power_state.event == PM_EVENT_SUSPEND) - __ata_ehi_hotplugged(ehi); - else - action |= ATA_EH_PM_FREEZE | ATA_EH_SOFTRESET; - ehi->dev_action[dev->devno] |= action; - - /* We don't want autopsy and verbose EH messages. Disable - * those if we're the only device on this link. - */ - if (ata_port_max_devices(ap) == 1) - ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; - - ata_port_schedule_eh(ap); - - out_unlock: - spin_unlock_irqrestore(ap->lock, flags); - out: - sdev->sdev_gendev.power.power_state = PMSG_ON; - return 0; -} -#endif /* CONFIG_PM */ - /** * ata_to_sense_error - convert ATA error to SCSI error * @id: ATA device number @@ -929,6 +802,8 @@ int ata_scsi_slave_config(struct scsi_device *sdev) blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD); + sdev->manage_start_stop = 1; + if (dev) ata_scsi_dev_config(sdev, dev); diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index d40edebb510a..48c7531ae690 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c @@ -291,10 +291,6 @@ static struct scsi_host_template ali_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; /* diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c index 67c7e87dec04..86a26186739c 100644 --- a/drivers/ata/pata_amd.c +++ b/drivers/ata/pata_amd.c @@ -324,10 +324,6 @@ static struct scsi_host_template amd_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations amd33_port_ops = { diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c index 21515381b5b3..3c2264dbdd67 100644 --- a/drivers/ata/pata_atiixp.c +++ b/drivers/ata/pata_atiixp.c @@ -229,10 +229,6 @@ static struct scsi_host_template atiixp_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations atiixp_port_ops = { diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c index 2105985a8013..987dec935b5c 100644 --- a/drivers/ata/pata_cmd640.c +++ b/drivers/ata/pata_cmd640.c @@ -181,10 +181,6 @@ static struct scsi_host_template cmd640_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations cmd640_port_ops = { diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c index 3989cc577fcd..3e02c6a3ba9c 100644 --- a/drivers/ata/pata_cmd64x.c +++ b/drivers/ata/pata_cmd64x.c @@ -266,10 +266,6 @@ static struct scsi_host_template cmd64x_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations cmd64x_port_ops = { diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c index 79bef0d1fad3..83bcc5b32597 100644 --- a/drivers/ata/pata_cs5520.c +++ b/drivers/ata/pata_cs5520.c @@ -155,10 +155,6 @@ static struct scsi_host_template cs5520_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations cs5520_port_ops = { diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c index 29642d5ee189..637d8b302e3e 100644 --- a/drivers/ata/pata_cs5530.c +++ b/drivers/ata/pata_cs5530.c @@ -176,10 +176,6 @@ static struct scsi_host_template cs5530_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations cs5530_port_ops = { diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c index 22006ae71941..683885a47b6d 100644 --- a/drivers/ata/pata_cs5535.c +++ b/drivers/ata/pata_cs5535.c @@ -173,10 +173,6 @@ static struct scsi_host_template cs5535_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations cs5535_port_ops = { diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c index 6ec049c3b1dc..30e5c543bcb0 100644 --- a/drivers/ata/pata_cypress.c +++ b/drivers/ata/pata_cypress.c @@ -125,10 +125,6 @@ static struct scsi_host_template cy82c693_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations cy82c693_port_ops = { diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c index d0f52e034906..23e929f0cd3f 100644 --- a/drivers/ata/pata_efar.c +++ b/drivers/ata/pata_efar.c @@ -247,10 +247,6 @@ static struct scsi_host_template efar_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static const struct ata_port_operations efar_ops = { diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c index e64e05e5c7fe..cb965f41d093 100644 --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c @@ -331,10 +331,6 @@ static struct scsi_host_template hpt36x_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; /* diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c index ac28ec8c50aa..84c636b9beac 100644 --- a/drivers/ata/pata_hpt3x3.c +++ b/drivers/ata/pata_hpt3x3.c @@ -100,10 +100,6 @@ static struct scsi_host_template hpt3x3_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations hpt3x3_port_ops = { diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c index 17bf9f3ed013..bf3aaa205edc 100644 --- a/drivers/ata/pata_it8213.c +++ b/drivers/ata/pata_it8213.c @@ -257,10 +257,6 @@ static struct scsi_host_template it8213_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static const struct ata_port_operations it8213_ops = { diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index f1f8cec8c224..8e565a5f2c8d 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c @@ -620,10 +620,6 @@ static struct scsi_host_template it821x_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations it821x_smart_port_ops = { diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c index 420c343e5711..b994351fbcd0 100644 --- a/drivers/ata/pata_ixp4xx_cf.c +++ b/drivers/ata/pata_ixp4xx_cf.c @@ -31,7 +31,7 @@ static int ixp4xx_set_mode(struct ata_port *ap, struct ata_device **error) for (i = 0; i < ATA_MAX_DEVICES; i++) { struct ata_device *dev = &ap->device[i]; - if (ata_dev_ready(dev)) { + if (ata_dev_enabled(dev)) { ata_dev_printk(dev, KERN_INFO, "configured for PIO0\n"); dev->pio_mode = XFER_PIO_0; dev->xfer_mode = XFER_PIO_0; diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c index 1daf78ac6efb..1aa7bc2fda54 100644 --- a/drivers/ata/pata_jmicron.c +++ b/drivers/ata/pata_jmicron.c @@ -138,10 +138,6 @@ static struct scsi_host_template jmicron_sht = { .slave_destroy = ata_scsi_slave_destroy, /* Use standard CHS mapping rules */ .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static const struct ata_port_operations jmicron_ops = { diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c index 837b7fe77dc7..2745e23cac43 100644 --- a/drivers/ata/pata_marvell.c +++ b/drivers/ata/pata_marvell.c @@ -107,10 +107,6 @@ static struct scsi_host_template marvell_sht = { .slave_destroy = ata_scsi_slave_destroy, /* Use standard CHS mapping rules */ .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static const struct ata_port_operations marvell_ops = { diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c index 9587a89f9683..368fac7d168b 100644 --- a/drivers/ata/pata_mpc52xx.c +++ b/drivers/ata/pata_mpc52xx.c @@ -280,10 +280,6 @@ static struct scsi_host_template mpc52xx_ata_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static struct ata_port_operations mpc52xx_ata_port_ops = { diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c index 3bfbd495f643..4ea42838297e 100644 --- a/drivers/ata/pata_mpiix.c +++ b/drivers/ata/pata_mpiix.c @@ -165,10 +165,6 @@ static struct scsi_host_template mpiix_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations mpiix_port_ops = { diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c index dbba5b77d79c..f15eb34fb1fc 100644 --- a/drivers/ata/pata_netcell.c +++ b/drivers/ata/pata_netcell.c @@ -37,10 +37,6 @@ static struct scsi_host_template netcell_sht = { .slave_destroy = ata_scsi_slave_destroy, /* Use standard CHS mapping rules */ .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static const struct ata_port_operations netcell_ops = { diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c index ebc58a907d26..d5eb42bdae9a 100644 --- a/drivers/ata/pata_ns87410.c +++ b/drivers/ata/pata_ns87410.c @@ -158,10 +158,6 @@ static struct scsi_host_template ns87410_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations ns87410_port_ops = { diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c index 4d75d32e5826..d59002e7528d 100644 --- a/drivers/ata/pata_oldpiix.c +++ b/drivers/ata/pata_oldpiix.c @@ -234,10 +234,6 @@ static struct scsi_host_template oldpiix_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static const struct ata_port_operations oldpiix_pata_ops = { diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c index 0af8a2c77cc9..944b7084b459 100644 --- a/drivers/ata/pata_opti.c +++ b/drivers/ata/pata_opti.c @@ -179,10 +179,6 @@ static struct scsi_host_template opti_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations opti_port_ops = { diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c index 2843e480f216..875ac4a49dd7 100644 --- a/drivers/ata/pata_optidma.c +++ b/drivers/ata/pata_optidma.c @@ -363,10 +363,6 @@ static struct scsi_host_template optidma_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations optidma_port_ops = { diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c index ee636beb05e1..3e204c329d51 100644 --- a/drivers/ata/pata_pdc202xx_old.c +++ b/drivers/ata/pata_pdc202xx_old.c @@ -244,10 +244,6 @@ static struct scsi_host_template pdc202xx_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations pdc2024x_port_ops = { diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c index 1c54673e008d..bc01b17a00c2 100644 --- a/drivers/ata/pata_radisys.c +++ b/drivers/ata/pata_radisys.c @@ -200,10 +200,6 @@ static struct scsi_host_template radisys_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static const struct ata_port_operations radisys_pata_ops = { diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c index 85c45290eeee..97785b4f1efa 100644 --- a/drivers/ata/pata_rz1000.c +++ b/drivers/ata/pata_rz1000.c @@ -40,7 +40,7 @@ static int rz1000_set_mode(struct ata_port *ap, struct ata_device **unused) for (i = 0; i < ATA_MAX_DEVICES; i++) { struct ata_device *dev = &ap->device[i]; - if (ata_dev_ready(dev)) { + if (ata_dev_enabled(dev)) { /* We don't really care */ dev->pio_mode = XFER_PIO_0; dev->xfer_mode = XFER_PIO_0; @@ -69,10 +69,6 @@ static struct scsi_host_template rz1000_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations rz1000_port_ops = { diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c index 66e8ff467c8d..2af9f8c8bd1f 100644 --- a/drivers/ata/pata_sc1200.c +++ b/drivers/ata/pata_sc1200.c @@ -194,10 +194,6 @@ static struct scsi_host_template sc1200_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations sc1200_port_ops = { diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c index 203f463ac39f..cca3aa225efe 100644 --- a/drivers/ata/pata_scc.c +++ b/drivers/ata/pata_scc.c @@ -984,10 +984,6 @@ static struct scsi_host_template scc_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static const struct ata_port_operations scc_pata_ops = { diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c index b6e020383dd9..8bbe4266f760 100644 --- a/drivers/ata/pata_serverworks.c +++ b/drivers/ata/pata_serverworks.c @@ -315,10 +315,6 @@ static struct scsi_host_template serverworks_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations serverworks_osb4_port_ops = { diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index a5886f061c0b..8c0b25f145ae 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c @@ -232,10 +232,6 @@ static struct scsi_host_template sil680_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static struct ata_port_operations sil680_port_ops = { diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c index f5838cc11728..9b3774a4775a 100644 --- a/drivers/ata/pata_sis.c +++ b/drivers/ata/pata_sis.c @@ -524,10 +524,6 @@ static struct scsi_host_template sis_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static const struct ata_port_operations sis_133_ops = { diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c index 349887bf5b93..045f9d2832df 100644 --- a/drivers/ata/pata_triflex.c +++ b/drivers/ata/pata_triflex.c @@ -194,10 +194,6 @@ static struct scsi_host_template triflex_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations triflex_port_ops = { diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index 362beb2f489c..3740644e7f43 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c @@ -301,10 +301,6 @@ static struct scsi_host_template via_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .resume = ata_scsi_device_resume, - .suspend = ata_scsi_device_suspend, -#endif }; static struct ata_port_operations via_port_ops = { diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c index b3b62e985f19..bda5e7747c21 100644 --- a/drivers/ata/sata_inic162x.c +++ b/drivers/ata/sata_inic162x.c @@ -135,10 +135,6 @@ static struct scsi_host_template inic_sht = { .slave_configure = inic_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static const int scr_map[] = { diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index a097595d4dc7..6962f8e492f5 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c @@ -325,10 +325,6 @@ static struct scsi_host_template nv_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static struct scsi_host_template nv_adma_sht = { @@ -347,10 +343,6 @@ static struct scsi_host_template nv_adma_sht = { .slave_configure = nv_adma_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static const struct ata_port_operations nv_generic_ops = { diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c index 0a1e417f309c..e8483aadd11b 100644 --- a/drivers/ata/sata_sil.c +++ b/drivers/ata/sata_sil.c @@ -182,10 +182,6 @@ static struct scsi_host_template sil_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static const struct ata_port_operations sil_ops = { diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c index b97ee9f31aec..a69d78cd8e9b 100644 --- a/drivers/ata/sata_sil24.c +++ b/drivers/ata/sata_sil24.c @@ -380,10 +380,6 @@ static struct scsi_host_template sil24_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static const struct ata_port_operations sil24_ops = { diff --git a/include/linux/libata.h b/include/linux/libata.h index 7906d750aa77..8a7cc13c8516 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -140,7 +140,6 @@ enum { ATA_DFLAG_PIO = (1 << 8), /* device limited to PIO mode */ ATA_DFLAG_NCQ_OFF = (1 << 9), /* device limited to non-NCQ mode */ - ATA_DFLAG_SUSPENDED = (1 << 10), /* device suspended */ ATA_DFLAG_INIT_MASK = (1 << 16) - 1, ATA_DFLAG_DETACH = (1 << 16), @@ -268,13 +267,9 @@ enum { ATA_EH_REVALIDATE = (1 << 0), ATA_EH_SOFTRESET = (1 << 1), ATA_EH_HARDRESET = (1 << 2), - ATA_EH_SUSPEND = (1 << 3), - ATA_EH_RESUME = (1 << 4), - ATA_EH_PM_FREEZE = (1 << 5), ATA_EH_RESET_MASK = ATA_EH_SOFTRESET | ATA_EH_HARDRESET, - ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE | ATA_EH_SUSPEND | - ATA_EH_RESUME | ATA_EH_PM_FREEZE, + ATA_EH_PERDEV_MASK = ATA_EH_REVALIDATE, /* ata_eh_info->flags */ ATA_EHI_HOTPLUGGED = (1 << 0), /* could have been hotplugged */ @@ -736,8 +731,6 @@ extern int sata_scr_write_flush(struct ata_port *ap, int reg, u32 val); extern int ata_port_online(struct ata_port *ap); extern int ata_port_offline(struct ata_port *ap); #ifdef CONFIG_PM -extern int ata_scsi_device_resume(struct scsi_device *); -extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t mesg); extern int ata_host_suspend(struct ata_host *host, pm_message_t mesg); extern void ata_host_resume(struct ata_host *host); #endif @@ -1008,11 +1001,6 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev) return ata_class_absent(dev->class); } -static inline unsigned int ata_dev_ready(const struct ata_device *dev) -{ - return ata_dev_enabled(dev) && !(dev->flags & ATA_DFLAG_SUSPENDED); -} - /* * port helpers */ From 920a4b1038e442700a1cfac77ea7e20bd615a2c3 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 4 May 2007 21:28:48 +0200 Subject: [PATCH 02/14] libata: implement libata.spindown_compat Now that libata uses sd->manage_start_stop, libata spins down disk on shutdown. In an attempt to compensate libata's previous shortcoming, some distros sync and spin down disks attached via libata in their shutdown(8). Some disks spin back up just to spin down again on STANDBYNOW1 if the command is issued when the disk is spun down, so this double spinning down causes problem. This patch implements module parameter libata.spindown_compat which, when set to one (default value), prevents libata from spinning down disks on shutdown thus avoiding double spinning down. Note that libata spins down disks for suspend to mem and disk, so with libata.spindown_compat set to one, disks should be properly spun down in all cases without modifying shutdown(8). shutdown(8) should be fixed eventually. Some drive do spin up on SYNCHRONZE_CACHE even when their cache is clean. Those disks currently spin up briefly when sd tries to shutdown the device and then the machine powers off immediately, which can't be good for the head. We can't skip SYNCHRONIZE_CACHE during shudown as it can be dangerous data integrity-wise. So, this spindown_compat parameter is already scheduled for removal by the end of the next year and here's what shutdown(8) should do. * Check whether /sys/modules/libata/parameters/spindown_compat exists. If it does, write 0 to it. * For each libata harddisk { * Check whether /sys/class/scsi_disk/h:c:i:l/manage_start_stop exists. Iff it doesn't, synchronize cache and spin the disk down as before. } The above procedure will make shutdown(8) work properly with kernels before this change, ones with this workaround and later ones without it. To accelerate shutdown(8) updates, if the compat mode is in use, this patch prints BIG FAT warning for five seconds during shutdown (the optimal interval to annoy the user just the right amount discovered by hours of tireless usability testing). Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- Documentation/feature-removal-schedule.txt | 19 +++++++++++++++ drivers/ata/libata-core.c | 6 +++++ drivers/ata/libata-scsi.c | 28 +++++++++++++++++++++- drivers/ata/libata.h | 1 + 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index c6322c760348..498ff31f3aa1 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt @@ -328,3 +328,22 @@ Who: Adrian Bunk --------------------------- +What: libata.spindown_compat module parameter +When: Dec 2008 +Why: halt(8) synchronizes caches for and spins down libata disks + because libata didn't use to spin down disk on system halt + (only synchronized caches). + Spin down on system halt is now implemented and can be tested + using sysfs node /sys/class/scsi_disk/h:c:i:l/manage_start_stop. + Because issuing spin down command to an already spun down disk + makes some disks spin up just to spin down again, the old + behavior needs to be maintained till userspace tool is updated + to check the sysfs node and not to spin down disks with the + node set to one. + This module parameter is to give userspace tool the time to + get updated and should be removed after userspace is + reasonably updated. +Who: Tejun Heo + +--------------------------- + diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 2e2a2fa8e9e9..bf8f65b09591 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -101,6 +101,12 @@ int libata_noacpi = 1; module_param_named(noacpi, libata_noacpi, int, 0444); MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set"); +int ata_spindown_compat = 1; +module_param_named(spindown_compat, ata_spindown_compat, int, 0644); +MODULE_PARM_DESC(spindown_compat, "Enable backward compatible spindown " + "behavior. Will be removed. More info can be found in " + "Documentation/feature-removal-schedule.txt\n"); + MODULE_AUTHOR("Jeff Garzik"); MODULE_DESCRIPTION("Library module for ATA devices"); MODULE_LICENSE("GPL"); diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 8f800196d596..dd81fa78cdcf 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -944,9 +944,35 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc) } tf->command = ATA_CMD_VERIFY; /* READ VERIFY */ - } else + } else { + /* XXX: This is for backward compatibility, will be + * removed. Read Documentation/feature-removal-schedule.txt + * for more info. + */ + if (ata_spindown_compat && + (system_state == SYSTEM_HALT || + system_state == SYSTEM_POWER_OFF)) { + static int warned = 0; + + if (!warned) { + spin_unlock_irq(qc->ap->lock); + ata_dev_printk(qc->dev, KERN_WARNING, + "DISK MIGHT NOT BE SPUN DOWN PROPERLY. " + "UPDATE SHUTDOWN UTILITY\n"); + ata_dev_printk(qc->dev, KERN_WARNING, + "For more info, visit " + "http://linux-ata.org/shutdown.html\n"); + warned = 1; + ssleep(5); + spin_lock_irq(qc->ap->lock); + } + scmd->result = SAM_STAT_GOOD; + return 1; + } + /* Issue ATA STANDBY IMMEDIATE command */ tf->command = ATA_CMD_STANDBYNOW1; + } /* * Standby and Idle condition timers could be implemented but that diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 5f4d40cd3288..316bf8ae4536 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h @@ -58,6 +58,7 @@ extern int atapi_enabled; extern int atapi_dmadir; extern int libata_fua; extern int libata_noacpi; +extern int ata_spindown_compat; extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, u64 block, u32 n_block, unsigned int tf_flags, From 1626aeb881236c8cb022b5e4ca594146a951d669 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 4 May 2007 12:43:58 +0200 Subject: [PATCH 03/14] libata: clean up SFF init mess The intention of using port_mask in SFF init helpers was to eventually support exoctic configurations such as combination of legacy and native port on the same controller. This never became actually necessary and the related code always has been subtly broken one way or the other. Now that new init model is in place, there is no reason to make common helpers capable of handling all corner cases. Exotic cases can simply dealt within LLDs as necessary. This patch removes port_mask handling in SFF init helpers. SFF init helpers don't take n_ports argument and interpret it into port_mask anymore. All information is carried via port_info. n_ports argument is dropped and always two ports are allocated. LLD can tell SFF to skip certain port by marking it dummy. Note that SFF code has been treating unuvailable ports this way for a long time until recent breakage fix from Linus and is consistent with how other drivers handle with unavailable ports. This fixes 1-port legacy host handling still broken after the recent native mode fix and simplifies SFF init logic. The following changes are made... * ata_pci_init_native_host() and ata_init_legacy_host() both now try to initialized whatever they can and mark failed ports dummy. They return 0 if any port is successfully initialized. * ata_pci_prepare_native_host() and ata_pci_init_one() now doesn't take n_ports argument. All info should be specified via port_info array. Always two ports are allocated. * ata_pci_init_bmdma() exported to be used by LLDs in exotic cases. * port_info handling in all LLDs are standardized - all port_info arrays are const stack variable named ppi. Unless the second port is different from the first, its port_info is specified as NULL (tells libata that it's identical to the last non-NULL port_info). * pata_hpt37x/hpt3x2n: don't modify static variable directly. Make an on-stack copy instead as ata_piix does. * pata_uli: It has 4 ports instead of 2. Don't use ata_pci_prepare_native_host(). Allocate the host explicitly and use init helpers. It's simple enough. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/ata_generic.c | 6 +- drivers/ata/ata_piix.c | 4 +- drivers/ata/libata-core.c | 1 + drivers/ata/libata-sff.c | 162 ++++++++++++++++---------------- drivers/ata/pata_ali.c | 32 +++---- drivers/ata/pata_amd.c | 9 +- drivers/ata/pata_artop.c | 25 +++-- drivers/ata/pata_atiixp.c | 6 +- drivers/ata/pata_cmd640.c | 7 +- drivers/ata/pata_cmd64x.c | 13 +-- drivers/ata/pata_cs5530.c | 10 +- drivers/ata/pata_cs5535.c | 6 +- drivers/ata/pata_cypress.c | 6 +- drivers/ata/pata_efar.c | 6 +- drivers/ata/pata_hpt366.c | 13 +-- drivers/ata/pata_hpt37x.c | 33 ++++--- drivers/ata/pata_hpt3x2n.c | 13 ++- drivers/ata/pata_hpt3x3.c | 6 +- drivers/ata/pata_it8213.c | 8 +- drivers/ata/pata_it821x.c | 12 +-- drivers/ata/pata_jmicron.c | 6 +- drivers/ata/pata_marvell.c | 11 +-- drivers/ata/pata_netcell.c | 6 +- drivers/ata/pata_ns87410.c | 6 +- drivers/ata/pata_oldpiix.c | 6 +- drivers/ata/pata_opti.c | 6 +- drivers/ata/pata_optidma.c | 12 +-- drivers/ata/pata_pdc202xx_old.c | 8 +- drivers/ata/pata_radisys.c | 6 +- drivers/ata/pata_rz1000.c | 12 +-- drivers/ata/pata_sc1200.c | 8 +- drivers/ata/pata_serverworks.c | 15 ++- drivers/ata/pata_sil680.c | 10 +- drivers/ata/pata_sis.c | 29 +++--- drivers/ata/pata_sl82c105.c | 17 ++-- drivers/ata/pata_triflex.c | 6 +- drivers/ata/pata_via.c | 32 +++---- drivers/ata/sata_nv.c | 8 +- drivers/ata/sata_sis.c | 6 +- drivers/ata/sata_uli.c | 22 ++++- drivers/ata/sata_via.c | 2 +- drivers/ata/sis.h | 2 +- include/linux/libata.h | 14 +-- 43 files changed, 313 insertions(+), 315 deletions(-) diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c index 0f19e3223358..c3d753296bc6 100644 --- a/drivers/ata/ata_generic.c +++ b/drivers/ata/ata_generic.c @@ -141,7 +141,7 @@ static int all_generic_ide; /* Set to claim all devices */ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) { u16 command; - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &generic_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -149,7 +149,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id .udma_mask = 0x3f, .port_ops = &generic_port_ops }; - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; /* Don't use the generic entry unless instructed to do so */ if (id->driver_data == 1 && all_generic_ide == 0) @@ -175,7 +175,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id if (dev->vendor == PCI_VENDOR_ID_AL) ata_pci_clear_simplex(dev); - return ata_pci_init_one(dev, port_info, 2); + return ata_pci_init_one(dev, ppi); } static struct pci_device_id ata_generic[] = { diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c index 4f5a0dc7fb9c..13b6b1df2ac4 100644 --- a/drivers/ata/ata_piix.c +++ b/drivers/ata/ata_piix.c @@ -1030,7 +1030,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) static int printed_version; struct device *dev = &pdev->dev; struct ata_port_info port_info[2]; - struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; + const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] }; struct piix_host_priv *hpriv; unsigned long port_flags; @@ -1089,7 +1089,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) port_info[1].mwdma_mask = 0; port_info[1].udma_mask = 0; } - return ata_pci_init_one(pdev, ppinfo, 2); + return ata_pci_init_one(pdev, ppi); } static int __init piix_init(void) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index bf8f65b09591..9cff5c506573 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -6856,6 +6856,7 @@ EXPORT_SYMBOL_GPL(ata_timing_merge); #ifdef CONFIG_PCI EXPORT_SYMBOL_GPL(pci_test_config_bits); EXPORT_SYMBOL_GPL(ata_pci_init_native_host); +EXPORT_SYMBOL_GPL(ata_pci_init_bmdma); EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host); EXPORT_SYMBOL_GPL(ata_pci_init_one); EXPORT_SYMBOL_GPL(ata_pci_remove_one); diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index d211db6b35a2..e35d13466c69 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c @@ -544,7 +544,7 @@ static int ata_resources_present(struct pci_dev *pdev, int port) * RETURNS: * 0 on success, -errno otherwise. */ -static int ata_pci_init_bmdma(struct ata_host *host) +int ata_pci_init_bmdma(struct ata_host *host) { struct device *gdev = host->dev; struct pci_dev *pdev = to_pci_dev(gdev); @@ -566,7 +566,7 @@ static int ata_pci_init_bmdma(struct ata_host *host) } host->iomap = pcim_iomap_table(pdev); - for (i = 0; i < host->n_ports; i++) { + for (i = 0; i < 2; i++) { struct ata_port *ap = host->ports[i]; void __iomem *bmdma = host->iomap[4] + 8 * i; @@ -585,54 +585,52 @@ static int ata_pci_init_bmdma(struct ata_host *host) /** * ata_pci_init_native_host - acquire native ATA resources and init host * @host: target ATA host - * @port_mask: ports to consider * - * Acquire native PCI ATA resources for @host and initialize - * @host accordoingly. + * Acquire native PCI ATA resources for @host and initialize the + * first two ports of @host accordingly. Ports marked dummy are + * skipped and allocation failure makes the port dummy. * * LOCKING: * Inherited from calling layer (may sleep). * * RETURNS: - * 0 on success, -errno otherwise. + * 0 if at least one port is initialized, -ENODEV if no port is + * available. */ -int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) +int ata_pci_init_native_host(struct ata_host *host) { struct device *gdev = host->dev; struct pci_dev *pdev = to_pci_dev(gdev); + unsigned int mask = 0; int i, rc; - /* Discard disabled ports. Some controllers show their unused - * channels this way. Disabled ports are made dummy. - */ - for (i = 0; i < 2; i++) { - if ((port_mask & (1 << i)) && !ata_resources_present(pdev, i)) { - host->ports[i]->ops = &ata_dummy_port_ops; - port_mask &= ~(1 << i); - } - } - - if (!port_mask) { - dev_printk(KERN_ERR, gdev, "no available port\n"); - return -ENODEV; - } - /* request, iomap BARs and init port addresses accordingly */ for (i = 0; i < 2; i++) { struct ata_port *ap = host->ports[i]; int base = i * 2; void __iomem * const *iomap; - if (!(port_mask & (1 << i))) + if (ata_port_is_dummy(ap)) continue; + /* Discard disabled ports. Some controllers show + * their unused channels this way. Disabled ports are + * made dummy. + */ + if (!ata_resources_present(pdev, i)) { + ap->ops = &ata_dummy_port_ops; + continue; + } + rc = pcim_iomap_regions(pdev, 0x3 << base, DRV_NAME); if (rc) { - dev_printk(KERN_ERR, gdev, "failed to request/iomap " - "BARs for port %d (errno=%d)\n", i, rc); + dev_printk(KERN_WARNING, gdev, + "failed to request/iomap BARs for port %d " + "(errno=%d)\n", i, rc); if (rc == -EBUSY) pcim_pin_device(pdev); - return rc; + ap->ops = &ata_dummy_port_ops; + continue; } host->iomap = iomap = pcim_iomap_table(pdev); @@ -641,6 +639,13 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) ap->ioaddr.ctl_addr = (void __iomem *) ((unsigned long)iomap[base + 1] | ATA_PCI_CTL_OFS); ata_std_ports(&ap->ioaddr); + + mask |= 1 << i; + } + + if (!mask) { + dev_printk(KERN_ERR, gdev, "no available native port\n"); + return -ENODEV; } return 0; @@ -649,8 +654,7 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) /** * ata_pci_prepare_native_host - helper to prepare native PCI ATA host * @pdev: target PCI device - * @ppi: array of port_info - * @n_ports: number of ports to allocate + * @ppi: array of port_info, must be enough for two ports * @r_host: out argument for the initialized ATA host * * Helper to allocate ATA host for @pdev, acquire all native PCI @@ -664,10 +668,9 @@ int ata_pci_init_native_host(struct ata_host *host, unsigned int port_mask) */ int ata_pci_prepare_native_host(struct pci_dev *pdev, const struct ata_port_info * const * ppi, - int n_ports, struct ata_host **r_host) + struct ata_host **r_host) { struct ata_host *host; - unsigned int port_mask; int rc; if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) @@ -681,11 +684,7 @@ int ata_pci_prepare_native_host(struct pci_dev *pdev, goto err_out; } - port_mask = ATA_PORT_PRIMARY; - if (n_ports > 1) - port_mask |= ATA_PORT_SECONDARY; - - rc = ata_pci_init_native_host(host, port_mask); + rc = ata_pci_init_native_host(host); if (rc) goto err_out; @@ -777,8 +776,11 @@ static int ata_init_legacy_port(struct ata_port *ap, /* iomap cmd and ctl ports */ legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8); legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1); - if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) + if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) { + dev_printk(KERN_WARNING, host->dev, + "failed to map cmd/ctl ports\n"); return -ENOMEM; + } /* init IO addresses */ ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no]; @@ -792,19 +794,20 @@ static int ata_init_legacy_port(struct ata_port *ap, /** * ata_init_legacy_host - acquire legacy ATA resources and init ATA host * @host: target ATA host - * @legacy_mask: out parameter, mask indicating ports is in legacy mode * @was_busy: out parameter, indicates whether any port was busy * - * Acquire legacy ATA resources for ports. + * Acquire legacy ATA resources for the first two ports of @host + * and initialize it accordingly. Ports marked dummy are skipped + * and resource acquistion failure makes the port dummy. * * LOCKING: * Inherited from calling layer (may sleep). * * RETURNS: - * 0 on success, -errno otherwise. + * 0 if at least one port is initialized, -ENODEV if no port is + * available. */ -static int ata_init_legacy_host(struct ata_host *host, - unsigned int *legacy_mask, int *was_busy) +static int ata_init_legacy_host(struct ata_host *host, int *was_busy) { struct device *gdev = host->dev; struct ata_legacy_devres *legacy_dr; @@ -821,22 +824,23 @@ static int ata_init_legacy_host(struct ata_host *host, devres_add(gdev, legacy_dr); for (i = 0; i < 2; i++) { - *legacy_mask &= ~(1 << i); + if (ata_port_is_dummy(host->ports[i])) + continue; + rc = ata_init_legacy_port(host->ports[i], legacy_dr); if (rc == 0) legacy_dr->mask |= 1 << i; - else if (rc == -EBUSY) - (*was_busy)++; + else { + if (rc == -EBUSY) + (*was_busy)++; + host->ports[i]->ops = &ata_dummy_port_ops; + } } - if (!legacy_dr->mask) - return -EBUSY; - - for (i = 0; i < 2; i++) - if (!(legacy_dr->mask & (1 << i))) - host->ports[i]->ops = &ata_dummy_port_ops; - - *legacy_mask |= legacy_dr->mask; + if (!legacy_dr->mask) { + dev_printk(KERN_ERR, gdev, "no available legacy port\n"); + return -ENODEV; + } devres_remove_group(gdev, NULL); return 0; @@ -875,7 +879,7 @@ static int ata_request_legacy_irqs(struct ata_host *host, legacy_dr = devres_find(host->dev, ata_legacy_release, NULL, NULL); BUG_ON(!legacy_dr); - for (i = 0; i < host->n_ports; i++) { + for (i = 0; i < 2; i++) { unsigned int irq; /* FIXME: ATA_*_IRQ() should take generic device not pci_dev */ @@ -923,8 +927,7 @@ static int ata_request_legacy_irqs(struct ata_host *host, /** * ata_pci_init_one - Initialize/register PCI IDE host controller * @pdev: Controller to be initialized - * @port_info: Information from low-level host driver - * @n_ports: Number of ports attached to host controller + * @ppi: array of port_info, must be enough for two ports * * This is a helper function which can be called from a driver's * xxx_init_one() probe function if the hardware uses traditional @@ -944,27 +947,35 @@ static int ata_request_legacy_irqs(struct ata_host *host, * RETURNS: * Zero on success, negative on errno-based value on error. */ - -int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, - unsigned int n_ports) +int ata_pci_init_one(struct pci_dev *pdev, + const struct ata_port_info * const * ppi) { struct device *dev = &pdev->dev; + const struct ata_port_info *pi = NULL; struct ata_host *host = NULL; - const struct ata_port_info *port[2]; u8 mask; - unsigned int legacy_mode = 0; - int rc; + int legacy_mode = 0; + int i, rc; DPRINTK("ENTER\n"); + /* look up the first valid port_info */ + for (i = 0; i < 2 && ppi[i]; i++) { + if (ppi[i]->port_ops != &ata_dummy_port_ops) { + pi = ppi[i]; + break; + } + } + + if (!pi) { + dev_printk(KERN_ERR, &pdev->dev, + "no valid port_info specified\n"); + return -EINVAL; + } + if (!devres_open_group(dev, NULL, GFP_KERNEL)) return -ENOMEM; - BUG_ON(n_ports < 1 || n_ports > 2); - - port[0] = port_info[0]; - port[1] = (n_ports > 1) ? port_info[1] : NULL; - /* FIXME: Really for ATA it isn't safe because the device may be multi-purpose and we want to leave it alone if it was already enabled. Secondly for shared use as Arjan says we want refcounting @@ -984,7 +995,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, pci_read_config_byte(pdev, PCI_CLASS_PROG, &tmp8); mask = (1 << 2) | (1 << 0); if ((tmp8 & mask) != mask) - legacy_mode = (1 << 3); + legacy_mode = 1; #if defined(CONFIG_NO_ATA_LEGACY) /* Some platforms with PCI limits cannot address compat port space. In that case we punt if their firmware has @@ -998,7 +1009,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, } /* alloc and init host */ - host = ata_host_alloc_pinfo(dev, port, n_ports); + host = ata_host_alloc_pinfo(dev, ppi, 2); if (!host) { dev_printk(KERN_ERR, &pdev->dev, "failed to allocate ATA host\n"); @@ -1007,19 +1018,13 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, } if (!legacy_mode) { - unsigned int port_mask; - - port_mask = ATA_PORT_PRIMARY; - if (n_ports > 1) - port_mask |= ATA_PORT_SECONDARY; - - rc = ata_pci_init_native_host(host, port_mask); + rc = ata_pci_init_native_host(host); if (rc) goto err_out; } else { int was_busy = 0; - rc = ata_init_legacy_host(host, &legacy_mode, &was_busy); + rc = ata_init_legacy_host(host, &was_busy); if (was_busy) pcim_pin_device(pdev); if (rc) @@ -1040,8 +1045,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, goto err_out; if (!legacy_mode) - rc = devm_request_irq(dev, pdev->irq, - port_info[0]->port_ops->irq_handler, + rc = devm_request_irq(dev, pdev->irq, pi->port_ops->irq_handler, IRQF_SHARED, DRV_NAME, host); else { irq_handler_t handler[2] = { host->ops->irq_handler, @@ -1055,7 +1059,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, goto err_out; /* register */ - rc = ata_host_register(host, port_info[0]->sht); + rc = ata_host_register(host, pi->sht); if (rc) goto err_out; diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c index 48c7531ae690..3c55a5ff74c7 100644 --- a/drivers/ata/pata_ali.c +++ b/drivers/ata/pata_ali.c @@ -518,14 +518,14 @@ static void ali_init_chipset(struct pci_dev *pdev) static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static struct ata_port_info info_early = { + static const struct ata_port_info info_early = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &ali_early_port_ops }; /* Revision 0x20 added DMA */ - static struct ata_port_info info_20 = { + static const struct ata_port_info info_20 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -533,7 +533,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_20_port_ops }; /* Revision 0x20 with support logic added UDMA */ - static struct ata_port_info info_20_udma = { + static const struct ata_port_info info_20_udma = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -542,7 +542,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_20_port_ops }; /* Revision 0xC2 adds UDMA66 */ - static struct ata_port_info info_c2 = { + static const struct ata_port_info info_c2 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -551,7 +551,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_c2_port_ops }; /* Revision 0xC3 is UDMA100 */ - static struct ata_port_info info_c3 = { + static const struct ata_port_info info_c3 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -560,7 +560,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_c2_port_ops }; /* Revision 0xC4 is UDMA133 */ - static struct ata_port_info info_c4 = { + static const struct ata_port_info info_c4 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48, .pio_mask = 0x1f, @@ -569,7 +569,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_c2_port_ops }; /* Revision 0xC5 is UDMA133 with LBA48 DMA */ - static struct ata_port_info info_c5 = { + static const struct ata_port_info info_c5 = { .sht = &ali_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -578,7 +578,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &ali_c5_port_ops }; - static struct ata_port_info *port_info[2]; + const struct ata_port_info *ppi[] = { NULL, NULL }; u8 rev, tmp; struct pci_dev *isa_bridge; @@ -590,17 +590,17 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) */ if (rev < 0x20) { - port_info[0] = port_info[1] = &info_early; + ppi[0] = &info_early; } else if (rev < 0xC2) { - port_info[0] = port_info[1] = &info_20; + ppi[0] = &info_20; } else if (rev == 0xC2) { - port_info[0] = port_info[1] = &info_c2; + ppi[0] = &info_c2; } else if (rev == 0xC3) { - port_info[0] = port_info[1] = &info_c3; + ppi[0] = &info_c3; } else if (rev == 0xC4) { - port_info[0] = port_info[1] = &info_c4; + ppi[0] = &info_c4; } else - port_info[0] = port_info[1] = &info_c5; + ppi[0] = &info_c5; ali_init_chipset(pdev); @@ -609,10 +609,10 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id) /* Are we paired with a UDMA capable chip */ pci_read_config_byte(isa_bridge, 0x5E, &tmp); if ((tmp & 0x1E) == 0x12) - port_info[0] = port_info[1] = &info_20_udma; + ppi[0] = &info_20_udma; pci_dev_put(isa_bridge); } - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c index 86a26186739c..b439351f1fd3 100644 --- a/drivers/ata/pata_amd.c +++ b/drivers/ata/pata_amd.c @@ -538,7 +538,7 @@ static struct ata_port_operations nv133_port_ops = { static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static struct ata_port_info info[10] = { + static const struct ata_port_info info[10] = { { /* 0: AMD 7401 */ .sht = &amd_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -620,7 +620,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &amd100_port_ops } }; - static struct ata_port_info *port_info[2]; + const struct ata_port_info *ppi[] = { NULL, NULL }; static int printed_version; int type = id->driver_data; u8 rev; @@ -652,9 +652,8 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ata_pci_clear_simplex(pdev); /* And fire it up */ - - port_info[0] = port_info[1] = &info[type]; - return ata_pci_init_one(pdev, port_info, 2); + ppi[0] = &info[type]; + return ata_pci_init_one(pdev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c index ef51940c3adb..9861059dd673 100644 --- a/drivers/ata/pata_artop.c +++ b/drivers/ata/pata_artop.c @@ -414,7 +414,7 @@ static const struct ata_port_operations artop6260_ops = { static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) { static int printed_version; - static struct ata_port_info info_6210 = { + static const struct ata_port_info info_6210 = { .sht = &artop_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -422,7 +422,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = ATA_UDMA2, .port_ops = &artop6210_ops, }; - static struct ata_port_info info_626x = { + static const struct ata_port_info info_626x = { .sht = &artop_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -430,7 +430,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = ATA_UDMA4, .port_ops = &artop6260_ops, }; - static struct ata_port_info info_626x_fast = { + static const struct ata_port_info info_626x_fast = { .sht = &artop_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -438,32 +438,30 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = ATA_UDMA5, .port_ops = &artop6260_ops, }; - struct ata_port_info *port_info[2]; - struct ata_port_info *info = NULL; - int ports = 2; + const struct ata_port_info *ppi[] = { NULL, NULL }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); if (id->driver_data == 0) { /* 6210 variant */ - info = &info_6210; + ppi[0] = &info_6210; + ppi[1] = &ata_dummy_port_info; /* BIOS may have left us in UDMA, clear it before libata probe */ pci_write_config_byte(pdev, 0x54, 0); /* For the moment (also lacks dsc) */ printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n"); printk(KERN_WARNING "Secondary ATA ports will not be activated.\n"); - ports = 1; } else if (id->driver_data == 1) /* 6260 */ - info = &info_626x; + ppi[0] = &info_626x; else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ unsigned long io = pci_resource_start(pdev, 4); u8 reg; - info = &info_626x; + ppi[0] = &info_626x; if (inb(io) & 0x10) - info = &info_626x_fast; + ppi[0] = &info_626x_fast; /* Mac systems come up with some registers not set as we will need them */ @@ -484,10 +482,9 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id) } - BUG_ON(info == NULL); + BUG_ON(ppi[0] == NULL); - port_info[0] = port_info[1] = info; - return ata_pci_init_one(pdev, port_info, ports); + return ata_pci_init_one(pdev, ppi); } static const struct pci_device_id artop_pci_tbl[] = { diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c index 3c2264dbdd67..844914681a2a 100644 --- a/drivers/ata/pata_atiixp.c +++ b/drivers/ata/pata_atiixp.c @@ -268,7 +268,7 @@ static struct ata_port_operations atiixp_port_ops = { static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &atiixp_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -276,8 +276,8 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x3F, .port_ops = &atiixp_port_ops }; - static struct ata_port_info *port_info[2] = { &info, &info }; - return ata_pci_init_one(dev, port_info, 2); + const struct ata_port_info *ppi[] = { &info, NULL }; + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id atiixp[] = { diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c index 987dec935b5c..ed00fa9d53be 100644 --- a/drivers/ata/pata_cmd640.c +++ b/drivers/ata/pata_cmd640.c @@ -249,17 +249,16 @@ static void cmd640_hardware_init(struct pci_dev *pdev) static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &cmd640_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &cmd640_port_ops }; - - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; cmd640_hardware_init(pdev); - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } static int cmd640_reinit_one(struct pci_dev *pdev) diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c index 3e02c6a3ba9c..2a79b335cfcc 100644 --- a/drivers/ata/pata_cmd64x.c +++ b/drivers/ata/pata_cmd64x.c @@ -377,7 +377,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { u32 class_rev; - static struct ata_port_info cmd_info[6] = { + static const struct ata_port_info cmd_info[6] = { { /* CMD 643 - no UDMA */ .sht = &cmd64x_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -424,11 +424,9 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &cmd648_port_ops } }; - static struct ata_port_info *port_info[2], *info; + const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL }; u8 mrdmode; - info = &cmd_info[id->driver_data]; - pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev); class_rev &= 0xFF; @@ -438,10 +436,10 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) if (pdev->device == PCI_DEVICE_ID_CMD_646) { /* Does UDMA work ? */ if (class_rev > 4) - info = &cmd_info[2]; + ppi[0] = &cmd_info[2]; /* Early rev with other problems ? */ else if (class_rev == 1) - info = &cmd_info[3]; + ppi[0] = &cmd_info[3]; } pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64); @@ -457,8 +455,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) pci_write_config_byte(pdev, UDIDETCR0, 0xF0); #endif - port_info[0] = port_info[1] = info; - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c index 637d8b302e3e..1b67923d7a4e 100644 --- a/drivers/ata/pata_cs5530.c +++ b/drivers/ata/pata_cs5530.c @@ -335,7 +335,7 @@ fail_put: static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &cs5530_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -344,23 +344,23 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &cs5530_port_ops }; /* The docking connector doesn't do UDMA, and it seems not MWDMA */ - static struct ata_port_info info_palmax_secondary = { + static const struct ata_port_info info_palmax_secondary = { .sht = &cs5530_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &cs5530_port_ops }; - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; /* Chip initialisation */ if (cs5530_init_chip()) return -ENODEV; if (cs5530_is_palmax()) - port_info[1] = &info_palmax_secondary; + ppi[1] = &info_palmax_secondary; /* Now kick off ATA set up */ - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c index 683885a47b6d..f37d4cd812a1 100644 --- a/drivers/ata/pata_cs5535.c +++ b/drivers/ata/pata_cs5535.c @@ -223,7 +223,7 @@ static struct ata_port_operations cs5535_port_ops = { static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &cs5535_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -231,7 +231,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x1f, .port_ops = &cs5535_port_ops }; - struct ata_port_info *ports[1] = { &info }; + const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; u32 timings, dummy; @@ -243,7 +243,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id) rdmsr(ATAC_CH0D1_PIO, timings, dummy); if (CS5535_BAD_PIO(timings)) wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0); - return ata_pci_init_one(dev, ports, 1); + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id cs5535[] = { diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c index 30e5c543bcb0..27b9f29c01e3 100644 --- a/drivers/ata/pata_cypress.c +++ b/drivers/ata/pata_cypress.c @@ -165,14 +165,14 @@ static struct ata_port_operations cy82c693_port_ops = { static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &cy82c693_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &cy82c693_port_ops }; - static struct ata_port_info *port_info[1] = { &info }; + const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; /* Devfn 1 is the ATA primary. The secondary is magic and on devfn2. For the moment we don't handle the secondary. FIXME */ @@ -180,7 +180,7 @@ static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *i if (PCI_FUNC(pdev->devfn) != 1) return -ENODEV; - return ata_pci_init_one(pdev, port_info, 1); + return ata_pci_init_one(pdev, ppi); } static const struct pci_device_id cy82c693[] = { diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c index 23e929f0cd3f..079248a9b460 100644 --- a/drivers/ata/pata_efar.c +++ b/drivers/ata/pata_efar.c @@ -301,7 +301,7 @@ static const struct ata_port_operations efar_ops = { static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &efar_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -309,13 +309,13 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) .udma_mask = 0x0f, /* UDMA 66 */ .port_ops = &efar_ops, }; - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } static const struct pci_device_id efar_pci_tbl[] = { diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c index cb965f41d093..c6c8a8bb06d0 100644 --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c @@ -417,7 +417,7 @@ static void hpt36x_init_chipset(struct pci_dev *dev) static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info_hpt366 = { + static const struct ata_port_info info_hpt366 = { .sht = &hpt36x_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -425,7 +425,8 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x1f, .port_ops = &hpt366_port_ops }; - struct ata_port_info *port_info[2] = {&info_hpt366, &info_hpt366}; + struct ata_port_info info = info_hpt366; + const struct ata_port_info *ppi[] = { &info, NULL }; u32 class_rev; u32 reg1; @@ -446,17 +447,17 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id) /* info_hpt366 is safe against re-entry so we can scribble on it */ switch((reg1 & 0x700) >> 8) { case 5: - info_hpt366.private_data = &hpt366_40; + info.private_data = &hpt366_40; break; case 9: - info_hpt366.private_data = &hpt366_25; + info.private_data = &hpt366_25; break; default: - info_hpt366.private_data = &hpt366_33; + info.private_data = &hpt366_33; break; } /* Now kick off ATA set up */ - return ata_pci_init_one(dev, port_info, 2); + return ata_pci_init_one(dev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index 1614e8c822a4..5a0a410654e2 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c @@ -887,7 +887,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev) static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) { /* HPT370 - UDMA100 */ - static struct ata_port_info info_hpt370 = { + static const struct ata_port_info info_hpt370 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -896,7 +896,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt370_port_ops }; /* HPT370A - UDMA100 */ - static struct ata_port_info info_hpt370a = { + static const struct ata_port_info info_hpt370a = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -905,7 +905,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt370a_port_ops }; /* HPT370 - UDMA100 */ - static struct ata_port_info info_hpt370_33 = { + static const struct ata_port_info info_hpt370_33 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -914,7 +914,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt370_port_ops }; /* HPT370A - UDMA100 */ - static struct ata_port_info info_hpt370a_33 = { + static const struct ata_port_info info_hpt370a_33 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -923,7 +923,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt370a_port_ops }; /* HPT371, 372 and friends - UDMA133 */ - static struct ata_port_info info_hpt372 = { + static const struct ata_port_info info_hpt372 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -932,7 +932,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt372_port_ops }; /* HPT371, 372 and friends - UDMA100 at 50MHz clock */ - static struct ata_port_info info_hpt372_50 = { + static const struct ata_port_info info_hpt372_50 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -941,7 +941,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) .port_ops = &hpt372_port_ops }; /* HPT374 - UDMA133 */ - static struct ata_port_info info_hpt374 = { + static const struct ata_port_info info_hpt374 = { .sht = &hpt37x_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -951,9 +951,10 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) }; static const int MHz[4] = { 33, 40, 50, 66 }; - - struct ata_port_info *port_info[2]; - struct ata_port_info *port; + const struct ata_port_info *port; + void *private_data = NULL; + struct ata_port_info port_info; + const struct ata_port_info *ppi[] = { &port_info, NULL }; u8 irqmask; u32 class_rev; @@ -1124,13 +1125,13 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) return -ENODEV; } if (clock_slot == 3) - port->private_data = (void *)hpt37x_timings_66; + private_data = (void *)hpt37x_timings_66; else - port->private_data = (void *)hpt37x_timings_50; + private_data = (void *)hpt37x_timings_50; printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); } else { - port->private_data = (void *)chip_table->clocks[clock_slot]; + private_data = (void *)chip_table->clocks[clock_slot]; /* * Perform a final fixup. Note that we will have used the * DPLL on the HPT372 which means we don't have to worry @@ -1144,9 +1145,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); } - port_info[0] = port_info[1] = port; /* Now kick off ATA set up */ - return ata_pci_init_one(dev, port_info, 2); + port_info = *port; + port_info.private_data = private_data; + + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id hpt37x[] = { diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c index ea1037d67860..f25154aed75d 100644 --- a/drivers/ata/pata_hpt3x2n.c +++ b/drivers/ata/pata_hpt3x2n.c @@ -488,7 +488,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev) static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) { /* HPT372N and friends - UDMA133 */ - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &hpt3x2n_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -496,8 +496,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x7f, .port_ops = &hpt3x2n_port_ops }; - struct ata_port_info *port_info[2]; - struct ata_port_info *port = &info; + struct ata_port_info port = info; + const struct ata_port_info *ppi[] = { &port, NULL }; u8 irqmask; u32 class_rev; @@ -585,9 +585,9 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) /* Set our private data up. We only need a few flags so we use it directly */ - port->private_data = NULL; + port.private_data = NULL; if (pci_mhz > 60) { - port->private_data = (void *)PCI66; + port.private_data = (void *)PCI66; /* * On HPT371N, if ATA clock is 66 MHz we must set bit 2 in * the MISC. register to stretch the UltraDMA Tss timing. @@ -598,8 +598,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) } /* Now kick off ATA set up */ - port_info[0] = port_info[1] = port; - return ata_pci_init_one(dev, port_info, 2); + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id hpt3x2n[] = { diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c index 84c636b9beac..bbabe7902fbb 100644 --- a/drivers/ata/pata_hpt3x3.c +++ b/drivers/ata/pata_hpt3x3.c @@ -171,7 +171,7 @@ static void hpt3x3_init_chipset(struct pci_dev *dev) static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &hpt3x3_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -179,11 +179,11 @@ static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x07, .port_ops = &hpt3x3_port_ops }; - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; hpt3x3_init_chipset(dev); /* Now kick off ATA set up */ - return ata_pci_init_one(dev, port_info, 2); + return ata_pci_init_one(dev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/pata_it8213.c b/drivers/ata/pata_it8213.c index bf3aaa205edc..a769952646e1 100644 --- a/drivers/ata/pata_it8213.c +++ b/drivers/ata/pata_it8213.c @@ -311,7 +311,7 @@ static const struct ata_port_operations it8213_ops = { static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &it8213_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -319,14 +319,14 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en .udma_mask = 0x1f, /* UDMA 100 */ .port_ops = &it8213_ops, }; - static struct ata_port_info *port_info[2] = { &info, &info }; + /* Current IT8213 stuff is single port */ + const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); - /* Current IT8213 stuff is single port */ - return ata_pci_init_one(pdev, port_info, 1); + return ata_pci_init_one(pdev, ppi); } static const struct pci_device_id it8213_pci_tbl[] = { diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index 8e565a5f2c8d..ff9a6fd36657 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c @@ -718,14 +718,14 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { u8 conf; - static struct ata_port_info info_smart = { + static const struct ata_port_info info_smart = { .sht = &it821x_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &it821x_smart_port_ops }; - static struct ata_port_info info_passthru = { + static const struct ata_port_info info_passthru = { .sht = &it821x_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -733,8 +733,8 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = 0x7f, .port_ops = &it821x_passthru_port_ops }; - static struct ata_port_info *port_info[2]; + const struct ata_port_info *ppi[] = { NULL, NULL }; static char *mode[2] = { "pass through", "smart" }; /* Force the card into bypass mode if so requested */ @@ -747,11 +747,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) printk(KERN_INFO DRV_NAME ": controller in %s mode.\n", mode[conf]); if (conf == 0) - port_info[0] = port_info[1] = &info_passthru; + ppi[0] = &info_passthru; else - port_info[0] = port_info[1] = &info_smart; + ppi[0] = &info_smart; - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c index 1aa7bc2fda54..8d799e87f752 100644 --- a/drivers/ata/pata_jmicron.c +++ b/drivers/ata/pata_jmicron.c @@ -191,7 +191,7 @@ static const struct ata_port_operations jmicron_ops = { static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &jmicron_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -201,9 +201,9 @@ static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *i .port_ops = &jmicron_ops, }; - struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } static const struct pci_device_id jmicron_pci_tbl[] = { diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c index 2745e23cac43..edbfe0dbbf78 100644 --- a/drivers/ata/pata_marvell.c +++ b/drivers/ata/pata_marvell.c @@ -161,7 +161,7 @@ static const struct ata_port_operations marvell_ops = { static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &marvell_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -171,7 +171,7 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i .port_ops = &marvell_ops, }; - static struct ata_port_info info_sata = { + static const struct ata_port_info info_sata = { .sht = &marvell_sht, /* Slave possible as its magically mapped not real */ .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -182,13 +182,12 @@ static int marvell_init_one (struct pci_dev *pdev, const struct pci_device_id *i .port_ops = &marvell_ops, }; - struct ata_port_info *port_info[2] = { &info, &info_sata }; - int n_port = 2; + const struct ata_port_info *ppi[] = { &info, &info_sata }; if (pdev->device == 0x6101) - n_port = 1; + ppi[1] = &ata_dummy_port_info; - return ata_pci_init_one(pdev, port_info, n_port); + return ata_pci_init_one(pdev, ppi); } static const struct pci_device_id marvell_pci_tbl[] = { diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c index f15eb34fb1fc..81f563458666 100644 --- a/drivers/ata/pata_netcell.c +++ b/drivers/ata/pata_netcell.c @@ -92,7 +92,7 @@ static const struct ata_port_operations netcell_ops = { static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &netcell_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, /* Actually we don't really care about these as the @@ -102,7 +102,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e .udma_mask = 0x3f, /* UDMA 133 */ .port_ops = &netcell_ops, }; - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *port_info[] = { &info, NULL }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, @@ -112,7 +112,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e ata_pci_clear_simplex(pdev); /* And let the library code do the work */ - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, port_info); } static const struct pci_device_id netcell_pci_tbl[] = { diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c index d5eb42bdae9a..ea70ec744879 100644 --- a/drivers/ata/pata_ns87410.c +++ b/drivers/ata/pata_ns87410.c @@ -191,14 +191,14 @@ static struct ata_port_operations ns87410_port_ops = { static int ns87410_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &ns87410_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x0F, .port_ops = &ns87410_port_ops }; - static struct ata_port_info *port_info[2] = {&info, &info}; - return ata_pci_init_one(dev, port_info, 2); + const struct ata_port_info *ppi[] = { &info, NULL }; + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id ns87410[] = { diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c index d59002e7528d..29c23ddd6550 100644 --- a/drivers/ata/pata_oldpiix.c +++ b/drivers/ata/pata_oldpiix.c @@ -289,20 +289,20 @@ static const struct ata_port_operations oldpiix_pata_ops = { static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &oldpiix_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ .mwdma_mask = 0x07, /* mwdma1-2 */ .port_ops = &oldpiix_pata_ops, }; - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } static const struct pci_device_id oldpiix_pci_tbl[] = { diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c index 944b7084b459..1c44653e1e06 100644 --- a/drivers/ata/pata_opti.c +++ b/drivers/ata/pata_opti.c @@ -216,19 +216,19 @@ static struct ata_port_operations opti_port_ops = { static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &opti_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &opti_port_ops }; - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; static int printed_version; if (!printed_version++) dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(dev, port_info, 2); + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id opti[] = { diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c index 875ac4a49dd7..3093b02286ce 100644 --- a/drivers/ata/pata_optidma.c +++ b/drivers/ata/pata_optidma.c @@ -482,14 +482,14 @@ done_nomsg: /* Wrong chip revision */ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info_82c700 = { + static const struct ata_port_info info_82c700 = { .sht = &optidma_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &optidma_port_ops }; - static struct ata_port_info info_82c700_udma = { + static const struct ata_port_info info_82c700_udma = { .sht = &optidma_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -497,8 +497,7 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x07, .port_ops = &optiplus_port_ops }; - static struct ata_port_info *port_info[2]; - struct ata_port_info *info = &info_82c700; + const struct ata_port_info *ppi[] = { &info_82c700, NULL }; static int printed_version; if (!printed_version++) @@ -510,10 +509,9 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id) pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */ if (optiplus_with_udma(dev)) - info = &info_82c700_udma; + ppi[0] = &info_82c700_udma; - port_info[0] = port_info[1] = info; - return ata_pci_init_one(dev, port_info, 2); + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id optidma[] = { diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c index 3e204c329d51..edbaf9d653b8 100644 --- a/drivers/ata/pata_pdc202xx_old.c +++ b/drivers/ata/pata_pdc202xx_old.c @@ -317,7 +317,7 @@ static struct ata_port_operations pdc2026x_port_ops = { static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info[3] = { + static const struct ata_port_info info[3] = { { .sht = &pdc202xx_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -344,9 +344,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id } }; - static struct ata_port_info *port_info[2]; - - port_info[0] = port_info[1] = &info[id->driver_data]; + const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; if (dev->device == PCI_DEVICE_ID_PROMISE_20265) { struct pci_dev *bridge = dev->bus->self; @@ -358,7 +356,7 @@ static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id *id return -ENODEV; } } - return ata_pci_init_one(dev, port_info, 2); + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id pdc202xx[] = { diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c index bc01b17a00c2..ba96b54f5b87 100644 --- a/drivers/ata/pata_radisys.c +++ b/drivers/ata/pata_radisys.c @@ -255,7 +255,7 @@ static const struct ata_port_operations radisys_pata_ops = { static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &radisys_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -263,13 +263,13 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e .udma_mask = 0x14, /* UDMA33/66 only */ .port_ops = &radisys_pata_ops, }; - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; if (!printed_version++) dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } static const struct pci_device_id radisys_pci_tbl[] = { diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c index 97785b4f1efa..2bfd7ef42af5 100644 --- a/drivers/ata/pata_rz1000.c +++ b/drivers/ata/pata_rz1000.c @@ -131,22 +131,20 @@ static int rz1000_fifo_disable(struct pci_dev *pdev) static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - struct ata_port_info *port_info[2]; - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &rz1000_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &rz1000_port_ops }; + const struct ata_port_info *ppi[] = { &info, NULL }; if (!printed_version++) printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n"); - if (rz1000_fifo_disable(pdev) == 0) { - port_info[0] = &info; - port_info[1] = &info; - return ata_pci_init_one(pdev, port_info, 2); - } + if (rz1000_fifo_disable(pdev) == 0) + return ata_pci_init_one(pdev, ppi); + printk(KERN_ERR DRV_NAME ": failed to disable read-ahead on chipset..\n"); /* Not safe to use so skip */ return -ENODEV; diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c index 2af9f8c8bd1f..225013ecf4b6 100644 --- a/drivers/ata/pata_sc1200.c +++ b/drivers/ata/pata_sc1200.c @@ -243,7 +243,7 @@ static struct ata_port_operations sc1200_port_ops = { static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &sc1200_sht, .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -251,10 +251,10 @@ static int sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) .udma_mask = 0x07, .port_ops = &sc1200_port_ops }; - static struct ata_port_info *port_info[2] = { &info, &info }; - /* Can't enable port 2 yet, see top comments */ - return ata_pci_init_one(dev, port_info, 1); + const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info }; + + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id sc1200[] = { diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c index 8bbe4266f760..dee6e211949d 100644 --- a/drivers/ata/pata_serverworks.c +++ b/drivers/ata/pata_serverworks.c @@ -475,8 +475,7 @@ static void serverworks_fixup_ht1000(struct pci_dev *pdev) static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - int ports = 2; - static struct ata_port_info info[4] = { + static const struct ata_port_info info[4] = { { /* OSB4 */ .sht = &serverworks_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, @@ -507,8 +506,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id .port_ops = &serverworks_csb_port_ops } }; - static struct ata_port_info *port_info[2]; - struct ata_port_info *devinfo = &info[id->driver_data]; + const struct ata_port_info *ppi[] = { &info[id->driver_data], NULL }; /* Force master latency timer to 64 PCI clocks */ pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40); @@ -517,7 +515,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { /* Select non UDMA capable OSB4 if we can't do fixups */ if ( serverworks_fixup_osb4(pdev) < 0) - devinfo = &info[1]; + ppi[0] = &info[1]; } /* setup CSB5/CSB6 : South Bridge and IDE option RAID */ else if ((pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) || @@ -527,11 +525,11 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id /* If the returned btr is the newer revision then select the right info block */ if (serverworks_fixup_csb(pdev) == 3) - devinfo = &info[3]; + ppi[0] = &info[3]; /* Is this the 3rd channel CSB6 IDE ? */ if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2) - ports = 1; + ppi[1] = &ata_dummy_port_info; } /* setup HT1000E */ else if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) @@ -540,8 +538,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id if (pdev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE) ata_pci_clear_simplex(pdev); - port_info[0] = port_info[1] = devinfo; - return ata_pci_init_one(pdev, port_info, ports); + return ata_pci_init_one(pdev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c index 8c0b25f145ae..440e2cb6ee75 100644 --- a/drivers/ata/pata_sil680.c +++ b/drivers/ata/pata_sil680.c @@ -341,7 +341,7 @@ static u8 sil680_init_chip(struct pci_dev *pdev) static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &sil680_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -349,7 +349,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = 0x7f, .port_ops = &sil680_port_ops }; - static struct ata_port_info info_slow = { + static const struct ata_port_info info_slow = { .sht = &sil680_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, @@ -357,7 +357,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = 0x3f, .port_ops = &sil680_port_ops }; - static struct ata_port_info *port_info[2] = {&info, &info}; + const struct ata_port_info *ppi[] = { &info, NULL }; static int printed_version; if (!printed_version++) @@ -366,12 +366,12 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) switch(sil680_init_chip(pdev)) { case 0: - port_info[0] = port_info[1] = &info_slow; + ppi[0] = &info_slow; break; case 0x30: return -ENODEV; } - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c index 9b3774a4775a..f2231267e011 100644 --- a/drivers/ata/pata_sis.c +++ b/drivers/ata/pata_sis.c @@ -38,8 +38,8 @@ #define DRV_VERSION "0.5.1" struct sis_chipset { - u16 device; /* PCI host ID */ - struct ata_port_info *info; /* Info block */ + u16 device; /* PCI host ID */ + const struct ata_port_info *info; /* Info block */ /* Probably add family, cable detect type etc here to clean up code later */ }; @@ -696,7 +696,7 @@ static const struct ata_port_operations sis_old_ops = { .port_start = ata_port_start, }; -static struct ata_port_info sis_info = { +static const struct ata_port_info sis_info = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -704,7 +704,7 @@ static struct ata_port_info sis_info = { .udma_mask = 0, .port_ops = &sis_old_ops, }; -static struct ata_port_info sis_info33 = { +static const struct ata_port_info sis_info33 = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -712,35 +712,35 @@ static struct ata_port_info sis_info33 = { .udma_mask = ATA_UDMA2, /* UDMA 33 */ .port_ops = &sis_old_ops, }; -static struct ata_port_info sis_info66 = { +static const struct ata_port_info sis_info66 = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ .udma_mask = ATA_UDMA4, /* UDMA 66 */ .port_ops = &sis_66_ops, }; -static struct ata_port_info sis_info100 = { +static const struct ata_port_info sis_info100 = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ .udma_mask = ATA_UDMA5, .port_ops = &sis_100_ops, }; -static struct ata_port_info sis_info100_early = { +static const struct ata_port_info sis_info100_early = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .udma_mask = ATA_UDMA5, .pio_mask = 0x1f, /* pio0-4 */ .port_ops = &sis_66_ops, }; -struct ata_port_info sis_info133 = { +const struct ata_port_info sis_info133 = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ .udma_mask = ATA_UDMA6, .port_ops = &sis_133_ops, }; -static struct ata_port_info sis_info133_early = { +static const struct ata_port_info sis_info133_early = { .sht = &sis_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, /* pio0-4 */ @@ -823,8 +823,8 @@ static void sis_fixup(struct pci_dev *pdev, struct sis_chipset *sis) static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; - static struct ata_port_info *port_info[2]; - struct ata_port_info *port; + struct ata_port_info port; + const struct ata_port_info *ppi[] = { &port, NULL }; struct pci_dev *host = NULL; struct sis_chipset *chipset = NULL; struct sis_chipset *sets; @@ -964,13 +964,12 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) if (chipset == NULL) return -ENODEV; - port = chipset->info; - port->private_data = chipset; + port = *chipset->info; + port.private_data = chipset; sis_fixup(pdev, chipset); - port_info[0] = port_info[1] = port; - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } static const struct pci_device_id sis_pci_tbl[] = { diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c index 9aeffdbe2829..f48491ad5f3a 100644 --- a/drivers/ata/pata_sl82c105.c +++ b/drivers/ata/pata_sl82c105.c @@ -301,20 +301,22 @@ static int sl82c105_bridge_revision(struct pci_dev *pdev) static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info_dma = { + static const struct ata_port_info info_dma = { .sht = &sl82c105_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &sl82c105_port_ops }; - static struct ata_port_info info_early = { + static const struct ata_port_info info_early = { .sht = &sl82c105_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .port_ops = &sl82c105_port_ops }; - static struct ata_port_info *port_info[2] = { &info_early, &info_early }; + /* for now use only the first port */ + const struct ata_port_info *ppi[] = { &info_early, + &ata_dummy_port_info }; u32 val; int rev; @@ -324,17 +326,14 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Unable to find bridge, disabling DMA.\n"); else if (rev <= 5) dev_printk(KERN_WARNING, &dev->dev, "pata_sl82c105: Early bridge revision, no DMA available.\n"); - else { - port_info[0] = &info_dma; - port_info[1] = &info_dma; - } + else + ppi[0] = &info_dma; pci_read_config_dword(dev, 0x40, &val); val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16; pci_write_config_dword(dev, 0x40, val); - - return ata_pci_init_one(dev, port_info, 1); /* For now */ + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id sl82c105[] = { diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c index 045f9d2832df..b1d3076dfe51 100644 --- a/drivers/ata/pata_triflex.c +++ b/drivers/ata/pata_triflex.c @@ -233,20 +233,20 @@ static struct ata_port_operations triflex_port_ops = { static int triflex_init_one(struct pci_dev *dev, const struct pci_device_id *id) { - static struct ata_port_info info = { + static const struct ata_port_info info = { .sht = &triflex_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, .pio_mask = 0x1f, .mwdma_mask = 0x07, .port_ops = &triflex_port_ops }; - static struct ata_port_info *port_info[2] = { &info, &info }; + const struct ata_port_info *ppi[] = { &info, NULL }; static int printed_version; if (!printed_version++) dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n"); - return ata_pci_init_one(dev, port_info, 2); + return ata_pci_init_one(dev, ppi); } static const struct pci_device_id triflex[] = { diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c index 3740644e7f43..e4c71f76bd55 100644 --- a/drivers/ata/pata_via.c +++ b/drivers/ata/pata_via.c @@ -421,7 +421,7 @@ static void via_config_fifo(struct pci_dev *pdev, unsigned int flags) static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { /* Early VIA without UDMA support */ - static struct ata_port_info via_mwdma_info = { + static const struct ata_port_info via_mwdma_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -429,7 +429,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops }; /* Ditto with IRQ masking required */ - static struct ata_port_info via_mwdma_info_borked = { + static const struct ata_port_info via_mwdma_info_borked = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -437,7 +437,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops_noirq, }; /* VIA UDMA 33 devices (and borked 66) */ - static struct ata_port_info via_udma33_info = { + static const struct ata_port_info via_udma33_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -446,7 +446,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops }; /* VIA UDMA 66 devices */ - static struct ata_port_info via_udma66_info = { + static const struct ata_port_info via_udma66_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -455,7 +455,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops }; /* VIA UDMA 100 devices */ - static struct ata_port_info via_udma100_info = { + static const struct ata_port_info via_udma100_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -464,7 +464,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .port_ops = &via_port_ops }; /* UDMA133 with bad AST (All current 133) */ - static struct ata_port_info via_udma133_info = { + static const struct ata_port_info via_udma133_info = { .sht = &via_sht, .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING, .pio_mask = 0x1f, @@ -472,7 +472,8 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .udma_mask = 0x7f, /* FIXME: should check north bridge */ .port_ops = &via_port_ops }; - struct ata_port_info *port_info[2], *type; + struct ata_port_info type; + const struct ata_port_info *ppi[] = { &type, NULL }; struct pci_dev *isa = NULL; const struct via_isa_bridge *config; static int printed_version; @@ -517,25 +518,25 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) switch(config->flags & VIA_UDMA) { case VIA_UDMA_NONE: if (config->flags & VIA_NO_UNMASK) - type = &via_mwdma_info_borked; + type = via_mwdma_info_borked; else - type = &via_mwdma_info; + type = via_mwdma_info; break; case VIA_UDMA_33: - type = &via_udma33_info; + type = via_udma33_info; break; case VIA_UDMA_66: - type = &via_udma66_info; + type = via_udma66_info; /* The 66 MHz devices require we enable the clock */ pci_read_config_dword(pdev, 0x50, &timing); timing |= 0x80008; pci_write_config_dword(pdev, 0x50, timing); break; case VIA_UDMA_100: - type = &via_udma100_info; + type = via_udma100_info; break; case VIA_UDMA_133: - type = &via_udma133_info; + type = via_udma133_info; break; default: WARN_ON(1); @@ -550,10 +551,9 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id) } /* We have established the device type, now fire it up */ - type->private_data = (void *)config; + type.private_data = (void *)config; - port_info[0] = port_info[1] = type; - return ata_pci_init_one(pdev, port_info, 2); + return ata_pci_init_one(pdev, ppi); } #ifdef CONFIG_PM diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 6962f8e492f5..4cea3ef75226 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c @@ -457,7 +457,7 @@ static const struct ata_port_operations nv_adma_ops = { .host_stop = nv_adma_host_stop, }; -static struct ata_port_info nv_port_info[] = { +static const struct ata_port_info nv_port_info[] = { /* generic */ { .sht = &nv_sht, @@ -1537,7 +1537,7 @@ static void nv_adma_error_handler(struct ata_port *ap) static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version = 0; - const struct ata_port_info *ppi[2]; + const struct ata_port_info *ppi[] = { NULL, NULL }; struct ata_host *host; struct nv_host_priv *hpriv; int rc; @@ -1565,8 +1565,8 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) type = ADMA; } - ppi[0] = ppi[1] = &nv_port_info[type]; - rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); + ppi[0] = &nv_port_info[type]; + rc = ata_pci_prepare_native_host(pdev, ppi, &host); if (rc) return rc; diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c index d8ee062e82fc..ee66c5fa7ac8 100644 --- a/drivers/ata/sata_sis.c +++ b/drivers/ata/sata_sis.c @@ -129,7 +129,7 @@ static const struct ata_port_operations sis_ops = { .port_start = ata_port_start, }; -static struct ata_port_info sis_port_info = { +static const struct ata_port_info sis_port_info = { .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, .pio_mask = 0x1f, .mwdma_mask = 0x7, @@ -255,7 +255,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { static int printed_version; struct ata_port_info pi = sis_port_info; - const struct ata_port_info *ppi[2] = { &pi, &pi }; + const struct ata_port_info *ppi[] = { &pi, NULL }; struct ata_host *host; u32 genctl, val; u8 pmr; @@ -335,7 +335,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) break; } - rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); + rc = ata_pci_prepare_native_host(pdev, ppi, &host); if (rc) return rc; diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c index f74e383de083..006f5e352658 100644 --- a/drivers/ata/sata_uli.c +++ b/drivers/ata/sata_uli.c @@ -125,7 +125,7 @@ static const struct ata_port_operations uli_ops = { .port_start = ata_port_start, }; -static struct ata_port_info uli_port_info = { +static const struct ata_port_info uli_port_info = { .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | ATA_FLAG_IGN_SIMPLEX, .pio_mask = 0x1f, /* pio0-4 */ @@ -201,19 +201,33 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) n_ports = 2; if (board_idx == uli_5287) n_ports = 4; - rc = ata_pci_prepare_native_host(pdev, ppi, n_ports, &host); - if (rc) - return rc; + + /* allocate the host */ + host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); + if (!host) + return -ENOMEM; hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); if (!hpriv) return -ENOMEM; host->private_data = hpriv; + /* the first two ports are standard SFF */ + rc = ata_pci_init_native_host(host); + if (rc) + return rc; + + rc = ata_pci_init_bmdma(host); + if (rc) + return rc; + iomap = host->iomap; switch (board_idx) { case uli_5287: + /* If there are four, the last two live right after + * the standard SFF ports. + */ hpriv->scr_cfg_addr[0] = ULI5287_BASE; hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS; diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index 939c9246fdd1..814597a0a708 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c @@ -415,7 +415,7 @@ static int vt6420_prepare_host(struct pci_dev *pdev, struct ata_host **r_host) struct ata_host *host; int rc; - rc = ata_pci_prepare_native_host(pdev, ppi, 2, &host); + rc = ata_pci_prepare_native_host(pdev, ppi, &host); if (rc) return rc; *r_host = host; diff --git a/drivers/ata/sis.h b/drivers/ata/sis.h index 231da8fc2200..0f2208d8d5ef 100644 --- a/drivers/ata/sis.h +++ b/drivers/ata/sis.h @@ -2,4 +2,4 @@ struct ata_port_info; /* pata_sis.c */ -extern struct ata_port_info sis_info133; +extern const struct ata_port_info sis_info133; diff --git a/include/linux/libata.h b/include/linux/libata.h index 8a7cc13c8516..95b74ba7dbf4 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -253,10 +253,6 @@ enum { ATA_DMA_PAD_SZ = 4, ATA_DMA_PAD_BUF_SZ = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE, - /* masks for port functions */ - ATA_PORT_PRIMARY = (1 << 0), - ATA_PORT_SECONDARY = (1 << 1), - /* ering size */ ATA_ERING_SIZE = 32, @@ -688,8 +684,8 @@ extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); extern void ata_port_disable(struct ata_port *); extern void ata_std_ports(struct ata_ioports *ioaddr); #ifdef CONFIG_PCI -extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, - unsigned int n_ports); +extern int ata_pci_init_one (struct pci_dev *pdev, + const struct ata_port_info * const * ppi); extern void ata_pci_remove_one (struct pci_dev *pdev); #ifdef CONFIG_PM extern void ata_pci_device_do_suspend(struct pci_dev *pdev, pm_message_t mesg); @@ -854,11 +850,11 @@ struct pci_bits { unsigned long val; }; -extern int ata_pci_init_native_host(struct ata_host *host, - unsigned int port_mask); +extern int ata_pci_init_native_host(struct ata_host *host); +extern int ata_pci_init_bmdma(struct ata_host *host); extern int ata_pci_prepare_native_host(struct pci_dev *pdev, const struct ata_port_info * const * ppi, - int n_ports, struct ata_host **r_host); + struct ata_host **r_host); extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long); #endif /* CONFIG_PCI */ From f4d6d00466ef4879e4289f18c2f59210a06a7ada Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 1 May 2007 11:50:15 +0200 Subject: [PATCH 04/14] libata: ignore EH scheduling during initialization libata enables SCSI host during ATA host activation which happens after IRQ handler is registered and IRQ is enabled. All ATA ports are in frozen state when IRQ is enabled but frozen ports may raise limited number of IRQs after being frozen - IOW, ->freeze() is not responsible for clearing pending IRQs. During normal operation, the IRQ handler is responsible for clearing spurious IRQs on frozen ports and it usually doesn't require any extra code. Unfortunately, during host initialization, the IRQ handler can end up scheduling EH for a port whose SCSI host isn't initialized yet. This results in OOPS in the SCSI midlayer. This is relatively short window and scheduling EH for probing is the first thing libata does after initialization, so ignoring EH scheduling until initialization is complete solves the problem nicely. This problem was spotted by Berck E. Nash in the following thread. http://thread.gmane.org/gmane.linux.kernel/519412 Signed-off-by: Tejun Heo Cc: Berck E. Nash Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 2 ++ drivers/ata/libata-eh.c | 3 +++ include/linux/libata.h | 1 + 3 files changed, 6 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 9cff5c506573..6ac4f32ddcc2 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5964,6 +5964,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host) if (!ap) return NULL; + ap->pflags |= ATA_PFLAG_INITIALIZING; ap->lock = &host->lock; ap->flags = ATA_FLAG_DISABLED; ap->print_id = -1; @@ -6332,6 +6333,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) ehi->action |= ATA_EH_SOFTRESET; ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET; + ap->pflags &= ~ATA_PFLAG_INITIALIZING; ap->pflags |= ATA_PFLAG_LOADING; ata_port_schedule_eh(ap); diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 412d6049afa3..ee9bb534153a 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -551,6 +551,9 @@ void ata_port_schedule_eh(struct ata_port *ap) { WARN_ON(!ap->ops->error_handler); + if (ap->pflags & ATA_PFLAG_INITIALIZING) + return; + ap->pflags |= ATA_PFLAG_EH_PENDING; scsi_schedule_eh(ap->scsi_host); diff --git a/include/linux/libata.h b/include/linux/libata.h index 95b74ba7dbf4..90abcdc3d4ef 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -190,6 +190,7 @@ enum { ATA_PFLAG_LOADING = (1 << 4), /* boot/loading probe */ ATA_PFLAG_UNLOADING = (1 << 5), /* module is unloading */ ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */ + ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */ ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */ ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ From 54936f8b099325992f0f212a5e366fd5257c6c9c Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 11 May 2007 14:35:29 +0200 Subject: [PATCH 05/14] libata: fallback to the other IDENTIFY on device error, take#2 It seems the world isn't as frank as we thought and some devices lie about who they are. Fallback to the other IDENTIFY if IDENTIFY is aborted by the device. As this is the strategy used by IDE for a long time, it shouldn't cause too much problem. Signed-off-by: Tejun Heo Cc: William Thompson Signed-off-by: Jeff Garzik --- drivers/ata/libata-core.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 6ac4f32ddcc2..335ac8fb5251 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -1660,7 +1660,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, struct ata_taskfile tf; unsigned int err_mask = 0; const char *reason; - int tried_spinup = 0; + int may_fallback = 1, tried_spinup = 0; int rc; if (ata_msg_ctl(ap)) @@ -1704,11 +1704,31 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, return -ENOENT; } + /* Device or controller might have reported the wrong + * device class. Give a shot at the other IDENTIFY if + * the current one is aborted by the device. + */ + if (may_fallback && + (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { + may_fallback = 0; + + if (class == ATA_DEV_ATA) + class = ATA_DEV_ATAPI; + else + class = ATA_DEV_ATA; + goto retry; + } + rc = -EIO; reason = "I/O error"; goto err_out; } + /* Falling back doesn't make sense if ID data was read + * successfully at least once. + */ + may_fallback = 0; + swap_buf_le16(id, ATA_ID_WORDS); /* sanity check */ From 8575b814097af648dad284bd3087875a11b13d18 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 11 May 2007 14:46:51 +0200 Subject: [PATCH 06/14] libata: give devices one last chance even if recovery failed with -EINVAL After certain errors, some devices report complete garbage on IDENTIFY. This can cause ata_dev_read_id() to fail with -EINVAL resulting in immediate disabling of the device. Give the device one last chance after -EINVAL to allow recovery from such situations. As -EINVAL is triggered very rarely, this shouldn't cause any noticeable affect on more common error paths. Signed-off-by: Tejun Heo Cc: Harald Dunkel Signed-off-by: Jeff Garzik --- drivers/ata/libata-eh.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index ee9bb534153a..5309c312f517 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -2003,14 +2003,10 @@ static int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ehc->tries[dev->devno]--; switch (rc) { - case -EINVAL: - /* eeek, something went very wrong, give up */ - ehc->tries[dev->devno] = 0; - break; - case -ENODEV: /* device missing or wrong IDENTIFY data, schedule probing */ ehc->i.probe_mask |= (1 << dev->devno); + case -EINVAL: /* give it just one more chance */ ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1); case -EIO: From e92351bb53c0849fabfa80be53cbf3b0aa166e54 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 5 May 2007 23:50:38 +0900 Subject: [PATCH 07/14] libata-acpi: s/CONFIG_SATA_ACPI/CONFIG_ATA_ACPI/ ACPI applies to both SATA and PATA. Drop the 'S' from the config variable. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/Kconfig | 26 +++++++++++++------------- drivers/ata/Makefile | 2 +- drivers/ata/libata.h | 2 +- include/linux/libata.h | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index f031b8732330..8e136ff013f4 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -24,6 +24,19 @@ config ATA_NONSTANDARD bool default n +config ATA_ACPI + bool + depends on ACPI && PCI + default y + help + This option adds support for ATA-related ACPI objects. + These ACPI objects add the ability to retrieve taskfiles + from the ACPI BIOS and write them to the disk controller. + These objects may be related to performance, security, + power management, or other areas. + You can disable this at kernel boot time by using the + option libata.noacpi=1 + config SATA_AHCI tristate "AHCI SATA support" depends on PCI @@ -157,19 +170,6 @@ config SATA_INIC162X help This option enables support for Initio 162x Serial ATA. -config SATA_ACPI - bool - depends on ACPI && PCI - default y - help - This option adds support for SATA-related ACPI objects. - These ACPI objects add the ability to retrieve taskfiles - from the ACPI BIOS and write them to the disk controller. - These objects may be related to performance, security, - power management, or other areas. - You can disable this at kernel boot time by using the - option libata.noacpi=1 - config PATA_ALI tristate "ALi PATA support (Experimental)" depends on PCI && EXPERIMENTAL diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 6f42a0e2812d..8149c68ac2c7 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile @@ -69,4 +69,4 @@ obj-$(CONFIG_ATA_GENERIC) += ata_generic.o obj-$(CONFIG_PATA_LEGACY) += pata_legacy.o libata-objs := libata-core.o libata-scsi.o libata-sff.o libata-eh.o -libata-$(CONFIG_SATA_ACPI) += libata-acpi.o +libata-$(CONFIG_ATA_ACPI) += libata-acpi.o diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 316bf8ae4536..49ec182e5057 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h @@ -97,7 +97,7 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); extern struct ata_port *ata_port_alloc(struct ata_host *host); /* libata-acpi.c */ -#ifdef CONFIG_SATA_ACPI +#ifdef CONFIG_ATA_ACPI extern int ata_acpi_exec_tfs(struct ata_port *ap); extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix); #else diff --git a/include/linux/libata.h b/include/linux/libata.h index 90abcdc3d4ef..27d936279574 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -458,7 +458,7 @@ struct ata_device { struct ata_ering ering; int spdn_cnt; unsigned int horkage; /* List of broken features */ -#ifdef CONFIG_SATA_ACPI +#ifdef CONFIG_ATA_ACPI /* ACPI objects info */ acpi_handle obj_handle; #endif From 3a32a8e96694a243ec7e7feb6d76dfc4b1fe90c1 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 5 May 2007 23:50:38 +0900 Subject: [PATCH 08/14] libata-acpi: clean up parameters and misc stuff This patch cleans up libata-acpi such that it looks similar to other libata files. This patch doesn't introuce any behavior changes. * make libata-acpi functions take ata_device instead of ata_port + device index * s/atadev/dev/ * de-indent local variable declarations Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/ata/libata-acpi.c | 192 +++++++++++++++++++------------------- drivers/ata/libata-core.c | 2 +- drivers/ata/libata.h | 4 +- 3 files changed, 98 insertions(+), 100 deletions(-) diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index cb3eab6e379d..ed4138e24b0c 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c @@ -270,8 +270,7 @@ out: /** * do_drive_get_GTF - get the drive bootup default taskfile settings - * @ap: the ata_port for the drive - * @ix: target ata_device (drive) index + * @dev: target ATA device * @gtf_length: number of bytes of _GTF data returned at @gtf_address * @gtf_address: buffer containing _GTF taskfile arrays * @@ -286,20 +285,19 @@ out: * The returned @gtf_length and @gtf_address are only valid if the * function return value is 0. */ -static int do_drive_get_GTF(struct ata_port *ap, int ix, - unsigned int *gtf_length, unsigned long *gtf_address, - unsigned long *obj_loc) +static int do_drive_get_GTF(struct ata_device *dev, unsigned int *gtf_length, + unsigned long *gtf_address, unsigned long *obj_loc) { - acpi_status status; - acpi_handle dev_handle = NULL; - acpi_handle chan_handle, drive_handle; - acpi_integer pcidevfn = 0; - u32 dev_adr; - struct acpi_buffer output; - union acpi_object *out_obj; - struct device *dev = ap->host->dev; - struct ata_device *atadev = &ap->device[ix]; - int err = -ENODEV; + struct ata_port *ap = dev->ap; + acpi_status status; + acpi_handle dev_handle = NULL; + acpi_handle chan_handle, drive_handle; + acpi_integer pcidevfn = 0; + u32 dev_adr; + struct acpi_buffer output; + union acpi_object *out_obj; + struct device *gdev = ap->host->dev; + int err = -ENODEV; *gtf_length = 0; *gtf_address = 0UL; @@ -309,14 +307,14 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, return 0; if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", + ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", __FUNCTION__, ap->port_no); - if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) { + if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, "%s: ERR: " + ata_dev_printk(dev, KERN_DEBUG, "%s: ERR: " "ata_dev_present: %d, PORT_DISABLED: %lu\n", - __FUNCTION__, ata_dev_enabled(atadev), + __FUNCTION__, ata_dev_enabled(dev), ap->flags & ATA_FLAG_DISABLED); goto out; } @@ -324,19 +322,19 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, /* Don't continue if device has no _ADR method. * _GTF is intended for known motherboard devices. */ if (!(ap->cbl == ATA_CBL_SATA)) { - err = pata_get_dev_handle(dev, &dev_handle, &pcidevfn); + err = pata_get_dev_handle(gdev, &dev_handle, &pcidevfn); if (err < 0) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, + ata_dev_printk(dev, KERN_DEBUG, "%s: pata_get_dev_handle failed (%d)\n", __FUNCTION__, err); goto out; } } else { - err = sata_get_dev_handle(dev, &dev_handle, &pcidevfn); + err = sata_get_dev_handle(gdev, &dev_handle, &pcidevfn); if (err < 0) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, + ata_dev_printk(dev, KERN_DEBUG, "%s: sata_get_dev_handle failed (%d\n", __FUNCTION__, err); goto out; @@ -344,7 +342,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, } /* Get this drive's _ADR info. if not already known. */ - if (!atadev->obj_handle) { + if (!dev->obj_handle) { if (!(ap->cbl == ATA_CBL_SATA)) { /* get child objects of dev_handle == channel objects, * + _their_ children == drive objects */ @@ -352,7 +350,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, chan_handle = acpi_get_child(dev_handle, ap->port_no); if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, + ata_dev_printk(dev, KERN_DEBUG, "%s: chan adr=%d: chan_handle=0x%p\n", __FUNCTION__, ap->port_no, chan_handle); @@ -361,26 +359,26 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, goto out; } /* TBD: could also check ACPI object VALID bits */ - drive_handle = acpi_get_child(chan_handle, ix); + drive_handle = acpi_get_child(chan_handle, dev->devno); if (!drive_handle) { err = -ENODEV; goto out; } - dev_adr = ix; - atadev->obj_handle = drive_handle; + dev_adr = dev->devno; + dev->obj_handle = drive_handle; } else { /* for SATA mode */ dev_adr = SATA_ADR_RSVD; - err = get_sata_adr(dev, dev_handle, pcidevfn, 0, - ap, atadev, &dev_adr); + err = get_sata_adr(gdev, dev_handle, pcidevfn, 0, + ap, dev, &dev_adr); } if (err < 0 || dev_adr == SATA_ADR_RSVD || - !atadev->obj_handle) { + !dev->obj_handle) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, + ata_dev_printk(dev, KERN_DEBUG, "%s: get_sata/pata_adr failed: " "err=%d, dev_adr=%u, obj_handle=0x%p\n", __FUNCTION__, err, dev_adr, - atadev->obj_handle); + dev->obj_handle); goto out; } } @@ -391,11 +389,11 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, /* _GTF has no input parameters */ err = -EIO; - status = acpi_evaluate_object(atadev->obj_handle, "_GTF", + status = acpi_evaluate_object(dev->obj_handle, "_GTF", NULL, &output); if (ACPI_FAILURE(status)) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, + ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF error: status = 0x%x\n", __FUNCTION__, status); goto out; @@ -403,7 +401,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, if (!output.length || !output.pointer) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " + ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " "length or ptr is NULL (0x%llx, 0x%p)\n", __FUNCTION__, (unsigned long long)output.length, @@ -416,7 +414,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, if (out_obj->type != ACPI_TYPE_BUFFER) { kfree(output.pointer); if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, "%s: Run _GTF: " + ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " "error: expected object type of " " ACPI_TYPE_BUFFER, got 0x%x\n", __FUNCTION__, out_obj->type); @@ -427,7 +425,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, if (!out_obj->buffer.length || !out_obj->buffer.pointer || out_obj->buffer.length % REGS_PER_GTF) { if (ata_msg_drv(ap)) - ata_dev_printk(atadev, KERN_ERR, + ata_dev_printk(dev, KERN_ERR, "%s: unexpected GTF length (%d) or addr (0x%p)\n", __FUNCTION__, out_obj->buffer.length, out_obj->buffer.pointer); @@ -439,7 +437,7 @@ static int do_drive_get_GTF(struct ata_port *ap, int ix, *gtf_address = (unsigned long)out_obj->buffer.pointer; *obj_loc = (unsigned long)out_obj; if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, "%s: returning " + ata_dev_printk(dev, KERN_DEBUG, "%s: returning " "gtf_length=%d, gtf_address=0x%lx, obj_loc=0x%lx\n", __FUNCTION__, *gtf_length, *gtf_address, *obj_loc); err = 0; @@ -449,7 +447,7 @@ out: /** * taskfile_load_raw - send taskfile registers to host controller - * @ap: Port to which output is sent + * @dev: target ATA device * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) * * Outputs ATA taskfile to standard ATA host controller using MMIO @@ -466,15 +464,15 @@ out: * LOCKING: TBD: * Inherited from caller. */ -static void taskfile_load_raw(struct ata_port *ap, - struct ata_device *atadev, - const struct taskfile_array *gtf) +static void taskfile_load_raw(struct ata_device *dev, + const struct taskfile_array *gtf) { + struct ata_port *ap = dev->ap; struct ata_taskfile tf; unsigned int err; if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " + ata_dev_printk(dev, KERN_DEBUG, "%s: (0x1f1-1f7): hex: " "%02x %02x %02x %02x %02x %02x %02x\n", __FUNCTION__, gtf->tfa[0], gtf->tfa[1], gtf->tfa[2], @@ -485,7 +483,7 @@ static void taskfile_load_raw(struct ata_port *ap, && (gtf->tfa[6] == 0)) return; - ata_tf_init(atadev, &tf); + ata_tf_init(dev, &tf); /* convert gtf to tf */ tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; /* TBD */ @@ -498,17 +496,16 @@ static void taskfile_load_raw(struct ata_port *ap, tf.device = gtf->tfa[5]; /* 0x1f6 */ tf.command = gtf->tfa[6]; /* 0x1f7 */ - err = ata_exec_internal(atadev, &tf, NULL, DMA_NONE, NULL, 0); + err = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); if (err && ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_ERR, + ata_dev_printk(dev, KERN_ERR, "%s: ata_exec_internal failed: %u\n", __FUNCTION__, err); } /** * do_drive_set_taskfiles - write the drive taskfile settings from _GTF - * @ap: the ata_port for the drive - * @atadev: target ata_device + * @dev: target ATA device * @gtf_length: total number of bytes of _GTF taskfiles * @gtf_address: location of _GTF taskfile arrays * @@ -517,30 +514,31 @@ static void taskfile_load_raw(struct ata_port *ap, * Write {gtf_address, length gtf_length} in groups of * REGS_PER_GTF bytes. */ -static int do_drive_set_taskfiles(struct ata_port *ap, - struct ata_device *atadev, unsigned int gtf_length, - unsigned long gtf_address) +static int do_drive_set_taskfiles(struct ata_device *dev, + unsigned int gtf_length, + unsigned long gtf_address) { - int err = -ENODEV; - int gtf_count = gtf_length / REGS_PER_GTF; - int ix; + struct ata_port *ap = dev->ap; + int err = -ENODEV; + int gtf_count = gtf_length / REGS_PER_GTF; + int ix; struct taskfile_array *gtf; if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, "%s: ENTER: port#: %d\n", + ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", __FUNCTION__, ap->port_no); if (libata_noacpi || !(ap->cbl == ATA_CBL_SATA)) return 0; - if (!ata_dev_enabled(atadev) || (ap->flags & ATA_FLAG_DISABLED)) + if (!ata_dev_enabled(dev) || (ap->flags & ATA_FLAG_DISABLED)) goto out; if (!gtf_count) /* shouldn't be here */ goto out; if (gtf_length % REGS_PER_GTF) { if (ata_msg_drv(ap)) - ata_dev_printk(atadev, KERN_ERR, + ata_dev_printk(dev, KERN_ERR, "%s: unexpected GTF length (%d)\n", __FUNCTION__, gtf_length); goto out; @@ -551,7 +549,7 @@ static int do_drive_set_taskfiles(struct ata_port *ap, (gtf_address + ix * REGS_PER_GTF); /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */ - taskfile_load_raw(ap, atadev, gtf); + taskfile_load_raw(dev, gtf); } err = 0; @@ -567,11 +565,11 @@ out: */ int ata_acpi_exec_tfs(struct ata_port *ap) { - int ix; - int ret =0; - unsigned int gtf_length; - unsigned long gtf_address; - unsigned long obj_loc; + int ix; + int ret = 0; + unsigned int gtf_length; + unsigned long gtf_address; + unsigned long obj_loc; if (libata_noacpi) return 0; @@ -584,11 +582,13 @@ int ata_acpi_exec_tfs(struct ata_port *ap) return 0; for (ix = 0; ix < ATA_MAX_DEVICES; ix++) { - if (!ata_dev_enabled(&ap->device[ix])) + struct ata_device *dev = &ap->device[ix]; + + if (!ata_dev_enabled(dev)) continue; - ret = do_drive_get_GTF(ap, ix, - >f_length, >f_address, &obj_loc); + ret = do_drive_get_GTF(dev, >f_length, >f_address, + &obj_loc); if (ret < 0) { if (ata_msg_probe(ap)) ata_port_printk(ap, KERN_DEBUG, @@ -597,8 +597,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap) break; } - ret = do_drive_set_taskfiles(ap, &ap->device[ix], - gtf_length, gtf_address); + ret = do_drive_set_taskfiles(dev, gtf_length, gtf_address); kfree((void *)obj_loc); if (ret < 0) { if (ata_msg_probe(ap)) @@ -614,8 +613,7 @@ int ata_acpi_exec_tfs(struct ata_port *ap) /** * ata_acpi_push_id - send Identify data to drive - * @ap: the ata_port for the drive - * @ix: drive index + * @dev: target ATA device * * _SDD ACPI object: for SATA mode only * Must be after Identify (Packet) Device -- uses its data @@ -623,57 +621,57 @@ int ata_acpi_exec_tfs(struct ata_port *ap) * method and if it fails for whatever reason, we should still * just keep going. */ -int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) +int ata_acpi_push_id(struct ata_device *dev) { - acpi_handle handle; - acpi_integer pcidevfn; - int err; - struct device *dev = ap->host->dev; - struct ata_device *atadev = &ap->device[ix]; - u32 dev_adr; - acpi_status status; - struct acpi_object_list input; - union acpi_object in_params[1]; + struct ata_port *ap = dev->ap; + acpi_handle handle; + acpi_integer pcidevfn; + int err; + struct device *gdev = ap->host->dev; + u32 dev_adr; + acpi_status status; + struct acpi_object_list input; + union acpi_object in_params[1]; if (libata_noacpi) return 0; if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", - __FUNCTION__, ix, ap->port_no); + ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", + __FUNCTION__, dev->devno, ap->port_no); /* Don't continue if not a SATA device. */ if (!(ap->cbl == ATA_CBL_SATA)) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, + ata_dev_printk(dev, KERN_DEBUG, "%s: Not a SATA device\n", __FUNCTION__); goto out; } /* Don't continue if device has no _ADR method. * _SDD is intended for known motherboard devices. */ - err = sata_get_dev_handle(dev, &handle, &pcidevfn); + err = sata_get_dev_handle(gdev, &handle, &pcidevfn); if (err < 0) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, + ata_dev_printk(dev, KERN_DEBUG, "%s: sata_get_dev_handle failed (%d\n", __FUNCTION__, err); goto out; } /* Get this drive's _ADR info, if not already known */ - if (!atadev->obj_handle) { + if (!dev->obj_handle) { dev_adr = SATA_ADR_RSVD; - err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev, + err = get_sata_adr(gdev, handle, pcidevfn, dev->devno, ap, dev, &dev_adr); if (err < 0 || dev_adr == SATA_ADR_RSVD || - !atadev->obj_handle) { + !dev->obj_handle) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, + ata_dev_printk(dev, KERN_DEBUG, "%s: get_sata_adr failed: " "err=%d, dev_adr=%u, obj_handle=0x%p\n", __FUNCTION__, err, dev_adr, - atadev->obj_handle); + dev->obj_handle); goto out; } } @@ -683,19 +681,19 @@ int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) input.count = 1; input.pointer = in_params; in_params[0].type = ACPI_TYPE_BUFFER; - in_params[0].buffer.length = sizeof(atadev->id[0]) * ATA_ID_WORDS; - in_params[0].buffer.pointer = (u8 *)atadev->id; + in_params[0].buffer.length = sizeof(dev->id[0]) * ATA_ID_WORDS; + in_params[0].buffer.pointer = (u8 *)dev->id; /* Output buffer: _SDD has no output */ /* It's OK for _SDD to be missing too. */ - swap_buf_le16(atadev->id, ATA_ID_WORDS); - status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL); - swap_buf_le16(atadev->id, ATA_ID_WORDS); + swap_buf_le16(dev->id, ATA_ID_WORDS); + status = acpi_evaluate_object(dev->obj_handle, "_SDD", &input, NULL); + swap_buf_le16(dev->id, ATA_ID_WORDS); err = ACPI_FAILURE(status) ? -EIO : 0; if (err < 0) { if (ata_msg_probe(ap)) - ata_dev_printk(atadev, KERN_DEBUG, + ata_dev_printk(dev, KERN_DEBUG, "%s _SDD error: status = 0x%x\n", __FUNCTION__, status); } diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 335ac8fb5251..4166407eb47c 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -1869,7 +1869,7 @@ int ata_dev_configure(struct ata_device *dev) ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); /* set _SDD */ - rc = ata_acpi_push_id(ap, dev->devno); + rc = ata_acpi_push_id(dev); if (rc) { ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n", rc); diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 49ec182e5057..8b71b73a199c 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h @@ -99,13 +99,13 @@ extern struct ata_port *ata_port_alloc(struct ata_host *host); /* libata-acpi.c */ #ifdef CONFIG_ATA_ACPI extern int ata_acpi_exec_tfs(struct ata_port *ap); -extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix); +extern int ata_acpi_push_id(struct ata_device *dev); #else static inline int ata_acpi_exec_tfs(struct ata_port *ap) { return 0; } -static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix) +static inline int ata_acpi_push_id(struct ata_device *dev) { return 0; } From 1d30c33d8d07868199560b24f10ed6280e78a89c Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 10 May 2007 22:48:43 -0700 Subject: [PATCH 09/14] git-libata-all: sata_via build fix Cc: Tejun Heo Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/ata/sata_via.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c index 814597a0a708..d105d2c189d2 100644 --- a/drivers/ata/sata_via.c +++ b/drivers/ata/sata_via.c @@ -116,10 +116,6 @@ static struct scsi_host_template svia_sht = { .slave_configure = ata_scsi_slave_config, .slave_destroy = ata_scsi_slave_destroy, .bios_param = ata_std_bios_param, -#ifdef CONFIG_PM - .suspend = ata_scsi_device_suspend, - .resume = ata_scsi_device_resume, -#endif }; static const struct ata_port_operations vt6420_sata_ops = { From 48aaae7a2fa46e1ed0d0b7677fde79ccfcb8c963 Mon Sep 17 00:00:00 2001 From: "Aeschbacher, Fabrice" Date: Thu, 10 May 2007 22:48:48 -0700 Subject: [PATCH 10/14] pata_pcmcia: recognize 2GB CompactFlash from Transcend Allow the pata_pcmcia driver to automatically detect 2GB CompactFlash cards from Transcend. Signed-off-by: Fabrice Aeschbacher Cc: "Peter Stuge" Acked-by: Alan Cox Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/ata/pata_pcmcia.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c index 11245e331f77..4d44c7555db1 100644 --- a/drivers/ata/pata_pcmcia.c +++ b/drivers/ata/pata_pcmcia.c @@ -397,6 +397,7 @@ static struct pcmcia_device_id pcmcia_devices[] = { PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1), + PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS2GCF120", 0x709b1bf1, 0x969aa4f2), PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918), From 823777181b4c0200923dcb026efa5b37f55c0ecf Mon Sep 17 00:00:00 2001 From: Henry Su Date: Thu, 10 May 2007 22:48:50 -0700 Subject: [PATCH 11/14] Add the combined mode for ATI SB700 Besides those modes in ATI SB600 SATA controller, ATI SB700 supports one more mode:the combined mode. The combined mode is a Legacy IDE mode used for compatibility with some old OS without AHCI driver, but now it is not necessary for Linux since the kernel has supported AHCI. Signed-off-by: Luugi Marsan Cc: Jeff Garzik Cc: Tejun Heo Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/pci/quirks.c | 1 + include/linux/pci_ids.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 147d86f8edbf..6ccc2e95930a 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -875,6 +875,7 @@ static void __devinit quirk_sb600_sata(struct pci_dev *pdev) } } DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_sb600_sata); +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_sb600_sata); /* * Serverworks CSB5 IDE does not fully support native mode diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index ae849f0d4430..ccd85e4d3b8f 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -370,6 +370,7 @@ #define PCI_DEVICE_ID_ATI_IXP600_SATA 0x4380 #define PCI_DEVICE_ID_ATI_IXP600_SMBUS 0x4385 #define PCI_DEVICE_ID_ATI_IXP600_IDE 0x438c +#define PCI_DEVICE_ID_ATI_IXP700_SATA 0x4390 #define PCI_VENDOR_ID_VLSI 0x1004 #define PCI_DEVICE_ID_VLSI_82C592 0x0005 From 2bcfdde6767f2f07891d2753c25220012fe5e6d2 Mon Sep 17 00:00:00 2001 From: Henry Su Date: Thu, 10 May 2007 22:48:51 -0700 Subject: [PATCH 12/14] add the ATI SB700 SATA controller device id to AHCI pci table Add the device ID to AHCI pci table for ATI SB700 SATA controller, the subsequent chipset of SB600. Signed-off-by: henry su Cc: Jeff Garzik Cc: Tejun Heo Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/ata/ahci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 1ab8a8fdeaac..1ae443d7ab92 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -396,6 +396,7 @@ static const struct pci_device_id ahci_pci_tbl[] = { /* ATI */ { PCI_VDEVICE(ATI, 0x4380), board_ahci_sb600 }, /* ATI SB600 */ + { PCI_VDEVICE(ATI, 0x4390), board_ahci_sb600 }, /* ATI SB700 */ /* VIA */ { PCI_VDEVICE(VIA, 0x3349), board_ahci_vt8251 }, /* VIA VT8251 */ From b196fc69f7be7b4454781add9c2d5173f44d509b Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 10 May 2007 22:48:54 -0700 Subject: [PATCH 13/14] Use menuconfig objects: libata Use menuconfigs instead of menus, so the whole menu can be disabled at once instead of going through all options. Signed-off-by: Jan Engelhardt Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/ata/Kconfig | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 8e136ff013f4..ad1f59c1b3fc 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -2,11 +2,9 @@ # SATA/PATA driver configuration # -menu "Serial ATA (prod) and Parallel ATA (experimental) drivers" +menuconfig ATA + tristate "Serial ATA (prod) and Parallel ATA (experimental) drivers" depends on HAS_IOMEM - -config ATA - tristate "ATA device support" depends on BLOCK depends on !(M32R || M68K) || BROKEN depends on !SUN4 || BROKEN @@ -585,6 +583,4 @@ config PATA_SCC If unsure, say N. -endif -endmenu - +endif # ATA From b9a3b4d1453689f2927668fcdc4827fdccf44d1b Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Wed, 9 May 2007 23:00:20 -0500 Subject: [PATCH 14/14] pata_platform: don't use generic ata_port_start I have a system where I have a simple IDE controller that sits on a local bus without bus master dma capability, and thus no dma_mapping ops defined for the device/bus. pata_platform works great for me, with the exception of using the generic ata_port_start which tries to do a dmam_alloc_coherent. Looks like it doesn't need to allocate a prd table at all, so replace it with a dummy function instead. Signed-off-by: Olof Johansson Signed-off-by: Jeff Garzik --- drivers/ata/pata_platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index a0a650c7f272..1f6384895a4f 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c @@ -48,6 +48,8 @@ static int pata_platform_set_mode(struct ata_port *ap, struct ata_device **unuse return 0; } +static int ata_dummy_ret0(struct ata_port *ap) { return 0; } + static struct scsi_host_template pata_platform_sht = { .module = THIS_MODULE, .name = DRV_NAME, @@ -91,7 +93,7 @@ static struct ata_port_operations pata_platform_port_ops = { .irq_on = ata_irq_on, .irq_ack = ata_irq_ack, - .port_start = ata_port_start, + .port_start = ata_dummy_ret0, }; static void pata_platform_setup_port(struct ata_ioports *ioaddr,