Skip to content

Commit 3b2a5c7

Browse files
committed
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>
1 parent c30daac commit 3b2a5c7

13 files changed

Lines changed: 8 additions & 35 deletions

File tree

‎drivers/ide/ide-lib.c‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -266,22 +266,11 @@ int ide_set_xfer_rate(ide_drive_t *drive, u8 rate)
266266

267267
rate = ide_rate_filter(drive, rate);
268268

269+
BUG_ON(rate < XFER_PIO_0);
270+
269271
if (rate >= XFER_PIO_0 && rate <= XFER_PIO_5)
270272
return ide_set_pio_mode(drive, rate);
271273

272-
/*
273-
* TODO: transfer modes 0x00-0x07 passed from the user-space are
274-
* currently handled here which needs fixing (please note that such
275-
* case could happen iff the transfer mode has already been set on
276-
* the device by ide-proc.c::set_xfer_rate()).
277-
*/
278-
if (rate < XFER_PIO_0) {
279-
if (hwif->host_flags & IDE_HFLAG_ABUSE_SET_DMA_MODE)
280-
return ide_set_dma_mode(drive, rate);
281-
else
282-
return ide_config_drive_speed(drive, rate);
283-
}
284-
285274
return ide_set_dma_mode(drive, rate);
286275
}
287276

‎drivers/ide/ide-proc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg)
345345
ide_task_t task;
346346
int err;
347347

348-
if (arg < 0 || (arg > 1 && arg < XFER_PIO_0) || arg > XFER_UDMA_6)
348+
if (arg < XFER_PIO_0 || arg > XFER_UDMA_6)
349349
return -EINVAL;
350350

351351
memset(&task, 0, sizeof(task));
@@ -357,7 +357,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg)
357357

358358
err = ide_no_data_taskfile(drive, &task);
359359

360-
if (!err && arg) {
360+
if (!err) {
361361
ide_set_xfer_rate(drive, (u8) arg);
362362
ide_driveid_update(drive);
363363
}

‎drivers/ide/pci/aec62xx.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
195195
.host_flags = IDE_HFLAG_SERIALIZE |
196196
IDE_HFLAG_NO_ATAPI_DMA |
197197
IDE_HFLAG_NO_DSC |
198-
IDE_HFLAG_ABUSE_SET_DMA_MODE |
199198
IDE_HFLAG_OFF_BOARD,
200199
.pio_mask = ATA_PIO4,
201200
.mwdma_mask = ATA_MWDMA2,
@@ -205,7 +204,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
205204
.init_chipset = init_chipset_aec62xx,
206205
.port_ops = &atp86x_port_ops,
207206
.host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA |
208-
IDE_HFLAG_ABUSE_SET_DMA_MODE |
209207
IDE_HFLAG_OFF_BOARD,
210208
.pio_mask = ATA_PIO4,
211209
.mwdma_mask = ATA_MWDMA2,
@@ -216,7 +214,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
216214
.enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
217215
.port_ops = &atp86x_port_ops,
218216
.host_flags = IDE_HFLAG_NO_ATAPI_DMA |
219-
IDE_HFLAG_ABUSE_SET_DMA_MODE |
220217
IDE_HFLAG_NON_BOOTABLE,
221218
.pio_mask = ATA_PIO4,
222219
.mwdma_mask = ATA_MWDMA2,
@@ -226,7 +223,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
226223
.init_chipset = init_chipset_aec62xx,
227224
.port_ops = &atp86x_port_ops,
228225
.host_flags = IDE_HFLAG_NO_ATAPI_DMA |
229-
IDE_HFLAG_ABUSE_SET_DMA_MODE |
230226
IDE_HFLAG_OFF_BOARD,
231227
.pio_mask = ATA_PIO4,
232228
.mwdma_mask = ATA_MWDMA2,
@@ -237,7 +233,6 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
237233
.enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
238234
.port_ops = &atp86x_port_ops,
239235
.host_flags = IDE_HFLAG_NO_ATAPI_DMA |
240-
IDE_HFLAG_ABUSE_SET_DMA_MODE |
241236
IDE_HFLAG_OFF_BOARD,
242237
.pio_mask = ATA_PIO4,
243238
.mwdma_mask = ATA_MWDMA2,

‎drivers/ide/pci/amd74xx.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ static const struct ide_port_ops amd_port_ops = {
218218

219219
#define IDE_HFLAGS_AMD \
220220
(IDE_HFLAG_PIO_NO_BLACKLIST | \
221-
IDE_HFLAG_ABUSE_SET_DMA_MODE | \
222221
IDE_HFLAG_POST_SET_MODE | \
223222
IDE_HFLAG_IO_32BIT | \
224223
IDE_HFLAG_UNMASK_IRQS)

‎drivers/ide/pci/cs5520.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ static const struct ide_port_ops cs5520_port_ops = {
9797
.name = name_str, \
9898
.port_ops = &cs5520_port_ops, \
9999
.host_flags = IDE_HFLAG_ISA_PORTS | \
100-
IDE_HFLAG_CS5520 | \
101-
IDE_HFLAG_ABUSE_SET_DMA_MODE, \
100+
IDE_HFLAG_CS5520, \
102101
.pio_mask = ATA_PIO4, \
103102
}
104103

‎drivers/ide/pci/cs5535.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ static const struct ide_port_ops cs5535_port_ops = {
171171
static const struct ide_port_info cs5535_chipset __devinitdata = {
172172
.name = "CS5535",
173173
.port_ops = &cs5535_port_ops,
174-
.host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE |
175-
IDE_HFLAG_ABUSE_SET_DMA_MODE,
174+
.host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE,
176175
.pio_mask = ATA_PIO4,
177176
.mwdma_mask = ATA_MWDMA2,
178177
.udma_mask = ATA_UDMA4,

‎drivers/ide/pci/hpt34x.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ static const struct ide_port_ops hpt34x_port_ops = {
123123
#define IDE_HFLAGS_HPT34X \
124124
(IDE_HFLAG_NO_ATAPI_DMA | \
125125
IDE_HFLAG_NO_DSC | \
126-
IDE_HFLAG_ABUSE_SET_DMA_MODE | \
127126
IDE_HFLAG_NO_AUTODMA)
128127

129128
static const struct ide_port_info hpt34x_chipsets[] __devinitdata = {

‎drivers/ide/pci/hpt366.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,6 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2)
14091409

14101410
#define IDE_HFLAGS_HPT3XX \
14111411
(IDE_HFLAG_NO_ATAPI_DMA | \
1412-
IDE_HFLAG_ABUSE_SET_DMA_MODE | \
14131412
IDE_HFLAG_OFF_BOARD)
14141413

14151414
static const struct ide_port_ops hpt3xx_port_ops = {

‎drivers/ide/pci/pdc202xx_old.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
312312

313313
#define IDE_HFLAGS_PDC202XX \
314314
(IDE_HFLAG_ERROR_STOPS_FIFO | \
315-
IDE_HFLAG_ABUSE_SET_DMA_MODE | \
316315
IDE_HFLAG_OFF_BOARD)
317316

318317
static const struct ide_port_ops pdc20246_port_ops = {

‎drivers/ide/pci/serverworks.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,7 @@ static const struct ide_port_ops svwks_port_ops = {
349349
.cable_detect = svwks_cable_detect,
350350
};
351351

352-
#define IDE_HFLAGS_SVWKS \
353-
(IDE_HFLAG_LEGACY_IRQS | \
354-
IDE_HFLAG_ABUSE_SET_DMA_MODE)
352+
#define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS
355353

356354
static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
357355
{ /* 0 */

0 commit comments

Comments
 (0)