From nobody Mon Feb 9 20:36:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1661159767; cv=none; d=zohomail.com; s=zohoarc; b=NAPjg+hV5vBmhAoU2/jMbyl2DCD+acxm/3ELgqjWDsYS18yH5idXTgL/laq8iNh6Kan4MEgNFtN4X5IqOJt/qWU2THd1bwGrhu4Rqtwo/zDY9nR3UzyZ+awyn1VIUL9NjebB+w7yK2B6+hDMKTzvx1R6h832zHaIFXBqCYLCXQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661159767; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XPO6uUW2aI4P/8vL92ycMK94cuye3tq563IA6689ljc=; b=m+RHgvgM+eCe8mIc/LXzfgJoQhNRXaSSFchBJva4KmD9uXgKINaUViNVT1I6eGiRP4l8k2J1JGqg+ezvQWf9lEdgFc3oDnp7fQGmVN6Npm0TpGOoTfSK0V5gxKYWrEEH8k2g+0bKjOWR/Khn5K1RBtBlr2Te1kaiWOpbKDg+zAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1661159767840860.166494309841; Mon, 22 Aug 2022 02:16:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.391249.629039 (Exim 4.92) (envelope-from ) id 1oQ3X8-0002fj-Hf; Mon, 22 Aug 2022 09:15:46 +0000 Received: by outflank-mailman (output) from mailman id 391249.629039; Mon, 22 Aug 2022 09:15:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oQ3X8-0002fa-CH; Mon, 22 Aug 2022 09:15:46 +0000 Received: by outflank-mailman (input) for mailman id 391249; Mon, 22 Aug 2022 09:15:44 +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 1oQ3X6-00016q-If for xen-devel@lists.xen.org; Mon, 22 Aug 2022 09:15:44 +0000 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [2607:f8b0:4864:20::1033]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ff6ca335-21fa-11ed-9250-1f966e50362f; Mon, 22 Aug 2022 11:15:43 +0200 (CEST) Received: by mail-pj1-x1033.google.com with SMTP id m15so2273118pjj.3 for ; Mon, 22 Aug 2022 02:15:43 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id b194-20020a6334cb000000b0041d02809facsm6958423pga.79.2022.08.22.02.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 02:15:41 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: ff6ca335-21fa-11ed-9250-1f966e50362f 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; bh=XPO6uUW2aI4P/8vL92ycMK94cuye3tq563IA6689ljc=; b=HTZEvkwROQexnDYLr+x+fQKWnjQO4N+9lAvx1razDZPz/wrNJgOiURGFZmERofc1Wi nFwWH27wOsfcEYfKhN2wOlH79TLMPJzql8U1utfnlI8MEJAE0h1Upf0eUV8Ws1fR8xUk pQjebaOB1bBrSYapq8LJnPSWPGWi/C2RlPXLKcLG9ACC6g35wTUyhRj5CSRCTXTRTPV0 rkt1IUIPU08FUImcHfvAIOkoq2SbMfYQHkJGeySJbVxLTW4LrIIb0cidQ2FjauukmYfR ehdQaxuhYvUFbuqz9Vl7EU4iST5EQrvUrrbedJzf82hMRw+SF9fFXThY5HZjJj77IUME ZADQ== 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; bh=XPO6uUW2aI4P/8vL92ycMK94cuye3tq563IA6689ljc=; b=eZJKYyN76f969m3O9QYGBZMfRuLgZHQnQumqZ0zgNnB6MWUJMtWehnNjYDZv83HwKm QVGnv7C3/uFKDUTDK2EZtmEmwT2Y4qhd/ZolnbDXQkO0OYci9scuWDbvBPoFhWqVZQHX B/rtFaW8N6Rzooo+EnvQ9OwO1og3cRE0A/5Rg+85PN9aS7KvFfwVNnzJqZhTz8CCNiDW Hg3lpkyrwAqUoGyLkJEXUZ+Z60tthddKlZvLC9yCHP1+f277qfjGC+5NJ9YZ6FbSgZal QW4EOHTvT5vD+W4pZgKqWxTD3pRo79gcRB4vOn3PGjbGCSYoIMO28TFT1A+hoPcUW0qz 1lKQ== X-Gm-Message-State: ACgBeo19wDCyMjU4tzO5i37H/kqve4JcjG8nN8RgeBJO5Y85+7VuVvcZ 8KnGJ0jyusL7G4wM9qqSfE+8V7EtDhu9Sw== X-Google-Smtp-Source: AA6agR7byTBxhWJPa6a5rX2AncrvRnnlziDy+FzQHQ2INg5On7XlXYdlOSG+9SfCSdXy7YShhnMfqw== X-Received: by 2002:a17:90a:e009:b0:1fa:e417:b9b7 with SMTP id u9-20020a17090ae00900b001fae417b9b7mr17532898pjy.149.1661159742430; Mon, 22 Aug 2022 02:15:42 -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=20Benn=C3=A9e?= , Stefano Stabellini , Mathieu Poirier , Mike Holmes , Oleksandr Tyshchenko , Wei Liu , Juergen Gross , Julien Grall , anthony.perard@citrix.com, Oleksandr Tyshchenko Subject: [PATCH V5 6/6] libxl: Allocate MMIO params for GPIO device and update DT Date: Mon, 22 Aug 2022 14:45:18 +0530 Message-Id: <4a238937ceb803f494e5633a3a779866383bd463.1661159474.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1661159768473100005 Content-Type: text/plain; charset="utf-8" This patch allocates Virtio MMIO params (IRQ and memory region) and pass them to the backend, also update Guest device-tree based on Virtio GPIO DT bindings [1]. [1] https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio-= virtio.yaml Reviewed-by: Oleksandr Tyshchenko Signed-off-by: Viresh Kumar --- tools/libs/light/libxl_arm.c | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c index 4c1012e56893..86c1e560900f 100644 --- a/tools/libs/light/libxl_arm.c +++ b/tools/libs/light/libxl_arm.c @@ -121,6 +121,15 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, return rc; } =20 + for (i =3D 0; i < d_config->num_gpios; i++) { + libxl_device_gpio *gpio =3D &d_config->gpios[i]; + int rc =3D alloc_virtio_mmio_params(gc, &gpio->base, &gpio->irq, + &virtio_mmio_base, &virtio_mmio_irq); + + if (rc) + return rc; + } + /* * Every virtio-mmio device uses one emulated SPI. If Virtio devices a= re * present, make sure that we allocate enough SPIs for them. @@ -984,6 +993,38 @@ static int make_virtio_mmio_node_i2c(libxl__gc *gc, vo= id *fdt, uint64_t base, return fdt_end_node(fdt); } =20 +static int make_virtio_mmio_node_gpio(libxl__gc *gc, void *fdt, uint64_t b= ase, + uint32_t irq, uint32_t backend_domid) +{ + int res; + + res =3D make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid= ); + if (res) return res; + + res =3D fdt_begin_node(fdt, "gpio"); + if (res) return res; + + res =3D fdt_property_compat(gc, fdt, 1, "virtio,device29"); + if (res) return res; + + res =3D fdt_property(fdt, "gpio-controller", NULL, 0); + if (res) return res; + + res =3D fdt_property_cell(fdt, "#gpio-cells", 2); + if (res) return res; + + res =3D fdt_property(fdt, "interrupt-controller", NULL, 0); + if (res) return res; + + res =3D fdt_property_cell(fdt, "#interrupt-cells", 2); + if (res) return res; + + res =3D fdt_end_node(fdt); + if (res) return res; + + return fdt_end_node(fdt); +} + static const struct arch_info *get_arch_info(libxl__gc *gc, const struct xc_dom_image *do= m) { @@ -1317,6 +1358,16 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_d= omain_config *d_config, i2c->backend_domid) ); } =20 + for (i =3D 0; i < d_config->num_gpios; i++) { + libxl_device_gpio *gpio =3D &d_config->gpios[i]; + + if (gpio->backend_domid !=3D LIBXL_TOOLSTACK_DOMID) + iommu_needed =3D true; + + FDT( make_virtio_mmio_node_gpio(gc, fdt, gpio->base, gpio->irq, + gpio->backend_domid) ); + } + /* * Note, this should be only called after creating all virtio-mmio * device nodes --=20 2.31.1.272.g89b43f80a514