spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
/*
|
|
|
|
* QEMU SPAPR Dynamic Reconfiguration Connector Implementation
|
|
|
|
*
|
|
|
|
* Copyright IBM Corp. 2014
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:16:58 +01:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 09:01:28 +01:00
|
|
|
#include "qapi/error.h"
|
2016-01-19 21:51:44 +01:00
|
|
|
#include "cpu.h"
|
2016-03-20 18:16:19 +01:00
|
|
|
#include "qemu/cutils.h"
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
#include "hw/ppc/spapr_drc.h"
|
|
|
|
#include "qom/object.h"
|
|
|
|
#include "hw/qdev.h"
|
|
|
|
#include "qapi/visitor.h"
|
|
|
|
#include "qemu/error-report.h"
|
2015-09-10 23:11:02 +02:00
|
|
|
#include "hw/ppc/spapr.h" /* for RTAS return codes */
|
2017-05-22 21:35:48 +02:00
|
|
|
#include "hw/pci-host/spapr.h" /* spapr_phb_remove_pci_device_cb callback */
|
2016-09-14 20:48:23 +02:00
|
|
|
#include "trace.h"
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
|
|
|
|
#define DRC_CONTAINER_PATH "/dr-connector"
|
|
|
|
#define DRC_INDEX_TYPE_SHIFT 28
|
2015-09-03 02:08:23 +02:00
|
|
|
#define DRC_INDEX_ID_MASK ((1ULL << DRC_INDEX_TYPE_SHIFT) - 1)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
|
2017-06-04 12:25:17 +02:00
|
|
|
sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc)
|
|
|
|
{
|
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
|
|
|
|
|
|
|
return 1 << drck->typeshift;
|
|
|
|
}
|
|
|
|
|
2017-06-02 05:49:20 +02:00
|
|
|
uint32_t spapr_drc_index(sPAPRDRConnector *drc)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
2017-06-04 12:25:17 +02:00
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
|
|
|
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
/* no set format for a drc index: it only needs to be globally
|
|
|
|
* unique. this is how we encode the DRC type on bare-metal
|
|
|
|
* however, so might as well do that here
|
|
|
|
*/
|
2017-06-04 12:25:17 +02:00
|
|
|
return (drck->typeshift << DRC_INDEX_TYPE_SHIFT)
|
|
|
|
| (drc->id & DRC_INDEX_ID_MASK);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
|
2017-06-07 16:58:32 +02:00
|
|
|
static uint32_t drc_isolate_physical(sPAPRDRConnector *drc)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
2017-06-04 12:26:25 +02:00
|
|
|
/* if the guest is configuring a device attached to this DRC, we
|
|
|
|
* should reset the configuration state at this point since it may
|
|
|
|
* no longer be reliable (guest released device and needs to start
|
|
|
|
* over, or unplug occurred so the FDT is no longer valid)
|
|
|
|
*/
|
2017-06-07 16:58:32 +02:00
|
|
|
g_free(drc->ccs);
|
|
|
|
drc->ccs = NULL;
|
2017-06-04 12:26:25 +02:00
|
|
|
|
2017-06-07 16:58:32 +02:00
|
|
|
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;
|
|
|
|
|
|
|
|
/* if we're awaiting release, but still in an unconfigured state,
|
|
|
|
* it's likely the guest is still in the process of configuring
|
|
|
|
* the device and is transitioning the devices to an ISOLATED
|
|
|
|
* state as a part of that process. so we only complete the
|
|
|
|
* removal when this transition happens for a device in a
|
|
|
|
* configured state, as suggested by the state diagram from PAPR+
|
|
|
|
* 2.7, 13.4
|
|
|
|
*/
|
|
|
|
if (drc->awaiting_release) {
|
|
|
|
uint32_t drc_index = spapr_drc_index(drc);
|
|
|
|
if (drc->configured) {
|
|
|
|
trace_spapr_drc_set_isolation_state_finalizing(drc_index);
|
|
|
|
spapr_drc_detach(drc, DEVICE(drc->dev), NULL);
|
|
|
|
} else {
|
|
|
|
trace_spapr_drc_set_isolation_state_deferring(drc_index);
|
2015-09-10 23:11:03 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-07 16:58:32 +02:00
|
|
|
drc->configured = false;
|
|
|
|
|
|
|
|
return RTAS_OUT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t drc_unisolate_physical(sPAPRDRConnector *drc)
|
|
|
|
{
|
|
|
|
/* cannot unisolate a non-existent resource, and, or resources
|
|
|
|
* which are in an 'UNUSABLE' allocation state. (PAPR 2.7,
|
|
|
|
* 13.5.3.5)
|
|
|
|
*/
|
|
|
|
if (!drc->dev) {
|
|
|
|
return RTAS_OUT_NO_SUCH_INDICATOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;
|
|
|
|
|
|
|
|
return RTAS_OUT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t drc_isolate_logical(sPAPRDRConnector *drc)
|
|
|
|
{
|
|
|
|
/* if the guest is configuring a device attached to this DRC, we
|
|
|
|
* should reset the configuration state at this point since it may
|
|
|
|
* no longer be reliable (guest released device and needs to start
|
|
|
|
* over, or unplug occurred so the FDT is no longer valid)
|
|
|
|
*/
|
|
|
|
g_free(drc->ccs);
|
|
|
|
drc->ccs = NULL;
|
2015-09-10 23:11:03 +02:00
|
|
|
|
2016-10-27 04:20:30 +02:00
|
|
|
/*
|
|
|
|
* Fail any requests to ISOLATE the LMB DRC if this LMB doesn't
|
|
|
|
* belong to a DIMM device that is marked for removal.
|
|
|
|
*
|
|
|
|
* Currently the guest userspace tool drmgr that drives the memory
|
|
|
|
* hotplug/unplug will just try to remove a set of 'removable' LMBs
|
|
|
|
* in response to a hot unplug request that is based on drc-count.
|
|
|
|
* If the LMB being removed doesn't belong to a DIMM device that is
|
|
|
|
* actually being unplugged, fail the isolation request here.
|
|
|
|
*/
|
2017-06-07 16:58:32 +02:00
|
|
|
if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_LMB
|
|
|
|
&& !drc->awaiting_release) {
|
|
|
|
return RTAS_OUT_HW_ERROR;
|
2016-10-27 04:20:30 +02:00
|
|
|
}
|
|
|
|
|
2017-06-07 16:58:32 +02:00
|
|
|
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
|
2017-06-07 16:58:32 +02:00
|
|
|
/* if we're awaiting release, but still in an unconfigured state,
|
|
|
|
* it's likely the guest is still in the process of configuring
|
|
|
|
* the device and is transitioning the devices to an ISOLATED
|
|
|
|
* state as a part of that process. so we only complete the
|
|
|
|
* removal when this transition happens for a device in a
|
|
|
|
* configured state, as suggested by the state diagram from PAPR+
|
|
|
|
* 2.7, 13.4
|
|
|
|
*/
|
|
|
|
if (drc->awaiting_release) {
|
|
|
|
uint32_t drc_index = spapr_drc_index(drc);
|
|
|
|
if (drc->configured) {
|
|
|
|
trace_spapr_drc_set_isolation_state_finalizing(drc_index);
|
|
|
|
spapr_drc_detach(drc, DEVICE(drc->dev), NULL);
|
|
|
|
} else {
|
|
|
|
trace_spapr_drc_set_isolation_state_deferring(drc_index);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-07 16:58:32 +02:00
|
|
|
drc->configured = false;
|
|
|
|
|
|
|
|
return RTAS_OUT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t drc_unisolate_logical(sPAPRDRConnector *drc)
|
|
|
|
{
|
|
|
|
/* cannot unisolate a non-existent resource, and, or resources
|
|
|
|
* which are in an 'UNUSABLE' allocation state. (PAPR 2.7,
|
|
|
|
* 13.5.3.5)
|
|
|
|
*/
|
|
|
|
if (!drc->dev ||
|
|
|
|
drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
|
|
|
|
return RTAS_OUT_NO_SUCH_INDICATOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
|
2015-09-10 23:11:02 +02:00
|
|
|
return RTAS_OUT_SUCCESS;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
|
2017-06-07 16:50:19 +02:00
|
|
|
static uint32_t drc_set_usable(sPAPRDRConnector *drc)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
2017-06-07 16:50:19 +02:00
|
|
|
/* if there's no resource/device associated with the DRC, there's
|
|
|
|
* no way for us to put it in an allocation state consistent with
|
|
|
|
* being 'USABLE'. PAPR 2.7, 13.5.3.4 documents that this should
|
|
|
|
* result in an RTAS return code of -3 / "no such indicator"
|
|
|
|
*/
|
|
|
|
if (!drc->dev) {
|
|
|
|
return RTAS_OUT_NO_SUCH_INDICATOR;
|
|
|
|
}
|
2017-07-03 12:20:53 +02:00
|
|
|
if (drc->awaiting_release) {
|
|
|
|
/* Don't allow the guest to move a device away from UNUSABLE
|
|
|
|
* state when we want to unplug it */
|
2017-06-07 16:50:19 +02:00
|
|
|
return RTAS_OUT_NO_SUCH_INDICATOR;
|
2015-09-10 23:11:03 +02:00
|
|
|
}
|
|
|
|
|
2017-06-07 16:50:19 +02:00
|
|
|
drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE;
|
|
|
|
|
|
|
|
return RTAS_OUT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t drc_set_unusable(sPAPRDRConnector *drc)
|
|
|
|
{
|
|
|
|
drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_UNUSABLE;
|
|
|
|
if (drc->awaiting_release) {
|
|
|
|
uint32_t drc_index = spapr_drc_index(drc);
|
|
|
|
trace_spapr_drc_set_allocation_state_finalizing(drc_index);
|
|
|
|
spapr_drc_detach(drc, DEVICE(drc->dev), NULL);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
2017-06-07 16:50:19 +02:00
|
|
|
|
2015-09-10 23:11:02 +02:00
|
|
|
return RTAS_OUT_SUCCESS;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
|
2017-06-07 04:00:11 +02:00
|
|
|
static const char *spapr_drc_name(sPAPRDRConnector *drc)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
2017-06-07 04:00:11 +02:00
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
|
|
|
|
|
|
|
/* human-readable name for a DRC to encode into the DT
|
|
|
|
* description. this is mainly only used within a guest in place
|
|
|
|
* of the unique DRC index.
|
|
|
|
*
|
|
|
|
* in the case of VIO/PCI devices, it corresponds to a "location
|
|
|
|
* code" that maps a logical device/function (DRC index) to a
|
|
|
|
* physical (or virtual in the case of VIO) location in the system
|
|
|
|
* by chaining together the "location label" for each
|
|
|
|
* encapsulating component.
|
|
|
|
*
|
|
|
|
* since this is more to do with diagnosing physical hardware
|
|
|
|
* issues than guest compatibility, we choose location codes/DRC
|
|
|
|
* names that adhere to the documented format, but avoid encoding
|
|
|
|
* the entire topology information into the label/code, instead
|
|
|
|
* just using the location codes based on the labels for the
|
|
|
|
* endpoints (VIO/PCI adaptor connectors), which is basically just
|
|
|
|
* "C" followed by an integer ID.
|
|
|
|
*
|
|
|
|
* DRC names as documented by PAPR+ v2.7, 13.5.2.4
|
|
|
|
* location codes as documented by PAPR+ v2.7, 12.3.1.5
|
|
|
|
*/
|
|
|
|
return g_strdup_printf("%s%d", drck->drc_name_prefix, drc->id);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dr-entity-sense sensor value
|
|
|
|
* returned via get-sensor-state RTAS calls
|
|
|
|
* as expected by state diagram in PAPR+ 2.7, 13.4
|
|
|
|
* based on the current allocation/indicator/power states
|
|
|
|
* for the DR connector.
|
|
|
|
*/
|
2017-06-07 03:26:52 +02:00
|
|
|
static sPAPRDREntitySense physical_entity_sense(sPAPRDRConnector *drc)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
2017-06-07 03:26:52 +02:00
|
|
|
/* this assumes all PCI devices are assigned to a 'live insertion'
|
|
|
|
* power domain, where QEMU manages power state automatically as
|
|
|
|
* opposed to the guest. present, non-PCI resources are unaffected
|
|
|
|
* by power state.
|
|
|
|
*/
|
|
|
|
return drc->dev ? SPAPR_DR_ENTITY_SENSE_PRESENT
|
|
|
|
: SPAPR_DR_ENTITY_SENSE_EMPTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static sPAPRDREntitySense logical_entity_sense(sPAPRDRConnector *drc)
|
|
|
|
{
|
|
|
|
if (drc->dev
|
|
|
|
&& (drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE)) {
|
|
|
|
return SPAPR_DR_ENTITY_SENSE_PRESENT;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
} else {
|
2017-06-07 03:26:52 +02:00
|
|
|
return SPAPR_DR_ENTITY_SENSE_UNUSABLE;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
qom: Swap 'name' next to visitor in ObjectPropertyAccessor
Similar to the previous patch, it's nice to have all functions
in the tree that involve a visitor and a name for conversion to
or from QAPI to consistently stick the 'name' parameter next
to the Visitor parameter.
Done by manually changing include/qom/object.h and qom/object.c,
then running this Coccinelle script and touching up the fallout
(Coccinelle insisted on adding some trailing whitespace).
@ rule1 @
identifier fn;
typedef Object, Visitor, Error;
identifier obj, v, opaque, name, errp;
@@
void fn
- (Object *obj, Visitor *v, void *opaque, const char *name,
+ (Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp) { ... }
@@
identifier rule1.fn;
expression obj, v, opaque, name, errp;
@@
fn(obj, v,
- opaque, name,
+ name, opaque,
errp)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-20-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 14:48:55 +01:00
|
|
|
static void prop_get_index(Object *obj, Visitor *v, const char *name,
|
|
|
|
void *opaque, Error **errp)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
|
|
|
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj);
|
2017-06-02 05:49:20 +02:00
|
|
|
uint32_t value = spapr_drc_index(drc);
|
qapi: Swap visit_* arguments for consistent 'name' placement
JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp). This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order. It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.
Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.
Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.
Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
$ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings'). The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.
// Part 1: Swap declaration order
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_start_struct
-(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type bool, TV, T1;
identifier ARG1;
@@
bool visit_optional
-(TV v, T1 ARG1, const char *name)
+(TV v, const char *name, T1 ARG1)
{ ... }
@@
type TV, TErr, TObj, T1;
identifier OBJ, ARG1;
@@
void visit_get_next_type
-(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
{ ... }
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_type_enum
-(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type TV, TErr, TObj;
identifier OBJ;
identifier VISIT_TYPE =~ "^visit_type_";
@@
void VISIT_TYPE
-(TV v, TObj OBJ, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, TErr errp)
{ ... }
// Part 2: swap caller order
@@
expression V, NAME, OBJ, ARG1, ARG2, ERR;
identifier VISIT_TYPE =~ "^visit_type_";
@@
(
-visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
+visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-visit_optional(V, ARG1, NAME)
+visit_optional(V, NAME, ARG1)
|
-visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
+visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
|
-visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
+visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-VISIT_TYPE(V, OBJ, NAME, ERR)
+VISIT_TYPE(V, NAME, OBJ, ERR)
)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 14:48:54 +01:00
|
|
|
visit_type_uint32(v, name, &value, errp);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
|
qom: Swap 'name' next to visitor in ObjectPropertyAccessor
Similar to the previous patch, it's nice to have all functions
in the tree that involve a visitor and a name for conversion to
or from QAPI to consistently stick the 'name' parameter next
to the Visitor parameter.
Done by manually changing include/qom/object.h and qom/object.c,
then running this Coccinelle script and touching up the fallout
(Coccinelle insisted on adding some trailing whitespace).
@ rule1 @
identifier fn;
typedef Object, Visitor, Error;
identifier obj, v, opaque, name, errp;
@@
void fn
- (Object *obj, Visitor *v, void *opaque, const char *name,
+ (Object *obj, Visitor *v, const char *name, void *opaque,
Error **errp) { ... }
@@
identifier rule1.fn;
expression obj, v, opaque, name, errp;
@@
fn(obj, v,
- opaque, name,
+ name, opaque,
errp)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-20-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 14:48:55 +01:00
|
|
|
static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
|
|
|
|
void *opaque, Error **errp)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
|
|
|
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj);
|
2015-12-03 17:37:38 +01:00
|
|
|
Error *err = NULL;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
int fdt_offset_next, fdt_offset, fdt_depth;
|
|
|
|
void *fdt;
|
|
|
|
|
|
|
|
if (!drc->fdt) {
|
2016-04-28 23:45:24 +02:00
|
|
|
visit_type_null(v, NULL, errp);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fdt = drc->fdt;
|
|
|
|
fdt_offset = drc->fdt_start_offset;
|
|
|
|
fdt_depth = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
const char *name = NULL;
|
|
|
|
const struct fdt_property *prop = NULL;
|
|
|
|
int prop_len = 0, name_len = 0;
|
|
|
|
uint32_t tag;
|
|
|
|
|
|
|
|
tag = fdt_next_tag(fdt, fdt_offset, &fdt_offset_next);
|
|
|
|
switch (tag) {
|
|
|
|
case FDT_BEGIN_NODE:
|
|
|
|
fdt_depth++;
|
|
|
|
name = fdt_get_name(fdt, fdt_offset, &name_len);
|
2016-01-29 14:48:57 +01:00
|
|
|
visit_start_struct(v, name, NULL, 0, &err);
|
2015-12-03 17:37:38 +01:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
break;
|
|
|
|
case FDT_END_NODE:
|
|
|
|
/* shouldn't ever see an FDT_END_NODE before FDT_BEGIN_NODE */
|
|
|
|
g_assert(fdt_depth > 0);
|
qapi: Split visit_end_struct() into pieces
As mentioned in previous patches, we want to call visit_end_struct()
functions unconditionally, so that visitors can release resources
tied up since the matching visit_start_struct() without also having
to worry about error priority if more than one error occurs.
Even though error_propagate() can be safely used to ignore a second
error during cleanup caused by a first error, it is simpler if the
cleanup cannot set an error. So, split out the error checking
portion (basically, input visitors checking for unvisited keys) into
a new function visit_check_struct(), which can be safely skipped if
any earlier errors are encountered, and leave the cleanup portion
(which never fails, but must be called unconditionally if
visit_start_struct() succeeded) in visit_end_struct().
Generated code in qapi-visit.c has diffs resembling:
|@@ -59,10 +59,12 @@ void visit_type_ACPIOSTInfo(Visitor *v,
| goto out_obj;
| }
| visit_type_ACPIOSTInfo_members(v, obj, &err);
|- error_propagate(errp, err);
|- err = NULL;
|+ if (err) {
|+ goto out_obj;
|+ }
|+ visit_check_struct(v, &err);
| out_obj:
|- visit_end_struct(v, &err);
|+ visit_end_struct(v);
| out:
and in qapi-event.c:
@@ -47,7 +47,10 @@ void qapi_event_send_acpi_device_ost(ACP
| goto out;
| }
| visit_type_q_obj_ACPI_DEVICE_OST_arg_members(v, ¶m, &err);
|- visit_end_struct(v, err ? NULL : &err);
|+ if (!err) {
|+ visit_check_struct(v, &err);
|+ }
|+ visit_end_struct(v);
| if (err) {
| goto out;
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1461879932-9020-20-git-send-email-eblake@redhat.com>
[Conflict with a doc fixup resolved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-04-28 23:45:27 +02:00
|
|
|
visit_check_struct(v, &err);
|
qapi: Add parameter to visit_end_*
Rather than making the dealloc visitor track of stack of pointers
remembered during visit_start_* in order to free them during
visit_end_*, it's a lot easier to just make all callers pass the
same pointer to visit_end_*. The generated code has access to the
same pointer, while all other users are doing virtual walks and
can pass NULL. The dealloc visitor is then greatly simplified.
All three visit_end_*() functions intentionally take a void**,
even though the visit_start_*() functions differ between void**,
GenericList**, and GenericAlternate**. This is done for several
reasons: when doing a virtual walk, passing NULL doesn't care
what the type is, but when doing a generated walk, we already
have to cast the caller's specific FOO* to call visit_start,
while using void** lets us use visit_end without a cast. Also,
an upcoming patch will add a clone visitor that wants to use
the same implementation for all three visit_end callbacks,
which is made easier if all three share the same signature.
For visitors with already track per-object state (the QMP visitors
via a stack, and the string visitors which do not allow nesting),
add an assertion that the caller is indeed passing the same
pointer to paired calls.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1465490926-28625-4-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-06-09 18:48:34 +02:00
|
|
|
visit_end_struct(v, NULL);
|
2015-12-03 17:37:38 +01:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
fdt_depth--;
|
|
|
|
break;
|
|
|
|
case FDT_PROP: {
|
|
|
|
int i;
|
|
|
|
prop = fdt_get_property_by_offset(fdt, fdt_offset, &prop_len);
|
|
|
|
name = fdt_string(fdt, fdt32_to_cpu(prop->nameoff));
|
qapi: Simplify semantics of visit_next_list()
The semantics of the list visit are somewhat baroque, with the
following pseudocode when FooList is used:
start()
for (prev = head; cur = next(prev); prev = &cur) {
visit(&cur->value)
}
Note that these semantics (advance before visit) requires that
the first call to next() return the list head, while all other
calls return the next element of the list; that is, every visitor
implementation is required to track extra state to decide whether
to return the input as-is, or to advance. It also requires an
argument of 'GenericList **' to next(), solely because the first
iteration might need to modify the caller's GenericList head, so
that all other calls have to do a layer of dereferencing.
Thankfully, we only have two uses of list visits in the entire
code base: one in spapr_drc (which completely avoids
visit_next_list(), feeding in integers from a different source
than uint8List), and one in qapi-visit.py. That is, all other
list visitors are generated in qapi-visit.c, and share the same
paradigm based on a qapi FooList type, so we can refactor how
lists are laid out with minimal churn among clients.
We can greatly simplify things by hoisting the special case
into the start() routine, and flipping the order in the loop
to visit before advance:
start(head)
for (tail = *head; tail; tail = next(tail)) {
visit(&tail->value)
}
With the simpler semantics, visitors have less state to track,
the argument to next() is reduced to 'GenericList *', and it
also becomes obvious whether an input visitor is allocating a
FooList during visit_start_list() (rather than the old way of
not knowing if an allocation happened until the first
visit_next_list()). As a minor drawback, we now allocate in
two functions instead of one, and have to pass the size to
both functions (unless we were to tweak the input visitors to
cache the size to start_list for reuse during next_list, but
that defeats the goal of less visitor state).
The signature of visit_start_list() is chosen to match
visit_start_struct(), with the new parameters after 'name'.
The spapr_drc case is a virtual visit, done by passing NULL for
list, similarly to how NULL is passed to visit_start_struct()
when a qapi type is not used in those visits. It was easy to
provide these semantics for qmp-output and dealloc visitors,
and a bit harder for qmp-input (several prerequisite patches
refactored things to make this patch straightforward). But it
turned out that the string and opts visitors munge enough other
state during visit_next_list() to make it easier to just
document and require a GenericList visit for now; an assertion
will remind us to adjust things if we need the semantics in the
future.
Several pre-requisite cleanup patches made the reshuffling of
the various visitors easier; particularly the qmp input visitor.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1461879932-9020-24-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-04-28 23:45:31 +02:00
|
|
|
visit_start_list(v, name, NULL, 0, &err);
|
2015-12-03 17:37:38 +01:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
for (i = 0; i < prop_len; i++) {
|
qapi: Swap visit_* arguments for consistent 'name' placement
JSON uses "name":value, but many of our visitor interfaces were
called with visit_type_FOO(v, &value, name, errp). This can be
a bit confusing to have to mentally swap the parameter order to
match JSON order. It's particularly bad for visit_start_struct(),
where the 'name' parameter is smack in the middle of the
otherwise-related group of 'obj, kind, size' parameters! It's
time to do a global swap of the parameter ordering, so that the
'name' parameter is always immediately after the Visitor argument.
Additional reason in favor of the swap: the existing include/qjson.h
prefers listing 'name' first in json_prop_*(), and I have plans to
unify that file with the qapi visitors; listing 'name' first in
qapi will minimize churn to the (admittedly few) qjson.h clients.
Later patches will then fix docs, object.h, visitor-impl.h, and
those clients to match.
Done by first patching scripts/qapi*.py by hand to make generated
files do what I want, then by running the following Coccinelle
script to affect the rest of the code base:
$ spatch --sp-file script `git grep -l '\bvisit_' -- '**/*.[ch]'`
I then had to apply some touchups (Coccinelle insisted on TAB
indentation in visitor.h, and botched the signature of
visit_type_enum() by rewriting 'const char *const strings[]' to
the syntactically invalid 'const char*const[] strings'). The
movement of parameters is sufficient to provoke compiler errors
if any callers were missed.
// Part 1: Swap declaration order
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_start_struct
-(TV v, TObj OBJ, T1 ARG1, const char *name, T2 ARG2, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type bool, TV, T1;
identifier ARG1;
@@
bool visit_optional
-(TV v, T1 ARG1, const char *name)
+(TV v, const char *name, T1 ARG1)
{ ... }
@@
type TV, TErr, TObj, T1;
identifier OBJ, ARG1;
@@
void visit_get_next_type
-(TV v, TObj OBJ, T1 ARG1, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, TErr errp)
{ ... }
@@
type TV, TErr, TObj, T1, T2;
identifier OBJ, ARG1, ARG2;
@@
void visit_type_enum
-(TV v, TObj OBJ, T1 ARG1, T2 ARG2, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, T1 ARG1, T2 ARG2, TErr errp)
{ ... }
@@
type TV, TErr, TObj;
identifier OBJ;
identifier VISIT_TYPE =~ "^visit_type_";
@@
void VISIT_TYPE
-(TV v, TObj OBJ, const char *name, TErr errp)
+(TV v, const char *name, TObj OBJ, TErr errp)
{ ... }
// Part 2: swap caller order
@@
expression V, NAME, OBJ, ARG1, ARG2, ERR;
identifier VISIT_TYPE =~ "^visit_type_";
@@
(
-visit_start_struct(V, OBJ, ARG1, NAME, ARG2, ERR)
+visit_start_struct(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-visit_optional(V, ARG1, NAME)
+visit_optional(V, NAME, ARG1)
|
-visit_get_next_type(V, OBJ, ARG1, NAME, ERR)
+visit_get_next_type(V, NAME, OBJ, ARG1, ERR)
|
-visit_type_enum(V, OBJ, ARG1, ARG2, NAME, ERR)
+visit_type_enum(V, NAME, OBJ, ARG1, ARG2, ERR)
|
-VISIT_TYPE(V, OBJ, NAME, ERR)
+VISIT_TYPE(V, NAME, OBJ, ERR)
)
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1454075341-13658-19-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-01-29 14:48:54 +01:00
|
|
|
visit_type_uint8(v, NULL, (uint8_t *)&prop->data[i], &err);
|
2015-12-03 17:37:38 +01:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-03-03 13:32:45 +01:00
|
|
|
visit_check_list(v, &err);
|
qapi: Add parameter to visit_end_*
Rather than making the dealloc visitor track of stack of pointers
remembered during visit_start_* in order to free them during
visit_end_*, it's a lot easier to just make all callers pass the
same pointer to visit_end_*. The generated code has access to the
same pointer, while all other users are doing virtual walks and
can pass NULL. The dealloc visitor is then greatly simplified.
All three visit_end_*() functions intentionally take a void**,
even though the visit_start_*() functions differ between void**,
GenericList**, and GenericAlternate**. This is done for several
reasons: when doing a virtual walk, passing NULL doesn't care
what the type is, but when doing a generated walk, we already
have to cast the caller's specific FOO* to call visit_start,
while using void** lets us use visit_end without a cast. Also,
an upcoming patch will add a clone visitor that wants to use
the same implementation for all three visit_end callbacks,
which is made easier if all three share the same signature.
For visitors with already track per-object state (the QMP visitors
via a stack, and the string visitors which do not allow nesting),
add an assertion that the caller is indeed passing the same
pointer to paired calls.
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1465490926-28625-4-git-send-email-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2016-06-09 18:48:34 +02:00
|
|
|
visit_end_list(v, NULL);
|
2017-03-03 13:32:45 +01:00
|
|
|
if (err) {
|
|
|
|
error_propagate(errp, err);
|
|
|
|
return;
|
|
|
|
}
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
error_setg(&error_abort, "device FDT in unexpected state: %d", tag);
|
|
|
|
}
|
|
|
|
fdt_offset = fdt_offset_next;
|
|
|
|
} while (fdt_depth != 0);
|
|
|
|
}
|
|
|
|
|
2017-06-06 09:44:11 +02:00
|
|
|
void spapr_drc_attach(sPAPRDRConnector *drc, DeviceState *d, void *fdt,
|
2017-06-19 07:16:21 +02:00
|
|
|
int fdt_start_offset, Error **errp)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
2017-06-02 05:49:20 +02:00
|
|
|
trace_spapr_drc_attach(spapr_drc_index(drc));
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
|
|
|
|
if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
|
|
|
|
error_setg(errp, "an attached device is still awaiting release");
|
|
|
|
return;
|
|
|
|
}
|
2017-06-04 12:25:17 +02:00
|
|
|
if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_PCI) {
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
g_assert(drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE);
|
|
|
|
}
|
2017-06-19 07:16:21 +02:00
|
|
|
g_assert(fdt);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
|
|
|
|
drc->dev = d;
|
|
|
|
drc->fdt = fdt;
|
|
|
|
drc->fdt_start_offset = fdt_start_offset;
|
|
|
|
|
|
|
|
object_property_add_link(OBJECT(drc), "device",
|
|
|
|
object_get_typename(OBJECT(drc->dev)),
|
|
|
|
(Object **)(&drc->dev),
|
|
|
|
NULL, 0, NULL);
|
|
|
|
}
|
|
|
|
|
2017-06-07 16:36:23 +02:00
|
|
|
static void spapr_drc_release(sPAPRDRConnector *drc)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
2017-06-16 10:19:20 +02:00
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
|
|
|
|
|
|
|
drck->release(drc->dev);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
|
|
|
|
drc->awaiting_release = false;
|
|
|
|
g_free(drc->fdt);
|
|
|
|
drc->fdt = NULL;
|
|
|
|
drc->fdt_start_offset = 0;
|
|
|
|
object_property_del(OBJECT(drc), "device", NULL);
|
|
|
|
drc->dev = NULL;
|
|
|
|
}
|
|
|
|
|
2017-06-07 16:36:23 +02:00
|
|
|
void spapr_drc_detach(sPAPRDRConnector *drc, DeviceState *d, Error **errp)
|
|
|
|
{
|
|
|
|
trace_spapr_drc_detach(spapr_drc_index(drc));
|
|
|
|
|
|
|
|
if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
|
|
|
|
trace_spapr_drc_awaiting_isolated(spapr_drc_index(drc));
|
|
|
|
drc->awaiting_release = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI &&
|
|
|
|
drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
|
|
|
|
trace_spapr_drc_awaiting_unusable(spapr_drc_index(drc));
|
|
|
|
drc->awaiting_release = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
spapr_drc_release(drc);
|
|
|
|
}
|
|
|
|
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
static bool release_pending(sPAPRDRConnector *drc)
|
|
|
|
{
|
|
|
|
return drc->awaiting_release;
|
|
|
|
}
|
|
|
|
|
spapr: Treat devices added before inbound migration as coldplugged
When migrating a guest which has already had devices hotplugged,
libvirt typically starts the destination qemu with -incoming defer,
adds those hotplugged devices with qmp, then initiates the incoming
migration.
This causes problems for the management of spapr DRC state. Because
the device is treated as hotplugged, it goes into a DRC state for a
device immediately after it's plugged, but before the guest has
acknowledged its presence. However, chances are the guest on the
source machine *has* acknowledged the device's presence and configured
it.
If the source has fully configured the device, then DRC state won't be
sent in the migration stream: for maximum migration compatibility with
earlier versions we don't migrate DRCs in coldplug-equivalent state.
That means that the DRC effectively changes state over the migrate,
causing problems later on.
In addition, logging hotplug events for these devices isn't what we
want because a) those events should already have been issued on the
source host and b) the event queue should get wiped out by the
incoming state anyway.
In short, what we really want is to treat devices added before an
incoming migration as if they were coldplugged.
To do this, we first add a spapr_drc_hotplugged() helper which
determines if the device is hotplugged in the sense relevant for DRC
state management. We only send hotplug events when this is true.
Second, when we add a device which isn't hotplugged in this sense, we
force a reset of the DRC state - this ensures the DRC is in a
coldplug-equivalent state (there isn't usually a system reset between
these device adds and the incoming migration).
This is based on an earlier patch by Laurent Vivier, cleaned up and
extended.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Tested-by: Daniel Barboza <danielhb@linux.vnet.ibm.com>
2017-06-09 13:08:10 +02:00
|
|
|
void spapr_drc_reset(sPAPRDRConnector *drc)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
2017-06-02 05:49:20 +02:00
|
|
|
trace_spapr_drc_reset(spapr_drc_index(drc));
|
2017-06-04 12:26:25 +02:00
|
|
|
|
|
|
|
g_free(drc->ccs);
|
|
|
|
drc->ccs = NULL;
|
|
|
|
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
/* immediately upon reset we can safely assume DRCs whose devices
|
2017-06-21 09:21:28 +02:00
|
|
|
* are pending removal can be safely removed.
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
*/
|
|
|
|
if (drc->awaiting_release) {
|
2017-06-21 09:21:28 +02:00
|
|
|
spapr_drc_release(drc);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drc->dev) {
|
|
|
|
/* A device present at reset is coldplugged */
|
|
|
|
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_UNISOLATED;
|
|
|
|
if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) {
|
|
|
|
drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE;
|
|
|
|
}
|
2017-06-08 09:01:57 +02:00
|
|
|
drc->dr_indicator = SPAPR_DR_INDICATOR_ACTIVE;
|
2017-06-21 09:21:28 +02:00
|
|
|
} else {
|
|
|
|
/* Otherwise device is absent, but might be hotplugged */
|
|
|
|
drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;
|
|
|
|
if (spapr_drc_type(drc) != SPAPR_DR_CONNECTOR_TYPE_PCI) {
|
|
|
|
drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_UNUSABLE;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
2017-06-08 09:01:57 +02:00
|
|
|
drc->dr_indicator = SPAPR_DR_INDICATOR_INACTIVE;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
spapr: Treat devices added before inbound migration as coldplugged
When migrating a guest which has already had devices hotplugged,
libvirt typically starts the destination qemu with -incoming defer,
adds those hotplugged devices with qmp, then initiates the incoming
migration.
This causes problems for the management of spapr DRC state. Because
the device is treated as hotplugged, it goes into a DRC state for a
device immediately after it's plugged, but before the guest has
acknowledged its presence. However, chances are the guest on the
source machine *has* acknowledged the device's presence and configured
it.
If the source has fully configured the device, then DRC state won't be
sent in the migration stream: for maximum migration compatibility with
earlier versions we don't migrate DRCs in coldplug-equivalent state.
That means that the DRC effectively changes state over the migrate,
causing problems later on.
In addition, logging hotplug events for these devices isn't what we
want because a) those events should already have been issued on the
source host and b) the event queue should get wiped out by the
incoming state anyway.
In short, what we really want is to treat devices added before an
incoming migration as if they were coldplugged.
To do this, we first add a spapr_drc_hotplugged() helper which
determines if the device is hotplugged in the sense relevant for DRC
state management. We only send hotplug events when this is true.
Second, when we add a device which isn't hotplugged in this sense, we
force a reset of the DRC state - this ensures the DRC is in a
coldplug-equivalent state (there isn't usually a system reset between
these device adds and the incoming migration).
This is based on an earlier patch by Laurent Vivier, cleaned up and
extended.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Tested-by: Daniel Barboza <danielhb@linux.vnet.ibm.com>
2017-06-09 13:08:10 +02:00
|
|
|
static void drc_reset(void *opaque)
|
|
|
|
{
|
|
|
|
spapr_drc_reset(SPAPR_DR_CONNECTOR(opaque));
|
|
|
|
}
|
|
|
|
|
hw/ppc: migrating the DRC state of hotplugged devices
In pseries, a firmware abstraction called Dynamic Reconfiguration
Connector (DRC) is used to assign a particular dynamic resource
to the guest and provide an interface to manage configuration/removal
of the resource associated with it. In other words, DRC is the
'plugged state' of a device.
Before this patch, DRC wasn't being migrated. This causes
post-migration problems due to DRC state mismatch between source and
target. The DRC state of a device X in the source might
change, while in the target the DRC state of X is still fresh. When
migrating the guest, X will not have the same hotplugged state as it
did in the source. This means that we can't hot unplug X in the
target after migration is completed because its DRC state is not consistent.
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1677552 is one
bug that is caused by this DRC state mismatch between source and
target.
To migrate the DRC state, we defined the VMStateDescription struct for
spapr_drc to enable the transmission of spapr_drc state in migration.
Not all the elements in the DRC state are migrated - only those
that can be modified by guest actions or device add/remove
operations:
- 'isolation_state', 'allocation_state' and 'indicator_state'
are involved in the DR state transition diagram from
PAPR+ 2.7, 13.4;
- 'configured', 'signalled', 'awaiting_release' and 'awaiting_allocation'
are needed in attaching and detaching devices;
- 'indicator_state' provides users with hardware state information.
These are the DRC elements that are migrated.
In this patch the DRC state is migrated for PCI, LMB and CPU
connector types. At this moment there is no support to migrate
DRC for the PHB (PCI Host Bridge) type.
In the 'realize' function the DRC is registered using vmstate_register,
similar to what hw/ppc/spapr_iommu.c does in 'spapr_tce_table_realize'.
This approach works because DRCs are bus-less and do not sit
on a BusClass that implements bc->get_dev_path, so as a fallback the
VMSD gets identified via "spapr_drc"/get_index(drc).
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-05-22 21:35:49 +02:00
|
|
|
static bool spapr_drc_needed(void *opaque)
|
|
|
|
{
|
|
|
|
sPAPRDRConnector *drc = (sPAPRDRConnector *)opaque;
|
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
|
|
|
bool rc = false;
|
2017-06-07 03:26:52 +02:00
|
|
|
sPAPRDREntitySense value = drck->dr_entity_sense(drc);
|
hw/ppc: migrating the DRC state of hotplugged devices
In pseries, a firmware abstraction called Dynamic Reconfiguration
Connector (DRC) is used to assign a particular dynamic resource
to the guest and provide an interface to manage configuration/removal
of the resource associated with it. In other words, DRC is the
'plugged state' of a device.
Before this patch, DRC wasn't being migrated. This causes
post-migration problems due to DRC state mismatch between source and
target. The DRC state of a device X in the source might
change, while in the target the DRC state of X is still fresh. When
migrating the guest, X will not have the same hotplugged state as it
did in the source. This means that we can't hot unplug X in the
target after migration is completed because its DRC state is not consistent.
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1677552 is one
bug that is caused by this DRC state mismatch between source and
target.
To migrate the DRC state, we defined the VMStateDescription struct for
spapr_drc to enable the transmission of spapr_drc state in migration.
Not all the elements in the DRC state are migrated - only those
that can be modified by guest actions or device add/remove
operations:
- 'isolation_state', 'allocation_state' and 'indicator_state'
are involved in the DR state transition diagram from
PAPR+ 2.7, 13.4;
- 'configured', 'signalled', 'awaiting_release' and 'awaiting_allocation'
are needed in attaching and detaching devices;
- 'indicator_state' provides users with hardware state information.
These are the DRC elements that are migrated.
In this patch the DRC state is migrated for PCI, LMB and CPU
connector types. At this moment there is no support to migrate
DRC for the PHB (PCI Host Bridge) type.
In the 'realize' function the DRC is registered using vmstate_register,
similar to what hw/ppc/spapr_iommu.c does in 'spapr_tce_table_realize'.
This approach works because DRCs are bus-less and do not sit
on a BusClass that implements bc->get_dev_path, so as a fallback the
VMSD gets identified via "spapr_drc"/get_index(drc).
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-05-22 21:35:49 +02:00
|
|
|
|
|
|
|
/* If no dev is plugged in there is no need to migrate the DRC state */
|
|
|
|
if (value != SPAPR_DR_ENTITY_SENSE_PRESENT) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there is dev plugged in, we need to migrate the DRC state when
|
|
|
|
* it is different from cold-plugged state
|
|
|
|
*/
|
2017-06-04 12:25:17 +02:00
|
|
|
switch (spapr_drc_type(drc)) {
|
hw/ppc: migrating the DRC state of hotplugged devices
In pseries, a firmware abstraction called Dynamic Reconfiguration
Connector (DRC) is used to assign a particular dynamic resource
to the guest and provide an interface to manage configuration/removal
of the resource associated with it. In other words, DRC is the
'plugged state' of a device.
Before this patch, DRC wasn't being migrated. This causes
post-migration problems due to DRC state mismatch between source and
target. The DRC state of a device X in the source might
change, while in the target the DRC state of X is still fresh. When
migrating the guest, X will not have the same hotplugged state as it
did in the source. This means that we can't hot unplug X in the
target after migration is completed because its DRC state is not consistent.
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1677552 is one
bug that is caused by this DRC state mismatch between source and
target.
To migrate the DRC state, we defined the VMStateDescription struct for
spapr_drc to enable the transmission of spapr_drc state in migration.
Not all the elements in the DRC state are migrated - only those
that can be modified by guest actions or device add/remove
operations:
- 'isolation_state', 'allocation_state' and 'indicator_state'
are involved in the DR state transition diagram from
PAPR+ 2.7, 13.4;
- 'configured', 'signalled', 'awaiting_release' and 'awaiting_allocation'
are needed in attaching and detaching devices;
- 'indicator_state' provides users with hardware state information.
These are the DRC elements that are migrated.
In this patch the DRC state is migrated for PCI, LMB and CPU
connector types. At this moment there is no support to migrate
DRC for the PHB (PCI Host Bridge) type.
In the 'realize' function the DRC is registered using vmstate_register,
similar to what hw/ppc/spapr_iommu.c does in 'spapr_tce_table_realize'.
This approach works because DRCs are bus-less and do not sit
on a BusClass that implements bc->get_dev_path, so as a fallback the
VMSD gets identified via "spapr_drc"/get_index(drc).
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-05-22 21:35:49 +02:00
|
|
|
case SPAPR_DR_CONNECTOR_TYPE_PCI:
|
|
|
|
case SPAPR_DR_CONNECTOR_TYPE_CPU:
|
|
|
|
case SPAPR_DR_CONNECTOR_TYPE_LMB:
|
2017-06-02 12:09:35 +02:00
|
|
|
rc = !((drc->isolation_state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) &&
|
|
|
|
(drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_USABLE) &&
|
spapr: Eliminate DRC 'signalled' state variable
The 'signalled' field in the DRC appears to be entirely a torturous
workaround for the fact that PCI devices were started in UNISOLATED state
for unclear reasons.
1) 'signalled' is already meaningless for logical (so far, all non PCI)
DRCs. It's always set to true (at least at any point it might be tested),
and can't be assigned any real meaning due to the way signalling works for
logical DRCs.
2) For PCI DRCs, the only time signalled would be false is when non-zero
functions of a multifunction device are hotplugged, followed by function
zero (the other way around is explicitly not permitted). In that case the
secondary function DRCs are attached, but the notification isn't sent to
the guest until function 0 is plugged.
3) signalled being false is used to allow a DRC detach to switch mode
back to ISOLATED state, which allows a secondary function to be hotplugged
then unplugged with function 0 never inserted. Without this a secondary
function starting in UNISOLATED state couldn't be detached again without
function 0 being inserted, all the functions configured by the guest, then
sent back to ISOLATED state.
4) But now that PCI DRCs start in ISOLATED state, there's nothing to be
done. If the guest doesn't get the notification, it won't switch the
device to UNISOLATED state, so nothing prevents it from being unplugged.
If the guest does move it to UNISOLATED state without the signal (due to
a manual drmgr call, for instance) then it really isn't safe to unplug it.
So, this patch removes the signalled variable and all code related to it.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2017-06-06 15:01:43 +02:00
|
|
|
drc->configured && !drc->awaiting_release);
|
hw/ppc: migrating the DRC state of hotplugged devices
In pseries, a firmware abstraction called Dynamic Reconfiguration
Connector (DRC) is used to assign a particular dynamic resource
to the guest and provide an interface to manage configuration/removal
of the resource associated with it. In other words, DRC is the
'plugged state' of a device.
Before this patch, DRC wasn't being migrated. This causes
post-migration problems due to DRC state mismatch between source and
target. The DRC state of a device X in the source might
change, while in the target the DRC state of X is still fresh. When
migrating the guest, X will not have the same hotplugged state as it
did in the source. This means that we can't hot unplug X in the
target after migration is completed because its DRC state is not consistent.
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1677552 is one
bug that is caused by this DRC state mismatch between source and
target.
To migrate the DRC state, we defined the VMStateDescription struct for
spapr_drc to enable the transmission of spapr_drc state in migration.
Not all the elements in the DRC state are migrated - only those
that can be modified by guest actions or device add/remove
operations:
- 'isolation_state', 'allocation_state' and 'indicator_state'
are involved in the DR state transition diagram from
PAPR+ 2.7, 13.4;
- 'configured', 'signalled', 'awaiting_release' and 'awaiting_allocation'
are needed in attaching and detaching devices;
- 'indicator_state' provides users with hardware state information.
These are the DRC elements that are migrated.
In this patch the DRC state is migrated for PCI, LMB and CPU
connector types. At this moment there is no support to migrate
DRC for the PHB (PCI Host Bridge) type.
In the 'realize' function the DRC is registered using vmstate_register,
similar to what hw/ppc/spapr_iommu.c does in 'spapr_tce_table_realize'.
This approach works because DRCs are bus-less and do not sit
on a BusClass that implements bc->get_dev_path, so as a fallback the
VMSD gets identified via "spapr_drc"/get_index(drc).
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-05-22 21:35:49 +02:00
|
|
|
break;
|
|
|
|
case SPAPR_DR_CONNECTOR_TYPE_PHB:
|
|
|
|
case SPAPR_DR_CONNECTOR_TYPE_VIO:
|
|
|
|
default:
|
2017-06-02 12:09:35 +02:00
|
|
|
g_assert_not_reached();
|
hw/ppc: migrating the DRC state of hotplugged devices
In pseries, a firmware abstraction called Dynamic Reconfiguration
Connector (DRC) is used to assign a particular dynamic resource
to the guest and provide an interface to manage configuration/removal
of the resource associated with it. In other words, DRC is the
'plugged state' of a device.
Before this patch, DRC wasn't being migrated. This causes
post-migration problems due to DRC state mismatch between source and
target. The DRC state of a device X in the source might
change, while in the target the DRC state of X is still fresh. When
migrating the guest, X will not have the same hotplugged state as it
did in the source. This means that we can't hot unplug X in the
target after migration is completed because its DRC state is not consistent.
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1677552 is one
bug that is caused by this DRC state mismatch between source and
target.
To migrate the DRC state, we defined the VMStateDescription struct for
spapr_drc to enable the transmission of spapr_drc state in migration.
Not all the elements in the DRC state are migrated - only those
that can be modified by guest actions or device add/remove
operations:
- 'isolation_state', 'allocation_state' and 'indicator_state'
are involved in the DR state transition diagram from
PAPR+ 2.7, 13.4;
- 'configured', 'signalled', 'awaiting_release' and 'awaiting_allocation'
are needed in attaching and detaching devices;
- 'indicator_state' provides users with hardware state information.
These are the DRC elements that are migrated.
In this patch the DRC state is migrated for PCI, LMB and CPU
connector types. At this moment there is no support to migrate
DRC for the PHB (PCI Host Bridge) type.
In the 'realize' function the DRC is registered using vmstate_register,
similar to what hw/ppc/spapr_iommu.c does in 'spapr_tce_table_realize'.
This approach works because DRCs are bus-less and do not sit
on a BusClass that implements bc->get_dev_path, so as a fallback the
VMSD gets identified via "spapr_drc"/get_index(drc).
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-05-22 21:35:49 +02:00
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_spapr_drc = {
|
|
|
|
.name = "spapr_drc",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = spapr_drc_needed,
|
|
|
|
.fields = (VMStateField []) {
|
|
|
|
VMSTATE_UINT32(isolation_state, sPAPRDRConnector),
|
|
|
|
VMSTATE_UINT32(allocation_state, sPAPRDRConnector),
|
2017-06-06 09:42:26 +02:00
|
|
|
VMSTATE_UINT32(dr_indicator, sPAPRDRConnector),
|
hw/ppc: migrating the DRC state of hotplugged devices
In pseries, a firmware abstraction called Dynamic Reconfiguration
Connector (DRC) is used to assign a particular dynamic resource
to the guest and provide an interface to manage configuration/removal
of the resource associated with it. In other words, DRC is the
'plugged state' of a device.
Before this patch, DRC wasn't being migrated. This causes
post-migration problems due to DRC state mismatch between source and
target. The DRC state of a device X in the source might
change, while in the target the DRC state of X is still fresh. When
migrating the guest, X will not have the same hotplugged state as it
did in the source. This means that we can't hot unplug X in the
target after migration is completed because its DRC state is not consistent.
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1677552 is one
bug that is caused by this DRC state mismatch between source and
target.
To migrate the DRC state, we defined the VMStateDescription struct for
spapr_drc to enable the transmission of spapr_drc state in migration.
Not all the elements in the DRC state are migrated - only those
that can be modified by guest actions or device add/remove
operations:
- 'isolation_state', 'allocation_state' and 'indicator_state'
are involved in the DR state transition diagram from
PAPR+ 2.7, 13.4;
- 'configured', 'signalled', 'awaiting_release' and 'awaiting_allocation'
are needed in attaching and detaching devices;
- 'indicator_state' provides users with hardware state information.
These are the DRC elements that are migrated.
In this patch the DRC state is migrated for PCI, LMB and CPU
connector types. At this moment there is no support to migrate
DRC for the PHB (PCI Host Bridge) type.
In the 'realize' function the DRC is registered using vmstate_register,
similar to what hw/ppc/spapr_iommu.c does in 'spapr_tce_table_realize'.
This approach works because DRCs are bus-less and do not sit
on a BusClass that implements bc->get_dev_path, so as a fallback the
VMSD gets identified via "spapr_drc"/get_index(drc).
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-05-22 21:35:49 +02:00
|
|
|
VMSTATE_BOOL(configured, sPAPRDRConnector),
|
|
|
|
VMSTATE_BOOL(awaiting_release, sPAPRDRConnector),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
static void realize(DeviceState *d, Error **errp)
|
|
|
|
{
|
|
|
|
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
|
|
|
|
Object *root_container;
|
|
|
|
char link_name[256];
|
|
|
|
gchar *child_name;
|
|
|
|
Error *err = NULL;
|
|
|
|
|
2017-06-02 05:49:20 +02:00
|
|
|
trace_spapr_drc_realize(spapr_drc_index(drc));
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
/* NOTE: we do this as part of realize/unrealize due to the fact
|
|
|
|
* that the guest will communicate with the DRC via RTAS calls
|
|
|
|
* referencing the global DRC index. By unlinking the DRC
|
|
|
|
* from DRC_CONTAINER_PATH/<drc_index> we effectively make it
|
|
|
|
* inaccessible by the guest, since lookups rely on this path
|
|
|
|
* existing in the composition tree
|
|
|
|
*/
|
|
|
|
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
|
2017-06-02 05:49:20 +02:00
|
|
|
snprintf(link_name, sizeof(link_name), "%x", spapr_drc_index(drc));
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
child_name = object_get_canonical_path_component(OBJECT(drc));
|
2017-06-02 05:49:20 +02:00
|
|
|
trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
object_property_add_alias(root_container, link_name,
|
|
|
|
drc->owner, child_name, &err);
|
|
|
|
if (err) {
|
2015-12-18 16:35:05 +01:00
|
|
|
error_report_err(err);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
object_unref(OBJECT(drc));
|
|
|
|
}
|
2015-07-10 02:51:28 +02:00
|
|
|
g_free(child_name);
|
2017-06-02 05:49:20 +02:00
|
|
|
vmstate_register(DEVICE(drc), spapr_drc_index(drc), &vmstate_spapr_drc,
|
hw/ppc: migrating the DRC state of hotplugged devices
In pseries, a firmware abstraction called Dynamic Reconfiguration
Connector (DRC) is used to assign a particular dynamic resource
to the guest and provide an interface to manage configuration/removal
of the resource associated with it. In other words, DRC is the
'plugged state' of a device.
Before this patch, DRC wasn't being migrated. This causes
post-migration problems due to DRC state mismatch between source and
target. The DRC state of a device X in the source might
change, while in the target the DRC state of X is still fresh. When
migrating the guest, X will not have the same hotplugged state as it
did in the source. This means that we can't hot unplug X in the
target after migration is completed because its DRC state is not consistent.
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1677552 is one
bug that is caused by this DRC state mismatch between source and
target.
To migrate the DRC state, we defined the VMStateDescription struct for
spapr_drc to enable the transmission of spapr_drc state in migration.
Not all the elements in the DRC state are migrated - only those
that can be modified by guest actions or device add/remove
operations:
- 'isolation_state', 'allocation_state' and 'indicator_state'
are involved in the DR state transition diagram from
PAPR+ 2.7, 13.4;
- 'configured', 'signalled', 'awaiting_release' and 'awaiting_allocation'
are needed in attaching and detaching devices;
- 'indicator_state' provides users with hardware state information.
These are the DRC elements that are migrated.
In this patch the DRC state is migrated for PCI, LMB and CPU
connector types. At this moment there is no support to migrate
DRC for the PHB (PCI Host Bridge) type.
In the 'realize' function the DRC is registered using vmstate_register,
similar to what hw/ppc/spapr_iommu.c does in 'spapr_tce_table_realize'.
This approach works because DRCs are bus-less and do not sit
on a BusClass that implements bc->get_dev_path, so as a fallback the
VMSD gets identified via "spapr_drc"/get_index(drc).
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2017-05-22 21:35:49 +02:00
|
|
|
drc);
|
2017-06-08 14:18:34 +02:00
|
|
|
qemu_register_reset(drc_reset, drc);
|
2017-06-02 05:49:20 +02:00
|
|
|
trace_spapr_drc_realize_complete(spapr_drc_index(drc));
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void unrealize(DeviceState *d, Error **errp)
|
|
|
|
{
|
|
|
|
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(d);
|
|
|
|
Object *root_container;
|
|
|
|
char name[256];
|
|
|
|
Error *err = NULL;
|
|
|
|
|
2017-06-02 05:49:20 +02:00
|
|
|
trace_spapr_drc_unrealize(spapr_drc_index(drc));
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
|
2017-06-02 05:49:20 +02:00
|
|
|
snprintf(name, sizeof(name), "%x", spapr_drc_index(drc));
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
object_property_del(root_container, name, &err);
|
|
|
|
if (err) {
|
2015-12-18 16:35:05 +01:00
|
|
|
error_report_err(err);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
object_unref(OBJECT(drc));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-04 12:25:17 +02:00
|
|
|
sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type,
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
uint32_t id)
|
|
|
|
{
|
2017-06-04 12:25:17 +02:00
|
|
|
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(object_new(type));
|
spapr: Don't use QOM [*] syntax for DR connectors.
The dynamic reconfiguration (hotplug) code for the pseries machine type
uses a "DR connector" QOM object for each resource it will be possible
to hotplug. Each of these is added to its owner using
object_property_add_child(owner, "dr-connector[*], ...);
That works ok, mostly, but it means that the property indices are
arbitrary, depending on the order in which the connectors are constructed.
That might line up to something useful, but it doesn't have to.
It will get worse once we add hotplug RAM support. That will add a DR
connector object for every 256MB of potential memory. So if maxmem=2T,
for example, there are 8192 objects under the same parent.
The QOM interfaces aren't really designed for this. In particular
object_property_add() with [*] has O(n^2) time complexity (in the number of
existing children): first it has a linear search through array indices to
find a free slot, each of which is attempted to a recursive call to
object_property_add() with a specific [N]. Those calls are O(n) because
there's a linear search through all properties to check for duplicates.
By using a meaningful index value, which we already know is unique we can
avoid the [*] special behaviour. That lets us reduce the total time for
creating the DR objects from O(n^3) to O(n^2).
O(n^2) is still kind of crappy, but it's enough to reduce the startup time
of qemu (with in-progress memory hotplug support) with maxmem=2T from ~20
minutes to ~4 seconds.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
Tested-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-09-16 08:57:51 +02:00
|
|
|
char *prop_name;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
|
|
|
|
drc->id = id;
|
|
|
|
drc->owner = owner;
|
2017-06-02 05:49:20 +02:00
|
|
|
prop_name = g_strdup_printf("dr-connector[%"PRIu32"]",
|
|
|
|
spapr_drc_index(drc));
|
spapr: Don't use QOM [*] syntax for DR connectors.
The dynamic reconfiguration (hotplug) code for the pseries machine type
uses a "DR connector" QOM object for each resource it will be possible
to hotplug. Each of these is added to its owner using
object_property_add_child(owner, "dr-connector[*], ...);
That works ok, mostly, but it means that the property indices are
arbitrary, depending on the order in which the connectors are constructed.
That might line up to something useful, but it doesn't have to.
It will get worse once we add hotplug RAM support. That will add a DR
connector object for every 256MB of potential memory. So if maxmem=2T,
for example, there are 8192 objects under the same parent.
The QOM interfaces aren't really designed for this. In particular
object_property_add() with [*] has O(n^2) time complexity (in the number of
existing children): first it has a linear search through array indices to
find a free slot, each of which is attempted to a recursive call to
object_property_add() with a specific [N]. Those calls are O(n) because
there's a linear search through all properties to check for duplicates.
By using a meaningful index value, which we already know is unique we can
avoid the [*] special behaviour. That lets us reduce the total time for
creating the DR objects from O(n^3) to O(n^2).
O(n^2) is still kind of crappy, but it's enough to reduce the startup time
of qemu (with in-progress memory hotplug support) with maxmem=2T from ~20
minutes to ~4 seconds.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
Tested-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-09-16 08:57:51 +02:00
|
|
|
object_property_add_child(owner, prop_name, OBJECT(drc), NULL);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
object_property_set_bool(OBJECT(drc), true, "realized", NULL);
|
spapr: Don't use QOM [*] syntax for DR connectors.
The dynamic reconfiguration (hotplug) code for the pseries machine type
uses a "DR connector" QOM object for each resource it will be possible
to hotplug. Each of these is added to its owner using
object_property_add_child(owner, "dr-connector[*], ...);
That works ok, mostly, but it means that the property indices are
arbitrary, depending on the order in which the connectors are constructed.
That might line up to something useful, but it doesn't have to.
It will get worse once we add hotplug RAM support. That will add a DR
connector object for every 256MB of potential memory. So if maxmem=2T,
for example, there are 8192 objects under the same parent.
The QOM interfaces aren't really designed for this. In particular
object_property_add() with [*] has O(n^2) time complexity (in the number of
existing children): first it has a linear search through array indices to
find a free slot, each of which is attempted to a recursive call to
object_property_add() with a specific [N]. Those calls are O(n) because
there's a linear search through all properties to check for duplicates.
By using a meaningful index value, which we already know is unique we can
avoid the [*] special behaviour. That lets us reduce the total time for
creating the DR objects from O(n^3) to O(n^2).
O(n^2) is still kind of crappy, but it's enough to reduce the startup time
of qemu (with in-progress memory hotplug support) with maxmem=2T from ~20
minutes to ~4 seconds.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
Tested-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
2015-09-16 08:57:51 +02:00
|
|
|
g_free(prop_name);
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
|
|
|
|
/* PCI slot always start in a USABLE state, and stay there */
|
2017-06-04 12:25:17 +02:00
|
|
|
if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_PCI) {
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
drc->allocation_state = SPAPR_DR_ALLOCATION_STATE_USABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return drc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spapr_dr_connector_instance_init(Object *obj)
|
|
|
|
{
|
|
|
|
sPAPRDRConnector *drc = SPAPR_DR_CONNECTOR(obj);
|
|
|
|
|
|
|
|
object_property_add_uint32_ptr(obj, "id", &drc->id, NULL);
|
|
|
|
object_property_add(obj, "index", "uint32", prop_get_index,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
object_property_add(obj, "fdt", "struct", prop_get_fdt,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spapr_dr_connector_class_init(ObjectClass *k, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dk = DEVICE_CLASS(k);
|
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
|
|
|
|
|
|
|
|
dk->realize = realize;
|
|
|
|
dk->unrealize = unrealize;
|
|
|
|
drck->release_pending = release_pending;
|
2015-12-03 17:37:40 +01:00
|
|
|
/*
|
|
|
|
* Reason: it crashes FIXME find and document the real reason
|
|
|
|
*/
|
2017-05-03 22:35:44 +02:00
|
|
|
dk->user_creatable = false;
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
|
|
|
|
2017-06-07 03:26:52 +02:00
|
|
|
static void spapr_drc_physical_class_init(ObjectClass *k, void *data)
|
|
|
|
{
|
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
|
|
|
|
|
|
|
|
drck->dr_entity_sense = physical_entity_sense;
|
2017-06-07 16:58:32 +02:00
|
|
|
drck->isolate = drc_isolate_physical;
|
|
|
|
drck->unisolate = drc_unisolate_physical;
|
2017-06-07 03:26:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void spapr_drc_logical_class_init(ObjectClass *k, void *data)
|
|
|
|
{
|
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
|
|
|
|
|
|
|
|
drck->dr_entity_sense = logical_entity_sense;
|
2017-06-07 16:58:32 +02:00
|
|
|
drck->isolate = drc_isolate_logical;
|
|
|
|
drck->unisolate = drc_unisolate_logical;
|
2017-06-07 03:26:52 +02:00
|
|
|
}
|
|
|
|
|
2017-06-04 12:25:17 +02:00
|
|
|
static void spapr_drc_cpu_class_init(ObjectClass *k, void *data)
|
|
|
|
{
|
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
|
|
|
|
|
|
|
|
drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU;
|
2017-06-04 12:26:54 +02:00
|
|
|
drck->typename = "CPU";
|
2017-06-07 04:00:11 +02:00
|
|
|
drck->drc_name_prefix = "CPU ";
|
2017-06-16 10:19:20 +02:00
|
|
|
drck->release = spapr_core_release;
|
2017-06-04 12:25:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void spapr_drc_pci_class_init(ObjectClass *k, void *data)
|
|
|
|
{
|
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
|
|
|
|
|
|
|
|
drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI;
|
2017-06-04 12:26:54 +02:00
|
|
|
drck->typename = "28";
|
2017-06-07 04:00:11 +02:00
|
|
|
drck->drc_name_prefix = "C";
|
2017-06-16 10:19:20 +02:00
|
|
|
drck->release = spapr_phb_remove_pci_device_cb;
|
2017-06-04 12:25:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void spapr_drc_lmb_class_init(ObjectClass *k, void *data)
|
|
|
|
{
|
|
|
|
sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_CLASS(k);
|
|
|
|
|
|
|
|
drck->typeshift = SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB;
|
2017-06-04 12:26:54 +02:00
|
|
|
drck->typename = "MEM";
|
2017-06-07 04:00:11 +02:00
|
|
|
drck->drc_name_prefix = "LMB ";
|
2017-06-16 10:19:20 +02:00
|
|
|
drck->release = spapr_lmb_release;
|
2017-06-04 12:25:17 +02:00
|
|
|
}
|
|
|
|
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
static const TypeInfo spapr_dr_connector_info = {
|
|
|
|
.name = TYPE_SPAPR_DR_CONNECTOR,
|
|
|
|
.parent = TYPE_DEVICE,
|
|
|
|
.instance_size = sizeof(sPAPRDRConnector),
|
|
|
|
.instance_init = spapr_dr_connector_instance_init,
|
|
|
|
.class_size = sizeof(sPAPRDRConnectorClass),
|
|
|
|
.class_init = spapr_dr_connector_class_init,
|
2017-06-04 12:25:17 +02:00
|
|
|
.abstract = true,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const TypeInfo spapr_drc_physical_info = {
|
|
|
|
.name = TYPE_SPAPR_DRC_PHYSICAL,
|
|
|
|
.parent = TYPE_SPAPR_DR_CONNECTOR,
|
2017-06-07 03:26:52 +02:00
|
|
|
.class_init = spapr_drc_physical_class_init,
|
2017-06-04 12:25:17 +02:00
|
|
|
.abstract = true,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const TypeInfo spapr_drc_logical_info = {
|
|
|
|
.name = TYPE_SPAPR_DRC_LOGICAL,
|
|
|
|
.parent = TYPE_SPAPR_DR_CONNECTOR,
|
2017-06-07 03:26:52 +02:00
|
|
|
.class_init = spapr_drc_logical_class_init,
|
2017-06-04 12:25:17 +02:00
|
|
|
.abstract = true,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const TypeInfo spapr_drc_cpu_info = {
|
|
|
|
.name = TYPE_SPAPR_DRC_CPU,
|
|
|
|
.parent = TYPE_SPAPR_DRC_LOGICAL,
|
|
|
|
.class_init = spapr_drc_cpu_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const TypeInfo spapr_drc_pci_info = {
|
|
|
|
.name = TYPE_SPAPR_DRC_PCI,
|
|
|
|
.parent = TYPE_SPAPR_DRC_PHYSICAL,
|
|
|
|
.class_init = spapr_drc_pci_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const TypeInfo spapr_drc_lmb_info = {
|
|
|
|
.name = TYPE_SPAPR_DRC_LMB,
|
|
|
|
.parent = TYPE_SPAPR_DRC_LOGICAL,
|
|
|
|
.class_init = spapr_drc_lmb_class_init,
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* helper functions for external users */
|
|
|
|
|
2017-06-04 12:26:03 +02:00
|
|
|
sPAPRDRConnector *spapr_drc_by_index(uint32_t index)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
|
|
|
Object *obj;
|
|
|
|
char name[256];
|
|
|
|
|
|
|
|
snprintf(name, sizeof(name), "%s/%x", DRC_CONTAINER_PATH, index);
|
|
|
|
obj = object_resolve_path(name, NULL);
|
|
|
|
|
|
|
|
return !obj ? NULL : SPAPR_DR_CONNECTOR(obj);
|
|
|
|
}
|
|
|
|
|
2017-06-04 12:26:03 +02:00
|
|
|
sPAPRDRConnector *spapr_drc_by_id(const char *type, uint32_t id)
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
{
|
2017-06-04 12:26:03 +02:00
|
|
|
sPAPRDRConnectorClass *drck
|
|
|
|
= SPAPR_DR_CONNECTOR_CLASS(object_class_by_name(type));
|
|
|
|
|
|
|
|
return spapr_drc_by_index(drck->typeshift << DRC_INDEX_TYPE_SHIFT
|
|
|
|
| (id & DRC_INDEX_ID_MASK));
|
spapr_drc: initial implementation of sPAPRDRConnector device
This device emulates a firmware abstraction used by pSeries guests to
manage hotplug/dynamic-reconfiguration of host-bridges, PCI devices,
memory, and CPUs. It is conceptually similar to an SHPC device,
complete with LED indicators to identify individual slots to physical
physical users and indicate when it is safe to remove a device. In
some cases it is also used to manage virtualized resources, such a
memory, CPUs, and physical-host bridges, which in the case of pSeries
guests are virtualized resources where the physical components are
managed by the host.
Guests communicate with these DR Connectors using RTAS calls,
generally by addressing the unique DRC index associated with a
particular connector for a particular resource. For introspection
purposes we expose this state initially as QOM properties, and
in subsequent patches will introduce the RTAS calls that make use of
it. This constitutes to the 'guest' interface.
On the QEMU side we provide an attach/detach interface to associate
or cleanup a DeviceState with a particular sPAPRDRConnector in
response to hotplug/unplug, respectively. This constitutes the
'physical' interface to the DR Connector.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
2015-05-07 07:33:43 +02:00
|
|
|
}
|
2015-05-07 07:33:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* spapr_drc_populate_dt
|
|
|
|
*
|
|
|
|
* @fdt: libfdt device tree
|
|
|
|
* @path: path in the DT to generate properties
|
|
|
|
* @owner: parent Object/DeviceState for which to generate DRC
|
|
|
|
* descriptions for
|
|
|
|
* @drc_type_mask: mask of sPAPRDRConnectorType values corresponding
|
|
|
|
* to the types of DRCs to generate entries for
|
|
|
|
*
|
|
|
|
* generate OF properties to describe DRC topology/indices to guests
|
|
|
|
*
|
|
|
|
* as documented in PAPR+ v2.1, 13.5.2
|
|
|
|
*/
|
|
|
|
int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner,
|
|
|
|
uint32_t drc_type_mask)
|
|
|
|
{
|
|
|
|
Object *root_container;
|
|
|
|
ObjectProperty *prop;
|
2015-12-09 13:34:02 +01:00
|
|
|
ObjectPropertyIterator iter;
|
2015-05-07 07:33:51 +02:00
|
|
|
uint32_t drc_count = 0;
|
|
|
|
GArray *drc_indexes, *drc_power_domains;
|
|
|
|
GString *drc_names, *drc_types;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* the first entry of each properties is a 32-bit integer encoding
|
|
|
|
* the number of elements in the array. we won't know this until
|
|
|
|
* we complete the iteration through all the matching DRCs, but
|
|
|
|
* reserve the space now and set the offsets accordingly so we
|
|
|
|
* can fill them in later.
|
|
|
|
*/
|
|
|
|
drc_indexes = g_array_new(false, true, sizeof(uint32_t));
|
|
|
|
drc_indexes = g_array_set_size(drc_indexes, 1);
|
|
|
|
drc_power_domains = g_array_new(false, true, sizeof(uint32_t));
|
|
|
|
drc_power_domains = g_array_set_size(drc_power_domains, 1);
|
|
|
|
drc_names = g_string_set_size(g_string_new(NULL), sizeof(uint32_t));
|
|
|
|
drc_types = g_string_set_size(g_string_new(NULL), sizeof(uint32_t));
|
|
|
|
|
|
|
|
/* aliases for all DRConnector objects will be rooted in QOM
|
|
|
|
* composition tree at DRC_CONTAINER_PATH
|
|
|
|
*/
|
|
|
|
root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
|
|
|
|
|
2015-12-09 13:34:02 +01:00
|
|
|
object_property_iter_init(&iter, root_container);
|
|
|
|
while ((prop = object_property_iter_next(&iter))) {
|
2015-05-07 07:33:51 +02:00
|
|
|
Object *obj;
|
|
|
|
sPAPRDRConnector *drc;
|
|
|
|
sPAPRDRConnectorClass *drck;
|
|
|
|
uint32_t drc_index, drc_power_domain;
|
|
|
|
|
|
|
|
if (!strstart(prop->type, "link<", NULL)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj = object_property_get_link(root_container, prop->name, NULL);
|
|
|
|
drc = SPAPR_DR_CONNECTOR(obj);
|
|
|
|
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
|
|
|
|
|
|
|
if (owner && (drc->owner != owner)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-06-04 12:25:17 +02:00
|
|
|
if ((spapr_drc_type(drc) & drc_type_mask) == 0) {
|
2015-05-07 07:33:51 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
drc_count++;
|
|
|
|
|
|
|
|
/* ibm,drc-indexes */
|
2017-06-02 05:49:20 +02:00
|
|
|
drc_index = cpu_to_be32(spapr_drc_index(drc));
|
2015-05-07 07:33:51 +02:00
|
|
|
g_array_append_val(drc_indexes, drc_index);
|
|
|
|
|
|
|
|
/* ibm,drc-power-domains */
|
|
|
|
drc_power_domain = cpu_to_be32(-1);
|
|
|
|
g_array_append_val(drc_power_domains, drc_power_domain);
|
|
|
|
|
|
|
|
/* ibm,drc-names */
|
2017-06-07 04:00:11 +02:00
|
|
|
drc_names = g_string_append(drc_names, spapr_drc_name(drc));
|
2015-05-07 07:33:51 +02:00
|
|
|
drc_names = g_string_insert_len(drc_names, -1, "\0", 1);
|
|
|
|
|
|
|
|
/* ibm,drc-types */
|
2017-06-04 12:26:54 +02:00
|
|
|
drc_types = g_string_append(drc_types, drck->typename);
|
2015-05-07 07:33:51 +02:00
|
|
|
drc_types = g_string_insert_len(drc_types, -1, "\0", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now write the drc count into the space we reserved at the
|
|
|
|
* beginning of the arrays previously
|
|
|
|
*/
|
|
|
|
*(uint32_t *)drc_indexes->data = cpu_to_be32(drc_count);
|
|
|
|
*(uint32_t *)drc_power_domains->data = cpu_to_be32(drc_count);
|
|
|
|
*(uint32_t *)drc_names->str = cpu_to_be32(drc_count);
|
|
|
|
*(uint32_t *)drc_types->str = cpu_to_be32(drc_count);
|
|
|
|
|
|
|
|
ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-indexes",
|
|
|
|
drc_indexes->data,
|
|
|
|
drc_indexes->len * sizeof(uint32_t));
|
|
|
|
if (ret) {
|
2016-08-02 19:38:00 +02:00
|
|
|
error_report("Couldn't create ibm,drc-indexes property");
|
2015-05-07 07:33:51 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-power-domains",
|
|
|
|
drc_power_domains->data,
|
|
|
|
drc_power_domains->len * sizeof(uint32_t));
|
|
|
|
if (ret) {
|
2016-08-02 19:38:00 +02:00
|
|
|
error_report("Couldn't finalize ibm,drc-power-domains property");
|
2015-05-07 07:33:51 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-names",
|
|
|
|
drc_names->str, drc_names->len);
|
|
|
|
if (ret) {
|
2016-08-02 19:38:00 +02:00
|
|
|
error_report("Couldn't finalize ibm,drc-names property");
|
2015-05-07 07:33:51 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-types",
|
|
|
|
drc_types->str, drc_types->len);
|
|
|
|
if (ret) {
|
2016-08-02 19:38:00 +02:00
|
|
|
error_report("Couldn't finalize ibm,drc-types property");
|
2015-05-07 07:33:51 +02:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
g_array_free(drc_indexes, true);
|
|
|
|
g_array_free(drc_power_domains, true);
|
|
|
|
g_string_free(drc_names, true);
|
|
|
|
g_string_free(drc_types, true);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2017-06-01 02:30:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* RTAS calls
|
|
|
|
*/
|
|
|
|
|
2017-06-06 09:05:53 +02:00
|
|
|
static uint32_t rtas_set_isolation_state(uint32_t idx, uint32_t state)
|
2017-06-01 02:30:00 +02:00
|
|
|
{
|
2017-06-06 09:05:53 +02:00
|
|
|
sPAPRDRConnector *drc = spapr_drc_by_index(idx);
|
|
|
|
sPAPRDRConnectorClass *drck;
|
|
|
|
|
|
|
|
if (!drc) {
|
2017-06-07 16:58:32 +02:00
|
|
|
return RTAS_OUT_NO_SUCH_INDICATOR;
|
2017-06-01 02:30:00 +02:00
|
|
|
}
|
|
|
|
|
2017-06-07 16:58:32 +02:00
|
|
|
trace_spapr_drc_set_isolation_state(spapr_drc_index(drc), state);
|
|
|
|
|
2017-06-06 09:05:53 +02:00
|
|
|
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
2017-06-07 16:58:32 +02:00
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case SPAPR_DR_ISOLATION_STATE_ISOLATED:
|
|
|
|
return drck->isolate(drc);
|
|
|
|
|
|
|
|
case SPAPR_DR_ISOLATION_STATE_UNISOLATED:
|
|
|
|
return drck->unisolate(drc);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return RTAS_OUT_PARAM_ERROR;
|
|
|
|
}
|
2017-06-01 02:30:00 +02:00
|
|
|
}
|
|
|
|
|
2017-06-06 09:05:53 +02:00
|
|
|
static uint32_t rtas_set_allocation_state(uint32_t idx, uint32_t state)
|
2017-06-01 02:30:00 +02:00
|
|
|
{
|
2017-06-06 09:05:53 +02:00
|
|
|
sPAPRDRConnector *drc = spapr_drc_by_index(idx);
|
2017-06-01 02:30:00 +02:00
|
|
|
|
2017-06-07 16:50:19 +02:00
|
|
|
if (!drc || !object_dynamic_cast(OBJECT(drc), TYPE_SPAPR_DRC_LOGICAL)) {
|
|
|
|
return RTAS_OUT_NO_SUCH_INDICATOR;
|
2017-06-01 02:30:00 +02:00
|
|
|
}
|
|
|
|
|
2017-06-07 16:50:19 +02:00
|
|
|
trace_spapr_drc_set_allocation_state(spapr_drc_index(drc), state);
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case SPAPR_DR_ALLOCATION_STATE_USABLE:
|
|
|
|
return drc_set_usable(drc);
|
|
|
|
|
|
|
|
case SPAPR_DR_ALLOCATION_STATE_UNUSABLE:
|
|
|
|
return drc_set_unusable(drc);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return RTAS_OUT_PARAM_ERROR;
|
|
|
|
}
|
2017-06-06 09:05:53 +02:00
|
|
|
}
|
2017-06-01 02:30:00 +02:00
|
|
|
|
2017-06-06 09:42:26 +02:00
|
|
|
static uint32_t rtas_set_dr_indicator(uint32_t idx, uint32_t state)
|
2017-06-06 09:05:53 +02:00
|
|
|
{
|
|
|
|
sPAPRDRConnector *drc = spapr_drc_by_index(idx);
|
2017-06-01 02:30:00 +02:00
|
|
|
|
|
|
|
if (!drc) {
|
2017-06-06 09:05:53 +02:00
|
|
|
return RTAS_OUT_PARAM_ERROR;
|
|
|
|
}
|
|
|
|
|
2017-06-06 09:42:26 +02:00
|
|
|
trace_spapr_drc_set_dr_indicator(idx, state);
|
|
|
|
drc->dr_indicator = state;
|
|
|
|
return RTAS_OUT_SUCCESS;
|
2017-06-06 09:05:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rtas_set_indicator(PowerPCCPU *cpu, sPAPRMachineState *spapr,
|
|
|
|
uint32_t token,
|
|
|
|
uint32_t nargs, target_ulong args,
|
|
|
|
uint32_t nret, target_ulong rets)
|
|
|
|
{
|
|
|
|
uint32_t type, idx, state;
|
|
|
|
uint32_t ret = RTAS_OUT_SUCCESS;
|
|
|
|
|
|
|
|
if (nargs != 3 || nret != 1) {
|
2017-06-01 02:30:00 +02:00
|
|
|
ret = RTAS_OUT_PARAM_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-06-06 09:05:53 +02:00
|
|
|
type = rtas_ld(args, 0);
|
|
|
|
idx = rtas_ld(args, 1);
|
|
|
|
state = rtas_ld(args, 2);
|
|
|
|
|
|
|
|
switch (type) {
|
2017-06-01 02:30:00 +02:00
|
|
|
case RTAS_SENSOR_TYPE_ISOLATION_STATE:
|
2017-06-06 09:05:53 +02:00
|
|
|
ret = rtas_set_isolation_state(idx, state);
|
2017-06-01 02:30:00 +02:00
|
|
|
break;
|
|
|
|
case RTAS_SENSOR_TYPE_DR:
|
2017-06-06 09:42:26 +02:00
|
|
|
ret = rtas_set_dr_indicator(idx, state);
|
2017-06-01 02:30:00 +02:00
|
|
|
break;
|
|
|
|
case RTAS_SENSOR_TYPE_ALLOCATION_STATE:
|
2017-06-06 09:05:53 +02:00
|
|
|
ret = rtas_set_allocation_state(idx, state);
|
2017-06-01 02:30:00 +02:00
|
|
|
break;
|
|
|
|
default:
|
2017-06-06 09:05:53 +02:00
|
|
|
ret = RTAS_OUT_NOT_SUPPORTED;
|
2017-06-01 02:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
rtas_st(rets, 0, ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rtas_get_sensor_state(PowerPCCPU *cpu, sPAPRMachineState *spapr,
|
|
|
|
uint32_t token, uint32_t nargs,
|
|
|
|
target_ulong args, uint32_t nret,
|
|
|
|
target_ulong rets)
|
|
|
|
{
|
|
|
|
uint32_t sensor_type;
|
|
|
|
uint32_t sensor_index;
|
|
|
|
uint32_t sensor_state = 0;
|
|
|
|
sPAPRDRConnector *drc;
|
|
|
|
sPAPRDRConnectorClass *drck;
|
|
|
|
uint32_t ret = RTAS_OUT_SUCCESS;
|
|
|
|
|
|
|
|
if (nargs != 2 || nret != 2) {
|
|
|
|
ret = RTAS_OUT_PARAM_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
sensor_type = rtas_ld(args, 0);
|
|
|
|
sensor_index = rtas_ld(args, 1);
|
|
|
|
|
|
|
|
if (sensor_type != RTAS_SENSOR_TYPE_ENTITY_SENSE) {
|
|
|
|
/* currently only DR-related sensors are implemented */
|
|
|
|
trace_spapr_rtas_get_sensor_state_not_supported(sensor_index,
|
|
|
|
sensor_type);
|
|
|
|
ret = RTAS_OUT_NOT_SUPPORTED;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-06-04 12:26:03 +02:00
|
|
|
drc = spapr_drc_by_index(sensor_index);
|
2017-06-01 02:30:00 +02:00
|
|
|
if (!drc) {
|
|
|
|
trace_spapr_rtas_get_sensor_state_invalid(sensor_index);
|
|
|
|
ret = RTAS_OUT_PARAM_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
|
2017-06-07 03:26:52 +02:00
|
|
|
sensor_state = drck->dr_entity_sense(drc);
|
2017-06-01 02:30:00 +02:00
|
|
|
|
|
|
|
out:
|
|
|
|
rtas_st(rets, 0, ret);
|
|
|
|
rtas_st(rets, 1, sensor_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* configure-connector work area offsets, int32_t units for field
|
|
|
|
* indexes, bytes for field offset/len values.
|
|
|
|
*
|
|
|
|
* as documented by PAPR+ v2.7, 13.5.3.5
|
|
|
|
*/
|
|
|
|
#define CC_IDX_NODE_NAME_OFFSET 2
|
|
|
|
#define CC_IDX_PROP_NAME_OFFSET 2
|
|
|
|
#define CC_IDX_PROP_LEN 3
|
|
|
|
#define CC_IDX_PROP_DATA_OFFSET 4
|
|
|
|
#define CC_VAL_DATA_OFFSET ((CC_IDX_PROP_DATA_OFFSET + 1) * 4)
|
|
|
|
#define CC_WA_LEN 4096
|
|
|
|
|
|
|
|
static void configure_connector_st(target_ulong addr, target_ulong offset,
|
|
|
|
const void *buf, size_t len)
|
|
|
|
{
|
|
|
|
cpu_physical_memory_write(ppc64_phys_to_real(addr + offset),
|
|
|
|
buf, MIN(len, CC_WA_LEN - offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rtas_ibm_configure_connector(PowerPCCPU *cpu,
|
|
|
|
sPAPRMachineState *spapr,
|
|
|
|
uint32_t token, uint32_t nargs,
|
|
|
|
target_ulong args, uint32_t nret,
|
|
|
|
target_ulong rets)
|
|
|
|
{
|
|
|
|
uint64_t wa_addr;
|
|
|
|
uint64_t wa_offset;
|
|
|
|
uint32_t drc_index;
|
|
|
|
sPAPRDRConnector *drc;
|
|
|
|
sPAPRConfigureConnectorState *ccs;
|
|
|
|
sPAPRDRCCResponse resp = SPAPR_DR_CC_RESPONSE_CONTINUE;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (nargs != 2 || nret != 1) {
|
|
|
|
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wa_addr = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 0);
|
|
|
|
|
|
|
|
drc_index = rtas_ld(wa_addr, 0);
|
2017-06-04 12:26:03 +02:00
|
|
|
drc = spapr_drc_by_index(drc_index);
|
2017-06-01 02:30:00 +02:00
|
|
|
if (!drc) {
|
|
|
|
trace_spapr_rtas_ibm_configure_connector_invalid(drc_index);
|
|
|
|
rc = RTAS_OUT_PARAM_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-06-01 02:36:24 +02:00
|
|
|
if (!drc->fdt) {
|
2017-06-01 02:30:00 +02:00
|
|
|
trace_spapr_rtas_ibm_configure_connector_missing_fdt(drc_index);
|
|
|
|
rc = SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-06-04 12:26:25 +02:00
|
|
|
ccs = drc->ccs;
|
2017-06-01 02:30:00 +02:00
|
|
|
if (!ccs) {
|
|
|
|
ccs = g_new0(sPAPRConfigureConnectorState, 1);
|
2017-06-01 02:36:24 +02:00
|
|
|
ccs->fdt_offset = drc->fdt_start_offset;
|
2017-06-04 12:26:25 +02:00
|
|
|
drc->ccs = ccs;
|
2017-06-01 02:30:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
uint32_t tag;
|
|
|
|
const char *name;
|
|
|
|
const struct fdt_property *prop;
|
|
|
|
int fdt_offset_next, prop_len;
|
|
|
|
|
2017-06-01 02:36:24 +02:00
|
|
|
tag = fdt_next_tag(drc->fdt, ccs->fdt_offset, &fdt_offset_next);
|
2017-06-01 02:30:00 +02:00
|
|
|
|
|
|
|
switch (tag) {
|
|
|
|
case FDT_BEGIN_NODE:
|
|
|
|
ccs->fdt_depth++;
|
2017-06-01 02:36:24 +02:00
|
|
|
name = fdt_get_name(drc->fdt, ccs->fdt_offset, NULL);
|
2017-06-01 02:30:00 +02:00
|
|
|
|
|
|
|
/* provide the name of the next OF node */
|
|
|
|
wa_offset = CC_VAL_DATA_OFFSET;
|
|
|
|
rtas_st(wa_addr, CC_IDX_NODE_NAME_OFFSET, wa_offset);
|
|
|
|
configure_connector_st(wa_addr, wa_offset, name, strlen(name) + 1);
|
|
|
|
resp = SPAPR_DR_CC_RESPONSE_NEXT_CHILD;
|
|
|
|
break;
|
|
|
|
case FDT_END_NODE:
|
|
|
|
ccs->fdt_depth--;
|
|
|
|
if (ccs->fdt_depth == 0) {
|
2017-06-02 05:36:10 +02:00
|
|
|
sPAPRDRIsolationState state = drc->isolation_state;
|
2017-06-02 05:49:20 +02:00
|
|
|
uint32_t drc_index = spapr_drc_index(drc);
|
2017-06-01 02:30:00 +02:00
|
|
|
/* done sending the device tree, don't need to track
|
|
|
|
* the state anymore
|
|
|
|
*/
|
2017-06-02 05:49:20 +02:00
|
|
|
trace_spapr_drc_set_configured(drc_index);
|
2017-06-02 05:36:10 +02:00
|
|
|
if (state == SPAPR_DR_ISOLATION_STATE_UNISOLATED) {
|
|
|
|
drc->configured = true;
|
|
|
|
} else {
|
|
|
|
/* guest should be not configuring an isolated device */
|
2017-06-02 05:49:20 +02:00
|
|
|
trace_spapr_drc_set_configured_skipping(drc_index);
|
2017-06-02 05:36:10 +02:00
|
|
|
}
|
2017-06-04 12:26:25 +02:00
|
|
|
g_free(ccs);
|
|
|
|
drc->ccs = NULL;
|
2017-06-01 02:30:00 +02:00
|
|
|
ccs = NULL;
|
|
|
|
resp = SPAPR_DR_CC_RESPONSE_SUCCESS;
|
|
|
|
} else {
|
|
|
|
resp = SPAPR_DR_CC_RESPONSE_PREV_PARENT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FDT_PROP:
|
2017-06-01 02:36:24 +02:00
|
|
|
prop = fdt_get_property_by_offset(drc->fdt, ccs->fdt_offset,
|
2017-06-01 02:30:00 +02:00
|
|
|
&prop_len);
|
2017-06-01 02:36:24 +02:00
|
|
|
name = fdt_string(drc->fdt, fdt32_to_cpu(prop->nameoff));
|
2017-06-01 02:30:00 +02:00
|
|
|
|
|
|
|
/* provide the name of the next OF property */
|
|
|
|
wa_offset = CC_VAL_DATA_OFFSET;
|
|
|
|
rtas_st(wa_addr, CC_IDX_PROP_NAME_OFFSET, wa_offset);
|
|
|
|
configure_connector_st(wa_addr, wa_offset, name, strlen(name) + 1);
|
|
|
|
|
|
|
|
/* provide the length and value of the OF property. data gets
|
|
|
|
* placed immediately after NULL terminator of the OF property's
|
|
|
|
* name string
|
|
|
|
*/
|
|
|
|
wa_offset += strlen(name) + 1,
|
|
|
|
rtas_st(wa_addr, CC_IDX_PROP_LEN, prop_len);
|
|
|
|
rtas_st(wa_addr, CC_IDX_PROP_DATA_OFFSET, wa_offset);
|
|
|
|
configure_connector_st(wa_addr, wa_offset, prop->data, prop_len);
|
|
|
|
resp = SPAPR_DR_CC_RESPONSE_NEXT_PROPERTY;
|
|
|
|
break;
|
|
|
|
case FDT_END:
|
|
|
|
resp = SPAPR_DR_CC_RESPONSE_ERROR;
|
|
|
|
default:
|
|
|
|
/* keep seeking for an actionable tag */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ccs) {
|
|
|
|
ccs->fdt_offset = fdt_offset_next;
|
|
|
|
}
|
|
|
|
} while (resp == SPAPR_DR_CC_RESPONSE_CONTINUE);
|
|
|
|
|
|
|
|
rc = resp;
|
|
|
|
out:
|
|
|
|
rtas_st(rets, 0, rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spapr_drc_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&spapr_dr_connector_info);
|
2017-06-04 12:25:17 +02:00
|
|
|
type_register_static(&spapr_drc_physical_info);
|
|
|
|
type_register_static(&spapr_drc_logical_info);
|
|
|
|
type_register_static(&spapr_drc_cpu_info);
|
|
|
|
type_register_static(&spapr_drc_pci_info);
|
|
|
|
type_register_static(&spapr_drc_lmb_info);
|
2017-06-01 02:30:00 +02:00
|
|
|
|
|
|
|
spapr_rtas_register(RTAS_SET_INDICATOR, "set-indicator",
|
|
|
|
rtas_set_indicator);
|
|
|
|
spapr_rtas_register(RTAS_GET_SENSOR_STATE, "get-sensor-state",
|
|
|
|
rtas_get_sensor_state);
|
|
|
|
spapr_rtas_register(RTAS_IBM_CONFIGURE_CONNECTOR, "ibm,configure-connector",
|
|
|
|
rtas_ibm_configure_connector);
|
|
|
|
}
|
|
|
|
type_init(spapr_drc_register_types)
|