From nobody Wed Nov 5 17:43:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14968062222261015.66060439222; Tue, 6 Jun 2017 20:30:22 -0700 (PDT) Received: from localhost ([::1]:41073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIRfo-0003eo-Fi for importer@patchew.org; Tue, 06 Jun 2017 23:30:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIRWK-0003at-K4 for qemu-devel@nongnu.org; Tue, 06 Jun 2017 23:20:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIRWI-0002UB-Gd for qemu-devel@nongnu.org; Tue, 06 Jun 2017 23:20:32 -0400 Received: from ozlabs.org ([103.22.144.67]:48811) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIRWH-0002Sv-Ti; Tue, 06 Jun 2017 23:20:30 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3wjDMW29k7z9sNH; Wed, 7 Jun 2017 13:20:22 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496805623; bh=NWDC4O3IIRMw85jaIr7GNF7ABQaN2wiyxTDlpprqaI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qRgKqRTpjLj/llBXH3EE4rDfEkpEe0eUe+itH0ll1MFeEVLmTMfwB6i0gxwpRUGZG C7jJEfmet7t7n7KLANWP8jJ21OUyZ6yIvtOFs0PzthShOWVyD9lWR/M5UJ8+FWQEWe nVbjeYHwbJpWG1KA93inuOfuyWKZ2Nsk0KNuaYig= From: David Gibson To: mdroth@linux.vnet.ibm.com Date: Wed, 7 Jun 2017 13:20:18 +1000 Message-Id: <20170607032018.19588-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170607032018.19588-1-david@gibson.dropbear.id.au> References: <20170607032018.19588-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PATCHv2 7/7] spapr: Rework DRC name handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sursingh@redhat.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, bharata@linux.vnet.ibm.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" DRC objects have a get_name method which returns the DRC name generated when the DRC is created. Replace that with a fixed spapr_drc_name() function which generates the name on the fly from other information. This means: * We get rid of a method with only one implementation, and only local callers * We don't have to carry the name string around for the lifetime of the DRC * We use information added to the class structure to generate the name in standard format, so we don't need an explicit switch on drc type any more We also eliminate the 'name' property; it's basically useless since the only information in it can easily be deduced from other things. Signed-off-by: David Gibson --- hw/ppc/spapr_drc.c | 80 +++++++++++++++++-------------------------= ---- include/hw/ppc/spapr_drc.h | 3 +- 2 files changed, 30 insertions(+), 53 deletions(-) diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 82c0b94..15ef67d 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -155,9 +155,32 @@ static uint32_t set_allocation_state(sPAPRDRConnector = *drc, return RTAS_OUT_SUCCESS; } =20 -static const char *get_name(sPAPRDRConnector *drc) +static const char *spapr_drc_name(sPAPRDRConnector *drc) { - return drc->name; + sPAPRDRConnectorClass *drck =3D 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); } =20 /* has the guest been notified of device attachment? */ @@ -202,13 +225,6 @@ static void prop_get_index(Object *obj, Visitor *v, co= nst char *name, visit_type_uint32(v, name, &value, errp); } =20 -static char *prop_get_name(Object *obj, Error **errp) -{ - sPAPRDRConnector *drc =3D SPAPR_DR_CONNECTOR(obj); - sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_GET_CLASS(drc); - return g_strdup(drck->get_name(drc)); -} - static void prop_get_fdt(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -567,45 +583,6 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *owner= , const char *type, object_property_set_bool(OBJECT(drc), true, "realized", NULL); g_free(prop_name); =20 - /* 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 - */ - switch (spapr_drc_type(drc)) { - case SPAPR_DR_CONNECTOR_TYPE_CPU: - drc->name =3D g_strdup_printf("CPU %d", id); - break; - case SPAPR_DR_CONNECTOR_TYPE_PHB: - drc->name =3D g_strdup_printf("PHB %d", id); - break; - case SPAPR_DR_CONNECTOR_TYPE_VIO: - case SPAPR_DR_CONNECTOR_TYPE_PCI: - drc->name =3D g_strdup_printf("C%d", id); - break; - case SPAPR_DR_CONNECTOR_TYPE_LMB: - drc->name =3D g_strdup_printf("LMB %d", id); - break; - default: - g_assert(false); - } - /* PCI slot always start in a USABLE state, and stay there */ if (spapr_drc_type(drc) =3D=3D SPAPR_DR_CONNECTOR_TYPE_PCI) { drc->allocation_state =3D SPAPR_DR_ALLOCATION_STATE_USABLE; @@ -621,7 +598,6 @@ static void spapr_dr_connector_instance_init(Object *ob= j) 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_str(obj, "name", prop_get_name, NULL, NULL); object_property_add(obj, "fdt", "struct", prop_get_fdt, NULL, NULL, NULL, NULL); } @@ -636,7 +612,6 @@ static void spapr_dr_connector_class_init(ObjectClass *= k, void *data) dk->unrealize =3D unrealize; drck->set_isolation_state =3D set_isolation_state; drck->set_allocation_state =3D set_allocation_state; - drck->get_name =3D get_name; drck->release_pending =3D release_pending; drck->set_signalled =3D set_signalled; /* @@ -665,6 +640,7 @@ static void spapr_drc_cpu_class_init(ObjectClass *k, vo= id *data) =20 drck->typeshift =3D SPAPR_DR_CONNECTOR_TYPE_SHIFT_CPU; drck->typename =3D "CPU"; + drck->drc_name_prefix =3D "CPU "; } =20 static void spapr_drc_pci_class_init(ObjectClass *k, void *data) @@ -673,6 +649,7 @@ static void spapr_drc_pci_class_init(ObjectClass *k, vo= id *data) =20 drck->typeshift =3D SPAPR_DR_CONNECTOR_TYPE_SHIFT_PCI; drck->typename =3D "28"; + drck->drc_name_prefix =3D "C"; } =20 static void spapr_drc_lmb_class_init(ObjectClass *k, void *data) @@ -681,6 +658,7 @@ static void spapr_drc_lmb_class_init(ObjectClass *k, vo= id *data) =20 drck->typeshift =3D SPAPR_DR_CONNECTOR_TYPE_SHIFT_LMB; drck->typename =3D "MEM"; + drck->drc_name_prefix =3D "LMB "; } =20 static const TypeInfo spapr_dr_connector_info =3D { @@ -829,7 +807,7 @@ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Ob= ject *owner, g_array_append_val(drc_power_domains, drc_power_domain); =20 /* ibm,drc-names */ - drc_names =3D g_string_append(drc_names, drck->get_name(drc)); + drc_names =3D g_string_append(drc_names, spapr_drc_name(drc)); drc_names =3D g_string_insert_len(drc_names, -1, "\0", 1); =20 /* ibm,drc-types */ diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 4f82001..c487123 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -184,7 +184,6 @@ typedef struct sPAPRDRConnector { =20 uint32_t id; Object *owner; - const char *name; =20 /* DR-indicator */ uint32_t dr_indicator; @@ -215,6 +214,7 @@ typedef struct sPAPRDRConnectorClass { /*< public >*/ sPAPRDRConnectorTypeShift typeshift; const char *typename; /* used in device tree, PAPR 13.5.2.6 & C.6.1 */ + const char *drc_name_prefix; /* used other places in device tree */ =20 sPAPRDREntitySense (*dr_entity_sense)(sPAPRDRConnector *drc); =20 @@ -223,7 +223,6 @@ typedef struct sPAPRDRConnectorClass { sPAPRDRIsolationState state); uint32_t (*set_allocation_state)(sPAPRDRConnector *drc, sPAPRDRAllocationState state); - const char *(*get_name)(sPAPRDRConnector *drc); =20 /* QEMU interfaces for managing hotplug operations */ bool (*release_pending)(sPAPRDRConnector *drc); --=20 2.9.4