From nobody Fri Dec 19 21:00:36 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=1748855121; cv=none; d=zohomail.com; s=zohoarc; b=O3JT/qTclq5svhra8EoJXWv8qoi2IhQl+Wv2wntaIEG3tFGbITyjgnayQOOMnjyKMltXmiN5Vsh6vZoqK0C7odN7LlIGLD0O9hRrY0MIs9AKMeDcHuhtbeOqgJ+VxOH9P8J9d8eNr7QhOkeBBayjea6AOCDvnRpJVO/PK1TwMCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748855121; 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=gLtZvLmNS5IQ5nQywV+KESH/yusLqzvm5c+C1sq8VQE=; b=gk6Am77yMUkCggsOIFHT6DTBVA1/8NmdOhCCIJUNznBoF3IPTu7R6cjRUa/0tW1CwM19bQJKM5SlxcUIpg2Eq9l+Sllg+/OYs5htv3f6j3hGLQHITwtHPQZn6/KSBMRci9tw5e+UNmjjOOKnc0IlVRX2TCo4LKlfzGJKsDupOC0= 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 1748855121080536.468507501727; Mon, 2 Jun 2025 02:05:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1002947.1382417 (Exim 4.92) (envelope-from ) id 1uM16M-0000yj-4j; Mon, 02 Jun 2025 09:05:02 +0000 Received: by outflank-mailman (output) from mailman id 1002947.1382417; Mon, 02 Jun 2025 09:05:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uM16L-0000xn-Vx; Mon, 02 Jun 2025 09:05:01 +0000 Received: by outflank-mailman (input) for mailman id 1002947; Mon, 02 Jun 2025 09:05:01 +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 1uM16L-0007kh-6a for xen-devel@lists.xenproject.org; Mon, 02 Jun 2025 09:05:01 +0000 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [2a00:1450:4864:20::135]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a94a2ed8-3f90-11f0-b894-0df219b8e170; Mon, 02 Jun 2025 11:04:59 +0200 (CEST) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-55220699ba8so5134319e87.2 for ; Mon, 02 Jun 2025 02:04:59 -0700 (PDT) Received: from yp-VivoBook-ASUSLaptop-M1503QA-M1503QA.. ([95.67.15.120]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5533791cdc3sm1507541e87.176.2025.06.02.02.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jun 2025 02:04:58 -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: a94a2ed8-3f90-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748855099; x=1749459899; 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=gLtZvLmNS5IQ5nQywV+KESH/yusLqzvm5c+C1sq8VQE=; b=ZI6qqWrhzS7h7+3frDr+CYM7CAaAxcp4CfwrFfUakAtDva5BHNjlh50FLoTRLHQzMG wkyTjMl6cGeMxW1njm/PKcDpProuJEa1FcVX4CKQm77WOOQ0zOiKovwzV/Bn3NfSWYuM 6VGwUp54NsmO5F00OPe70O6jaN5A5dc3Kui6DKfPhfEHaUe+/8ZEEJDRXcdfAq69GTDs am2NkT2GHzQ20nKI/Po+4nwKkjct1dsflb6o1WYG4b5haWuNxkGC2gvArCYTIRYQ11Ny ncVhpUFEOabhO5kabtZHggfPR7+CVK/nCk7pI5eIrWe/X73gz8+9Qc0Wnm4DGF2Jb3C4 eI/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748855099; x=1749459899; 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=gLtZvLmNS5IQ5nQywV+KESH/yusLqzvm5c+C1sq8VQE=; b=r8RfCvmE/GB7aO1FXW4s5ErzP5KW47yHxb2kofW8Gy3IHwSv5adWvZRhpXsYT9mRcn 2uPEeyQhki/gb52g8UMTOtY0fq17TGEmI1iN62C0TTc0hEyEs2ZlSELBwQlir8FwPAv2 WservR/cXepMdCYw/6shY6Z3+X+r8mGUY3yyg/XievJAoJAfWRDWEOZv0QfrQ4B2sbzE RrdMxjIcKbLiZ7ysRK6WCIQ3PNUewSio4XFpLL68wr6XCQ2Akm+mg8oBBoPo0t9oKvf3 dcG1+AFDtiNAXBPiYPshbg0Fa2vmbihCccW40RI8i3SfoOtAYR6fqmjrb1EjmDLLAcSV 629Q== X-Gm-Message-State: AOJu0YwUx+DzBVvTQ6SPf1iAMQ9CrKprQZFgbxXut4IYnIxkIeP4q/9i zhuzoY3fzxvn0SS+oKtTW1uYwCzpiHier03NooYrWjj0fhYMMxE6Zye9IZg0ReRw X-Gm-Gg: ASbGnctnsjJp8ZuBCj3jQ7PgBsT2U6izBiVKLl1BfpXomkDGTHYo8LaYDfKtqAwm3vW JY/68jokWsaB2vyiLVVRy0gJEvOAaTHrGk3J3IGyki85N+ftLn5XLrPtnTUF+90jYUotMi5ZWjE /jTCe03JwsriFe+f+dIm3A2b+7pFRWh9Knnue1SP3Uovj7Io9UXwRWCrNrLT+o2Tdz7z3/tsOdX YP9aSJX0PW4z1FE8KppwxX/EO5bXBvipEL6HvSfDsi23XTUaFNsu2tJSAG0NzkVz48iAjrIZhZI uRKjFgffRuqInV7K7FqUJYccdK0829eR2w04PQMI580qyS5nG5rW/6WZOJw/V2I9+DPODgjFFjZ sEJThol4GB/s98KPz4HFK+NvBIw== X-Google-Smtp-Source: AGHT+IEvX585OOmt7ZiEiMyg7i6PA8bef54WnayP0mdDtUFr/dnbjwdOuWJmj0LjXKmXClWMsr03gg== X-Received: by 2002:a05:6512:3d13:b0:550:e5c4:b0a1 with SMTP id 2adb3069b0e04-5533d13e73dmr2804533e87.11.1748855098750; Mon, 02 Jun 2025 02:04:58 -0700 (PDT) From: Mykola Kvach To: xen-devel@lists.xenproject.org Cc: xakep.amatop@gmail.com, Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v4][PART 2 06/10] xen/arm: irq: Restore state of local IRQs during system resume Date: Mon, 2 Jun 2025 12:04:17 +0300 Message-ID: <8cbea1b2335ba0f2ea189c653c62bd591882b295.1748848482.git.mykola_kvach@epam.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1748855122012116600 Content-Type: text/plain; charset="utf-8" From: Mykola Kvach On ARM, the first 32 interrupts (SGIs and PPIs) are banked per-CPU and not restored by gic_resume (for secondary cpus). This patch introduces restore_local_irqs_on_resume, a function that restores the state of local interrupts on the target CPU during system resume. It iterates over all local IRQs and re-enables those that were not disabled, reprogramming their routing and affinity accordingly. The function is invoked from start_secondary, ensuring that local IRQ state is restored early during CPU bring-up after suspend. Signed-off-by: Mykola Kvach --- xen/arch/arm/irq.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 372716a73b..f32f8b56ca 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -113,6 +113,47 @@ static int init_local_irq_data(unsigned int cpu) return 0; } =20 +/* + * The first 32 interrupts (PPIs and SGIs) are per-CPU, + * so call this function on the target CPU to restore them. + * + * SPIs are restored via gic_resume. + */ +static void restore_local_irqs_on_resume(void) +{ + int irq; + + if ( system_state !=3D SYS_STATE_resume ) + return; + + spin_lock(&local_irqs_type_lock); + + for ( irq =3D 0; irq < NR_LOCAL_IRQS; irq++ ) + { + struct irq_desc *desc =3D irq_to_desc(irq); + + spin_lock(&desc->lock); + + if ( test_bit(_IRQ_DISABLED, &desc->status) ) + { + spin_unlock(&desc->lock); + continue; + } + + /* it is needed to avoid asserts in below calls */ + set_bit(_IRQ_DISABLED, &desc->status); + + gic_route_irq_to_xen(desc, GIC_PRI_IRQ); + + /* _IRQ_DISABLED is cleared by below call */ + desc->handler->startup(desc); + + spin_unlock(&desc->lock); + } + + spin_unlock(&local_irqs_type_lock); +} + static int cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -131,6 +172,9 @@ static int cpu_callback(struct notifier_block *nfb, uns= igned long action, printk(XENLOG_ERR "Unable to allocate local IRQ for CPU%u\n", cpu); break; + case CPU_STARTING: + restore_local_irqs_on_resume(); + break; } =20 return notifier_from_errno(rc); --=20 2.48.1