mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
ide: filter out "default" transfer mode values in set_xfer_rate()
* Filter out "default" transfer mode values (0x00 - default PIO mode, 0x01 - default PIO mode w/ IORDY disabled) in write handler for obsoleted /proc/ide/hd?/settings:current_speed setting. Allowing "default" transfer mode values is a dangerous thing to do as we don't support programming controller to the "default" transfer mode and devices often use different values for the default and maximum PIO mode (i.e. PIO2 default and PIO4 maximum) so the controller will stay programmed for higher PIO mode while device will use the lower PIO mode. There is no functionality loss as by using special IOCTLs device can still be programmed to "default" transfer modes (it is only useful for debugging/testing purposes anyway). * Remove no longer needed IDE_HFLAG_ABUSE_SET_DMA_MODE host flag, it was previously used by few host drivers to program the controller to PIO0 timings for "default" transfer mode == 0x01 (although some host drivers would program invalid PIO timings instead). * Cleanup ide_set_xfer_rate() and add BUG_ON(). Suggested-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
parent
c30daac190
commit
3b2a5c7149
@ -266,22 +266,11 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
|
||||
|
||||
rate = ide_rate_filter(drive, rate);
|
||||
|
||||
BUG_ON(rate < XFER_PIO_0);
|
||||
|
||||
if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5)
|
||||
return ide_set_pio_mode(drive, rate);
|
||||
|
||||
/*
|
||||
* TODO: transfer modes 0x00-0x07 passed from the user-space are
|
||||
* currently handled here which needs fixing (please note that such
|
||||
* case could happen iff the transfer mode has already been set on
|
||||
* the device by ide-proc.c::set_xfer_rate()).
|
||||
*/
|
||||
if (rate < XFER_PIO_0) {
|
||||
if (hwif->host_flags & IDE_HFLAG_ABUSE_SET_DMA_MODE)
|
||||
return ide_set_dma_mode(drive, rate);
|
||||
else
|
||||
return ide_config_drive_speed(drive, rate);
|
||||
}
|
||||
|
||||
return ide_set_dma_mode(drive, rate);
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg)
|
||||
ide_task_t task;
|
||||
int err;
|
||||
|
||||
if (arg < 0 || (arg > 1 && arg < XFER_PIO_0) || arg > XFER_UDMA_6)
|
||||
if (arg < XFER_PIO_0 || arg > XFER_UDMA_6)
|
||||
return -EINVAL;
|
||||
|
||||
memset(&task, 0, sizeof(task));
|
||||
@ -357,7 +357,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg)
|
||||
|
||||
err = ide_no_data_taskfile(drive, &task);
|
||||
|
||||
if (!err && arg) {
|
||||
if (!err) {
|
||||
ide_set_xfer_rate(drive, (u8) arg);
|
||||
ide_driveid_update(drive);
|
||||
}
|
||||
|
@ -195,7 +195,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
|
||||
.host_flags = IDE_HFLAG_SERIALIZE |
|
||||
IDE_HFLAG_NO_ATAPI_DMA |
|
||||
IDE_HFLAG_NO_DSC |
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE |
|
||||
IDE_HFLAG_OFF_BOARD,
|
||||
.pio_mask = ATA_PIO4,
|
||||
.mwdma_mask = ATA_MWDMA2,
|
||||
@ -205,7 +204,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
|
||||
.init_chipset = init_chipset_aec62xx,
|
||||
.port_ops = &atp86x_port_ops,
|
||||
.host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA |
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE |
|
||||
IDE_HFLAG_OFF_BOARD,
|
||||
.pio_mask = ATA_PIO4,
|
||||
.mwdma_mask = ATA_MWDMA2,
|
||||
@ -216,7 +214,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
|
||||
.enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
|
||||
.port_ops = &atp86x_port_ops,
|
||||
.host_flags = IDE_HFLAG_NO_ATAPI_DMA |
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE |
|
||||
IDE_HFLAG_NON_BOOTABLE,
|
||||
.pio_mask = ATA_PIO4,
|
||||
.mwdma_mask = ATA_MWDMA2,
|
||||
@ -226,7 +223,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
|
||||
.init_chipset = init_chipset_aec62xx,
|
||||
.port_ops = &atp86x_port_ops,
|
||||
.host_flags = IDE_HFLAG_NO_ATAPI_DMA |
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE |
|
||||
IDE_HFLAG_OFF_BOARD,
|
||||
.pio_mask = ATA_PIO4,
|
||||
.mwdma_mask = ATA_MWDMA2,
|
||||
@ -237,7 +233,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
|
||||
.enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
|
||||
.port_ops = &atp86x_port_ops,
|
||||
.host_flags = IDE_HFLAG_NO_ATAPI_DMA |
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE |
|
||||
IDE_HFLAG_OFF_BOARD,
|
||||
.pio_mask = ATA_PIO4,
|
||||
.mwdma_mask = ATA_MWDMA2,
|
||||
|
@ -218,7 +218,6 @@ static const struct ide_port_ops amd_port_ops = {
|
||||
|
||||
#define IDE_HFLAGS_AMD \
|
||||
(IDE_HFLAG_PIO_NO_BLACKLIST | \
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE | \
|
||||
IDE_HFLAG_POST_SET_MODE | \
|
||||
IDE_HFLAG_IO_32BIT | \
|
||||
IDE_HFLAG_UNMASK_IRQS)
|
||||
|
@ -97,8 +97,7 @@ static const struct ide_port_ops cs5520_port_ops = {
|
||||
.name = name_str, \
|
||||
.port_ops = &cs5520_port_ops, \
|
||||
.host_flags = IDE_HFLAG_ISA_PORTS | \
|
||||
IDE_HFLAG_CS5520 | \
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE, \
|
||||
IDE_HFLAG_CS5520, \
|
||||
.pio_mask = ATA_PIO4, \
|
||||
}
|
||||
|
||||
|
@ -171,8 +171,7 @@ static const struct ide_port_ops cs5535_port_ops = {
|
||||
static const struct ide_port_info cs5535_chipset __devinitdata = {
|
||||
.name = "CS5535",
|
||||
.port_ops = &cs5535_port_ops,
|
||||
.host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE |
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE,
|
||||
.host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE,
|
||||
.pio_mask = ATA_PIO4,
|
||||
.mwdma_mask = ATA_MWDMA2,
|
||||
.udma_mask = ATA_UDMA4,
|
||||
|
@ -123,7 +123,6 @@ static const struct ide_port_ops hpt34x_port_ops = {
|
||||
#define IDE_HFLAGS_HPT34X \
|
||||
(IDE_HFLAG_NO_ATAPI_DMA | \
|
||||
IDE_HFLAG_NO_DSC | \
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE | \
|
||||
IDE_HFLAG_NO_AUTODMA)
|
||||
|
||||
static const struct ide_port_info hpt34x_chipsets[] __devinitdata = {
|
||||
|
@ -1409,7 +1409,6 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2)
|
||||
|
||||
#define IDE_HFLAGS_HPT3XX \
|
||||
(IDE_HFLAG_NO_ATAPI_DMA | \
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE | \
|
||||
IDE_HFLAG_OFF_BOARD)
|
||||
|
||||
static const struct ide_port_ops hpt3xx_port_ops = {
|
||||
|
@ -312,7 +312,6 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
|
||||
|
||||
#define IDE_HFLAGS_PDC202XX \
|
||||
(IDE_HFLAG_ERROR_STOPS_FIFO | \
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE | \
|
||||
IDE_HFLAG_OFF_BOARD)
|
||||
|
||||
static const struct ide_port_ops pdc20246_port_ops = {
|
||||
|
@ -349,9 +349,7 @@ static const struct ide_port_ops svwks_port_ops = {
|
||||
.cable_detect = svwks_cable_detect,
|
||||
};
|
||||
|
||||
#define IDE_HFLAGS_SVWKS \
|
||||
(IDE_HFLAG_LEGACY_IRQS | \
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE)
|
||||
#define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS
|
||||
|
||||
static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
|
||||
{ /* 0 */
|
||||
|
@ -206,8 +206,7 @@ static const struct ide_port_info tc86c001_chipset __devinitdata = {
|
||||
.init_hwif = init_hwif_tc86c001,
|
||||
.port_ops = &tc86c001_port_ops,
|
||||
.dma_ops = &tc86c001_dma_ops,
|
||||
.host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD |
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE,
|
||||
.host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD,
|
||||
.pio_mask = ATA_PIO4,
|
||||
.mwdma_mask = ATA_MWDMA2,
|
||||
.udma_mask = ATA_UDMA4,
|
||||
|
@ -425,7 +425,6 @@ static const struct ide_port_info via82cxxx_chipset __devinitdata = {
|
||||
.enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } },
|
||||
.port_ops = &via_port_ops,
|
||||
.host_flags = IDE_HFLAG_PIO_NO_BLACKLIST |
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE |
|
||||
IDE_HFLAG_POST_SET_MODE |
|
||||
IDE_HFLAG_IO_32BIT,
|
||||
.pio_mask = ATA_PIO5,
|
||||
|
@ -1085,7 +1085,6 @@ enum {
|
||||
IDE_HFLAG_IO_32BIT = (1 << 24),
|
||||
/* unmask IRQs */
|
||||
IDE_HFLAG_UNMASK_IRQS = (1 << 25),
|
||||
IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26),
|
||||
/* serialize ports if DMA is possible (for sl82c105) */
|
||||
IDE_HFLAG_SERIALIZE_DMA = (1 << 27),
|
||||
/* force host out of "simplex" mode */
|
||||
|
Loading…
Reference in New Issue
Block a user