Skip to content

ASoC: SOF: trace: sdev->host_offset management changes#3516

Merged
plbossart merged 2 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/dtrace_print_offsets_01
May 20, 2022
Merged

ASoC: SOF: trace: sdev->host_offset management changes#3516
plbossart merged 2 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/dtrace_print_offsets_01

Conversation

@ujfalusi

Copy link
Copy Markdown
Collaborator

Hi,

The READ_ONCE(sdev->host_offset) alone does nothing to prevent any race regarding to host_offset change race prevention.
Introduce a new helper to do this in a correct way and while at it, print out the new offset for us to see where we are.

Additional debug prints can be added to track what is copied to user space with a simple change:

diff --git a/sound/soc/sof/trace.c b/sound/soc/sof/trace.c
index 76c763da5804..32c3c0d8a75e 100644
--- a/sound/soc/sof/trace.c
+++ b/sound/soc/sof/trace.c
@@ -334,8 +334,10 @@ static ssize_t sof_dfsentry_trace_read(struct file *file, char __user *buffer,
 	}
 
 	/* no new trace data */
-	if (!avail)
+	if (!avail) {
+		dev_dbg(sdev->dev, "trace: nothing to copy\n");
 		return 0;
+	}
 
 	/* make sure count is <= avail */
 	if (count > avail)
@@ -349,6 +351,8 @@ static ssize_t sof_dfsentry_trace_read(struct file *file, char __user *buffer,
 	 */
 	snd_dma_buffer_sync(&sdev->dmatb, SNDRV_DMA_SYNC_CPU);
 	/* copy available trace data to debugfs */
+	dev_dbg(sdev->dev, "trace: copy to user from offset : %#llx, count: %#zx\n",
+		lpos, count);
 	rem = copy_to_user(buffer, ((u8 *)(dfse->buf) + lpos), count);
 	if (rem)
 		return -EFAULT;

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants