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 E0F382777EA for ; Wed, 19 Nov 2025 18:04:54 +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=1763575499; cv=none; b=HjiJb8Z5Ta2GX1OCe0pn2Vla6SnE8zyGSFLforqOBr8LEjBTrP+1p+73D+G7J7xSS2JszbSgONgNpIq2r1rrDQRtL36bY0Bq+WKmP1AHvWxjC4y6ng5WhdsArsTPaQL3qfo5TM6qEBl2NxMYnjXohxH8LvhAD8i7zKf/QSN8Y/8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763575499; c=relaxed/simple; bh=nGWVgVQwxACOrI1BMQU9I+EcRPpVXiTZ7iKzm/FxEfA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZrGZdf3ZH9VvP6B/TTBrCo8ZvranXHuccMv0syACRm90+G8hG5DTk3DjRb8RXkHB8/mvHGojRk30Ya5vzQmbz4uzZsDsRtN7Lo04fyCdBQHfZftWjmIFNEOupMfw2Mzxym8QyA/QBEnvauS+/Zv42EvjxO8H955VBQuO1kZE/Kc= 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 BECDBFEC; Wed, 19 Nov 2025 10:04:42 -0800 (PST) Received: from localhost (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CBD283F740; Wed, 19 Nov 2025 10:04:49 -0800 (PST) Date: Wed, 19 Nov 2025 18:04:47 +0000 From: Leo Yan To: Suzuki K Poulose Cc: Junhao He , james.clark@linaro.org, anshuman.khandual@arm.com, yeoreum.yun@arm.com, mike.leach@linaro.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, jonathan.cameron@huawei.com Subject: Re: [PATCH v4 2/3] coresight: tmc: refactor the tmc-etr mode setting to avoid race conditions Message-ID: <20251119180447.GG8204@e132581.arm.com> References: <20251111122149.1981162-1-hejunhao3@h-partners.com> <20251111122149.1981162-3-hejunhao3@h-partners.com> <15868ecb-c1e7-4273-a2e2-5c10f2701c0b@arm.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <15868ecb-c1e7-4273-a2e2-5c10f2701c0b@arm.com> On Thu, Nov 13, 2025 at 03:02:45PM +0000, Suzuki Kuruppassery Poulose wrote: > Hi Junhao, > > While your patch fixes the problem it introduces imbalance in the > way perf vs sysfs modes are handled. Previously, I suggested setting the mode in a unified way in tmc_enable_etr_sink() [1]. After looking into the code again, it seems that both my suggestion and this patch set the perf mode is too late. Maybe we need to set the sink's device mode once a session starts to use it. So we should set the perf mode when allocating sink's buffer (tmc_alloc_etr_buffer()), as this is the first callback invoked for a perf session. As a result, we can keep to set the sysfs mode in tmc_enable_etr_sink_sysfs(). A side topic is we need to refactor the tmc_etr_get_sysfs_buffer() function, ideally this function is purely for allocating buffer without any locking. We can defer to assign "drvdata->sysfs_buf" until acquired spin lock in tmc_enable_etr_sink_sysfs(). Essetionally, we can enable sink in one go rather than acquire-release lock for several times. Thanks, Leo [1] https://lore.kernel.org/linux-arm-kernel/20251020143718.GH281971@e132581.arm.com/