highlevel.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*
  2. * IEEE 1394 for Linux
  3. *
  4. * Copyright (C) 1999 Andreas E. Bombe
  5. *
  6. * This code is licensed under the GPL. See the file COPYING in the root
  7. * directory of the kernel sources for details.
  8. *
  9. *
  10. * Contributions:
  11. *
  12. * Christian Toegel <christian.toegel@gmx.at>
  13. * unregister address space
  14. *
  15. * Manfred Weihs <weihs@ict.tuwien.ac.at>
  16. * unregister address space
  17. *
  18. */
  19. #include <linux/slab.h>
  20. #include <linux/list.h>
  21. #include <linux/bitops.h>
  22. #include "ieee1394.h"
  23. #include "ieee1394_types.h"
  24. #include "hosts.h"
  25. #include "ieee1394_core.h"
  26. #include "highlevel.h"
  27. #include "nodemgr.h"
  28. struct hl_host_info {
  29. struct list_head list;
  30. struct hpsb_host *host;
  31. size_t size;
  32. unsigned long key;
  33. void *data;
  34. };
  35. static LIST_HEAD(hl_drivers);
  36. static DECLARE_RWSEM(hl_drivers_sem);
  37. static LIST_HEAD(hl_irqs);
  38. static DEFINE_RWLOCK(hl_irqs_lock);
  39. static DEFINE_RWLOCK(addr_space_lock);
  40. /* addr_space list will have zero and max already included as bounds */
  41. static struct hpsb_address_ops dummy_ops = { NULL, NULL, NULL, NULL };
  42. static struct hpsb_address_serve dummy_zero_addr, dummy_max_addr;
  43. static struct hl_host_info *hl_get_hostinfo(struct hpsb_highlevel *hl,
  44. struct hpsb_host *host)
  45. {
  46. struct hl_host_info *hi = NULL;
  47. if (!hl || !host)
  48. return NULL;
  49. read_lock(&hl->host_info_lock);
  50. list_for_each_entry(hi, &hl->host_info_list, list) {
  51. if (hi->host == host) {
  52. read_unlock(&hl->host_info_lock);
  53. return hi;
  54. }
  55. }
  56. read_unlock(&hl->host_info_lock);
  57. return NULL;
  58. }
  59. /**
  60. * hpsb_get_hostinfo - retrieve a hostinfo pointer bound to this driver/host
  61. *
  62. * Returns a per @host and @hl driver data structure that was previously stored
  63. * by hpsb_create_hostinfo.
  64. */
  65. void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
  66. {
  67. struct hl_host_info *hi = hl_get_hostinfo(hl, host);
  68. return hi ? hi->data : NULL;
  69. }
  70. /**
  71. * hpsb_create_hostinfo - allocate a hostinfo pointer bound to this driver/host
  72. *
  73. * Allocate a hostinfo pointer backed by memory with @data_size and bind it to
  74. * to this @hl driver and @host. If @data_size is zero, then the return here is
  75. * only valid for error checking.
  76. */
  77. void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
  78. size_t data_size)
  79. {
  80. struct hl_host_info *hi;
  81. void *data;
  82. unsigned long flags;
  83. hi = hl_get_hostinfo(hl, host);
  84. if (hi) {
  85. HPSB_ERR("%s called hpsb_create_hostinfo when hostinfo already"
  86. " exists", hl->name);
  87. return NULL;
  88. }
  89. hi = kzalloc(sizeof(*hi) + data_size, GFP_ATOMIC);
  90. if (!hi)
  91. return NULL;
  92. if (data_size) {
  93. data = hi->data = hi + 1;
  94. hi->size = data_size;
  95. } else
  96. data = hi;
  97. hi->host = host;
  98. write_lock_irqsave(&hl->host_info_lock, flags);
  99. list_add_tail(&hi->list, &hl->host_info_list);
  100. write_unlock_irqrestore(&hl->host_info_lock, flags);
  101. return data;
  102. }
  103. /**
  104. * hpsb_set_hostinfo - set the hostinfo pointer to something useful
  105. *
  106. * Usually follows a call to hpsb_create_hostinfo, where the size is 0.
  107. */
  108. int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
  109. void *data)
  110. {
  111. struct hl_host_info *hi;
  112. hi = hl_get_hostinfo(hl, host);
  113. if (hi) {
  114. if (!hi->size && !hi->data) {
  115. hi->data = data;
  116. return 0;
  117. } else
  118. HPSB_ERR("%s called hpsb_set_hostinfo when hostinfo "
  119. "already has data", hl->name);
  120. } else
  121. HPSB_ERR("%s called hpsb_set_hostinfo when no hostinfo exists",
  122. hl->name);
  123. return -EINVAL;
  124. }
  125. /**
  126. * hpsb_destroy_hostinfo - free and remove a hostinfo pointer
  127. *
  128. * Free and remove the hostinfo pointer bound to this @hl driver and @host.
  129. */
  130. void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
  131. {
  132. struct hl_host_info *hi;
  133. hi = hl_get_hostinfo(hl, host);
  134. if (hi) {
  135. unsigned long flags;
  136. write_lock_irqsave(&hl->host_info_lock, flags);
  137. list_del(&hi->list);
  138. write_unlock_irqrestore(&hl->host_info_lock, flags);
  139. kfree(hi);
  140. }
  141. return;
  142. }
  143. /**
  144. * hpsb_set_hostinfo_key - set an alternate lookup key for an hostinfo
  145. *
  146. * Sets an alternate lookup key for the hostinfo bound to this @hl driver and
  147. * @host.
  148. */
  149. void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host,
  150. unsigned long key)
  151. {
  152. struct hl_host_info *hi;
  153. hi = hl_get_hostinfo(hl, host);
  154. if (hi)
  155. hi->key = key;
  156. return;
  157. }
  158. /**
  159. * hpsb_get_hostinfo_bykey - retrieve a hostinfo pointer by its alternate key
  160. */
  161. void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key)
  162. {
  163. struct hl_host_info *hi;
  164. void *data = NULL;
  165. if (!hl)
  166. return NULL;
  167. read_lock(&hl->host_info_lock);
  168. list_for_each_entry(hi, &hl->host_info_list, list) {
  169. if (hi->key == key) {
  170. data = hi->data;
  171. break;
  172. }
  173. }
  174. read_unlock(&hl->host_info_lock);
  175. return data;
  176. }
  177. static int highlevel_for_each_host_reg(struct hpsb_host *host, void *__data)
  178. {
  179. struct hpsb_highlevel *hl = __data;
  180. hl->add_host(host);
  181. if (host->update_config_rom && hpsb_update_config_rom_image(host) < 0)
  182. HPSB_ERR("Failed to generate Configuration ROM image for host "
  183. "%s-%d", hl->name, host->id);
  184. return 0;
  185. }
  186. /**
  187. * hpsb_register_highlevel - register highlevel driver
  188. *
  189. * The name pointer in @hl has to stay valid at all times because the string is
  190. * not copied.
  191. */
  192. void hpsb_register_highlevel(struct hpsb_highlevel *hl)
  193. {
  194. unsigned long flags;
  195. hpsb_init_highlevel(hl);
  196. INIT_LIST_HEAD(&hl->addr_list);
  197. down_write(&hl_drivers_sem);
  198. list_add_tail(&hl->hl_list, &hl_drivers);
  199. up_write(&hl_drivers_sem);
  200. write_lock_irqsave(&hl_irqs_lock, flags);
  201. list_add_tail(&hl->irq_list, &hl_irqs);
  202. write_unlock_irqrestore(&hl_irqs_lock, flags);
  203. if (hl->add_host)
  204. nodemgr_for_each_host(hl, highlevel_for_each_host_reg);
  205. return;
  206. }
  207. static void __delete_addr(struct hpsb_address_serve *as)
  208. {
  209. list_del(&as->host_list);
  210. list_del(&as->hl_list);
  211. kfree(as);
  212. }
  213. static void __unregister_host(struct hpsb_highlevel *hl, struct hpsb_host *host,
  214. int update_cr)
  215. {
  216. unsigned long flags;
  217. struct list_head *lh, *next;
  218. struct hpsb_address_serve *as;
  219. /* First, let the highlevel driver unreg */
  220. if (hl->remove_host)
  221. hl->remove_host(host);
  222. /* Remove any addresses that are matched for this highlevel driver
  223. * and this particular host. */
  224. write_lock_irqsave(&addr_space_lock, flags);
  225. list_for_each_safe (lh, next, &hl->addr_list) {
  226. as = list_entry(lh, struct hpsb_address_serve, hl_list);
  227. if (as->host == host)
  228. __delete_addr(as);
  229. }
  230. write_unlock_irqrestore(&addr_space_lock, flags);
  231. /* Now update the config-rom to reflect anything removed by the
  232. * highlevel driver. */
  233. if (update_cr && host->update_config_rom &&
  234. hpsb_update_config_rom_image(host) < 0)
  235. HPSB_ERR("Failed to generate Configuration ROM image for host "
  236. "%s-%d", hl->name, host->id);
  237. /* Finally remove all the host info associated between these two. */
  238. hpsb_destroy_hostinfo(hl, host);
  239. }
  240. static int highlevel_for_each_host_unreg(struct hpsb_host *host, void *__data)
  241. {
  242. struct hpsb_highlevel *hl = __data;
  243. __unregister_host(hl, host, 1);
  244. return 0;
  245. }
  246. /**
  247. * hpsb_unregister_highlevel - unregister highlevel driver
  248. */
  249. void hpsb_unregister_highlevel(struct hpsb_highlevel *hl)
  250. {
  251. unsigned long flags;
  252. write_lock_irqsave(&hl_irqs_lock, flags);
  253. list_del(&hl->irq_list);
  254. write_unlock_irqrestore(&hl_irqs_lock, flags);
  255. down_write(&hl_drivers_sem);
  256. list_del(&hl->hl_list);
  257. up_write(&hl_drivers_sem);
  258. nodemgr_for_each_host(hl, highlevel_for_each_host_unreg);
  259. }
  260. /**
  261. * hpsb_allocate_and_register_addrspace - alloc' and reg' a host address space
  262. *
  263. * @start and @end are 48 bit pointers and have to be quadlet aligned.
  264. * @end points to the first address behind the handled addresses. This
  265. * function can be called multiple times for a single hpsb_highlevel @hl to
  266. * implement sparse register sets. The requested region must not overlap any
  267. * previously allocated region, otherwise registering will fail.
  268. *
  269. * It returns true for successful allocation. Address spaces can be
  270. * unregistered with hpsb_unregister_addrspace. All remaining address spaces
  271. * are automatically deallocated together with the hpsb_highlevel @hl.
  272. */
  273. u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
  274. struct hpsb_host *host,
  275. struct hpsb_address_ops *ops,
  276. u64 size, u64 alignment,
  277. u64 start, u64 end)
  278. {
  279. struct hpsb_address_serve *as, *a1, *a2;
  280. struct list_head *entry;
  281. u64 retval = CSR1212_INVALID_ADDR_SPACE;
  282. unsigned long flags;
  283. u64 align_mask = ~(alignment - 1);
  284. if ((alignment & 3) || (alignment > 0x800000000000ULL) ||
  285. (hweight64(alignment) != 1)) {
  286. HPSB_ERR("%s called with invalid alignment: 0x%048llx",
  287. __func__, (unsigned long long)alignment);
  288. return retval;
  289. }
  290. /* default range,
  291. * avoids controller's posted write area (see OHCI 1.1 clause 1.5) */
  292. if (start == CSR1212_INVALID_ADDR_SPACE &&
  293. end == CSR1212_INVALID_ADDR_SPACE) {
  294. start = host->middle_addr_space;
  295. end = CSR1212_ALL_SPACE_END;
  296. }
  297. if (((start|end) & ~align_mask) || (start >= end) ||
  298. (end > CSR1212_ALL_SPACE_END)) {
  299. HPSB_ERR("%s called with invalid addresses "
  300. "(start = %012Lx end = %012Lx)", __func__,
  301. (unsigned long long)start,(unsigned long long)end);
  302. return retval;
  303. }
  304. as = kmalloc(sizeof(*as), GFP_KERNEL);
  305. if (!as)
  306. return retval;
  307. INIT_LIST_HEAD(&as->host_list);
  308. INIT_LIST_HEAD(&as->hl_list);
  309. as->op = ops;
  310. as->host = host;
  311. write_lock_irqsave(&addr_space_lock, flags);
  312. list_for_each(entry, &host->addr_space) {
  313. u64 a1sa, a1ea;
  314. u64 a2sa, a2ea;
  315. a1 = list_entry(entry, struct hpsb_address_serve, host_list);
  316. a2 = list_entry(entry->next, struct hpsb_address_serve,
  317. host_list);
  318. a1sa = a1->start & align_mask;
  319. a1ea = (a1->end + alignment -1) & align_mask;
  320. a2sa = a2->start & align_mask;
  321. a2ea = (a2->end + alignment -1) & align_mask;
  322. if ((a2sa - a1ea >= size) && (a2sa - start >= size) &&
  323. (a2sa > start)) {
  324. as->start = max(start, a1ea);
  325. as->end = as->start + size;
  326. list_add(&as->host_list, entry);
  327. list_add_tail(&as->hl_list, &hl->addr_list);
  328. retval = as->start;
  329. break;
  330. }
  331. }
  332. write_unlock_irqrestore(&addr_space_lock, flags);
  333. if (retval == CSR1212_INVALID_ADDR_SPACE)
  334. kfree(as);
  335. return retval;
  336. }
  337. /**
  338. * hpsb_register_addrspace - register a host address space
  339. *
  340. * @start and @end are 48 bit pointers and have to be quadlet aligned.
  341. * @end points to the first address behind the handled addresses. This
  342. * function can be called multiple times for a single hpsb_highlevel @hl to
  343. * implement sparse register sets. The requested region must not overlap any
  344. * previously allocated region, otherwise registering will fail.
  345. *
  346. * It returns true for successful allocation. Address spaces can be
  347. * unregistered with hpsb_unregister_addrspace. All remaining address spaces
  348. * are automatically deallocated together with the hpsb_highlevel @hl.
  349. */
  350. int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
  351. struct hpsb_address_ops *ops, u64 start, u64 end)
  352. {
  353. struct hpsb_address_serve *as;
  354. struct list_head *lh;
  355. int retval = 0;
  356. unsigned long flags;
  357. if (((start|end) & 3) || (start >= end) ||
  358. (end > CSR1212_ALL_SPACE_END)) {
  359. HPSB_ERR("%s called with invalid addresses", __func__);
  360. return 0;
  361. }
  362. as = kmalloc(sizeof(*as), GFP_ATOMIC);
  363. if (!as)
  364. return 0;
  365. INIT_LIST_HEAD(&as->host_list);
  366. INIT_LIST_HEAD(&as->hl_list);
  367. as->op = ops;
  368. as->start = start;
  369. as->end = end;
  370. as->host = host;
  371. write_lock_irqsave(&addr_space_lock, flags);
  372. list_for_each(lh, &host->addr_space) {
  373. struct hpsb_address_serve *as_this =
  374. list_entry(lh, struct hpsb_address_serve, host_list);
  375. struct hpsb_address_serve *as_next =
  376. list_entry(lh->next, struct hpsb_address_serve,
  377. host_list);
  378. if (as_this->end > as->start)
  379. break;
  380. if (as_next->start >= as->end) {
  381. list_add(&as->host_list, lh);
  382. list_add_tail(&as->hl_list, &hl->addr_list);
  383. retval = 1;
  384. break;
  385. }
  386. }
  387. write_unlock_irqrestore(&addr_space_lock, flags);
  388. if (retval == 0)
  389. kfree(as);
  390. return retval;
  391. }
  392. int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
  393. u64 start)
  394. {
  395. int retval = 0;
  396. struct hpsb_address_serve *as;
  397. struct list_head *lh, *next;
  398. unsigned long flags;
  399. write_lock_irqsave(&addr_space_lock, flags);
  400. list_for_each_safe (lh, next, &hl->addr_list) {
  401. as = list_entry(lh, struct hpsb_address_serve, hl_list);
  402. if (as->start == start && as->host == host) {
  403. __delete_addr(as);
  404. retval = 1;
  405. break;
  406. }
  407. }
  408. write_unlock_irqrestore(&addr_space_lock, flags);
  409. return retval;
  410. }
  411. static void init_hpsb_highlevel(struct hpsb_host *host)
  412. {
  413. INIT_LIST_HEAD(&dummy_zero_addr.host_list);
  414. INIT_LIST_HEAD(&dummy_zero_addr.hl_list);
  415. INIT_LIST_HEAD(&dummy_max_addr.host_list);
  416. INIT_LIST_HEAD(&dummy_max_addr.hl_list);
  417. dummy_zero_addr.op = dummy_max_addr.op = &dummy_ops;
  418. dummy_zero_addr.start = dummy_zero_addr.end = 0;
  419. dummy_max_addr.start = dummy_max_addr.end = ((u64) 1) << 48;
  420. list_add_tail(&dummy_zero_addr.host_list, &host->addr_space);
  421. list_add_tail(&dummy_max_addr.host_list, &host->addr_space);
  422. }
  423. void highlevel_add_host(struct hpsb_host *host)
  424. {
  425. struct hpsb_highlevel *hl;
  426. init_hpsb_highlevel(host);
  427. down_read(&hl_drivers_sem);
  428. list_for_each_entry(hl, &hl_drivers, hl_list) {
  429. if (hl->add_host)
  430. hl->add_host(host);
  431. }
  432. up_read(&hl_drivers_sem);
  433. if (host->update_config_rom && hpsb_update_config_rom_image(host) < 0)
  434. HPSB_ERR("Failed to generate Configuration ROM image for host "
  435. "%s-%d", hl->name, host->id);
  436. }
  437. void highlevel_remove_host(struct hpsb_host *host)
  438. {
  439. struct hpsb_highlevel *hl;
  440. down_read(&hl_drivers_sem);
  441. list_for_each_entry(hl, &hl_drivers, hl_list)
  442. __unregister_host(hl, host, 0);
  443. up_read(&hl_drivers_sem);
  444. }
  445. void highlevel_host_reset(struct hpsb_host *host)
  446. {
  447. unsigned long flags;
  448. struct hpsb_highlevel *hl;
  449. read_lock_irqsave(&hl_irqs_lock, flags);
  450. list_for_each_entry(hl, &hl_irqs, irq_list) {
  451. if (hl->host_reset)
  452. hl->host_reset(host);
  453. }
  454. read_unlock_irqrestore(&hl_irqs_lock, flags);
  455. }
  456. void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
  457. void *data, size_t length)
  458. {
  459. unsigned long flags;
  460. struct hpsb_highlevel *hl;
  461. int cts = ((quadlet_t *)data)[0] >> 4;
  462. read_lock_irqsave(&hl_irqs_lock, flags);
  463. list_for_each_entry(hl, &hl_irqs, irq_list) {
  464. if (hl->fcp_request)
  465. hl->fcp_request(host, nodeid, direction, cts, data,
  466. length);
  467. }
  468. read_unlock_irqrestore(&hl_irqs_lock, flags);
  469. }
  470. /*
  471. * highlevel_read, highlevel_write, highlevel_lock, highlevel_lock64:
  472. *
  473. * These functions are called to handle transactions. They are called when a
  474. * packet arrives. The flags argument contains the second word of the first
  475. * header quadlet of the incoming packet (containing transaction label, retry
  476. * code, transaction code and priority). These functions either return a
  477. * response code or a negative number. In the first case a response will be
  478. * generated. In the latter case, no response will be sent and the driver which
  479. * handled the request will send the response itself.
  480. */
  481. int highlevel_read(struct hpsb_host *host, int nodeid, void *data, u64 addr,
  482. unsigned int length, u16 flags)
  483. {
  484. struct hpsb_address_serve *as;
  485. unsigned int partlength;
  486. int rcode = RCODE_ADDRESS_ERROR;
  487. read_lock(&addr_space_lock);
  488. list_for_each_entry(as, &host->addr_space, host_list) {
  489. if (as->start > addr)
  490. break;
  491. if (as->end > addr) {
  492. partlength = min(as->end - addr, (u64) length);
  493. if (as->op->read)
  494. rcode = as->op->read(host, nodeid, data,
  495. addr, partlength, flags);
  496. else
  497. rcode = RCODE_TYPE_ERROR;
  498. data += partlength;
  499. length -= partlength;
  500. addr += partlength;
  501. if ((rcode != RCODE_COMPLETE) || !length)
  502. break;
  503. }
  504. }
  505. read_unlock(&addr_space_lock);
  506. if (length && (rcode == RCODE_COMPLETE))
  507. rcode = RCODE_ADDRESS_ERROR;
  508. return rcode;
  509. }
  510. int highlevel_write(struct hpsb_host *host, int nodeid, int destid, void *data,
  511. u64 addr, unsigned int length, u16 flags)
  512. {
  513. struct hpsb_address_serve *as;
  514. unsigned int partlength;
  515. int rcode = RCODE_ADDRESS_ERROR;
  516. read_lock(&addr_space_lock);
  517. list_for_each_entry(as, &host->addr_space, host_list) {
  518. if (as->start > addr)
  519. break;
  520. if (as->end > addr) {
  521. partlength = min(as->end - addr, (u64) length);
  522. if (as->op->write)
  523. rcode = as->op->write(host, nodeid, destid,
  524. data, addr, partlength,
  525. flags);
  526. else
  527. rcode = RCODE_TYPE_ERROR;
  528. data += partlength;
  529. length -= partlength;
  530. addr += partlength;
  531. if ((rcode != RCODE_COMPLETE) || !length)
  532. break;
  533. }
  534. }
  535. read_unlock(&addr_space_lock);
  536. if (length && (rcode == RCODE_COMPLETE))
  537. rcode = RCODE_ADDRESS_ERROR;
  538. return rcode;
  539. }
  540. int highlevel_lock(struct hpsb_host *host, int nodeid, quadlet_t *store,
  541. u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode,
  542. u16 flags)
  543. {
  544. struct hpsb_address_serve *as;
  545. int rcode = RCODE_ADDRESS_ERROR;
  546. read_lock(&addr_space_lock);
  547. list_for_each_entry(as, &host->addr_space, host_list) {
  548. if (as->start > addr)
  549. break;
  550. if (as->end > addr) {
  551. if (as->op->lock)
  552. rcode = as->op->lock(host, nodeid, store, addr,
  553. data, arg, ext_tcode,
  554. flags);
  555. else
  556. rcode = RCODE_TYPE_ERROR;
  557. break;
  558. }
  559. }
  560. read_unlock(&addr_space_lock);
  561. return rcode;
  562. }
  563. int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store,
  564. u64 addr, octlet_t data, octlet_t arg, int ext_tcode,
  565. u16 flags)
  566. {
  567. struct hpsb_address_serve *as;
  568. int rcode = RCODE_ADDRESS_ERROR;
  569. read_lock(&addr_space_lock);
  570. list_for_each_entry(as, &host->addr_space, host_list) {
  571. if (as->start > addr)
  572. break;
  573. if (as->end > addr) {
  574. if (as->op->lock64)
  575. rcode = as->op->lock64(host, nodeid, store,
  576. addr, data, arg,
  577. ext_tcode, flags);
  578. else
  579. rcode = RCODE_TYPE_ERROR;
  580. break;
  581. }
  582. }
  583. read_unlock(&addr_space_lock);
  584. return rcode;
  585. }