From patchwork Wed Feb 3 16:56:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Alrae X-Patchwork-Id: 8205501 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0C634BEEE5 for ; Wed, 3 Feb 2016 17:05:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5FB4F20122 for ; Wed, 3 Feb 2016 17:05:35 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 94994200F4 for ; Wed, 3 Feb 2016 17:05:34 +0000 (UTC) Received: from localhost ([::1]:36431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR0s1-0000Fj-T3 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 03 Feb 2016 12:05:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR0kJ-0003Qi-4E for qemu-devel@nongnu.org; Wed, 03 Feb 2016 11:57:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aR0kH-0005xW-4R for qemu-devel@nongnu.org; Wed, 03 Feb 2016 11:57:35 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:52172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR0kG-0005xS-VL for qemu-devel@nongnu.org; Wed, 03 Feb 2016 11:57:33 -0500 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Websense Email Security Gateway with ESMTPS id 66A7B7D3889F4; Wed, 3 Feb 2016 16:57:28 +0000 (GMT) Received: from lalrae-linux.kl.imgtec.org (192.168.169.37) by hhmail02.hh.imgtec.org (10.100.10.20) with Microsoft SMTP Server (TLS) id 14.3.266.1; Wed, 3 Feb 2016 16:57:31 +0000 From: Leon Alrae To: Date: Wed, 3 Feb 2016 16:56:49 +0000 Message-ID: <1454518611-26134-8-git-send-email-leon.alrae@imgtec.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1454518611-26134-1-git-send-email-leon.alrae@imgtec.com> References: <1454518611-26134-1-git-send-email-leon.alrae@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.169.37] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.59.15.196 Cc: aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 7/9] hw/mips_malta: make ITU available to multi-threading processors 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add ITU block to Malta board and make it available to multithreading processors. Signed-off-by: Leon Alrae --- hw/mips/mips_malta.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index c5da83f..2c54a04 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -55,6 +55,7 @@ #include "hw/empty_slot.h" #include "sysemu/kvm.h" #include "exec/semihost.h" +#include "hw/misc/mips_itu.h" //#define DEBUG_BOARD_INIT @@ -93,6 +94,7 @@ typedef struct { typedef struct { SysBusDevice parent_obj; + MIPSITUState itu; qemu_irq *i8259; } MaltaState; @@ -567,6 +569,25 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space, return s; } +static void itu_init(MaltaState *s, Error **err) +{ + SysBusDevice *itubusdev; + + object_initialize(&s->itu, sizeof(s->itu), TYPE_MIPS_ITU); + qdev_set_parent_bus(DEVICE(&s->itu), sysbus_get_default()); + + object_property_set_int(OBJECT(&s->itu), 16, "num-fifo", err); + object_property_set_int(OBJECT(&s->itu), 16, "num-semaphores", err); + object_property_set_bool(OBJECT(&s->itu), true, "realized", err); + + if (*err != NULL) { + return; + } + + itubusdev = SYS_BUS_DEVICE(&s->itu); + sysbus_mmio_map_overlap(itubusdev, 0, 0, 1); +} + /* Network support */ static void network_init(PCIBus *pci_bus) { @@ -882,6 +903,10 @@ static void malta_mips_config(MIPSCPU *cpu) env->mvp->CP0_MVPConf0 |= ((smp_cpus - 1) << CP0MVPC0_PVPE) | ((smp_cpus * cs->nr_threads - 1) << CP0MVPC0_PTC); + + if (env->itc_tag) { + env->mvp->CP0_MVPConf0 |= 1 << CP0MVPC0_GS; + } } static void main_cpu_reset(void *opaque) @@ -906,6 +931,20 @@ static void main_cpu_reset(void *opaque) } } +static bool cpu_mips_itu_supported(CPUMIPSState *env) +{ + bool is_mt = ((env->CP0_Config5 & (1 << CP0C5_VP)) != 0) || + ((env->CP0_Config3 & (1 << CP0C3_MT)) != 0); + + return is_mt && !kvm_enabled(); + +} + +static void cpu_mips_attach_itc_tag(CPUMIPSState *env, MIPSITUState *itu) +{ + env->itc_tag = mips_itu_get_tag_region(itu); +} + static void mips_malta_init(MachineState *machine) { @@ -940,6 +979,7 @@ void mips_malta_init(MachineState *machine) int fl_idx = 0; int fl_sectors = bios_size >> 16; int be; + bool itu_present = false; DeviceState *dev = qdev_create(NULL, TYPE_MIPS_MALTA); MaltaState *s = MIPS_MALTA(dev); @@ -980,6 +1020,10 @@ void mips_malta_init(MachineState *machine) /* Init internal devices */ cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); + if (cpu_mips_itu_supported(env)) { + itu_present = true; + cpu_mips_attach_itc_tag(env, &s->itu); + } qemu_register_reset(main_cpu_reset, cpu); } cpu = MIPS_CPU(first_cpu); @@ -1137,6 +1181,15 @@ void mips_malta_init(MachineState *machine) cpu_mips_irq_init_cpu(env); cpu_mips_clock_init(env); + if (itu_present) { + Error *err = NULL; + itu_init(s, &err); + if (err != NULL) { + error_report("%s", error_get_pretty(err)); + exit(1); + } + } + /* * We have a circular dependency problem: pci_bus depends on isa_irq, * isa_irq is provided by i8259, i8259 depends on ISA, ISA depends