From nobody Wed Oct 8 07:28:52 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 36C0A278E6A for ; Tue, 1 Jul 2025 14:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751381650; cv=none; b=U+yvFOY5VmhOV5+PQQKTJYTNxGjhGzMxgQ3YdSqE+9eCQe7tvKCPBo+010fJypGwAAcW56U3x8lvgo/KbLiNZHgIlnapUGg/pXU1NQGe7YutQsu6//AcUzd2wrPjGT2yRbpbZg63+IgmzLXiwAuDuW/v0IAnJkKznRpW9bcT7fY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751381650; c=relaxed/simple; bh=O1pI0iF9hTryWdOQgp3cU1VgAjwnoi8ZWBPkrrj4lyQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iuNgJwbTuCRkqBSJDa15BSLlyKClXoxig93a8TfwQWZrPQmEeDysNhYkzkLoVxO8y7MytbZujGUWkOYbpP4xJhI7RbgnLP0IN+2NImjiPRZlrQ46gIqVFgXqFhCv6kERNqrxs1CI/meIn+KKTCzUAFNCE/KihAThtBi+mAZ5Xsg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4B3D012FC; Tue, 1 Jul 2025 07:53:53 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 90BFB3F66E; Tue, 1 Jul 2025 07:54:06 -0700 (PDT) From: Leo Yan Date: Tue, 01 Jul 2025 15:53:33 +0100 Subject: [PATCH v2 08/28] coresight: etm4x: Remove the state_needs_restore flag Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250701-arm_cs_pm_fix_v3-v2-8-23ebb864fcc1@arm.com> References: <20250701-arm_cs_pm_fix_v3-v2-0-23ebb864fcc1@arm.com> In-Reply-To: <20250701-arm_cs_pm_fix_v3-v2-0-23ebb864fcc1@arm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Levi Yun , Greg Kroah-Hartman , Alexander Shishkin , Yabin Cui , Keita Morisaki , Yuanfang Zhang Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1751381627; l=3440; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=O1pI0iF9hTryWdOQgp3cU1VgAjwnoi8ZWBPkrrj4lyQ=; b=dYOZvCM3nvqRLI36PKBsdDWkTy0rDNrp6alwsu3pxbeJTHsUs2gX2QTCQ7ygC+VbaD91lFLMp EZGEldNbONWDk050LHG9bQ78FZepIz3RZbVWMq76LbKlM1+XRBaCC5i X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= When the restore flow is invoked, it means no error occurred during the save phase. Otherwise, if any errors happened while saving the context, the function would return an error and abort the suspend sequence. Therefore, the state_needs_restore flag is unnecessary. The save and restore functions are changed to check two conditions: 1) The global flag pm_save_enable is SELF_HOSTED mode; 2) The device is in active mode (non DISABLED). Signed-off-by: Leo Yan Reviewed-by: Yeoreum Yun --- drivers/hwtracing/coresight/coresight-etm4x-core.c | 14 ++++++++------ drivers/hwtracing/coresight/coresight-etm4x.h | 2 -- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index 6cd76a2527cf11752963a7cb1b3b0e9a8be241f0..1faf8614366f38eea4909152558= fe8e69730bde4 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -1981,8 +1981,6 @@ static int __etm4_cpu_save(struct etmv4_drvdata *drvd= ata) goto out; } =20 - drvdata->state_needs_restore =3D true; - /* * Power can be removed from the trace unit now. We do this to * potentially save power on systems that respect the TRCPDCR_PU @@ -2000,11 +1998,14 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvd= ata) { int ret =3D 0; =20 + if (pm_save_enable !=3D PARAM_PM_SAVE_SELF_HOSTED) + return 0; + /* * Save and restore the ETM Trace registers only if * the ETM is active. */ - if (coresight_get_mode(drvdata->csdev) && drvdata->save_state) + if (coresight_get_mode(drvdata->csdev)) ret =3D __etm4_cpu_save(drvdata); return ret; } @@ -2093,8 +2094,6 @@ static void __etm4_cpu_restore(struct etmv4_drvdata *= drvdata) if (!drvdata->skip_power_up) etm4x_relaxed_write32(csa, state->trcpdcr, TRCPDCR); =20 - drvdata->state_needs_restore =3D false; - /* * As recommended by section 4.3.7 ("Synchronization when using the * memory-mapped interface") of ARM IHI 0064D @@ -2120,7 +2119,10 @@ static void __etm4_cpu_restore(struct etmv4_drvdata = *drvdata) =20 static void etm4_cpu_restore(struct etmv4_drvdata *drvdata) { - if (drvdata->state_needs_restore) + if (pm_save_enable !=3D PARAM_PM_SAVE_SELF_HOSTED) + return; + + if (coresight_get_mode(drvdata->csdev)) __etm4_cpu_restore(drvdata); } =20 diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtrac= ing/coresight/coresight-etm4x.h index 4d32605a84ce91eae2101cd83cad5f5317e2638a..06438ed1071478cd5c1a143c6ef= 58a926d6992fb 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -978,7 +978,6 @@ struct etmv4_save_state { * in EL2. Otherwise, 0. * @config: structure holding configuration parameters. * @save_state: State to be preserved across power loss - * @state_needs_restore: True when there is context to restore after PM ex= it * @skip_power_up: Indicates if an implementation can skip powering up * the trace unit. * @paused: Indicates if the trace unit is paused. @@ -1032,7 +1031,6 @@ struct etmv4_drvdata { u64 trfcr; struct etmv4_config config; struct etmv4_save_state *save_state; - bool state_needs_restore; bool skip_power_up; bool paused; DECLARE_BITMAP(arch_features, ETM4_IMPDEF_FEATURE_MAX); --=20 2.34.1