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. static struct hl_host_info *hl_get_hostinfo(struct hpsb_highlevel *hl,
  41. struct hpsb_host *host)
  42. {
  43. struct hl_host_info *hi = NULL;
  44. if (!hl || !host)
  45. return NULL;
  46. read_lock(&hl->host_info_lock);
  47. list_for_each_entry(hi, &hl->host_info_list, list) {
  48. if (hi->host == host) {
  49. read_unlock(&hl->host_info_lock);
  50. return hi;
  51. }
  52. }
  53. read_unlock(&hl->host_info_lock);
  54. return NULL;
  55. }
  56. /**
  57. * hpsb_get_hostinfo - retrieve a hostinfo pointer bound to this driver/host
  58. *
  59. * Returns a per @host and @hl driver data structure that was previously stored
  60. * by hpsb_create_hostinfo.
  61. */
  62. void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
  63. {
  64. struct hl_host_info *hi = hl_get_hostinfo(hl, host);
  65. return hi ? hi->data : NULL;
  66. }
  67. /**
  68. * hpsb_create_hostinfo - allocate a hostinfo pointer bound to this driver/host
  69. *
  70. * Allocate a hostinfo pointer backed by memory with @data_size and bind it to
  71. * to this @hl driver and @host. If @data_size is zero, then the return here is
  72. * only valid for error checking.
  73. */
  74. void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
  75. size_t data_size)
  76. {
  77. struct hl_host_info *hi;
  78. void *data;
  79. unsigned long flags;
  80. hi = hl_get_hostinfo(hl, host);
  81. if (hi) {
  82. HPSB_ERR("%s called hpsb_create_hostinfo when hostinfo already"
  83. " exists", hl->name);
  84. return NULL;
  85. }
  86. hi = kzalloc(sizeof(*hi) + data_size, GFP_ATOMIC);
  87. if (!hi)
  88. return NULL;
  89. if (data_size) {
  90. data = hi->data = hi + 1;
  91. hi->size = data_size;
  92. } else
  93. data = hi;
  94. hi->host = host;
  95. write_lock_irqsave(&hl->host_info_lock, flags);
  96. list_add_tail(&hi->list, &hl->host_info_list);
  97. write_unlock_irqrestore(&hl->host_info_lock, flags);
  98. return data;
  99. }
  100. /**
  101. * hpsb_set_hostinfo - set the hostinfo pointer to something useful
  102. *
  103. * Usually follows a call to hpsb_create_hostinfo, where the size is 0.
  104. */
  105. int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
  106. void *data)
  107. {
  108. struct hl_host_info *hi;
  109. hi = hl_get_hostinfo(hl, host);
  110. if (hi) {
  111. if (!hi->size && !hi->data) {
  112. hi->data = data;
  113. return 0;
  114. } else
  115. HPSB_ERR("%s called hpsb_set_hostinfo when hostinfo "
  116. "already has data", hl->name);
  117. } else
  118. HPSB_ERR("%s called hpsb_set_hostinfo when no hostinfo exists",
  119. hl->name);
  120. return -EINVAL;
  121. }
  122. /**
  123. * hpsb_destroy_hostinfo - free and remove a hostinfo pointer
  124. *
  125. * Free and remove the hostinfo pointer bound to this @hl driver and @host.
  126. */
  127. void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host)
  128. {
  129. struct hl_host_info *hi;
  130. hi = hl_get_hostinfo(hl, host);
  131. if (hi) {
  132. unsigned long flags;
  133. write_lock_irqsave(&hl->host_info_lock, flags);
  134. list_del(&hi->list);
  135. write_unlock_irqrestore(&hl->host_info_lock, flags);
  136. kfree(hi);
  137. }
  138. return;
  139. }
  140. /**
  141. * hpsb_set_hostinfo_key - set an alternate lookup key for an hostinfo
  142. *
  143. * Sets an alternate lookup key for the hostinfo bound to this @hl driver and
  144. * @host.
  145. */
  146. void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host,
  147. unsigned long key)
  148. {
  149. struct hl_host_info *hi;
  150. hi = hl_get_hostinfo(hl, host);
  151. if (hi)
  152. hi->key = key;
  153. return;
  154. }
  155. /**
  156. * hpsb_get_hostinfo_bykey - retrieve a hostinfo pointer by its alternate key
  157. */
  158. void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key)
  159. {
  160. struct hl_host_info *hi;
  161. void *data = NULL;
  162. if (!hl)
  163. return NULL;
  164. read_lock(&hl->host_info_lock);
  165. list_for_each_entry(hi, &hl->host_info_list, list) {
  166. if (hi->key == key) {
  167. data = hi->data;
  168. break;
  169. }
  170. }
  171. read_unlock(&hl->host_info_lock);
  172. return data;
  173. }
  174. static int highlevel_for_each_host_reg(struct hpsb_host *host, void *__data)
  175. {
  176. struct hpsb_highlevel *hl = __data;
  177. hl->add_host(host);
  178. if (host->update_config_rom && hpsb_update_config_rom_image(host) < 0)
  179. HPSB_ERR("Failed to generate Configuration ROM image for host "
  180. "%s-%d", hl->name, host->id);
  181. return 0;
  182. }
  183. /**
  184. * hpsb_register_highlevel - register highlevel driver
  185. *
  186. * The name pointer in @hl has to stay valid at all times because the string is
  187. * not copied.
  188. */
  189. void hpsb_register_highlevel(struct hpsb_highlevel *hl)
  190. {
  191. unsigned long flags;
  192. hpsb_init_highlevel(hl);
  193. INIT_LIST_HEAD(&hl->addr_list);
  194. down_write(&hl_drivers_sem);
  195. list_add_tail(&hl->hl_list, &hl_drivers);
  196. up_write(&hl_drivers_sem);
  197. write_lock_irqsave(&hl_irqs_lock, flags);
  198. list_add_tail(&hl->irq_list, &hl_irqs);
  199. write_unlock_irqrestore(&hl_irqs_lock, flags);
  200. if (hl->add_host)
  201. nodemgr_for_each_host(hl, highlevel_for_each_host_reg);
  202. return;
  203. }
  204. static void __delete_addr(struct hpsb_address_serve *as)
  205. {
  206. list_del(&as->host_list);
  207. list_del(&as->hl_list);
  208. kfree(as);
  209. }
  210. static void __unregister_host(struct hpsb_highlevel *hl, struct hpsb_host *host,
  211. int update_cr)
  212. {
  213. unsigned long flags;
  214. struct list_head *lh, *next;
  215. struct hpsb_address_serve *as;
  216. /* First, let the highlevel driver unreg */
  217. if (hl->remove_host)
  218. hl->remove_host(host);
  219. /* Remove any addresses that are matched for this highlevel driver
  220. * and this particular host. */
  221. write_lock_irqsave(&addr_space_lock, flags);
  222. list_for_each_safe (lh, next, &hl->addr_list) {
  223. as = list_entry(lh, struct hpsb_address_serve, hl_list);
  224. if (as->host == host)
  225. __delete_addr(as);
  226. }
  227. write_unlock_irqrestore(&addr_space_lock, flags);
  228. /* Now update the config-rom to reflect anything removed by the
  229. * highlevel driver. */
  230. if (update_cr && host->update_config_rom &&
  231. hpsb_update_config_rom_image(host) < 0)
  232. HPSB_ERR("Failed to generate Configuration ROM image for host "
  233. "%s-%d", hl->name, host->id);
  234. /* Finally remove all the host info associated between these two. */
  235. hpsb_destroy_hostinfo(hl, host);
  236. }
  237. static int highlevel_for_each_host_unreg(struct hpsb_host *host, void *__data)
  238. {
  239. struct hpsb_highlevel *hl = __data;
  240. __unregister_host(hl, host, 1);
  241. return 0;
  242. }
  243. /**
  244. * hpsb_unregister_highlevel - unregister highlevel driver
  245. */
  246. void hpsb_unregister_highlevel(struct hpsb_highlevel *hl)
  247. {
  248. unsigned long flags;
  249. write_lock_irqsave(&hl_irqs_lock, flags);
  250. list_del(&hl->irq_list);
  251. write_unlock_irqrestore(&hl_irqs_lock, flags);
  252. down_write(&hl_drivers_sem);
  253. list_del(&hl->hl_list);
  254. up_write(&hl_drivers_sem);
  255. nodemgr_for_each_host(hl, highlevel_for_each_host_unreg);
  256. }
  257. /**
  258. * hpsb_allocate_and_register_addrspace - alloc' and reg' a host address space
  259. *
  260. * @start and @end are 48 bit pointers and have to be quadlet aligned.
  261. * @end points to the first address behind the handled addresses. This
  262. * function can be called multiple times for a single hpsb_highlevel @hl to
  263. * implement sparse register sets. The requested region must not overlap any
  264. * previously allocated region, otherwise registering will fail.
  265. *
  266. * It returns true for successful allocation. Address spaces can be
  267. * unregistered with hpsb_unregister_addrspace. All remaining address spaces
  268. * are automatically deallocated together with the hpsb_highlevel @hl.
  269. */
  270. u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
  271. struct hpsb_host *host,
  272. const struct hpsb_address_ops *ops,
  273. u64 size, u64 alignment,
  274. u64 start, u64 end)
  275. {
  276. struct hpsb_address_serve *as, *a1, *a2;
  277. struct list_head *entry;
  278. u64 retval = CSR1212_INVALID_ADDR_SPACE;
  279. unsigned long flags;
  280. u64 align_mask = ~(alignment - 1);
  281. if ((alignment & 3) || (alignment > 0x800000000000ULL) ||
  282. (hweight64(alignment) != 1)) {
  283. HPSB_ERR("%s called with invalid alignment: 0x%048llx",
  284. __func__, (unsigned long long)alignment);
  285. return retval;
  286. }
  287. /* default range,
  288. * avoids controller's posted write area (see OHCI 1.1 clause 1.5) */
  289. if (start == CSR1212_INVALID_ADDR_SPACE &&
  290. end == CSR1212_INVALID_ADDR_SPACE) {
  291. start = host->middle_addr_space;
  292. end = CSR1212_ALL_SPACE_END;
  293. }
  294. if (((start|end) & ~align_mask) || (start >= end) ||
  295. (end > CSR1212_ALL_SPACE_END)) {
  296. HPSB_ERR("%s called with invalid addresses "
  297. "(start = %012Lx end = %012Lx)", __func__,
  298. (unsigned long long)start,(unsigned long long)end);
  299. return retval;
  300. }
  301. as = kmalloc(sizeof(*as), GFP_KERNEL);
  302. if (!as)
  303. return retval;
  304. INIT_LIST_HEAD(&as->host_list);
  305. INIT_LIST_HEAD(&as->hl_list);
  306. as->op = ops;
  307. as->host = host;
  308. write_lock_irqsave(&addr_space_lock, flags);
  309. list_for_each(entry, &host->addr_space) {
  310. u64 a1sa, a1ea;
  311. u64 a2sa, a2ea;
  312. a1 = list_entry(entry, struct hpsb_address_serve, host_list);
  313. a2 = list_entry(entry->next, struct hpsb_address_serve,
  314. host_list);
  315. a1sa = a1->start & align_mask;
  316. a1ea = (a1->end + alignment -1) & align_mask;
  317. a2sa = a2->start & align_mask;
  318. a2ea = (a2->end + alignment -1) & align_mask;
  319. if ((a2sa - a1ea >= size) && (a2sa - start >= size) &&
  320. (a2sa > start)) {
  321. as->start = max(start, a1ea);
  322. as->end = as->start + size;
  323. list_add(&as->host_list, entry);
  324. list_add_tail(&as->hl_list, &hl->addr_list);
  325. retval = as->start;
  326. break;
  327. }
  328. }
  329. write_unlock_irqrestore(&addr_space_lock, flags);
  330. if (retval == CSR1212_INVALID_ADDR_SPACE)
  331. kfree(as);
  332. return retval;
  333. }
  334. /**
  335. * hpsb_register_addrspace - register a host address space
  336. *
  337. * @start and @end are 48 bit pointers and have to be quadlet aligned.
  338. * @end points to the first address behind the handled addresses. This
  339. * function can be called multiple times for a single hpsb_highlevel @hl to
  340. * implement sparse register sets. The requested region must not overlap any
  341. * previously allocated region, otherwise registering will fail.
  342. *
  343. * It returns true for successful allocation. Address spaces can be
  344. * unregistered with hpsb_unregister_addrspace. All remaining address spaces
  345. * are automatically deallocated together with the hpsb_highlevel @hl.
  346. */
  347. int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
  348. const struct hpsb_address_ops *ops,
  349. u64 start, u64 end)
  350. {
  351. struct hpsb_address_serve *as;
  352. struct list_head *lh;
  353. int retval = 0;
  354. unsigned long flags;
  355. if (((start|end) & 3) || (start >= end) ||
  356. (end > CSR1212_ALL_SPACE_END)) {
  357. HPSB_ERR("%s called with invalid addresses", __func__);
  358. return 0;
  359. }
  360. as = kmalloc(sizeof(*as), GFP_KERNEL);
  361. if (!as)
  362. return 0;
  363. INIT_LIST_HEAD(&as->host_list);
  364. INIT_LIST_HEAD(&as->hl_list);
  365. as->op = ops;
  366. as->start = start;
  367. as->end = end;
  368. as->host = host;
  369. write_lock_irqsave(&addr_space_lock, flags);
  370. list_for_each(lh, &host->addr_space) {
  371. struct hpsb_address_serve *as_this =
  372. list_entry(lh, struct hpsb_address_serve, host_list);
  373. struct hpsb_address_serve *as_next =
  374. list_entry(lh->next, struct hpsb_address_serve,
  375. host_list);
  376. if (as_this->end > as->start)
  377. break;
  378. if (as_next->start >= as->end) {
  379. list_add(&as->host_list, lh);
  380. list_add_tail(&as->hl_list, &hl->addr_list);
  381. retval = 1;
  382. break;
  383. }
  384. }
  385. write_unlock_irqrestore(&addr_space_lock, flags);
  386. if (retval == 0)
  387. kfree(as);
  388. return retval;
  389. }
  390. int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
  391. u64 start)
  392. {
  393. int retval = 0;
  394. struct hpsb_address_serve *as;
  395. struct list_head *lh, *next;
  396. unsigned long flags;
  397. write_lock_irqsave(&addr_space_lock, flags);
  398. list_for_each_safe (lh, next, &hl->addr_list) {
  399. as = list_entry(lh, struct hpsb_address_serve, hl_list);
  400. if (as->start == start && as->host == host) {
  401. __delete_addr(as);
  402. retval = 1;
  403. break;
  404. }
  405. }
  406. write_unlock_irqrestore(&addr_space_lock, flags);
  407. return retval;
  408. }
  409. static const struct hpsb_address_ops dummy_ops;
  410. /* dummy address spaces as lower and upper bounds of the host's a.s. list */
  411. static void init_hpsb_highlevel(struct hpsb_host *host)
  412. {
  413. INIT_LIST_HEAD(&host->dummy_zero_addr.host_list);
  414. INIT_LIST_HEAD(&host->dummy_zero_addr.hl_list);
  415. INIT_LIST_HEAD(&host->dummy_max_addr.host_list);
  416. INIT_LIST_HEAD(&host->dummy_max_addr.hl_list);
  417. host->dummy_zero_addr.op = host->dummy_max_addr.op = &dummy_ops;
  418. host->dummy_zero_addr.start = host->dummy_zero_addr.end = 0;
  419. host->dummy_max_addr.start = host->dummy_max_addr.end = ((u64) 1) << 48;
  420. list_add_tail(&host->dummy_zero_addr.host_list, &host->addr_space);
  421. list_add_tail(&host->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. }