-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed bug that copy order incorrect at host component. #9426
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,6 +194,8 @@ static uint32_t host_get_copy_bytes_one_shot(struct host_data *hd, struct comp_d | |
*/ | ||
static int host_copy_one_shot(struct host_data *hd, struct comp_dev *dev, copy_callback_t cb) | ||
{ | ||
struct comp_buffer *source; | ||
struct comp_buffer *sink; | ||
uint32_t copy_bytes = 0; | ||
int ret = 0; | ||
|
||
|
@@ -212,6 +214,17 @@ static int host_copy_one_shot(struct host_data *hd, struct comp_dev *dev, copy_c | |
return ret; | ||
} | ||
|
||
if (dev->direction == SOF_IPC_STREAM_CAPTURE) | ||
{ | ||
source = hd->local_buffer; | ||
sink = hd->dma_buffer; | ||
comp_info(dev, "bf cp local buf addr %p end %p w %p r %p", source->stream.addr, source->stream.end_addr, source->stream.w_ptr, source->stream.r_ptr); | ||
comp_info(dev, "bf cp dma addr %p end %p w %p r %p", sink->stream.addr, sink->stream.end_addr, sink->stream.w_ptr, sink->stream.r_ptr); | ||
ret = dma_buffer_copy_to(source, sink, hd->process, copy_bytes); | ||
comp_info(dev, "af cp local buf addr %p end %p w %p r %p", source->stream.addr, source->stream.end_addr, source->stream.w_ptr, source->stream.r_ptr); | ||
comp_info(dev, "af cp dma addr %p end %p w %p r %p", sink->stream.addr, sink->stream.end_addr, sink->stream.w_ptr, sink->stream.r_ptr); | ||
} | ||
|
||
ret = dma_copy_legacy(hd->chan, copy_bytes, DMA_COPY_ONE_SHOT); | ||
if (ret < 0) { | ||
comp_err(dev, "host_copy_one_shot(): dma_copy() failed, ret = %u", ret); | ||
|
@@ -226,18 +239,14 @@ void host_common_update(struct host_data *hd, struct comp_dev *dev, uint32_t byt | |
{ | ||
struct comp_buffer *source; | ||
struct comp_buffer *sink; | ||
int ret; | ||
int ret = 0; | ||
bool update_mailbox = false; | ||
bool send_ipc = false; | ||
|
||
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) { | ||
source = hd->dma_buffer; | ||
sink = hd->local_buffer; | ||
ret = dma_buffer_copy_from(source, sink, hd->process, bytes, DUMMY_CHMAP); | ||
} else { | ||
source = hd->local_buffer; | ||
sink = hd->dma_buffer; | ||
ret = dma_buffer_copy_to(source, sink, hd->process, bytes, DUMMY_CHMAP); | ||
} | ||
Comment on lines
-237
to
250
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chihualee any update, this part looks wrong as capture uses the DMA buffer for sink, unless your device has no DMA to copy data to host driver from DSP (i.e. you have shared memory) ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My capture mechanism is almost the same as original legacy-host, src/audio/host-legacy.c |
||
|
||
/* assert dma_buffer_copy succeed */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check existing git commits in this project for examples on how to write git commit. SOF follows similar practises as Linux kernel and Zephyr. One git commit per logical change, proper summary line, explains what bug you are fixing, etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please explain what order is incorrect. AFAICT you're only moving the dma_buffer_copy_to() for the one shot case and this will break normal copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranj063
sorry, I am new to GitHub.
As mentioned in https://github.com/orgs/thesofproject/discussions/9362,
For capture stream scenario, I find a bug that copying order incorrect in Host component.
The copy order should be: Local-buffer => DMA-buffer => Host-buffer.
But actually it is first DMA-buffer => Host-buffer, then Local-buffer => DMA-buffer.
I think host_copy_one_shot() is correct for playback, but incorrect for capture.
So my patch is let host copy change into Local-buffer => DMA-buffer => Host-buffer:
Just move (copy from Local-buffer to DMA-buffer)
from host_common_update() to host_copy_one_shot().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kv2019i
sorry, I am new to GitHub.
I think we discuss bug and solution first.
Finally, if the patch is fine I will modify the commit log more normally.