From patchwork Thu Feb 8 18:12:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 770856 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp464553wre; Thu, 8 Feb 2024 10:14:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2IhyoadLzObyMWEOesNpGTnb94tmOBHsB60oBtdGDcqMZJuaZtXEB7yDxyvomS4Fb9sqY X-Received: by 2002:a05:620a:4784:b0:781:c01:385f with SMTP id dt4-20020a05620a478400b007810c01385fmr276732qkb.53.1707416040343; Thu, 08 Feb 2024 10:14:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707416040; cv=none; d=google.com; s=arc-20160816; b=tfQ7qZzta6+FCi/OQkamtR6S7tGCrF5djouORttCXgrV4rsOimM5/S1mj2BDz8LUFA +YTzS49mgiB6B6yThJ6QynoHpyly2YHqzIlfnV8MRHa6/mY/OcUTHQw4O9J36COfe0ZA HILkknXxBl16r+8dB5WUha1XawfXxHHd07YGK9219z60NnxVeLqLAMdcK0To2MkONdtM 1xPEuCDehw5e7HBe68aIGSxMGbJTTbaUw6DWfXmosjvskmdZ41vjQu8Z3nDqKFv91g/o Ir8dEHACNy70tsoCImm7k19Fru5UZ7NrngneRRhU2yUpYMhIGFNlJvIkhPUwDD6Br7rY Z89w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L0ogzzUtX0pA4ogtPPYPzAFnKo2sHz3gs+YB0BMu1oo=; fh=H1JZ+9WlsYRdBmgCwRbs5sU7Bj+23p9GKsDG/93yt3Q=; b=kybaeIcs605p2Ju486ZhoJS8zSzOorW4oXzJY2Y782gv5Jeg2n9BH70PtYeuHrxISP FpYy3vSga9zJPhfMX3siVUB4882CoWkWcFmYBa1RzumBUHBCowEFQwvOWkzihkXB10t+ OieAU+E9la9iOrwkVlodQ4vSXH+lmBuGdsRNFvBUqeFrb05Mi0qCdCyG72hmDgtMsg2u ByVhA6IXvbK3L2q0deE+D7Gi5iKdMjdyccJa/TqI9D04Q6CTCf/vOpNrQwUiEnRIfkj4 wT/Ih4A+vBJq2RoCc5A0e9AY546QWCeMknL6TsnmqzEVb/rkRTJLh+fXk3fKZKySAWzW C1uA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MNaP1E22; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=1; AJvYcCV8My/Id8jobIpeij/YhGE4lmF9G5xm82zPjHn2HtiHcCCbNGbospMstqI7+hVmOdeICek6xH4yB+61a7el37eb Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x14-20020ae9f80e000000b0078349f5b7c7si111741qkh.559.2024.02.08.10.14.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Feb 2024 10:14:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MNaP1E22; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rY8tj-0004dB-TL; Thu, 08 Feb 2024 13:13:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rY8tb-0004IW-Gs for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:13:14 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rY8tY-0006lP-Qr for qemu-devel@nongnu.org; Thu, 08 Feb 2024 13:13:11 -0500 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a30f7c9574eso9509166b.0 for ; Thu, 08 Feb 2024 10:13:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707415987; x=1708020787; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L0ogzzUtX0pA4ogtPPYPzAFnKo2sHz3gs+YB0BMu1oo=; b=MNaP1E22rrBn2bXQkGF3n0cl51UKSFaGT9lmlFuI0mjYDoY7/Eb2l2QTCWkY6YFe8a Ts/MAVviCTFhBwvhWE4YuAABTpYHpOBuW//GikOQBp+52itomLOnMQrKy/6JJth4VIxc +YFLk+ntc7fakgIEh2/Mzd73ObaMN4yjXx5SDgsRZfFkD/VBVdOw7gm4+kOL5EHgUWtD W6oA9SkHvMb1iadMTrrZz4ImXab/uthPNAJJX5lUflp/+KQn+by35Meu4BOzhL2jybU1 sZd4TPC5RrtJPKlJTVvYwAus3Avc2MWRmWHKW6Owf3U96lrUYvt2DAN03WYSmOewRH8k k0JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707415987; x=1708020787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L0ogzzUtX0pA4ogtPPYPzAFnKo2sHz3gs+YB0BMu1oo=; b=RkVJL6CgP9vbYOnfvM0PnDDaYtRr33g7HvkvteZoYNr9l4Sf2tPqngp8aPd7jhZBek JNVzmbfilul7nEHpeEFaEvtmaiDL3Ypa6cz7IDCzyS/xV/sH6FKPmoLjHgXKtNP13qDO JtzoLiXd/DkoH88FL3NbPR40oTjt9E8SJKCGiHhT//mpsbD9MDOEPaN8sDE7Z5en84fJ CkAKWsMYPS8DYC1FeqI0lfeZ+3KcHqCZwWq/7xAaPdPpR0+Ej37h9xnEwsNI4+HMJbrL ZA8iArbiqPWy/POyUCfZ8lmbcYT8gE6CKhyyMyPCVbB45luBEf448co/oKVfUsLhaOXm 3+wA== X-Gm-Message-State: AOJu0YxcOVj2gpOR+k1TrxI4z4tMK+9DJE/04+uiKC8jLtVmJX15qfoU piZVyCzS+/ITjImvlx8p5cNRPw/fScLwUvBXPTJfAi9j/Mdhy2U18E9hrd7A/iFi2Rdp88VyGPx jFEo= X-Received: by 2002:a17:906:5794:b0:a38:8d35:c8b4 with SMTP id k20-20020a170906579400b00a388d35c8b4mr75914ejq.46.1707415987030; Thu, 08 Feb 2024 10:13:07 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWjPzvlEHE4oYPpySgAkE7/zjy3goOzi3NwSHkTTSWlgD0P6yoQ7k0sJB/Q+d4MdKul1AdEsOjJ0yOyR5lATAxU26+mLETi+tasJrtjM4E0kNlJUWJallVGABAm/WxVLT0rdhX8OxFjS976Yrati9OfnDRZ8n3oA8FM4o17D40f5o8yahIwdA7uc9KjVQCyKqv5CBpzdpIZAXfveZ9LXPnJoyjMR1iKzNKzYh9orktB+3cJEMhQAnmhP28LE4N/2xVV48MCHrB6hhWyNgPQLP4cqAFjwJWXkj+AJ8D6NNxO8xQbLB7rkutceBzmeQwAKRTRywrejh6Tt7O4XguPzLl99oH/sCNH1dCB/jweM3JeDjA= Received: from m1x-phil.lan ([176.187.218.105]) by smtp.gmail.com with ESMTPSA id s18-20020a17090699d200b00a3ba3d8af9bsm296233ejn.136.2024.02.08.10.13.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 08 Feb 2024 10:13:06 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Zhao Liu , Paolo Bonzini , qemu-block@nongnu.org, John Snow , qemu-ppc@nongnu.org, Eduardo Habkost , Richard Henderson , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Yoshinori Sato Subject: [PATCH v3 03/11] hw/rx/rx62n: Only call qdev_get_gpio_in() when necessary Date: Thu, 8 Feb 2024 19:12:36 +0100 Message-ID: <20240208181245.96617-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240208181245.96617-1-philmd@linaro.org> References: <20240208181245.96617-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Instead of filling an array of all the possible IRQs, only call qdev_get_gpio_in() when an IRQ is used. Remove the array from RX62NState. Doing so we avoid calling qdev_get_gpio_in() on an unrealized device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Reviewed-by: Yoshinori Sato --- include/hw/rx/rx62n.h | 1 - hw/rx/rx62n.c | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/hw/rx/rx62n.h b/include/hw/rx/rx62n.h index bcda583ab3..766fe0e435 100644 --- a/include/hw/rx/rx62n.h +++ b/include/hw/rx/rx62n.h @@ -67,7 +67,6 @@ struct RX62NState { MemoryRegion iomem2; MemoryRegion iomem3; MemoryRegion c_flash; - qemu_irq irq[NR_IRQS]; /* Input Clock (XTAL) frequency */ uint32_t xtal_freq_hz; diff --git a/hw/rx/rx62n.c b/hw/rx/rx62n.c index d3f61a6837..560f53a58a 100644 --- a/hw/rx/rx62n.c +++ b/hw/rx/rx62n.c @@ -148,14 +148,11 @@ static void register_icu(RX62NState *s) qlist_append_int(trigger_level, levelirq[i]); } qdev_prop_set_array(DEVICE(icu), "trigger-level", trigger_level); - - for (i = 0; i < NR_IRQS; i++) { - s->irq[i] = qdev_get_gpio_in(DEVICE(icu), i); - } sysbus_realize(icu, &error_abort); + sysbus_connect_irq(icu, 0, qdev_get_gpio_in(DEVICE(&s->cpu), RX_CPU_IRQ)); sysbus_connect_irq(icu, 1, qdev_get_gpio_in(DEVICE(&s->cpu), RX_CPU_FIR)); - sysbus_connect_irq(icu, 2, s->irq[SWI]); + sysbus_connect_irq(icu, 2, qdev_get_gpio_in(DEVICE(&s->icu), SWI)); sysbus_mmio_map(icu, 0, RX62N_ICU_BASE); } @@ -172,7 +169,8 @@ static void register_tmr(RX62NState *s, int unit) irqbase = RX62N_TMR_IRQ + TMR_NR_IRQ * unit; for (i = 0; i < TMR_NR_IRQ; i++) { - sysbus_connect_irq(tmr, i, s->irq[irqbase + i]); + sysbus_connect_irq(tmr, i, + qdev_get_gpio_in(DEVICE(&s->icu), irqbase + i)); } sysbus_mmio_map(tmr, 0, RX62N_TMR_BASE + unit * 0x10); } @@ -190,7 +188,8 @@ static void register_cmt(RX62NState *s, int unit) irqbase = RX62N_CMT_IRQ + CMT_NR_IRQ * unit; for (i = 0; i < CMT_NR_IRQ; i++) { - sysbus_connect_irq(cmt, i, s->irq[irqbase + i]); + sysbus_connect_irq(cmt, i, + qdev_get_gpio_in(DEVICE(&s->icu), irqbase + i)); } sysbus_mmio_map(cmt, 0, RX62N_CMT_BASE + unit * 0x10); } @@ -209,7 +208,8 @@ static void register_sci(RX62NState *s, int unit) irqbase = RX62N_SCI_IRQ + SCI_NR_IRQ * unit; for (i = 0; i < SCI_NR_IRQ; i++) { - sysbus_connect_irq(sci, i, s->irq[irqbase + i]); + sysbus_connect_irq(sci, i, + qdev_get_gpio_in(DEVICE(&s->icu), irqbase + i)); } sysbus_mmio_map(sci, 0, RX62N_SCI_BASE + unit * 0x08); }