From patchwork Sun Jan 27 01:45:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10782671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 996BD1390 for ; Sun, 27 Jan 2019 01:58:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83C7E2CA28 for ; Sun, 27 Jan 2019 01:58:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 729712CA37; Sun, 27 Jan 2019 01:58:55 +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=-2.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA0292CA28 for ; Sun, 27 Jan 2019 01:58:54 +0000 (UTC) Received: from localhost ([127.0.0.1]:38184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnZio-0005ZF-9u for patchwork-qemu-devel@patchwork.kernel.org; Sat, 26 Jan 2019 20:58:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnZfs-0003W1-FB for qemu-devel@nongnu.org; Sat, 26 Jan 2019 20:55:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gnZVc-0008Gi-0N for qemu-devel@nongnu.org; Sat, 26 Jan 2019 20:45:16 -0500 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]:44391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gnZVb-0008GY-Py for qemu-devel@nongnu.org; Sat, 26 Jan 2019 20:45:15 -0500 Received: by mail-lj1-x243.google.com with SMTP id k19-v6so11339241lji.11 for ; Sat, 26 Jan 2019 17:45:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=yjuY8CXwQ8fxDnfwKT6/6C9ZzLlnEMvSVsd+8K3FvZY=; b=EXpU5hcluNcoYR2H3ry7TXN4Ek0NiSB/HtBNFQdhsfSGLfKcnm9LTJ7WDcZ1KvhjgK u8V9tlR8cRuTZPAYSToVBaja2fIIoxl7+4WE9K6slri78QCma+Ac4sA9U0tG+Y68hUfM Deeili8iBKs1JTZlL8+9qNnWW1OWnOJ7K1qcahmXlN2a0L1PRYTCgpd7VIUeiwtp3Mw+ GQWEvhFYJwqcrAI5jC8U4CokM3ihh+i27cJ2YucZyOwy7MHLKYtx1fjnWK1IwsFJhseF XouXgOgzaZMjx4S7042SmYQU55AoF2gqoI6wFUdka0wk+Ne/dloXarTU3+rsqhzVm77U XUGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yjuY8CXwQ8fxDnfwKT6/6C9ZzLlnEMvSVsd+8K3FvZY=; b=fB/KcxnMq9vqRGejgJmCXCYEeXgMmyPZmt7EkmShlKc56v79R18fDOgWdu2E32I+mV lVcFIHBKHiRmhNjS0VcWy5T6OZqYQsr8/XitO8b1LJNn7zvbDLGy0sR+iyVqSIg595QL wflNJmDuf6+tMAzggFpDZO7MV5t8yq5H5kvJ02LYfqYR2DzqkIKGuxdR3NLnK3N/C4RC l20U6NC39ZQz1RXlN0hhShxbt0A6+3/3q4M0d8jI40Mq/9F4ki76LMiK9bTao0Tt68Fz LMgxHqKn4y0PJoAMozNsZkFcZLbyaLqZf9JwyBLTJdgx6x0PiHkudx10xtFSo2pt4jCy HJsQ== X-Gm-Message-State: AJcUukfUfQ9VbBml4HAHfMJyrJv62qnIoemjbzAtBqW4ZOiKz1rHGNa6 cuhzSgAECe+U6l2r62wpgydXAPSFh2Q= X-Google-Smtp-Source: ALg8bN5fLX6C8m1u93m1oBBEkqilzTro5POvAATTmVR1TaL5XaApH1BazuxdA7vmMMyPgN9K68BZDw== X-Received: by 2002:a2e:9b15:: with SMTP id u21-v6mr11942504lji.29.1548553514162; Sat, 26 Jan 2019 17:45:14 -0800 (PST) Received: from octofox.hsd1.ca.comcast.net. (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id z64sm2215615lff.39.2019.01.26.17.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Jan 2019 17:45:13 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Sat, 26 Jan 2019 17:45:01 -0800 Message-Id: <20190127014501.21840-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::243 Subject: [Qemu-devel] [PATCH] target/xtensa: rearrange access to external interrupts 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: Max Filippov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Replace xtensa_get_extint that returns single external IRQ descriptor with xtensa_get_extints that returns a vector of all external IRQs. Signed-off-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé --- hw/xtensa/pic_cpu.c | 24 +++++++++++------------- hw/xtensa/xtfpga.c | 8 +++++--- target/xtensa/cpu.h | 5 +++-- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/hw/xtensa/pic_cpu.c b/hw/xtensa/pic_cpu.c index f70684902628..077f4ad53d6d 100644 --- a/hw/xtensa/pic_cpu.c +++ b/hw/xtensa/pic_cpu.c @@ -88,11 +88,11 @@ static void xtensa_ccompare_cb(void *opaque) void xtensa_irq_init(CPUXtensaState *env) { - env->irq_inputs = (void **)qemu_allocate_irqs( - xtensa_set_irq, env, env->config->ninterrupt); - if (xtensa_option_enabled(env->config, XTENSA_OPTION_TIMER_INTERRUPT)) { - unsigned i; + unsigned i; + env->irq_inputs = qemu_allocate_irqs(xtensa_set_irq, env, + env->config->ninterrupt); + if (xtensa_option_enabled(env->config, XTENSA_OPTION_TIMER_INTERRUPT)) { env->time_base = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); env->ccount_base = env->sregs[CCOUNT]; for (i = 0; i < env->config->nccompare; ++i) { @@ -101,16 +101,14 @@ void xtensa_irq_init(CPUXtensaState *env) xtensa_ccompare_cb, env->ccompare + i); } } + for (i = 0; i < env->config->nextint; ++i) { + unsigned irq = env->config->extint[i]; + + env->ext_irq_inputs[i] = env->irq_inputs[irq]; + } } -void *xtensa_get_extint(CPUXtensaState *env, unsigned extint) +qemu_irq *xtensa_get_extints(CPUXtensaState *env) { - if (extint < env->config->nextint) { - unsigned irq = env->config->extint[extint]; - return env->irq_inputs[irq]; - } else { - qemu_log("%s: trying to acquire invalid external interrupt %d\n", - __func__, extint); - return NULL; - } + return env->ext_irq_inputs; } diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 7379b3fff427..3102f8c04709 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -225,6 +225,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) XtensaCPU *cpu = NULL; CPUXtensaState *env = NULL; MemoryRegion *system_io; + qemu_irq *extints; DriveInfo *dinfo; pflash_t *flash = NULL; QemuOpts *machine_opts = qemu_get_machine_opts(); @@ -253,6 +254,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) */ cpu_reset(CPU(cpu)); } + extints = xtensa_get_extints(env); if (env) { XtensaMemory sysram = env->config->sysram; @@ -284,11 +286,11 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) xtfpga_fpga_init(system_io, 0x0d020000, freq); if (nd_table[0].used) { xtfpga_net_init(system_io, 0x0d030000, 0x0d030400, 0x0d800000, - xtensa_get_extint(env, 1), nd_table); + extints[1], nd_table); } - serial_mm_init(system_io, 0x0d050020, 2, xtensa_get_extint(env, 0), - 115200, serial_hd(0), DEVICE_NATIVE_ENDIAN); + serial_mm_init(system_io, 0x0d050020, 2, extints[0], + 115200, serial_hd(0), DEVICE_NATIVE_ENDIAN); dinfo = drive_get(IF_PFLASH, 0, 0); if (dinfo) { diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index f579294822c3..176af8a53cf0 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -483,7 +483,8 @@ typedef struct CPUXtensaState { AddressSpace *address_space_er; MemoryRegion *system_er; int pending_irq_level; /* level of last raised IRQ */ - void **irq_inputs; + qemu_irq *irq_inputs; + qemu_irq ext_irq_inputs[MAX_NINTERRUPT]; XtensaCcompareTimer ccompare[MAX_NCCOMPARE]; uint64_t time_base; uint64_t ccount_time; @@ -569,7 +570,7 @@ void xtensa_register_core(XtensaConfigList *node); void xtensa_sim_open_console(Chardev *chr); void check_interrupts(CPUXtensaState *s); void xtensa_irq_init(CPUXtensaState *env); -void *xtensa_get_extint(CPUXtensaState *env, unsigned extint); +qemu_irq *xtensa_get_extints(CPUXtensaState *env); int cpu_xtensa_signal_handler(int host_signum, void *pinfo, void *puc); void xtensa_cpu_list(FILE *f, fprintf_function cpu_fprintf); void xtensa_sync_window_from_phys(CPUXtensaState *env);