aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/i2o/iop.c
diff options
context:
space:
mode:
authorMarkus Lidel <Markus.Lidel@shadowconnect.com>2005-06-24 01:02:21 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-24 03:05:29 -0400
commit9e87545f06930c1d294423a8091d1077e7444a47 (patch)
treeef05fca1becfa0e1584f234ddf9b1a430b7d018e /drivers/message/i2o/iop.c
parentb2aaee33fbb354a2f08121aa1c1be55841102761 (diff)
[PATCH] I2O: second code cleanup of sparse warnings and unneeded syncronization
Changes: - Added header "core.h" for i2o_core.ko internal definitions - More sparse fixes - Changed display of TID's in sysfs attributes from XXX to 0xXXX - Use the right functions for accessing I/O and normal memory - Removed error handling of SCSI device errors and let the SCSI layer take care of it - Added new device / removed device handling to SCSI-OSM - Make status access volatile - Cleaned up activation of I2O controller - Removed unnecessary wmb() and rmb() calls - Use own struct i2o_io for I/O memory instead of struct i2o_dma Signed-off-by: Markus Lidel <Markus.Lidel@shadowconnect.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/message/i2o/iop.c')
-rw-r--r--drivers/message/i2o/iop.c128
1 files changed, 68 insertions, 60 deletions
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 40312053b38d..c32022bc2a21 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -28,8 +28,10 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/i2o.h> 29#include <linux/i2o.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include "core.h"
31 32
32#define OSM_VERSION "$Rev$" 33#define OSM_NAME "i2o"
34#define OSM_VERSION "1.288"
33#define OSM_DESCRIPTION "I2O subsystem" 35#define OSM_DESCRIPTION "I2O subsystem"
34 36
35/* global I2O controller list */ 37/* global I2O controller list */
@@ -43,20 +45,6 @@ static struct i2o_dma i2o_systab;
43 45
44static int i2o_hrt_get(struct i2o_controller *c); 46static int i2o_hrt_get(struct i2o_controller *c);
45 47
46/* Module internal functions from other sources */
47extern struct i2o_driver i2o_exec_driver;
48extern int i2o_exec_lct_get(struct i2o_controller *);
49extern void i2o_device_remove(struct i2o_device *);
50
51extern int __init i2o_driver_init(void);
52extern void __exit i2o_driver_exit(void);
53extern int __init i2o_exec_init(void);
54extern void __exit i2o_exec_exit(void);
55extern int __init i2o_pci_init(void);
56extern void __exit i2o_pci_exit(void);
57extern int i2o_device_init(void);
58extern void i2o_device_exit(void);
59
60/** 48/**
61 * i2o_msg_nop - Returns a message which is not used 49 * i2o_msg_nop - Returns a message which is not used
62 * @c: I2O controller from which the message was created 50 * @c: I2O controller from which the message was created
@@ -92,16 +80,16 @@ void i2o_msg_nop(struct i2o_controller *c, u32 m)
92 * address from the read port (see the i2o spec). If no message is 80 * address from the read port (see the i2o spec). If no message is
93 * available returns I2O_QUEUE_EMPTY and msg is leaved untouched. 81 * available returns I2O_QUEUE_EMPTY and msg is leaved untouched.
94 */ 82 */
95u32 i2o_msg_get_wait(struct i2o_controller *c, struct i2o_message __iomem **msg, 83u32 i2o_msg_get_wait(struct i2o_controller *c,
96 int wait) 84 struct i2o_message __iomem ** msg, int wait)
97{ 85{
98 unsigned long timeout = jiffies + wait * HZ; 86 unsigned long timeout = jiffies + wait * HZ;
99 u32 m; 87 u32 m;
100 88
101 while ((m = i2o_msg_get(c, msg)) == I2O_QUEUE_EMPTY) { 89 while ((m = i2o_msg_get(c, msg)) == I2O_QUEUE_EMPTY) {
102 if (time_after(jiffies, timeout)) { 90 if (time_after(jiffies, timeout)) {
103 pr_debug("%s: Timeout waiting for message frame.\n", 91 osm_debug("%s: Timeout waiting for message frame.\n",
104 c->name); 92 c->name);
105 return I2O_QUEUE_EMPTY; 93 return I2O_QUEUE_EMPTY;
106 } 94 }
107 set_current_state(TASK_UNINTERRUPTIBLE); 95 set_current_state(TASK_UNINTERRUPTIBLE);
@@ -466,7 +454,7 @@ static int i2o_iop_clear(struct i2o_controller *c)
466 */ 454 */
467static int i2o_iop_init_outbound_queue(struct i2o_controller *c) 455static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
468{ 456{
469 u8 *status = c->status.virt; 457 volatile u8 *status = c->status.virt;
470 u32 m; 458 u32 m;
471 struct i2o_message __iomem *msg; 459 struct i2o_message __iomem *msg;
472 ulong timeout; 460 ulong timeout;
@@ -474,21 +462,20 @@ static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
474 462
475 osm_debug("%s: Initializing Outbound Queue...\n", c->name); 463 osm_debug("%s: Initializing Outbound Queue...\n", c->name);
476 464
477 memset(status, 0, 4); 465 memset(c->status.virt, 0, 4);
478 466
479 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 467 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
480 if (m == I2O_QUEUE_EMPTY) 468 if (m == I2O_QUEUE_EMPTY)
481 return -ETIMEDOUT; 469 return -ETIMEDOUT;
482 470
483 writel(EIGHT_WORD_MSG_SIZE | TRL_OFFSET_6, &msg->u.head[0]); 471 writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]);
484 writel(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_TID, 472 writel(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_TID,
485 &msg->u.head[1]); 473 &msg->u.head[1]);
486 writel(i2o_exec_driver.context, &msg->u.s.icntxt); 474 writel(i2o_exec_driver.context, &msg->u.s.icntxt);
487 writel(0x0106, &msg->u.s.tcntxt); /* FIXME: why 0x0106, maybe in 475 writel(0x00000000, &msg->u.s.tcntxt);
488 Spec? */
489 writel(PAGE_SIZE, &msg->body[0]); 476 writel(PAGE_SIZE, &msg->body[0]);
490 /* Outbound msg frame size in words and Initcode */ 477 /* Outbound msg frame size in words and Initcode */
491 writel(MSG_FRAME_SIZE << 16 | 0x80, &msg->body[1]); 478 writel(I2O_OUTBOUND_MSG_FRAME_SIZE << 16 | 0x80, &msg->body[1]);
492 writel(0xd0000004, &msg->body[2]); 479 writel(0xd0000004, &msg->body[2]);
493 writel(i2o_dma_low(c->status.phys), &msg->body[3]); 480 writel(i2o_dma_low(c->status.phys), &msg->body[3]);
494 writel(i2o_dma_high(c->status.phys), &msg->body[4]); 481 writel(i2o_dma_high(c->status.phys), &msg->body[4]);
@@ -503,17 +490,15 @@ static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
503 } 490 }
504 set_current_state(TASK_UNINTERRUPTIBLE); 491 set_current_state(TASK_UNINTERRUPTIBLE);
505 schedule_timeout(1); 492 schedule_timeout(1);
506
507 rmb();
508 } 493 }
509 494
510 m = c->out_queue.phys; 495 m = c->out_queue.phys;
511 496
512 /* Post frames */ 497 /* Post frames */
513 for (i = 0; i < NMBR_MSG_FRAMES; i++) { 498 for (i = 0; i < I2O_MAX_OUTBOUND_MSG_FRAMES; i++) {
514 i2o_flush_reply(c, m); 499 i2o_flush_reply(c, m);
515 udelay(1); /* Promise */ 500 udelay(1); /* Promise */
516 m += MSG_FRAME_SIZE * 4; 501 m += I2O_OUTBOUND_MSG_FRAME_SIZE * sizeof(u32);
517 } 502 }
518 503
519 return 0; 504 return 0;
@@ -530,20 +515,20 @@ static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
530 */ 515 */
531static int i2o_iop_reset(struct i2o_controller *c) 516static int i2o_iop_reset(struct i2o_controller *c)
532{ 517{
533 u8 *status = c->status.virt; 518 volatile u8 *status = c->status.virt;
534 struct i2o_message __iomem *msg; 519 struct i2o_message __iomem *msg;
535 u32 m; 520 u32 m;
536 unsigned long timeout; 521 unsigned long timeout;
537 i2o_status_block *sb = c->status_block.virt; 522 i2o_status_block *sb = c->status_block.virt;
538 int rc = 0; 523 int rc = 0;
539 524
540 pr_debug("%s: Resetting controller\n", c->name); 525 osm_debug("%s: Resetting controller\n", c->name);
541 526
542 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 527 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
543 if (m == I2O_QUEUE_EMPTY) 528 if (m == I2O_QUEUE_EMPTY)
544 return -ETIMEDOUT; 529 return -ETIMEDOUT;
545 530
546 memset(status, 0, 8); 531 memset(c->status_block.virt, 0, 8);
547 532
548 /* Quiesce all IOPs first */ 533 /* Quiesce all IOPs first */
549 i2o_iop_quiesce_all(); 534 i2o_iop_quiesce_all();
@@ -568,8 +553,6 @@ static int i2o_iop_reset(struct i2o_controller *c)
568 553
569 set_current_state(TASK_UNINTERRUPTIBLE); 554 set_current_state(TASK_UNINTERRUPTIBLE);
570 schedule_timeout(1); 555 schedule_timeout(1);
571
572 rmb();
573 } 556 }
574 557
575 switch (*status) { 558 switch (*status) {
@@ -984,11 +967,11 @@ int i2o_status_get(struct i2o_controller *c)
984{ 967{
985 struct i2o_message __iomem *msg; 968 struct i2o_message __iomem *msg;
986 u32 m; 969 u32 m;
987 u8 *status_block; 970 volatile u8 *status_block;
988 unsigned long timeout; 971 unsigned long timeout;
989 972
990 status_block = (u8 *) c->status_block.virt; 973 status_block = (u8 *) c->status_block.virt;
991 memset(status_block, 0, sizeof(i2o_status_block)); 974 memset(c->status_block.virt, 0, sizeof(i2o_status_block));
992 975
993 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 976 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
994 if (m == I2O_QUEUE_EMPTY) 977 if (m == I2O_QUEUE_EMPTY)
@@ -1017,8 +1000,6 @@ int i2o_status_get(struct i2o_controller *c)
1017 1000
1018 set_current_state(TASK_UNINTERRUPTIBLE); 1001 set_current_state(TASK_UNINTERRUPTIBLE);
1019 schedule_timeout(1); 1002 schedule_timeout(1);
1020
1021 rmb();
1022 } 1003 }
1023 1004
1024#ifdef DEBUG 1005#ifdef DEBUG
@@ -1107,6 +1088,11 @@ static void i2o_iop_release(struct device *dev)
1107 i2o_iop_free(c); 1088 i2o_iop_free(c);
1108}; 1089};
1109 1090
1091/* I2O controller class */
1092static struct class i2o_controller_class = {
1093 .name = "i2o_controller",
1094};
1095
1110/** 1096/**
1111 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct 1097 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
1112 * 1098 *
@@ -1136,8 +1122,14 @@ struct i2o_controller *i2o_iop_alloc(void)
1136 sprintf(c->name, "iop%d", c->unit); 1122 sprintf(c->name, "iop%d", c->unit);
1137 1123
1138 device_initialize(&c->device); 1124 device_initialize(&c->device);
1125 class_device_initialize(&c->classdev);
1126
1139 c->device.release = &i2o_iop_release; 1127 c->device.release = &i2o_iop_release;
1128 c->classdev.class = &i2o_controller_class;
1129 c->classdev.dev = &c->device;
1130
1140 snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit); 1131 snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit);
1132 snprintf(c->classdev.class_id, BUS_ID_SIZE, "iop%d", c->unit);
1141 1133
1142#if BITS_PER_LONG == 64 1134#if BITS_PER_LONG == 64
1143 spin_lock_init(&c->context_list_lock); 1135 spin_lock_init(&c->context_list_lock);
@@ -1161,45 +1153,55 @@ int i2o_iop_add(struct i2o_controller *c)
1161{ 1153{
1162 int rc; 1154 int rc;
1163 1155
1164 if((rc = device_add(&c->device))) { 1156 if ((rc = device_add(&c->device))) {
1165 printk(KERN_ERR "%s: could not register controller\n", c->name); 1157 osm_err("%s: could not add controller\n", c->name);
1166 goto iop_reset; 1158 goto iop_reset;
1167 } 1159 }
1168 1160
1169 printk(KERN_INFO "%s: Activating I2O controller...\n", c->name); 1161 if ((rc = class_device_add(&c->classdev))) {
1170 printk(KERN_INFO "%s: This may take a few minutes if there are many " 1162 osm_err("%s: could not add controller class\n", c->name);
1171 "devices\n", c->name); 1163 goto device_del;
1164 }
1165
1166 osm_info("%s: Activating I2O controller...\n", c->name);
1167 osm_info("%s: This may take a few minutes if there are many devices\n",
1168 c->name);
1172 1169
1173 if ((rc = i2o_iop_activate(c))) { 1170 if ((rc = i2o_iop_activate(c))) {
1174 printk(KERN_ERR "%s: could not activate controller\n", 1171 osm_err("%s: could not activate controller\n", c->name);
1175 c->name); 1172 goto class_del;
1176 goto iop_reset;
1177 } 1173 }
1178 1174
1179 pr_debug("%s: building sys table...\n", c->name); 1175 osm_debug("%s: building sys table...\n", c->name);
1180 1176
1181 if ((rc = i2o_systab_build())) 1177 if ((rc = i2o_systab_build()))
1182 goto iop_reset; 1178 goto class_del;
1183 1179
1184 pr_debug("%s: online controller...\n", c->name); 1180 osm_debug("%s: online controller...\n", c->name);
1185 1181
1186 if ((rc = i2o_iop_online(c))) 1182 if ((rc = i2o_iop_online(c)))
1187 goto iop_reset; 1183 goto class_del;
1188 1184
1189 pr_debug("%s: getting LCT...\n", c->name); 1185 osm_debug("%s: getting LCT...\n", c->name);
1190 1186
1191 if ((rc = i2o_exec_lct_get(c))) 1187 if ((rc = i2o_exec_lct_get(c)))
1192 goto iop_reset; 1188 goto class_del;
1193 1189
1194 list_add(&c->list, &i2o_controllers); 1190 list_add(&c->list, &i2o_controllers);
1195 1191
1196 i2o_driver_notify_controller_add_all(c); 1192 i2o_driver_notify_controller_add_all(c);
1197 1193
1198 printk(KERN_INFO "%s: Controller added\n", c->name); 1194 osm_info("%s: Controller added\n", c->name);
1199 1195
1200 return 0; 1196 return 0;
1201 1197
1202iop_reset: 1198 class_del:
1199 class_device_del(&c->classdev);
1200
1201 device_del:
1202 device_del(&c->device);
1203
1204 iop_reset:
1203 i2o_iop_reset(c); 1205 i2o_iop_reset(c);
1204 1206
1205 return rc; 1207 return rc;
@@ -1260,16 +1262,18 @@ static int __init i2o_iop_init(void)
1260 if (rc) 1262 if (rc)
1261 goto exit; 1263 goto exit;
1262 1264
1263 rc = i2o_driver_init(); 1265 if ((rc = class_register(&i2o_controller_class))) {
1264 if (rc) 1266 osm_err("can't register class i2o_controller\n");
1265 goto device_exit; 1267 goto device_exit;
1268 }
1266 1269
1267 rc = i2o_exec_init(); 1270 if ((rc = i2o_driver_init()))
1268 if (rc) 1271 goto class_exit;
1272
1273 if ((rc = i2o_exec_init()))
1269 goto driver_exit; 1274 goto driver_exit;
1270 1275
1271 rc = i2o_pci_init(); 1276 if ((rc = i2o_pci_init()))
1272 if (rc < 0)
1273 goto exec_exit; 1277 goto exec_exit;
1274 1278
1275 return 0; 1279 return 0;
@@ -1280,6 +1284,9 @@ static int __init i2o_iop_init(void)
1280 driver_exit: 1284 driver_exit:
1281 i2o_driver_exit(); 1285 i2o_driver_exit();
1282 1286
1287 class_exit:
1288 class_unregister(&i2o_controller_class);
1289
1283 device_exit: 1290 device_exit:
1284 i2o_device_exit(); 1291 i2o_device_exit();
1285 1292
@@ -1297,6 +1304,7 @@ static void __exit i2o_iop_exit(void)
1297 i2o_pci_exit(); 1304 i2o_pci_exit();
1298 i2o_exec_exit(); 1305 i2o_exec_exit();
1299 i2o_driver_exit(); 1306 i2o_driver_exit();
1307 class_unregister(&i2o_controller_class);
1300 i2o_device_exit(); 1308 i2o_device_exit();
1301}; 1309};
1302 1310