Skip to content
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

Support PSRAM in DmaTxBuf #2161

Merged
merged 25 commits into from
Sep 24, 2024
Merged

Support PSRAM in DmaTxBuf #2161

merged 25 commits into from
Sep 24, 2024

Conversation

liebman
Copy link
Contributor

@liebman liebman commented Sep 15, 2024

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the Migration Guide.
  • My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Description

This PR adds support for PSRAM in DmaTxBuf allowing DMA transfers out from PSRAM.

Some observations:

  • it seems to only work with octal PSRAM
  • there seem to be some edge cases where
    • changing the CHUNK_SIZE makes it work or fail
    • changing the BUFFER_SIZE makes it work or fail

Testing

  • I added an example
  • I added a hardware test that passes

@bugadani
Copy link
Contributor

(and 100% fails on an esp32s3 with psram-2m)

Lovely, maybe it has something to do with the reduced bandwidth of QSPI vs OSPI?

esp-hal/src/dma/mod.rs Outdated Show resolved Hide resolved
@liebman
Copy link
Contributor Author

liebman commented Sep 15, 2024

(and 100% fails on an esp32s3 with psram-2m)

Lovely, maybe it has something to do with the reduced bandwidth of QSPI vs OSPI?

Actually I think it was because one of my modules only has quad psram-2m and I had it configured for opsram-2m

example seems to work now

esp-hal/src/dma/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/dma/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/dma/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/dma/mod.rs Outdated Show resolved Hide resolved
@liebman liebman marked this pull request as ready for review September 18, 2024 22:55
esp-hal/src/dma/mod.rs Outdated Show resolved Hide resolved
@liebman liebman force-pushed the dma-psram-tx-buf branch 2 times, most recently from fe8ef3a to 68f076a Compare September 19, 2024 19:43
Copy link
Collaborator

@Dominaezzz Dominaezzz left a comment

Choose a reason for hiding this comment

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

LGTM fwiw

Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

esp-hal/src/dma/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/dma/mod.rs Show resolved Hide resolved
Copy link
Contributor

@bugadani bugadani left a comment

Choose a reason for hiding this comment

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

Thanks, provided that the tests pass, this looks good to me, too.

@bugadani bugadani added this pull request to the merge queue Sep 24, 2024
Merged via the queue into esp-rs:main with commit cf9050d Sep 24, 2024
28 checks passed
@liebman liebman deleted the dma-psram-tx-buf branch September 24, 2024 16:18
@liebman
Copy link
Contributor Author

liebman commented Sep 24, 2024 via email

@bugadani
Copy link
Contributor

bugadani commented Sep 24, 2024

I mixed up the two enums. 🤷‍♂️ There likely should be only one, and we should convert it differently depending on the place of use.

return Err(DmaBufError::UnsupportedMemoryRegion);
}
// if its PSRAM, the block_size/alignment must be specified
if is_slice_in_psram(buffer) && block_size.is_none() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we do any validation here, so in theory, could we simplify all this? Could we, instead of erroring if block_size is None, assume the strictest alignment requirement, and use that for our chunk size? If yes, do we even need manually specifying block_size? The difference between 4080 and 4032 byte chunks sounds mostly negligible to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we do any validation here

Isn't this the validation? Oh you mean that we don't check that the buffer aligns to the block size? That's because it's TX, fair it could be skipped.

imo the user should be able to choose and the choice should be explicit. Using bigger block sizes has bandwidth consequences for PSRAM.

Would moving the psram support to a different type get out of your way?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would moving the psram support to a different type get out of your way?

This isn't exactly in my way, I was just wondering. But I missed the bandwidth part of the question so I'm fine with the rest :)

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