View | Details | Raw Unified | Return to bug 104647
Collapse All | Expand All

(-)linux-2.6.12/drivers/scsi/ata_piix.c (+4 lines)
Lines 104-109 Link Here
104
	.id_table		= piix_pci_tbl,
104
	.id_table		= piix_pci_tbl,
105
	.probe			= piix_init_one,
105
	.probe			= piix_init_one,
106
	.remove			= ata_pci_remove_one,
106
	.remove			= ata_pci_remove_one,
107
	.suspend		= ata_pci_device_suspend,
108
	.resume			= ata_pci_device_resume,
107
};
109
};
108
110
109
static Scsi_Host_Template piix_sht = {
111
static Scsi_Host_Template piix_sht = {
Lines 124-129 Link Here
124
	.slave_configure	= ata_scsi_slave_config,
126
	.slave_configure	= ata_scsi_slave_config,
125
	.bios_param		= ata_std_bios_param,
127
	.bios_param		= ata_std_bios_param,
126
	.ordered_flush		= 1,
128
	.ordered_flush		= 1,
129
	.resume			= ata_scsi_device_resume,
130
	.suspend		= ata_scsi_device_suspend,
127
};
131
};
128
132
129
static struct ata_port_operations piix_pata_ops = {
133
static struct ata_port_operations piix_pata_ops = {
(-)linux-2.6.12/drivers/scsi/libata-core.c (+122 lines)
Lines 3632-3637 Link Here
3632
 *	LOCKING:
3632
 *	LOCKING:
3633
 */
3633
 */
3634
3634
3635
/*
3636
 * Execute a 'simple' command, that only consists of the opcode 'cmd' itself,
3637
 * without filling any other registers
3638
 */
3639
static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev,
3640
			     u8 cmd)
3641
{
3642
	DECLARE_COMPLETION(wait);
3643
	struct ata_queued_cmd *qc;
3644
	unsigned long flags;
3645
	int rc;
3646
3647
	qc = ata_qc_new_init(ap, dev);
3648
	BUG_ON(qc == NULL);
3649
3650
	qc->tf.command = cmd;
3651
	qc->tf.flags |= ATA_TFLAG_DEVICE;
3652
	qc->tf.protocol = ATA_PROT_NODATA;
3653
3654
	qc->waiting = &wait;
3655
	qc->complete_fn = ata_qc_complete_noop;
3656
3657
	spin_lock_irqsave(&ap->host_set->lock, flags);
3658
	rc = ata_qc_issue(qc);
3659
	spin_unlock_irqrestore(&ap->host_set->lock, flags);
3660
3661
	if (!rc)
3662
		wait_for_completion(&wait);
3663
3664
	return rc;
3665
}
3666
3667
static int ata_flush_cache(struct ata_port *ap, struct ata_device *dev)
3668
{
3669
	u8 cmd;
3670
3671
	if (!ata_try_flush_cache(dev))
3672
		return 0;
3673
3674
	if (ata_id_has_flush_ext(dev->id))
3675
		cmd = ATA_CMD_FLUSH_EXT;
3676
	else
3677
		cmd = ATA_CMD_FLUSH;
3678
3679
	return ata_do_simple_cmd(ap, dev, cmd);
3680
}
3681
3682
static int ata_standby_drive(struct ata_port *ap, struct ata_device *dev)
3683
{
3684
	return ata_do_simple_cmd(ap, dev, ATA_CMD_STANDBYNOW1);
3685
}
3686
3687
static int ata_start_drive(struct ata_port *ap, struct ata_device *dev)
3688
{
3689
	return ata_do_simple_cmd(ap, dev, ATA_CMD_IDLEIMMEDIATE);
3690
}
3691
3692
/**
3693
 *	ata_device_resume - wakeup a previously suspended devices
3694
 *
3695
 *	Kick the drive back into action, by sending it an idle immediate
3696
 *	command and making sure its transfer mode matches between drive
3697
 *	and host.
3698
 *
3699
 */
3700
int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
3701
{
3702
	if (ap->flags & ATA_FLAG_SUSPENDED) {
3703
		ap->flags &= ~ATA_FLAG_SUSPENDED;
3704
		ata_set_mode(ap);
3705
	}
3706
	if (!ata_dev_present(dev))
3707
		return 0;
3708
	if (dev->class == ATA_DEV_ATA)
3709
		ata_start_drive(ap, dev);
3710
3711
	return 0;
3712
}
3713
3714
/**
3715
 *	ata_device_suspend - prepare a device for suspend
3716
 *
3717
 *	Flush the cache on the drive, if appropriate, then issue a
3718
 *	standbynow command.
3719
 *
3720
 */
3721
int ata_device_suspend(struct ata_port *ap, struct ata_device *dev)
3722
{
3723
	if (!ata_dev_present(dev))
3724
		return 0;
3725
	if (dev->class == ATA_DEV_ATA)
3726
		ata_flush_cache(ap, dev);
3727
3728
	ata_standby_drive(ap, dev);
3729
	ap->flags |= ATA_FLAG_SUSPENDED;
3730
	return 0;
3731
}
3732
3635
int ata_port_start (struct ata_port *ap)
3733
int ata_port_start (struct ata_port *ap)
3636
{
3734
{
3637
	struct device *dev = ap->host_set->dev;
3735
	struct device *dev = ap->host_set->dev;
Lines 4337-4342 Link Here
4337
4435
4338
	return (tmp == bits->val) ? 1 : 0;
4436
	return (tmp == bits->val) ? 1 : 0;
4339
}
4437
}
4438
4439
int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state)
4440
{
4441
	pci_save_state(pdev);
4442
	pci_disable_device(pdev);
4443
	pci_set_power_state(pdev, PCI_D3hot);
4444
	return 0;
4445
}
4446
4447
int ata_pci_device_resume(struct pci_dev *pdev)
4448
{
4449
	pci_set_power_state(pdev, PCI_D0);
4450
	pci_restore_state(pdev);
4451
	pci_enable_device(pdev);
4452
	pci_set_master(pdev);
4453
	return 0;
4454
}
4340
#endif /* CONFIG_PCI */
4455
#endif /* CONFIG_PCI */
4341
4456
4342
4457
Lines 4413-4416 Link Here
4413
EXPORT_SYMBOL_GPL(ata_pci_init_native_mode);
4528
EXPORT_SYMBOL_GPL(ata_pci_init_native_mode);
4414
EXPORT_SYMBOL_GPL(ata_pci_init_one);
4529
EXPORT_SYMBOL_GPL(ata_pci_init_one);
4415
EXPORT_SYMBOL_GPL(ata_pci_remove_one);
4530
EXPORT_SYMBOL_GPL(ata_pci_remove_one);
4531
EXPORT_SYMBOL_GPL(ata_pci_device_suspend);
4532
EXPORT_SYMBOL_GPL(ata_pci_device_resume);
4416
#endif /* CONFIG_PCI */
4533
#endif /* CONFIG_PCI */
4534
4535
EXPORT_SYMBOL_GPL(ata_device_suspend);
4536
EXPORT_SYMBOL_GPL(ata_device_resume);
4537
EXPORT_SYMBOL_GPL(ata_scsi_device_suspend);
4538
EXPORT_SYMBOL_GPL(ata_scsi_device_resume);
(-)linux-2.6.12/drivers/scsi/libata-scsi.c (+16 lines)
Lines 390-395 Link Here
390
	return 0;
