Message ID | 20231011-msm8953-iommu-restore-v1-1-48a0c93809a2@z3ntu.xyz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp716485vqb; Wed, 11 Oct 2023 10:57:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVAbeJm/ze4EVVzqegYN1AUsJ7PCXOLhZksn/aCyDlxuSSkWJwl3LeMQZw79sw5Hcsnn2h X-Received: by 2002:a05:6a20:3d85:b0:163:f945:42c4 with SMTP id s5-20020a056a203d8500b00163f94542c4mr25349168pzi.1.1697047074114; Wed, 11 Oct 2023 10:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697047074; cv=none; d=google.com; s=arc-20160816; b=RfLuA5UtpdZBP12Avopcw9h83BKGVphD5H/NF7kMqpZ9AXLWRjzSBO4aCoHCE0Ed0M XUhLAJLlS/74KAmludqyoq8la+MwUR2SLmjH201vEMJyHrHCa81H8Jos3RFYlXJHgkbA 53QCHW5ra0V1w9eY1slcKuVMwE3VUFMYZSi9AYfmLSRiRr80b31jOGfbvBp93L3KyCt1 XP9cfuHSQxuF8pYMeELZrD/JFF/EMjEujJHsbCbG3+b5D4Sd9N/TD8k3m2FT0irP9QVj sXc9lPw6Kvgwk+d89hurULTH+93YD7UCFZTouygScXy3N8R7aRLOF0ar0fmK/Db2mHmu CCbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=kLjzZxN8MG//Q26pvIqeBd+N3J1SoycJ3JFSHdxe9TQ=; fh=bQI+DdMx7GC4Pb791t7Uu46C9PTfyL4AjuUCC5yWBvQ=; b=l9PrjtHauhgz7CPtCZwqaqBKd8XR/aha6vJfcx/IX1R77sek8f4MroyWwQa+k8xvTh fPUTmtczpvuXsWcAEWqBDGXO+4jwo+q9gBdEAxa3B5IXBQ2j/Hd7t+DNmRjWTb/8Zp6B B7H90sqg7n0H1ViwhcGFCsUs2+Q/IugiquJ46EEi9XwG+FarL3HCuKm54o68inL2j5+X +pVgKzGdPQ2WI1FXdWp7P9JJVT/w29OEHRAOiRuzZyLZhuoFLM/AQXiq6uKJ9y+9zULz 5Vhx/yjvYwseO5imR59/ee/1oMa0v+ZaIgUFIdM00JBcCWzteYKF3oWL4gMFo9txE9QF M7OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@z3ntu.xyz header.s=z3ntu header.b=kLRSZ4cv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id r34-20020a634422000000b00584e05f62e1si264985pga.297.2023.10.11.10.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 10:57:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@z3ntu.xyz header.s=z3ntu header.b=kLRSZ4cv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=z3ntu.xyz Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 591388078C9A; Wed, 11 Oct 2023 10:57:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233045AbjJKR5i (ORCPT <rfc822;kartikey406@gmail.com> + 18 others); Wed, 11 Oct 2023 13:57:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbjJKR5h (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 11 Oct 2023 13:57:37 -0400 Received: from mail.z3ntu.xyz (mail.z3ntu.xyz [128.199.32.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7597E8F; Wed, 11 Oct 2023 10:57:35 -0700 (PDT) Received: from [192.168.178.23] (k10064.upc-k.chello.nl [62.108.10.64]) by mail.z3ntu.xyz (Postfix) with ESMTPSA id 80CDBC639E; Wed, 11 Oct 2023 17:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=z3ntu.xyz; s=z3ntu; t=1697047053; bh=fz91rxvql77qr9tMmn1NOBTiPcKPztIjFo5x3BgCYa0=; h=From:Date:Subject:To:Cc; b=kLRSZ4cvQ+/OfOwa9s6WqbjXcAx1pYKF5pYS0O/hb0MV7YGMz+rlqExYqw6JIuWTN UUy8DLgQI5pDlNAj9bTHZEjcvjcJykhFE821q3paKqR58k3sSvqaWRGEWKlT8lNEhj DmJLJsP7OurtMLMrZSH2092cBwQL49F3gxu7lfu0= From: Luca Weiss <luca@z3ntu.xyz> Date: Wed, 11 Oct 2023 19:57:26 +0200 Subject: [PATCH] iommu/qcom: restore IOMMU state if needed MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231011-msm8953-iommu-restore-v1-1-48a0c93809a2@z3ntu.xyz> X-B4-Tracking: v=1; b=H4sIAAXiJmUC/x3MQQ6CQAxG4auQrm1CZ0IAr2JcIPyjXQxjWjEmh Ls7Yfkt3tvJYQqna7OT4auuZa2QS0Pza1qfYF2qKbQhSivC2fMwdpG15LyxwT/FwGl6zAFREtB Tbd+GpL/ze7sfxx8DsOMqZwAAAA== To: ~postmarketos/upstreaming@lists.sr.ht, phone-devel@vger.kernel.org, Rob Clark <robdclark@gmail.com>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, Joerg Roedel <joro@8bytes.org> Cc: iommu@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Vladimir Lypak <vladimir.lypak@gmail.com>, Luca Weiss <luca@z3ntu.xyz> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1945; i=luca@z3ntu.xyz; h=from:subject:message-id; bh=7t+7cwQLSRo2oYCkBswJGXelQGziACs1O48hSiYmsM4=; b=owEBbQKS/ZANAwAIAXLYQ7idTddWAcsmYgBlJuIMkTrnEcWE4KqdSmG3hMW26WWFXTvQfrfvu gizQyswB0CJAjMEAAEIAB0WIQQ5utIvCCzakboVj/py2EO4nU3XVgUCZSbiDAAKCRBy2EO4nU3X Vp2jD/oCIiYMI9Gil0+BaHzQDQWzcmZEdryBvCxe7aC8GDfuoj5QkCU2sluK7/LkrEVa0MV+nMA bmixiWu/ZKR7ZtvUk/8WSMGiqLAUNSNz1Ds5SsOwbrWuXhI///gNtZvJgv9WxZyVUt7Q2Jh4qiy ddlKvO3T+9KwGZMNYj5/vopBweXe7ezmB07/JQMj4vbgpPzsDbxzTNl9WHHs5c1wlTmAK/w9laE xMybXFkTZhMzH4IRJoRIrq09WDWf6c5CzSR0fuCftbsyagRDImLlDhzjDUMz96mxOx0qizBiVlS tUMjnWqm7TgOIXFdug3zAo1+SLHlRnhGE+Y/zG2ObdltYKVhQ86RUcNlRh/HId3pdsr+4yjQ37n jRAKIeD0IYkJZihKDsiPqwHhf6IaARmpfVeafrcFFpmnfNNh2qXIkJZF8A6qc/oIg3t3Fg54ZY5 sSohEVTxoK9vlVmkuaHGahcMEIQHvg76KyLhIIdjn9cZSGEtuo/ooy4UwduZ++vQfyl6wJEhtKa CvFthJUvfN5MBavz7My4wY/faioQAbSS5PQfdbqc7PiT6cHp12p5F18ugc+zxgP0sEaQfQ16tUn 5MTKxHAISqkCLQEpb8gyxf0tzRBV6H6X+HGCpg9Dn/zCs1jN7Ylh6QBsaz61wTIhT4QDTekuvG0 1eCGezSsfC5QyRg== X-Developer-Key: i=luca@z3ntu.xyz; a=openpgp; fpr=BD04DA24C971B8D587B2B8D7FAF69CF6CD2D02CD X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 10:57:51 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779482832336409763 X-GMAIL-MSGID: 1779482832336409763 |
Series |
iommu/qcom: restore IOMMU state if needed
|
|
Commit Message
Luca Weiss
Oct. 11, 2023, 5:57 p.m. UTC
From: Vladimir Lypak <vladimir.lypak@gmail.com> If the IOMMU has a power domain then some state will be lost in qcom_iommu_suspend and TZ will reset device if we don't call qcom_scm_restore_sec_cfg before accessing it again. Signed-off-by: Vladimir Lypak <vladimir.lypak@gmail.com> [luca@z3ntu.xyz: reword commit message a bit] Signed-off-by: Luca Weiss <luca@z3ntu.xyz> --- This patch is required for MSM8953 GPU IOMMU. See also downstream sources: https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/commit/f8464885dafc5b780b85de29d92a08c692d3a4d0 https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/LA.UM.10.6.2.r1-02500-89xx.0/drivers/iommu/arm-smmu.c#L4221-4225 Since the compatibles provided by this driver (qcom,msm-iommu-v*) is only used on msm8916, msm8939 and msm8953, and both 8916 and 8939 don't have a power domain on the IOMMU, I also don't expect anything to break there. --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- base-commit: 2933a1156742d8c47550493a77af8e2d81cf3c84 change-id: 20231011-msm8953-iommu-restore-fabc2e31fee7 Best regards,
Comments
On Mittwoch, 11. Oktober 2023 19:57:26 CET Luca Weiss wrote: > From: Vladimir Lypak <vladimir.lypak@gmail.com> > > If the IOMMU has a power domain then some state will be lost in > qcom_iommu_suspend and TZ will reset device if we don't call > qcom_scm_restore_sec_cfg before accessing it again. > > Signed-off-by: Vladimir Lypak <vladimir.lypak@gmail.com> > [luca@z3ntu.xyz: reword commit message a bit] > Signed-off-by: Luca Weiss <luca@z3ntu.xyz> > --- > This patch is required for MSM8953 GPU IOMMU. > > See also downstream sources: > https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/commit/f8464885dafc5b780b > 85de29d92a08c692d3a4d0 > https://git.codelinaro.org/clo/la/kernel/msm-4.9/-/blob/LA.UM.10.6.2.r1-025 > 00-89xx.0/drivers/iommu/arm-smmu.c#L4221-4225 > > Since the compatibles provided by this driver (qcom,msm-iommu-v*) is > only used on msm8916, msm8939 and msm8953, and both 8916 and 8939 don't > have a power domain on the IOMMU, I also don't expect anything to break > there. Hi all, Any feedback on this patch? Regards Luca > --- > drivers/iommu/arm/arm-smmu/qcom_iommu.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c > b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index 97b2122032b2..67abeb02cf53 > 100644 > --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c > +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c > @@ -900,8 +900,16 @@ static void qcom_iommu_device_remove(struct > platform_device *pdev) static int __maybe_unused qcom_iommu_resume(struct > device *dev) > { > struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev); > + int ret; > + > + ret = clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks); > + if (ret < 0) > + return ret; > + > + if (dev->pm_domain) > + return qcom_scm_restore_sec_cfg(qcom_iommu->sec_id, 0); > > - return clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks); > + return ret; > } > > static int __maybe_unused qcom_iommu_suspend(struct device *dev) > > --- > base-commit: 2933a1156742d8c47550493a77af8e2d81cf3c84 > change-id: 20231011-msm8953-iommu-restore-fabc2e31fee7 > > Best regards,
On Wed, 11 Oct 2023 19:57:26 +0200, Luca Weiss wrote: > From: Vladimir Lypak <vladimir.lypak@gmail.com> > > If the IOMMU has a power domain then some state will be lost in > qcom_iommu_suspend and TZ will reset device if we don't call > qcom_scm_restore_sec_cfg before accessing it again. > > > [...] Applied to will (for-joerg/arm-smmu/updates), thanks! [1/1] iommu/qcom: restore IOMMU state if needed https://git.kernel.org/will/c/268dd4edb748 Cheers,
diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c index 97b2122032b2..67abeb02cf53 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -900,8 +900,16 @@ static void qcom_iommu_device_remove(struct platform_device *pdev) static int __maybe_unused qcom_iommu_resume(struct device *dev) { struct qcom_iommu_dev *qcom_iommu = dev_get_drvdata(dev); + int ret; + + ret = clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks); + if (ret < 0) + return ret; + + if (dev->pm_domain) + return qcom_scm_restore_sec_cfg(qcom_iommu->sec_id, 0); - return clk_bulk_prepare_enable(CLK_NUM, qcom_iommu->clks); + return ret; } static int __maybe_unused qcom_iommu_suspend(struct device *dev)