From patchwork Thu Aug 8 07:26:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prerna Saxena X-Patchwork-Id: 265676 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 83B6D2C00C0 for ; Thu, 8 Aug 2013 17:32:46 +1000 (EST) Received: from localhost ([::1]:55304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7KiC-00052T-G2 for incoming@patchwork.ozlabs.org; Thu, 08 Aug 2013 03:32:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7Khn-0004zV-Sv for qemu-devel@nongnu.org; Thu, 08 Aug 2013 03:32:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V7Khd-0001nX-K9 for qemu-devel@nongnu.org; Thu, 08 Aug 2013 03:32:19 -0400 Received: from e28smtp05.in.ibm.com ([122.248.162.5]:51408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V7Khc-0001ly-Vi for qemu-devel@nongnu.org; Thu, 08 Aug 2013 03:32:09 -0400 Received: from /spool/local by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Aug 2013 12:55:54 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp05.in.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 8 Aug 2013 12:55:53 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 4D4C2E005C; Thu, 8 Aug 2013 13:02:16 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r787XBgA39190660; Thu, 8 Aug 2013 13:03:12 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r787VpH0014736; Thu, 8 Aug 2013 07:31:53 GMT Received: from zephyr ([9.78.197.24]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r787VmR6014288; Thu, 8 Aug 2013 07:31:49 GMT Date: Thu, 8 Aug 2013 12:56:29 +0530 From: Prerna Saxena To: QEMU Message-ID: <20130808125629.4e5f435d@zephyr> In-Reply-To: <20130808125106.6b29a78c@zephyr> References: <20130808125106.6b29a78c@zephyr> X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.13; x86_64-redhat-linux-gnu) Mime-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13080807-8256-0000-0000-000008B47A08 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.5 Cc: sPAPR , Alexey Kardashevisky , Andreas =?UTF-8?B?RsOkcmJlcg==?= , Anthony Liguori , Alexander Graf Subject: [Qemu-devel] [PATCH 2/2] [v3] target-ppc: Enhance CPU nodes of device tree to be PAPR compliant. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Prerna Saxena Date: Thu, 8 Aug 2013 06:38:03 +0530 Subject: [PATCH 2/2] Enhance CPU nodes of device tree to be PAPR compliant. This is based on patch from Andreas which enables the default CPU with KVM to show up as "-cpu ", such as "POWER7_V2.3@0" While this is definitely, more descriptive, PAPR mandates the device tree CPU node names to be of the form : "PowerPC," where should not have underscores. Hence replacing the CPU model (which has underscores) with CPU alias. With this patch, the CPU nodes of device tree show up as : /proc/device-tree/cpus/PowerPC,POWER7@0/... /proc/device-tree/cpus/PowerPC,POWER7@4/... Signed-off-by: Prerna Saxena --- hw/ppc/spapr.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 59e2fea..8efd84e 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -43,6 +43,7 @@ #include "hw/pci-host/spapr.h" #include "hw/ppc/xics.h" #include "hw/pci/msi.h" +#include "cpu-models.h" #include "hw/pci/pci.h" @@ -80,6 +81,8 @@ #define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift)) +#define PPC_DEVTREE_STR "PowerPC," + sPAPREnvironment *spapr; int spapr_allocate_irq(int hint, bool lsi) @@ -322,9 +325,16 @@ static void *spapr_create_fdt_skel(const char *cpu_model, _FDT((fdt_property_cell(fdt, "#address-cells", 0x1))); _FDT((fdt_property_cell(fdt, "#size-cells", 0x0))); - modelname = g_strdup(cpu_model); + /* + * PAPR convention mandates that + * Device tree nodes must be named as: + * PowerPC,CPU-NAME@... + * Also, CPU-NAME must not have underscores.(hence use of CPU-ALIAS) + */ + + modelname = g_strdup_printf(PPC_DEVTREE_STR "%s", cpu_model); - for (i = 0; i < strlen(modelname); i++) { + for (i = strlen(PPC_DEVTREE_STR); i < strlen(modelname); i++) { modelname[i] = toupper(modelname[i]); } @@ -1315,6 +1325,14 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args) cpu_model = g_strndup(parent_name, strlen(parent_name) - strlen("-" TYPE_POWERPC_CPU)); + + for (i = 0; ppc_cpu_aliases[i].model != NULL; i++) { + if (strcmp(ppc_cpu_aliases[i].model, cpu_model) == 0) { + g_free(cpu_model); + cpu_model = g_strndup(ppc_cpu_aliases[i].alias, + strlen(ppc_cpu_aliases[i].alias)); + } + } } /* Prepare the device tree */