390
	return 0;
391
}
391
}
392
392
393
int ata_scsi_device_resume(struct scsi_device *sdev)
394
{
395
	struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0];
396
	struct ata_device *dev = &ap->device[sdev->id];
397
398
	return ata_device_resume(ap, dev);
399
}
400
401
int ata_scsi_device_suspend(struct scsi_device *sdev)
402
{
403
	struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0];
404
	struct ata_device *dev = &ap->device[sdev->id];
405
406
	return ata_device_suspend(ap, dev);
407
}
408
393
/**
409
/**
394
 *	ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command
410
 *	ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command
395
 *	@qc: Storage for translated ATA taskfile
411
 *	@qc: Storage for translated ATA taskfile
(-)linux-2.6.12/drivers/scsi/scsi_lib.c (-1 / +2 lines)
Lines 1855-1862 Link Here
1855
void
1855
void
1856
scsi_device_resume(struct scsi_device *sdev)
1856
scsi_device_resume(struct scsi_device *sdev)
1857
{
1857
{
1858
	if(scsi_device_set_state(sdev, SDEV_RUNNING))
1858
	if (scsi_device_set_state(sdev, SDEV_RUNNING))
1859
		return;
1859
		return;
1860
1860
	scsi_run_queue(sdev->request_queue);
1861
	scsi_run_queue(sdev->request_queue);
1861
}
1862
}
1862
EXPORT_SYMBOL(scsi_device_resume);
1863
EXPORT_SYMBOL(scsi_device_resume);
(-)linux-2.6.12/drivers/scsi/scsi_sysfs.c (+31 lines)
Lines 199-207 Link Here
199
	return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
199
	return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
200
}
200
}
201
201
202
static int scsi_bus_suspend(struct device * dev, pm_message_t state)
203
{
204
	struct scsi_device *sdev = to_scsi_device(dev);
205
	struct scsi_host_template *sht = sdev->host->hostt;
206
	int err;
207
208
	err = scsi_device_quiesce(sdev);
209
	if (err)
210
		return err;
211
212
	if (sht->suspend)
213
		err = sht->suspend(sdev);
214
215
	return err;
216
}
217
218
static int scsi_bus_resume(struct device * dev)
219
{
220
	struct scsi_device *sdev = to_scsi_device(dev);
221
	struct scsi_host_template *sht = sdev->host->hostt;
222
	int err = 0;
223
224
	if (sht->resume)
225
		err = sht->resume(sdev);
226
227
	scsi_device_resume(sdev);
228
	return err;
229
}
230
202
struct bus_type scsi_bus_type = {
231
struct bus_type scsi_bus_type = {
203
        .name		= "scsi",
232
        .name		= "scsi",
204
        .match		= scsi_bus_match,
233
        .match		= scsi_bus_match,
234
	.suspend	= scsi_bus_suspend,
235
	.resume		= scsi_bus_resume,
205
};
236
};
206
237
207
int scsi_sysfs_register(void)
238
int scsi_sysfs_register(void)
(-)linux-2.6.12/include/linux/ata.h (+2 lines)
Lines 125-130 Link Here
125
	ATA_CMD_PACKET		= 0xA0,
125
	ATA_CMD_PACKET		= 0xA0,
126
	ATA_CMD_VERIFY		= 0x40,
126
	ATA_CMD_VERIFY		= 0x40,
127
	ATA_CMD_VERIFY_EXT	= 0x42,
127
	ATA_CMD_VERIFY_EXT	= 0x42,
128
	ATA_CMD_STANDBYNOW1	= 0xE0,
129
	ATA_CMD_IDLEIMMEDIATE	= 0xE1,
128
130
129
	/* SETFEATURES stuff */
