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 19540CD98C5 for ; Mon, 15 Jun 2026 15:54:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1338427.1599456 (Exim 4.92) (envelope-from ) id 1wZ9d7-0008E5-UE; Mon, 15 Jun 2026 15:53:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1338427.1599456; Mon, 15 Jun 2026 15:53:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZ9d7-0008Dy-RM; Mon, 15 Jun 2026 15:53:41 +0000 Received: by outflank-mailman (input) for mailman id 1338427; Mon, 15 Jun 2026 15:53:40 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZ9d6-0008Ds-NW for xen-devel@lists.xenproject.org; Mon, 15 Jun 2026 15:53:40 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZ9d5-00755E-Dy for xen-devel@lists.xenproject.org; Mon, 15 Jun 2026 17:53:39 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a301fff-5cb7-0a2a0a5109dd-0a2a4506af78-12 for ; Mon, 15 Jun 2026 17:53:39 +0200 Received: from [209.85.128.43] (helo=mail-wm1-f43.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a302003-7371-0a2a45060019-d155802bb4f1-3 for ; Mon, 15 Jun 2026 17:53:39 +0200 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4908b92904fso42923085e9.0 for ; Mon, 15 Jun 2026 08:53:39 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4606f26f4f6sm38817085f8f.16.2026.06.15.08.53.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Jun 2026 08:53:37 -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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1781538818; x=1782143618; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=vLPIMyze5rWcNUNeET2GyTTIAiJmLn+nae/3ySjnuog=; b=FUcDK+v+EIWjwlTl+F7Os4ZVMteLFqk4Ccijv6iwPWAb36vDpb61e1t8e95wXufMmE AHZCtNuQGhBCTKbVvZy58t8HDWoifo+YQD9MtMhQwSyc1uwwJLfsehxSwDvj4niiR/3G E1oODvL8rmhzulr9skYGC2WYQ992r9LSmSl4i59Ee05PsD3msOKDN9kFLWgdLNK/bSio 2YMEbV9qhatbkoB4n7RWguvFNgb6/mtdoc/Fz3RWq5pRlDFbqmLuyR+pH/Q71+akpj9S zlv8UmuAHH4meovRntx7QQjx8Th7BSrCSj39PKvmU+SvUh68JMQalUGBKGAPepf8jQDM 8bdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781538818; x=1782143618; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vLPIMyze5rWcNUNeET2GyTTIAiJmLn+nae/3ySjnuog=; b=I9TEyBTP7BWfSbnrfnuZjIfuf8FQZmXWUZMNZijdccMPA16jz7+8quJsTSXKZXQ8yS S7KNG5/zP2TOTtFst2+xLO/o+eQf+r+2GWhl528kVttNEV7yAcEPtltQUivrmJ1EKqjS bX3f9Fm38eXlIKcfgUX6DT37FZ3BAO6cn40kmdomRhNqCxbAYif7bkDF58M0D1AdFDff uJms4yQNBNF4OFvQJyWdtb9EafS0ypeDsfbuw1R1a8Caiz9+sYZ3gVFbAqv7RlWSevgn mJw7tCk8sJ68MO/7KOgfIei/P5MHKhgDojK6l3WXgs6F/iSRd4tFSJk2HDjGLLaG1mWg cI8A== X-Forwarded-Encrypted: i=1; AFNElJ9ETnfpq9xYACpCwqyJv0bvA1TrrVnE+MPJaAOeFBeljVbALAFa1kZVxgGOly8jAVKYaWmFEvoiZeI=@lists.xenproject.org X-Gm-Message-State: AOJu0YxUbMDIaF3QSSxRSeEGlzSzhpIKNb4CRc5MF/7eD79au+5+HzdE ULXypObL5TA2gGfLx/mqx8VMMcym8SlfYQ9War2ax6p1X0WH1ZTOseR6nTD4AkBorA== X-Gm-Gg: Acq92OEX8h7djwRxctrjidMmdRI+MttG0+QEoCGcDJXGyTDq+SWwFMBzYJ5leKoenBx dLPmDh/aei6Rak4rJ7dGryHHrFbBzvsW4dRz9z5x0heE33GKzsOFBZ017TmTC/RNgMLH2T93McT nqwvo8IcGJd1zsPthiFvn5oB2ztJBQAqm4aIC51K3Iu6OjQx0mAziwfYEdmLjELFkEguKUZy5mr YZJh1ObUtVIyfDaKf+cHVx6i9weBl03z5aCxgh940KOdfB7imax2EYrl2DkurjyfcjScDrj+dDc U2BfEpxKNwFpSLwOctEywN34oljm7uYtWJV/j2bLD+regQjWkggrQQDfWvHmmEgMTJfG1W0bd/G dfVNwr1SLzDiKgwV3mhZtA7IpxGFliUuTbFYI4GRILBZXaKKTvu9q6ls0FXUM1VQ6u7AWqoiTvn /tZh78+IO4C9ffcoqrmSDHQH2QJBBMu+p8jjnZG2XZ0RGE3efox6Qa7vdNumUIbCKGvJZXBes4k czh71GnJ4P544Q= X-Received: by 2002:a05:600c:c16f:b0:490:6e11:c303 with SMTP id 5b1f17b1804b1-490ec4e6f22mr182801995e9.13.1781538818114; Mon, 15 Jun 2026 08:53:38 -0700 (PDT) Message-ID: <4580492d-c5e7-454d-b4a9-4bc959268cfb@suse.com> Date: Mon, 15 Jun 2026 17:53:36 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 26/26] xen/riscv: manage IRQ_DISABLED flag in APLIC irq enable/disable callbacks To: Oleksii Kurochko Cc: Romain Caritey , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , xen-devel@lists.xenproject.org References: <6121dce6347f03030a2de05f29c1780b6fc0cd01.1778250616.git.oleksii.kurochko@gmail.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I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cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <6121dce6347f03030a2de05f29c1780b6fc0cd01.1778250616.git.oleksii.kurochko@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-purgate-ID: tlsNG-16d1c6/1781538819-8E58CD75-48DE188E/10/73395122804 X-purgate-type: spam X-purgate-size: 3071 On 08.05.2026 16:43, Oleksii Kurochko wrote: > desc->status is only set once during setup_irq(), but interrupts can be > enabled/disabled at runtime, so update it in the corresponding callbacks. > > wmb() in aplic_irq_enable() ensures do_IRQ(), which can fire immediately > after the interrupt is enabled, sees the updated desc->status. This doesn't look entirely correct. Aiui ... > No rmb() is > needed on the do_IRQ() side because desc->status is read under a spinlock, > which implies an acquire barrier. > > No barrier is needed in aplic_irq_disable() because the hardware disables > the interrupt before the status is updated, so do_IRQ() cannot fire, and > spin_unlock() makes the updated value visible. > > Fixes: d4676a1398bc5 ("xen/riscv: implementation of aplic and imsic operations") > Signed-off-by: Oleksii Kurochko > --- > Changes in v2: > - New patch. > --- > xen/arch/riscv/aplic.c | 5 +++++ > xen/arch/riscv/irq.c | 3 --- > 2 files changed, 5 insertions(+), 3 deletions(-) > > --- a/xen/arch/riscv/aplic.c > +++ b/xen/arch/riscv/aplic.c > @@ -161,6 +161,9 @@ static void cf_check aplic_irq_enable(struct irq_desc *desc) > > spin_lock(&aplic.lock); > > + desc->status &= ~IRQ_DISABLED; > + wmb(); > + > /* Enable interrupt in IMSIC */ > imsic_irq_enable(desc->irq); ... you want to order the ->status update ahead of the imsic_irq_enable() operation. Yet that's a CSR write. Do fences really cover that? If not, you may need to resort to mb(), to order the ->status write against the ->irq read, in lieu of being able to order against a CSR write. Of course with imsic_irq_enable() itself acquiring a lock (which necessarily has a memory write), you could then further argue that wmb() is indeed sufficient, bot for a reason different from the one presently stated in the description. (I would also strongly suggest to annotate the wmb() with an explanatory comment.) > @@ -189,6 +192,8 @@ static void cf_check aplic_irq_disable(struct irq_desc *desc) > /* Disable interrupt in IMSIC */ > imsic_irq_disable(desc->irq); > > + desc->status |= IRQ_DISABLED; > + > spin_unlock(&aplic.lock); > } The ->status write becoming globally visible ahead of imsic_irq_disable() doing its work is not an issue? In the paragraph in the description you again appear to assume that the CSR write and the memory write of the spin-unlock are ordered wrt one another. > --- a/xen/arch/riscv/irq.c > +++ b/xen/arch/riscv/irq.c > @@ -145,9 +145,6 @@ int setup_irq(unsigned int irq, unsigned int irqflags, struct irqaction *new) > desc->handler->set_affinity(desc, cpumask_of(smp_processor_id())); > > desc->handler->startup(desc); > - > - /* Enable irq */ > - desc->status &= ~IRQ_DISABLED; > } Arm and x86 are different in this regard, so it's hard to tell which way it ought to be for RISC-V. This removal surely wants a sentence or two in the description. Jan