From patchwork Thu Sep 8 08:52:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12969805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DF32C38145 for ; Thu, 8 Sep 2022 08:53:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.402880.644819 (Exim 4.92) (envelope-from ) id 1oWDHo-0004Iu-DN; Thu, 08 Sep 2022 08:53:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 402880.644819; Thu, 08 Sep 2022 08:53:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWDHo-0004Ic-9v; Thu, 08 Sep 2022 08:53:24 +0000 Received: by outflank-mailman (input) for mailman id 402880; Thu, 08 Sep 2022 08:53:23 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWDHn-0004Hp-5v for xen-devel@lists.xen.org; Thu, 08 Sep 2022 08:53:23 +0000 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [2607:f8b0:4864:20::62f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b0356a2b-2f53-11ed-a31c-8f8a9ae3403f; Thu, 08 Sep 2022 10:53:22 +0200 (CEST) Received: by mail-pl1-x62f.google.com with SMTP id b21so4255078plz.7 for ; Thu, 08 Sep 2022 01:53:21 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id h186-20020a62dec3000000b00536b67c6a80sm14202330pfg.109.2022.09.08.01.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 01:53:19 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b0356a2b-2f53-11ed-a31c-8f8a9ae3403f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=g8uTdefvk9Re34ta3Hpj2EM7Z0M3BKhJL7lQL/PEL2M=; b=mBtM7uvNiEiMQLI2MLWBZ6JSOiFTqkssUfJyR7Lxq52+GS4fT+MsWyp1FiV4D9xh7r rtUo196+JZzmyWgL9K/iXKZWKEwh3mW0D+ScWCax7w2DL9kPOUYANXRiaGa1y0+UkvS9 l2OUxIcSpjj4lAUegWK5xEbr01sr4ytlgnTKin8q1FLQDu3YpYbbs00fylMajKkB+FbA KzhXbrrK06bJmmxx7fWmv8y9SNGakoUIvwYs6XaHiLV2pUXsIhL6Dra+0zF0sbP+WLHm bSuiGkRZ2caIfvwA8yGlpzXAWjwF1oRClkh15Oh6MFFlOIsfCSHUMAdM3qY31yn9hdvT mhLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=g8uTdefvk9Re34ta3Hpj2EM7Z0M3BKhJL7lQL/PEL2M=; b=ZhsyVVtnU1tjZXeTO4QpBxDhj1aN+WnzMvm/bc5JO4AWtyRVKmViyCHuCzyZHcT6ta aDQ9ilEgcxymkUCkTVceOgU+0d9x0M8Mx0kiK61BdO0G7V7zm7mkRv9eldQ9Ac7HjbyG VXFfL2eJgzimG9IClZRBsfedQ8Jb2pXY09M/lK2VhLeVBrlABayxWljCzNEQSxczoTo2 zkauHsGnMDamqixHuj5g1I26eBTko33PXgVESpJmwXMNqKvEk8R/accs5TosmBVg0H+5 EhL4zxgyAkNj2iBFCe6ffH/XZQl6MbF5pjiKQmZMQ2+aj0SX0ma2u97j/FHFoLDYZt45 4RGw== X-Gm-Message-State: ACgBeo2Z4U82SEu2F56Ebsx+qWXqcg5WcVW5Cmtm83OP2q05hxtkUac8 LbXACpopS+dH/6p5RxD/FaBPid2sk2HcPw== X-Google-Smtp-Source: AA6agR7ySj8B3HLO3ogrPbMnT+iVySyqolRFoWBUwcMlzqYCix0W79Ex8+UATRIvXkt438fUFUgeFA== X-Received: by 2002:a17:90a:13c8:b0:200:17ca:f183 with SMTP id s8-20020a17090a13c800b0020017caf183mr3010705pjf.104.1662627199819; Thu, 08 Sep 2022 01:53:19 -0700 (PDT) From: Viresh Kumar To: xen-devel@lists.xen.org Cc: Viresh Kumar , Vincent Guittot , stratos-dev@op-lists.linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Stefano Stabellini , Mathieu Poirier , Oleksandr Tyshchenko , Wei Liu , Juergen Gross , Julien Grall , Anthony PERARD , Oleksandr Tyshchenko Subject: [PATCH V6 1/3] libxl: arm: Create alloc_virtio_mmio_params() Date: Thu, 8 Sep 2022 14:22:59 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 In order to prepare for adding support for more device types, create a separate routine to allocate base and irq for a device as the same code will be required for other device types too. Also move updates to virtio_irq and virtio_enabled out of the disk device specific block, as they will depend on other device types too. Suggested-by: Oleksandr Tyshchenko Reviewed-by: Oleksandr Tyshchenko Signed-off-by: Viresh Kumar Reviewed-by: Anthony PERARD --- tools/libs/light/libxl_arm.c | 47 +++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 1a3ac1646e94..cc30ba124918 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -48,6 +48,24 @@ static uint32_t alloc_virtio_mmio_irq(libxl__gc *gc, uint32_t *virtio_mmio_irq) return irq; } +static int alloc_virtio_mmio_params(libxl__gc *gc, uint64_t *base, + uint32_t *irq, uint64_t *virtio_mmio_base, + uint32_t *virtio_mmio_irq) +{ + *base = alloc_virtio_mmio_base(gc, virtio_mmio_base); + if (!*base) + return ERROR_FAIL; + + *irq = alloc_virtio_mmio_irq(gc, virtio_mmio_irq); + if (!*irq) + return ERROR_FAIL; + + LOG(DEBUG, "Allocate Virtio MMIO params: IRQ %u BASE 0x%"PRIx64, *irq, + *base); + + return 0; +} + static const char *gicv_to_string(libxl_gic_version gic_version) { switch (gic_version) { @@ -70,6 +88,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, bool vuart_enabled = false, virtio_enabled = false; uint64_t virtio_mmio_base = GUEST_VIRTIO_MMIO_BASE; uint32_t virtio_mmio_irq = GUEST_VIRTIO_MMIO_SPI_FIRST; + int rc; /* * If pl011 vuart is enabled then increment the nr_spis to allow allocation @@ -85,20 +104,12 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, libxl_device_disk *disk = &d_config->disks[i]; if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) { - disk->base = alloc_virtio_mmio_base(gc, &virtio_mmio_base); - if (!disk->base) - return ERROR_FAIL; - - disk->irq = alloc_virtio_mmio_irq(gc, &virtio_mmio_irq); - if (!disk->irq) - return ERROR_FAIL; - - if (virtio_irq < disk->irq) - virtio_irq = disk->irq; - virtio_enabled = true; + rc = alloc_virtio_mmio_params(gc, &disk->base, &disk->irq, + &virtio_mmio_base, + &virtio_mmio_irq); - LOG(DEBUG, "Allocate Virtio MMIO params for Vdev %s: IRQ %u BASE 0x%"PRIx64, - disk->vdev, disk->irq, disk->base); + if (rc) + return rc; } } @@ -107,8 +118,16 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, * present, make sure that we allocate enough SPIs for them. * The resulting "nr_spis" needs to cover the highest possible SPI. */ - if (virtio_enabled) + if (virtio_mmio_irq != GUEST_VIRTIO_MMIO_SPI_FIRST) { + virtio_enabled = true; + + /* + * Assumes that "virtio_mmio_irq" is the highest allocated irq, which is + * updated from alloc_virtio_mmio_irq() currently. + */ + virtio_irq = virtio_mmio_irq - 1; nr_spis = max(nr_spis, virtio_irq - 32 + 1); + } for (i = 0; i < d_config->b_info.num_irqs; i++) { uint32_t irq = d_config->b_info.irqs[i]; From patchwork Thu Sep 8 08:53:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12969806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1E64DC54EE9 for ; Thu, 8 Sep 2022 08:53:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.402881.644830 (Exim 4.92) (envelope-from ) id 1oWDHp-0004a0-Qh; Thu, 08 Sep 2022 08:53:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 402881.644830; Thu, 08 Sep 2022 08:53:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWDHp-0004Zp-Nn; Thu, 08 Sep 2022 08:53:25 +0000 Received: by outflank-mailman (input) for mailman id 402881; Thu, 08 Sep 2022 08:53:25 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWDHp-0004Hp-0g for xen-devel@lists.xen.org; Thu, 08 Sep 2022 08:53:25 +0000 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [2607:f8b0:4864:20::62e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b1dc067c-2f53-11ed-a31c-8f8a9ae3403f; Thu, 08 Sep 2022 10:53:24 +0200 (CEST) Received: by mail-pl1-x62e.google.com with SMTP id iw17so10521616plb.0 for ; Thu, 08 Sep 2022 01:53:23 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id m14-20020a170902bb8e00b0017519b86996sm13793459pls.218.2022.09.08.01.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 01:53:22 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b1dc067c-2f53-11ed-a31c-8f8a9ae3403f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/UEiFJKtm7/4NuvrzhnPo0LaLbvuX390efC9WrRSDDA=; b=wWgUabhPbeJq2hBFiCzFdXfq110UIC+HRSYH4k4bh1bV8dxugymD82lrIUOn94NmRv s0FW+wjGfMw2GIm2DXIuYb2V9zrhWmiO6VhHl++hzYejWaFGRnR+KS36dw2PFqKjWf0E 8WRYpRnyZZR2vHWeLXdhw8uKDCcSBpqswRXY7p2i4U7LWNMOcfW2L9viOsLvz88kzdcT wpCphxw+pJyYzwI3gXt2Y4GEqI3O0OO2W0+67/dUnShjm/IE3+J5rPG00TVoeR2lJHSx 8psrXFdHGoYrlBllLO5rNUsj9eGcvV9y9hCeZOy9asX3DfwwMOI9Lc+EC7DMaoDauxdY z0Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=/UEiFJKtm7/4NuvrzhnPo0LaLbvuX390efC9WrRSDDA=; b=LMVkFl21/V+64rIN2BAvKt36iDR4xAouXqKn0nkMSqgY1Z+5k+wXme6yDGy91hM8C6 tW7wBIjHVAatQcrBF5yqmxscKHVkiIpag+Uy74ID9c00t5vfYA/REco3F2ppM+CfBRbx aLc8fx+JpPgnLkax4KTg3QrjkZ9zW8s+pY0a4UbR7krmeFLh5K90eLYEMsStnxUHr2/N qiQRzKMYHLP6RT8ms5BpXijeWTJAKQUylYkANs2LKdA5v7Faqa5l0xFnc9oSyxpK6rCy 2w6b1WRbOpTDb6QfkJAfmH7Mqs9zNJ22NRYpdioGTX7zU6xF4B6PLEoHniuxh9fGbx76 x25Q== X-Gm-Message-State: ACgBeo2uHul7ZyKyYBJod+rKFmWUKWuum/OVmq2Z5mCqIExYeTfx2Wao H4b2Jefh8ykL116EildX06hGxkMXTlzYsg== X-Google-Smtp-Source: AA6agR44zhvleFny9uTwjI62GkT4G1FygHSVLhOOBlnLa/zEmKAqCg6xfNxPUp/bNyLw2IyO1iNKhQ== X-Received: by 2002:a17:903:40d2:b0:174:e086:c748 with SMTP id t18-20020a17090340d200b00174e086c748mr8259497pld.108.1662627202662; Thu, 08 Sep 2022 01:53:22 -0700 (PDT) From: Viresh Kumar To: xen-devel@lists.xen.org Cc: Viresh Kumar , Vincent Guittot , stratos-dev@op-lists.linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Stefano Stabellini , Mathieu Poirier , Oleksandr Tyshchenko , Wei Liu , Juergen Gross , Julien Grall , Anthony PERARD , Oleksandr Tyshchenko Subject: [PATCH V6 2/3] libxl: arm: Split make_virtio_mmio_node() Date: Thu, 8 Sep 2022 14:23:00 +0530 Message-Id: <0edb5dc1ea3308cf9202e6476ff2797aad953966.1662626550.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 make_virtio_mmio_node() creates the DT node for simple MMIO devices currently, i.e. the ones that don't require any additional properties. In order to allow using it for other complex device types, split the functionality into two, one where the fdt node isn't closed and the other one to create a simple DT node. Reviewed-by: Oleksandr Tyshchenko Signed-off-by: Viresh Kumar Reviewed-by: Anthony PERARD --- tools/libs/light/libxl_arm.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index cc30ba124918..55aee15c10b4 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -907,9 +907,9 @@ static int make_xen_iommu_node(libxl__gc *gc, void *fdt) return 0; } -static int make_virtio_mmio_node(libxl__gc *gc, void *fdt, - uint64_t base, uint32_t irq, - uint32_t backend_domid) +/* The caller is responsible to complete / close the fdt node */ +static int make_virtio_mmio_node_common(libxl__gc *gc, void *fdt, uint64_t base, + uint32_t irq, uint32_t backend_domid) { int res; gic_interrupt intr; @@ -942,10 +942,18 @@ static int make_virtio_mmio_node(libxl__gc *gc, void *fdt, if (res) return res; } - res = fdt_end_node(fdt); + return res; +} + +static int make_virtio_mmio_node(libxl__gc *gc, void *fdt, uint64_t base, + uint32_t irq, uint32_t backend_domid) +{ + int res; + + res = make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid); if (res) return res; - return 0; + return fdt_end_node(fdt); } static const struct arch_info *get_arch_info(libxl__gc *gc, From patchwork Thu Sep 8 08:53:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 12969807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E73DFECAAD5 for ; Thu, 8 Sep 2022 08:53:35 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.402882.644841 (Exim 4.92) (envelope-from ) id 1oWDHt-0004uE-2D; Thu, 08 Sep 2022 08:53:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 402882.644841; Thu, 08 Sep 2022 08:53:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWDHs-0004u3-VO; Thu, 08 Sep 2022 08:53:28 +0000 Received: by outflank-mailman (input) for mailman id 402882; Thu, 08 Sep 2022 08:53:28 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oWDHs-00041V-0U for xen-devel@lists.xen.org; Thu, 08 Sep 2022 08:53:28 +0000 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [2607:f8b0:4864:20::52d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b3829a88-2f53-11ed-9760-273f2230c3a0; Thu, 08 Sep 2022 10:53:26 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id 78so16054808pgb.13 for ; Thu, 08 Sep 2022 01:53:26 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id k15-20020aa7998f000000b0053e9c04757dsm2067450pfh.169.2022.09.08.01.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 01:53:24 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b3829a88-2f53-11ed-9760-273f2230c3a0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KvygtE56N8zYKSJxBlMmn0X+tKsUv5sphCjxV3H2TI4=; b=WohkmT1BeCvS0E8Wetu+Zk37tJlFt2oJSQpKV+b3jFHbACkodyw/hJgyGjsoSZlxXq rHcd2Roec+M4LP+J/u6QvlYY4x3kECdQHjPklUMGK+3Q9Iz91AR8NtYD2JeMvplDNfJa zC4lBxO7izl7baxR2DE52F2OonJlXP4oKQDr1bTFAb7Zcb4iChJEf7MuUqYU7XKS1sKY 46+/i1+6VS8YfaWjE2YN2Zc/0t6tuqcElgIBVISus5FIC2E5CO3E3cDuhgVs47cCWGLI p8clqR40EALUIXkcklT2O4Qw5vB/I6ymUus+26KLIOip7ydmb6sWVsArmkjh0V2VSIi5 YSMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=KvygtE56N8zYKSJxBlMmn0X+tKsUv5sphCjxV3H2TI4=; b=N+/zuVXR7rOH/Yp8lE3wCfgXBOE+zzBNi2ouAxrJH54+tnpSsnlIDvUKDtVSkrv3tl 1OflqWe/mziM2nrAeBy3l034IURryV5i3oP8RVFR08HgLc/l28zUtoi2dEO2NfVnXXqc F2TtiipVuhl71X+u3vXsvxfsLXBaSgs3X8gwVPr5amx9t4o3iQ1Xb1tSeOknwzhfQn+w mqImg9YwXFeOO40upSRnUdLFZ0++bwCK46yB2ylH4TNsiNcdM/RmQBXix8yYnANz5t74 FBuVdKp2lquu3sb2pGen/0N2JPwx37jDyqmrQQcVeDfUkSJ1Hgxml7d+db7vlKsK90e7 4c8Q== X-Gm-Message-State: ACgBeo1rYXXHjwgoG6AeuBpjjmAV72hzo26GrHWjXoIEveJ/HhGiqrb/ KlqRC0XpTT3p6kwDUuyXJXQsn04OqVTPKg== X-Google-Smtp-Source: AA6agR7rTh0qzn+h0YaGzImMjv1sCcTEZWC+LMNk7f8DZa4Jdj1plGLmSf7Cz36sRy94uaxwxeYcug== X-Received: by 2002:a63:d114:0:b0:429:f039:ccfc with SMTP id k20-20020a63d114000000b00429f039ccfcmr7090714pgg.95.1662627205408; Thu, 08 Sep 2022 01:53:25 -0700 (PDT) From: Viresh Kumar To: xen-devel@lists.xen.org Cc: Viresh Kumar , Vincent Guittot , stratos-dev@op-lists.linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Stefano Stabellini , Mathieu Poirier , Oleksandr Tyshchenko , Wei Liu , Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH V6 3/3] libxl: arm: make creation of iommu node independent of disk device Date: Thu, 8 Sep 2022 14:23:01 +0530 Message-Id: <099616e1092409fceea4eb30590215310f8c091c.1662626550.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 The iommu node will be required for other virtio device types too, not just disk device. Move the call to make_xen_iommu_node(), out of the disk device specific block and rename "iommu_created" variable to "iommu_needed", and set it to true for virtio disk device. Signed-off-by: Viresh Kumar --- tools/libs/light/libxl_arm.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 55aee15c10b4..2637acafa358 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -1157,7 +1157,7 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_config *d_config, size_t fdt_size = 0; int pfdt_size = 0; libxl_domain_build_info *const info = &d_config->b_info; - bool iommu_created; + bool iommu_needed; unsigned int i; const libxl_version_info *vers; @@ -1265,22 +1265,26 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_config *d_config, if (d_config->num_pcidevs) FDT( make_vpci_node(gc, fdt, ainfo, dom) ); - iommu_created = false; + iommu_needed = false; for (i = 0; i < d_config->num_disks; i++) { libxl_device_disk *disk = &d_config->disks[i]; if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) { - if (disk->backend_domid != LIBXL_TOOLSTACK_DOMID && - !iommu_created) { - FDT( make_xen_iommu_node(gc, fdt) ); - iommu_created = true; - } + if (disk->backend_domid != LIBXL_TOOLSTACK_DOMID) + iommu_needed = true; FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq, disk->backend_domid) ); } } + /* + * Note, this should be only called after creating all virtio-mmio + * device nodes + */ + if (iommu_needed) + FDT( make_xen_iommu_node(gc, fdt) ); + if (pfdt) FDT( copy_partial_fdt(gc, fdt, pfdt) );