aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/i2o/iop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/message/i2o/iop.c')
-rw-r--r--drivers/message/i2o/iop.c85
1 files changed, 42 insertions, 43 deletions
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index a8c08f332da0..92752fb5b2d3 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -652,6 +652,44 @@ static int i2o_iop_activate(struct i2o_controller *c)
652 return i2o_hrt_get(c); 652 return i2o_hrt_get(c);
653}; 653};
654 654
655static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags)
656{
657 i2o_status_block *sb = c->status_block.virt;
658 struct resource *res = &c->mem_resource;
659 resource_size_t size, align;
660 int err;
661
662 res->name = c->pdev->bus->name;
663 res->flags = flags;
664 res->start = 0;
665 res->end = 0;
666 osm_info("%s: requires private memory resources.\n", c->name);
667
668 if (flags & IORESOURCE_MEM) {
669 size = sb->desired_mem_size;
670 align = 1 << 20; /* unspecified, use 1Mb and play safe */
671 } else {
672 size = sb->desired_io_size;
673 align = 1 << 12; /* unspecified, use 4Kb and play safe */
674 }
675
676 err = pci_bus_alloc_resource(c->pdev->bus, res, size, align, 0, 0,
677 NULL, NULL);
678 if (err < 0)
679 return;
680
681 if (flags & IORESOURCE_MEM) {
682 c->mem_alloc = 1;
683 sb->current_mem_size = resource_size(res);
684 sb->current_mem_base = res->start;
685 } else if (flags & IORESOURCE_IO) {
686 c->io_alloc = 1;
687 sb->current_io_size = resource_size(res);
688 sb->current_io_base = res->start;
689 }
690 osm_info("%s: allocated PCI space %pR\n", c->name, res);
691}
692
655/** 693/**
656 * i2o_iop_systab_set - Set the I2O System Table of the specified IOP 694 * i2o_iop_systab_set - Set the I2O System Table of the specified IOP
657 * @c: I2O controller to which the system table should be send 695 * @c: I2O controller to which the system table should be send
@@ -665,52 +703,13 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
665 struct i2o_message *msg; 703 struct i2o_message *msg;
666 i2o_status_block *sb = c->status_block.virt; 704 i2o_status_block *sb = c->status_block.virt;
667 struct device *dev = &c->pdev->dev; 705 struct device *dev = &c->pdev->dev;
668 struct resource *root;
669 int rc; 706 int rc;
670 707
671 if (sb->current_mem_size < sb->desired_mem_size) { 708 if (sb->current_mem_size < sb->desired_mem_size)
672 struct resource *res = &c->mem_resource; 709 i2o_res_alloc(c, IORESOURCE_MEM);
673 res->name = c->pdev->bus->name;
674 res->flags = IORESOURCE_MEM;
675 res->start = 0;
676 res->end = 0;
677 osm_info("%s: requires private memory resources.\n", c->name);
678 root = pci_find_parent_resource(c->pdev, res);
679 if (root == NULL)
680 osm_warn("%s: Can't find parent resource!\n", c->name);
681 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 */
682 NULL, NULL) >= 0) {
683 c->mem_alloc = 1;
684 sb->current_mem_size = resource_size(res);
685 sb->current_mem_base = res->start;
686 osm_info("%s: allocated %llu bytes of PCI memory at "
687 "0x%016llX.\n", c->name,
688 (unsigned long long)resource_size(res),
689 (unsigned long long)res->start);
690 }
691 }
692 710
693 if (sb->current_io_size < sb->desired_io_size) { 711 if (sb->current_io_size < sb->desired_io_size)
694 struct resource *res = &c->io_resource; 712 i2o_res_alloc(c, IORESOURCE_IO);
695 res->name = c->pdev->bus->name;
696 res->flags = IORESOURCE_IO;
697 res->start = 0;
698 res->end = 0;
699 osm_info("%s: requires private memory resources.\n", c->name);
700 root = pci_find_parent_resource(c->pdev, res);
701 if (root == NULL)
702 osm_warn("%s: Can't find parent resource!\n", c->name);
703 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 */
704 NULL, NULL) >= 0) {
705 c->io_alloc = 1;
706 sb->current_io_size = resource_size(res);
707 sb->current_mem_base = res->start;
708 osm_info("%s: allocated %llu bytes of PCI I/O at "
709 "0x%016llX.\n", c->name,
710 (unsigned long long)resource_size(res),
711 (unsigned long long)res->start);
712 }
713 }
714 713
715 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); 714 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
716 if (IS_ERR(msg)) 715 if (IS_ERR(msg))