From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52CD913D638 for ; Fri, 1 May 2026 09:43:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777628594; cv=none; b=T9PirQesfbePei2C2/PFarYOCcGHOPUlz/0rGxg2jv9wUx0BNXkbIpUbXZSvyspabQ56NsKvyrCf7ntSnbrGNkIccO6wxpAq78mNR908bBpEjjMzR9DXMIdyFV2YPqKPtSIKojLaJ/OUhJBHm5cMs0cCMVGk16CudF/wbjfuc9k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777628594; c=relaxed/simple; bh=KDs4GTWKAYWXEfK6iEd1JOpSCNrrYr8qtwJyZQbJr+M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=P4XfaIf7kn+OIKQUzkMQfQf7ypR9RCqQBhCK/ULIcd/4Sw4l3IkZhIGcNoccOmBn4wX1kwdCZDxSrn5H/RuF0vM081ECobkGN2/t9rNri4ntd0CY0mfB33RuzRFvlS+XnaqUWZTyYYjTYzXB+IaNSX/LyGsL1dJiEvuz5kEmLlE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=TWJyHN+H; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TWJyHN+H" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-43d73422431so1510139f8f.2 for ; Fri, 01 May 2026 02:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1777628591; x=1778233391; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=in3/bYblpEbZej2XATKsoT0Of3FBnJ5woY0ebB360NI=; b=TWJyHN+HOiuJUrql3xLKmRWxiLEwM8F0M8A/eqYPlr44nBy9BdhpDLQPmM6ERGIu0p PiJoTLoQErWBg7XWRO8vqABpPd3Q86zXb4mHnzc57/PWeASH2HYie0YDVt8Kkl70vLa3 oYsUiG7oTEo9rPDb4eaRM9Bnyhb5H9jmD28vZ7I89qlvALBvo9EwiNgjbdrV1m1rqkhK Rj4WBoEEZR0Y0N6sRpmz1jzrA3uTicKWY8nmpfg1YwJ9ZdSxzhvqyAQ3xQ7+C9CGK7z/ UqXLBp/NLNB6PGqkvFKavpvADFbIO68yKbofbyT1hnnflYe4vDXMkWy2fGh4Uf3NXAYj cQmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777628591; x=1778233391; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=in3/bYblpEbZej2XATKsoT0Of3FBnJ5woY0ebB360NI=; b=Y7KBwgUG0XWnkNDYKxlJKW/trVHYooGbt3jAptLoif7Ppr/zBdwcRvmYKZaqO3pRgX eKne2wYFyF4LxjzYR8maCTf9xXO+UkpiIZr88fr+r01QwGq2/56Le5j5t5fdJmUveeUp B5M/Is/OjXQiybVN2b92Dh/8i+NqJ3knHyZK9lv6EJlR1LMX8E6u+LnNQbwrIC814EAy HJzwsPB8oZaxLS05B5lbtMaEKje/lgvNQSsRrqBhkfifoN6chnqRMnvYsSjiy/JZrLfd hAsictGjlFsqjTvbtYD/Cpi0dTLwrdKruDGcWrvDgimxcj+0xqZ29um7rMsb58GMngj/ 1x9A== X-Forwarded-Encrypted: i=1; AFNElJ+C/UOUI0ouutx/T3Bs0qdoHB93zOsOkef+tN/wcizEBLzSiszcXlJCc6beVzwvkOg4DY0uZg0uJs0hOVw=@vger.kernel.org X-Gm-Message-State: AOJu0YzAdeZekZQgF2IZaA15SQIk1RE1KGF83lm1t769IhnBcIYE0w/Y 68tJLhsuHYrcqtRwbJM3HGBnURO0EP44bNcw1SfwWfg51RB2mNLB91Net3o+5u2Jk18= X-Gm-Gg: AeBDievotJvsS6As0O8zfdnlbldyjhc0elugMhvg0FqfvYHL5VE/4TEJ9qiI+ThbQLt lAPnxFbiAEoXkE9MVurjcdEv4xU0jSsf7K9ScDT5c1zq/TkBhbHxlwedpPF57M/oAWKhegVzO9x 54QWWuOu/GdKzrshiHeOxsexeJt67qxrETN5gYIpGh8gjsm/8S41Wl7QFjdTIUbzh1C3fistnF0 L5T6pujxtTxD+FBnE6UdhrbVb5zBxI7/+0ck0eZHO/277z447pQlUi+2z687L68WRzQauzYO1Kk TAQEIARb28vnsKhaKetOeC7N0XdSWEps3tF95DeTxa3p977XDwQi5vafWaW0lFZVco7We/Q16Aw VvixzLjKOhZCgBehJOGtYhOcvAqWj30ws5rOciOqrI/tXKM6DkA5sekJHFal13rszE41ddcr8hc xEGfYLrVPYmgKERLQ19/x8gwdid9bC0Wv4afE1gsY= X-Received: by 2002:a05:6000:2508:b0:43d:1c59:2dc with SMTP id ffacd0b85a97d-4493e5ac44cmr11110357f8f.28.1777628590663; Fri, 01 May 2026 02:43:10 -0700 (PDT) Received: from [192.168.1.3] ([185.48.77.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44a9879ef89sm4384785f8f.30.2026.05.01.02.43.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 May 2026 02:43:10 -0700 (PDT) Message-ID: Date: Fri, 1 May 2026 10:43:09 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] coresight: ete: Always save state on power down To: Suzuki K Poulose , Leo Yan Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mike Leach , Alexander Shishkin , Mathieu Poirier References: <20260428-james-cs-ete-pm_save_enable-v1-0-c7a90ca6f43b@linaro.org> <20260428-james-cs-ete-pm_save_enable-v1-1-c7a90ca6f43b@linaro.org> Content-Language: en-US From: James Clark In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 01/05/2026 9:24 am, Suzuki K Poulose wrote: > On 28/04/2026 13:18, James Clark wrote: >> ETE registers are always system registers so it's highly unlikely there >> will be an implementation that preserves them on CPU power down. Also >> the ETE DT binding never documented >> "arm,coresight-loses-context-with-cpu" so nobody would have legitimately >> been able to use that binding to fix it. >> >> Fix it by hard coding the setting for ETE and add a warning if the user >> tried to use the module parameter. Don't add a warning if >> loses-context-with-cpu is present in the DT as it's not a documented >> binding anyway. etm4_init_pm_save() needs to happen after drvdata is >> initialised so etm4x_is_ete() can be called. >> >> This fixes the following error when using Coresight with ACPI on the FVP >> which supports CPU PM: >> >>    coresight ete0: External agent took claim tag >>    WARNING: drivers/hwtracing/coresight/coresight-core.c:248 at >> coresight_disclaim_device_unlocked+0xe0/0xe8, CPU#0: perf/117 >> >> Fixes: 35e1c9163e02 ("coresight: ete: Add support for ETE tracing") >> Signed-off-by: James Clark >> --- >>   drivers/hwtracing/coresight/coresight-etm4x-core.c | 41 ++++++++++++ >> +++------- >>   1 file changed, 29 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/ >> drivers/hwtracing/coresight/coresight-etm4x-core.c >> index d565a73f0042..a7fb680dd383 100644 >> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c >> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c >> @@ -56,10 +56,11 @@ MODULE_PARM_DESC(boot_enable, "Enable tracing on >> boot"); >>   #define PARAM_PM_SAVE_NEVER      1 /* never save any state */ >>   #define PARAM_PM_SAVE_SELF_HOSTED 2 /* save self-hosted state only */ >> +/* Save option for ETM4. ETE ignores this option and always saves */ >>   static int pm_save_enable = PARAM_PM_SAVE_FIRMWARE; >>   module_param(pm_save_enable, int, 0444); >>   MODULE_PARM_DESC(pm_save_enable, >> -    "Save/restore state on power down: 1 = never, 2 = self-hosted"); >> +    "Save/restore state on power down: 1 = never, 2 = self-hosted. >> ETM4 only."); >>   static struct etmv4_drvdata *etmdrvdata[NR_CPUS]; >>   static void etm4_set_default_config(struct etmv4_config *config); >> @@ -1365,6 +1366,30 @@ static void etm4_fixup_wrong_ccitmin(struct >> etmv4_drvdata *drvdata) >>       } >>   } >> +static int etm4_init_pm_save(struct device *dev, struct etmv4_drvdata >> *drvdata) >> +{ >> +    if (etm4x_is_ete(drvdata)) { >> +        /* >> +         * Always do PM save for ETE. It always uses system registers >> +         * which will be lost on CPU power down. >> +         */ >> +        pm_save_enable = PARAM_PM_SAVE_SELF_HOSTED; > > Should we do this instead based on if the ETM/ETE is accessed via sys > instructions ? That would cover all implementations? > > > Suzuki > I did discuss that with Leo but we thought it might be a riskier change as ETM is older and nobody has reported any issues, and there is already the DT option to fix it that way. Turning it on by default could cause some performance regressions. Although it's only if the ETM is in use, so the impact is minimal. In reality it probably does make sense as it's highly unlikely that sysreg ETM wouldn't need saving, so it might make some platforms with misconfigured DTs more stable. I can send another version if you think it makes sense, what do you think Leo? >> +    } else if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE) { >> +        pm_save_enable = coresight_loses_context_with_cpu(dev) ? >> +            PARAM_PM_SAVE_SELF_HOSTED : PARAM_PM_SAVE_NEVER; >> +    } >> + >> +    if (pm_save_enable != PARAM_PM_SAVE_NEVER) { >> +        drvdata->save_state = devm_kmalloc(dev, >> +                           sizeof(struct etmv4_save_state), >> +                           GFP_KERNEL); >> +        if (!drvdata->save_state) >> +            return -ENOMEM; >> +    } >> + >> +    return 0; >> +} >> + >>   static void etm4_init_arch_data(void *info) >>   { >>       u32 etmidr0; >> @@ -2247,6 +2272,9 @@ static int etm4_add_coresight_dev(struct >> etm4_init_arg *init_arg) >>           return -ENOMEM; >>       etm4_set_default(&drvdata->config); >> +    ret = etm4_init_pm_save(dev, drvdata); >> +    if (ret) >> +        return ret; >>       pdata = coresight_get_platform_data(dev); >>       if (IS_ERR(pdata)) >> @@ -2305,17 +2333,6 @@ static int etm4_probe(struct device *dev) >>       if (ret) >>           return ret; >> -    if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE) >> -        pm_save_enable = coresight_loses_context_with_cpu(dev) ? >> -                   PARAM_PM_SAVE_SELF_HOSTED : PARAM_PM_SAVE_NEVER; >> - >> -    if (pm_save_enable != PARAM_PM_SAVE_NEVER) { >> -        drvdata->save_state = devm_kmalloc(dev, >> -                sizeof(struct etmv4_save_state), GFP_KERNEL); >> -        if (!drvdata->save_state) >> -            return -ENOMEM; >> -    } >> - >>       raw_spin_lock_init(&drvdata->spinlock); >>       drvdata->cpu = coresight_get_cpu(dev); >> >