aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2012-04-11 11:39:19 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2012-04-17 16:57:02 -0400
commit94fba9fbeac44462c498e848496ba088198d78d1 (patch)
tree6c161b9133f55949570b742dff29ce102c9d2ccb
parent3b00b008888a851499bc039e70d12002af00ec9c (diff)
firewire: core: log config rom reading errors
If reading or refreshing a config rom fails, also log the actual error that caused it to fail. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r--drivers/firewire/core-device.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index f9f782afedf2..a3f486fbd7b7 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -481,6 +481,7 @@ static int read_rom(struct fw_device *device,
481 * generation changes under us, read_config_rom will fail and get retried. 481 * generation changes under us, read_config_rom will fail and get retried.
482 * It's better to start all over in this case because the node from which we 482 * It's better to start all over in this case because the node from which we
483 * are reading the ROM may have changed the ROM during the reset. 483 * are reading the ROM may have changed the ROM during the reset.
484 * Returns either a result code or a negative error code.
484 */ 485 */
485static int read_config_rom(struct fw_device *device, int generation) 486static int read_config_rom(struct fw_device *device, int generation)
486{ 487{
@@ -488,7 +489,7 @@ static int read_config_rom(struct fw_device *device, int generation)
488 const u32 *old_rom, *new_rom; 489 const u32 *old_rom, *new_rom;
489 u32 *rom, *stack; 490 u32 *rom, *stack;
490 u32 sp, key; 491 u32 sp, key;
491 int i, end, length, ret = -1; 492 int i, end, length, ret;
492 493
493 rom = kmalloc(sizeof(*rom) * MAX_CONFIG_ROM_SIZE + 494 rom = kmalloc(sizeof(*rom) * MAX_CONFIG_ROM_SIZE +
494 sizeof(*stack) * MAX_CONFIG_ROM_SIZE, GFP_KERNEL); 495 sizeof(*stack) * MAX_CONFIG_ROM_SIZE, GFP_KERNEL);
@@ -502,7 +503,8 @@ static int read_config_rom(struct fw_device *device, int generation)
502 503
503 /* First read the bus info block. */ 504 /* First read the bus info block. */
504 for (i = 0; i < 5; i++) { 505 for (i = 0; i < 5; i++) {
505 if (read_rom(device, generation, i, &rom[i]) != RCODE_COMPLETE) 506 ret = read_rom(device, generation, i, &rom[i]);
507 if (ret != RCODE_COMPLETE)
506 goto out; 508 goto out;
507 /* 509 /*
508 * As per IEEE1212 7.2, during initialization, devices can 510 * As per IEEE1212 7.2, during initialization, devices can
@@ -512,8 +514,10 @@ static int read_config_rom(struct fw_device *device, int generation)
512 * harddisk). In that case we just fail, and the 514 * harddisk). In that case we just fail, and the
513 * retry mechanism will try again later. 515 * retry mechanism will try again later.
514 */ 516 */
515 if (i == 0 && rom[i] == 0) 517 if (i == 0 && rom[i] == 0) {
518 ret = RCODE_BUSY;
516 goto out; 519 goto out;
520 }
517 } 521 }
518 522
519 device->max_speed = device->node->max_speed; 523 device->max_speed = device->node->max_speed;
@@ -563,11 +567,14 @@ static int read_config_rom(struct fw_device *device, int generation)
563 */ 567 */
564 key = stack[--sp]; 568 key = stack[--sp];
565 i = key & 0xffffff; 569 i = key & 0xffffff;
566 if (WARN_ON(i >= MAX_CONFIG_ROM_SIZE)) 570 if (WARN_ON(i >= MAX_CONFIG_ROM_SIZE)) {
571 ret = -ENXIO;
567 goto out; 572 goto out;
573 }
568 574
569 /* Read header quadlet for the block to get the length. */ 575 /* Read header quadlet for the block to get the length. */
570 if (read_rom(device, generation, i, &rom[i]) != RCODE_COMPLETE) 576 ret = read_rom(device, generation, i, &rom[i]);
577 if (ret != RCODE_COMPLETE)
571 goto out; 578 goto out;
572 end = i + (rom[i] >> 16) + 1; 579 end = i + (rom[i] >> 16) + 1;
573 if (end > MAX_CONFIG_ROM_SIZE) { 580 if (end > MAX_CONFIG_ROM_SIZE) {
@@ -590,8 +597,8 @@ static int read_config_rom(struct fw_device *device, int generation)
590 * it references another block, and push it in that case. 597 * it references another block, and push it in that case.
591 */ 598 */
592 for (; i < end; i++) { 599 for (; i < end; i++) {
593 if (read_rom(device, generation, i, &rom[i]) != 600 ret = read_rom(device, generation, i, &rom[i]);
594 RCODE_COMPLETE) 601 if (ret != RCODE_COMPLETE)
595 goto out; 602 goto out;
596 603
597 if ((key >> 30) != 3 || (rom[i] >> 30) < 2) 604 if ((key >> 30) != 3 || (rom[i] >> 30) < 2)
@@ -619,8 +626,10 @@ static int read_config_rom(struct fw_device *device, int generation)
619 626
620 old_rom = device->config_rom; 627 old_rom = device->config_rom;
621 new_rom = kmemdup(rom, length * 4, GFP_KERNEL); 628 new_rom = kmemdup(rom, length * 4, GFP_KERNEL);
622 if (new_rom == NULL) 629 if (new_rom == NULL) {
630 ret = -ENOMEM;
623 goto out; 631 goto out;
632 }
624 633
625 down_write(&fw_device_rwsem); 634 down_write(&fw_device_rwsem);
626 device->config_rom = new_rom; 635 device->config_rom = new_rom;
@@ -628,7 +637,7 @@ static int read_config_rom(struct fw_device *device, int generation)
628 up_write(&fw_device_rwsem); 637 up_write(&fw_device_rwsem);
629 638
630 kfree(old_rom); 639 kfree(old_rom);
631 ret = 0; 640 ret = RCODE_COMPLETE;
632 device->max_rec = rom[2] >> 12 & 0xf; 641 device->max_rec = rom[2] >> 12 & 0xf;
633 device->cmc = rom[2] >> 30 & 1; 642 device->cmc = rom[2] >> 30 & 1;
634 device->irmc = rom[2] >> 31 & 1; 643 device->irmc = rom[2] >> 31 & 1;
@@ -967,15 +976,17 @@ static void fw_device_init(struct work_struct *work)
967 * device. 976 * device.
968 */ 977 */
969 978
970 if (read_config_rom(device, device->generation) < 0) { 979 ret = read_config_rom(device, device->generation);
980 if (ret != RCODE_COMPLETE) {
971 if (device->config_rom_retries < MAX_RETRIES && 981 if (device->config_rom_retries < MAX_RETRIES &&
972 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { 982 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
973 device->config_rom_retries++; 983 device->config_rom_retries++;
974 fw_schedule_device_work(device, RETRY_DELAY); 984 fw_schedule_device_work(device, RETRY_DELAY);
975 } else { 985 } else {
976 if (device->node->link_on) 986 if (device->node->link_on)
977 fw_notice(card, "giving up on Config ROM for node id %x\n", 987 fw_notice(card, "giving up on node %x: reading config rom failed: %s\n",
978 device->node_id); 988 device->node_id,
989 fw_rcode_string(ret));
979 if (device->node == card->root_node) 990 if (device->node == card->root_node)
980 fw_schedule_bm_work(card, 0); 991 fw_schedule_bm_work(card, 0);
981 fw_device_release(&device->device); 992 fw_device_release(&device->device);
@@ -1132,7 +1143,8 @@ static void fw_device_refresh(struct work_struct *work)
1132 */ 1143 */
1133 device_for_each_child(&device->device, NULL, shutdown_unit); 1144 device_for_each_child(&device->device, NULL, shutdown_unit);
1134 1145
1135 if (read_config_rom(device, device->generation) < 0) { 1146 ret = read_config_rom(device, device->generation);
1147 if (ret != RCODE_COMPLETE) {
1136 if (device->config_rom_retries < MAX_RETRIES && 1148 if (device->config_rom_retries < MAX_RETRIES &&
1137 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) { 1149 atomic_read(&device->state) == FW_DEVICE_INITIALIZING) {
1138 device->config_rom_retries++; 1150 device->config_rom_retries++;
@@ -1159,8 +1171,8 @@ static void fw_device_refresh(struct work_struct *work)
1159 goto out; 1171 goto out;
1160 1172
1161 give_up: 1173 give_up:
1162 fw_notice(card, "giving up on refresh of device %s\n", 1174 fw_notice(card, "giving up on refresh of device %s: %s\n",
1163 dev_name(&device->device)); 1175 dev_name(&device->device), fw_rcode_string(ret));
1164 gone: 1176 gone:
1165 atomic_set(&device->state, FW_DEVICE_GONE); 1177 atomic_set(&device->state, FW_DEVICE_GONE);
1166 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown); 1178 PREPARE_DELAYED_WORK(&device->work, fw_device_shutdown);