From nobody Fri Oct 31 03:46:07 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=1756764662; cv=none; d=zohomail.com; s=zohoarc; b=ZUNihgyP/PkKnXhGwFcyLAIq+vv2ASd3mVDUzL8kFILFsAuqHW4BDxOsAHFEEemID9Lkb+6smoUhdiECPfrZJhbAQxTeZ9cTmAmneV3oYvvPVDORkiwx4ab4Mei3YKtClxmRkqYutY06TOgvG1QVOm9xCLaAY8aeWk/4NE6ZgrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756764662; 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=7jLnGK/W9IzxOZ6CLKOO5BPor3o3fyjNQvRa1agLv/o=; b=MsFZY4A6XpaKE2QCG9qtiJizMiYXRFxNL6g76yl6IWQ0mwxOirnOIDCNMzQBocwjy6Dl5yFW/XNEPa4qNMpu4BBAcVDWKoOVA2s1QhTslJ8TAZR9wjzO9wVIsDY4YAAGx+ciI3aMmqVWsPL3SHejbSDXd56+ZDP5SiiWk9gn2Cs= 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 1756764662559437.7836381035529; Mon, 1 Sep 2025 15:11:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1105412.1456437 (Exim 4.92) (envelope-from ) id 1utCjZ-0008Qe-Gc; Mon, 01 Sep 2025 22:10:41 +0000 Received: by outflank-mailman (output) from mailman id 1105412.1456437; Mon, 01 Sep 2025 22:10: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 1utCjZ-0008Pb-9K; Mon, 01 Sep 2025 22:10:41 +0000 Received: by outflank-mailman (input) for mailman id 1105412; Mon, 01 Sep 2025 22:10:39 +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 1utCjX-00055o-TK for xen-devel@lists.xenproject.org; Mon, 01 Sep 2025 22:10:39 +0000 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [2a00:1450:4864:20::12b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7d232868-8780-11f0-8dd7-1b34d833f44b; Tue, 02 Sep 2025 00:10:37 +0200 (CEST) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-55f69cf4b77so3061906e87.2 for ; Mon, 01 Sep 2025 15:10:37 -0700 (PDT) Received: from yp-VivoBook-ASUSLaptop-M1503QA-M1503QA.. ([95.67.15.120]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5608279307asm123038e87.75.2025.09.01.15.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Sep 2025 15:10:36 -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: 7d232868-8780-11f0-8dd7-1b34d833f44b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756764637; x=1757369437; 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=7jLnGK/W9IzxOZ6CLKOO5BPor3o3fyjNQvRa1agLv/o=; b=iTP2GJ/agVaLRIl9CbyxtbmKv9vK0Kmfc0vQvD9UJJ+VsWHnwm0C91teejA5069jbj lvFqrgdbERgifdjCWjURa5l9Bu8c9emdO4e8DqxZj/ebimOAlGs4BZfd5yFcFhvquTeq 3WEwZw9jewRdjaDmWlnViXn/8J7ukMTjdNha7uVsH2IPYGmmWmbyfOIJmcaLwd3ZFrBu D/00UtgdFwaF+rNmxT0mDBvPftWN4BWm4PH+wJadGkCpR+z2S3Jk+1j7lpNbf43tAw5D oTMCxYXZacmJUr+LstIXKxlSy7FlwXJczRaazLnvNJdP04Y/B1SLm12N05aetx+kk1Ul fL2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756764637; x=1757369437; 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=7jLnGK/W9IzxOZ6CLKOO5BPor3o3fyjNQvRa1agLv/o=; b=Kl6XnjXUI5L8r90NrRQ6pL1FYqA9VjslaIcnFvcd+wC8o9gGLZEe/FJ0cHe/za5YHG +O864eobkRAnUpfO1ym45/ZAuwi0/FaYxXtFK+I+mkrztqMa3AL8iAV7VMNt35OSnMPp Ry/YbM7saD1Ns1eW3j4lMLJnxnw9Y8Ji6Tyf33pHCAqlEEz/uOeGV4XvY+KKp6vB3TeR Dd6e6vf1OJtgVUGIVGgmWS7ZMVMuE53iw4O2KTUIzEG/I7B+Iaozo4tYgSIZWVXnE2Vo CcBl3a1d8j4d8hnAvL7/SScYfFGOSYQgaNSsUYBIEhTB3bYgPeJHCtzL1REO22f4WBhb uFhg== X-Gm-Message-State: AOJu0Yx7K6ZRTJAE2/O1XtvM83f05XC1xVpsDmedUEbd0E0wWaorTb3a pGesJ2r/BX7HGZ0n1i6LQdF9Gfkh0mGmuH5wwfycrQKKgN4gZz4FArsxL7nnyiTS X-Gm-Gg: ASbGnct64cGiOEmevkj+8JPF/y1Zve+X5FLAzDZ2VjPvBHf8PxHlAKXg/uoJtNBuHCf Z28SAmUyv5sDYQjdNzuJOaWqnJnSGkfDOgCcPo8QWEBXx/dCdsm9eGMgkZJD9z+OTunwz4Qmv8i Ew1GmlKramjC2vUOe2hMo9n5pCHVhxnMvfaZ6egEettEf48Jt+9I+JaAXyj+fjnMtroKISWA5si WdKWQMznb/eJAs0vV9mYyOez/H6NWAnC2ZWoqD4JvnqenRSwiTXXB1O12camonfEZ3Hiec7n/Y2 MppBAalrq4m39+HD0PlQmDuGPnJKzGU7daSBslhCnvQlglIxr/yZoAyd8gEgV0+D1+oj9xAnvBg NSZJkkmlotKRwVF5qEoOKGv6mQ5n4vNoXeEKcHAw8RX8k6PvDQ0YtVWjkzaLZnQ== X-Google-Smtp-Source: AGHT+IGXdEdoSAzn5JEBY3rqDuehu56DiyGTfp49x/4lqJkOcHbolBJuNKUoq29Yojmc/eQDmAjVSQ== X-Received: by 2002:a05:6512:3c97:b0:55f:6a49:6e71 with SMTP id 2adb3069b0e04-55f708ecdadmr2606498e87.29.1756764636522; Mon, 01 Sep 2025 15:10:36 -0700 (PDT) From: Mykola Kvach To: xen-devel@lists.xenproject.org Cc: Oleksandr Tyshchenko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Rahul Singh , Mykola Kvach Subject: [PATCH v6 12/13] xen/arm: Suspend/resume IOMMU on Xen suspend/resume Date: Tue, 2 Sep 2025 01:10:16 +0300 Message-ID: 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: 1756764664679116600 Content-Type: text/plain; charset="utf-8" From: Oleksandr Tyshchenko This is done using generic iommu_suspend/resume functions that cause IOMMU driver specific suspend/resume handlers to be called for enabled IOMMU (if one has suspend/resume driver handlers implemented). Signed-off-by: Oleksandr Tyshchenko Signed-off-by: Mykola Kvach Reviewed-by: Volodymyr Babchuk --- Changes in V6: - Drop iommu_enabled check from host system suspend. --- xen/arch/arm/suspend.c | 11 +++++++++++ xen/drivers/passthrough/arm/smmu-v3.c | 10 ++++++++++ xen/drivers/passthrough/arm/smmu.c | 10 ++++++++++ 3 files changed, 31 insertions(+) diff --git a/xen/arch/arm/suspend.c b/xen/arch/arm/suspend.c index 35b20581f1..f3a3b831c5 100644 --- a/xen/arch/arm/suspend.c +++ b/xen/arch/arm/suspend.c @@ -5,6 +5,7 @@ =20 #include #include +#include #include #include #include @@ -62,6 +63,13 @@ static void cf_check system_suspend(void *data) =20 time_suspend(); =20 + status =3D iommu_suspend(); + if ( status ) + { + system_state =3D SYS_STATE_resume; + goto resume_time; + } + console_start_sync(); status =3D console_suspend(); if ( status ) @@ -118,6 +126,9 @@ static void cf_check system_suspend(void *data) console_resume(); console_end_sync(); =20 + iommu_resume(); + + resume_time: time_resume(); =20 resume_nonboot_cpus: diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthroug= h/arm/smmu-v3.c index 81071f4018..f887faf7dc 100644 --- a/xen/drivers/passthrough/arm/smmu-v3.c +++ b/xen/drivers/passthrough/arm/smmu-v3.c @@ -2854,6 +2854,13 @@ static void arm_smmu_iommu_xen_domain_teardown(struc= t domain *d) xfree(xen_domain); } =20 +#ifdef CONFIG_SYSTEM_SUSPEND +static int arm_smmu_suspend(void) +{ + return -ENOSYS; +} +#endif + static const struct iommu_ops arm_smmu_iommu_ops =3D { .page_sizes =3D PAGE_SIZE_4K, .init =3D arm_smmu_iommu_xen_domain_init, @@ -2866,6 +2873,9 @@ static const struct iommu_ops arm_smmu_iommu_ops =3D { .unmap_page =3D arm_iommu_unmap_page, .dt_xlate =3D arm_smmu_dt_xlate, .add_device =3D arm_smmu_add_device, +#ifdef CONFIG_SYSTEM_SUSPEND + .suspend =3D arm_smmu_suspend, +#endif }; =20 static __init int arm_smmu_dt_init(struct dt_device_node *dev, diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/a= rm/smmu.c index 22d306d0cb..45f29ef8ec 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -2947,6 +2947,13 @@ static void arm_smmu_iommu_domain_teardown(struct do= main *d) xfree(xen_domain); } =20 +#ifdef CONFIG_SYSTEM_SUSPEND +static int arm_smmu_suspend(void) +{ + return -ENOSYS; +} +#endif + static const struct iommu_ops arm_smmu_iommu_ops =3D { .page_sizes =3D PAGE_SIZE_4K, .init =3D arm_smmu_iommu_domain_init, @@ -2960,6 +2967,9 @@ static const struct iommu_ops arm_smmu_iommu_ops =3D { .map_page =3D arm_iommu_map_page, .unmap_page =3D arm_iommu_unmap_page, .dt_xlate =3D arm_smmu_dt_xlate_generic, +#ifdef CONFIG_SYSTEM_SUSPEND + .suspend =3D arm_smmu_suspend, +#endif }; =20 static struct arm_smmu_device *find_smmu(const struct device *dev) --=20 2.48.1