iop.c 34 KB

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