131
	/* SETFEATURES stuff */
130
	SETFEATURES_XFER	= 0x03,
132
	SETFEATURES_XFER	= 0x03,
(-)linux-2.6.12/include/linux/libata.h (+7 lines)
Lines 113-118 Link Here
113
	ATA_FLAG_MMIO		= (1 << 6), /* use MMIO, not PIO */
113
	ATA_FLAG_MMIO		= (1 << 6), /* use MMIO, not PIO */
114
	ATA_FLAG_SATA_RESET	= (1 << 7), /* use COMRESET */
114
	ATA_FLAG_SATA_RESET	= (1 << 7), /* use COMRESET */
115
	ATA_FLAG_PIO_DMA	= (1 << 8), /* PIO cmds via DMA */
115
	ATA_FLAG_PIO_DMA	= (1 << 8), /* PIO cmds via DMA */
116
	ATA_FLAG_SUSPENDED	= (1 << 9), /* port is suspended */
116
117
117
	ATA_QCFLAG_ACTIVE	= (1 << 1), /* cmd not yet ack'd to scsi lyer */
118
	ATA_QCFLAG_ACTIVE	= (1 << 1), /* cmd not yet ack'd to scsi lyer */
118
	ATA_QCFLAG_SG		= (1 << 3), /* have s/g table? */
119
	ATA_QCFLAG_SG		= (1 << 3), /* have s/g table? */
Lines 387-392 Link Here
387
extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
388
extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
388
			     unsigned int n_ports);
389
			     unsigned int n_ports);
389
extern void ata_pci_remove_one (struct pci_dev *pdev);
390
extern void ata_pci_remove_one (struct pci_dev *pdev);
391
extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state);
392
extern int ata_pci_device_resume(struct pci_dev *pdev);
390
#endif /* CONFIG_PCI */
393
#endif /* CONFIG_PCI */
391
extern int ata_device_add(struct ata_probe_ent *ent);
394
extern int ata_device_add(struct ata_probe_ent *ent);
392
extern int ata_scsi_detect(Scsi_Host_Template *sht);
395
extern int ata_scsi_detect(Scsi_Host_Template *sht);
Lines 395-400 Link Here
395
extern int ata_scsi_error(struct Scsi_Host *host);
398
extern int ata_scsi_error(struct Scsi_Host *host);
396
extern int ata_scsi_release(struct Scsi_Host *host);
399
extern int ata_scsi_release(struct Scsi_Host *host);
397
extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
400
extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
401
extern int ata_scsi_device_resume(struct scsi_device *);
402
extern int ata_scsi_device_suspend(struct scsi_device *);
403
extern int ata_device_resume(struct ata_port *, struct ata_device *);
404
extern int ata_device_suspend(struct ata_port *, struct ata_device *);
398
/*
405
/*
399
 * Default driver ops implementations
406
 * Default driver ops implementations
400
 */
407
 */
(-)linux-2.6.12/include/scsi/scsi_host.h (+6 lines)
Lines 270-275 Link Here
270
	int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int);
270
	int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int);
271
271
272
	/*
272
	/*
273
	 * suspend support
274
	 */
275
	int (*resume)(struct scsi_device *);
276
	int (*suspend)(struct scsi_device *);
277
278
	/*
273
	 * Name of proc directory
279
	 * Name of proc directory
274
	 */
280
	 */
275
	char *proc_name;
281
	char *proc_name;

Return to bug 104647