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