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

[feat] add nvme support #205

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[feat] add nvme support #205

wants to merge 1 commit into from

Conversation

ZR233
Copy link
Contributor

@ZR233 ZR233 commented Nov 27, 2024

  1. add aarch64 dcache clean and invalid funcs.
  2. add nvme driver.

@ZR233 ZR233 force-pushed the phytium_pi branch 5 times, most recently from 4aee9a5 to bd39c2b Compare November 27, 2024 02:35
modules/axdriver/src/bus/pci.rs Outdated Show resolved Hide resolved
modules/axhal/src/arch/riscv/cache.rs Outdated Show resolved Hide resolved
modules/axhal/src/arch/x86_64/cache.rs Outdated Show resolved Hide resolved
@@ -57,6 +57,9 @@ pub mod irq;
#[cfg(feature = "paging")]
pub mod paging;

#[cfg(feature = "alloc")]
mod dma;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is extremely strange, why the dma mod is decorated under #[cfg(feature = "alloc")]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dma-api use normal alloc api to alloc Vec.

Copy link
Contributor

Choose a reason for hiding this comment

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

Dma-api use normal alloc api to alloc Vec.

I just do not get it, generally, the size of dma region is known and fixed, why a Vec is needed since it's usually related to dynamically arrays with unknown size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dma use global allocator.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can delete this now?

@@ -0,0 +1,26 @@
use dma_api::Impl;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the Impl trait exposed by dma-api crate is strange.

I believe that you want to use this trait for the translation from IOVA to actual PA

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you can refer to the DMA addr related trait defined in virtio-drivers?

https://github.com/rcore-os/virtio-drivers/blob/master/src/hal.rs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This crate is not just about converting virtual addresses into physical addresses,but also got dma direction usage by map func, when read from data, crate will invlid cache, when write, it will flush back from cache to memory, so that we can use normal type memory for dma, and direct use upstream &[u8] without copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When use &mut [u8] from os, map to dma slice type, and when give back &[u8] to os, umap to normal memory. If use like virtio-drivers, we need to copy &[u8] to no cache type memory for dma and copy back to &[u8] for send to os.

Copy link
Contributor

@hky1999 hky1999 Nov 28, 2024

Choose a reason for hiding this comment

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

Sorry, I need to learn how dma_api works before offering any more valuable suggestions.

kind of busy lately, so this may take a little bit longer

scripts/make/qemu.mk Outdated Show resolved Hide resolved
modules/axdriver/src/lib.rs Outdated Show resolved Hide resolved
modules/axdriver/src/bus/pci.rs Outdated Show resolved Hide resolved
@ZR233 ZR233 force-pushed the phytium_pi branch 3 times, most recently from c55cdad to 3f0576d Compare November 28, 2024 02:41
@ZR233 ZR233 requested a review from hky1999 November 28, 2024 03:10
@@ -57,6 +57,9 @@ pub mod irq;
#[cfg(feature = "paging")]
pub mod paging;

#[cfg(feature = "alloc")]
mod dma;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can delete this now?

@@ -0,0 +1,26 @@
use dma_api::Impl;
Copy link
Contributor

@hky1999 hky1999 Nov 28, 2024

Choose a reason for hiding this comment

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

Sorry, I need to learn how dma_api works before offering any more valuable suggestions.

kind of busy lately, so this may take a little bit longer

}
}

dma_api::set_impl!(DmaImpl);
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, this is kind of strange, too.

Copy link
Contributor Author

@ZR233 ZR233 Nov 28, 2024

Choose a reason for hiding this comment

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

It a good way for singleton trait. It is widely used in embedded-hal group, like critical-section

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