From nobody Wed Nov 5 17:40:55 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 1496738350761646.0850272220933; Tue, 6 Jun 2017 01:39:10 -0700 (PDT) Received: from localhost ([::1]:36849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIA17-0000XF-D0 for importer@patchew.org; Tue, 06 Jun 2017 04:39:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dI9uh-0003Ns-RB for qemu-devel@nongnu.org; Tue, 06 Jun 2017 04:32:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dI9ug-00021q-B3 for qemu-devel@nongnu.org; Tue, 06 Jun 2017 04:32:31 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:54515) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dI9uf-00020b-L1; Tue, 06 Jun 2017 04:32:30 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3whlL24SCwz9s7B; Tue, 6 Jun 2017 18:32:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1496737946; bh=cmpkb1XJMNomrW3YpFNNVax8iZjMhc7wlv1gP6XDep0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TgtD7Q26vTuj0e9It1rflueJhoq+Qlc9appZLTd9ZV/RYGPSWb6ujfessjgY6jlGK Wn0NqPimv3sK/+Tfo4VnIprzJXBqSS7qm7ey1iu2P04D+onwe7+RQ4SbsxHcncWIG0 d01mq2cvQ/zzQSQUk7VZMedHK8SGHbnM7Vd83uys= From: David Gibson To: mdroth@linux.vnet.ibm.com Date: Tue, 6 Jun 2017 18:32:17 +1000 Message-Id: <20170606083221.9299-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170606083221.9299-1-david@gibson.dropbear.id.au> References: <20170606083221.9299-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PATCH 3/7] spapr: Assign DRC names from owners 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: lvivier@redhat.com, sursingh@redhat.com, groug@kaod.org, qemu-devel@nongnu.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" At present, spapr_dr_connector_new assigns a name to the drc based on its type and ID. The few places the DRC name are used, however, are supposed to give some sort of human-useful information to correlate guest-side problems with host-side resources (for PCI devices it's supposed to be a physical location code). The owners who set up the DRCs are in a much better position to supply this information than the DRC core. We already have a "name" R/O property, so make it R/W and set from the callers. We change the "name" property from a new-style QOM one to the property list form, simply because it's a bit less verbose that way. Signed-off-by: David Gibson --- hw/ppc/spapr.c | 16 +++++++++--- hw/ppc/spapr_drc.c | 61 ++++++++++++------------------------------= ---- hw/ppc/spapr_pci.c | 29 ++++++++++++++++++++-- include/hw/ppc/spapr_drc.h | 5 ++-- 4 files changed, 57 insertions(+), 54 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 86e6228..671cdbb 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1909,11 +1909,14 @@ static void spapr_create_lmb_dr_connectors(sPAPRMac= hineState *spapr) =20 for (i =3D 0; i < nr_lmbs; i++) { sPAPRDRConnector *drc; + char *drc_name; uint64_t addr; =20 addr =3D i * lmb_size + spapr->hotplug_memory.base; + drc_name =3D g_strdup_printf("LMB %"PRId64, addr / lmb_size); drc =3D spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_LMB, - addr/lmb_size); + addr / lmb_size, drc_name, &error_abo= rt); + g_free(drc_name); qemu_register_reset(spapr_drc_reset, drc); } } @@ -2008,9 +2011,14 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) int core_id =3D i * smp_threads; =20 if (mc->has_hotpluggable_cpus) { - sPAPRDRConnector *drc =3D - spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_CPU, - (core_id / smp_threads) * smt); + int id =3D (core_id / smp_threads) * smt; + char *drc_name; + sPAPRDRConnector *drc; + + drc_name =3D g_strdup_printf("CPU %d", id); + drc =3D spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_C= PU, + id, drc_name, &error_abort); + g_free(drc_name); =20 qemu_register_reset(spapr_drc_reset, drc); } diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 9140b48..1fc51c9 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -213,12 +213,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); - return g_strdup(drc->name); -} - static void prop_get_fdt(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -564,9 +558,11 @@ static void unrealize(DeviceState *d, Error **errp) } =20 sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type, - uint32_t id) + uint32_t id, const char *name, + Error **errp) { sPAPRDRConnector *drc =3D SPAPR_DR_CONNECTOR(object_new(type)); + Error *local_err =3D NULL; char *prop_name; =20 drc->id =3D id; @@ -574,48 +570,16 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *owne= r, const char *type, prop_name =3D g_strdup_printf("dr-connector[%"PRIu32"]", spapr_drc_index(drc)); object_property_add_child(owner, prop_name, OBJECT(drc), NULL); - 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); + object_property_set_str(OBJECT(drc), name, "name", &local_err); + if (local_err) { + error_propagate(errp, local_err); + return NULL; } =20 + object_property_set_bool(OBJECT(drc), true, "realized", NULL); + /* 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; @@ -631,16 +595,21 @@ static void spapr_dr_connector_instance_init(Object *= 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_str(obj, "name", prop_get_name, NULL, NULL); object_property_add(obj, "fdt", "struct", prop_get_fdt, NULL, NULL, NULL, NULL); } =20 +static Property spapr_drc_properties[] =3D { + DEFINE_PROP_STRING("name", sPAPRDRConnector, name), + DEFINE_PROP_END_OF_LIST(), +}; + static void spapr_dr_connector_class_init(ObjectClass *k, void *data) { DeviceClass *dk =3D DEVICE_CLASS(k); sPAPRDRConnectorClass *drck =3D SPAPR_DR_CONNECTOR_CLASS(k); =20 + dk->props =3D spapr_drc_properties; dk->reset =3D reset; dk->realize =3D realize; dk->unrealize =3D unrealize; diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 5cba8f9..967d7c3 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1570,10 +1570,10 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) sPAPRTCETable *tcet; const unsigned windows_supported =3D sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1; + Error *local_err =3D NULL; =20 if (sphb->index !=3D (uint32_t)-1) { sPAPRMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); - Error *local_err =3D NULL; =20 if ((sphb->buid !=3D (uint64_t)-1) || (sphb->dma_liobn[0] !=3D (ui= nt32_t)-1) || (sphb->dma_liobn[1] !=3D (uint32_t)-1 && windows_supported = =3D=3D 2) @@ -1759,8 +1759,33 @@ static void spapr_phb_realize(DeviceState *dev, Erro= r **errp) /* allocate connectors for child PCI devices */ if (sphb->dr_enabled) { for (i =3D 0; i < PCI_SLOT_MAX * 8; i++) { + int id =3D sphb->index << 16 | i; + char *drc_name; + + /* Name for a DRC for the DT. For PCI devices, it is a + * "location code" mapping a logical device/function (DRC + * index) to a physical location in the system. + * + * This is more to do with diagnosing physical hardware + * issues than guest compatibility, so choose 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 + */ + + drc_name =3D g_strdup_printf("C%d", id); spapr_dr_connector_new(OBJECT(phb), TYPE_SPAPR_DRC_PCI, - (sphb->index << 16) | i); + id, drc_name, &local_err); + g_free(drc_name); + if (local_err) { + error_propagate(errp, local_err); + return; + } } } =20 diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 795b7dd..d437e0a 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -184,7 +184,7 @@ typedef struct sPAPRDRConnector { =20 uint32_t id; Object *owner; - const char *name; + char *name; =20 /* sensor/indicator states */ uint32_t isolation_state; @@ -236,7 +236,8 @@ uint32_t spapr_drc_index(sPAPRDRConnector *drc); sPAPRDRConnectorType spapr_drc_type(sPAPRDRConnector *drc); =20 sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type, - uint32_t id); + uint32_t id, const char *name, + Error **errp); 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, --=20 2.9.4