diff options
author | Borislav Petkov <petkovbb@googlemail.com> | 2008-04-27 09:38:25 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-27 09:38:25 -0400 |
commit | ddfe7a776360f7067e06eee9d8b1ae4d957e6ddf (patch) | |
tree | a21e169170f98bda7b604a9b481c12d6ffaf3482 /drivers | |
parent | 97c566cebe083b8e500c9b0b5033212c809d9844 (diff) |
ide-tape remove pipeline speed/control calculations
Pipeline handling calculations in idetape_calculate_speeds() can
go since they do not have any effect on other functionality besides:
1. info is only being exported through /proc as a read-only item
(controlled_pipeline_head_speed, uncontrolled_pipeline_head_speed)
2. used in idetape_restart_speed_control() which, in turn, is unrelated to
other code
3. used only for pipeline frames number accounting (tape->pipeline_head),
also unused elsewhere.
4.some variables are:
only written to: tape->buffer_head;
unused: tape->tape_head, tape->last_tape_head
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ide-tape.c | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 71ebee001882..e785145abb47 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -84,9 +84,6 @@ enum { | |||
84 | * We start from MIN maximum stages (we will not even use MIN stages if we don't | 84 | * We start from MIN maximum stages (we will not even use MIN stages if we don't |
85 | * need them), increment it by RATE*(MAX-MIN) whenever we sense that the | 85 | * need them), increment it by RATE*(MAX-MIN) whenever we sense that the |
86 | * pipeline is empty, until we reach the optimum value or until we reach MAX. | 86 | * pipeline is empty, until we reach the optimum value or until we reach MAX. |
87 | * | ||
88 | * Setting the following parameter to 0 is illegal: the pipelined mode cannot be | ||
89 | * disabled (idetape_calculate_speeds() divides by tape->max_stages.) | ||
90 | */ | 87 | */ |
91 | #define IDETAPE_MIN_PIPELINE_STAGES 1 | 88 | #define IDETAPE_MIN_PIPELINE_STAGES 1 |
92 | #define IDETAPE_MAX_PIPELINE_STAGES 400 | 89 | #define IDETAPE_MAX_PIPELINE_STAGES 400 |
@@ -392,39 +389,12 @@ typedef struct ide_tape_obj { | |||
392 | */ | 389 | */ |
393 | int postpone_cnt; | 390 | int postpone_cnt; |
394 | 391 | ||
395 | /* | ||
396 | * Measures number of frames: | ||
397 | * | ||
398 | * 1. written/read to/from the driver pipeline (pipeline_head). | ||
399 | * 2. written/read to/from the tape buffers (idetape_bh). | ||
400 | * 3. written/read by the tape to/from the media (tape_head). | ||
401 | */ | ||
402 | int pipeline_head; | ||
403 | int buffer_head; | ||
404 | int tape_head; | ||
405 | int last_tape_head; | ||
406 | |||
407 | /* Speed control at the tape buffers input/output */ | 392 | /* Speed control at the tape buffers input/output */ |
408 | unsigned long insert_time; | 393 | unsigned long insert_time; |
409 | int insert_size; | 394 | int insert_size; |
410 | int insert_speed; | 395 | int insert_speed; |
411 | int max_insert_speed; | ||
412 | int measure_insert_time; | 396 | int measure_insert_time; |
413 | 397 | ||
414 | /* Speed regulation negative feedback loop */ | ||
415 | int speed_control; | ||
416 | int pipeline_head_speed; | ||
417 | int controlled_pipeline_head_speed; | ||
418 | int uncontrolled_pipeline_head_speed; | ||
419 | int controlled_last_pipeline_head; | ||
420 | unsigned long uncontrolled_pipeline_head_time; | ||
421 | unsigned long controlled_pipeline_head_time; | ||
422 | int controlled_previous_pipeline_head; | ||
423 | int uncontrolled_previous_pipeline_head; | ||
424 | unsigned long controlled_previous_head_time; | ||
425 | unsigned long uncontrolled_previous_head_time; | ||
426 | int restart_speed_control_req; | ||
427 | |||
428 | u32 debug_mask; | 398 | u32 debug_mask; |
429 | } idetape_tape_t; | 399 | } idetape_tape_t; |
430 | 400 | ||
@@ -1333,69 +1303,6 @@ static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) | |||
1333 | pc->idetape_callback = &idetape_pc_callback; | 1303 | pc->idetape_callback = &idetape_pc_callback; |
1334 | } | 1304 | } |
1335 | 1305 | ||
1336 | static void idetape_calculate_speeds(ide_drive_t *drive) | ||
1337 | { | ||
1338 | idetape_tape_t *tape = drive->driver_data; | ||
1339 | |||
1340 | if (time_after(jiffies, | ||
1341 | tape->controlled_pipeline_head_time + 120 * HZ)) { | ||
1342 | tape->controlled_previous_pipeline_head = | ||
1343 | tape->controlled_last_pipeline_head; | ||
1344 | tape->controlled_previous_head_time = | ||
1345 | tape->controlled_pipeline_head_time; | ||
1346 | tape->controlled_last_pipeline_head = tape->pipeline_head; | ||
1347 | tape->controlled_pipeline_head_time = jiffies; | ||
1348 | } | ||
1349 | if (time_after(jiffies, tape->controlled_pipeline_head_time + 60 * HZ)) | ||
1350 | tape->controlled_pipeline_head_speed = (tape->pipeline_head - | ||
1351 | tape->controlled_last_pipeline_head) * 32 * HZ / | ||
1352 | (jiffies - tape->controlled_pipeline_head_time); | ||
1353 | else if (time_after(jiffies, tape->controlled_previous_head_time)) | ||
1354 | tape->controlled_pipeline_head_speed = (tape->pipeline_head - | ||
1355 | tape->controlled_previous_pipeline_head) * 32 * | ||
1356 | HZ / (jiffies - tape->controlled_previous_head_time); | ||
1357 | |||
1358 | if (tape->nr_pending_stages < tape->max_stages/*- 1 */) { | ||
1359 | /* -1 for read mode error recovery */ | ||
1360 | if (time_after(jiffies, tape->uncontrolled_previous_head_time + | ||
1361 | 10 * HZ)) { | ||
1362 | tape->uncontrolled_pipeline_head_time = jiffies; | ||
1363 | tape->uncontrolled_pipeline_head_speed = | ||
1364 | (tape->pipeline_head - | ||
1365 | tape->uncontrolled_previous_pipeline_head) * | ||
1366 | 32 * HZ / (jiffies - | ||
1367 | tape->uncontrolled_previous_head_time); | ||
1368 | } | ||
1369 | } else { | ||
1370 | tape->uncontrolled_previous_head_time = jiffies; | ||
1371 | tape->uncontrolled_previous_pipeline_head = tape->pipeline_head; | ||
1372 | if (time_after(jiffies, tape->uncontrolled_pipeline_head_time + | ||
1373 | 30 * HZ)) | ||
1374 | tape->uncontrolled_pipeline_head_time = jiffies; | ||
1375 | |||
1376 | } | ||
1377 | tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, | ||
1378 | tape->controlled_pipeline_head_speed); | ||
1379 | |||
1380 | if (tape->speed_control == 1) { | ||
1381 | if (tape->nr_pending_stages >= tape->max_stages / 2) | ||
1382 | tape->max_insert_speed = tape->pipeline_head_speed + | ||
1383 | (1100 - tape->pipeline_head_speed) * 2 * | ||
1384 | (tape->nr_pending_stages - tape->max_stages / 2) | ||
1385 | / tape->max_stages; | ||
1386 | else | ||
1387 | tape->max_insert_speed = 500 + | ||
1388 | (tape->pipeline_head_speed - 500) * 2 * | ||
1389 | tape->nr_pending_stages / tape->max_stages; | ||
1390 | |||
1391 | if (tape->nr_pending_stages >= tape->max_stages * 99 / 100) | ||
1392 | tape->max_insert_speed = 5000; | ||
1393 | } else | ||
1394 | tape->max_insert_speed = tape->speed_control; | ||
1395 | |||
1396 | tape->max_insert_speed = max(tape->max_insert_speed, 500); | ||
1397 | } | ||
1398 | |||
1399 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | 1306 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) |
1400 | { | 1307 | { |
1401 | idetape_tape_t *tape = drive->driver_data; | 1308 | idetape_tape_t *tape = drive->driver_data; |
@@ -1548,7 +1455,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1548 | if (time_after(jiffies, tape->insert_time)) | 1455 | if (time_after(jiffies, tape->insert_time)) |
1549 | tape->insert_speed = tape->insert_size / 1024 * HZ / | 1456 | tape->insert_speed = tape->insert_size / 1024 * HZ / |
1550 | (jiffies - tape->insert_time); | 1457 | (jiffies - tape->insert_time); |
1551 | idetape_calculate_speeds(drive); | ||
1552 | if (!test_and_clear_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags) && | 1458 | if (!test_and_clear_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags) && |
1553 | (stat & SEEK_STAT) == 0) { | 1459 | (stat & SEEK_STAT) == 0) { |
1554 | if (postponed_rq == NULL) { | 1460 | if (postponed_rq == NULL) { |
@@ -1572,7 +1478,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1572 | return ide_stopped; | 1478 | return ide_stopped; |
1573 | } | 1479 | } |
1574 | if (rq->cmd[0] & REQ_IDETAPE_READ) { | 1480 | if (rq->cmd[0] & REQ_IDETAPE_READ) { |
1575 | tape->buffer_head++; | ||
1576 | tape->postpone_cnt = 0; | 1481 | tape->postpone_cnt = 0; |
1577 | pc = idetape_next_pc_storage(drive); | 1482 | pc = idetape_next_pc_storage(drive); |
1578 | idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, | 1483 | idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, |
@@ -1580,7 +1485,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1580 | goto out; | 1485 | goto out; |
1581 | } | 1486 | } |
1582 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { | 1487 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { |
1583 | tape->buffer_head++; | ||
1584 | tape->postpone_cnt = 0; | 1488 | tape->postpone_cnt = 0; |
1585 | pc = idetape_next_pc_storage(drive); | 1489 | pc = idetape_next_pc_storage(drive); |
1586 | idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, | 1490 | idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, |
@@ -2321,24 +2225,6 @@ static void idetape_empty_write_pipeline(ide_drive_t *drive) | |||
2321 | } | 2225 | } |
2322 | } | 2226 | } |
2323 | 2227 | ||
2324 | static void idetape_restart_speed_control(ide_drive_t *drive) | ||
2325 | { | ||
2326 | idetape_tape_t *tape = drive->driver_data; | ||
2327 | |||
2328 | tape->restart_speed_control_req = 0; | ||
2329 | tape->pipeline_head = 0; | ||
2330 | tape->controlled_last_pipeline_head = 0; | ||
2331 | tape->controlled_previous_pipeline_head = 0; | ||
2332 | tape->uncontrolled_previous_pipeline_head = 0; | ||
2333 | tape->controlled_pipeline_head_speed = 5000; | ||
2334 | tape->pipeline_head_speed = 5000; | ||
2335 | tape->uncontrolled_pipeline_head_speed = 0; | ||
2336 | tape->controlled_pipeline_head_time = | ||
2337 | tape->uncontrolled_pipeline_head_time = jiffies; | ||
2338 | tape->controlled_previous_head_time = | ||
2339 | tape->uncontrolled_previous_head_time = jiffies; | ||
2340 | } | ||
2341 | |||
2342 | static int idetape_init_read(ide_drive_t *drive, int max_stages) | 2228 | static int idetape_init_read(ide_drive_t *drive, int max_stages) |
2343 | { | 2229 | { |
2344 | idetape_tape_t *tape = drive->driver_data; | 2230 | idetape_tape_t *tape = drive->driver_data; |
@@ -2381,8 +2267,6 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages) | |||
2381 | } | 2267 | } |
2382 | } | 2268 | } |
2383 | } | 2269 | } |
2384 | if (tape->restart_speed_control_req) | ||
2385 | idetape_restart_speed_control(drive); | ||
2386 | idetape_init_rq(&rq, REQ_IDETAPE_READ); | 2270 | idetape_init_rq(&rq, REQ_IDETAPE_READ); |
2387 | rq.sector = tape->first_frame; | 2271 | rq.sector = tape->first_frame; |
2388 | rq.nr_sectors = blocks; | 2272 | rq.nr_sectors = blocks; |
@@ -2451,8 +2335,6 @@ static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) | |||
2451 | spin_lock_irqsave(&tape->lock, flags); | 2335 | spin_lock_irqsave(&tape->lock, flags); |
2452 | idetape_remove_stage_head(drive); | 2336 | idetape_remove_stage_head(drive); |
2453 | spin_unlock_irqrestore(&tape->lock, flags); | 2337 | spin_unlock_irqrestore(&tape->lock, flags); |
2454 | tape->pipeline_head++; | ||
2455 | idetape_calculate_speeds(drive); | ||
2456 | } | 2338 | } |
2457 | if (bytes_read > blocks * tape->blk_size) { | 2339 | if (bytes_read > blocks * tape->blk_size) { |
2458 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes" | 2340 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes" |
@@ -2787,8 +2669,6 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | |||
2787 | } | 2669 | } |
2788 | if (count == 0) | 2670 | if (count == 0) |
2789 | return (0); | 2671 | return (0); |
2790 | if (tape->restart_speed_control_req) | ||
2791 | idetape_restart_speed_control(drive); | ||
2792 | if (tape->merge_stage_size) { | 2672 | if (tape->merge_stage_size) { |
2793 | if (tape->merge_stage_size >= tape->stage_size) { | 2673 | if (tape->merge_stage_size >= tape->stage_size) { |
2794 | printk(KERN_ERR "ide-tape: bug: merge buf too big\n"); | 2674 | printk(KERN_ERR "ide-tape: bug: merge buf too big\n"); |
@@ -2997,7 +2877,6 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
2997 | 2877 | ||
2998 | debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); | 2878 | debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); |
2999 | 2879 | ||
3000 | tape->restart_speed_control_req = 1; | ||
3001 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { | 2880 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { |
3002 | idetape_empty_write_pipeline(drive); | 2881 | idetape_empty_write_pipeline(drive); |
3003 | idetape_flush_tape_buffers(drive); | 2882 | idetape_flush_tape_buffers(drive); |
@@ -3140,8 +3019,6 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
3140 | } | 3019 | } |
3141 | } | 3020 | } |
3142 | } | 3021 | } |
3143 | idetape_restart_speed_control(drive); | ||
3144 | tape->restart_speed_control_req = 0; | ||
3145 | return 0; | 3022 | return 0; |
3146 | 3023 | ||
3147 | out_put_tape: | 3024 | out_put_tape: |
@@ -3344,12 +3221,6 @@ static void idetape_add_settings(ide_drive_t *drive) | |||
3344 | NULL); | 3221 | NULL); |
3345 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, | 3222 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, |
3346 | 1, &drive->dsc_overlap, NULL); | 3223 | 1, &drive->dsc_overlap, NULL); |
3347 | ide_add_setting(drive, "pipeline_head_speed_c", SETTING_READ, TYPE_INT, | ||
3348 | 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, | ||
3349 | NULL); | ||
3350 | ide_add_setting(drive, "pipeline_head_speed_u", SETTING_READ, TYPE_INT, | ||
3351 | 0, 0xffff, 1, 1, | ||
3352 | &tape->uncontrolled_pipeline_head_speed, NULL); | ||
3353 | ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, | 3224 | ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, |
3354 | 1, 1, &tape->avg_speed, NULL); | 3225 | 1, 1, &tape->avg_speed, NULL); |
3355 | ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1, | 3226 | ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1, |
@@ -3395,8 +3266,6 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
3395 | tape->name[2] = '0' + minor; | 3266 | tape->name[2] = '0' + minor; |
3396 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 3267 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
3397 | tape->pc = tape->pc_stack; | 3268 | tape->pc = tape->pc_stack; |
3398 | tape->max_insert_speed = 10000; | ||
3399 | tape->speed_control = 1; | ||
3400 | *((unsigned short *) &gcw) = drive->id->config; | 3269 | *((unsigned short *) &gcw) = drive->id->config; |
3401 | 3270 | ||
3402 | /* Command packet DRQ type */ | 3271 | /* Command packet DRQ type */ |