From nobody Sun Nov 2 22:32:05 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=1746550339; cv=none; d=zohomail.com; s=zohoarc; b=MWHOoo6wHw7+i/4LG44Am+vtRCh23R3oUwZvE/WZVoDp0dGLKvn3omAK3PwYi4wHmfsaOiCgH/rg8YNdcyC7bAOXSxtiMBoeYfvJEdw+mPGx2jdspO+QuOwmQsVgSLPgf9EdNOoNU1sz4gSmP3Rah/KWpUIqgnXVfWcIdaXzT/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746550339; 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=sQmSVGxqEnAHeu+UgiQeZLUtUFIRNIGEg4FW26txKNs=; b=ZC/B/0zOcCgmr5xq6QnOO0gvTEwCRHtHhyVeIQ+wLAr9L6lphQf/2hsbKQ/AUXWtOMfGWKpqsuLA4ctOFjdraTeT5BW1Oq/EhNbcalT7JDWV1Becx3v800jKriCWVB3iZ3ggLF4yLKSWp2V3hUsPSR2PYbXjlQ8jh6NogIkfO64= 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 1746550339710978.8974219386548; Tue, 6 May 2025 09:52:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.977623.1364633 (Exim 4.92) (envelope-from ) id 1uCLWY-0006de-5C; Tue, 06 May 2025 16:52:06 +0000 Received: by outflank-mailman (output) from mailman id 977623.1364633; Tue, 06 May 2025 16:52:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uCLWX-0006cp-Vu; Tue, 06 May 2025 16:52:05 +0000 Received: by outflank-mailman (input) for mailman id 977623; Tue, 06 May 2025 16:52:04 +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 1uCLWW-00058E-8P for xen-devel@lists.xenproject.org; Tue, 06 May 2025 16:52:04 +0000 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [2a00:1450:4864:20::52b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6faca94b-2a9a-11f0-9eb4-5ba50f476ded; Tue, 06 May 2025 18:52:03 +0200 (CEST) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5f6c3f7b0b0so11799413a12.0 for ; Tue, 06 May 2025 09:52:03 -0700 (PDT) Received: from fedora.. (user-109-243-69-225.play-internet.pl. [109.243.69.225]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ad1891a3cb9sm740295366b.60.2025.05.06.09.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 May 2025 09:52:02 -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: 6faca94b-2a9a-11f0-9eb4-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746550323; x=1747155123; 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=sQmSVGxqEnAHeu+UgiQeZLUtUFIRNIGEg4FW26txKNs=; b=OSNe/ndfvuDC822lP2dM8YoshI0hRUVFlEkJdsr8tz4mH+OAsqkUgZjLZOUaQGDwPB RZKU/DHQ0mBxmURhrbIsQM82QQ35K/CRftGvMTi+6owsKvD2MhJGb+T1XkamIrywJNFy f48+jdJbaOMyjBAniykbAEAjvIyDBHkBTQuUQCts9lLscJT+EJTtbEJP8aN34Y9dC6SV 9sAAnDI+oJNsTJYu3P+5LG0h3jn4l/myb1jbEj+N32wGRcXjwYAg69IyTDcO4HOl0SKO /me3y4pc2fJOvnVvcC3UrqwAppJzA2h/yBUSusMlCDGLi3ZEBl1vsbw2/ltSyGFlfeX5 maMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746550323; x=1747155123; 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=sQmSVGxqEnAHeu+UgiQeZLUtUFIRNIGEg4FW26txKNs=; b=FgVWcDEtnhb638WdTG+XBVDZW4clzJ2izVndl70kEqF0M8aJmWxAZsFzy0dtRmcQV6 swO7Zw0kRzsTOoctV7+2vCn/aeyIDxUhiaiKEZhwi9F0w3isjekNGqB2pe6l7+v3Jc+E Inha7PqXZyiovvL7droXmCPD/GBLBjK5yNFIVxBoOE7fow7uW73UZdecBuYxGegsZrb+ JShFU+oNaVIE0Ul3JxuVfWhIdagMEH98d5PUoxWFOOiN1y3LyzPUGEfqbXDs4SOx02Gw osjO1ZciSxn+e3rwTwxPLvwFMnFVIv8X5QxQzmJtGmd7tgQKTNbk/nYaB/xgFJWtcoXl +eYw== X-Gm-Message-State: AOJu0YzN2xT5M62HNCg1QSc8sdgtFwi/JMupSWcbrsyvQMI5NRcUSOpR CCTZxry7x3Ty8H94c1Ap5Nztl16XOIp9L2t8fAWptep101EyKmmxYkXK+g== X-Gm-Gg: ASbGncv99+BJMt5UfgmQ0pPd75IKcAja5Sd0fCtzTlSwgXAEl811bdFblJfUbP8OrzE j6WRaqvvdId70WwbZwk+hf7gs5h0heCDMLvF+Q+NbNermiylVb9mXUc1CfjxVqHTj7LYUssWUjO b5CIb5f1B/IuUponO9ySg2blnUKi9y6Mkpg8fs0EfEAhD07fCPMsSwP+GR5gx2P/v4d/2NitzFm Su3OSvZHIyWjfUDdpC7oFa5Y6yvcw5KMx198ul3bJC4k3KKNuzuCuFWU3aFaPzydfIUN0GKny7u xZMxDhxbz42e5K/J7uAybzwMKsmrMqyrLau7SJTaXxLa3fvm8Igpd4xulgGeWq2Ql5629j90vG5 avvInGIR9Dap51Y/wFOYj X-Google-Smtp-Source: AGHT+IEmGcXV6QzEG20w+umThYUL14rC7eZyQsSdWYUQrMcXWQKyWCRp4acrsSIB59X1kJW/UWJMRQ== X-Received: by 2002:a17:907:8688:b0:ad1:8dd3:a4eb with SMTP id a640c23a62f3a-ad1e8d0d9e5mr16872366b.56.1746550322718; Tue, 06 May 2025 09:52:02 -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 v2 07/16] xen/riscv: introduce platform_get_irq() Date: Tue, 6 May 2025 18:51:37 +0200 Message-ID: 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: 1746550340656019000 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 --- Changes in V2: - Add cf_check for aplic_irq_xlate(). - Ident label in irq_set_type(). - Return proper -E... values for platform_get_irq(). --- xen/arch/riscv/aplic.c | 20 +++++++++++++++ xen/arch/riscv/include/asm/irq.h | 3 +++ xen/arch/riscv/irq.c | 42 ++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index caba8f8993..10ae81f7ac 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,23 @@ static struct intc_info __ro_after_init aplic_info =3D { .hw_version =3D INTC_APLIC, }; =20 +static int cf_check 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 +53,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 f609df466e..6223bbbed5 100644 --- a/xen/arch/riscv/include/asm/irq.h +++ b/xen/arch/riscv/include/asm/irq.h @@ -30,6 +30,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 26a8556b2c..4c518bbd97 100644 --- a/xen/arch/riscv/irq.c +++ b/xen/arch/riscv/irq.c @@ -7,11 +7,53 @@ */ =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; + int ret; + + if ( (ret =3D dt_device_get_irq(device, index, &dt_irq)) !=3D 0 ) + return ret; + + if ( (ret =3D irq_set_type(dt_irq.irq, dt_irq.type)) !=3D 0 ) + return ret; + + 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