Skip to content

Multi core series -- cache & consistency - #4221

Merged
keyonjie merged 2 commits into
thesofproject:mainfrom
keyonjie:multi_core
May 25, 2021
Merged

keyonjie merged 2 commits into
thesofproject:mainfrom
keyonjie:multi_core

Conversation

@keyonjie

Copy link
Copy Markdown
Contributor

For dw dma controllers and channels, they are shared to multiple pipelines and cores.
For dai config and ssp config, the configuration may happen on different core with the one on the active time.

Add cache invalidate and writeback to ensure the consistency, to address issue #3953

Comment thread src/drivers/dw/dma.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else looks good, not sure why this is going away though. What was the logic here and why is this no longer needed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie this code clears all the DONE bits in the LLI that's be written by HW. If these bits are not clear then DMA will stop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulstelian97 @lgirdwood this part is covered by above Zephyr lines:

		for (i = 0; i < channel->desc_count; i++)	
			dw_chan->lli[i].ctrl_hi &= ~DW_CTLH_DONE(1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I mean, when we dont use Zephyr ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I mean, when we dont use Zephyr ?

before change,
Zephyr case: do invalidate -> write -> writeback
Non-Zephyr case: just write.
after my change,
unified for Zephyr and Non-Zephyr cases('#if defined ZEPHYR' is removed): do invalidate -> write -> writeback

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is racy and there is no easy way around it. We are racing against the DMAC writing back the LLI data which could occur during this loop. This may be safer if we allocate LLI as an uncache region. i.e. both DW driver and DMAC use the uncache address for LLI.

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we are good for alh and dmic ?

Comment thread src/drivers/dw/dma.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keyonjie this code clears all the DONE bits in the LLI that's be written by HW. If these bits are not clear then DMA will stop.

@keyonjie
keyonjie marked this pull request as draft May 20, 2021 12:40
@keyonjie

Copy link
Copy Markdown
Contributor Author

looks this fail on APL, mark it draft as debugging needed.

Comment thread src/drivers/dw/dma.c Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spurious line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corresponding to the line 829, an empty line between variables and codes.

@keyonjie

Copy link
Copy Markdown
Contributor Author

SOFCI TEST

@keyonjie
keyonjie force-pushed the multi_core branch 2 times, most recently from c694029 to 46152d3 Compare May 24, 2021 06:11

@lgirdwood lgirdwood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it probably make a lot more sense to allocate shared configuration data using the uncached alias, this way we dont have to manually remember to inv or wb and it keeps the code simpler.
Btw, there is still a CI failure in APL nocodec.

Comment thread src/drivers/dw/dma.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be after the spin_lock (since the lock has a memory barrier built in)

Comment thread src/drivers/dw/dma.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before the unlock

Comment thread src/drivers/dw/dma.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is racy and there is no easy way around it. We are racing against the DMAC writing back the LLI data which could occur during this loop. This may be safer if we allocate LLI as an uncache region. i.e. both DW driver and DMAC use the uncache address for LLI.

@paulstelian97

paulstelian97 commented May 24, 2021 •

Copy link
Copy Markdown
Collaborator

I think it probably make a lot more sense to allocate shared configuration data using the uncached alias, this way we dont have to manually remember to inv or wb and it keeps the code simpler.

While this is probably fine for now, the code should be compatible with switching back to being able to correctly support either; if i.MX ever comes up with a multicore DSP, well we don't have uncached aliases so we'd have to use cached memory for that.

@lgirdwood

Copy link
Copy Markdown
Member

I think it probably make a lot more sense to allocate shared configuration data using the uncached alias, this way we dont have to manually remember to inv or wb and it keeps the code simpler.

While this is probably fine for now, the code should be compatible with switching back to being able to correctly support either; if i.MX ever comes up with a multicore DSP, well we don't have uncached aliases so we'd have to use cached memory for that.

Agree, but the driver will be fully integrated with Zephyr at this point so that would then have to align with any Zephyr cache APIs.

@keyonjie
keyonjie marked this pull request as ready for review May 24, 2021 14:55
@keyonjie
keyonjie requested a review from bardliao as a code owner May 24, 2021 14:55
@keyonjie

Copy link
Copy Markdown
Contributor Author

@lgirdwood @paulstelian97 I just change to use small change as @lgirdwood suggested, allocated shared uncached memory where needed, now the change is very minor while addressing multi-core issue.

@keyonjie
keyonjie requested a review from lgirdwood May 24, 2021 14:58
@keyonjie

Copy link
Copy Markdown
Contributor Author

SOFCI TEST

keyonjie added 2 commits May 24, 2021 23:00
The DMA channels need to be shared among pipelines and DSP cores,
allocate buffer for it in RUNTIME_SHARED area.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
The dd and dai_spec_config need to be shared among DSP cores, allocate
them in RUNTIME_SHARED area.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
@lgirdwood

Copy link
Copy Markdown
Member

This should go for rc3

@lgirdwood lgirdwood added this to the v1.8 milestone May 24, 2021
@lgirdwood

Copy link
Copy Markdown
Member

@keyonjie CI looking clean now - we can ignore the DUT boot failure. Lets takes for rc3. @slawblauciak fyi

@keyonjie
keyonjie requested review from paulstelian97 and ranj063 May 25, 2021 00:12
@keyonjie

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing, as it is minor change and fixes multi-core xrun issue, I will merge it myself.

@keyonjie
keyonjie merged commit c8589b9 into thesofproject:main May 25, 2021
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.

5 participants