From 88af6ea5687b1fdad47dad44eb9ff67c459c7dcc Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 1 Jun 2017 10:36:24 +1000 Subject: spapr: Abolish DRC get_fdt method The DRConnectorClass includes a get_fdt method. However * There's only one implementation, and there's only likely to ever be one * Both callers are local to spapr_drc * Each caller only uses one half of the actual implementation So abolish get_fdt() entirely, and just open-code what we need. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Reviewed-by: Greg Kurz Tested-by: Daniel Barboza --- include/hw/ppc/spapr_drc.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/hw/ppc') diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 813b9ff..80db955 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -178,7 +178,6 @@ typedef struct sPAPRDRConnectorClass { uint32_t (*entity_sense)(sPAPRDRConnector *drc, sPAPRDREntitySense *state); /* QEMU interfaces for managing FDT/configure-connector */ - const void *(*get_fdt)(sPAPRDRConnector *drc, int *fdt_start_offset); void (*set_configured)(sPAPRDRConnector *drc); /* QEMU interfaces for managing hotplug operations */ -- cgit v1.1 From 4f65ce00ab9b059ed1aadc18718760ffd0c60a68 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 2 Jun 2017 13:36:10 +1000 Subject: spapr: Abolish DRC set_configured method DRConnectorClass has a set_configured method, however: * There is only one implementation, and only ever likely to be one * There's exactly one caller, and that's (now) local * The implementation is very straightforward So abolish the method entirely, and just open-code what we need. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Reviewed-by: Greg Kurz Tested-by: Daniel Barboza --- include/hw/ppc/spapr_drc.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include/hw/ppc') diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 80db955..90f4953 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -177,9 +177,6 @@ typedef struct sPAPRDRConnectorClass { uint32_t (*entity_sense)(sPAPRDRConnector *drc, sPAPRDREntitySense *state); - /* QEMU interfaces for managing FDT/configure-connector */ - void (*set_configured)(sPAPRDRConnector *drc); - /* QEMU interfaces for managing hotplug operations */ void (*attach)(sPAPRDRConnector *drc, DeviceState *d, void *fdt, int fdt_start_offset, bool coldplug, Error **errp); -- cgit v1.1 From 0b55aa91c976b30b527c123fb66d25f5db43d083 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 2 Jun 2017 13:49:20 +1000 Subject: spapr: Make DRC get_index and get_type methods into plain functions These two methods only have one implementation, and the spec they're implementing means any other implementation is unlikely, verging on impossible. So replace them with simple functions. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Tested-by: Daniel Barboza --- include/hw/ppc/spapr_drc.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/hw/ppc') diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 90f4953..10e7c24 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -171,8 +171,6 @@ typedef struct sPAPRDRConnectorClass { sPAPRDRIndicatorState state); uint32_t (*set_allocation_state)(sPAPRDRConnector *drc, sPAPRDRAllocationState state); - uint32_t (*get_index)(sPAPRDRConnector *drc); - uint32_t (*get_type)(sPAPRDRConnector *drc); const char *(*get_name)(sPAPRDRConnector *drc); uint32_t (*entity_sense)(sPAPRDRConnector *drc, sPAPRDREntitySense *state); @@ -185,6 +183,9 @@ typedef struct sPAPRDRConnectorClass { void (*set_signalled)(sPAPRDRConnector *drc); } sPAPRDRConnectorClass; +uint32_t spapr_drc_index(sPAPRDRConnector *drc); +sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc); + sPAPRDRConnector *spapr_dr_connector_new(Object *owner, sPAPRDRConnectorType type, uint32_t id); -- cgit v1.1 From 2d33581899edcaba9b7e48def11c4ddfcd2423ec Mon Sep 17 00:00:00 2001 From: David Gibson Date: Sun, 4 Jun 2017 20:25:17 +1000 Subject: spapr: Introduce DRC subclasses Currently we only have a single QOM type for all DRCs, but lots of places where we switch behaviour based on the DRC's PAPR defined type. This is a poor use of our existing type system. So, instead create QOM subclasses for each PAPR defined DRC type. We also introduce intermediate subclasses for physical and logical DRCs, a division which will be useful later on. Instead of being stored in the DRC object itself, the PAPR type is now stored in the class structure. There are still many places where we switch directly on the PAPR type value, but this at least provides the basis to start to remove those. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- include/hw/ppc/spapr_drc.h | 47 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'include/hw/ppc') diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 10e7c24..969c16d 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -26,6 +26,48 @@ #define SPAPR_DR_CONNECTOR(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ TYPE_SPAPR_DR_CONNECTOR) +#define TYPE_SPAPR_DRC_PHYSICAL "spapr-drc-physical" +#define SPAPR_DRC_PHYSICAL_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_PHYSICAL) +#define SPAPR_DRC_PHYSICAL_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, \ + TYPE_SPAPR_DRC_PHYSICAL) +#define SPAPR_DRC_PHYSICAL(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_PHYSICAL) + +#define TYPE_SPAPR_DRC_LOGICAL "spapr-drc-logical" +#define SPAPR_DRC_LOGICAL_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_LOGICAL) +#define SPAPR_DRC_LOGICAL_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, \ + TYPE_SPAPR_DRC_LOGICAL) +#define SPAPR_DRC_LOGICAL(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_LOGICAL) + +#define TYPE_SPAPR_DRC_CPU "spapr-drc-cpu" +#define SPAPR_DRC_CPU_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_CPU) +#define SPAPR_DRC_CPU_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_CPU) +#define SPAPR_DRC_CPU(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_CPU) + +#define TYPE_SPAPR_DRC_PCI "spapr-drc-pci" +#define SPAPR_DRC_PCI_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_PCI) +#define SPAPR_DRC_PCI_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_PCI) +#define SPAPR_DRC_PCI(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_PCI) + +#define TYPE_SPAPR_DRC_LMB "spapr-drc-lmb" +#define SPAPR_DRC_LMB_GET_CLASS(obj) \ + OBJECT_GET_CLASS(sPAPRDRConnectorClass, obj, TYPE_SPAPR_DRC_LMB) +#define SPAPR_DRC_LMB_CLASS(klass) \ + OBJECT_CLASS_CHECK(sPAPRDRConnectorClass, klass, TYPE_SPAPR_DRC_LMB) +#define SPAPR_DRC_LMB(obj) OBJECT_CHECK(sPAPRDRConnector, (obj), \ + TYPE_SPAPR_DRC_LMB) + /* * Various hotplug types managed by sPAPRDRConnector * @@ -134,7 +176,6 @@ typedef struct sPAPRDRConnector { /*< private >*/ DeviceState parent; - sPAPRDRConnectorType type; uint32_t id; Object *owner; const char *name; @@ -163,6 +204,7 @@ typedef struct sPAPRDRConnectorClass { DeviceClass parent; /*< public >*/ + sPAPRDRConnectorTypeShift typeshift; /* accessors for guest-visible (generally via RTAS) DR state */ uint32_t (*set_isolation_state)(sPAPRDRConnector *drc, @@ -186,8 +228,7 @@ typedef struct sPAPRDRConnectorClass { uint32_t spapr_drc_index(sPAPRDRConnector *drc); sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc); -sPAPRDRConnector *spapr_dr_connector_new(Object *owner, - sPAPRDRConnectorType type, +sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type, uint32_t id); sPAPRDRConnector *spapr_dr_connector_by_index(uint32_t index); sPAPRDRConnector *spapr_dr_connector_by_id(sPAPRDRConnectorType type, -- cgit v1.1 From fbf553971898aee18b5933d335e2fa3e74bb9be7 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Sun, 4 Jun 2017 20:26:03 +1000 Subject: spapr: Clean up spapr_dr_connector_by_*() * Change names to something less ludicrously verbose * Now that we have QOM subclasses for the different DRC types, use a QOM typename instead of a PAPR type value parameter The latter allows removal of the get_type_shift() helper. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- include/hw/ppc/spapr_drc.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include/hw/ppc') diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 969c16d..e4a25c8 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -230,9 +230,8 @@ sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc); sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type, uint32_t id); -sPAPRDRConnector *spapr_dr_connector_by_index(uint32_t index); -sPAPRDRConnector *spapr_dr_connector_by_id(sPAPRDRConnectorType type, - uint32_t id); +sPAPRDRConnector *spapr_drc_by_index(uint32_t index); +sPAPRDRConnector *spapr_drc_by_id(const char *type, uint32_t id); int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner, uint32_t drc_type_mask); -- cgit v1.1 From b8fdd530be3450940130b63d930bb0aee1538e7e Mon Sep 17 00:00:00 2001 From: David Gibson Date: Sun, 4 Jun 2017 20:26:25 +1000 Subject: spapr: Move configure-connector state into DRC Currently the sPAPRMachineState contains a list of sPAPRConfigureConnector structures which store intermediate state for the ibm,configure-connector RTAS call. This was an attempt to separate this state from the core of the DRC state. However the configure connector process is intimately tied to the DRC model, so there's really no point trying to have two levels of interface here. Moving the configure-connector state into its corresponding DRC allows removal of a number of helpers for maintaining the anciliary list. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- include/hw/ppc/spapr.h | 14 -------------- include/hw/ppc/spapr_drc.h | 7 +++++++ 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'include/hw/ppc') diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 98fb78b..f973b02 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -11,7 +11,6 @@ struct VIOsPAPRBus; struct sPAPRPHBState; struct sPAPRNVRAM; -typedef struct sPAPRConfigureConnectorState sPAPRConfigureConnectorState; typedef struct sPAPREventLogEntry sPAPREventLogEntry; typedef struct sPAPREventSource sPAPREventSource; @@ -102,9 +101,6 @@ struct sPAPRMachineState { bool htab_first_pass; int htab_fd; - /* RTAS state */ - QTAILQ_HEAD(, sPAPRConfigureConnectorState) ccs_list; - /* Pending DIMM unplug cache. It is populated when a LMB * unplug starts. It can be regenerated if a migration * occurs during the unplug process. */ @@ -646,16 +642,6 @@ void *spapr_populate_hotplug_cpu_dt(CPUState *cs, int *fdt_offset, void spapr_core_release(DeviceState *dev); void spapr_lmb_release(DeviceState *dev); -/* rtas-configure-connector state */ -struct sPAPRConfigureConnectorState { - uint32_t drc_index; - int fdt_offset; - int fdt_depth; - QTAILQ_ENTRY(sPAPRConfigureConnectorState) next; -}; - -void spapr_ccs_reset_hook(void *opaque); - void spapr_rtc_read(sPAPRRTCState *rtc, struct tm *tm, uint32_t *ns); int spapr_rtc_import_offset(sPAPRRTCState *rtc, int64_t legacy_offset); diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index e4a25c8..7dbb478 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -172,6 +172,12 @@ typedef enum { SPAPR_DR_CC_RESPONSE_NOT_CONFIGURABLE = -9003, } sPAPRDRCCResponse; +/* rtas-configure-connector state */ +typedef struct sPAPRConfigureConnectorState { + int fdt_offset; + int fdt_depth; +} sPAPRConfigureConnectorState; + typedef struct sPAPRDRConnector { /*< private >*/ DeviceState parent; @@ -189,6 +195,7 @@ typedef struct sPAPRDRConnector { void *fdt; int fdt_start_offset; bool configured; + sPAPRConfigureConnectorState *ccs; bool awaiting_release; bool signalled; -- cgit v1.1 From 1693ea168575849bc2784e193002c317ef3eee39 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Sun, 4 Jun 2017 20:26:54 +1000 Subject: spapr: Eliminate spapr_drc_get_type_str() This function was used in generating the device tree. However, now that we have different QOM types for different DRC types we can easily store the information we need in the class structure and avoid this specialized lookup function. Signed-off-by: David Gibson Reviewed-by: Michael Roth Acked-by: Michael Roth --- include/hw/ppc/spapr_drc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/hw/ppc') diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 7dbb478..c88e1be 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -212,6 +212,7 @@ typedef struct sPAPRDRConnectorClass { /*< public >*/ sPAPRDRConnectorTypeShift typeshift; + const char *typename; /* used in device tree, PAPR 13.5.2.6 & C.6.1 */ /* accessors for guest-visible (generally via RTAS) DR state */ uint32_t (*set_isolation_state)(sPAPRDRConnector *drc, -- cgit v1.1