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