ia64/linux-2.6.18-xen.hg

annotate arch/sparc64/kernel/ebus.c @ 897:329ea0ccb344

balloon: try harder to balloon up under memory pressure.

Currently if the balloon driver is unable to increase the guest's
reservation it assumes the failure was due to reaching its full
allocation, gives up on the ballooning operation and records the limit
it reached as the "hard limit". The driver will not try again until
the target is set again (even to the same value).

However it is possible that ballooning has in fact failed due to
memory pressure in the host and therefore it is desirable to keep
attempting to reach the target in case memory becomes available. The
most likely scenario is that some guests are ballooning down while
others are ballooning up and therefore there is temporary memory
pressure while things stabilise. You would not expect a well behaved
toolstack to ask a domain to balloon to more than its allocation nor
would you expect it to deliberately over-commit memory by setting
balloon targets which exceed the total host memory.

This patch drops the concept of a hard limit and causes the balloon
driver to retry increasing the reservation on a timer in the same
manner as when decreasing the reservation.

Also if we partially succeed in increasing the reservation
(i.e. receive less pages than we asked for) then we may as well keep
those pages rather than returning them to Xen.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 14:01:20 2009 +0100 (2009-06-05)
parents 831230e53067
children
rev   line source
ian@0 1 /* $Id: ebus.c,v 1.64 2001/11/08 04:41:33 davem Exp $
ian@0 2 * ebus.c: PCI to EBus bridge device.
ian@0 3 *
ian@0 4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
ian@0 5 * Copyright (C) 1999 David S. Miller (davem@redhat.com)
ian@0 6 */
ian@0 7
ian@0 8 #include <linux/module.h>
ian@0 9 #include <linux/kernel.h>
ian@0 10 #include <linux/types.h>
ian@0 11 #include <linux/init.h>
ian@0 12 #include <linux/slab.h>
ian@0 13 #include <linux/string.h>
ian@0 14 #include <linux/interrupt.h>
ian@0 15 #include <linux/delay.h>
ian@0 16
ian@0 17 #include <asm/system.h>
ian@0 18 #include <asm/page.h>
ian@0 19 #include <asm/pbm.h>
ian@0 20 #include <asm/ebus.h>
ian@0 21 #include <asm/oplib.h>
ian@0 22 #include <asm/prom.h>
ian@0 23 #include <asm/of_device.h>
ian@0 24 #include <asm/bpp.h>
ian@0 25 #include <asm/irq.h>
ian@0 26
ian@0 27 /* EBUS dma library. */
ian@0 28
ian@0 29 #define EBDMA_CSR 0x00UL /* Control/Status */
ian@0 30 #define EBDMA_ADDR 0x04UL /* DMA Address */
ian@0 31 #define EBDMA_COUNT 0x08UL /* DMA Count */
ian@0 32
ian@0 33 #define EBDMA_CSR_INT_PEND 0x00000001
ian@0 34 #define EBDMA_CSR_ERR_PEND 0x00000002
ian@0 35 #define EBDMA_CSR_DRAIN 0x00000004
ian@0 36 #define EBDMA_CSR_INT_EN 0x00000010
ian@0 37 #define EBDMA_CSR_RESET 0x00000080
ian@0 38 #define EBDMA_CSR_WRITE 0x00000100
ian@0 39 #define EBDMA_CSR_EN_DMA 0x00000200
ian@0 40 #define EBDMA_CSR_CYC_PEND 0x00000400
ian@0 41 #define EBDMA_CSR_DIAG_RD_DONE 0x00000800
ian@0 42 #define EBDMA_CSR_DIAG_WR_DONE 0x00001000
ian@0 43 #define EBDMA_CSR_EN_CNT 0x00002000
ian@0 44 #define EBDMA_CSR_TC 0x00004000
ian@0 45 #define EBDMA_CSR_DIS_CSR_DRN 0x00010000
ian@0 46 #define EBDMA_CSR_BURST_SZ_MASK 0x000c0000
ian@0 47 #define EBDMA_CSR_BURST_SZ_1 0x00080000
ian@0 48 #define EBDMA_CSR_BURST_SZ_4 0x00000000
ian@0 49 #define EBDMA_CSR_BURST_SZ_8 0x00040000
ian@0 50 #define EBDMA_CSR_BURST_SZ_16 0x000c0000
ian@0 51 #define EBDMA_CSR_DIAG_EN 0x00100000
ian@0 52 #define EBDMA_CSR_DIS_ERR_PEND 0x00400000
ian@0 53 #define EBDMA_CSR_TCI_DIS 0x00800000
ian@0 54 #define EBDMA_CSR_EN_NEXT 0x01000000
ian@0 55 #define EBDMA_CSR_DMA_ON 0x02000000
ian@0 56 #define EBDMA_CSR_A_LOADED 0x04000000
ian@0 57 #define EBDMA_CSR_NA_LOADED 0x08000000
ian@0 58 #define EBDMA_CSR_DEV_ID_MASK 0xf0000000
ian@0 59
ian@0 60 #define EBUS_DMA_RESET_TIMEOUT 10000
ian@0 61
ian@0 62 static void __ebus_dma_reset(struct ebus_dma_info *p, int no_drain)
ian@0 63 {
ian@0 64 int i;
ian@0 65 u32 val = 0;
ian@0 66
ian@0 67 writel(EBDMA_CSR_RESET, p->regs + EBDMA_CSR);
ian@0 68 udelay(1);
ian@0 69
ian@0 70 if (no_drain)
ian@0 71 return;
ian@0 72
ian@0 73 for (i = EBUS_DMA_RESET_TIMEOUT; i > 0; i--) {
ian@0 74 val = readl(p->regs + EBDMA_CSR);
ian@0 75
ian@0 76 if (!(val & (EBDMA_CSR_DRAIN | EBDMA_CSR_CYC_PEND)))
ian@0 77 break;
ian@0 78 udelay(10);
ian@0 79 }
ian@0 80 }
ian@0 81
ian@0 82 static irqreturn_t ebus_dma_irq(int irq, void *dev_id, struct pt_regs *regs)
ian@0 83 {
ian@0 84 struct ebus_dma_info *p = dev_id;
ian@0 85 unsigned long flags;
ian@0 86 u32 csr = 0;
ian@0 87
ian@0 88 spin_lock_irqsave(&p->lock, flags);
ian@0 89 csr = readl(p->regs + EBDMA_CSR);
ian@0 90 writel(csr, p->regs + EBDMA_CSR);
ian@0 91 spin_unlock_irqrestore(&p->lock, flags);
ian@0 92
ian@0 93 if (csr & EBDMA_CSR_ERR_PEND) {
ian@0 94 printk(KERN_CRIT "ebus_dma(%s): DMA error!\n", p->name);
ian@0 95 p->callback(p, EBUS_DMA_EVENT_ERROR, p->client_cookie);
ian@0 96 return IRQ_HANDLED;
ian@0 97 } else if (csr & EBDMA_CSR_INT_PEND) {
ian@0 98 p->callback(p,
ian@0 99 (csr & EBDMA_CSR_TC) ?
ian@0 100 EBUS_DMA_EVENT_DMA : EBUS_DMA_EVENT_DEVICE,
ian@0 101 p->client_cookie);
ian@0 102 return IRQ_HANDLED;
ian@0 103 }
ian@0 104
ian@0 105 return IRQ_NONE;
ian@0 106
ian@0 107 }
ian@0 108
ian@0 109 int ebus_dma_register(struct ebus_dma_info *p)
ian@0 110 {
ian@0 111 u32 csr;
ian@0 112
ian@0 113 if (!p->regs)
ian@0 114 return -EINVAL;
ian@0 115 if (p->flags & ~(EBUS_DMA_FLAG_USE_EBDMA_HANDLER |
ian@0 116 EBUS_DMA_FLAG_TCI_DISABLE))
ian@0 117 return -EINVAL;
ian@0 118 if ((p->flags & EBUS_DMA_FLAG_USE_EBDMA_HANDLER) && !p->callback)
ian@0 119 return -EINVAL;
ian@0 120 if (!strlen(p->name))
ian@0 121 return -EINVAL;
ian@0 122
ian@0 123 __ebus_dma_reset(p, 1);
ian@0 124
ian@0 125 csr = EBDMA_CSR_BURST_SZ_16 | EBDMA_CSR_EN_CNT;
ian@0 126
ian@0 127 if (p->flags & EBUS_DMA_FLAG_TCI_DISABLE)
ian@0 128 csr |= EBDMA_CSR_TCI_DIS;
ian@0 129
ian@0 130 writel(csr, p->regs + EBDMA_CSR);
ian@0 131
ian@0 132 return 0;
ian@0 133 }
ian@0 134 EXPORT_SYMBOL(ebus_dma_register);
ian@0 135
ian@0 136 int ebus_dma_irq_enable(struct ebus_dma_info *p, int on)
ian@0 137 {
ian@0 138 unsigned long flags;
ian@0 139 u32 csr;
ian@0 140
ian@0 141 if (on) {
ian@0 142 if (p->flags & EBUS_DMA_FLAG_USE_EBDMA_HANDLER) {
ian@0 143 if (request_irq(p->irq, ebus_dma_irq, IRQF_SHARED, p->name, p))
ian@0 144 return -EBUSY;
ian@0 145 }
ian@0 146
ian@0 147 spin_lock_irqsave(&p->lock, flags);
ian@0 148 csr = readl(p->regs + EBDMA_CSR);
ian@0 149 csr |= EBDMA_CSR_INT_EN;
ian@0 150 writel(csr, p->regs + EBDMA_CSR);
ian@0 151 spin_unlock_irqrestore(&p->lock, flags);
ian@0 152 } else {
ian@0 153 spin_lock_irqsave(&p->lock, flags);
ian@0 154 csr = readl(p->regs + EBDMA_CSR);
ian@0 155 csr &= ~EBDMA_CSR_INT_EN;
ian@0 156 writel(csr, p->regs + EBDMA_CSR);
ian@0 157 spin_unlock_irqrestore(&p->lock, flags);
ian@0 158
ian@0 159 if (p->flags & EBUS_DMA_FLAG_USE_EBDMA_HANDLER) {
ian@0 160 free_irq(p->irq, p);
ian@0 161 }
ian@0 162 }
ian@0 163
ian@0 164 return 0;
ian@0 165 }
ian@0 166 EXPORT_SYMBOL(ebus_dma_irq_enable);
ian@0 167
ian@0 168 void ebus_dma_unregister(struct ebus_dma_info *p)
ian@0 169 {
ian@0 170 unsigned long flags;
ian@0 171 u32 csr;
ian@0 172 int irq_on = 0;
ian@0 173
ian@0 174 spin_lock_irqsave(&p->lock, flags);
ian@0 175 csr = readl(p->regs + EBDMA_CSR);
ian@0 176 if (csr & EBDMA_CSR_INT_EN) {
ian@0 177 csr &= ~EBDMA_CSR_INT_EN;
ian@0 178 writel(csr, p->regs + EBDMA_CSR);
ian@0 179 irq_on = 1;
ian@0 180 }
ian@0 181 spin_unlock_irqrestore(&p->lock, flags);
ian@0 182
ian@0 183 if (irq_on)
ian@0 184 free_irq(p->irq, p);
ian@0 185 }
ian@0 186 EXPORT_SYMBOL(ebus_dma_unregister);
ian@0 187
ian@0 188 int ebus_dma_request(struct ebus_dma_info *p, dma_addr_t bus_addr, size_t len)
ian@0 189 {
ian@0 190 unsigned long flags;
ian@0 191 u32 csr;
ian@0 192 int err;
ian@0 193
ian@0 194 if (len >= (1 << 24))
ian@0 195 return -EINVAL;
ian@0 196
ian@0 197 spin_lock_irqsave(&p->lock, flags);
ian@0 198 csr = readl(p->regs + EBDMA_CSR);
ian@0 199 err = -EINVAL;
ian@0 200 if (!(csr & EBDMA_CSR_EN_DMA))
ian@0 201 goto out;
ian@0 202 err = -EBUSY;
ian@0 203 if (csr & EBDMA_CSR_NA_LOADED)
ian@0 204 goto out;
ian@0 205
ian@0 206 writel(len, p->regs + EBDMA_COUNT);
ian@0 207 writel(bus_addr, p->regs + EBDMA_ADDR);
ian@0 208 err = 0;
ian@0 209
ian@0 210 out:
ian@0 211 spin_unlock_irqrestore(&p->lock, flags);
ian@0 212
ian@0 213 return err;
ian@0 214 }
ian@0 215 EXPORT_SYMBOL(ebus_dma_request);
ian@0 216
ian@0 217 void ebus_dma_prepare(struct ebus_dma_info *p, int write)
ian@0 218 {
ian@0 219 unsigned long flags;
ian@0 220 u32 csr;
ian@0 221
ian@0 222 spin_lock_irqsave(&p->lock, flags);
ian@0 223 __ebus_dma_reset(p, 0);
ian@0 224
ian@0 225 csr = (EBDMA_CSR_INT_EN |
ian@0 226 EBDMA_CSR_EN_CNT |
ian@0 227 EBDMA_CSR_BURST_SZ_16 |
ian@0 228 EBDMA_CSR_EN_NEXT);
ian@0 229
ian@0 230 if (write)
ian@0 231 csr |= EBDMA_CSR_WRITE;
ian@0 232 if (p->flags & EBUS_DMA_FLAG_TCI_DISABLE)
ian@0 233 csr |= EBDMA_CSR_TCI_DIS;
ian@0 234
ian@0 235 writel(csr, p->regs + EBDMA_CSR);
ian@0 236
ian@0 237 spin_unlock_irqrestore(&p->lock, flags);
ian@0 238 }
ian@0 239 EXPORT_SYMBOL(ebus_dma_prepare);
ian@0 240
ian@0 241 unsigned int ebus_dma_residue(struct ebus_dma_info *p)
ian@0 242 {
ian@0 243 return readl(p->regs + EBDMA_COUNT);
ian@0 244 }
ian@0 245 EXPORT_SYMBOL(ebus_dma_residue);
ian@0 246
ian@0 247 unsigned int ebus_dma_addr(struct ebus_dma_info *p)
ian@0 248 {
ian@0 249 return readl(p->regs + EBDMA_ADDR);
ian@0 250 }
ian@0 251 EXPORT_SYMBOL(ebus_dma_addr);
ian@0 252
ian@0 253 void ebus_dma_enable(struct ebus_dma_info *p, int on)
ian@0 254 {
ian@0 255 unsigned long flags;
ian@0 256 u32 orig_csr, csr;
ian@0 257
ian@0 258 spin_lock_irqsave(&p->lock, flags);
ian@0 259 orig_csr = csr = readl(p->regs + EBDMA_CSR);
ian@0 260 if (on)
ian@0 261 csr |= EBDMA_CSR_EN_DMA;
ian@0 262 else
ian@0 263 csr &= ~EBDMA_CSR_EN_DMA;
ian@0 264 if ((orig_csr & EBDMA_CSR_EN_DMA) !=
ian@0 265 (csr & EBDMA_CSR_EN_DMA))
ian@0 266 writel(csr, p->regs + EBDMA_CSR);
ian@0 267 spin_unlock_irqrestore(&p->lock, flags);
ian@0 268 }
ian@0 269 EXPORT_SYMBOL(ebus_dma_enable);
ian@0 270
ian@0 271 struct linux_ebus *ebus_chain = NULL;
ian@0 272
ian@0 273 static inline void *ebus_alloc(size_t size)
ian@0 274 {
ian@0 275 void *mem;
ian@0 276
ian@0 277 mem = kzalloc(size, GFP_ATOMIC);
ian@0 278 if (!mem)
ian@0 279 panic("ebus_alloc: out of memory");
ian@0 280 return mem;
ian@0 281 }
ian@0 282
ian@0 283 static void __init fill_ebus_child(struct device_node *dp,
ian@0 284 struct linux_ebus_child *dev,
ian@0 285 int non_standard_regs)
ian@0 286 {
ian@0 287 struct of_device *op;
ian@0 288 int *regs;
ian@0 289 int i, len;
ian@0 290
ian@0 291 dev->prom_node = dp;
ian@0 292 printk(" (%s)", dp->name);
ian@0 293
ian@0 294 regs = of_get_property(dp, "reg", &len);
ian@0 295 if (!regs)
ian@0 296 dev->num_addrs = 0;
ian@0 297 else
ian@0 298 dev->num_addrs = len / sizeof(regs[0]);
ian@0 299
ian@0 300 if (non_standard_regs) {
ian@0 301 /* This is to handle reg properties which are not
ian@0 302 * in the parent relative format. One example are
ian@0 303 * children of the i2c device on CompactPCI systems.
ian@0 304 *
ian@0 305 * So, for such devices we just record the property
ian@0 306 * raw in the child resources.
ian@0 307 */
ian@0 308 for (i = 0; i < dev->num_addrs; i++)
ian@0 309 dev->resource[i].start = regs[i];
ian@0 310 } else {
ian@0 311 for (i = 0; i < dev->num_addrs; i++) {
ian@0 312 int rnum = regs[i];
ian@0 313 if (rnum >= dev->parent->num_addrs) {
ian@0 314 prom_printf("UGH: property for %s was %d, need < %d\n",
ian@0 315 dp->name, len, dev->parent->num_addrs);
ian@0 316 prom_halt();
ian@0 317 }
ian@0 318 dev->resource[i].start = dev->parent->resource[i].start;
ian@0 319 dev->resource[i].end = dev->parent->resource[i].end;
ian@0 320 dev->resource[i].flags = IORESOURCE_MEM;
ian@0 321 dev->resource[i].name = dp->name;
ian@0 322 }
ian@0 323 }
ian@0 324
ian@0 325 op = of_find_device_by_node(dp);
ian@0 326 if (!op) {
ian@0 327 dev->num_irqs = 0;
ian@0 328 } else {
ian@0 329 dev->num_irqs = op->num_irqs;
ian@0 330 for (i = 0; i < dev->num_irqs; i++)
ian@0 331 dev->irqs[i] = op->irqs[i];
ian@0 332 }
ian@0 333
ian@0 334 if (!dev->num_irqs) {
ian@0 335 /*
ian@0 336 * Oh, well, some PROMs don't export interrupts
ian@0 337 * property to children of EBus devices...
ian@0 338 *
ian@0 339 * Be smart about PS/2 keyboard and mouse.
ian@0 340 */
ian@0 341 if (!strcmp(dev->parent->prom_node->name, "8042")) {
ian@0 342 if (!strcmp(dev->prom_node->name, "kb_ps2")) {
ian@0 343 dev->num_irqs = 1;
ian@0 344 dev->irqs[0] = dev->parent->irqs[0];
ian@0 345 } else {
ian@0 346 dev->num_irqs = 1;
ian@0 347 dev->irqs[0] = dev->parent->irqs[1];
ian@0 348 }
ian@0 349 }
ian@0 350 }
ian@0 351 }
ian@0 352
ian@0 353 static int __init child_regs_nonstandard(struct linux_ebus_device *dev)
ian@0 354 {
ian@0 355 if (!strcmp(dev->prom_node->name, "i2c") ||
ian@0 356 !strcmp(dev->prom_node->name, "SUNW,lombus"))
ian@0 357 return 1;
ian@0 358 return 0;
ian@0 359 }
ian@0 360
ian@0 361 static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev)
ian@0 362 {
ian@0 363 struct linux_ebus_child *child;
ian@0 364 struct of_device *op;
ian@0 365 int i, len;
ian@0 366
ian@0 367 dev->prom_node = dp;
ian@0 368
ian@0 369 printk(" [%s", dp->name);
ian@0 370
ian@0 371 op = of_find_device_by_node(dp);
ian@0 372 if (!op) {
ian@0 373 dev->num_addrs = 0;
ian@0 374 dev->num_irqs = 0;
ian@0 375 } else {
ian@0 376 (void) of_get_property(dp, "reg", &len);
ian@0 377 dev->num_addrs = len / sizeof(struct linux_prom_registers);
ian@0 378
ian@0 379 for (i = 0; i < dev->num_addrs; i++)
ian@0 380 memcpy(&dev->resource[i],
ian@0 381 &op->resource[i],
ian@0 382 sizeof(struct resource));
ian@0 383
ian@0 384 dev->num_irqs = op->num_irqs;
ian@0 385 for (i = 0; i < dev->num_irqs; i++)
ian@0 386 dev->irqs[i] = op->irqs[i];
ian@0 387 }
ian@0 388
ian@0 389 dev->ofdev.node = dp;
ian@0 390 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
ian@0 391 dev->ofdev.dev.bus = &ebus_bus_type;
ian@0 392 strcpy(dev->ofdev.dev.bus_id, dp->path_component_name);
ian@0 393
ian@0 394 /* Register with core */
ian@0 395 if (of_device_register(&dev->ofdev) != 0)
ian@0 396 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
ian@0 397 dev->ofdev.dev.bus_id);
ian@0 398
ian@0 399 dp = dp->child;
ian@0 400 if (dp) {
ian@0 401 printk(" ->");
ian@0 402 dev->children = ebus_alloc(sizeof(struct linux_ebus_child));
ian@0 403
ian@0 404 child = dev->children;
ian@0 405 child->next = NULL;
ian@0 406 child->parent = dev;
ian@0 407 child->bus = dev->bus;
ian@0 408 fill_ebus_child(dp, child,
ian@0 409 child_regs_nonstandard(dev));
ian@0 410
ian@0 411 while ((dp = dp->sibling) != NULL) {
ian@0 412 child->next = ebus_alloc(sizeof(struct linux_ebus_child));
ian@0 413
ian@0 414 child = child->next;
ian@0 415 child->next = NULL;
ian@0 416 child->parent = dev;
ian@0 417 child->bus = dev->bus;
ian@0 418 fill_ebus_child(dp, child,
ian@0 419 child_regs_nonstandard(dev));
ian@0 420 }
ian@0 421 }
ian@0 422 printk("]");
ian@0 423 }
ian@0 424
ian@0 425 static struct pci_dev *find_next_ebus(struct pci_dev *start, int *is_rio_p)
ian@0 426 {
ian@0 427 struct pci_dev *pdev = start;
ian@0 428
ian@0 429 while ((pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev)))
ian@0 430 if (pdev->device == PCI_DEVICE_ID_SUN_EBUS ||
ian@0 431 pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)
ian@0 432 break;
ian@0 433
ian@0 434 *is_rio_p = !!(pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS));
ian@0 435
ian@0 436 return pdev;
ian@0 437 }
ian@0 438
ian@0 439 void __init ebus_init(void)
ian@0 440 {
ian@0 441 struct pci_pbm_info *pbm;
ian@0 442 struct linux_ebus_device *dev;
ian@0 443 struct linux_ebus *ebus;
ian@0 444 struct pci_dev *pdev;
ian@0 445 struct pcidev_cookie *cookie;
ian@0 446 struct device_node *dp;
ian@0 447 int is_rio;
ian@0 448 int num_ebus = 0;
ian@0 449
ian@0 450 pdev = find_next_ebus(NULL, &is_rio);
ian@0 451 if (!pdev) {
ian@0 452 printk("ebus: No EBus's found.\n");
ian@0 453 return;
ian@0 454 }
ian@0 455
ian@0 456 cookie = pdev->sysdata;
ian@0 457 dp = cookie->prom_node;
ian@0 458
ian@0 459 ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus));
ian@0 460 ebus->next = NULL;
ian@0 461 ebus->is_rio = is_rio;
ian@0 462
ian@0 463 while (dp) {
ian@0 464 struct device_node *child;
ian@0 465
ian@0 466 /* SUNW,pci-qfe uses four empty ebuses on it.
ian@0 467 I think we should not consider them here,
ian@0 468 as they have half of the properties this
ian@0 469 code expects and once we do PCI hot-plug,
ian@0 470 we'd have to tweak with the ebus_chain
ian@0 471 in the runtime after initialization. -jj */
ian@0 472 if (!dp->child) {
ian@0 473 pdev = find_next_ebus(pdev, &is_rio);
ian@0 474 if (!pdev) {
ian@0 475 if (ebus == ebus_chain) {
ian@0 476 ebus_chain = NULL;
ian@0 477 printk("ebus: No EBus's found.\n");
ian@0 478 return;
ian@0 479 }
ian@0 480 break;
ian@0 481 }
ian@0 482 ebus->is_rio = is_rio;
ian@0 483 cookie = pdev->sysdata;
ian@0 484 dp = cookie->prom_node;
ian@0 485 continue;
ian@0 486 }
ian@0 487 printk("ebus%d:", num_ebus);
ian@0 488
ian@0 489 ebus->index = num_ebus;
ian@0 490 ebus->prom_node = dp;
ian@0 491 ebus->self = pdev;
ian@0 492 ebus->parent = pbm = cookie->pbm;
ian@0 493
ian@0 494 ebus->ofdev.node = dp;
ian@0 495 ebus->ofdev.dev.parent = &pdev->dev;
ian@0 496 ebus->ofdev.dev.bus = &ebus_bus_type;
ian@0 497 strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name);
ian@0 498
ian@0 499 /* Register with core */
ian@0 500 if (of_device_register(&ebus->ofdev) != 0)
ian@0 501 printk(KERN_DEBUG "ebus: device registration error for %s!\n",
ian@0 502 ebus->ofdev.dev.bus_id);
ian@0 503
ian@0 504
ian@0 505 child = dp->child;
ian@0 506 if (!child)
ian@0 507 goto next_ebus;
ian@0 508
ian@0 509 ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device));
ian@0 510
ian@0 511 dev = ebus->devices;
ian@0 512 dev->next = NULL;
ian@0 513 dev->children = NULL;
ian@0 514 dev->bus = ebus;
ian@0 515 fill_ebus_device(child, dev);
ian@0 516
ian@0 517 while ((child = child->sibling) != NULL) {
ian@0 518 dev->next = ebus_alloc(sizeof(struct linux_ebus_device));
ian@0 519
ian@0 520 dev = dev->next;
ian@0 521 dev->next = NULL;
ian@0 522 dev->children = NULL;
ian@0 523 dev->bus = ebus;
ian@0 524 fill_ebus_device(child, dev);
ian@0 525 }
ian@0 526
ian@0 527 next_ebus:
ian@0 528 printk("\n");
ian@0 529
ian@0 530 pdev = find_next_ebus(pdev, &is_rio);
ian@0 531 if (!pdev)
ian@0 532 break;
ian@0 533
ian@0 534 cookie = pdev->sysdata;
ian@0 535 dp = cookie->prom_node;
ian@0 536
ian@0 537 ebus->next = ebus_alloc(sizeof(struct linux_ebus));
ian@0 538 ebus = ebus->next;
ian@0 539 ebus->next = NULL;
ian@0 540 ebus->is_rio = is_rio;
ian@0 541 ++num_ebus;
ian@0 542 }
ian@0 543 pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */
ian@0 544 }