From nobody Tue Feb 10 04:13:32 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 719A114F104 for ; Sat, 21 Dec 2024 16:59:44 +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=1734800387; cv=none; b=ftviT0xAAnNNjekIRyAeJy1tZZqcJvh8HlyI+YniA4S0C3amgS0h0qJZDstQv4elhweTBqXkjcmvMW4rCqscc2aU21ZW5KLl1UpAo1sbJmb2r9SZqMGsCwCr6HJ1Y/e3EmH6UKlSdTs7e+ipwXhK5zGjjwOb1JTWspp2BuYbLmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734800387; c=relaxed/simple; bh=STpgDgIMq/gbPfYARNUuEFJc+1Bw9OQgohVvukYzebs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kOOKLUZ0/ljlHVH3zbljky2Z+AzkFGVJu5Mmr4ORqBLzV8wDspxyEO3ZgfSAy+Ulx0YwJ0+UnAfvO3EbxyqwePHIorUKJKkABgr7nqjd3zwYm2n8muSjHklqYHvAlyG2P6J4zT7LgUdYQliO7iwAhJAMLgHHVaGs8/SJHePLXfM= 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 BABBD1AC1; Sat, 21 Dec 2024 09:00:11 -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 5D4BE3F528; Sat, 21 Dec 2024 08:59:42 -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 4/4] coresight/etm3x: remove redundant usage of drvdata->spinlock Date: Sat, 21 Dec 2024 16:59:34 +0000 Message-Id: <20241221165934.1161856-5-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 etm_starting/dying_cpu() by preventing cpu hotplug while enabling etm3x via sysfs since - perf and sysfs enable method are serialized by csdev->mode - etm_starting/dying_cpu() aren't called concurrently with etm_enable_perf/sysfs() because they're called in cpu offline status. - while etm_enable_sysfs(), config isn't changed since csdev->mode is not DISABLED. Signed-off-by: Yeoreum Yun --- .../coresight/coresight-etm3x-core.c | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index c103f4c70f5d..5ec871979ef7 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -519,7 +519,12 @@ static int etm_enable_sysfs(struct coresight_device *c= sdev) struct etm_enable_arg arg =3D { }; int ret; =20 - spin_lock(&drvdata->spinlock); + cpus_read_lock(); + + if (cpu_is_offline(drvdata->cpu)) { + ret =3D -ENODEV; + goto unlock_sysfs_enable; + } =20 /* sysfs needs to allocate and set a trace ID */ ret =3D etm_read_alloc_trace_id(drvdata); @@ -530,23 +535,19 @@ static int etm_enable_sysfs(struct coresight_device *= csdev) * Configure the ETM only if the CPU is online. If it isn't online * hw configuration will take place on the local CPU during bring up. */ - if (cpu_online(drvdata->cpu)) { - arg.drvdata =3D drvdata; - ret =3D smp_call_function_single(drvdata->cpu, - etm_enable_hw_smp_call, &arg, 1); - if (!ret) - ret =3D arg.rc; - if (!ret) - drvdata->sticky_enable =3D true; - } else { - ret =3D -ENODEV; - } + arg.drvdata =3D drvdata; + ret =3D smp_call_function_single(drvdata->cpu, + etm_enable_hw_smp_call, &arg, 1); + if (!ret) + ret =3D arg.rc; + if (!ret) + drvdata->sticky_enable =3D true; =20 if (ret) etm_release_trace_id(drvdata); =20 unlock_enable_sysfs: - spin_unlock(&drvdata->spinlock); + cpus_read_unlock(); =20 if (!ret) dev_dbg(&csdev->dev, "ETM tracing enabled\n"); @@ -646,7 +647,6 @@ static void etm_disable_sysfs(struct coresight_device *= csdev) * DYING hotplug callback is serviced by the ETM driver. */ cpus_read_lock(); - spin_lock(&drvdata->spinlock); =20 /* * Executing etm_disable_hw on the cpu whose ETM is being disabled @@ -654,7 +654,6 @@ static void etm_disable_sysfs(struct coresight_device *= csdev) */ smp_call_function_single(drvdata->cpu, etm_disable_hw, drvdata, 1); =20 - spin_unlock(&drvdata->spinlock); cpus_read_unlock(); =20 /* @@ -722,7 +721,6 @@ static int etm_starting_cpu(unsigned int cpu) if (!etmdrvdata[cpu]) return 0; =20 - spin_lock(&etmdrvdata[cpu]->spinlock); if (!etmdrvdata[cpu]->os_unlock) { etm_os_unlock(etmdrvdata[cpu]); etmdrvdata[cpu]->os_unlock =3D true; @@ -730,7 +728,6 @@ static int etm_starting_cpu(unsigned int cpu) =20 if (coresight_get_mode(etmdrvdata[cpu]->csdev)) etm_enable_hw(etmdrvdata[cpu]); - spin_unlock(&etmdrvdata[cpu]->spinlock); return 0; } =20 @@ -739,10 +736,8 @@ static int etm_dying_cpu(unsigned int cpu) if (!etmdrvdata[cpu]) return 0; =20 - spin_lock(&etmdrvdata[cpu]->spinlock); if (coresight_get_mode(etmdrvdata[cpu]->csdev)) etm_disable_hw(etmdrvdata[cpu]); - spin_unlock(&etmdrvdata[cpu]->spinlock); return 0; } =20 --=20 LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}