iop.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319
  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. device_del(&c->device);
  703. /* Ask the IOP to switch to RESET state */
  704. i2o_iop_reset(c);
  705. put_device(&c->device);
  706. }
  707. /**
  708. * i2o_systab_build - Build system table
  709. *
  710. * The system table contains information about all the IOPs in the system
  711. * (duh) and is used by the Executives on the IOPs to establish peer2peer
  712. * connections. We're not supporting peer2peer at the moment, but this
  713. * will be needed down the road for things like lan2lan forwarding.
  714. *
  715. * Returns 0 on success or negative error code on failure.
  716. */
  717. static int i2o_systab_build(void)
  718. {
  719. struct i2o_controller *c, *tmp;
  720. int num_controllers = 0;
  721. u32 change_ind = 0;
  722. int count = 0;
  723. struct i2o_sys_tbl *systab = i2o_systab.virt;
  724. list_for_each_entry_safe(c, tmp, &i2o_controllers, list)
  725. num_controllers++;
  726. if (systab) {
  727. change_ind = systab->change_ind;
  728. kfree(i2o_systab.virt);
  729. }
  730. /* Header + IOPs */
  731. i2o_systab.len = sizeof(struct i2o_sys_tbl) + num_controllers *
  732. sizeof(struct i2o_sys_tbl_entry);
  733. systab = i2o_systab.virt = kmalloc(i2o_systab.len, GFP_KERNEL);
  734. if (!systab) {
  735. osm_err("unable to allocate memory for System Table\n");
  736. return -ENOMEM;
  737. }
  738. memset(systab, 0, i2o_systab.len);
  739. systab->version = I2OVERSION;
  740. systab->change_ind = change_ind + 1;
  741. list_for_each_entry_safe(c, tmp, &i2o_controllers, list) {
  742. i2o_status_block *sb;
  743. if (count >= num_controllers) {
  744. osm_err("controller added while building system table"
  745. "\n");
  746. break;
  747. }
  748. sb = c->status_block.virt;
  749. /*
  750. * Get updated IOP state so we have the latest information
  751. *
  752. * We should delete the controller at this point if it
  753. * doesn't respond since if it's not on the system table
  754. * it is techninically not part of the I2O subsystem...
  755. */
  756. if (unlikely(i2o_status_get(c))) {
  757. osm_err("%s: Deleting b/c could not get status while "
  758. "attempting to build system table\n", c->name);
  759. i2o_iop_remove(c);
  760. continue; // try the next one
  761. }
  762. systab->iops[count].org_id = sb->org_id;
  763. systab->iops[count].iop_id = c->unit + 2;
  764. systab->iops[count].seg_num = 0;
  765. systab->iops[count].i2o_version = sb->i2o_version;
  766. systab->iops[count].iop_state = sb->iop_state;
  767. systab->iops[count].msg_type = sb->msg_type;
  768. systab->iops[count].frame_size = sb->inbound_frame_size;
  769. systab->iops[count].last_changed = change_ind;
  770. systab->iops[count].iop_capabilities = sb->iop_capabilities;
  771. systab->iops[count].inbound_low =
  772. i2o_dma_low(c->base.phys + I2O_IN_PORT);
  773. systab->iops[count].inbound_high =
  774. i2o_dma_high(c->base.phys + I2O_IN_PORT);
  775. count++;
  776. }
  777. systab->num_entries = count;
  778. return 0;
  779. };
  780. /**
  781. * i2o_parse_hrt - Parse the hardware resource table.
  782. * @c: I2O controller
  783. *
  784. * We don't do anything with it except dumping it (in debug mode).
  785. *
  786. * Returns 0.
  787. */
  788. static int i2o_parse_hrt(struct i2o_controller *c)
  789. {
  790. i2o_dump_hrt(c);
  791. return 0;
  792. };
  793. /**
  794. * i2o_status_get - Get the status block from the I2O controller
  795. * @c: I2O controller
  796. *
  797. * Issue a status query on the controller. This updates the attached
  798. * status block. The status block could then be accessed through
  799. * c->status_block.
  800. *
  801. * Returns 0 on sucess or negative error code on failure.
  802. */
  803. int i2o_status_get(struct i2o_controller *c)
  804. {
  805. struct i2o_message __iomem *msg;
  806. u32 m;
  807. volatile u8 *status_block;
  808. unsigned long timeout;
  809. status_block = (u8 *) c->status_block.virt;
  810. memset(c->status_block.virt, 0, sizeof(i2o_status_block));
  811. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  812. if (m == I2O_QUEUE_EMPTY)
  813. return -ETIMEDOUT;
  814. writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  815. writel(I2O_CMD_STATUS_GET << 24 | HOST_TID << 12 | ADAPTER_TID,
  816. &msg->u.head[1]);
  817. writel(i2o_exec_driver.context, &msg->u.s.icntxt);
  818. writel(0, &msg->u.s.tcntxt); // FIXME: use resonable transaction context
  819. writel(0, &msg->body[0]);
  820. writel(0, &msg->body[1]);
  821. writel(i2o_dma_low(c->status_block.phys), &msg->body[2]);
  822. writel(i2o_dma_high(c->status_block.phys), &msg->body[3]);
  823. writel(sizeof(i2o_status_block), &msg->body[4]); /* always 88 bytes */
  824. i2o_msg_post(c, m);
  825. /* Wait for a reply */
  826. timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ;
  827. while (status_block[87] != 0xFF) {
  828. if (time_after(jiffies, timeout)) {
  829. osm_err("%s: Get status timeout.\n", c->name);
  830. return -ETIMEDOUT;
  831. }
  832. set_current_state(TASK_UNINTERRUPTIBLE);
  833. schedule_timeout(1);
  834. }
  835. #ifdef DEBUG
  836. i2o_debug_state(c);
  837. #endif
  838. return 0;
  839. }
  840. /*
  841. * i2o_hrt_get - Get the Hardware Resource Table from the I2O controller
  842. * @c: I2O controller from which the HRT should be fetched
  843. *
  844. * The HRT contains information about possible hidden devices but is
  845. * mostly useless to us.
  846. *
  847. * Returns 0 on success or negativer error code on failure.
  848. */
  849. static int i2o_hrt_get(struct i2o_controller *c)
  850. {
  851. int rc;
  852. int i;
  853. i2o_hrt *hrt = c->hrt.virt;
  854. u32 size = sizeof(i2o_hrt);
  855. struct device *dev = &c->pdev->dev;
  856. for (i = 0; i < I2O_HRT_GET_TRIES; i++) {
  857. struct i2o_message __iomem *msg;
  858. u32 m;
  859. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  860. if (m == I2O_QUEUE_EMPTY)
  861. return -ETIMEDOUT;
  862. writel(SIX_WORD_MSG_SIZE | SGL_OFFSET_4, &msg->u.head[0]);
  863. writel(I2O_CMD_HRT_GET << 24 | HOST_TID << 12 | ADAPTER_TID,
  864. &msg->u.head[1]);
  865. writel(0xd0000000 | c->hrt.len, &msg->body[0]);
  866. writel(c->hrt.phys, &msg->body[1]);
  867. rc = i2o_msg_post_wait_mem(c, m, 20, &c->hrt);
  868. if (rc < 0) {
  869. osm_err("%s: Unable to get HRT (status=%#x)\n", c->name,
  870. -rc);
  871. return rc;
  872. }
  873. size = hrt->num_entries * hrt->entry_len << 2;
  874. if (size > c->hrt.len) {
  875. if (i2o_dma_realloc(dev, &c->hrt, size, GFP_KERNEL))
  876. return -ENOMEM;
  877. else
  878. hrt = c->hrt.virt;
  879. } else
  880. return i2o_parse_hrt(c);
  881. }
  882. osm_err("%s: Unable to get HRT after %d tries, giving up\n", c->name,
  883. I2O_HRT_GET_TRIES);
  884. return -EBUSY;
  885. }
  886. /**
  887. * i2o_iop_free - Free the i2o_controller struct
  888. * @c: I2O controller to free
  889. */
  890. void i2o_iop_free(struct i2o_controller *c)
  891. {
  892. kfree(c);
  893. };
  894. /**
  895. * i2o_iop_release - release the memory for a I2O controller
  896. * @dev: I2O controller which should be released
  897. *
  898. * Release the allocated memory. This function is called if refcount of
  899. * device reaches 0 automatically.
  900. */
  901. static void i2o_iop_release(struct device *dev)
  902. {
  903. struct i2o_controller *c = to_i2o_controller(dev);
  904. i2o_iop_free(c);
  905. };
  906. /* I2O controller class */
  907. static struct class i2o_controller_class = {
  908. .name = "i2o_controller",
  909. };
  910. /**
  911. * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
  912. *
  913. * Allocate the necessary memory for a i2o_controller struct and
  914. * initialize the lists.
  915. *
  916. * Returns a pointer to the I2O controller or a negative error code on
  917. * failure.
  918. */
  919. struct i2o_controller *i2o_iop_alloc(void)
  920. {
  921. static int unit = 0; /* 0 and 1 are NULL IOP and Local Host */
  922. struct i2o_controller *c;
  923. c = kmalloc(sizeof(*c), GFP_KERNEL);
  924. if (!c) {
  925. osm_err("i2o: Insufficient memory to allocate a I2O controller."
  926. "\n");
  927. return ERR_PTR(-ENOMEM);
  928. }
  929. memset(c, 0, sizeof(*c));
  930. INIT_LIST_HEAD(&c->devices);
  931. spin_lock_init(&c->lock);
  932. init_MUTEX(&c->lct_lock);
  933. c->unit = unit++;
  934. sprintf(c->name, "iop%d", c->unit);
  935. device_initialize(&c->device);
  936. class_device_initialize(&c->classdev);
  937. c->device.release = &i2o_iop_release;
  938. c->classdev.class = &i2o_controller_class;
  939. c->classdev.dev = &c->device;
  940. snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit);
  941. snprintf(c->classdev.class_id, BUS_ID_SIZE, "iop%d", c->unit);
  942. #if BITS_PER_LONG == 64
  943. spin_lock_init(&c->context_list_lock);
  944. atomic_set(&c->context_list_counter, 0);
  945. INIT_LIST_HEAD(&c->context_list);
  946. #endif
  947. return c;
  948. };
  949. /**
  950. * i2o_iop_add - Initialize the I2O controller and add him to the I2O core
  951. * @c: controller
  952. *
  953. * Initialize the I2O controller and if no error occurs add him to the I2O
  954. * core.
  955. *
  956. * Returns 0 on success or negative error code on failure.
  957. */
  958. int i2o_iop_add(struct i2o_controller *c)
  959. {
  960. int rc;
  961. if ((rc = device_add(&c->device))) {
  962. osm_err("%s: could not add controller\n", c->name);
  963. goto iop_reset;
  964. }
  965. if ((rc = class_device_add(&c->classdev))) {
  966. osm_err("%s: could not add controller class\n", c->name);
  967. goto device_del;
  968. }
  969. osm_info("%s: Activating I2O controller...\n", c->name);
  970. osm_info("%s: This may take a few minutes if there are many devices\n",
  971. c->name);
  972. if ((rc = i2o_iop_activate(c))) {
  973. osm_err("%s: could not activate controller\n", c->name);
  974. goto class_del;
  975. }
  976. osm_debug("%s: building sys table...\n", c->name);
  977. if ((rc = i2o_systab_build()))
  978. goto class_del;
  979. osm_debug("%s: online controller...\n", c->name);
  980. if ((rc = i2o_iop_online(c)))
  981. goto class_del;
  982. osm_debug("%s: getting LCT...\n", c->name);
  983. if ((rc = i2o_exec_lct_get(c)))
  984. goto class_del;
  985. list_add(&c->list, &i2o_controllers);
  986. i2o_driver_notify_controller_add_all(c);
  987. osm_info("%s: Controller added\n", c->name);
  988. return 0;
  989. class_del:
  990. class_device_del(&c->classdev);
  991. device_del:
  992. device_del(&c->device);
  993. iop_reset:
  994. i2o_iop_reset(c);
  995. return rc;
  996. };
  997. /**
  998. * i2o_event_register - Turn on/off event notification for a I2O device
  999. * @dev: I2O device which should receive the event registration request
  1000. * @drv: driver which want to get notified
  1001. * @tcntxt: transaction context to use with this notifier
  1002. * @evt_mask: mask of events
  1003. *
  1004. * Create and posts an event registration message to the task. No reply
  1005. * is waited for, or expected. If you do not want further notifications,
  1006. * call the i2o_event_register again with a evt_mask of 0.
  1007. *
  1008. * Returns 0 on success or -ETIMEDOUT if no message could be fetched for
  1009. * sending the request.
  1010. */
  1011. int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv,
  1012. int tcntxt, u32 evt_mask)
  1013. {
  1014. struct i2o_controller *c = dev->iop;
  1015. struct i2o_message __iomem *msg;
  1016. u32 m;
  1017. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  1018. if (m == I2O_QUEUE_EMPTY)
  1019. return -ETIMEDOUT;
  1020. writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  1021. writel(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev->lct_data.
  1022. tid, &msg->u.head[1]);
  1023. writel(drv->context, &msg->u.s.icntxt);
  1024. writel(tcntxt, &msg->u.s.tcntxt);
  1025. writel(evt_mask, &msg->body[0]);
  1026. i2o_msg_post(c, m);
  1027. return 0;
  1028. };
  1029. /**
  1030. * i2o_iop_init - I2O main initialization function
  1031. *
  1032. * Initialize the I2O drivers (OSM) functions, register the Executive OSM,
  1033. * initialize the I2O PCI part and finally initialize I2O device stuff.
  1034. *
  1035. * Returns 0 on success or negative error code on failure.
  1036. */
  1037. static int __init i2o_iop_init(void)
  1038. {
  1039. int rc = 0;
  1040. printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
  1041. rc = i2o_device_init();
  1042. if (rc)
  1043. goto exit;
  1044. if ((rc = class_register(&i2o_controller_class))) {
  1045. osm_err("can't register class i2o_controller\n");
  1046. goto device_exit;
  1047. }
  1048. if ((rc = i2o_driver_init()))
  1049. goto class_exit;
  1050. if ((rc = i2o_exec_init()))
  1051. goto driver_exit;
  1052. if ((rc = i2o_pci_init()))
  1053. goto exec_exit;
  1054. return 0;
  1055. exec_exit:
  1056. i2o_exec_exit();
  1057. driver_exit:
  1058. i2o_driver_exit();
  1059. class_exit:
  1060. class_unregister(&i2o_controller_class);
  1061. device_exit:
  1062. i2o_device_exit();
  1063. exit:
  1064. return rc;
  1065. }
  1066. /**
  1067. * i2o_iop_exit - I2O main exit function
  1068. *
  1069. * Removes I2O controllers from PCI subsystem and shut down OSMs.
  1070. */
  1071. static void __exit i2o_iop_exit(void)
  1072. {
  1073. i2o_pci_exit();
  1074. i2o_exec_exit();
  1075. i2o_driver_exit();
  1076. class_unregister(&i2o_controller_class);
  1077. i2o_device_exit();
  1078. };
  1079. module_init(i2o_iop_init);
  1080. module_exit(i2o_iop_exit);
  1081. MODULE_AUTHOR("Red Hat Software");
  1082. MODULE_LICENSE("GPL");
  1083. MODULE_DESCRIPTION(OSM_DESCRIPTION);
  1084. MODULE_VERSION(OSM_VERSION);
  1085. #if BITS_PER_LONG == 64
  1086. EXPORT_SYMBOL(i2o_cntxt_list_add);
  1087. EXPORT_SYMBOL(i2o_cntxt_list_get);
  1088. EXPORT_SYMBOL(i2o_cntxt_list_remove);
  1089. EXPORT_SYMBOL(i2o_cntxt_list_get_ptr);
  1090. #endif
  1091. EXPORT_SYMBOL(i2o_msg_get_wait);
  1092. EXPORT_SYMBOL(i2o_msg_nop);
  1093. EXPORT_SYMBOL(i2o_find_iop);
  1094. EXPORT_SYMBOL(i2o_iop_find_device);
  1095. EXPORT_SYMBOL(i2o_event_register);
  1096. EXPORT_SYMBOL(i2o_status_get);
  1097. EXPORT_SYMBOL(i2o_controllers);