qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: "Clément Chigot" <chigot@adacore.com>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	peter.maydell@linaro.org, alistair@alistair23.me
Subject: Re: [PATCH 2/3] hw/arm/xlnx-zynqmp: introduce helper to compute RPU number
Date: Thu, 2 Oct 2025 09:35:33 +0200	[thread overview]
Message-ID: <aN4rRXnFX-Qj5CoR@zapote> (raw)
In-Reply-To: <20250930115718.437100-3-chigot@adacore.com>

On Tue, Sep 30, 2025 at 01:57:17PM +0200, Clément Chigot wrote:
> This helper will avoid repeating the MIN/MAX formula everytime the
> number of RPUs available is requested.
> 
> Signed-off-by: Clément Chigot <chigot@adacore.com>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>



> ---
>  hw/arm/xlnx-zynqmp.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
> index d7adc070f8..3d8c46986e 100644
> --- a/hw/arm/xlnx-zynqmp.c
> +++ b/hw/arm/xlnx-zynqmp.c
> @@ -207,14 +207,23 @@ static inline int arm_gic_ppi_index(int cpu_nr, int ppi_index)
>      return XLNX_ZYNQMP_GIC_NUM_SPI_INTR + cpu_nr * GIC_INTERNAL + ppi_index;
>  }
>  
> +static unsigned int xlnx_zynqmp_get_rpu_number(MachineState *ms)
> +{
> +    /*
> +     * RPUs will be created only if "-smp" is higher than the maximum
> +     * of APUs. Round it up to 0 to avoid dealing with negative values.
> +     */
> +    return MAX(0, MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS),
> +                      XLNX_ZYNQMP_NUM_RPU_CPUS));
> +}
> +
>  static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
>                                     const char *boot_cpu, Error **errp)
>  {
>      int i;
> -    int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS),
> -                       XLNX_ZYNQMP_NUM_RPU_CPUS);
> +    int num_rpus = xlnx_zynqmp_get_rpu_number(ms);
>  
> -    if (num_rpus <= 0) {
> +    if (!num_rpus) {
>          /* Don't create rpu-cluster object if there's nothing to put in it */
>          return;
>      }
> -- 
> 2.34.1
> 


  reply	other threads:[~2025-10-02  7:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-30 11:57 [PATCH 0/3] hw/arm/xlnx-zynqmp: wire a second GIC for the Cortex-R5 Clément Chigot
2025-09-30 11:57 ` [PATCH 1/3] hw/arm/xlnx-zynqmp: move GIC_NUM_SPI_INTR define in header Clément Chigot
2025-10-02  7:33   ` Edgar E. Iglesias
2025-09-30 11:57 ` [PATCH 2/3] hw/arm/xlnx-zynqmp: introduce helper to compute RPU number Clément Chigot
2025-10-02  7:35   ` Edgar E. Iglesias [this message]
2025-09-30 11:57 ` [PATCH 3/3] hw/arm/xlnx-zynqmp: wire a second GIC for the Cortex-R5 Clément Chigot
2025-10-02  7:36   ` Edgar E. Iglesias
2025-10-07  9:50 ` [PATCH 0/3] " Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aN4rRXnFX-Qj5CoR@zapote \
    --to=edgar.iglesias@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=chigot@adacore.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).