From nobody Mon Dec 15 21:31:11 2025 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1744127878; cv=none; d=zohomail.com; s=zohoarc; b=Yu0h1NHjxr22skwkuuyqT0MbXfIDBnCz91el2FylTfL19sKd54sFxGWmWGbh21gXhkkyo0hpKNEjF4E5sVQAYCrGTAxAvFFgWmIkMjZ76p4kJ9X2i8FvH9T8EX2CtM57ZAMPbBBj/qoXzI/VP3VVRfCZ2qK3RYk8L/HrRlzlHAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744127878; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uCtnXnepMjQJ6WdYnFvlLVv3tm/yir71NGvOBIDdkhw=; b=iuWRYmIPz5Vv3srkEzLr9LvTbTUaD2UnEykJed3UixazDxiXqVjx2sxWETsgea4u5A7+x+EC82+Pofd6qcYgrgpUnBT2SzCc2+kzND7HijJVw4Cy0VtNYV+I2ouX68Pmh14jry9PmZq96Idi6oHALPnCQUW8GZNwFWq2ap9AEkk= 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 1744127878488104.5095193989406; Tue, 8 Apr 2025 08:57:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.942505.1341682 (Exim 4.92) (envelope-from ) id 1u2BKP-0005rm-Di; Tue, 08 Apr 2025 15:57:33 +0000 Received: by outflank-mailman (output) from mailman id 942505.1341682; Tue, 08 Apr 2025 15:57:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u2BKP-0005rf-Ab; Tue, 08 Apr 2025 15:57:33 +0000 Received: by outflank-mailman (input) for mailman id 942505; Tue, 08 Apr 2025 15:57:31 +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 1u2BKN-0004Yq-IU for xen-devel@lists.xenproject.org; Tue, 08 Apr 2025 15:57:31 +0000 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [2a00:1450:4864:20::634]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2ccb0e72-1492-11f0-9ffb-bf95429c2676; Tue, 08 Apr 2025 17:57:29 +0200 (CEST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-ac25520a289so1006060566b.3 for ; Tue, 08 Apr 2025 08:57:29 -0700 (PDT) Received: from fedora.. (user-109-243-64-225.play-internet.pl. [109.243.64.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac7c018556bsm929934566b.156.2025.04.08.08.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Apr 2025 08:57:28 -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: 2ccb0e72-1492-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744127849; x=1744732649; darn=lists.xenproject.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=uCtnXnepMjQJ6WdYnFvlLVv3tm/yir71NGvOBIDdkhw=; b=J8kt5T71PBmUAbha+/X33kUE2vjPDncWuh6r1TwYCbFLfOyAaPMICVQ7lvljkP5XcC zRpFniX3N/KzVDG2TzpWKFJbvnNI2g36HNJX4esqQ4Bg6lvuB5pgmFCsX9bVUBgN6y5A ZLxlfZsb+H3+JO5UeoqS9rkcJ4qlDW0YBQPtKoGMSxuUt1bDM3FxFKbk0eX0D9NIGkis B8M3wUjZkiwkXTjpzKXw3+2oCoMtTlye7e7h/o+b4D8A3uKzmBDVUPK02lpdyAMQTIBq qMFf5UHWv4NtCb4YwZg4Q29AsfdKi9XF2RTDLjx/+bAlZDnDKR9mAR+LETReouSHsz8T m9Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744127849; x=1744732649; 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=uCtnXnepMjQJ6WdYnFvlLVv3tm/yir71NGvOBIDdkhw=; b=ojYnHaGd8IzXXci8xNMLT4+DzqA5OlRh7Y8aFEZKI5IfS3IaL36mFzIbIAve2dooRe HjlJcrtcIlr/kDC1pzWd1NybvEL/NraW+7+dUpTU93fvuMPfFb0Cc1sUKZGkDecpf8XL W2WcdGMbfmhHkw48mNZsLFc0HAn61nQOPg3JijRzRLjtyV+ZYrCIcrJhvykH/0NtZJDX m2vdwQ98DebkC/Lq2ytaDE74k+3PUNwnv+DbV1LxY7KORUoG2nYkxc3g4znsEGAfeNO3 tKeZ4YgFBq0NmOdculg9IyKKvb3v3rmelD5InMJHXFTSdDAms6cTkPAJIGHB4gWir4Ku +UsQ== X-Gm-Message-State: AOJu0YxBllLTTko1DidtLWy1cy3qDqiULD4pgvN7gU6XzKKSAQsx8Zkp EyFl+msz5WrXqSP5a7xKhIgdZET0AA4kdffFYFvYl77eqmHrFFlQPWwq9Q== X-Gm-Gg: ASbGncvnxQvgQ9JPA6TYL1dzCZIEGHfreCDC0B5vJJkkxiRMmUlZm4XRjKSHA/aiNTU hqwiu1HqWZDYXTagEJpSLIWHdqsaWuwp/eybW7rq9fNIAu00vKfWYnvkaakmIgNBidakWDMS+Cy pI5o5XwDIb6FuPyvy/w1ZwlBEj1UReHtOJvsFHa9kcuzLdtOVMCIYNUj2Ozi/W5jeVp7+Q3TbgT Hsqhk8un7bGWXlszgK6Ffdjsoz6XdoPo3daaBzvolZM8m5EzsxbBUigxx452etpCB9R/jhsj4TR MRX5+y1Uk4W1jcpgVuaeIuRyiZMmf8CbmgVmvEVziUVJFFJj8+DWtoXgXnMcnwvAdOGX+HpGKHF /gaYKUOi5CstEtA== X-Google-Smtp-Source: AGHT+IFJ1QvQ6CEjloJ0R8mMyvtVVCL9ldhwXDZiW0oswAHpDPPPugf5ISduozzVoTqxseYyEoUJXQ== X-Received: by 2002:a17:907:724a:b0:ac1:ddaa:2c03 with SMTP id a640c23a62f3a-ac7d690b353mr1371954466b.0.1744127848820; Tue, 08 Apr 2025 08:57:28 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Romain Caritey Subject: [PATCH v1 05/14] xen/riscv: introduce platform_get_irq() Date: Tue, 8 Apr 2025 17:57:09 +0200 Message-ID: <6c6e7482cc3b0332f5724c80bf16931fe2d793ae.1744126720.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1744127880168019000 Content-Type: text/plain; charset="utf-8" platform_get_irq() recieves information about device's irq ( type and irq number ) from device tree node and using this information update irq descriptor in irq_desc[] array. Introduce dt_irq_xlate and initialize with aplic_irq_xlate() as it is used by dt_device_get_irq() which is called by platform_get_irq(). Co-developed-by: Romain Caritey Signed-off-by: Oleksii Kurochko --- xen/arch/riscv/aplic.c | 19 +++++++++++++++ xen/arch/riscv/include/asm/irq.h | 3 +++ xen/arch/riscv/irq.c | 41 ++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index caba8f8993..6dc040af6f 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -11,6 +11,7 @@ =20 #include #include +#include #include #include =20 @@ -21,6 +22,22 @@ static struct intc_info __ro_after_init aplic_info =3D { .hw_version =3D INTC_APLIC, }; =20 +static int aplic_irq_xlate(const uint32_t *intspec, unsigned int intsize, + unsigned int *out_hwirq, + unsigned int *out_type) +{ + if ( intsize < 2 ) + return -EINVAL; + + /* Mapping 1:1 */ + *out_hwirq =3D intspec[0]; + + if ( out_type ) + *out_type =3D intspec[1] & IRQ_TYPE_SENSE_MASK; + + return 0; +} + static int __init aplic_preinit(struct dt_device_node *node, const void *d= at) { if ( aplic_info.node ) @@ -35,6 +52,8 @@ static int __init aplic_preinit(struct dt_device_node *no= de, const void *dat) =20 aplic_info.node =3D node; =20 + dt_irq_xlate =3D aplic_irq_xlate; + return 0; } =20 diff --git a/xen/arch/riscv/include/asm/irq.h b/xen/arch/riscv/include/asm/= irq.h index 8f936b7d01..ff1c95e0be 100644 --- a/xen/arch/riscv/include/asm/irq.h +++ b/xen/arch/riscv/include/asm/irq.h @@ -47,6 +47,9 @@ static inline void arch_move_irqs(struct vcpu *v) BUG_ON("unimplemented"); } =20 +struct dt_device_node; +int platform_get_irq(const struct dt_device_node *device, int index); + void init_IRQ(void); =20 #endif /* ASM__RISCV__IRQ_H */ diff --git a/xen/arch/riscv/irq.c b/xen/arch/riscv/irq.c index 99b8f2095e..c332e000c4 100644 --- a/xen/arch/riscv/irq.c +++ b/xen/arch/riscv/irq.c @@ -7,11 +7,52 @@ */ =20 #include +#include +#include #include #include =20 static irq_desc_t irq_desc[NR_IRQS]; =20 +static bool irq_validate_new_type(unsigned int curr, unsigned int new) +{ + return (curr =3D=3D IRQ_TYPE_INVALID || curr =3D=3D new ); +} + +static int irq_set_type(unsigned int irq, unsigned int type) +{ + unsigned long flags; + struct irq_desc *desc =3D irq_to_desc(irq); + int ret =3D -EBUSY; + + spin_lock_irqsave(&desc->lock, flags); + + if ( !irq_validate_new_type(desc->arch.type, type) ) + goto err; + + desc->arch.type =3D type; + + ret =3D 0; + +err: + spin_unlock_irqrestore(&desc->lock, flags); + + return ret; +} + +int platform_get_irq(const struct dt_device_node *device, int index) +{ + struct dt_irq dt_irq; + + if ( dt_device_get_irq(device, index, &dt_irq) ) + return -1; + + if ( irq_set_type(dt_irq.irq, dt_irq.type) ) + return -1; + + return dt_irq.irq; +} + int arch_init_one_irq_desc(struct irq_desc *desc) { desc->arch.type =3D IRQ_TYPE_INVALID; --=20 2.49.0