iop.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  1. /*
  2. * Functions to handle I2O controllers and I2O message handling
  3. *
  4. * Copyright (C) 1999-2002 Red Hat Software
  5. *
  6. * Written by Alan Cox, Building Number Three Ltd
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * A lot of the I2O message side code from this is taken from the
  14. * Red Creek RCPCI45 adapter driver by Red Creek Communications
  15. *
  16. * Fixes/additions:
  17. * Philipp Rumpf
  18. * Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
  19. * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
  20. * Deepak Saxena <deepak@plexity.net>
  21. * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
  22. * Alan Cox <alan@redhat.com>:
  23. * Ported to Linux 2.5.
  24. * Markus Lidel <Markus.Lidel@shadowconnect.com>:
  25. * Minor fixes for 2.6.
  26. */
  27. #include <linux/module.h>
  28. #include <linux/i2o.h>
  29. #include <linux/delay.h>
  30. #include "core.h"
  31. #define OSM_NAME "i2o"
  32. #define OSM_VERSION "1.288"
  33. #define OSM_DESCRIPTION "I2O subsystem"
  34. /* global I2O controller list */
  35. LIST_HEAD(i2o_controllers);
  36. /*
  37. * global I2O System Table. Contains information about all the IOPs in the
  38. * system. Used to inform IOPs about each others existence.
  39. */
  40. static struct i2o_dma i2o_systab;
  41. static int i2o_hrt_get(struct i2o_controller *c);
  42. /**
  43. * i2o_msg_nop - Returns a message which is not used
  44. * @c: I2O controller from which the message was created
  45. * @m: message which should be returned
  46. *
  47. * If you fetch a message via i2o_msg_get, and can't use it, you must
  48. * return the message with this function. Otherwise the message frame
  49. * is lost.
  50. */
  51. void i2o_msg_nop(struct i2o_controller *c, u32 m)
  52. {
  53. struct i2o_message __iomem *msg = i2o_msg_in_to_virt(c, m);
  54. writel(THREE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  55. writel(I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID,
  56. &msg->u.head[1]);
  57. writel(0, &msg->u.head[2]);
  58. writel(0, &msg->u.head[3]);
  59. i2o_msg_post(c, m);
  60. };
  61. /**
  62. * i2o_msg_get_wait - obtain an I2O message from the IOP
  63. * @c: I2O controller
  64. * @msg: pointer to a I2O message pointer
  65. * @wait: how long to wait until timeout
  66. *
  67. * This function waits up to wait seconds for a message slot to be
  68. * available.
  69. *
  70. * On a success the message is returned and the pointer to the message is
  71. * set in msg. The returned message is the physical page frame offset
  72. * address from the read port (see the i2o spec). If no message is
  73. * available returns I2O_QUEUE_EMPTY and msg is leaved untouched.
  74. */
  75. u32 i2o_msg_get_wait(struct i2o_controller *c,
  76. struct i2o_message __iomem ** msg, int wait)
  77. {
  78. unsigned long timeout = jiffies + wait * HZ;
  79. u32 m;
  80. while ((m = i2o_msg_get(c, msg)) == I2O_QUEUE_EMPTY) {
  81. if (time_after(jiffies, timeout)) {
  82. osm_debug("%s: Timeout waiting for message frame.\n",
  83. c->name);
  84. return I2O_QUEUE_EMPTY;
  85. }
  86. set_current_state(TASK_UNINTERRUPTIBLE);
  87. schedule_timeout(1);
  88. }
  89. return m;
  90. };
  91. #if BITS_PER_LONG == 64
  92. /**
  93. * i2o_cntxt_list_add - Append a pointer to context list and return a id
  94. * @c: controller to which the context list belong
  95. * @ptr: pointer to add to the context list
  96. *
  97. * Because the context field in I2O is only 32-bit large, on 64-bit the
  98. * pointer is to large to fit in the context field. The i2o_cntxt_list
  99. * functions therefore map pointers to context fields.
  100. *
  101. * Returns context id > 0 on success or 0 on failure.
  102. */
  103. u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
  104. {
  105. struct i2o_context_list_element *entry;
  106. unsigned long flags;
  107. if (!ptr)
  108. osm_err("%s: couldn't add NULL pointer to context list!\n",
  109. c->name);
  110. entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
  111. if (!entry) {
  112. osm_err("%s: Could not allocate memory for context list element"
  113. "\n", c->name);
  114. return 0;
  115. }
  116. entry->ptr = ptr;
  117. entry->timestamp = jiffies;
  118. INIT_LIST_HEAD(&entry->list);
  119. spin_lock_irqsave(&c->context_list_lock, flags);
  120. if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
  121. atomic_inc(&c->context_list_counter);
  122. entry->context = atomic_read(&c->context_list_counter);
  123. list_add(&entry->list, &c->context_list);
  124. spin_unlock_irqrestore(&c->context_list_lock, flags);
  125. osm_debug("%s: Add context to list %p -> %d\n", c->name, ptr, context);
  126. return entry->context;
  127. };
  128. /**
  129. * i2o_cntxt_list_remove - Remove a pointer from the context list
  130. * @c: controller to which the context list belong
  131. * @ptr: pointer which should be removed from the context list
  132. *
  133. * Removes a previously added pointer from the context list and returns
  134. * the matching context id.
  135. *
  136. * Returns context id on succes or 0 on failure.
  137. */
  138. u32 i2o_cntxt_list_remove(struct i2o_controller * c, void *ptr)
  139. {
  140. struct i2o_context_list_element *entry;
  141. u32 context = 0;
  142. unsigned long flags;
  143. spin_lock_irqsave(&c->context_list_lock, flags);
  144. list_for_each_entry(entry, &c->context_list, list)
  145. if (entry->ptr == ptr) {
  146. list_del(&entry->list);
  147. context = entry->context;
  148. kfree(entry);
  149. break;
  150. }
  151. spin_unlock_irqrestore(&c->context_list_lock, flags);
  152. if (!context)
  153. osm_warn("%s: Could not remove nonexistent ptr %p\n", c->name,
  154. ptr);
  155. osm_debug("%s: remove ptr from context list %d -> %p\n", c->name,
  156. context, ptr);
  157. return context;
  158. };
  159. /**
  160. * i2o_cntxt_list_get - Get a pointer from the context list and remove it
  161. * @c: controller to which the context list belong
  162. * @context: context id to which the pointer belong
  163. *
  164. * Returns pointer to the matching context id on success or NULL on
  165. * failure.
  166. */
  167. void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context)
  168. {
  169. struct i2o_context_list_element *entry;
  170. unsigned long flags;
  171. void *ptr = NULL;
  172. spin_lock_irqsave(&c->context_list_lock, flags);
  173. list_for_each_entry(entry, &c->context_list, list)
  174. if (entry->context == context) {
  175. list_del(&entry->list);
  176. ptr = entry->ptr;
  177. kfree(entry);
  178. break;
  179. }
  180. spin_unlock_irqrestore(&c->context_list_lock, flags);
  181. if (!ptr)
  182. osm_warn("%s: context id %d not found\n", c->name, context);
  183. osm_debug("%s: get ptr from context list %d -> %p\n", c->name, context,
  184. ptr);
  185. return ptr;
  186. };
  187. /**
  188. * i2o_cntxt_list_get_ptr - Get a context id from the context list
  189. * @c: controller to which the context list belong
  190. * @ptr: pointer to which the context id should be fetched
  191. *
  192. * Returns context id which matches to the pointer on succes or 0 on
  193. * failure.
  194. */
  195. u32 i2o_cntxt_list_get_ptr(struct i2o_controller * c, void *ptr)
  196. {
  197. struct i2o_context_list_element *entry;
  198. u32 context = 0;
  199. unsigned long flags;
  200. spin_lock_irqsave(&c->context_list_lock, flags);
  201. list_for_each_entry(entry, &c->context_list, list)
  202. if (entry->ptr == ptr) {
  203. context = entry->context;
  204. break;
  205. }
  206. spin_unlock_irqrestore(&c->context_list_lock, flags);
  207. if (!context)
  208. osm_warn("%s: Could not find nonexistent ptr %p\n", c->name,
  209. ptr);
  210. osm_debug("%s: get context id from context list %p -> %d\n", c->name,
  211. ptr, context);
  212. return context;
  213. };
  214. #endif
  215. /**
  216. * i2o_iop_find - Find an I2O controller by id
  217. * @unit: unit number of the I2O controller to search for
  218. *
  219. * Lookup the I2O controller on the controller list.
  220. *
  221. * Returns pointer to the I2O controller on success or NULL if not found.
  222. */
  223. struct i2o_controller *i2o_find_iop(int unit)
  224. {
  225. struct i2o_controller *c;
  226. list_for_each_entry(c, &i2o_controllers, list) {
  227. if (c->unit == unit)
  228. return c;
  229. }
  230. return NULL;
  231. };
  232. /**
  233. * i2o_iop_find_device - Find a I2O device on an I2O controller
  234. * @c: I2O controller where the I2O device hangs on
  235. * @tid: TID of the I2O device to search for
  236. *
  237. * Searches the devices of the I2O controller for a device with TID tid and
  238. * returns it.
  239. *
  240. * Returns a pointer to the I2O device if found, otherwise NULL.
  241. */
  242. struct i2o_device *i2o_iop_find_device(struct i2o_controller *c, u16 tid)
  243. {
  244. struct i2o_device *dev;
  245. list_for_each_entry(dev, &c->devices, list)
  246. if (dev->lct_data.tid == tid)
  247. return dev;
  248. return NULL;
  249. };
  250. /**
  251. * i2o_quiesce_controller - quiesce controller
  252. * @c: controller
  253. *
  254. * Quiesce an IOP. Causes IOP to make external operation quiescent
  255. * (i2o 'READY' state). Internal operation of the IOP continues normally.
  256. *
  257. * Returns 0 on success or negative error code on failure.
  258. */
  259. static int i2o_iop_quiesce(struct i2o_controller *c)
  260. {
  261. struct i2o_message __iomem *msg;
  262. u32 m;
  263. i2o_status_block *sb = c->status_block.virt;
  264. int rc;
  265. i2o_status_get(c);
  266. /* SysQuiesce discarded if IOP not in READY or OPERATIONAL state */
  267. if ((sb->iop_state != ADAPTER_STATE_READY) &&
  268. (sb->iop_state != ADAPTER_STATE_OPERATIONAL))
  269. return 0;
  270. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  271. if (m == I2O_QUEUE_EMPTY)
  272. return -ETIMEDOUT;
  273. writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  274. writel(I2O_CMD_SYS_QUIESCE << 24 | HOST_TID << 12 | ADAPTER_TID,
  275. &msg->u.head[1]);
  276. /* Long timeout needed for quiesce if lots of devices */
  277. if ((rc = i2o_msg_post_wait(c, m, 240)))
  278. osm_info("%s: Unable to quiesce (status=%#x).\n", c->name, -rc);
  279. else
  280. osm_debug("%s: Quiesced.\n", c->name);
  281. i2o_status_get(c); // Entered READY state
  282. return rc;
  283. };
  284. /**
  285. * i2o_iop_enable - move controller from ready to OPERATIONAL
  286. * @c: I2O controller
  287. *
  288. * Enable IOP. This allows the IOP to resume external operations and
  289. * reverses the effect of a quiesce. Returns zero or an error code if
  290. * an error occurs.
  291. */
  292. static int i2o_iop_enable(struct i2o_controller *c)
  293. {
  294. struct i2o_message __iomem *msg;
  295. u32 m;
  296. i2o_status_block *sb = c->status_block.virt;
  297. int rc;
  298. i2o_status_get(c);
  299. /* Enable only allowed on READY state */
  300. if (sb->iop_state != ADAPTER_STATE_READY)
  301. return -EINVAL;
  302. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  303. if (m == I2O_QUEUE_EMPTY)
  304. return -ETIMEDOUT;
  305. writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  306. writel(I2O_CMD_SYS_ENABLE << 24 | HOST_TID << 12 | ADAPTER_TID,
  307. &msg->u.head[1]);
  308. /* How long of a timeout do we need? */
  309. if ((rc = i2o_msg_post_wait(c, m, 240)))
  310. osm_err("%s: Could not enable (status=%#x).\n", c->name, -rc);
  311. else
  312. osm_debug("%s: Enabled.\n", c->name);
  313. i2o_status_get(c); // entered OPERATIONAL state
  314. return rc;
  315. };
  316. /**
  317. * i2o_iop_quiesce_all - Quiesce all I2O controllers on the system
  318. *
  319. * Quiesce all I2O controllers which are connected to the system.
  320. */
  321. static inline void i2o_iop_quiesce_all(void)
  322. {
  323. struct i2o_controller *c, *tmp;
  324. list_for_each_entry_safe(c, tmp, &i2o_controllers, list) {
  325. if (!c->no_quiesce)
  326. i2o_iop_quiesce(c);
  327. }
  328. };
  329. /**
  330. * i2o_iop_enable_all - Enables all controllers on the system
  331. *
  332. * Enables all I2O controllers which are connected to the system.
  333. */
  334. static inline void i2o_iop_enable_all(void)
  335. {
  336. struct i2o_controller *c, *tmp;
  337. list_for_each_entry_safe(c, tmp, &i2o_controllers, list)
  338. i2o_iop_enable(c);
  339. };
  340. /**
  341. * i2o_clear_controller - Bring I2O controller into HOLD state
  342. * @c: controller
  343. *
  344. * Clear an IOP to HOLD state, ie. terminate external operations, clear all
  345. * input queues and prepare for a system restart. IOP's internal operation
  346. * continues normally and the outbound queue is alive. The IOP is not
  347. * expected to rebuild its LCT.
  348. *
  349. * Returns 0 on success or negative error code on failure.
  350. */
  351. static int i2o_iop_clear(struct i2o_controller *c)
  352. {
  353. struct i2o_message __iomem *msg;
  354. u32 m;
  355. int rc;
  356. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  357. if (m == I2O_QUEUE_EMPTY)
  358. return -ETIMEDOUT;
  359. /* Quiesce all IOPs first */
  360. i2o_iop_quiesce_all();
  361. writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  362. writel(I2O_CMD_ADAPTER_CLEAR << 24 | HOST_TID << 12 | ADAPTER_TID,
  363. &msg->u.head[1]);
  364. if ((rc = i2o_msg_post_wait(c, m, 30)))
  365. osm_info("%s: Unable to clear (status=%#x).\n", c->name, -rc);
  366. else
  367. osm_debug("%s: Cleared.\n", c->name);
  368. /* Enable all IOPs */
  369. i2o_iop_enable_all();
  370. return rc;
  371. }
  372. /**
  373. * i2o_iop_init_outbound_queue - setup the outbound message queue
  374. * @c: I2O controller
  375. *
  376. * Clear and (re)initialize IOP's outbound queue and post the message
  377. * frames to the IOP.
  378. *
  379. * Returns 0 on success or a negative errno code on failure.
  380. */
  381. static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
  382. {
  383. volatile u8 *status = c->status.virt;
  384. u32 m;
  385. struct i2o_message __iomem *msg;
  386. ulong timeout;
  387. int i;
  388. osm_debug("%s: Initializing Outbound Queue...\n", c->name);
  389. memset(c->status.virt, 0, 4);
  390. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  391. if (m == I2O_QUEUE_EMPTY)
  392. return -ETIMEDOUT;
  393. writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]);
  394. writel(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_TID,
  395. &msg->u.head[1]);
  396. writel(i2o_exec_driver.context, &msg->u.s.icntxt);
  397. writel(0x00000000, &msg->u.s.tcntxt);
  398. writel(PAGE_SIZE, &msg->body[0]);
  399. /* Outbound msg frame size in words and Initcode */
  400. writel(I2O_OUTBOUND_MSG_FRAME_SIZE << 16 | 0x80, &msg->body[1]);
  401. writel(0xd0000004, &msg->body[2]);
  402. writel(i2o_dma_low(c->status.phys), &msg->body[3]);
  403. writel(i2o_dma_high(c->status.phys), &msg->body[4]);
  404. i2o_msg_post(c, m);
  405. timeout = jiffies + I2O_TIMEOUT_INIT_OUTBOUND_QUEUE * HZ;
  406. while (*status <= I2O_CMD_IN_PROGRESS) {
  407. if (time_after(jiffies, timeout)) {
  408. osm_warn("%s: Timeout Initializing\n", c->name);
  409. return -ETIMEDOUT;
  410. }
  411. set_current_state(TASK_UNINTERRUPTIBLE);
  412. schedule_timeout(1);
  413. }
  414. m = c->out_queue.phys;
  415. /* Post frames */
  416. for (i = 0; i < I2O_MAX_OUTBOUND_MSG_FRAMES; i++) {
  417. i2o_flush_reply(c, m);
  418. udelay(1); /* Promise */
  419. m += I2O_OUTBOUND_MSG_FRAME_SIZE * sizeof(u32);
  420. }
  421. return 0;
  422. }
  423. /**
  424. * i2o_iop_reset - reset an I2O controller
  425. * @c: controller to reset
  426. *
  427. * Reset the IOP into INIT state and wait until IOP gets into RESET state.
  428. * Terminate all external operations, clear IOP's inbound and outbound
  429. * queues, terminate all DDMs, and reload the IOP's operating environment
  430. * and all local DDMs. The IOP rebuilds its LCT.
  431. */
  432. static int i2o_iop_reset(struct i2o_controller *c)
  433. {
  434. volatile u8 *status = c->status.virt;
  435. struct i2o_message __iomem *msg;
  436. u32 m;
  437. unsigned long timeout;
  438. i2o_status_block *sb = c->status_block.virt;
  439. int rc = 0;
  440. osm_debug("%s: Resetting controller\n", c->name);
  441. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  442. if (m == I2O_QUEUE_EMPTY)
  443. return -ETIMEDOUT;
  444. memset(c->status_block.virt, 0, 8);
  445. /* Quiesce all IOPs first */
  446. i2o_iop_quiesce_all();
  447. writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  448. writel(I2O_CMD_ADAPTER_RESET << 24 | HOST_TID << 12 | ADAPTER_TID,
  449. &msg->u.head[1]);
  450. writel(i2o_exec_driver.context, &msg->u.s.icntxt);
  451. writel(0, &msg->u.s.tcntxt); //FIXME: use reasonable transaction context
  452. writel(0, &msg->body[0]);
  453. writel(0, &msg->body[1]);
  454. writel(i2o_dma_low(c->status.phys), &msg->body[2]);
  455. writel(i2o_dma_high(c->status.phys), &msg->body[3]);
  456. i2o_msg_post(c, m);
  457. /* Wait for a reply */
  458. timeout = jiffies + I2O_TIMEOUT_RESET * HZ;
  459. while (!*status) {
  460. if (time_after(jiffies, timeout))
  461. break;
  462. set_current_state(TASK_UNINTERRUPTIBLE);
  463. schedule_timeout(1);
  464. }
  465. switch (*status) {
  466. case I2O_CMD_REJECTED:
  467. osm_warn("%s: IOP reset rejected\n", c->name);
  468. rc = -EPERM;
  469. break;
  470. case I2O_CMD_IN_PROGRESS:
  471. /*
  472. * Once the reset is sent, the IOP goes into the INIT state
  473. * which is indeterminate. We need to wait until the IOP has
  474. * rebooted before we can let the system talk to it. We read
  475. * the inbound Free_List until a message is available. If we
  476. * can't read one in the given ammount of time, we assume the
  477. * IOP could not reboot properly.
  478. */
  479. osm_debug("%s: Reset in progress, waiting for reboot...\n",
  480. c->name);
  481. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET);
  482. while (m == I2O_QUEUE_EMPTY) {
  483. if (time_after(jiffies, timeout)) {
  484. osm_err("%s: IOP reset timeout.\n", c->name);
  485. rc = -ETIMEDOUT;
  486. goto exit;
  487. }
  488. set_current_state(TASK_UNINTERRUPTIBLE);
  489. schedule_timeout(1);
  490. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET);
  491. }
  492. i2o_msg_nop(c, m);
  493. /* from here all quiesce commands are safe */
  494. c->no_quiesce = 0;
  495. /* verify if controller is in state RESET */
  496. i2o_status_get(c);
  497. if (!c->promise && (sb->iop_state != ADAPTER_STATE_RESET))
  498. osm_warn("%s: reset completed, but adapter not in RESET"
  499. " state.\n", c->name);
  500. else
  501. osm_debug("%s: reset completed.\n", c->name);
  502. break;
  503. default:
  504. osm_err("%s: IOP reset timeout.\n", c->name);
  505. rc = -ETIMEDOUT;
  506. break;
  507. }
  508. exit:
  509. /* Enable all IOPs */
  510. i2o_iop_enable_all();
  511. return rc;
  512. };
  513. /**
  514. * i2o_iop_activate - Bring controller up to HOLD
  515. * @c: controller
  516. *
  517. * This function brings an I2O controller into HOLD state. The adapter
  518. * is reset if necessary and then the queues and resource table are read.
  519. *
  520. * Returns 0 on success or negative error code on failure.
  521. */
  522. static int i2o_iop_activate(struct i2o_controller *c)
  523. {
  524. i2o_status_block *sb = c->status_block.virt;
  525. int rc;
  526. int state;
  527. /* In INIT state, Wait Inbound Q to initialize (in i2o_status_get) */
  528. /* In READY state, Get status */
  529. rc = i2o_status_get(c);
  530. if (rc) {
  531. osm_info("%s: Unable to obtain status, attempting a reset.\n",
  532. c->name);
  533. rc = i2o_iop_reset(c);
  534. if (rc)
  535. return rc;
  536. }
  537. if (sb->i2o_version > I2OVER15) {
  538. osm_err("%s: Not running version 1.5 of the I2O Specification."
  539. "\n", c->name);
  540. return -ENODEV;
  541. }
  542. switch (sb->iop_state) {
  543. case ADAPTER_STATE_FAULTED:
  544. osm_err("%s: hardware fault\n", c->name);
  545. return -EFAULT;
  546. case ADAPTER_STATE_READY:
  547. case ADAPTER_STATE_OPERATIONAL:
  548. case ADAPTER_STATE_HOLD:
  549. case ADAPTER_STATE_FAILED:
  550. osm_debug("%s: already running, trying to reset...\n", c->name);
  551. rc = i2o_iop_reset(c);
  552. if (rc)
  553. return rc;
  554. }
  555. /* preserve state */
  556. state = sb->iop_state;
  557. rc = i2o_iop_init_outbound_queue(c);
  558. if (rc)
  559. return rc;
  560. /* if adapter was not in RESET state clear now */
  561. if (state != ADAPTER_STATE_RESET)
  562. i2o_iop_clear(c);
  563. i2o_status_get(c);
  564. if (sb->iop_state != ADAPTER_STATE_HOLD) {
  565. osm_err("%s: failed to bring IOP into HOLD state\n", c->name);
  566. return -EIO;
  567. }
  568. return i2o_hrt_get(c);
  569. };
  570. /**
  571. * i2o_iop_systab_set - Set the I2O System Table of the specified IOP
  572. * @c: I2O controller to which the system table should be send
  573. *
  574. * Before the systab could be set i2o_systab_build() must be called.
  575. *
  576. * Returns 0 on success or negative error code on failure.
  577. */
  578. static int i2o_iop_systab_set(struct i2o_controller *c)
  579. {
  580. struct i2o_message __iomem *msg;
  581. u32 m;
  582. i2o_status_block *sb = c->status_block.virt;
  583. struct device *dev = &c->pdev->dev;
  584. struct resource *root;
  585. int rc;
  586. if (sb->current_mem_size < sb->desired_mem_size) {
  587. struct resource *res = &c->mem_resource;
  588. res->name = c->pdev->bus->name;
  589. res->flags = IORESOURCE_MEM;
  590. res->start = 0;
  591. res->end = 0;
  592. osm_info("%s: requires private memory resources.\n", c->name);
  593. root = pci_find_parent_resource(c->pdev, res);
  594. if (root == NULL)
  595. osm_warn("%s: Can't find parent resource!\n", c->name);
  596. if (root && allocate_resource(root, res, sb->desired_mem_size, sb->desired_mem_size, sb->desired_mem_size, 1 << 20, /* Unspecified, so use 1Mb and play safe */
  597. NULL, NULL) >= 0) {
  598. c->mem_alloc = 1;
  599. sb->current_mem_size = 1 + res->end - res->start;
  600. sb->current_mem_base = res->start;
  601. osm_info("%s: allocated %ld bytes of PCI memory at "
  602. "0x%08lX.\n", c->name,
  603. 1 + res->end - res->start, res->start);
  604. }
  605. }
  606. if (sb->current_io_size < sb->desired_io_size) {
  607. struct resource *res = &c->io_resource;
  608. res->name = c->pdev->bus->name;
  609. res->flags = IORESOURCE_IO;
  610. res->start = 0;
  611. res->end = 0;
  612. osm_info("%s: requires private memory resources.\n", c->name);
  613. root = pci_find_parent_resource(c->pdev, res);
  614. if (root == NULL)
  615. osm_warn("%s: Can't find parent resource!\n", c->name);
  616. if (root && allocate_resource(root, res, sb->desired_io_size, sb->desired_io_size, sb->desired_io_size, 1 << 20, /* Unspecified, so use 1Mb and play safe */
  617. NULL, NULL) >= 0) {
  618. c->io_alloc = 1;
  619. sb->current_io_size = 1 + res->end - res->start;
  620. sb->current_mem_base = res->start;
  621. osm_info("%s: allocated %ld bytes of PCI I/O at 0x%08lX"
  622. ".\n", c->name, 1 + res->end - res->start,
  623. res->start);
  624. }
  625. }
  626. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  627. if (m == I2O_QUEUE_EMPTY)
  628. return -ETIMEDOUT;
  629. i2o_systab.phys = dma_map_single(dev, i2o_systab.virt, i2o_systab.len,
  630. PCI_DMA_TODEVICE);
  631. if (!i2o_systab.phys) {
  632. i2o_msg_nop(c, m);
  633. return -ENOMEM;
  634. }
  635. writel(I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6, &msg->u.head[0]);
  636. writel(I2O_CMD_SYS_TAB_SET << 24 | HOST_TID << 12 | ADAPTER_TID,
  637. &msg->u.head[1]);
  638. /*
  639. * Provide three SGL-elements:
  640. * System table (SysTab), Private memory space declaration and
  641. * Private i/o space declaration
  642. *
  643. * FIXME: is this still true?
  644. * Nasty one here. We can't use dma_alloc_coherent to send the
  645. * same table to everyone. We have to go remap it for them all
  646. */
  647. writel(c->unit + 2, &msg->body[0]);
  648. writel(0, &msg->body[1]);
  649. writel(0x54000000 | i2o_systab.len, &msg->body[2]);
  650. writel(i2o_systab.phys, &msg->body[3]);
  651. writel(0x54000000 | sb->current_mem_size, &msg->body[4]);
  652. writel(sb->current_mem_base, &msg->body[5]);
  653. writel(0xd4000000 | sb->current_io_size, &msg->body[6]);
  654. writel(sb->current_io_base, &msg->body[6]);
  655. rc = i2o_msg_post_wait(c, m, 120);
  656. dma_unmap_single(dev, i2o_systab.phys, i2o_systab.len,
  657. PCI_DMA_TODEVICE);
  658. if (rc < 0)
  659. osm_err("%s: Unable to set SysTab (status=%#x).\n", c->name,
  660. -rc);
  661. else
  662. osm_debug("%s: SysTab set.\n", c->name);
  663. i2o_status_get(c); // Entered READY state
  664. return rc;
  665. }
  666. /**
  667. * i2o_iop_online - Bring a controller online into OPERATIONAL state.
  668. * @c: I2O controller
  669. *
  670. * Send the system table and enable the I2O controller.
  671. *
  672. * Returns 0 on success or negativer error code on failure.
  673. */
  674. static int i2o_iop_online(struct i2o_controller *c)
  675. {
  676. int rc;
  677. rc = i2o_iop_systab_set(c);
  678. if (rc)
  679. return rc;
  680. /* In READY state */
  681. osm_debug("%s: Attempting to enable...\n", c->name);
  682. rc = i2o_iop_enable(c);
  683. if (rc)
  684. return rc;
  685. return 0;
  686. };
  687. /**
  688. * i2o_iop_remove - Remove the I2O controller from the I2O core
  689. * @c: I2O controller
  690. *
  691. * Remove the I2O controller from the I2O core. If devices are attached to
  692. * the controller remove these also and finally reset the controller.
  693. */
  694. void i2o_iop_remove(struct i2o_controller *c)
  695. {
  696. struct i2o_device *dev, *tmp;
  697. osm_debug("%s: deleting controller\n", c->name);
  698. i2o_driver_notify_controller_remove_all(c);
  699. list_del(&c->list);
  700. list_for_each_entry_safe(dev, tmp, &c->devices, list)
  701. i2o_device_remove(dev);
  702. class_device_unregister(c->classdev);
  703. device_del(&c->device);
  704. /* Ask the IOP to switch to RESET state */
  705. i2o_iop_reset(c);
  706. put_device(&c->device);
  707. }
  708. /**
  709. * i2o_systab_build - Build system table
  710. *
  711. * The system table contains information about all the IOPs in the system
  712. * (duh) and is used by the Executives on the IOPs to establish peer2peer
  713. * connections. We're not supporting peer2peer at the moment, but this
  714. * will be needed down the road for things like lan2lan forwarding.
  715. *
  716. * Returns 0 on success or negative error code on failure.
  717. */
  718. static int i2o_systab_build(void)
  719. {
  720. struct i2o_controller *c, *tmp;
  721. int num_controllers = 0;
  722. u32 change_ind = 0;
  723. int count = 0;
  724. struct i2o_sys_tbl *systab = i2o_systab.virt;
  725. list_for_each_entry_safe(c, tmp, &i2o_controllers, list)
  726. num_controllers++;
  727. if (systab) {
  728. change_ind = systab->change_ind;
  729. kfree(i2o_systab.virt);
  730. }
  731. /* Header + IOPs */
  732. i2o_systab.len = sizeof(struct i2o_sys_tbl) + num_controllers *
  733. sizeof(struct i2o_sys_tbl_entry);
  734. systab = i2o_systab.virt = kmalloc(i2o_systab.len, GFP_KERNEL);
  735. if (!systab) {
  736. osm_err("unable to allocate memory for System Table\n");
  737. return -ENOMEM;
  738. }
  739. memset(systab, 0, i2o_systab.len);
  740. systab->version = I2OVERSION;
  741. systab->change_ind = change_ind + 1;
  742. list_for_each_entry_safe(c, tmp, &i2o_controllers, list) {
  743. i2o_status_block *sb;
  744. if (count >= num_controllers) {
  745. osm_err("controller added while building system table"
  746. "\n");
  747. break;
  748. }
  749. sb = c->status_block.virt;
  750. /*
  751. * Get updated IOP state so we have the latest information
  752. *
  753. * We should delete the controller at this point if it
  754. * doesn't respond since if it's not on the system table
  755. * it is techninically not part of the I2O subsystem...
  756. */
  757. if (unlikely(i2o_status_get(c))) {
  758. osm_err("%s: Deleting b/c could not get status while "
  759. "attempting to build system table\n", c->name);
  760. i2o_iop_remove(c);
  761. continue; // try the next one
  762. }
  763. systab->iops[count].org_id = sb->org_id;
  764. systab->iops[count].iop_id = c->unit + 2;
  765. systab->iops[count].seg_num = 0;
  766. systab->iops[count].i2o_version = sb->i2o_version;
  767. systab->iops[count].iop_state = sb->iop_state;
  768. systab->iops[count].msg_type = sb->msg_type;
  769. systab->iops[count].frame_size = sb->inbound_frame_size;
  770. systab->iops[count].last_changed = change_ind;
  771. systab->iops[count].iop_capabilities = sb->iop_capabilities;
  772. systab->iops[count].inbound_low =
  773. i2o_dma_low(c->base.phys + I2O_IN_PORT);
  774. systab->iops[count].inbound_high =
  775. i2o_dma_high(c->base.phys + I2O_IN_PORT);
  776. count++;
  777. }
  778. systab->num_entries = count;
  779. return 0;
  780. };
  781. /**
  782. * i2o_parse_hrt - Parse the hardware resource table.
  783. * @c: I2O controller
  784. *
  785. * We don't do anything with it except dumping it (in debug mode).
  786. *
  787. * Returns 0.
  788. */
  789. static int i2o_parse_hrt(struct i2o_controller *c)
  790. {
  791. i2o_dump_hrt(c);
  792. return 0;
  793. };
  794. /**
  795. * i2o_status_get - Get the status block from the I2O controller
  796. * @c: I2O controller
  797. *
  798. * Issue a status query on the controller. This updates the attached
  799. * status block. The status block could then be accessed through
  800. * c->status_block.
  801. *
  802. * Returns 0 on sucess or negative error code on failure.
  803. */
  804. int i2o_status_get(struct i2o_controller *c)
  805. {
  806. struct i2o_message __iomem *msg;
  807. u32 m;
  808. volatile u8 *status_block;
  809. unsigned long timeout;
  810. status_block = (u8 *) c->status_block.virt;
  811. memset(c->status_block.virt, 0, sizeof(i2o_status_block));
  812. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  813. if (m == I2O_QUEUE_EMPTY)
  814. return -ETIMEDOUT;
  815. writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  816. writel(I2O_CMD_STATUS_GET << 24 | HOST_TID << 12 | ADAPTER_TID,
  817. &msg->u.head[1]);
  818. writel(i2o_exec_driver.context, &msg->u.s.icntxt);
  819. writel(0, &msg->u.s.tcntxt); // FIXME: use resonable transaction context
  820. writel(0, &msg->body[0]);
  821. writel(0, &msg->body[1]);
  822. writel(i2o_dma_low(c->status_block.phys), &msg->body[2]);
  823. writel(i2o_dma_high(c->status_block.phys), &msg->body[3]);
  824. writel(sizeof(i2o_status_block), &msg->body[4]); /* always 88 bytes */
  825. i2o_msg_post(c, m);
  826. /* Wait for a reply */
  827. timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ;
  828. while (status_block[87] != 0xFF) {
  829. if (time_after(jiffies, timeout)) {
  830. osm_err("%s: Get status timeout.\n", c->name);
  831. return -ETIMEDOUT;
  832. }
  833. set_current_state(TASK_UNINTERRUPTIBLE);
  834. schedule_timeout(1);
  835. }
  836. #ifdef DEBUG
  837. i2o_debug_state(c);
  838. #endif
  839. return 0;
  840. }
  841. /*
  842. * i2o_hrt_get - Get the Hardware Resource Table from the I2O controller
  843. * @c: I2O controller from which the HRT should be fetched
  844. *
  845. * The HRT contains information about possible hidden devices but is
  846. * mostly useless to us.
  847. *
  848. * Returns 0 on success or negativer error code on failure.
  849. */
  850. static int i2o_hrt_get(struct i2o_controller *c)
  851. {
  852. int rc;
  853. int i;
  854. i2o_hrt *hrt = c->hrt.virt;
  855. u32 size = sizeof(i2o_hrt);
  856. struct device *dev = &c->pdev->dev;
  857. for (i = 0; i < I2O_HRT_GET_TRIES; i++) {
  858. struct i2o_message __iomem *msg;
  859. u32 m;
  860. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  861. if (m == I2O_QUEUE_EMPTY)
  862. return -ETIMEDOUT;
  863. writel(SIX_WORD_MSG_SIZE | SGL_OFFSET_4, &msg->u.head[0]);
  864. writel(I2O_CMD_HRT_GET << 24 | HOST_TID << 12 | ADAPTER_TID,
  865. &msg->u.head[1]);
  866. writel(0xd0000000 | c->hrt.len, &msg->body[0]);
  867. writel(c->hrt.phys, &msg->body[1]);
  868. rc = i2o_msg_post_wait_mem(c, m, 20, &c->hrt);
  869. if (rc < 0) {
  870. osm_err("%s: Unable to get HRT (status=%#x)\n", c->name,
  871. -rc);
  872. return rc;
  873. }
  874. size = hrt->num_entries * hrt->entry_len << 2;
  875. if (size > c->hrt.len) {
  876. if (i2o_dma_realloc(dev, &c->hrt, size, GFP_KERNEL))
  877. return -ENOMEM;
  878. else
  879. hrt = c->hrt.virt;
  880. } else
  881. return i2o_parse_hrt(c);
  882. }
  883. osm_err("%s: Unable to get HRT after %d tries, giving up\n", c->name,
  884. I2O_HRT_GET_TRIES);
  885. return -EBUSY;
  886. }
  887. /**
  888. * i2o_iop_free - Free the i2o_controller struct
  889. * @c: I2O controller to free
  890. */
  891. void i2o_iop_free(struct i2o_controller *c)
  892. {
  893. kfree(c);
  894. };
  895. /**
  896. * i2o_iop_release - release the memory for a I2O controller
  897. * @dev: I2O controller which should be released
  898. *
  899. * Release the allocated memory. This function is called if refcount of
  900. * device reaches 0 automatically.
  901. */
  902. static void i2o_iop_release(struct device *dev)
  903. {
  904. struct i2o_controller *c = to_i2o_controller(dev);
  905. i2o_iop_free(c);
  906. };
  907. /* I2O controller class */
  908. static struct class *i2o_controller_class;
  909. /**
  910. * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
  911. *
  912. * Allocate the necessary memory for a i2o_controller struct and
  913. * initialize the lists.
  914. *
  915. * Returns a pointer to the I2O controller or a negative error code on
  916. * failure.
  917. */
  918. struct i2o_controller *i2o_iop_alloc(void)
  919. {
  920. static int unit = 0; /* 0 and 1 are NULL IOP and Local Host */
  921. struct i2o_controller *c;
  922. c = kmalloc(sizeof(*c), GFP_KERNEL);
  923. if (!c) {
  924. osm_err("i2o: Insufficient memory to allocate a I2O controller."
  925. "\n");
  926. return ERR_PTR(-ENOMEM);
  927. }
  928. memset(c, 0, sizeof(*c));
  929. INIT_LIST_HEAD(&c->devices);
  930. spin_lock_init(&c->lock);
  931. init_MUTEX(&c->lct_lock);
  932. c->unit = unit++;
  933. sprintf(c->name, "iop%d", c->unit);
  934. device_initialize(&c->device);
  935. c->device.release = &i2o_iop_release;
  936. snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit);
  937. #if BITS_PER_LONG == 64
  938. spin_lock_init(&c->context_list_lock);
  939. atomic_set(&c->context_list_counter, 0);
  940. INIT_LIST_HEAD(&c->context_list);
  941. #endif
  942. return c;
  943. };
  944. /**
  945. * i2o_iop_add - Initialize the I2O controller and add him to the I2O core
  946. * @c: controller
  947. *
  948. * Initialize the I2O controller and if no error occurs add him to the I2O
  949. * core.
  950. *
  951. * Returns 0 on success or negative error code on failure.
  952. */
  953. int i2o_iop_add(struct i2o_controller *c)
  954. {
  955. int rc;
  956. if ((rc = device_add(&c->device))) {
  957. osm_err("%s: could not add controller\n", c->name);
  958. goto iop_reset;
  959. }
  960. c->classdev = class_device_create(i2o_controller_class, 0,
  961. &c->device, "iop%d", c->unit);
  962. if (IS_ERR(c->classdev)) {
  963. osm_err("%s: could not add controller class\n", c->name);
  964. goto device_del;
  965. }
  966. osm_info("%s: Activating I2O controller...\n", c->name);
  967. osm_info("%s: This may take a few minutes if there are many devices\n",
  968. c->name);
  969. if ((rc = i2o_iop_activate(c))) {
  970. osm_err("%s: could not activate controller\n", c->name);
  971. goto class_del;
  972. }
  973. osm_debug("%s: building sys table...\n", c->name);
  974. if ((rc = i2o_systab_build()))
  975. goto class_del;
  976. osm_debug("%s: online controller...\n", c->name);
  977. if ((rc = i2o_iop_online(c)))
  978. goto class_del;
  979. osm_debug("%s: getting LCT...\n", c->name);
  980. if ((rc = i2o_exec_lct_get(c)))
  981. goto class_del;
  982. list_add(&c->list, &i2o_controllers);
  983. i2o_driver_notify_controller_add_all(c);
  984. osm_info("%s: Controller added\n", c->name);
  985. return 0;
  986. class_del:
  987. class_device_unregister(c->classdev);
  988. device_del:
  989. device_del(&c->device);
  990. iop_reset:
  991. i2o_iop_reset(c);
  992. return rc;
  993. };
  994. /**
  995. * i2o_event_register - Turn on/off event notification for a I2O device
  996. * @dev: I2O device which should receive the event registration request
  997. * @drv: driver which want to get notified
  998. * @tcntxt: transaction context to use with this notifier
  999. * @evt_mask: mask of events
  1000. *
  1001. * Create and posts an event registration message to the task. No reply
  1002. * is waited for, or expected. If you do not want further notifications,
  1003. * call the i2o_event_register again with a evt_mask of 0.
  1004. *
  1005. * Returns 0 on success or -ETIMEDOUT if no message could be fetched for
  1006. * sending the request.
  1007. */
  1008. int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv,
  1009. int tcntxt, u32 evt_mask)
  1010. {
  1011. struct i2o_controller *c = dev->iop;
  1012. struct i2o_message __iomem *msg;
  1013. u32 m;
  1014. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  1015. if (m == I2O_QUEUE_EMPTY)
  1016. return -ETIMEDOUT;
  1017. writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  1018. writel(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev->lct_data.
  1019. tid, &msg->u.head[1]);
  1020. writel(drv->context, &msg->u.s.icntxt);
  1021. writel(tcntxt, &msg->u.s.tcntxt);
  1022. writel(evt_mask, &msg->body[0]);
  1023. i2o_msg_post(c, m);
  1024. return 0;
  1025. };
  1026. /**
  1027. * i2o_iop_init - I2O main initialization function
  1028. *
  1029. * Initialize the I2O drivers (OSM) functions, register the Executive OSM,
  1030. * initialize the I2O PCI part and finally initialize I2O device stuff.
  1031. *
  1032. * Returns 0 on success or negative error code on failure.
  1033. */
  1034. static int __init i2o_iop_init(void)
  1035. {
  1036. int rc = 0;
  1037. printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
  1038. i2o_controller_class = class_create(THIS_MODULE, "i2o_controller");
  1039. if (IS_ERR(i2o_controller_class)) {
  1040. osm_err("can't register class i2o_controller\n");
  1041. goto exit;
  1042. }
  1043. if ((rc = i2o_driver_init()))
  1044. goto class_exit;
  1045. if ((rc = i2o_exec_init()))
  1046. goto driver_exit;
  1047. if ((rc = i2o_pci_init()))
  1048. goto exec_exit;
  1049. return 0;
  1050. exec_exit:
  1051. i2o_exec_exit();
  1052. driver_exit:
  1053. i2o_driver_exit();
  1054. class_exit:
  1055. class_destroy(i2o_controller_class);
  1056. exit:
  1057. return rc;
  1058. }
  1059. /**
  1060. * i2o_iop_exit - I2O main exit function
  1061. *
  1062. * Removes I2O controllers from PCI subsystem and shut down OSMs.
  1063. */
  1064. static void __exit i2o_iop_exit(void)
  1065. {
  1066. i2o_pci_exit();
  1067. i2o_exec_exit();
  1068. i2o_driver_exit();
  1069. class_destroy(i2o_controller_class);
  1070. };
  1071. module_init(i2o_iop_init);
  1072. module_exit(i2o_iop_exit);
  1073. MODULE_AUTHOR("Red Hat Software");
  1074. MODULE_LICENSE("GPL");
  1075. MODULE_DESCRIPTION(OSM_DESCRIPTION);
  1076. MODULE_VERSION(OSM_VERSION);
  1077. #if BITS_PER_LONG == 64
  1078. EXPORT_SYMBOL(i2o_cntxt_list_add);
  1079. EXPORT_SYMBOL(i2o_cntxt_list_get);
  1080. EXPORT_SYMBOL(i2o_cntxt_list_remove);
  1081. EXPORT_SYMBOL(i2o_cntxt_list_get_ptr);
  1082. #endif
  1083. EXPORT_SYMBOL(i2o_msg_get_wait);
  1084. EXPORT_SYMBOL(i2o_msg_nop);
  1085. EXPORT_SYMBOL(i2o_find_iop);
  1086. EXPORT_SYMBOL(i2o_iop_find_device);
  1087. EXPORT_SYMBOL(i2o_event_register);
  1088. EXPORT_SYMBOL(i2o_status_get);
  1089. EXPORT_SYMBOL(i2o_controllers);