Skip to content

Print full CSTS value when NVMe device failed to init #1401

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yupavlen-ms
Copy link
Contributor

With the emulated devices likely it will be 0x00000000 or 0xFFFFFFFF but we need to distinguish the cases for further diagnostics.

@yupavlen-ms yupavlen-ms requested review from a team as code owners May 22, 2025 18:04
@@ -226,7 +226,7 @@ impl<T: DeviceBacking> NvmeDriver<T> {
))
.await
{
anyhow::bail!("device is gone");
anyhow::bail!("device is gone, csts: {:x}", u32::from(bar0.csts()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these all have slightly different messages too to distinguish them from one another?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was my concern because I can't distinguish one from another, but I thought printing the full csts value will help figuring it out anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

Up to you

@@ -329,7 +329,7 @@ impl<T: DeviceBacking> NvmeDriver<T> {
loop {
let csts = worker.registers.bar0.csts();
if u32::from(csts) == !0 {
anyhow::bail!("device is gone");
anyhow::bail!("device is gone, csts: {:x}", u32::from(csts));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: store the u32::from result in a var, or just hardcode it since we know what it is thanks to the if

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this one let me add a variable. I think this code makes an assumption that failed emulated device returns 0xffffffff on read, but I am not sure if that's guaranteed.

smalis-msft
smalis-msft previously approved these changes May 22, 2025
Copy link
Member

@jstarks jstarks left a comment

Choose a reason for hiding this comment

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

reviewing

@@ -226,7 +226,7 @@ impl<T: DeviceBacking> NvmeDriver<T> {
))
.await
{
anyhow::bail!("device is gone");
anyhow::bail!("device is gone, csts: {:x}", u32::from(bar0.csts()));
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you should read the value again. Either leave this one out (we know reset only fails if csts == -1), or have reset return Result<(), u32>, where the error case is the csts value, and log that.

@@ -565,7 +566,7 @@ impl<T: DeviceBacking> NvmeDriver<T> {

// It is expected the device to be alive when restoring.
if !bar0.csts().rdy() {
anyhow::bail!("device is gone");
anyhow::bail!("device is gone, csts: {:x}", u32::from(bar0.csts()));
Copy link
Member

Choose a reason for hiding this comment

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

Don't re-read csts, the value could be different on the next read and that could create confusion.

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