lpfc_mem.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2004-2009 Emulex. All rights reserved. *
  5. * EMULEX and SLI are trademarks of Emulex. *
  6. * www.emulex.com *
  7. * Portions Copyright (C) 2004-2005 Christoph Hellwig *
  8. * *
  9. * This program is free software; you can redistribute it and/or *
  10. * modify it under the terms of version 2 of the GNU General *
  11. * Public License as published by the Free Software Foundation. *
  12. * This program is distributed in the hope that it will be useful. *
  13. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  14. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  15. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  16. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  17. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  18. * more details, a copy of which can be found in the file COPYING *
  19. * included with this package. *
  20. *******************************************************************/
  21. #include <linux/mempool.h>
  22. #include <linux/slab.h>
  23. #include <linux/pci.h>
  24. #include <linux/interrupt.h>
  25. #include <scsi/scsi_device.h>
  26. #include <scsi/scsi_transport_fc.h>
  27. #include <scsi/scsi.h>
  28. #include "lpfc_hw4.h"
  29. #include "lpfc_hw.h"
  30. #include "lpfc_sli.h"
  31. #include "lpfc_sli4.h"
  32. #include "lpfc_nl.h"
  33. #include "lpfc_disc.h"
  34. #include "lpfc_scsi.h"
  35. #include "lpfc.h"
  36. #include "lpfc_crtn.h"
  37. #define LPFC_MBUF_POOL_SIZE 64 /* max elements in MBUF safety pool */
  38. #define LPFC_MEM_POOL_SIZE 64 /* max elem in non-DMA safety pool */
  39. /**
  40. * lpfc_mem_alloc - create and allocate all PCI and memory pools
  41. * @phba: HBA to allocate pools for
  42. *
  43. * Description: Creates and allocates PCI pools lpfc_scsi_dma_buf_pool,
  44. * lpfc_mbuf_pool, lpfc_hrb_pool. Creates and allocates kmalloc-backed mempools
  45. * for LPFC_MBOXQ_t and lpfc_nodelist. Also allocates the VPI bitmask.
  46. *
  47. * Notes: Not interrupt-safe. Must be called with no locks held. If any
  48. * allocation fails, frees all successfully allocated memory before returning.
  49. *
  50. * Returns:
  51. * 0 on success
  52. * -ENOMEM on failure (if any memory allocations fail)
  53. **/
  54. int
  55. lpfc_mem_alloc(struct lpfc_hba *phba, int align)
  56. {
  57. struct lpfc_dma_pool *pool = &phba->lpfc_mbuf_safety_pool;
  58. int longs;
  59. int i;
  60. if (phba->sli_rev == LPFC_SLI_REV4)
  61. phba->lpfc_scsi_dma_buf_pool =
  62. pci_pool_create("lpfc_scsi_dma_buf_pool",
  63. phba->pcidev,
  64. phba->cfg_sg_dma_buf_size,
  65. phba->cfg_sg_dma_buf_size,
  66. 0);
  67. else
  68. phba->lpfc_scsi_dma_buf_pool =
  69. pci_pool_create("lpfc_scsi_dma_buf_pool",
  70. phba->pcidev, phba->cfg_sg_dma_buf_size,
  71. align, 0);
  72. if (!phba->lpfc_scsi_dma_buf_pool)
  73. goto fail;
  74. phba->lpfc_mbuf_pool = pci_pool_create("lpfc_mbuf_pool", phba->pcidev,
  75. LPFC_BPL_SIZE,
  76. align, 0);
  77. if (!phba->lpfc_mbuf_pool)
  78. goto fail_free_dma_buf_pool;
  79. pool->elements = kmalloc(sizeof(struct lpfc_dmabuf) *
  80. LPFC_MBUF_POOL_SIZE, GFP_KERNEL);
  81. if (!pool->elements)
  82. goto fail_free_lpfc_mbuf_pool;
  83. pool->max_count = 0;
  84. pool->current_count = 0;
  85. for ( i = 0; i < LPFC_MBUF_POOL_SIZE; i++) {
  86. pool->elements[i].virt = pci_pool_alloc(phba->lpfc_mbuf_pool,
  87. GFP_KERNEL, &pool->elements[i].phys);
  88. if (!pool->elements[i].virt)
  89. goto fail_free_mbuf_pool;
  90. pool->max_count++;
  91. pool->current_count++;
  92. }
  93. phba->mbox_mem_pool = mempool_create_kmalloc_pool(LPFC_MEM_POOL_SIZE,
  94. sizeof(LPFC_MBOXQ_t));
  95. if (!phba->mbox_mem_pool)
  96. goto fail_free_mbuf_pool;
  97. phba->nlp_mem_pool = mempool_create_kmalloc_pool(LPFC_MEM_POOL_SIZE,
  98. sizeof(struct lpfc_nodelist));
  99. if (!phba->nlp_mem_pool)
  100. goto fail_free_mbox_pool;
  101. if (phba->sli_rev == LPFC_SLI_REV4) {
  102. phba->rrq_pool =
  103. mempool_create_kmalloc_pool(LPFC_MEM_POOL_SIZE,
  104. sizeof(struct lpfc_node_rrq));
  105. if (!phba->rrq_pool)
  106. goto fail_free_nlp_mem_pool;
  107. phba->lpfc_hrb_pool = pci_pool_create("lpfc_hrb_pool",
  108. phba->pcidev,
  109. LPFC_HDR_BUF_SIZE, align, 0);
  110. if (!phba->lpfc_hrb_pool)
  111. goto fail_free_rrq_mem_pool;
  112. phba->lpfc_drb_pool = pci_pool_create("lpfc_drb_pool",
  113. phba->pcidev,
  114. LPFC_DATA_BUF_SIZE, align, 0);
  115. if (!phba->lpfc_drb_pool)
  116. goto fail_free_hrb_pool;
  117. phba->lpfc_hbq_pool = NULL;
  118. } else {
  119. phba->lpfc_hbq_pool = pci_pool_create("lpfc_hbq_pool",
  120. phba->pcidev, LPFC_BPL_SIZE, align, 0);
  121. if (!phba->lpfc_hbq_pool)
  122. goto fail_free_nlp_mem_pool;
  123. phba->lpfc_hrb_pool = NULL;
  124. phba->lpfc_drb_pool = NULL;
  125. }
  126. /* vpi zero is reserved for the physical port so add 1 to max */
  127. longs = ((phba->max_vpi + 1) + BITS_PER_LONG - 1) / BITS_PER_LONG;
  128. phba->vpi_bmask = kzalloc(longs * sizeof(unsigned long), GFP_KERNEL);
  129. if (!phba->vpi_bmask)
  130. goto fail_free_dbq_pool;
  131. return 0;
  132. fail_free_dbq_pool:
  133. pci_pool_destroy(phba->lpfc_drb_pool);
  134. phba->lpfc_drb_pool = NULL;
  135. fail_free_hrb_pool:
  136. pci_pool_destroy(phba->lpfc_hrb_pool);
  137. phba->lpfc_hrb_pool = NULL;
  138. fail_free_rrq_mem_pool:
  139. mempool_destroy(phba->rrq_pool);
  140. phba->rrq_pool = NULL;
  141. fail_free_nlp_mem_pool:
  142. mempool_destroy(phba->nlp_mem_pool);
  143. phba->nlp_mem_pool = NULL;
  144. fail_free_mbox_pool:
  145. mempool_destroy(phba->mbox_mem_pool);
  146. phba->mbox_mem_pool = NULL;
  147. fail_free_mbuf_pool:
  148. while (i--)
  149. pci_pool_free(phba->lpfc_mbuf_pool, pool->elements[i].virt,
  150. pool->elements[i].phys);
  151. kfree(pool->elements);
  152. fail_free_lpfc_mbuf_pool:
  153. pci_pool_destroy(phba->lpfc_mbuf_pool);
  154. phba->lpfc_mbuf_pool = NULL;
  155. fail_free_dma_buf_pool:
  156. pci_pool_destroy(phba->lpfc_scsi_dma_buf_pool);
  157. phba->lpfc_scsi_dma_buf_pool = NULL;
  158. fail:
  159. return -ENOMEM;
  160. }
  161. /**
  162. * lpfc_mem_free - Frees memory allocated by lpfc_mem_alloc
  163. * @phba: HBA to free memory for
  164. *
  165. * Description: Free the memory allocated by lpfc_mem_alloc routine. This
  166. * routine is a the counterpart of lpfc_mem_alloc.
  167. *
  168. * Returns: None
  169. **/
  170. void
  171. lpfc_mem_free(struct lpfc_hba *phba)
  172. {
  173. int i;
  174. struct lpfc_dma_pool *pool = &phba->lpfc_mbuf_safety_pool;
  175. /* Free VPI bitmask memory */
  176. kfree(phba->vpi_bmask);
  177. /* Free HBQ pools */
  178. lpfc_sli_hbqbuf_free_all(phba);
  179. if (phba->lpfc_drb_pool)
  180. pci_pool_destroy(phba->lpfc_drb_pool);
  181. phba->lpfc_drb_pool = NULL;
  182. if (phba->lpfc_hrb_pool)
  183. pci_pool_destroy(phba->lpfc_hrb_pool);
  184. phba->lpfc_hrb_pool = NULL;
  185. if (phba->lpfc_hbq_pool)
  186. pci_pool_destroy(phba->lpfc_hbq_pool);
  187. phba->lpfc_hbq_pool = NULL;
  188. /* Free NLP memory pool */
  189. mempool_destroy(phba->nlp_mem_pool);
  190. phba->nlp_mem_pool = NULL;
  191. /* Free mbox memory pool */
  192. mempool_destroy(phba->mbox_mem_pool);
  193. phba->mbox_mem_pool = NULL;
  194. /* Free MBUF memory pool */
  195. for (i = 0; i < pool->current_count; i++)
  196. pci_pool_free(phba->lpfc_mbuf_pool, pool->elements[i].virt,
  197. pool->elements[i].phys);
  198. kfree(pool->elements);
  199. pci_pool_destroy(phba->lpfc_mbuf_pool);
  200. phba->lpfc_mbuf_pool = NULL;
  201. /* Free DMA buffer memory pool */
  202. pci_pool_destroy(phba->lpfc_scsi_dma_buf_pool);
  203. phba->lpfc_scsi_dma_buf_pool = NULL;
  204. return;
  205. }
  206. /**
  207. * lpfc_mem_free_all - Frees all PCI and driver memory
  208. * @phba: HBA to free memory for
  209. *
  210. * Description: Free memory from PCI and driver memory pools and also those
  211. * used : lpfc_scsi_dma_buf_pool, lpfc_mbuf_pool, lpfc_hrb_pool. Frees
  212. * kmalloc-backed mempools for LPFC_MBOXQ_t and lpfc_nodelist. Also frees
  213. * the VPI bitmask.
  214. *
  215. * Returns: None
  216. **/
  217. void
  218. lpfc_mem_free_all(struct lpfc_hba *phba)
  219. {
  220. struct lpfc_sli *psli = &phba->sli;
  221. LPFC_MBOXQ_t *mbox, *next_mbox;
  222. struct lpfc_dmabuf *mp;
  223. /* Free memory used in mailbox queue back to mailbox memory pool */
  224. list_for_each_entry_safe(mbox, next_mbox, &psli->mboxq, list) {
  225. mp = (struct lpfc_dmabuf *) (mbox->context1);
  226. if (mp) {
  227. lpfc_mbuf_free(phba, mp->virt, mp->phys);
  228. kfree(mp);
  229. }
  230. list_del(&mbox->list);
  231. mempool_free(mbox, phba->mbox_mem_pool);
  232. }
  233. /* Free memory used in mailbox cmpl list back to mailbox memory pool */
  234. list_for_each_entry_safe(mbox, next_mbox, &psli->mboxq_cmpl, list) {
  235. mp = (struct lpfc_dmabuf *) (mbox->context1);
  236. if (mp) {
  237. lpfc_mbuf_free(phba, mp->virt, mp->phys);
  238. kfree(mp);
  239. }
  240. list_del(&mbox->list);
  241. mempool_free(mbox, phba->mbox_mem_pool);
  242. }
  243. /* Free the active mailbox command back to the mailbox memory pool */
  244. spin_lock_irq(&phba->hbalock);
  245. psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
  246. spin_unlock_irq(&phba->hbalock);
  247. if (psli->mbox_active) {
  248. mbox = psli->mbox_active;
  249. mp = (struct lpfc_dmabuf *) (mbox->context1);
  250. if (mp) {
  251. lpfc_mbuf_free(phba, mp->virt, mp->phys);
  252. kfree(mp);
  253. }
  254. mempool_free(mbox, phba->mbox_mem_pool);
  255. psli->mbox_active = NULL;
  256. }
  257. /* Free and destroy all the allocated memory pools */
  258. lpfc_mem_free(phba);
  259. /* Free the iocb lookup array */
  260. kfree(psli->iocbq_lookup);
  261. psli->iocbq_lookup = NULL;
  262. return;
  263. }
  264. /**
  265. * lpfc_mbuf_alloc - Allocate an mbuf from the lpfc_mbuf_pool PCI pool
  266. * @phba: HBA which owns the pool to allocate from
  267. * @mem_flags: indicates if this is a priority (MEM_PRI) allocation
  268. * @handle: used to return the DMA-mapped address of the mbuf
  269. *
  270. * Description: Allocates a DMA-mapped buffer from the lpfc_mbuf_pool PCI pool.
  271. * Allocates from generic pci_pool_alloc function first and if that fails and
  272. * mem_flags has MEM_PRI set (the only defined flag), returns an mbuf from the
  273. * HBA's pool.
  274. *
  275. * Notes: Not interrupt-safe. Must be called with no locks held. Takes
  276. * phba->hbalock.
  277. *
  278. * Returns:
  279. * pointer to the allocated mbuf on success
  280. * NULL on failure
  281. **/
  282. void *
  283. lpfc_mbuf_alloc(struct lpfc_hba *phba, int mem_flags, dma_addr_t *handle)
  284. {
  285. struct lpfc_dma_pool *pool = &phba->lpfc_mbuf_safety_pool;
  286. unsigned long iflags;
  287. void *ret;
  288. ret = pci_pool_alloc(phba->lpfc_mbuf_pool, GFP_KERNEL, handle);
  289. spin_lock_irqsave(&phba->hbalock, iflags);
  290. if (!ret && (mem_flags & MEM_PRI) && pool->current_count) {
  291. pool->current_count--;
  292. ret = pool->elements[pool->current_count].virt;
  293. *handle = pool->elements[pool->current_count].phys;
  294. }
  295. spin_unlock_irqrestore(&phba->hbalock, iflags);
  296. return ret;
  297. }
  298. /**
  299. * __lpfc_mbuf_free - Free an mbuf from the lpfc_mbuf_pool PCI pool (locked)
  300. * @phba: HBA which owns the pool to return to
  301. * @virt: mbuf to free
  302. * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed
  303. *
  304. * Description: Returns an mbuf lpfc_mbuf_pool to the lpfc_mbuf_safety_pool if
  305. * it is below its max_count, frees the mbuf otherwise.
  306. *
  307. * Notes: Must be called with phba->hbalock held to synchronize access to
  308. * lpfc_mbuf_safety_pool.
  309. *
  310. * Returns: None
  311. **/
  312. void
  313. __lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma)
  314. {
  315. struct lpfc_dma_pool *pool = &phba->lpfc_mbuf_safety_pool;
  316. if (pool->current_count < pool->max_count) {
  317. pool->elements[pool->current_count].virt = virt;
  318. pool->elements[pool->current_count].phys = dma;
  319. pool->current_count++;
  320. } else {
  321. pci_pool_free(phba->lpfc_mbuf_pool, virt, dma);
  322. }
  323. return;
  324. }
  325. /**
  326. * lpfc_mbuf_free - Free an mbuf from the lpfc_mbuf_pool PCI pool (unlocked)
  327. * @phba: HBA which owns the pool to return to
  328. * @virt: mbuf to free
  329. * @dma: the DMA-mapped address of the lpfc_mbuf_pool to be freed
  330. *
  331. * Description: Returns an mbuf lpfc_mbuf_pool to the lpfc_mbuf_safety_pool if
  332. * it is below its max_count, frees the mbuf otherwise.
  333. *
  334. * Notes: Takes phba->hbalock. Can be called with or without other locks held.
  335. *
  336. * Returns: None
  337. **/
  338. void
  339. lpfc_mbuf_free(struct lpfc_hba * phba, void *virt, dma_addr_t dma)
  340. {
  341. unsigned long iflags;
  342. spin_lock_irqsave(&phba->hbalock, iflags);
  343. __lpfc_mbuf_free(phba, virt, dma);
  344. spin_unlock_irqrestore(&phba->hbalock, iflags);
  345. return;
  346. }
  347. /**
  348. * lpfc_els_hbq_alloc - Allocate an HBQ buffer
  349. * @phba: HBA to allocate HBQ buffer for
  350. *
  351. * Description: Allocates a DMA-mapped HBQ buffer from the lpfc_hrb_pool PCI
  352. * pool along a non-DMA-mapped container for it.
  353. *
  354. * Notes: Not interrupt-safe. Must be called with no locks held.
  355. *
  356. * Returns:
  357. * pointer to HBQ on success
  358. * NULL on failure
  359. **/
  360. struct hbq_dmabuf *
  361. lpfc_els_hbq_alloc(struct lpfc_hba *phba)
  362. {
  363. struct hbq_dmabuf *hbqbp;
  364. hbqbp = kmalloc(sizeof(struct hbq_dmabuf), GFP_KERNEL);
  365. if (!hbqbp)
  366. return NULL;
  367. hbqbp->dbuf.virt = pci_pool_alloc(phba->lpfc_hbq_pool, GFP_KERNEL,
  368. &hbqbp->dbuf.phys);
  369. if (!hbqbp->dbuf.virt) {
  370. kfree(hbqbp);
  371. return NULL;
  372. }
  373. hbqbp->size = LPFC_BPL_SIZE;
  374. return hbqbp;
  375. }
  376. /**
  377. * lpfc_els_hbq_free - Frees an HBQ buffer allocated with lpfc_els_hbq_alloc
  378. * @phba: HBA buffer was allocated for
  379. * @hbqbp: HBQ container returned by lpfc_els_hbq_alloc
  380. *
  381. * Description: Frees both the container and the DMA-mapped buffer returned by
  382. * lpfc_els_hbq_alloc.
  383. *
  384. * Notes: Can be called with or without locks held.
  385. *
  386. * Returns: None
  387. **/
  388. void
  389. lpfc_els_hbq_free(struct lpfc_hba *phba, struct hbq_dmabuf *hbqbp)
  390. {
  391. pci_pool_free(phba->lpfc_hbq_pool, hbqbp->dbuf.virt, hbqbp->dbuf.phys);
  392. kfree(hbqbp);
  393. return;
  394. }
  395. /**
  396. * lpfc_sli4_rb_alloc - Allocate an SLI4 Receive buffer
  397. * @phba: HBA to allocate a receive buffer for
  398. *
  399. * Description: Allocates a DMA-mapped receive buffer from the lpfc_hrb_pool PCI
  400. * pool along a non-DMA-mapped container for it.
  401. *
  402. * Notes: Not interrupt-safe. Must be called with no locks held.
  403. *
  404. * Returns:
  405. * pointer to HBQ on success
  406. * NULL on failure
  407. **/
  408. struct hbq_dmabuf *
  409. lpfc_sli4_rb_alloc(struct lpfc_hba *phba)
  410. {
  411. struct hbq_dmabuf *dma_buf;
  412. dma_buf = kmalloc(sizeof(struct hbq_dmabuf), GFP_KERNEL);
  413. if (!dma_buf)
  414. return NULL;
  415. dma_buf->hbuf.virt = pci_pool_alloc(phba->lpfc_hrb_pool, GFP_KERNEL,
  416. &dma_buf->hbuf.phys);
  417. if (!dma_buf->hbuf.virt) {
  418. kfree(dma_buf);
  419. return NULL;
  420. }
  421. dma_buf->dbuf.virt = pci_pool_alloc(phba->lpfc_drb_pool, GFP_KERNEL,
  422. &dma_buf->dbuf.phys);
  423. if (!dma_buf->dbuf.virt) {
  424. pci_pool_free(phba->lpfc_hrb_pool, dma_buf->hbuf.virt,
  425. dma_buf->hbuf.phys);
  426. kfree(dma_buf);
  427. return NULL;
  428. }
  429. dma_buf->size = LPFC_BPL_SIZE;
  430. return dma_buf;
  431. }
  432. /**
  433. * lpfc_sli4_rb_free - Frees a receive buffer
  434. * @phba: HBA buffer was allocated for
  435. * @dmab: DMA Buffer container returned by lpfc_sli4_hbq_alloc
  436. *
  437. * Description: Frees both the container and the DMA-mapped buffers returned by
  438. * lpfc_sli4_rb_alloc.
  439. *
  440. * Notes: Can be called with or without locks held.
  441. *
  442. * Returns: None
  443. **/
  444. void
  445. lpfc_sli4_rb_free(struct lpfc_hba *phba, struct hbq_dmabuf *dmab)
  446. {
  447. pci_pool_free(phba->lpfc_hrb_pool, dmab->hbuf.virt, dmab->hbuf.phys);
  448. pci_pool_free(phba->lpfc_drb_pool, dmab->dbuf.virt, dmab->dbuf.phys);
  449. kfree(dmab);
  450. return;
  451. }
  452. /**
  453. * lpfc_in_buf_free - Free a DMA buffer
  454. * @phba: HBA buffer is associated with
  455. * @mp: Buffer to free
  456. *
  457. * Description: Frees the given DMA buffer in the appropriate way given if the
  458. * HBA is running in SLI3 mode with HBQs enabled.
  459. *
  460. * Notes: Takes phba->hbalock. Can be called with or without other locks held.
  461. *
  462. * Returns: None
  463. **/
  464. void
  465. lpfc_in_buf_free(struct lpfc_hba *phba, struct lpfc_dmabuf *mp)
  466. {
  467. struct hbq_dmabuf *hbq_entry;
  468. unsigned long flags;
  469. if (!mp)
  470. return;
  471. if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) {
  472. /* Check whether HBQ is still in use */
  473. spin_lock_irqsave(&phba->hbalock, flags);
  474. if (!phba->hbq_in_use) {
  475. spin_unlock_irqrestore(&phba->hbalock, flags);
  476. return;
  477. }
  478. hbq_entry = container_of(mp, struct hbq_dmabuf, dbuf);
  479. list_del(&hbq_entry->dbuf.list);
  480. if (hbq_entry->tag == -1) {
  481. (phba->hbqs[LPFC_ELS_HBQ].hbq_free_buffer)
  482. (phba, hbq_entry);
  483. } else {
  484. lpfc_sli_free_hbq(phba, hbq_entry);
  485. }
  486. spin_unlock_irqrestore(&phba->hbalock, flags);
  487. } else {
  488. lpfc_mbuf_free(phba, mp->virt, mp->phys);
  489. kfree(mp);
  490. }
  491. return;
  492. }