iop.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  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. schedule_timeout_uninterruptible(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. schedule_timeout_uninterruptible(1);
  412. }
  413. m = c->out_queue.phys;
  414. /* Post frames */
  415. for (i = 0; i < I2O_MAX_OUTBOUND_MSG_FRAMES; i++) {
  416. i2o_flush_reply(c, m);
  417. udelay(1); /* Promise */
  418. m += I2O_OUTBOUND_MSG_FRAME_SIZE * sizeof(u32);
  419. }
  420. return 0;
  421. }
  422. /**
  423. * i2o_iop_reset - reset an I2O controller
  424. * @c: controller to reset
  425. *
  426. * Reset the IOP into INIT state and wait until IOP gets into RESET state.
  427. * Terminate all external operations, clear IOP's inbound and outbound
  428. * queues, terminate all DDMs, and reload the IOP's operating environment
  429. * and all local DDMs. The IOP rebuilds its LCT.
  430. */
  431. static int i2o_iop_reset(struct i2o_controller *c)
  432. {
  433. volatile u8 *status = c->status.virt;
  434. struct i2o_message __iomem *msg;
  435. u32 m;
  436. unsigned long timeout;
  437. i2o_status_block *sb = c->status_block.virt;
  438. int rc = 0;
  439. osm_debug("%s: Resetting controller\n", c->name);
  440. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  441. if (m == I2O_QUEUE_EMPTY)
  442. return -ETIMEDOUT;
  443. memset(c->status_block.virt, 0, 8);
  444. /* Quiesce all IOPs first */
  445. i2o_iop_quiesce_all();
  446. writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  447. writel(I2O_CMD_ADAPTER_RESET << 24 | HOST_TID << 12 | ADAPTER_TID,
  448. &msg->u.head[1]);
  449. writel(i2o_exec_driver.context, &msg->u.s.icntxt);
  450. writel(0, &msg->u.s.tcntxt); //FIXME: use reasonable transaction context
  451. writel(0, &msg->body[0]);
  452. writel(0, &msg->body[1]);
  453. writel(i2o_dma_low(c->status.phys), &msg->body[2]);
  454. writel(i2o_dma_high(c->status.phys), &msg->body[3]);
  455. i2o_msg_post(c, m);
  456. /* Wait for a reply */
  457. timeout = jiffies + I2O_TIMEOUT_RESET * HZ;
  458. while (!*status) {
  459. if (time_after(jiffies, timeout))
  460. break;
  461. schedule_timeout_uninterruptible(1);
  462. }
  463. switch (*status) {
  464. case I2O_CMD_REJECTED:
  465. osm_warn("%s: IOP reset rejected\n", c->name);
  466. rc = -EPERM;
  467. break;
  468. case I2O_CMD_IN_PROGRESS:
  469. /*
  470. * Once the reset is sent, the IOP goes into the INIT state
  471. * which is indeterminate. We need to wait until the IOP has
  472. * rebooted before we can let the system talk to it. We read
  473. * the inbound Free_List until a message is available. If we
  474. * can't read one in the given ammount of time, we assume the
  475. * IOP could not reboot properly.
  476. */
  477. osm_debug("%s: Reset in progress, waiting for reboot...\n",
  478. c->name);
  479. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET);
  480. while (m == I2O_QUEUE_EMPTY) {
  481. if (time_after(jiffies, timeout)) {
  482. osm_err("%s: IOP reset timeout.\n", c->name);
  483. rc = -ETIMEDOUT;
  484. goto exit;
  485. }
  486. schedule_timeout_uninterruptible(1);
  487. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET);
  488. }
  489. i2o_msg_nop(c, m);
  490. /* from here all quiesce commands are safe */
  491. c->no_quiesce = 0;
  492. /* verify if controller is in state RESET */
  493. i2o_status_get(c);
  494. if (!c->promise && (sb->iop_state != ADAPTER_STATE_RESET))
  495. osm_warn("%s: reset completed, but adapter not in RESET"
  496. " state.\n", c->name);
  497. else
  498. osm_debug("%s: reset completed.\n", c->name);
  499. break;
  500. default:
  501. osm_err("%s: IOP reset timeout.\n", c->name);
  502. rc = -ETIMEDOUT;
  503. break;
  504. }
  505. exit:
  506. /* Enable all IOPs */
  507. i2o_iop_enable_all();
  508. return rc;
  509. };
  510. /**
  511. * i2o_iop_activate - Bring controller up to HOLD
  512. * @c: controller
  513. *
  514. * This function brings an I2O controller into HOLD state. The adapter
  515. * is reset if necessary and then the queues and resource table are read.
  516. *
  517. * Returns 0 on success or negative error code on failure.
  518. */
  519. static int i2o_iop_activate(struct i2o_controller *c)
  520. {
  521. i2o_status_block *sb = c->status_block.virt;
  522. int rc;
  523. int state;
  524. /* In INIT state, Wait Inbound Q to initialize (in i2o_status_get) */
  525. /* In READY state, Get status */
  526. rc = i2o_status_get(c);
  527. if (rc) {
  528. osm_info("%s: Unable to obtain status, attempting a reset.\n",
  529. c->name);
  530. rc = i2o_iop_reset(c);
  531. if (rc)
  532. return rc;
  533. }
  534. if (sb->i2o_version > I2OVER15) {
  535. osm_err("%s: Not running version 1.5 of the I2O Specification."
  536. "\n", c->name);
  537. return -ENODEV;
  538. }
  539. switch (sb->iop_state) {
  540. case ADAPTER_STATE_FAULTED:
  541. osm_err("%s: hardware fault\n", c->name);
  542. return -EFAULT;
  543. case ADAPTER_STATE_READY:
  544. case ADAPTER_STATE_OPERATIONAL:
  545. case ADAPTER_STATE_HOLD:
  546. case ADAPTER_STATE_FAILED:
  547. osm_debug("%s: already running, trying to reset...\n", c->name);
  548. rc = i2o_iop_reset(c);
  549. if (rc)
  550. return rc;
  551. }
  552. /* preserve state */
  553. state = sb->iop_state;
  554. rc = i2o_iop_init_outbound_queue(c);
  555. if (rc)
  556. return rc;
  557. /* if adapter was not in RESET state clear now */
  558. if (state != ADAPTER_STATE_RESET)
  559. i2o_iop_clear(c);
  560. i2o_status_get(c);
  561. if (sb->iop_state != ADAPTER_STATE_HOLD) {
  562. osm_err("%s: failed to bring IOP into HOLD state\n", c->name);
  563. return -EIO;
  564. }
  565. return i2o_hrt_get(c);
  566. };
  567. /**
  568. * i2o_iop_systab_set - Set the I2O System Table of the specified IOP
  569. * @c: I2O controller to which the system table should be send
  570. *
  571. * Before the systab could be set i2o_systab_build() must be called.
  572. *
  573. * Returns 0 on success or negative error code on failure.
  574. */
  575. static int i2o_iop_systab_set(struct i2o_controller *c)
  576. {
  577. struct i2o_message __iomem *msg;
  578. u32 m;
  579. i2o_status_block *sb = c->status_block.virt;
  580. struct device *dev = &c->pdev->dev;
  581. struct resource *root;
  582. int rc;
  583. if (sb->current_mem_size < sb->desired_mem_size) {
  584. struct resource *res = &c->mem_resource;
  585. res->name = c->pdev->bus->name;
  586. res->flags = IORESOURCE_MEM;
  587. res->start = 0;
  588. res->end = 0;
  589. osm_info("%s: requires private memory resources.\n", c->name);
  590. root = pci_find_parent_resource(c->pdev, res);
  591. if (root == NULL)
  592. osm_warn("%s: Can't find parent resource!\n", c->name);
  593. 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 */
  594. NULL, NULL) >= 0) {
  595. c->mem_alloc = 1;
  596. sb->current_mem_size = 1 + res->end - res->start;
  597. sb->current_mem_base = res->start;
  598. osm_info("%s: allocated %ld bytes of PCI memory at "
  599. "0x%08lX.\n", c->name,
  600. 1 + res->end - res->start, res->start);
  601. }
  602. }
  603. if (sb->current_io_size < sb->desired_io_size) {
  604. struct resource *res = &c->io_resource;
  605. res->name = c->pdev->bus->name;
  606. res->flags = IORESOURCE_IO;
  607. res->start = 0;
  608. res->end = 0;
  609. osm_info("%s: requires private memory resources.\n", c->name);
  610. root = pci_find_parent_resource(c->pdev, res);
  611. if (root == NULL)
  612. osm_warn("%s: Can't find parent resource!\n", c->name);
  613. 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 */
  614. NULL, NULL) >= 0) {
  615. c->io_alloc = 1;
  616. sb->current_io_size = 1 + res->end - res->start;
  617. sb->current_mem_base = res->start;
  618. osm_info("%s: allocated %ld bytes of PCI I/O at 0x%08lX"
  619. ".\n", c->name, 1 + res->end - res->start,
  620. res->start);
  621. }
  622. }
  623. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  624. if (m == I2O_QUEUE_EMPTY)
  625. return -ETIMEDOUT;
  626. i2o_systab.phys = dma_map_single(dev, i2o_systab.virt, i2o_systab.len,
  627. PCI_DMA_TODEVICE);
  628. if (!i2o_systab.phys) {
  629. i2o_msg_nop(c, m);
  630. return -ENOMEM;
  631. }
  632. writel(I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6, &msg->u.head[0]);
  633. writel(I2O_CMD_SYS_TAB_SET << 24 | HOST_TID << 12 | ADAPTER_TID,
  634. &msg->u.head[1]);
  635. /*
  636. * Provide three SGL-elements:
  637. * System table (SysTab), Private memory space declaration and
  638. * Private i/o space declaration
  639. *
  640. * FIXME: is this still true?
  641. * Nasty one here. We can't use dma_alloc_coherent to send the
  642. * same table to everyone. We have to go remap it for them all
  643. */
  644. writel(c->unit + 2, &msg->body[0]);
  645. writel(0, &msg->body[1]);
  646. writel(0x54000000 | i2o_systab.len, &msg->body[2]);
  647. writel(i2o_systab.phys, &msg->body[3]);
  648. writel(0x54000000 | sb->current_mem_size, &msg->body[4]);
  649. writel(sb->current_mem_base, &msg->body[5]);
  650. writel(0xd4000000 | sb->current_io_size, &msg->body[6]);
  651. writel(sb->current_io_base, &msg->body[6]);
  652. rc = i2o_msg_post_wait(c, m, 120);
  653. dma_unmap_single(dev, i2o_systab.phys, i2o_systab.len,
  654. PCI_DMA_TODEVICE);
  655. if (rc < 0)
  656. osm_err("%s: Unable to set SysTab (status=%#x).\n", c->name,
  657. -rc);
  658. else
  659. osm_debug("%s: SysTab set.\n", c->name);
  660. i2o_status_get(c); // Entered READY state
  661. return rc;
  662. }
  663. /**
  664. * i2o_iop_online - Bring a controller online into OPERATIONAL state.
  665. * @c: I2O controller
  666. *
  667. * Send the system table and enable the I2O controller.
  668. *
  669. * Returns 0 on success or negativer error code on failure.
  670. */
  671. static int i2o_iop_online(struct i2o_controller *c)
  672. {
  673. int rc;
  674. rc = i2o_iop_systab_set(c);
  675. if (rc)
  676. return rc;
  677. /* In READY state */
  678. osm_debug("%s: Attempting to enable...\n", c->name);
  679. rc = i2o_iop_enable(c);
  680. if (rc)
  681. return rc;
  682. return 0;
  683. };
  684. /**
  685. * i2o_iop_remove - Remove the I2O controller from the I2O core
  686. * @c: I2O controller
  687. *
  688. * Remove the I2O controller from the I2O core. If devices are attached to
  689. * the controller remove these also and finally reset the controller.
  690. */
  691. void i2o_iop_remove(struct i2o_controller *c)
  692. {
  693. struct i2o_device *dev, *tmp;
  694. osm_debug("%s: deleting controller\n", c->name);
  695. i2o_driver_notify_controller_remove_all(c);
  696. list_del(&c->list);
  697. list_for_each_entry_safe(dev, tmp, &c->devices, list)
  698. i2o_device_remove(dev);
  699. class_device_unregister(c->classdev);
  700. device_del(&c->device);
  701. /* Ask the IOP to switch to RESET state */
  702. i2o_iop_reset(c);
  703. put_device(&c->device);
  704. }
  705. /**
  706. * i2o_systab_build - Build system table
  707. *
  708. * The system table contains information about all the IOPs in the system
  709. * (duh) and is used by the Executives on the IOPs to establish peer2peer
  710. * connections. We're not supporting peer2peer at the moment, but this
  711. * will be needed down the road for things like lan2lan forwarding.
  712. *
  713. * Returns 0 on success or negative error code on failure.
  714. */
  715. static int i2o_systab_build(void)
  716. {
  717. struct i2o_controller *c, *tmp;
  718. int num_controllers = 0;
  719. u32 change_ind = 0;
  720. int count = 0;
  721. struct i2o_sys_tbl *systab = i2o_systab.virt;
  722. list_for_each_entry_safe(c, tmp, &i2o_controllers, list)
  723. num_controllers++;
  724. if (systab) {
  725. change_ind = systab->change_ind;
  726. kfree(i2o_systab.virt);
  727. }
  728. /* Header + IOPs */
  729. i2o_systab.len = sizeof(struct i2o_sys_tbl) + num_controllers *
  730. sizeof(struct i2o_sys_tbl_entry);
  731. systab = i2o_systab.virt = kmalloc(i2o_systab.len, GFP_KERNEL);
  732. if (!systab) {
  733. osm_err("unable to allocate memory for System Table\n");
  734. return -ENOMEM;
  735. }
  736. memset(systab, 0, i2o_systab.len);
  737. systab->version = I2OVERSION;
  738. systab->change_ind = change_ind + 1;
  739. list_for_each_entry_safe(c, tmp, &i2o_controllers, list) {
  740. i2o_status_block *sb;
  741. if (count >= num_controllers) {
  742. osm_err("controller added while building system table"
  743. "\n");
  744. break;
  745. }
  746. sb = c->status_block.virt;
  747. /*
  748. * Get updated IOP state so we have the latest information
  749. *
  750. * We should delete the controller at this point if it
  751. * doesn't respond since if it's not on the system table
  752. * it is techninically not part of the I2O subsystem...
  753. */
  754. if (unlikely(i2o_status_get(c))) {
  755. osm_err("%s: Deleting b/c could not get status while "
  756. "attempting to build system table\n", c->name);
  757. i2o_iop_remove(c);
  758. continue; // try the next one
  759. }
  760. systab->iops[count].org_id = sb->org_id;
  761. systab->iops[count].iop_id = c->unit + 2;
  762. systab->iops[count].seg_num = 0;
  763. systab->iops[count].i2o_version = sb->i2o_version;
  764. systab->iops[count].iop_state = sb->iop_state;
  765. systab->iops[count].msg_type = sb->msg_type;
  766. systab->iops[count].frame_size = sb->inbound_frame_size;
  767. systab->iops[count].last_changed = change_ind;
  768. systab->iops[count].iop_capabilities = sb->iop_capabilities;
  769. systab->iops[count].inbound_low =
  770. i2o_dma_low(c->base.phys + I2O_IN_PORT);
  771. systab->iops[count].inbound_high =
  772. i2o_dma_high(c->base.phys + I2O_IN_PORT);
  773. count++;
  774. }
  775. systab->num_entries = count;
  776. return 0;
  777. };
  778. /**
  779. * i2o_parse_hrt - Parse the hardware resource table.
  780. * @c: I2O controller
  781. *
  782. * We don't do anything with it except dumping it (in debug mode).
  783. *
  784. * Returns 0.
  785. */
  786. static int i2o_parse_hrt(struct i2o_controller *c)
  787. {
  788. i2o_dump_hrt(c);
  789. return 0;
  790. };
  791. /**
  792. * i2o_status_get - Get the status block from the I2O controller
  793. * @c: I2O controller
  794. *
  795. * Issue a status query on the controller. This updates the attached
  796. * status block. The status block could then be accessed through
  797. * c->status_block.
  798. *
  799. * Returns 0 on sucess or negative error code on failure.
  800. */
  801. int i2o_status_get(struct i2o_controller *c)
  802. {
  803. struct i2o_message __iomem *msg;
  804. u32 m;
  805. volatile u8 *status_block;
  806. unsigned long timeout;
  807. status_block = (u8 *) c->status_block.virt;
  808. memset(c->status_block.virt, 0, sizeof(i2o_status_block));
  809. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  810. if (m == I2O_QUEUE_EMPTY)
  811. return -ETIMEDOUT;
  812. writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  813. writel(I2O_CMD_STATUS_GET << 24 | HOST_TID << 12 | ADAPTER_TID,
  814. &msg->u.head[1]);
  815. writel(i2o_exec_driver.context, &msg->u.s.icntxt);
  816. writel(0, &msg->u.s.tcntxt); // FIXME: use resonable transaction context
  817. writel(0, &msg->body[0]);
  818. writel(0, &msg->body[1]);
  819. writel(i2o_dma_low(c->status_block.phys), &msg->body[2]);
  820. writel(i2o_dma_high(c->status_block.phys), &msg->body[3]);
  821. writel(sizeof(i2o_status_block), &msg->body[4]); /* always 88 bytes */
  822. i2o_msg_post(c, m);
  823. /* Wait for a reply */
  824. timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ;
  825. while (status_block[87] != 0xFF) {
  826. if (time_after(jiffies, timeout)) {
  827. osm_err("%s: Get status timeout.\n", c->name);
  828. return -ETIMEDOUT;
  829. }
  830. schedule_timeout_uninterruptible(1);
  831. }
  832. #ifdef DEBUG
  833. i2o_debug_state(c);
  834. #endif
  835. return 0;
  836. }
  837. /*
  838. * i2o_hrt_get - Get the Hardware Resource Table from the I2O controller
  839. * @c: I2O controller from which the HRT should be fetched
  840. *
  841. * The HRT contains information about possible hidden devices but is
  842. * mostly useless to us.
  843. *
  844. * Returns 0 on success or negativer error code on failure.
  845. */
  846. static int i2o_hrt_get(struct i2o_controller *c)
  847. {
  848. int rc;
  849. int i;
  850. i2o_hrt *hrt = c->hrt.virt;
  851. u32 size = sizeof(i2o_hrt);
  852. struct device *dev = &c->pdev->dev;
  853. for (i = 0; i < I2O_HRT_GET_TRIES; i++) {
  854. struct i2o_message __iomem *msg;
  855. u32 m;
  856. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  857. if (m == I2O_QUEUE_EMPTY)
  858. return -ETIMEDOUT;
  859. writel(SIX_WORD_MSG_SIZE | SGL_OFFSET_4, &msg->u.head[0]);
  860. writel(I2O_CMD_HRT_GET << 24 | HOST_TID << 12 | ADAPTER_TID,
  861. &msg->u.head[1]);
  862. writel(0xd0000000 | c->hrt.len, &msg->body[0]);
  863. writel(c->hrt.phys, &msg->body[1]);
  864. rc = i2o_msg_post_wait_mem(c, m, 20, &c->hrt);
  865. if (rc < 0) {
  866. osm_err("%s: Unable to get HRT (status=%#x)\n", c->name,
  867. -rc);
  868. return rc;
  869. }
  870. size = hrt->num_entries * hrt->entry_len << 2;
  871. if (size > c->hrt.len) {
  872. if (i2o_dma_realloc(dev, &c->hrt, size, GFP_KERNEL))
  873. return -ENOMEM;
  874. else
  875. hrt = c->hrt.virt;
  876. } else
  877. return i2o_parse_hrt(c);
  878. }
  879. osm_err("%s: Unable to get HRT after %d tries, giving up\n", c->name,
  880. I2O_HRT_GET_TRIES);
  881. return -EBUSY;
  882. }
  883. /**
  884. * i2o_iop_free - Free the i2o_controller struct
  885. * @c: I2O controller to free
  886. */
  887. void i2o_iop_free(struct i2o_controller *c)
  888. {
  889. kfree(c);
  890. };
  891. /**
  892. * i2o_iop_release - release the memory for a I2O controller
  893. * @dev: I2O controller which should be released
  894. *
  895. * Release the allocated memory. This function is called if refcount of
  896. * device reaches 0 automatically.
  897. */
  898. static void i2o_iop_release(struct device *dev)
  899. {
  900. struct i2o_controller *c = to_i2o_controller(dev);
  901. i2o_iop_free(c);
  902. };
  903. /* I2O controller class */
  904. static struct class *i2o_controller_class;
  905. /**
  906. * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
  907. *
  908. * Allocate the necessary memory for a i2o_controller struct and
  909. * initialize the lists.
  910. *
  911. * Returns a pointer to the I2O controller or a negative error code on
  912. * failure.
  913. */
  914. struct i2o_controller *i2o_iop_alloc(void)
  915. {
  916. static int unit = 0; /* 0 and 1 are NULL IOP and Local Host */
  917. struct i2o_controller *c;
  918. c = kmalloc(sizeof(*c), GFP_KERNEL);
  919. if (!c) {
  920. osm_err("i2o: Insufficient memory to allocate a I2O controller."
  921. "\n");
  922. return ERR_PTR(-ENOMEM);
  923. }
  924. memset(c, 0, sizeof(*c));
  925. INIT_LIST_HEAD(&c->devices);
  926. spin_lock_init(&c->lock);
  927. init_MUTEX(&c->lct_lock);
  928. c->unit = unit++;
  929. sprintf(c->name, "iop%d", c->unit);
  930. device_initialize(&c->device);
  931. c->device.release = &i2o_iop_release;
  932. snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit);
  933. #if BITS_PER_LONG == 64
  934. spin_lock_init(&c->context_list_lock);
  935. atomic_set(&c->context_list_counter, 0);
  936. INIT_LIST_HEAD(&c->context_list);
  937. #endif
  938. return c;
  939. };
  940. /**
  941. * i2o_iop_add - Initialize the I2O controller and add him to the I2O core
  942. * @c: controller
  943. *
  944. * Initialize the I2O controller and if no error occurs add him to the I2O
  945. * core.
  946. *
  947. * Returns 0 on success or negative error code on failure.
  948. */
  949. int i2o_iop_add(struct i2o_controller *c)
  950. {
  951. int rc;
  952. if ((rc = device_add(&c->device))) {
  953. osm_err("%s: could not add controller\n", c->name);
  954. goto iop_reset;
  955. }
  956. c->classdev = class_device_create(i2o_controller_class, NULL, MKDEV(0,0),
  957. &c->device, "iop%d", c->unit);
  958. if (IS_ERR(c->classdev)) {
  959. osm_err("%s: could not add controller class\n", c->name);
  960. goto device_del;
  961. }
  962. osm_info("%s: Activating I2O controller...\n", c->name);
  963. osm_info("%s: This may take a few minutes if there are many devices\n",
  964. c->name);
  965. if ((rc = i2o_iop_activate(c))) {
  966. osm_err("%s: could not activate controller\n", c->name);
  967. goto class_del;
  968. }
  969. osm_debug("%s: building sys table...\n", c->name);
  970. if ((rc = i2o_systab_build()))
  971. goto class_del;
  972. osm_debug("%s: online controller...\n", c->name);
  973. if ((rc = i2o_iop_online(c)))
  974. goto class_del;
  975. osm_debug("%s: getting LCT...\n", c->name);
  976. if ((rc = i2o_exec_lct_get(c)))
  977. goto class_del;
  978. list_add(&c->list, &i2o_controllers);
  979. i2o_driver_notify_controller_add_all(c);
  980. osm_info("%s: Controller added\n", c->name);
  981. return 0;
  982. class_del:
  983. class_device_unregister(c->classdev);
  984. device_del:
  985. device_del(&c->device);
  986. iop_reset:
  987. i2o_iop_reset(c);
  988. return rc;
  989. };
  990. /**
  991. * i2o_event_register - Turn on/off event notification for a I2O device
  992. * @dev: I2O device which should receive the event registration request
  993. * @drv: driver which want to get notified
  994. * @tcntxt: transaction context to use with this notifier
  995. * @evt_mask: mask of events
  996. *
  997. * Create and posts an event registration message to the task. No reply
  998. * is waited for, or expected. If you do not want further notifications,
  999. * call the i2o_event_register again with a evt_mask of 0.
  1000. *
  1001. * Returns 0 on success or -ETIMEDOUT if no message could be fetched for
  1002. * sending the request.
  1003. */
  1004. int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv,
  1005. int tcntxt, u32 evt_mask)
  1006. {
  1007. struct i2o_controller *c = dev->iop;
  1008. struct i2o_message __iomem *msg;
  1009. u32 m;
  1010. m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET);
  1011. if (m == I2O_QUEUE_EMPTY)
  1012. return -ETIMEDOUT;
  1013. writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
  1014. writel(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev->lct_data.
  1015. tid, &msg->u.head[1]);
  1016. writel(drv->context, &msg->u.s.icntxt);
  1017. writel(tcntxt, &msg->u.s.tcntxt);
  1018. writel(evt_mask, &msg->body[0]);
  1019. i2o_msg_post(c, m);
  1020. return 0;
  1021. };
  1022. /**
  1023. * i2o_iop_init - I2O main initialization function
  1024. *
  1025. * Initialize the I2O drivers (OSM) functions, register the Executive OSM,
  1026. * initialize the I2O PCI part and finally initialize I2O device stuff.
  1027. *
  1028. * Returns 0 on success or negative error code on failure.
  1029. */
  1030. static int __init i2o_iop_init(void)
  1031. {
  1032. int rc = 0;
  1033. printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
  1034. i2o_controller_class = class_create(THIS_MODULE, "i2o_controller");
  1035. if (IS_ERR(i2o_controller_class)) {
  1036. osm_err("can't register class i2o_controller\n");
  1037. goto exit;
  1038. }
  1039. if ((rc = i2o_driver_init()))
  1040. goto class_exit;
  1041. if ((rc = i2o_exec_init()))
  1042. goto driver_exit;
  1043. if ((rc = i2o_pci_init()))
  1044. goto exec_exit;
  1045. return 0;
  1046. exec_exit:
  1047. i2o_exec_exit();
  1048. driver_exit:
  1049. i2o_driver_exit();
  1050. class_exit:
  1051. class_destroy(i2o_controller_class);
  1052. exit:
  1053. return rc;
  1054. }
  1055. /**
  1056. * i2o_iop_exit - I2O main exit function
  1057. *
  1058. * Removes I2O controllers from PCI subsystem and shut down OSMs.
  1059. */
  1060. static void __exit i2o_iop_exit(void)
  1061. {
  1062. i2o_pci_exit();
  1063. i2o_exec_exit();
  1064. i2o_driver_exit();
  1065. class_destroy(i2o_controller_class);
  1066. };
  1067. module_init(i2o_iop_init);
  1068. module_exit(i2o_iop_exit);
  1069. MODULE_AUTHOR("Red Hat Software");
  1070. MODULE_LICENSE("GPL");
  1071. MODULE_DESCRIPTION(OSM_DESCRIPTION);
  1072. MODULE_VERSION(OSM_VERSION);
  1073. #if BITS_PER_LONG == 64
  1074. EXPORT_SYMBOL(i2o_cntxt_list_add);
  1075. EXPORT_SYMBOL(i2o_cntxt_list_get);
  1076. EXPORT_SYMBOL(i2o_cntxt_list_remove);
  1077. EXPORT_SYMBOL(i2o_cntxt_list_get_ptr);
  1078. #endif
  1079. EXPORT_SYMBOL(i2o_msg_get_wait);
  1080. EXPORT_SYMBOL(i2o_msg_nop);
  1081. EXPORT_SYMBOL(i2o_find_iop);
  1082. EXPORT_SYMBOL(i2o_iop_find_device);
  1083. EXPORT_SYMBOL(i2o_event_register);
  1084. EXPORT_SYMBOL(i2o_status_get);
  1085. EXPORT_SYMBOL(i2o_controllers);