From nobody Tue Feb 10 00:57:40 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98F2215AAC1 for ; Sat, 21 Dec 2024 16:59:46 +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=1734800388; cv=none; b=gJrX9ZVmRoAh7yUbMvBpTVN1H/IESvpRQqB1dKd0Xzkl5q6Au6nPzDjCFE07X7ITdfgOYqBsY+3UpsYli22W51Q0+trikwdQ3L8QT2sU8uVLQH5Np8wlsTVxcRkmPCGbMvGI/LkJHEomB8yv/F+aI/9yHFkgXd2/qnhAau+ETUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734800388; c=relaxed/simple; bh=IbgLNI5mPamR27NCNYOdpxIiaypUGZECmjIbPoLODfY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CIPVbRb++0hGE2DFmZMQtF2ySHFqeyJpJEQbKqNU3HmLDXqoZxBtKO588fdo2OtB58nGqw5Jxw7Bt6Pb5NYF4bR9yG8tT6kAHUtGjAwf0ur0fcx14DMYUncjKAAFriwaWVJ4RRhgpIWLTVLzo2k6p6Idus9qfbuVqAW4z98L3+A= 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 A772B168F; Sat, 21 Dec 2024 09:00:08 -0800 (PST) Received: from e129823.cambridge.arm.com (e129823.arm.com [10.1.197.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5105D3F528; Sat, 21 Dec 2024 08:59:39 -0800 (PST) From: Yeoreum Yun To: suzuki.poulose@arm.com, mike.leach@linaro.org, james.clark@linaro.org, alexander.shishkin@linux.intel.com Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Yeoreum Yun Subject: [PATCH 2/4] coresight/etm4x: remove redundant usage of drvdata->spinlock Date: Sat, 21 Dec 2024 16:59:32 +0000 Message-Id: <20241221165934.1161856-3-yeoreum.yun@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241221165934.1161856-1-yeoreum.yun@arm.com> References: <20241221165934.1161856-1-yeoreum.yun@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove redundant usage of drvdata->spinlock in etm4_starting/dying_cpu() by preventing cpu hotplug while enabling etm4x via sysfs since - perf and sysfs enable method are serialized by csdev->mode - etm4_starting/dying_cpu() aren't called concurrently with etm4_enable_perf/sysfs() because they're called in cpu offline status. - while etm4x_enable_sysfs(), config isn't altered since csdev->mode isn't DISABLED. Signed-off-by: Yeoreum Yun --- .../coresight/coresight-etm4x-core.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index 86893115df17..5c9475b44194 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -799,16 +799,21 @@ static int etm4_enable_sysfs(struct coresight_device = *csdev) unsigned long cfg_hash; int ret, preset; =20 + cpus_read_lock(); + + if (cpu_is_offline(drvdata->cpu)) { + ret =3D -EPERM; + goto unlock_sysfs_enable; + } + /* enable any config activated by configfs */ cscfg_config_sysfs_get_active_cfg(&cfg_hash, &preset); if (cfg_hash) { ret =3D cscfg_csdev_enable_active_config(csdev, cfg_hash, preset); if (ret) - return ret; + goto unlock_sysfs_enable; } =20 - raw_spin_lock(&drvdata->spinlock); - /* sysfs needs to read and allocate a trace ID */ ret =3D etm4_read_alloc_trace_id(drvdata); if (ret < 0) @@ -830,10 +835,11 @@ static int etm4_enable_sysfs(struct coresight_device = *csdev) etm4_release_trace_id(drvdata); =20 unlock_sysfs_enable: - raw_spin_unlock(&drvdata->spinlock); + cpus_read_unlock(); =20 if (!ret) dev_dbg(&csdev->dev, "ETM tracing enabled\n"); + return ret; } =20 @@ -977,7 +983,6 @@ static void etm4_disable_sysfs(struct coresight_device = *csdev) * DYING hotplug callback is serviced by the ETM driver. */ cpus_read_lock(); - raw_spin_lock(&drvdata->spinlock); =20 /* * Executing etm4_disable_hw on the cpu whose ETM is being disabled @@ -985,7 +990,6 @@ static void etm4_disable_sysfs(struct coresight_device = *csdev) */ smp_call_function_single(drvdata->cpu, etm4_disable_hw, drvdata, 1); =20 - raw_spin_unlock(&drvdata->spinlock); cpus_read_unlock(); =20 /* @@ -1663,13 +1667,11 @@ static int etm4_starting_cpu(unsigned int cpu) if (!etmdrvdata[cpu]) return 0; =20 - raw_spin_lock(&etmdrvdata[cpu]->spinlock); if (!etmdrvdata[cpu]->os_unlock) etm4_os_unlock(etmdrvdata[cpu]); =20 if (coresight_get_mode(etmdrvdata[cpu]->csdev)) etm4_enable_hw(etmdrvdata[cpu]); - raw_spin_unlock(&etmdrvdata[cpu]->spinlock); return 0; } =20 @@ -1678,10 +1680,8 @@ static int etm4_dying_cpu(unsigned int cpu) if (!etmdrvdata[cpu]) return 0; =20 - raw_spin_lock(&etmdrvdata[cpu]->spinlock); if (coresight_get_mode(etmdrvdata[cpu]->csdev)) etm4_disable_hw(etmdrvdata[cpu]); - raw_spin_unlock(&etmdrvdata[cpu]->spinlock); return 0; } =20 --=20 LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}