1 /* 2 * QEMU SPAPR Dynamic Reconfiguration Connector Implementation 3 * 4 * Copyright IBM Corp. 2014 5 * 6 * Authors: 7 * Michael Roth <mdroth@linux.vnet.ibm.com> 8 * 9 * This work is licensed under the terms of the GNU GPL, version 2 or later. 10 * See the COPYING file in the top-level directory. 11 */ 12 13 #include "qemu/osdep.h" 14 #include "qapi/error.h" 15 #include "cpu.h" 16 #include "qemu/cutils.h" 17 #include "hw/ppc/spapr_drc.h" 18 #include "qom/object.h" 19 #include "hw/qdev.h" 20 #include "qapi/visitor.h" 21 #include "qemu/error-report.h" 22 #include "hw/ppc/spapr.h" /* for RTAS return codes */ 23 #include "hw/pci-host/spapr.h" /* spapr_phb_remove_pci_device_cb callback */ 24 #include "trace.h" 25 26 #define DRC_CONTAINER_PATH "/dr-connector" 27 #define DRC_INDEX_TYPE_SHIFT 28 28 #define DRC_INDEX_ID_MASK ((1ULL << DRC_INDEX_TYPE_SHIFT) - 1) 29 30 static sPAPRConfigureConnectorState *spapr_ccs_find(sPAPRMachineState *spapr, 31 uint32_t drc_index) 32 { 33 sPAPRConfigureConnectorState *ccs = NULL; 34 35 QTAILQ_FOREACH(ccs, &spapr->ccs_list, next) { 36 if (ccs->drc_index == drc_index) { 37 break; 38 } 39 } 40 41 return ccs; 42 } 43 44 static void spapr_ccs_add(sPAPRMachineState *spapr, 45 sPAPRConfigureConnectorState *ccs) 46 { 47 g_assert(!spapr_ccs_find(spapr, ccs->drc_index)); 48 QTAILQ_INSERT_HEAD(&spapr->ccs_list, ccs, next); 49 } 50 51 static void spapr_ccs_remove(sPAPRMachineState *spapr, 52 sPAPRConfigureConnectorState *ccs) 53 { 54 QTAILQ_REMOVE(&spapr->ccs_list, ccs, next); 55 g_free(ccs); 56 } 57 58 static sPAPRDRConnectorTypeShift get_type_shift(sPAPRDRConnectorType type) 59 { 60 uint32_t shift = 0; 61 62 /* make sure this isn't SPAPR_DR_CONNECTOR_TYPE_ANY, or some 63 * other wonky value. 64 */ 65 g_assert(is_power_of_2(type)); 66 67 while (type != (1 << shift)) { 68 shift++; 69 } 70 return shift; 71 } 72 73 uint32_t spapr_drc_index(sPAPRDRConnector *drc) 74 { 75 /* no set format for a drc index: it only needs to be globally 76 * unique. this is how we encode the DRC type on bare-metal 77 * however, so might as well do that here 78 */ 79 return (get_type_shift(drc->type) << DRC_INDEX_TYPE_SHIFT) | 80 (drc->id & DRC_INDEX_ID_MASK); 81 } 82 83 static uint32_t set_isolation_state(sPAPRDRConnector *drc, 84 sPAPRDRIsolationState state) 85 { 86 sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); 87 88 trace_spapr_drc_set_isolation_state(spapr_drc_index(drc), state); 89 90 if (state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) { 91 /* cannot unisolate a non-existent resource, and, or resources 92 * which are in an 'UNUSABLE' allocation state. (PAPR 2.7, 13.5.3.5) 93 */ 94 if (!drc->dev || 95 drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) { 96 return RTAS_OUT_NO_SUCH_INDICATOR; 97 } 98 } 99 100 /* 101 * Fail any requests to ISOLATE the LMB DRC if this LMB doesn't 102 * belong to a DIMM device that is marked for removal. 103 * 104 * Currently the guest userspace tool drmgr that drives the memory 105 * hotplug/unplug will just try to remove a set of 'removable' LMBs 106 * in response to a hot unplug request that is based on drc-count. 107 * If the LMB being removed doesn't belong to a DIMM device that is 108 * actually being unplugged, fail the isolation request here. 109 */ 110 if (drc->type == SPAPR_DR_CONNECTOR_TYPE_LMB) { 111 if ((state == SPAPR_DR_ISOLATION_STATE_ISOLATED) && 112 !drc->awaiting_release) { 113 return RTAS_OUT_HW_ERROR; 114 } 115 } 116 117 drc->isolation_state = state; 118 119 if (drc->isolation_state == SPAPR_DR_ISOLATION_STATE_ISOLATED) { 120 /* if we're awaiting release, but still in an unconfigured state, 121 * it's likely the guest is still in the process of configuring 122 * the device and is transitioning the devices to an ISOLATED 123 * state as a part of that process. so we only complete the 124 * removal when this transition happens for a device in a 125 * configured state, as suggested by the state diagram from 126 * PAPR+ 2.7, 13.4 127 */ 128 if (drc->awaiting_release) { 129 uint32_t drc_index = spapr_drc_index(drc); 130 if (drc->configured) { 131 trace_spapr_drc_set_isolation_state_finalizing(drc_index); 132 drck->detach(drc, DEVICE(drc->dev), NULL); 133 } else { 134 trace_spapr_drc_set_isolation_state_deferring(drc_index); 135 } 136 } 137 drc->configured = false; 138 } 139 140 return RTAS_OUT_SUCCESS; 141 } 142 143 static uint32_t set_indicator_state(sPAPRDRConnector *drc, 144 sPAPRDRIndicatorState state) 145 { 146 trace_spapr_drc_set_indicator_state(spapr_drc_index(drc), state); 147 drc->indicator_state = state; 148 return RTAS_OUT_SUCCESS; 149 } 150 151 static uint32_t set_allocation_state(sPAPRDRConnector *drc, 152 sPAPRDRAllocationState state) 153 { 154 sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); 155 156 trace_spapr_drc_set_allocation_state(spapr_drc_index(drc), state); 157 158 if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) { 159 /* if there's no resource/device associated with the DRC, there's 160 * no way for us to put it in an allocation state consistent with 161 * being 'USABLE'. PAPR 2.7, 13.5.3.4 documents that this should 162 * result in an RTAS return code of -3 / "no such indicator" 163 */ 164 if (!drc->dev) { 165 return RTAS_OUT_NO_SUCH_INDICATOR; 166 } 167 if (drc->awaiting_release && drc->awaiting_allocation) { 168 /* kernel is acknowledging a previous hotplug event 169 * while we are already removing it. 170 * it's safe to ignore awaiting_allocation here since we know the 171 * situation is predicated on the guest either already having done 172 * so (boot-time hotplug), or never being able to acquire in the 173 * first place (hotplug followed by immediate unplug). 174 */ 175 drc->awaiting_allocation_skippable = true; 176 return RTAS_OUT_NO_SUCH_INDICATOR; 177 } 178 } 179 180 if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) { 181 drc->allocation_state = state; 182 if (drc->awaiting_release && 183 drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) { 184 uint32_t drc_index = spapr_drc_index(drc); 185 trace_spapr_drc_set_allocation_state_finalizing(drc_index); 186 drck->detach(drc, DEVICE(drc->dev), NULL); 187 } else if (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) { 188 drc->awaiting_allocation = false; 189 } 190 } 191 return RTAS_OUT_SUCCESS; 192 } 193 194 sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc) 195 { 196 return drc->type; 197 } 198 199 static const char *get_name(sPAPRDRConnector *drc) 200 { 201 return drc->name; 202 } 203 204 /* has the guest been notified of device attachment? */ 205 static void set_signalled(sPAPRDRConnector *drc) 206 { 207 drc->signalled = true; 208 } 209 210 /* 211 * dr-entity-sense sensor value 212 * returned via get-sensor-state RTAS calls 213 * as expected by state diagram in PAPR+ 2.7, 13.4 214 * based on the current allocation/indicator/power states 215 * for the DR connector. 216 */ 217 static uint32_t entity_sense(sPAPRDRConnector *drc, sPAPRDREntitySense *state) 218 { 219 if (drc->dev) { 220 if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI && 221 drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) { 222 /* for logical DR, we return a state of UNUSABLE 223 * iff the allocation state UNUSABLE. 224 * Otherwise, report the state as USABLE/PRESENT, 225 * as we would for PCI. 226 */ 227 *state = SPAPR_DR_ENTITY_SENSE_UNUSABLE; 228 } else { 229 /* this assumes all PCI devices are assigned to 230 * a 'live insertion' power domain, where QEMU 231 * manages power state automatically as opposed 232 * to the guest. present, non-PCI resources are 233 * unaffected by power state. 234 */ 235 *state = SPAPR_DR_ENTITY_SENSE_PRESENT; 236 } 237 } else { 238 if (drc->type == SPAPR_DR_CONNECTOR_TYPE_PCI) { 239 /* PCI devices, and only PCI devices, use EMPTY 240 * in cases where we'd otherwise use UNUSABLE 241 */ 242 *state = SPAPR_DR_ENTITY_SENSE_EMPTY; 243 } else { 244 *state = SPAPR_DR_ENTITY_SENSE_UNUSABLE; 245 } 246 } 247 248 trace_spapr_drc_entity_sense(spapr_drc_index(drc), *state); 249 return RTAS_OUT_SUCCESS; 250 } 251 252 static void prop_get_index(Object *obj, Visitor *v, const char *name, 253 void *opaque, Error **errp) 254 { 255 sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj); 256 uint32_t value = spapr_drc_index(drc); 257 visit_type_uint32(v, name, &value, errp); 258 } 259 260 static void prop_get_type(Object *obj, Visitor *v, const char *name, 261 void *opaque, Error **errp) 262 { 263 sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj); 264 uint32_t value = (uint32_t)spapr_drc_type(drc); 265 visit_type_uint32(v, name, &value, errp); 266 } 267 268 static char *prop_get_name(Object *obj, Error **errp) 269 { 270 sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj); 271 sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); 272 return g_strdup(drck->get_name(drc)); 273 } 274 275 static void prop_get_entity_sense(Object *obj, Visitor *v, const char *name, 276 void *opaque, Error **errp) 277 { 278 sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj); 279 sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); 280 uint32_t value; 281 282 drck->entity_sense(drc, &value); 283 visit_type_uint32(v, name, &value, errp); 284 } 285 286 static void prop_get_fdt(Object *obj, Visitor *v, const char *name, 287 void *opaque, Error **errp) 288 { 289 sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj); 290 Error *err = NULL; 291 int fdt_offset_next, fdt_offset, fdt_depth; 292 void *fdt; 293 294 if (!drc->fdt) { 295 visit_type_null(v, NULL, errp); 296 return; 297 } 298 299 fdt = drc->fdt; 300 fdt_offset = drc->fdt_start_offset; 301 fdt_depth = 0; 302 303 do { 304 const char *name = NULL; 305 const struct fdt_property *prop = NULL; 306 int prop_len = 0, name_len = 0; 307 uint32_t tag; 308 309 tag = fdt_next_tag(fdt, fdt_offset, &fdt_offset_next); 310 switch (tag) { 311 case FDT_BEGIN_NODE: 312 fdt_depth++; 313 name = fdt_get_name(fdt, fdt_offset, &name_len); 314 visit_start_struct(v, name, NULL, 0, &err); 315 if (err) { 316 error_propagate(errp, err); 317 return; 318 } 319 break; 320 case FDT_END_NODE: 321 /* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */ 322 g_assert(fdt_depth > 0); 323 visit_check_struct(v, &err); 324 visit_end_struct(v, NULL); 325 if (err) { 326 error_propagate(errp, err); 327 return; 328 } 329 fdt_depth--; 330 break; 331 case FDT_PROP: { 332 int i; 333 prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len); 334 name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); 335 visit_start_list(v, name, NULL, 0, &err); 336 if (err) { 337 error_propagate(errp, err); 338 return; 339 } 340 for (i = 0; i < prop_len; i++) { 341 visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], &err); 342 if (err) { 343 error_propagate(errp, err); 344 return; 345 } 346 } 347 visit_check_list(v, &err); 348 visit_end_list(v, NULL); 349 if (err) { 350 error_propagate(errp, err); 351 return; 352 } 353 break; 354 } 355 default: 356 error_setg(&error_abort, "device FDT in unexpected state: %d", tag); 357 } 358 fdt_offset = fdt_offset_next; 359 } while (fdt_depth != 0); 360 } 361 362 static void attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt, 363 int fdt_start_offset, bool coldplug, Error **errp) 364 { 365 trace_spapr_drc_attach(spapr_drc_index(drc)); 366 367 if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) { 368 error_setg(errp, "an attached device is still awaiting release"); 369 return; 370 } 371 if (drc->type == SPAPR_DR_CONNECTOR_TYPE_PCI) { 372 g_assert(drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE); 373 } 374 g_assert(fdt || coldplug); 375 376 /* NOTE: setting initial isolation state to UNISOLATED means we can't 377 * detach unless guest has a userspace/kernel that moves this state 378 * back to ISOLATED in response to an unplug event, or this is done 379 * manually by the admin prior. if we force things while the guest 380 * may be accessing the device, we can easily crash the guest, so we 381 * we defer completion of removal in such cases to the reset() hook. 382 */ 383 if (drc->type == SPAPR_DR_CONNECTOR_TYPE_PCI) { 384 drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED; 385 } 386 drc->indicator_state = SPAPR_DR_INDICATOR_STATE_ACTIVE; 387 388 drc->dev = d; 389 drc->fdt = fdt; 390 drc->fdt_start_offset = fdt_start_offset; 391 drc->configured = coldplug; 392 /* 'logical' DR resources such as memory/cpus are in some cases treated 393 * as a pool of resources from which the guest is free to choose from 394 * based on only a count. for resources that can be assigned in this 395 * fashion, we must assume the resource is signalled immediately 396 * since a single hotplug request might make an arbitrary number of 397 * such attached resources available to the guest, as opposed to 398 * 'physical' DR resources such as PCI where each device/resource is 399 * signalled individually. 400 */ 401 drc->signalled = (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) 402 ? true : coldplug; 403 404 if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) { 405 drc->awaiting_allocation = true; 406 } 407 408 object_property_add_link(OBJECT(drc), "device", 409 object_get_typename(OBJECT(drc->dev)), 410 (Object **)(&drc->dev), 411 NULL, 0, NULL); 412 } 413 414 static void detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp) 415 { 416 trace_spapr_drc_detach(spapr_drc_index(drc)); 417 418 /* if we've signalled device presence to the guest, or if the guest 419 * has gone ahead and configured the device (via manually-executed 420 * device add via drmgr in guest, namely), we need to wait 421 * for the guest to quiesce the device before completing detach. 422 * Otherwise, we can assume the guest hasn't seen it and complete the 423 * detach immediately. Note that there is a small race window 424 * just before, or during, configuration, which is this context 425 * refers mainly to fetching the device tree via RTAS. 426 * During this window the device access will be arbitrated by 427 * associated DRC, which will simply fail the RTAS calls as invalid. 428 * This is recoverable within guest and current implementations of 429 * drmgr should be able to cope. 430 */ 431 if (!drc->signalled && !drc->configured) { 432 /* if the guest hasn't seen the device we can't rely on it to 433 * set it back to an isolated state via RTAS, so do it here manually 434 */ 435 drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED; 436 } 437 438 if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) { 439 trace_spapr_drc_awaiting_isolated(spapr_drc_index(drc)); 440 drc->awaiting_release = true; 441 return; 442 } 443 444 if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI && 445 drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) { 446 trace_spapr_drc_awaiting_unusable(spapr_drc_index(drc)); 447 drc->awaiting_release = true; 448 return; 449 } 450 451 if (drc->awaiting_allocation) { 452 if (!drc->awaiting_allocation_skippable) { 453 drc->awaiting_release = true; 454 trace_spapr_drc_awaiting_allocation(spapr_drc_index(drc)); 455 return; 456 } 457 } 458 459 drc->indicator_state = SPAPR_DR_INDICATOR_STATE_INACTIVE; 460 461 /* Calling release callbacks based on drc->type. */ 462 switch (drc->type) { 463 case SPAPR_DR_CONNECTOR_TYPE_CPU: 464 spapr_core_release(drc->dev); 465 break; 466 case SPAPR_DR_CONNECTOR_TYPE_PCI: 467 spapr_phb_remove_pci_device_cb(drc->dev); 468 break; 469 case SPAPR_DR_CONNECTOR_TYPE_LMB: 470 spapr_lmb_release(drc->dev); 471 break; 472 case SPAPR_DR_CONNECTOR_TYPE_PHB: 473 case SPAPR_DR_CONNECTOR_TYPE_VIO: 474 default: 475 g_assert(false); 476 } 477 478 drc->awaiting_release = false; 479 drc->awaiting_allocation_skippable = false; 480 g_free(drc->fdt); 481 drc->fdt = NULL; 482 drc->fdt_start_offset = 0; 483 object_property_del(OBJECT(drc), "device", NULL); 484 drc->dev = NULL; 485 } 486 487 static bool release_pending(sPAPRDRConnector *drc) 488 { 489 return drc->awaiting_release; 490 } 491 492 static void reset(DeviceState *d) 493 { 494 sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d); 495 sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); 496 sPAPRDREntitySense state; 497 498 trace_spapr_drc_reset(spapr_drc_index(drc)); 499 /* immediately upon reset we can safely assume DRCs whose devices 500 * are pending removal can be safely removed, and that they will 501 * subsequently be left in an ISOLATED state. move the DRC to this 502 * state in these cases (which will in turn complete any pending 503 * device removals) 504 */ 505 if (drc->awaiting_release) { 506 drck->set_isolation_state(drc, SPAPR_DR_ISOLATION_STATE_ISOLATED); 507 /* generally this should also finalize the removal, but if the device 508 * hasn't yet been configured we normally defer removal under the 509 * assumption that this transition is taking place as part of device 510 * configuration. so check if we're still waiting after this, and 511 * force removal if we are 512 */ 513 if (drc->awaiting_release) { 514 drck->detach(drc, DEVICE(drc->dev), NULL); 515 } 516 517 /* non-PCI devices may be awaiting a transition to UNUSABLE */ 518 if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI && 519 drc->awaiting_release) { 520 drck->set_allocation_state(drc, SPAPR_DR_ALLOCATION_STATE_UNUSABLE); 521 } 522 } 523 524 drck->entity_sense(drc, &state); 525 if (state == SPAPR_DR_ENTITY_SENSE_PRESENT) { 526 drck->set_signalled(drc); 527 } 528 } 529 530 static bool spapr_drc_needed(void *opaque) 531 { 532 sPAPRDRConnector *drc = (sPAPRDRConnector *)opaque; 533 sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); 534 bool rc = false; 535 sPAPRDREntitySense value; 536 drck->entity_sense(drc, &value); 537 538 /* If no dev is plugged in there is no need to migrate the DRC state */ 539 if (value != SPAPR_DR_ENTITY_SENSE_PRESENT) { 540 return false; 541 } 542 543 /* 544 * If there is dev plugged in, we need to migrate the DRC state when 545 * it is different from cold-plugged state 546 */ 547 switch (drc->type) { 548 case SPAPR_DR_CONNECTOR_TYPE_PCI: 549 rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) && 550 (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) && 551 drc->configured && drc->signalled && !drc->awaiting_release); 552 break; 553 case SPAPR_DR_CONNECTOR_TYPE_CPU: 554 case SPAPR_DR_CONNECTOR_TYPE_LMB: 555 rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_ISOLATED) && 556 (drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) && 557 drc->configured && drc->signalled && !drc->awaiting_release); 558 break; 559 case SPAPR_DR_CONNECTOR_TYPE_PHB: 560 case SPAPR_DR_CONNECTOR_TYPE_VIO: 561 default: 562 g_assert(false); 563 } 564 return rc; 565 } 566 567 static const VMStateDescription vmstate_spapr_drc = { 568 .name = "spapr_drc", 569 .version_id = 1, 570 .minimum_version_id = 1, 571 .needed = spapr_drc_needed, 572 .fields = (VMStateField []) { 573 VMSTATE_UINT32(isolation_state, sPAPRDRConnector), 574 VMSTATE_UINT32(allocation_state, sPAPRDRConnector), 575 VMSTATE_UINT32(indicator_state, sPAPRDRConnector), 576 VMSTATE_BOOL(configured, sPAPRDRConnector), 577 VMSTATE_BOOL(awaiting_release, sPAPRDRConnector), 578 VMSTATE_BOOL(awaiting_allocation, sPAPRDRConnector), 579 VMSTATE_BOOL(signalled, sPAPRDRConnector), 580 VMSTATE_END_OF_LIST() 581 } 582 }; 583 584 static void realize(DeviceState *d, Error **errp) 585 { 586 sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d); 587 Object *root_container; 588 char link_name[256]; 589 gchar *child_name; 590 Error *err = NULL; 591 592 trace_spapr_drc_realize(spapr_drc_index(drc)); 593 /* NOTE: we do this as part of realize/unrealize due to the fact 594 * that the guest will communicate with the DRC via RTAS calls 595 * referencing the global DRC index. By unlinking the DRC 596 * from DRC_CONTAINER_PATH/<drc_index> we effectively make it 597 * inaccessible by the guest, since lookups rely on this path 598 * existing in the composition tree 599 */ 600 root_container = container_get(object_get_root(), DRC_CONTAINER_PATH); 601 snprintf(link_name, sizeof(link_name), "%x", spapr_drc_index(drc)); 602 child_name = object_get_canonical_path_component(OBJECT(drc)); 603 trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name); 604 object_property_add_alias(root_container, link_name, 605 drc->owner, child_name, &err); 606 if (err) { 607 error_report_err(err); 608 object_unref(OBJECT(drc)); 609 } 610 g_free(child_name); 611 vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc, 612 drc); 613 trace_spapr_drc_realize_complete(spapr_drc_index(drc)); 614 } 615 616 static void unrealize(DeviceState *d, Error **errp) 617 { 618 sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d); 619 Object *root_container; 620 char name[256]; 621 Error *err = NULL; 622 623 trace_spapr_drc_unrealize(spapr_drc_index(drc)); 624 root_container = container_get(object_get_root(), DRC_CONTAINER_PATH); 625 snprintf(name, sizeof(name), "%x", spapr_drc_index(drc)); 626 object_property_del(root_container, name, &err); 627 if (err) { 628 error_report_err(err); 629 object_unref(OBJECT(drc)); 630 } 631 } 632 633 sPAPRDRConnector *spapr_dr_connector_new(Object *owner, 634 sPAPRDRConnectorType type, 635 uint32_t id) 636 { 637 sPAPRDRConnector *drc = 638 SPAPR_DR_CONNECTOR(object_new(TYPE_SPAPR_DR_CONNECTOR)); 639 char *prop_name; 640 641 g_assert(type); 642 643 drc->type = type; 644 drc->id = id; 645 drc->owner = owner; 646 prop_name = g_strdup_printf("dr-connector[%"PRIu32"]", 647 spapr_drc_index(drc)); 648 object_property_add_child(owner, prop_name, OBJECT(drc), NULL); 649 object_property_set_bool(OBJECT(drc), true, "realized", NULL); 650 g_free(prop_name); 651 652 /* human-readable name for a DRC to encode into the DT 653 * description. this is mainly only used within a guest in place 654 * of the unique DRC index. 655 * 656 * in the case of VIO/PCI devices, it corresponds to a 657 * "location code" that maps a logical device/function (DRC index) 658 * to a physical (or virtual in the case of VIO) location in the 659 * system by chaining together the "location label" for each 660 * encapsulating component. 661 * 662 * since this is more to do with diagnosing physical hardware 663 * issues than guest compatibility, we choose location codes/DRC 664 * names that adhere to the documented format, but avoid encoding 665 * the entire topology information into the label/code, instead 666 * just using the location codes based on the labels for the 667 * endpoints (VIO/PCI adaptor connectors), which is basically 668 * just "C" followed by an integer ID. 669 * 670 * DRC names as documented by PAPR+ v2.7, 13.5.2.4 671 * location codes as documented by PAPR+ v2.7, 12.3.1.5 672 */ 673 switch (drc->type) { 674 case SPAPR_DR_CONNECTOR_TYPE_CPU: 675 drc->name = g_strdup_printf("CPU %d", id); 676 break; 677 case SPAPR_DR_CONNECTOR_TYPE_PHB: 678 drc->name = g_strdup_printf("PHB %d", id); 679 break; 680 case SPAPR_DR_CONNECTOR_TYPE_VIO: 681 case SPAPR_DR_CONNECTOR_TYPE_PCI: 682 drc->name = g_strdup_printf("C%d", id); 683 break; 684 case SPAPR_DR_CONNECTOR_TYPE_LMB: 685 drc->name = g_strdup_printf("LMB %d", id); 686 break; 687 default: 688 g_assert(false); 689 } 690 691 /* PCI slot always start in a USABLE state, and stay there */ 692 if (drc->type == SPAPR_DR_CONNECTOR_TYPE_PCI) { 693 drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE; 694 } 695 696 return drc; 697 } 698 699 static void spapr_dr_connector_instance_init(Object *obj) 700 { 701 sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj); 702 703 object_property_add_uint32_ptr(obj, "isolation-state", 704 &drc->isolation_state, NULL); 705 object_property_add_uint32_ptr(obj, "indicator-state", 706 &drc->indicator_state, NULL); 707 object_property_add_uint32_ptr(obj, "allocation-state", 708 &drc->allocation_state, NULL); 709 object_property_add_uint32_ptr(obj, "id", &drc->id, NULL); 710 object_property_add(obj, "index", "uint32", prop_get_index, 711 NULL, NULL, NULL, NULL); 712 object_property_add(obj, "connector_type", "uint32", prop_get_type, 713 NULL, NULL, NULL, NULL); 714 object_property_add_str(obj, "name", prop_get_name, NULL, NULL); 715 object_property_add(obj, "entity-sense", "uint32", prop_get_entity_sense, 716 NULL, NULL, NULL, NULL); 717 object_property_add(obj, "fdt", "struct", prop_get_fdt, 718 NULL, NULL, NULL, NULL); 719 } 720 721 static void spapr_dr_connector_class_init(ObjectClass *k, void *data) 722 { 723 DeviceClass *dk = DEVICE_CLASS(k); 724 sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k); 725 726 dk->reset = reset; 727 dk->realize = realize; 728 dk->unrealize = unrealize; 729 drck->set_isolation_state = set_isolation_state; 730 drck->set_indicator_state = set_indicator_state; 731 drck->set_allocation_state = set_allocation_state; 732 drck->get_name = get_name; 733 drck->entity_sense = entity_sense; 734 drck->attach = attach; 735 drck->detach = detach; 736 drck->release_pending = release_pending; 737 drck->set_signalled = set_signalled; 738 /* 739 * Reason: it crashes FIXME find and document the real reason 740 */ 741 dk->user_creatable = false; 742 } 743 744 static const TypeInfo spapr_dr_connector_info = { 745 .name = TYPE_SPAPR_DR_CONNECTOR, 746 .parent = TYPE_DEVICE, 747 .instance_size = sizeof(sPAPRDRConnector), 748 .instance_init = spapr_dr_connector_instance_init, 749 .class_size = sizeof(sPAPRDRConnectorClass), 750 .class_init = spapr_dr_connector_class_init, 751 }; 752 753 /* helper functions for external users */ 754 755 sPAPRDRConnector *spapr_dr_connector_by_index(uint32_t index) 756 { 757 Object *obj; 758 char name[256]; 759 760 snprintf(name, sizeof(name), "%s/%x", DRC_CONTAINER_PATH, index); 761 obj = object_resolve_path(name, NULL); 762 763 return !obj ? NULL : SPAPR_DR_CONNECTOR(obj); 764 } 765 766 sPAPRDRConnector *spapr_dr_connector_by_id(sPAPRDRConnectorType type, 767 uint32_t id) 768 { 769 return spapr_dr_connector_by_index( 770 (get_type_shift(type) << DRC_INDEX_TYPE_SHIFT) | 771 (id & DRC_INDEX_ID_MASK)); 772 } 773 774 /* generate a string the describes the DRC to encode into the 775 * device tree. 776 * 777 * as documented by PAPR+ v2.7, 13.5.2.6 and C.6.1 778 */ 779 static const char *spapr_drc_get_type_str(sPAPRDRConnectorType type) 780 { 781 switch (type) { 782 case SPAPR_DR_CONNECTOR_TYPE_CPU: 783 return "CPU"; 784 case SPAPR_DR_CONNECTOR_TYPE_PHB: 785 return "PHB"; 786 case SPAPR_DR_CONNECTOR_TYPE_VIO: 787 return "SLOT"; 788 case SPAPR_DR_CONNECTOR_TYPE_PCI: 789 return "28"; 790 case SPAPR_DR_CONNECTOR_TYPE_LMB: 791 return "MEM"; 792 default: 793 g_assert(false); 794 } 795 796 return NULL; 797 } 798 799 /** 800 * spapr_drc_populate_dt 801 * 802 * @fdt: libfdt device tree 803 * @path: path in the DT to generate properties 804 * @owner: parent Object/DeviceState for which to generate DRC 805 * descriptions for 806 * @drc_type_mask: mask of sPAPRDRConnectorType values corresponding 807 * to the types of DRCs to generate entries for 808 * 809 * generate OF properties to describe DRC topology/indices to guests 810 * 811 * as documented in PAPR+ v2.1, 13.5.2 812 */ 813 int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner, 814 uint32_t drc_type_mask) 815 { 816 Object *root_container; 817 ObjectProperty *prop; 818 ObjectPropertyIterator iter; 819 uint32_t drc_count = 0; 820 GArray *drc_indexes, *drc_power_domains; 821 GString *drc_names, *drc_types; 822 int ret; 823 824 /* the first entry of each properties is a 32-bit integer encoding 825 * the number of elements in the array. we won't know this until 826 * we complete the iteration through all the matching DRCs, but 827 * reserve the space now and set the offsets accordingly so we 828 * can fill them in later. 829 */ 830 drc_indexes = g_array_new(false, true, sizeof(uint32_t)); 831 drc_indexes = g_array_set_size(drc_indexes, 1); 832 drc_power_domains = g_array_new(false, true, sizeof(uint32_t)); 833 drc_power_domains = g_array_set_size(drc_power_domains, 1); 834 drc_names = g_string_set_size(g_string_new(NULL), sizeof(uint32_t)); 835 drc_types = g_string_set_size(g_string_new(NULL), sizeof(uint32_t)); 836 837 /* aliases for all DRConnector objects will be rooted in QOM 838 * composition tree at DRC_CONTAINER_PATH 839 */ 840 root_container = container_get(object_get_root(), DRC_CONTAINER_PATH); 841 842 object_property_iter_init(&iter, root_container); 843 while ((prop = object_property_iter_next(&iter))) { 844 Object *obj; 845 sPAPRDRConnector *drc; 846 sPAPRDRConnectorClass *drck; 847 uint32_t drc_index, drc_power_domain; 848 849 if (!strstart(prop->type, "link<", NULL)) { 850 continue; 851 } 852 853 obj = object_property_get_link(root_container, prop->name, NULL); 854 drc = SPAPR_DR_CONNECTOR(obj); 855 drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); 856 857 if (owner && (drc->owner != owner)) { 858 continue; 859 } 860 861 if ((drc->type & drc_type_mask) == 0) { 862 continue; 863 } 864 865 drc_count++; 866 867 /* ibm,drc-indexes */ 868 drc_index = cpu_to_be32(spapr_drc_index(drc)); 869 g_array_append_val(drc_indexes, drc_index); 870 871 /* ibm,drc-power-domains */ 872 drc_power_domain = cpu_to_be32(-1); 873 g_array_append_val(drc_power_domains, drc_power_domain); 874 875 /* ibm,drc-names */ 876 drc_names = g_string_append(drc_names, drck->get_name(drc)); 877 drc_names = g_string_insert_len(drc_names, -1, "\0", 1); 878 879 /* ibm,drc-types */ 880 drc_types = g_string_append(drc_types, 881 spapr_drc_get_type_str(drc->type)); 882 drc_types = g_string_insert_len(drc_types, -1, "\0", 1); 883 } 884 885 /* now write the drc count into the space we reserved at the 886 * beginning of the arrays previously 887 */ 888 *(uint32_t *)drc_indexes->data = cpu_to_be32(drc_count); 889 *(uint32_t *)drc_power_domains->data = cpu_to_be32(drc_count); 890 *(uint32_t *)drc_names->str = cpu_to_be32(drc_count); 891 *(uint32_t *)drc_types->str = cpu_to_be32(drc_count); 892 893 ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-indexes", 894 drc_indexes->data, 895 drc_indexes->len * sizeof(uint32_t)); 896 if (ret) { 897 error_report("Couldn't create ibm,drc-indexes property"); 898 goto out; 899 } 900 901 ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-power-domains", 902 drc_power_domains->data, 903 drc_power_domains->len * sizeof(uint32_t)); 904 if (ret) { 905 error_report("Couldn't finalize ibm,drc-power-domains property"); 906 goto out; 907 } 908 909 ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-names", 910 drc_names->str, drc_names->len); 911 if (ret) { 912 error_report("Couldn't finalize ibm,drc-names property"); 913 goto out; 914 } 915 916 ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-types", 917 drc_types->str, drc_types->len); 918 if (ret) { 919 error_report("Couldn't finalize ibm,drc-types property"); 920 goto out; 921 } 922 923 out: 924 g_array_free(drc_indexes, true); 925 g_array_free(drc_power_domains, true); 926 g_string_free(drc_names, true); 927 g_string_free(drc_types, true); 928 929 return ret; 930 } 931 932 /* 933 * RTAS calls 934 */ 935 936 static bool sensor_type_is_dr(uint32_t sensor_type) 937 { 938 switch (sensor_type) { 939 case RTAS_SENSOR_TYPE_ISOLATION_STATE: 940 case RTAS_SENSOR_TYPE_DR: 941 case RTAS_SENSOR_TYPE_ALLOCATION_STATE: 942 return true; 943 } 944 945 return false; 946 } 947 948 static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMachineState *spapr, 949 uint32_t token, uint32_t nargs, 950 target_ulong args, uint32_t nret, 951 target_ulong rets) 952 { 953 uint32_t sensor_type; 954 uint32_t sensor_index; 955 uint32_t sensor_state; 956 uint32_t ret = RTAS_OUT_SUCCESS; 957 sPAPRDRConnector *drc; 958 sPAPRDRConnectorClass *drck; 959 960 if (nargs != 3 || nret != 1) { 961 ret = RTAS_OUT_PARAM_ERROR; 962 goto out; 963 } 964 965 sensor_type = rtas_ld(args, 0); 966 sensor_index = rtas_ld(args, 1); 967 sensor_state = rtas_ld(args, 2); 968 969 if (!sensor_type_is_dr(sensor_type)) { 970 goto out_unimplemented; 971 } 972 973 /* if this is a DR sensor we can assume sensor_index == drc_index */ 974 drc = spapr_dr_connector_by_index(sensor_index); 975 if (!drc) { 976 trace_spapr_rtas_set_indicator_invalid(sensor_index); 977 ret = RTAS_OUT_PARAM_ERROR; 978 goto out; 979 } 980 drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); 981 982 switch (sensor_type) { 983 case RTAS_SENSOR_TYPE_ISOLATION_STATE: 984 /* if the guest is configuring a device attached to this 985 * DRC, we should reset the configuration state at this 986 * point since it may no longer be reliable (guest released 987 * device and needs to start over, or unplug occurred so 988 * the FDT is no longer valid) 989 */ 990 if (sensor_state == SPAPR_DR_ISOLATION_STATE_ISOLATED) { 991 sPAPRConfigureConnectorState *ccs = spapr_ccs_find(spapr, 992 sensor_index); 993 if (ccs) { 994 spapr_ccs_remove(spapr, ccs); 995 } 996 } 997 ret = drck->set_isolation_state(drc, sensor_state); 998 break; 999 case RTAS_SENSOR_TYPE_DR: 1000 ret = drck->set_indicator_state(drc, sensor_state); 1001 break; 1002 case RTAS_SENSOR_TYPE_ALLOCATION_STATE: 1003 ret = drck->set_allocation_state(drc, sensor_state); 1004 break; 1005 default: 1006 goto out_unimplemented; 1007 } 1008 1009 out: 1010 rtas_st(rets, 0, ret); 1011 return; 1012 1013 out_unimplemented: 1014 /* currently only DR-related sensors are implemented */ 1015 trace_spapr_rtas_set_indicator_not_supported(sensor_index, sensor_type); 1016 rtas_st(rets, 0, RTAS_OUT_NOT_SUPPORTED); 1017 } 1018 1019 static void rtas_get_sensor_state(PowerPCCPU *cpu, sPAPRMachineState *spapr, 1020 uint32_t token, uint32_t nargs, 1021 target_ulong args, uint32_t nret, 1022 target_ulong rets) 1023 { 1024 uint32_t sensor_type; 1025 uint32_t sensor_index; 1026 uint32_t sensor_state = 0; 1027 sPAPRDRConnector *drc; 1028 sPAPRDRConnectorClass *drck; 1029 uint32_t ret = RTAS_OUT_SUCCESS; 1030 1031 if (nargs != 2 || nret != 2) { 1032 ret = RTAS_OUT_PARAM_ERROR; 1033 goto out; 1034 } 1035 1036 sensor_type = rtas_ld(args, 0); 1037 sensor_index = rtas_ld(args, 1); 1038 1039 if (sensor_type != RTAS_SENSOR_TYPE_ENTITY_SENSE) { 1040 /* currently only DR-related sensors are implemented */ 1041 trace_spapr_rtas_get_sensor_state_not_supported(sensor_index, 1042 sensor_type); 1043 ret = RTAS_OUT_NOT_SUPPORTED; 1044 goto out; 1045 } 1046 1047 drc = spapr_dr_connector_by_index(sensor_index); 1048 if (!drc) { 1049 trace_spapr_rtas_get_sensor_state_invalid(sensor_index); 1050 ret = RTAS_OUT_PARAM_ERROR; 1051 goto out; 1052 } 1053 drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); 1054 ret = drck->entity_sense(drc, &sensor_state); 1055 1056 out: 1057 rtas_st(rets, 0, ret); 1058 rtas_st(rets, 1, sensor_state); 1059 } 1060 1061 /* configure-connector work area offsets, int32_t units for field 1062 * indexes, bytes for field offset/len values. 1063 * 1064 * as documented by PAPR+ v2.7, 13.5.3.5 1065 */ 1066 #define CC_IDX_NODE_NAME_OFFSET 2 1067 #define CC_IDX_PROP_NAME_OFFSET 2 1068 #define CC_IDX_PROP_LEN 3 1069 #define CC_IDX_PROP_DATA_OFFSET 4 1070 #define CC_VAL_DATA_OFFSET ((CC_IDX_PROP_DATA_OFFSET + 1) * 4) 1071 #define CC_WA_LEN 4096 1072 1073 static void configure_connector_st(target_ulong addr, target_ulong offset, 1074 const void *buf, size_t len) 1075 { 1076 cpu_physical_memory_write(ppc64_phys_to_real(addr + offset), 1077 buf, MIN(len, CC_WA_LEN - offset)); 1078 } 1079 1080 void spapr_ccs_reset_hook(void *opaque) 1081 { 1082 sPAPRMachineState *spapr = opaque; 1083 sPAPRConfigureConnectorState *ccs, *ccs_tmp; 1084 1085 QTAILQ_FOREACH_SAFE(ccs, &spapr->ccs_list, next, ccs_tmp) { 1086 spapr_ccs_remove(spapr, ccs); 1087 } 1088 } 1089 1090 static void rtas_ibm_configure_connector(PowerPCCPU *cpu, 1091 sPAPRMachineState *spapr, 1092 uint32_t token, uint32_t nargs, 1093 target_ulong args, uint32_t nret, 1094 target_ulong rets) 1095 { 1096 uint64_t wa_addr; 1097 uint64_t wa_offset; 1098 uint32_t drc_index; 1099 sPAPRDRConnector *drc; 1100 sPAPRConfigureConnectorState *ccs; 1101 sPAPRDRCCResponse resp = SPAPR_DR_CC_RESPONSE_CONTINUE; 1102 int rc; 1103 1104 if (nargs != 2 || nret != 1) { 1105 rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); 1106 return; 1107 } 1108 1109 wa_addr = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 0); 1110 1111 drc_index = rtas_ld(wa_addr, 0); 1112 drc = spapr_dr_connector_by_index(drc_index); 1113 if (!drc) { 1114 trace_spapr_rtas_ibm_configure_connector_invalid(drc_index); 1115 rc = RTAS_OUT_PARAM_ERROR; 1116 goto out; 1117 } 1118 1119 if (!drc->fdt) { 1120 trace_spapr_rtas_ibm_configure_connector_missing_fdt(drc_index); 1121 rc = SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE; 1122 goto out; 1123 } 1124 1125 ccs = spapr_ccs_find(spapr, drc_index); 1126 if (!ccs) { 1127 ccs = g_new0(sPAPRConfigureConnectorState, 1); 1128 ccs->fdt_offset = drc->fdt_start_offset; 1129 ccs->drc_index = drc_index; 1130 spapr_ccs_add(spapr, ccs); 1131 } 1132 1133 do { 1134 uint32_t tag; 1135 const char *name; 1136 const struct fdt_property *prop; 1137 int fdt_offset_next, prop_len; 1138 1139 tag = fdt_next_tag(drc->fdt, ccs->fdt_offset, &fdt_offset_next); 1140 1141 switch (tag) { 1142 case FDT_BEGIN_NODE: 1143 ccs->fdt_depth++; 1144 name = fdt_get_name(drc->fdt, ccs->fdt_offset, NULL); 1145 1146 /* provide the name of the next OF node */ 1147 wa_offset = CC_VAL_DATA_OFFSET; 1148 rtas_st(wa_addr, CC_IDX_NODE_NAME_OFFSET, wa_offset); 1149 configure_connector_st(wa_addr, wa_offset, name, strlen(name) + 1); 1150 resp = SPAPR_DR_CC_RESPONSE_NEXT_CHILD; 1151 break; 1152 case FDT_END_NODE: 1153 ccs->fdt_depth--; 1154 if (ccs->fdt_depth == 0) { 1155 sPAPRDRIsolationState state = drc->isolation_state; 1156 uint32_t drc_index = spapr_drc_index(drc); 1157 /* done sending the device tree, don't need to track 1158 * the state anymore 1159 */ 1160 trace_spapr_drc_set_configured(drc_index); 1161 if (state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) { 1162 drc->configured = true; 1163 } else { 1164 /* guest should be not configuring an isolated device */ 1165 trace_spapr_drc_set_configured_skipping(drc_index); 1166 } 1167 spapr_ccs_remove(spapr, ccs); 1168 ccs = NULL; 1169 resp = SPAPR_DR_CC_RESPONSE_SUCCESS; 1170 } else { 1171 resp = SPAPR_DR_CC_RESPONSE_PREV_PARENT; 1172 } 1173 break; 1174 case FDT_PROP: 1175 prop = fdt_get_property_by_offset(drc->fdt, ccs->fdt_offset, 1176 &prop_len); 1177 name = fdt_string(drc->fdt, fdt32_to_cpu(prop->nameoff)); 1178 1179 /* provide the name of the next OF property */ 1180 wa_offset = CC_VAL_DATA_OFFSET; 1181 rtas_st(wa_addr, CC_IDX_PROP_NAME_OFFSET, wa_offset); 1182 configure_connector_st(wa_addr, wa_offset, name, strlen(name) + 1); 1183 1184 /* provide the length and value of the OF property. data gets 1185 * placed immediately after NULL terminator of the OF property's 1186 * name string 1187 */ 1188 wa_offset += strlen(name) + 1, 1189 rtas_st(wa_addr, CC_IDX_PROP_LEN, prop_len); 1190 rtas_st(wa_addr, CC_IDX_PROP_DATA_OFFSET, wa_offset); 1191 configure_connector_st(wa_addr, wa_offset, prop->data, prop_len); 1192 resp = SPAPR_DR_CC_RESPONSE_NEXT_PROPERTY; 1193 break; 1194 case FDT_END: 1195 resp = SPAPR_DR_CC_RESPONSE_ERROR; 1196 default: 1197 /* keep seeking for an actionable tag */ 1198 break; 1199 } 1200 if (ccs) { 1201 ccs->fdt_offset = fdt_offset_next; 1202 } 1203 } while (resp == SPAPR_DR_CC_RESPONSE_CONTINUE); 1204 1205 rc = resp; 1206 out: 1207 rtas_st(rets, 0, rc); 1208 } 1209 1210 static void spapr_drc_register_types(void) 1211 { 1212 type_register_static(&spapr_dr_connector_info); 1213 1214 spapr_rtas_register(RTAS_SET_INDICATOR, "set-indicator", 1215 rtas_set_indicator); 1216 spapr_rtas_register(RTAS_GET_SENSOR_STATE, "get-sensor-state", 1217 rtas_get_sensor_state); 1218 spapr_rtas_register(RTAS_IBM_CONFIGURE_CONNECTOR, "ibm,configure-connector", 1219 rtas_ibm_configure_connector); 1220 } 1221 type_init(spapr_drc_register_types) 1222