-
Notifications
You must be signed in to change notification settings - Fork 324
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
Fixes for HDA-DMA driver #4820
Fixes for HDA-DMA driver #4820
Conversation
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.
Not fully clear on some simplifications - but the initial code is already confusing...
src/drivers/intel/hda/hda-dma.c
Outdated
@@ -407,8 +407,7 @@ static int hda_dma_enable_unlock(struct dma_chan_data *channel) | |||
} | |||
|
|||
/* start link output transfer now */ | |||
if (channel->direction == DMA_DIR_MEM_TO_DEV && | |||
!(hda_chan->state & HDA_STATE_RELEASE)) | |||
if (channel->direction == DMA_DIR_MEM_TO_DEV) |
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.
I wasn't able to follow that simplification.
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.
the only thing release ever did was to start host DMA but we never pause/release the host DMA in the first place, so the preovious patch removed that. With that, release literally does nothing now
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.
but we still set the HDA_STATE_RELEASE bit? I am officially confused!
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.
that bit is used to do 2 things: 1. releae host DMA which will never happen because we do no release host DMA. 2. prevent incrementing the firmware pointer for release which actually results in an xrun. But it isnt a register BIT just a state bit we used for the above 2 things. So its no longer needed
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.
so can we remove line 414 as well and even the definition of HDA_STATE_RELEASE?
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.
but I have removed the defitnion of HDA_STATE_RELEASE, no? not sure what 414 is, probably clearing the state and I' have removed that as well
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.
TBH, I would lump all the HDA DMA driver RELEASE removal into one patch.
if (channel->direction == DMA_DIR_HMEM_TO_LMEM || | ||
channel->direction == DMA_DIR_LMEM_TO_HMEM) | ||
ret = hda_dma_host_start(channel); | ||
|
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.
Same, not able to follow this simplification - not sure why we did a host_start in a dma_release in the first place.
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.
yeah, this change looks unrelated to RELEASE removal ? Line 570 also sets the RELEASE state, should we remove RELEASE completely ?
src/drivers/intel/hda/hda-dma.c
Outdated
tr_err(&hdma_tr, "hda_dma_link_check_xrun(): overrun detected"); | ||
dma_chan_reg_update_bits(chan, DGCS, DGCS_BOR, DGCS_BOR); | ||
return -ENODATA; |
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.
doesn't this need additional changes in the caller as mentioned by @lyakh ?
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.
I think his comment was for my host changes and I fixed that in my other PR. This one is correct isnt it?
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.
I can't recall precisely the issue... Just wanted to check that this change is legit.
SOFCI TEST |
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.
Quite a lot of red on CI pause tests, this PR could be split to upstream the low risk updates first.
if (channel->direction == DMA_DIR_HMEM_TO_LMEM || | ||
channel->direction == DMA_DIR_LMEM_TO_HMEM) | ||
ret = hda_dma_host_start(channel); | ||
|
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.
yeah, this change looks unrelated to RELEASE removal ? Line 570 also sets the RELEASE state, should we remove RELEASE completely ?
src/drivers/intel/hda/hda-dma.c
Outdated
@@ -407,8 +407,7 @@ static int hda_dma_enable_unlock(struct dma_chan_data *channel) | |||
} | |||
|
|||
/* start link output transfer now */ | |||
if (channel->direction == DMA_DIR_MEM_TO_DEV && | |||
!(hda_chan->state & HDA_STATE_RELEASE)) | |||
if (channel->direction == DMA_DIR_MEM_TO_DEV) |
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.
TBH, I would lump all the HDA DMA driver RELEASE removal into one patch.
src/drivers/intel/hda/hda-dma.c
Outdated
(!config->cyclic && config->direction == DMA_DIR_LMEM_TO_HMEM)) | ||
/* set DGCS.FIFORDY for host output dma */ | ||
if ((config->cyclic && config->direction == DMA_DIR_HMEM_TO_LMEM) || | ||
(config->cyclic && config->direction == DMA_DIR_LMEM_TO_HMEM)) |
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.
assuming the removal of the negation is indeed intentional and a fix, apart from making it a separate patch as @plbossart is suggesting, please also then simplify the test as
if (config->cyclic &&
(config->direction == DMA_DIR_HMEM_TO_LMEM ||
config->direction == DMA_DIR_LMEM_TO_HMEM))
src/drivers/intel/hda/hda-dma.c
Outdated
@@ -407,8 +407,7 @@ static int hda_dma_enable_unlock(struct dma_chan_data *channel) | |||
} | |||
|
|||
/* start link output transfer now */ | |||
if (channel->direction == DMA_DIR_MEM_TO_DEV && | |||
!(hda_chan->state & HDA_STATE_RELEASE)) | |||
if (channel->direction == DMA_DIR_MEM_TO_DEV) |
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.
I'm probably missing something, I thought DMA_DIR_MEM_TO_DEV
was only for link DMA playback?
34dc488
to
6a57aa4
Compare
@plbossart @lgirdwood I've dropped a couple of patches in this series. 1. to drop the release for link DMA. Even though this helps with the xrun, it doesnt completely avoid it. 2. return the right error in case of xrun. This is still TBD. We'll have to wait until I have a proper working solution for this. |
6a57aa4
to
cea55e1
Compare
https://sof-ci.01.org/sof-pr-viewer/#/build/PR4820/build7404529 is green but incomplete. |
https://sof-ci.01.org/sofpr/PR4820/build10517/devicetest/ is green but missing all firmware logs because of some internal issue. Restarting it. EDIT: still no firmware logs in https://sof-ci.01.org/sofpr/PR4820/build10520/devicetest/. Issue reported internally. EDIT2 https://sof-ci.01.org/sofpr/PR4820/build10520/devicetest/?model=CML_RVP_SDW&testcase=check-playback-10sec has firmware logs but https://sof-ci.01.org/sofpr/PR4820/build10520/devicetest/?model=CML_RVP_SDW&testcase=check-sof-logger has none. |
SOFCI TEST |
/* set DGCS.FIFORDY for output dma */ | ||
if (config->direction == DMA_DIR_MEM_TO_DEV || config->direction == DMA_DIR_LMEM_TO_HMEM) | ||
/* set DGCS.FIFORDY for host DMA for both playback and capture */ | ||
if (config->direction == DMA_DIR_HMEM_TO_LMEM || config->direction == DMA_DIR_LMEM_TO_HMEM) | ||
dgcs |= DGCS_FIFORDY; | ||
|
||
dma_chan_reg_write(channel, DGCS, dgcs); |
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.
Since we set/clear DGCS_FIFORDY explicitly in start/stop, do we need to preset it in _set_config() here?
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.
this seems to directly contradict the stated purpose of f96878a
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.
@lyakh I'm not sure what that specific commit achieved anyway. Before my change, we end up setting the FIFORDY bit for all DMAs unconditionally during START.
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 not sure GH made it clear enough what my comment was referring to. I meant the removal of cyclic support as per your commit comment "config->cyclic is not relevant for HDA DMAs." I'm not sure whether your comment is correct, but I just commented, that it contradicted the original commit, that introduced cyclic DMA support for HDA. Don't know whether that commit was right though.
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.
Maybe best to state in the comments the current feedback on setting DGCS.FIFORDY
from KarL. This way everyone can understand.
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.
@lgirdwood I have updated the commit message and added comments in the next patch for FIFORDY bit updates.
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.
I think I was confused by the commit description phrase "config->cyclic
is not relevant for HDA DMAs." It probably means "this one specific use of config->cyclic
is irrelevant." If it really is trying to say, that the whole config->cyclic
support in HDA DMA is irrelevant, then probably the whole commit f96878a should be reverted.
if (!(hda_chan->state & HDA_STATE_RELEASE)) | ||
pm_runtime_put(PM_RUNTIME_HOST_DMA_L1, 0); | ||
/* Force Host DMA to exit L1 on start */ | ||
pm_runtime_put(PM_RUNTIME_HOST_DMA_L1, 0); |
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.
I think the original logic is that we don't need to force L1 exit for the pause/release iteration, while we need it for a _start, as there will be preloading for a hda_dma_start() while there isn't for the _release().
We do have dma_pause() and dma_release() calling in dai.c, even though there might not be trigger pause/release IPCs from the Linux host side, so I would suggest to keep this as it is in case it doesn't bring any issues like Xruns to us.
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.
@keyonjie DAI uses link DMA and we have the ops for link DMA here. There is no need for host DMA pause/release when it is not used
@@ -979,8 +979,6 @@ const struct dma_ops hda_host_dma_ops = { | |||
.start = hda_dma_start, | |||
.stop = hda_dma_stop, | |||
.copy = hda_dma_host_copy, | |||
.pause = hda_dma_pause, | |||
.release = hda_dma_release, |
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.
"hda_dma_pause/release declared but not used"?
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.
sorry dont get it? it is used in link DMA ops
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.
sorry dont get it? it is used in link DMA ops
Oh, makes sense then, maybe better to rename them to hda_dma_link_pause/release().
@ranj063 CI looks good around the pause states :) are all the opens resolved now ? |
@lgirdwood I dont have any opens. As for @lyakh's comment, the check for FIFORDY bit in set_cnofig is inconsequential anyway, we were setting it unconditionally during START anyway. And I confirmed that we should set it for host DMA for playback and capture |
SOFCI TEST EDIT: re-running because the last run suffered from a CI issue, FW logs were missing, for instance https://sof-ci.01.org/sofpr/PR4820/build10520/devicetest/?model=TGLU_RVP_SDW&testcase=check-sof-logger has no FW logs. |
config->cyclic is not relevant for HDA DMAs. So remove the check for it. We set config->cyclic to 1 for both playback and capture for all DAI's anyway. So the check today would never set FIFORDY for host output DMA during set_config. But nevertheless, during the start trigger, FIFORDY is set for all DMA's unconditionally. That is also incorrect and will be fixed in the following commit. For now, just remove the check for cyclic to prepare for FIFORDY bit cleanup. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
So, leave this bit untouched for link DMA and only set/clear it for the host DMA for both playback and capture. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Host DMA is never paused or released. Remove the code to start host DMA during release and the check for release in hda_dma_host_start(). Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Not all DMA's need a pause/release. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Host DMA is never paused/released. So, remove the pause and release ops from the host DMA ops. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
cea55e1
to
0e092f2
Compare
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.
I only have one comment, but that could be handled in a follow-up PR
/* set DGCS.FIFORDY for output dma */ | ||
if (config->direction == DMA_DIR_MEM_TO_DEV || config->direction == DMA_DIR_LMEM_TO_HMEM) | ||
/* set DGCS.FIFORDY for input/output host DMA only. It is not relevant for link DMA's */ | ||
if (config->direction == DMA_DIR_HMEM_TO_LMEM || config->direction == DMA_DIR_LMEM_TO_HMEM) |
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.
I would agree with @keyonjie that it's not clear why we need to keep setting this FIFORDY bit in hda_dma_set_config(), when it's already set in enable_dma() and cleared in stop_dma()
Part 1 of HDA DMA fixes. Fixes the handling of FIFORDY bits and pause/release cleanups for host/link DMA
EDIT: part 2 is #4844