From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BC4941F5C0 for ; Thu, 16 Jul 2026 12:41:23 +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=1784205687; cv=none; b=WFNf3HGJCN1wzroFTk8uRiY/JR97tkoSoyNXdGZ3VxhNU78/at9J4J+zn6OoAPNfHxcRiwEo/x1JipxyhS6shXAUWqosAx3u7htD0WiM+/MrcuvUpjL8voDVbiE004c4IzZCFbt6W2Ysyq4W6ANd6dBve/xfT3EmQcPFLShIazY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784205687; c=relaxed/simple; bh=Y3aM/kQqvp++lv0mc4QE+i4DL7rm5D/JWaR3nRML3zI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TibgSADvAE9Ino8MDxNGISKxKPElzBRtpDMIaix6WGecu2BgiTVQ/66jyBOo/2doVMnA5DH/SSyNQ+9kUXn6Wy2RgfyoyoOywk/jB9tdH5+tE/cgRrgm/CPImNq0UFL7yYxerhdUMjvsaDo7yYN72aAidQ3Kwz27b4+uuE/Td/0= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=qlVTQLJG; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="qlVTQLJG" 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 0840B1476; Thu, 16 Jul 2026 05:41:19 -0700 (PDT) Received: from [10.2.197.99] (ewhatever.cambridge.arm.com [10.2.197.99]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C6003F7B4; Thu, 16 Jul 2026 05:41:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784205683; bh=Y3aM/kQqvp++lv0mc4QE+i4DL7rm5D/JWaR3nRML3zI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=qlVTQLJGnpvRinTtJ4NWwCfIhzmffxp11KxgrK0NTEaJMtM4Reo3kYV51OHiMKJc7 IEyNzUjXeLXO/sNY4CrPhGN23/73KwC89/+b+HyLPbh62C64kN3rHWgy2RlKTiBkKh 6IR1YMRL4qxLGWz14Kmko2cB7UUemkSebOa8J6Kg= Message-ID: <2005044a-ff4d-4585-963b-1c346d661a35@arm.com> Date: Thu, 16 Jul 2026 13:41:19 +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 v8 08/13] coresight: etm4x: fix inconsistencies with sysfs configuration To: Leo Yan , Yeoreum Yun Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mike.leach@arm.com, james.clark@linaro.org, alexander.shishkin@linux.intel.com, jie.gan@oss.qualcomm.com References: <20260629090007.1718746-1-yeoreum.yun@arm.com> <20260629090007.1718746-9-yeoreum.yun@arm.com> <20260706173940.GB1024232@e132581.arm.com> Content-Language: en-US From: Suzuki K Poulose In-Reply-To: <20260706173940.GB1024232@e132581.arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 06/07/2026 18:39, Leo Yan wrote: > On Mon, Jun 29, 2026 at 10:00:01AM +0100, Yeoreum Yun wrote: > > [...] > >> @@ -922,25 +950,7 @@ static int etm4_enable_sysfs(struct coresight_device *csdev, struct coresight_pa >> { >> struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); >> struct etm4_enable_arg arg = { }; >> - unsigned long cfg_hash; >> - int ret, preset; >> - >> - /* enable any config activated by configfs */ >> - cscfg_config_sysfs_get_active_cfg(&cfg_hash, &preset); >> - if (cfg_hash) { >> - ret = cscfg_csdev_enable_active_config(csdev, cfg_hash, preset); >> - if (ret) { >> - etm4_release_trace_id(drvdata); >> - return ret; >> - } >> - } >> - >> - raw_spin_lock(&drvdata->spinlock); >> - >> - drvdata->trcid = path->trace_id; >> - >> - /* Tracer will never be paused in sysfs mode */ >> - drvdata->paused = false; >> + int ret; >> >> /* >> * Executing etm4_enable_hw on the cpu whose ETM is being enabled >> @@ -948,20 +958,20 @@ static int etm4_enable_sysfs(struct coresight_device *csdev, struct coresight_pa >> */ >> arg.drvdata = drvdata; >> arg.path = path; >> + >> + raw_spin_lock(&drvdata->spinlock); >> + arg.config = drvdata->config; >> + raw_spin_unlock(&drvdata->spinlock); >> + >> ret = smp_call_function_single(drvdata->cpu, >> etm4_enable_sysfs_smp_call, &arg, 1); >> if (!ret) >> ret = arg.rc; >> if (!ret) >> - drvdata->sticky_enable = true; >> - >> - if (ret) >> + dev_dbg(&csdev->dev, "ETM tracing enabled\n"); >> + else >> etm4_release_trace_id(drvdata); >> >> - raw_spin_unlock(&drvdata->spinlock); >> - >> - if (!ret) >> - dev_dbg(&csdev->dev, "ETM tracing enabled\n"); >> return ret; >> } > > This is most valuable change for me, as now we will have much clear > scope for what is protected ("drvdata->config"). > > However, a corner case was mentioned by Sashiko: > > | It appears etm4_enable_hw() modifies drvdata->ss_status while executing > | via IPI, but sshot_ctrl_store() can modify the same array concurrently Could we stop modifying the drvdata->ss_status in enable_hw() ? We moved it outside the config claiming that the status is not used(or useful). # Then why not remove the updating from enable_hw() Suzuki > | from process context since the lock is no longer held across the > | smp_call_function_single() call. > > "drvdata->ss_status" is a race condition between SMP call and sysfs > knobs. Should we change to spinlock_irqsave/irqrestore when access > drvdata->ss_status? > > Thanks, > Leo