diff options
author | Roland Dreier <roland@topspin.com> | 2005-06-27 17:36:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-27 18:11:46 -0400 |
commit | ed878458eeff9754d66f1b0325df6ebbfcdce668 (patch) | |
tree | eab302706f069a7922e1d953b5f33b61bdc868a4 /drivers/infiniband/hw/mthca/mthca_eq.c | |
parent | 80fd8238734c852a8ed1ea39f8444a2df33bd161 (diff) |
[PATCH] IB/mthca: Align FW command mailboxes to 4K
Future versions of Mellanox HCA firmware will require command mailboxes to be
aligned to 4K. Support this by using a pci_pool to allocate all mailboxes.
This has the added benefit of shrinking the source and text of mthca.
Signed-off-by: Roland Dreier <roland@topspin.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_eq.c')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_eq.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c index 970cba24e79f..cbcf2b4722e4 100644 --- a/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/drivers/infiniband/hw/mthca/mthca_eq.c | |||
@@ -469,7 +469,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, | |||
469 | PAGE_SIZE; | 469 | PAGE_SIZE; |
470 | u64 *dma_list = NULL; | 470 | u64 *dma_list = NULL; |
471 | dma_addr_t t; | 471 | dma_addr_t t; |
472 | void *mailbox = NULL; | 472 | struct mthca_mailbox *mailbox; |
473 | struct mthca_eq_context *eq_context; | 473 | struct mthca_eq_context *eq_context; |
474 | int err = -ENOMEM; | 474 | int err = -ENOMEM; |
475 | int i; | 475 | int i; |
@@ -494,17 +494,16 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, | |||
494 | if (!dma_list) | 494 | if (!dma_list) |
495 | goto err_out_free; | 495 | goto err_out_free; |
496 | 496 | ||
497 | mailbox = kmalloc(sizeof *eq_context + MTHCA_CMD_MAILBOX_EXTRA, | 497 | mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); |
498 | GFP_KERNEL); | 498 | if (IS_ERR(mailbox)) |
499 | if (!mailbox) | ||
500 | goto err_out_free; | 499 | goto err_out_free; |
501 | eq_context = MAILBOX_ALIGN(mailbox); | 500 | eq_context = mailbox->buf; |
502 | 501 | ||
503 | for (i = 0; i < npages; ++i) { | 502 | for (i = 0; i < npages; ++i) { |
504 | eq->page_list[i].buf = dma_alloc_coherent(&dev->pdev->dev, | 503 | eq->page_list[i].buf = dma_alloc_coherent(&dev->pdev->dev, |
505 | PAGE_SIZE, &t, GFP_KERNEL); | 504 | PAGE_SIZE, &t, GFP_KERNEL); |
506 | if (!eq->page_list[i].buf) | 505 | if (!eq->page_list[i].buf) |
507 | goto err_out_free; | 506 | goto err_out_free_pages; |
508 | 507 | ||
509 | dma_list[i] = t; | 508 | dma_list[i] = t; |
510 | pci_unmap_addr_set(&eq->page_list[i], mapping, t); | 509 | pci_unmap_addr_set(&eq->page_list[i], mapping, t); |
@@ -517,7 +516,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, | |||
517 | 516 | ||
518 | eq->eqn = mthca_alloc(&dev->eq_table.alloc); | 517 | eq->eqn = mthca_alloc(&dev->eq_table.alloc); |
519 | if (eq->eqn == -1) | 518 | if (eq->eqn == -1) |
520 | goto err_out_free; | 519 | goto err_out_free_pages; |
521 | 520 | ||
522 | err = mthca_mr_alloc_phys(dev, dev->driver_pd.pd_num, | 521 | err = mthca_mr_alloc_phys(dev, dev->driver_pd.pd_num, |
523 | dma_list, PAGE_SHIFT, npages, | 522 | dma_list, PAGE_SHIFT, npages, |
@@ -548,7 +547,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, | |||
548 | eq_context->intr = intr; | 547 | eq_context->intr = intr; |
549 | eq_context->lkey = cpu_to_be32(eq->mr.ibmr.lkey); | 548 | eq_context->lkey = cpu_to_be32(eq->mr.ibmr.lkey); |
550 | 549 | ||
551 | err = mthca_SW2HW_EQ(dev, eq_context, eq->eqn, &status); | 550 | err = mthca_SW2HW_EQ(dev, mailbox, eq->eqn, &status); |
552 | if (err) { | 551 | if (err) { |
553 | mthca_warn(dev, "SW2HW_EQ failed (%d)\n", err); | 552 | mthca_warn(dev, "SW2HW_EQ failed (%d)\n", err); |
554 | goto err_out_free_mr; | 553 | goto err_out_free_mr; |
@@ -561,7 +560,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, | |||
561 | } | 560 | } |
562 | 561 | ||
563 | kfree(dma_list); | 562 | kfree(dma_list); |
564 | kfree(mailbox); | 563 | mthca_free_mailbox(dev, mailbox); |
565 | 564 | ||
566 | eq->eqn_mask = swab32(1 << eq->eqn); | 565 | eq->eqn_mask = swab32(1 << eq->eqn); |
567 | eq->cons_index = 0; | 566 | eq->cons_index = 0; |
@@ -579,7 +578,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, | |||
579 | err_out_free_eq: | 578 | err_out_free_eq: |
580 | mthca_free(&dev->eq_table.alloc, eq->eqn); | 579 | mthca_free(&dev->eq_table.alloc, eq->eqn); |
581 | 580 | ||
582 | err_out_free: | 581 | err_out_free_pages: |
583 | for (i = 0; i < npages; ++i) | 582 | for (i = 0; i < npages; ++i) |
584 | if (eq->page_list[i].buf) | 583 | if (eq->page_list[i].buf) |
585 | dma_free_coherent(&dev->pdev->dev, PAGE_SIZE, | 584 | dma_free_coherent(&dev->pdev->dev, PAGE_SIZE, |
@@ -587,9 +586,11 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, | |||
587 | pci_unmap_addr(&eq->page_list[i], | 586 | pci_unmap_addr(&eq->page_list[i], |
588 | mapping)); | 587 | mapping)); |
589 | 588 | ||
589 | mthca_free_mailbox(dev, mailbox); | ||
590 | |||
591 | err_out_free: | ||
590 | kfree(eq->page_list); | 592 | kfree(eq->page_list); |
591 | kfree(dma_list); | 593 | kfree(dma_list); |
592 | kfree(mailbox); | ||
593 | 594 | ||
594 | err_out: | 595 | err_out: |
595 | return err; | 596 | return err; |
@@ -598,20 +599,18 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, | |||
598 | static void mthca_free_eq(struct mthca_dev *dev, | 599 | static void mthca_free_eq(struct mthca_dev *dev, |
599 | struct mthca_eq *eq) | 600 | struct mthca_eq *eq) |
600 | { | 601 | { |
601 | void *mailbox = NULL; | 602 | struct mthca_mailbox *mailbox; |
602 | int err; | 603 | int err; |
603 | u8 status; | 604 | u8 status; |
604 | int npages = (eq->nent * MTHCA_EQ_ENTRY_SIZE + PAGE_SIZE - 1) / | 605 | int npages = (eq->nent * MTHCA_EQ_ENTRY_SIZE + PAGE_SIZE - 1) / |
605 | PAGE_SIZE; | 606 | PAGE_SIZE; |
606 | int i; | 607 | int i; |
607 | 608 | ||
608 | mailbox = kmalloc(sizeof (struct mthca_eq_context) + MTHCA_CMD_MAILBOX_EXTRA, | 609 | mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); |
609 | GFP_KERNEL); | 610 | if (IS_ERR(mailbox)) |
610 | if (!mailbox) | ||
611 | return; | 611 | return; |
612 | 612 | ||
613 | err = mthca_HW2SW_EQ(dev, MAILBOX_ALIGN(mailbox), | 613 | err = mthca_HW2SW_EQ(dev, mailbox, eq->eqn, &status); |
614 | eq->eqn, &status); | ||
615 | if (err) | 614 | if (err) |
616 | mthca_warn(dev, "HW2SW_EQ failed (%d)\n", err); | 615 | mthca_warn(dev, "HW2SW_EQ failed (%d)\n", err); |
617 | if (status) | 616 | if (status) |
@@ -624,7 +623,7 @@ static void mthca_free_eq(struct mthca_dev *dev, | |||
624 | for (i = 0; i < sizeof (struct mthca_eq_context) / 4; ++i) { | 623 | for (i = 0; i < sizeof (struct mthca_eq_context) / 4; ++i) { |
625 | if (i % 4 == 0) | 624 | if (i % 4 == 0) |
626 | printk("[%02x] ", i * 4); | 625 | printk("[%02x] ", i * 4); |
627 | printk(" %08x", be32_to_cpup(MAILBOX_ALIGN(mailbox) + i * 4)); | 626 | printk(" %08x", be32_to_cpup(mailbox->buf + i * 4)); |
628 | if ((i + 1) % 4 == 0) | 627 | if ((i + 1) % 4 == 0) |
629 | printk("\n"); | 628 | printk("\n"); |
630 | } | 629 | } |
@@ -637,7 +636,7 @@ static void mthca_free_eq(struct mthca_dev *dev, | |||
637 | pci_unmap_addr(&eq->page_list[i], mapping)); | 636 | pci_unmap_addr(&eq->page_list[i], mapping)); |
638 | 637 | ||
639 | kfree(eq->page_list); | 638 | kfree(eq->page_list); |
640 | kfree(mailbox); | 639 | mthca_free_mailbox(dev, mailbox); |
641 | } | 640 | } |
642 | 641 | ||
643 | static void mthca_free_irqs(struct mthca_dev *dev) | 642 | static void mthca_free_irqs(struct mthca_dev *dev) |