Commit 5a4f13fa authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide-2.6:
  ide: memory overrun in ide_get_identity_ioctl() on big endian machines using ioctl HDIO_OBSOLETE_IDENTITY
  ide: fix resume for CONFIG_BLK_DEV_IDEACPI=y
  ide-cd: handle fragmented packet commands gracefully
  ide: always kill the whole request on error
  ide: fix ide_kill_rq() for special ide-{floppy,tape} driver requests
parents ec9c45d4 e18ed145
...@@ -92,6 +92,11 @@ int ide_acpi_init(void) ...@@ -92,6 +92,11 @@ int ide_acpi_init(void)
return 0; return 0;
} }
bool ide_port_acpi(ide_hwif_t *hwif)
{
return ide_noacpi == 0 && hwif->acpidata;
}
/** /**
* ide_get_dev_handle - finds acpi_handle and PCI device.function * ide_get_dev_handle - finds acpi_handle and PCI device.function
* @dev: device to locate * @dev: device to locate
...@@ -352,9 +357,6 @@ int ide_acpi_exec_tfs(ide_drive_t *drive) ...@@ -352,9 +357,6 @@ int ide_acpi_exec_tfs(ide_drive_t *drive)
unsigned long gtf_address; unsigned long gtf_address;
unsigned long obj_loc; unsigned long obj_loc;
if (ide_noacpi)
return 0;
DEBPRINT("call get_GTF, drive=%s port=%d\n", drive->name, drive->dn); DEBPRINT("call get_GTF, drive=%s port=%d\n", drive->name, drive->dn);
ret = do_drive_get_GTF(drive, &gtf_length, &gtf_address, &obj_loc); ret = do_drive_get_GTF(drive, &gtf_length, &gtf_address, &obj_loc);
...@@ -389,16 +391,6 @@ void ide_acpi_get_timing(ide_hwif_t *hwif) ...@@ -389,16 +391,6 @@ void ide_acpi_get_timing(ide_hwif_t *hwif)
struct acpi_buffer output; struct acpi_buffer output;
union acpi_object *out_obj; union acpi_object *out_obj;
if (ide_noacpi)
return;
DEBPRINT("ENTER:\n");
if (!hwif->acpidata) {
DEBPRINT("no ACPI data for %s\n", hwif->name);
return;
}
/* Setting up output buffer for _GTM */ /* Setting up output buffer for _GTM */
output.length = ACPI_ALLOCATE_BUFFER; output.length = ACPI_ALLOCATE_BUFFER;
output.pointer = NULL; /* ACPI-CA sets this; save/free it later */ output.pointer = NULL; /* ACPI-CA sets this; save/free it later */
...@@ -479,16 +471,6 @@ void ide_acpi_push_timing(ide_hwif_t *hwif) ...@@ -479,16 +471,6 @@ void ide_acpi_push_timing(ide_hwif_t *hwif)
struct ide_acpi_drive_link *master = &hwif->acpidata->master; struct ide_acpi_drive_link *master = &hwif->acpidata->master;
struct ide_acpi_drive_link *slave = &hwif->acpidata->slave; struct ide_acpi_drive_link *slave = &hwif->acpidata->slave;
if (ide_noacpi)
return;
DEBPRINT("ENTER:\n");
if (!hwif->acpidata) {
DEBPRINT("no ACPI data for %s\n", hwif->name);
return;
}
/* Give the GTM buffer + drive Identify data to the channel via the /* Give the GTM buffer + drive Identify data to the channel via the
* _STM method: */ * _STM method: */
/* setup input parameters buffer for _STM */ /* setup input parameters buffer for _STM */
...@@ -527,16 +509,11 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on) ...@@ -527,16 +509,11 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
ide_drive_t *drive; ide_drive_t *drive;
int i; int i;
if (ide_noacpi || ide_noacpi_psx) if (ide_noacpi_psx)
return; return;
DEBPRINT("ENTER:\n"); DEBPRINT("ENTER:\n");
if (!hwif->acpidata) {
DEBPRINT("no ACPI data for %s\n", hwif->name);
return;
}
/* channel first and then drives for power on and verse versa for power off */ /* channel first and then drives for power on and verse versa for power off */
if (on) if (on)
acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
...@@ -616,7 +593,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif) ...@@ -616,7 +593,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
drive->name, err); drive->name, err);
} }
if (!ide_acpionboot) { if (ide_noacpi || ide_acpionboot == 0) {
DEBPRINT("ACPI methods disabled on boot\n"); DEBPRINT("ACPI methods disabled on boot\n");
return; return;
} }
......
...@@ -592,9 +592,19 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) ...@@ -592,9 +592,19 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
} }
} else if (!blk_pc_request(rq)) { } else if (!blk_pc_request(rq)) {
ide_cd_request_sense_fixup(drive, cmd); ide_cd_request_sense_fixup(drive, cmd);
/* complain if we still have data left to transfer */
uptodate = cmd->nleft ? 0 : 1; uptodate = cmd->nleft ? 0 : 1;
if (uptodate == 0)
/*
* suck out the remaining bytes from the drive in an
* attempt to complete the data xfer. (see BZ#13399)
*/
if (!(stat & ATA_ERR) && !uptodate && thislen) {
ide_pio_bytes(drive, cmd, write, thislen);
uptodate = cmd->nleft ? 0 : 1;
}
if (!uptodate)
rq->cmd_flags |= REQ_FAILED; rq->cmd_flags |= REQ_FAILED;
} }
goto out_end; goto out_end;
......
...@@ -183,6 +183,6 @@ ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq) ...@@ -183,6 +183,6 @@ ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq)
err = setfunc(drive, *(int *)&rq->cmd[1]); err = setfunc(drive, *(int *)&rq->cmd[1]);
if (err) if (err)
rq->errors = err; rq->errors = err;
ide_complete_rq(drive, err, ide_rq_bytes(rq)); ide_complete_rq(drive, err, blk_rq_bytes(rq));
return ide_stopped; return ide_stopped;
} }
...@@ -149,7 +149,7 @@ static inline void ide_complete_drive_reset(ide_drive_t *drive, int err) ...@@ -149,7 +149,7 @@ static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) { if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) {
if (err <= 0 && rq->errors == 0) if (err <= 0 && rq->errors == 0)
rq->errors = -EIO; rq->errors = -EIO;
ide_complete_rq(drive, err ? err : 0, ide_rq_bytes(rq)); ide_complete_rq(drive, err ? err : 0, blk_rq_bytes(rq));
} }
} }
......
...@@ -293,7 +293,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, ...@@ -293,7 +293,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
drive->failed_pc = NULL; drive->failed_pc = NULL;
if (blk_fs_request(rq) == 0 && rq->errors == 0) if (blk_fs_request(rq) == 0 && rq->errors == 0)
rq->errors = -EIO; rq->errors = -EIO;
ide_complete_rq(drive, -EIO, ide_rq_bytes(rq)); ide_complete_rq(drive, -EIO, blk_rq_bytes(rq));
return ide_stopped; return ide_stopped;
} }
......
...@@ -112,16 +112,6 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err) ...@@ -112,16 +112,6 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
} }
} }
/* obsolete, blk_rq_bytes() should be used instead */
unsigned int ide_rq_bytes(struct request *rq)
{
if (blk_pc_request(rq))
return blk_rq_bytes(rq);
else
return blk_rq_cur_sectors(rq) << 9;
}
EXPORT_SYMBOL_GPL(ide_rq_bytes);
int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes) int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes)
{ {
ide_hwif_t *hwif = drive->hwif; ide_hwif_t *hwif = drive->hwif;
...@@ -152,14 +142,14 @@ void ide_kill_rq(ide_drive_t *drive, struct request *rq) ...@@ -152,14 +142,14 @@ void ide_kill_rq(ide_drive_t *drive, struct request *rq)
if ((media == ide_floppy || media == ide_tape) && drv_req) { if ((media == ide_floppy || media == ide_tape) && drv_req) {
rq->errors = 0; rq->errors = 0;
ide_complete_rq(drive, 0, blk_rq_bytes(rq));
} else { } else {
if (media == ide_tape) if (media == ide_tape)
rq->errors = IDE_DRV_ERROR_GENERAL; rq->errors = IDE_DRV_ERROR_GENERAL;
else if (blk_fs_request(rq) == 0 && rq->errors == 0) else if (blk_fs_request(rq) == 0 && rq->errors == 0)
rq->errors = -EIO; rq->errors = -EIO;
ide_complete_rq(drive, -EIO, ide_rq_bytes(rq));
} }
ide_complete_rq(drive, -EIO, blk_rq_bytes(rq));
} }
static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
......
...@@ -64,7 +64,8 @@ static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd, ...@@ -64,7 +64,8 @@ static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd,
goto out; goto out;
} }
id = kmalloc(size, GFP_KERNEL); /* ata_id_to_hd_driveid() relies on 'id' to be fully allocated. */
id = kmalloc(ATA_ID_WORDS * 2, GFP_KERNEL);
if (id == NULL) { if (id == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
......
...@@ -10,9 +10,11 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) ...@@ -10,9 +10,11 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
struct request_pm_state rqpm; struct request_pm_state rqpm;
int ret; int ret;
if (ide_port_acpi(hwif)) {
/* call ACPI _GTM only once */ /* call ACPI _GTM only once */
if ((drive->dn & 1) == 0 || pair == NULL) if ((drive->dn & 1) == 0 || pair == NULL)
ide_acpi_get_timing(hwif); ide_acpi_get_timing(hwif);
}
memset(&rqpm, 0, sizeof(rqpm)); memset(&rqpm, 0, sizeof(rqpm));
rq = blk_get_request(drive->queue, READ, __GFP_WAIT); rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
...@@ -26,9 +28,11 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg) ...@@ -26,9 +28,11 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
ret = blk_execute_rq(drive->queue, NULL, rq, 0); ret = blk_execute_rq(drive->queue, NULL, rq, 0);
blk_put_request(rq); blk_put_request(rq);
if (ret == 0 && ide_port_acpi(hwif)) {
/* call ACPI _PS3 only after both devices are suspended */ /* call ACPI _PS3 only after both devices are suspended */
if (ret == 0 && ((drive->dn & 1) || pair == NULL)) if ((drive->dn & 1) || pair == NULL)
ide_acpi_set_state(hwif, 0); ide_acpi_set_state(hwif, 0);
}
return ret; return ret;
} }
...@@ -42,6 +46,7 @@ int generic_ide_resume(struct device *dev) ...@@ -42,6 +46,7 @@ int generic_ide_resume(struct device *dev)
struct request_pm_state rqpm; struct request_pm_state rqpm;
int err; int err;
if (ide_port_acpi(hwif)) {
/* call ACPI _PS0 / _STM only once */ /* call ACPI _PS0 / _STM only once */
if ((drive->dn & 1) == 0 || pair == NULL) { if ((drive->dn & 1) == 0 || pair == NULL) {
ide_acpi_set_state(hwif, 1); ide_acpi_set_state(hwif, 1);
...@@ -49,6 +54,7 @@ int generic_ide_resume(struct device *dev) ...@@ -49,6 +54,7 @@ int generic_ide_resume(struct device *dev)
} }
ide_acpi_exec_tfs(drive); ide_acpi_exec_tfs(drive);
}
memset(&rqpm, 0, sizeof(rqpm)); memset(&rqpm, 0, sizeof(rqpm));
rq = blk_get_request(drive->queue, READ, __GFP_WAIT); rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
......
...@@ -1062,7 +1062,6 @@ int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned, unsigned l ...@@ -1062,7 +1062,6 @@ int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned, unsigned l
extern int ide_vlb_clk; extern int ide_vlb_clk;
extern int ide_pci_clk; extern int ide_pci_clk;
unsigned int ide_rq_bytes(struct request *);
int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int); int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int);
void ide_kill_rq(ide_drive_t *, struct request *); void ide_kill_rq(ide_drive_t *, struct request *);
...@@ -1420,6 +1419,7 @@ static inline void ide_dma_unmap_sg(ide_drive_t *drive, ...@@ -1420,6 +1419,7 @@ static inline void ide_dma_unmap_sg(ide_drive_t *drive,
#ifdef CONFIG_BLK_DEV_IDEACPI #ifdef CONFIG_BLK_DEV_IDEACPI
int ide_acpi_init(void); int ide_acpi_init(void);
bool ide_port_acpi(ide_hwif_t *hwif);
extern int ide_acpi_exec_tfs(ide_drive_t *drive); extern int ide_acpi_exec_tfs(ide_drive_t *drive);
extern void ide_acpi_get_timing(ide_hwif_t *hwif); extern void ide_acpi_get_timing(ide_hwif_t *hwif);
extern void ide_acpi_push_timing(ide_hwif_t *hwif); extern void ide_acpi_push_timing(ide_hwif_t *hwif);
...@@ -1428,6 +1428,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *); ...@@ -1428,6 +1428,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *);
extern void ide_acpi_set_state(ide_hwif_t *hwif, int on); extern void ide_acpi_set_state(ide_hwif_t *hwif, int on);
#else #else
static inline int ide_acpi_init(void) { return 0; } static inline int ide_acpi_init(void) { return 0; }
static inline bool ide_port_acpi(ide_hwif_t *hwif) { return 0; }
static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; } static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; }
static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; } static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; }
static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; } static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment