Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2144423lqp; Sun, 24 Mar 2024 05:21:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUJUc9yNXe0uv5CL54Zmg7qZRERE0zHTAt2amVdUwrMvpaUtqNKqE+5sZJe1qDM1UFEyin92CcIIttnJFcZ1IrcDsabijbtWZsF+1ajjw== X-Google-Smtp-Source: AGHT+IEmJLhCpWXCc+QF5OTbycT4dAHdO66QRpaOFlqYKzMHAALiXJtIetCj9/VS/fNDrXWRqML9 X-Received: by 2002:a05:6808:219c:b0:3c3:8540:8641 with SMTP id be28-20020a056808219c00b003c385408641mr5914331oib.9.1711282900682; Sun, 24 Mar 2024 05:21:40 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t14-20020a05622a180e00b00431324fd54csi3241162qtc.519.2024.03.24.05.21.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 05:21:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112667-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=VdyJAsNv; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-112667-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112667-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 460481C20D58 for ; Sun, 24 Mar 2024 12:21:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D42818627; Sun, 24 Mar 2024 12:21:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="VdyJAsNv" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2043.outbound.protection.outlook.com [40.107.20.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2907F179BE for ; Sun, 24 Mar 2024 12:20:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.43 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711282861; cv=fail; b=mqTlglUwfDMJH7nxBpSDnRfUrXjP/moQrVWqHlUvZLswz9tJBeLV/OZupA1GLrUNjvXdEpmSUcfUU5myJHmWqxoovlp2CXMZHQukIV6lNOOO/xcoJrXp0U7iTPKwIsMOOIOzhXBeI7729aYmS0VXkN7lKQ2k5tb+i/Z844rD50g= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711282861; c=relaxed/simple; bh=GoSpC7n6WXnV2T/mfHSFPDuzbn5LxmE/urmN3js0sCg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=kN3LKLD11vNKeDnhWiU3+4x/g6QhHixHwBLiYZeB4NXr3s0UiueBDBpIf8YDBnLNEcY7v/d/DuDsaaDqeMkoHzK4mZhndipg0+Azt1ULvTM50HFaroW5Vspcw6Efmav69he1ygQ+CXAEBFoubIr5tg1i9f12oVC1ZIIxhxQ3ZIs= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=VdyJAsNv; arc=fail smtp.client-ip=40.107.20.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TLb3H0vDf3V0thM6p380iCjhw6zJT6RQ2VC1oZTC9HwyJ8d5QiONn2Oi1VtaYvLgsDU83Y81mxpgYTcc635meQHzh5cufb4RvNnBhPs9JbmKXKheyuoA1OaIo9FrPIxZon71etM6mixeCvcYH4krHvTLdDAswqwtg9nwXZHvoJm4sNDObj0C3Ajysm40u3vf5QLI396Yns5r/DEJ5jUPPS/5LdHXIXlberbsCnLcm3ayPmolpUdYZ6oiX7bI0M6CNtEGghCVdRK4VmSFKY5tfZSrkM69QKxyi/jpP0S2Qc7hRsK5hpZfQw47NF8/v09MJ787gyKi7fYjlo4XVWBtwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qSBBP8CdkRt26BWQnEn0Twnx5706NESRFGp7EcaHaUU=; b=itQGpBekUwekhdfcuY/Z0S8L79SKdJQx5cbDM+L+Gychuk64U929lg5fpvL+HmejXLj2EQMWhetx0btSZZRnpAL+RANEiICepk0QaXG5IEVVBTMU4+YKOWhVsOelV4h2Tj9Hnnl3kgMSo1SIyQ32BWad67I+b44iKheTgZH2Q4RwxyPfuQQOXc7H1mWAq+nmlMFpFfBnBPo3U2qBZcw03tbPpR4UHIynDJAha2+Z6Xc1rFbxRfOGs82jKhoS5UZ8b8v9duDS+cYgjyqnElVKG/YPQPGLxGGyMFb6VUsiEy0JwQlpQ5jPtJgfSwI5LZfE8s9dvA/S8yRhpgEG9/bXog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qSBBP8CdkRt26BWQnEn0Twnx5706NESRFGp7EcaHaUU=; b=VdyJAsNvtnZipZdR/9LnxouoYjStzer8lMGCaGkXnUvEnCc+aTuGLwK72z3ltJ1nEcuFKYU4udwhpKUNbgGx3rtwEy4WIrOIIHuRBkQl6jfvW30yLnvuI2hBGD+tiftl9vpXvZuPzk7WONOXqZv5RndhikbDyyJItgSu6kH7InU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by GVXPR04MB9901.eurprd04.prod.outlook.com (2603:10a6:150:113::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.30; Sun, 24 Mar 2024 12:20:57 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7386.037; Sun, 24 Mar 2024 12:20:57 +0000 From: "Peng Fan (OSS)" Date: Sun, 24 Mar 2024 20:29:00 +0800 Subject: [PATCH 3/3] iommu/arm-smmu-v3: support suspend/resume Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240324-smmu-v3-v1-3-11bc96e156a5@nxp.com> References: <20240324-smmu-v3-v1-0-11bc96e156a5@nxp.com> In-Reply-To: <20240324-smmu-v3-v1-0-11bc96e156a5@nxp.com> To: Will Deacon , Robin Murphy , Joerg Roedel , Thomas Gleixner , Marc Zyngier Cc: Bixuan Cui , linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1711283345; l=4688; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=GiSd4PlTexX48iZrMpUZF0JbBWkoDDMT3nVKob6ALg0=; b=Qw1qNbRzkiQXnGwnSyX4pIUbPqNQ+Aqr0AQUC1bi66PWMtK0gor0N4PGwcC4SOnugOY6F4ikt w95Ia4FqP/ZAr5L4tw8jvUhfY9eLH6pR31cONXOtIWJhWquCksA4kjg X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:4:191::19) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|GVXPR04MB9901:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c4dc8a9-8c4c-418d-92d6-08dc4bfcdbee X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qbSN8UJVE/j0W3BcbLbZzXAMmXmn0i+6BuhfLJxNNiB0tFftNS3BLRVChqFTQOq8LFO3Fo71ddekqFRXhkTK8jn2qdCZhpzGktGhQHqkmt3m+DzWodh0gO3VsBHhdWqjks5+J0ZWYnzghW6ZuVvkojVEoIxRGCKUEFxXt7toFf0VxAMGRx8Ekx3sDB8rnTFuAIYTvbSDh5E0OHMTl5LpmU4aK0O8WDQqI7hiEVwxEWVvpzg0uY/65b46JQi0nA2ibUtnAVPYNrdCcnOOYwI1ApwbgeFQjRyzA9r/EIjLosDTD6pTTdHhasO3ryJ2Jv55sLy7g3BHd3+CWWgWkCZFxeI2WusaA8Sja7RUwT99e5r8LaAp1u8SW9JeBBfxkw+TAN+3Wb+46cbqjWehc7owVMhFT5qeo5Ino3xECsCUUKBlcAXXvNhG+PMeHgrCGu7uHNyzAAWG8zk74k7JBW5c+xjIc1QlObw50pxnKK15NkGPEPfgDxevywbSM/qSRetrDeONe+9s5ReqfWUkDThGqiO3ej0kbWwuXD0QAUyh149Wnr5N6PgspgbedS0noNbOIame82E3HlzPUv1PstFQ2HIk/HtQoy74fQEiDiIiI1jiw9DizY+6kYW1taKEdGN9AHZchbkRo0mRfcKTGqX3omlZdqZJzlrk5anwrYKG2VcD32aFcftePWOH4iiKGE11ScEX7Gi8rhAwWZduRBkR9g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(52116005)(1800799015)(376005)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?L3hzMmRNQTNhUkRlMUFhS1IyalNxVnN2OVhQMGplMzJUYzN3RStWdXZwaEZL?= =?utf-8?B?YTF0M2Q2bHFDQzdDSFpkcUZVZVNOUFQ1UmY5Mm5ZL041emd2WHA4Y2w1ZkI4?= =?utf-8?B?b204YmlxelVtMVFDbEtvTjBKL29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= =?utf-8?B?ZFJwb3RTVCswZWQvRC83YzdoTEhWczF5N3VKQ001VFp2WDJsWkVGRnpBTGJi?= =?utf-8?B?blhUYko4K0ovQ2pyQSswRHg1VVZpR21KMHpLa1dUTmViZ1VYSnVpeWFYTnhP?= =?utf-8?B?S1dtWEJCUGNyWXFyVmNSeUoxeHQxRDE4V1RUbVNENEg1NTVJbUd6enhvZlgv?= =?utf-8?Q?PMzagKaXvD3NZ0ujysUSuOJL9?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c4dc8a9-8c4c-418d-92d6-08dc4bfcdbee X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2024 12:20:57.4250 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: s9/e38xJbknM2qqmXUpu0i/uYfs9dzOI0vXhCzH/hX3alae8DbLEMZOX1JWka3ccylgXJzjIIbl3q1BKjEIsGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB9901 From: Peng Fan smmu maybe power-gated, and the registers are cleared. So need to restore its registers with arm_smmu_device_reset and resume the msi interrupt settings in resume callback. Signed-off-by: Peng Fan --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 71 ++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index a8a569573c2f..2bfe4b3d0ba1 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3396,6 +3396,36 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu) devm_add_action(dev, arm_smmu_free_msis, dev); } +static void arm_smmu_resume_unique_irqs(struct arm_smmu_device *smmu) +{ + struct device *dev = smmu->dev; + struct msi_desc *desc; + struct msi_msg msg; + + if (!dev->msi.domain) + return; + + desc = irq_get_msi_desc(smmu->evtq.q.irq); + if (desc) { + get_cached_msi_msg(smmu->evtq.q.irq, &msg); + arm_smmu_write_msi_msg(desc, &msg); + } + + desc = irq_get_msi_desc(smmu->gerr_irq); + if (desc) { + get_cached_msi_msg(smmu->gerr_irq, &msg); + arm_smmu_write_msi_msg(desc, &msg); + } + + if (smmu->features & ARM_SMMU_FEAT_PRI) { + desc = irq_get_msi_desc(smmu->priq.q.irq); + if (desc) { + get_cached_msi_msg(smmu->priq.q.irq, &msg); + arm_smmu_write_msi_msg(desc, &msg); + } + } +} + static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu) { int irq, ret; @@ -3442,7 +3472,7 @@ static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu) } } -static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) +static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu, bool resume) { int ret, irq; u32 irqen_flags = IRQ_CTRL_EVTQ_IRQEN | IRQ_CTRL_GERROR_IRQEN; @@ -3456,7 +3486,7 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) } irq = smmu->combined_irq; - if (irq) { + if (irq && !resume) { /* * Cavium ThunderX2 implementation doesn't support unique irq * lines. Use a single irq line for all the SMMUv3 interrupts. @@ -3468,8 +3498,12 @@ static int arm_smmu_setup_irqs(struct arm_smmu_device *smmu) "arm-smmu-v3-combined-irq", smmu); if (ret < 0) dev_warn(smmu->dev, "failed to enable combined irq\n"); - } else - arm_smmu_setup_unique_irqs(smmu); + } else { + if (resume) + arm_smmu_resume_unique_irqs(smmu); + else + arm_smmu_setup_unique_irqs(smmu); + } if (smmu->features & ARM_SMMU_FEAT_PRI) irqen_flags |= IRQ_CTRL_PRIQ_IRQEN; @@ -3494,7 +3528,7 @@ static int arm_smmu_device_disable(struct arm_smmu_device *smmu) return ret; } -static int arm_smmu_device_reset(struct arm_smmu_device *smmu) +static int arm_smmu_device_reset(struct arm_smmu_device *smmu, bool resume) { int ret; u32 reg, enables; @@ -3602,7 +3636,7 @@ static int arm_smmu_device_reset(struct arm_smmu_device *smmu) } } - ret = arm_smmu_setup_irqs(smmu); + ret = arm_smmu_setup_irqs(smmu, resume); if (ret) { dev_err(smmu->dev, "failed to setup irqs\n"); return ret; @@ -4086,7 +4120,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev) arm_smmu_rmr_install_bypass_ste(smmu); /* Reset the device */ - ret = arm_smmu_device_reset(smmu); + ret = arm_smmu_device_reset(smmu, false); if (ret) return ret; @@ -4124,12 +4158,34 @@ static void arm_smmu_device_shutdown(struct platform_device *pdev) arm_smmu_device_disable(smmu); } +static int __maybe_unused arm_smmu_suspend(struct device *dev) +{ + struct arm_smmu_device *smmu = dev_get_drvdata(dev); + + arm_smmu_device_disable(smmu); + + return 0; +} + +static int __maybe_unused arm_smmu_resume(struct device *dev) +{ + struct arm_smmu_device *smmu = dev_get_drvdata(dev); + + arm_smmu_device_reset(smmu, true); + + return 0; +} + static const struct of_device_id arm_smmu_of_match[] = { { .compatible = "arm,smmu-v3", }, { }, }; MODULE_DEVICE_TABLE(of, arm_smmu_of_match); +static const struct dev_pm_ops arm_smmu_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(arm_smmu_suspend, arm_smmu_resume) +}; + static void arm_smmu_driver_unregister(struct platform_driver *drv) { arm_smmu_sva_notifier_synchronize(); @@ -4141,6 +4197,7 @@ static struct platform_driver arm_smmu_driver = { .name = "arm-smmu-v3", .of_match_table = arm_smmu_of_match, .suppress_bind_attrs = true, + .pm = &arm_smmu_pm_ops, }, .probe = arm_smmu_device_probe, .remove_new = arm_smmu_device_remove, -- 2.37.1