From patchwork Wed Sep 6 08:27:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Nikunj A. Dadhania" X-Patchwork-Id: 9940103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF1F86038C for ; Wed, 6 Sep 2017 08:30:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 920F328B4B for ; Wed, 6 Sep 2017 08:30:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9097128B47; Wed, 6 Sep 2017 08:30:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1FCD728B47 for ; Wed, 6 Sep 2017 08:30:40 +0000 (UTC) Received: from localhost ([::1]:34946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpVj7-0000OZ-T6 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 06 Sep 2017 04:30:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpViD-0000MV-2k for qemu-devel@nongnu.org; Wed, 06 Sep 2017 04:29:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpVi8-0003NZ-W0 for qemu-devel@nongnu.org; Wed, 06 Sep 2017 04:29:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36367) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpVi8-0003NE-Na for qemu-devel@nongnu.org; Wed, 06 Sep 2017 04:29:24 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v868TG7K143724 for ; Wed, 6 Sep 2017 04:29:23 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ct76an5wu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 06 Sep 2017 04:29:22 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Sep 2017 18:29:20 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 6 Sep 2017 18:29:18 +1000 Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v868S2CL33226768; Wed, 6 Sep 2017 18:28:02 +1000 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v868S2dh028128; Wed, 6 Sep 2017 18:28:02 +1000 Received: from abhimanyu.in.ibm.com (abhimanyu.in.ibm.com [9.124.35.100]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v868Rw9o028060; Wed, 6 Sep 2017 18:27:59 +1000 From: Nikunj A Dadhania To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Wed, 6 Sep 2017 13:57:48 +0530 X-Mailer: git-send-email 2.9.3 X-TM-AS-MML: disable x-cbid: 17090608-0040-0000-0000-000003534340 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17090608-0041-0000-0000-00000CD1593D Message-Id: <20170906082748.28520-1-nikunj@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-06_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709060117 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH] ppc/pnv: fix cores per chip for multiple cpus 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: bharata@linux.vnet.ibm.com, qemu-devel@nongnu.org, Nikunj A Dadhania , clg@kaod.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When the user does not provide the cpu topology, e.g. "-smp 4", machine fails to initialize 4 cpus. Compute the chip per cores depending on the number of chips and smt threads. Signed-off-by: Nikunj A Dadhania Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater --- hw/ppc/pnv.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 9724719..3fbaafb 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -642,7 +642,7 @@ static void ppc_powernv_init(MachineState *machine) MemoryRegion *ram; char *fw_filename; long fw_size; - int i; + int i, cores_per_chip; char *chip_typename; PCIBus *pbus; bool has_gfx = false; @@ -710,6 +710,22 @@ static void ppc_powernv_init(MachineState *machine) } pnv->chips = g_new0(PnvChip *, pnv->num_chips); + + /* If user has specified number of cores, use it. Otherwise, compute it. */ + if (smp_cores != 1) { + cores_per_chip = smp_cores; + } else { + cores_per_chip = smp_cpus / (smp_threads * pnv->num_chips); + } + + if (smp_cpus != (smp_threads * pnv->num_chips * cores_per_chip)) { + error_report("cpu topology not balanced: " + "chips (%u) * cores (%u) * threads (%u) != " + "number of cpus (%u)", + pnv->num_chips, cores_per_chip, smp_threads, smp_cpus); + exit(1); + } + for (i = 0; i < pnv->num_chips; i++) { char chip_name[32]; Object *chip = object_new(chip_typename); @@ -728,7 +744,7 @@ static void ppc_powernv_init(MachineState *machine) object_property_add_child(OBJECT(pnv), chip_name, chip, &error_fatal); object_property_set_int(chip, PNV_CHIP_HWID(i), "chip-id", &error_fatal); - object_property_set_int(chip, smp_cores, "nr-cores", &error_fatal); + object_property_set_int(chip, cores_per_chip, "nr-cores", &error_fatal); object_property_set_int(chip, 1, "num-phbs", &error_fatal); object_property_set_bool(chip, true, "realized", &error_fatal); }