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