Bug while creating the first i/o completion queue (NVMe over PCIe)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
osdev199
Posts: 16
Joined: Tue Apr 16, 2024 9:50 am

Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by osdev199 »

Hi, in my nvme driver, while creating the first i/o completion queue, it is failing with the status code 2 (Invalid Field in Command). I have double checked my commands and still can't figure out which cmd is invalid.

Here are my commands: https://pastebin.com/PYiL0WJA . I'm testing my driver on my real machine.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by Octocontrabass »

osdev199 wrote: Mon Aug 05, 2024 6:55 amit is failing with the status code 2
What's the status code type?
osdev199
Posts: 16
Joined: Tue Apr 16, 2024 9:50 am

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by osdev199 »

status code type is 1 (Command Specific Status).
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by Octocontrabass »

When the status code type is 1, status code 2 means "Maximum Queue Size Exceeded". Use CAP.MQES to choose a valid queue size.
osdev199
Posts: 16
Joined: Tue Apr 16, 2024 9:50 am

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by osdev199 »

Thank you. Before creating the i/o completion queue, I was reading the CAP register value. Accidentally I was doing `*addr = value` instead of `value = *addr`. I fixed this and I checked that the queue size i.e. 64 commands is valid. Still I'm getting the same error status.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by Octocontrabass »

What is the value of the CAP register?

Have you tried your driver in a virtual machine like QEMU?
osdev199
Posts: 16
Joined: Tue Apr 16, 2024 9:50 am

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by osdev199 »

CAP register value = 0x300a0103ff

I have tried running it on qemu too but launching qemu fails with "gtk initialization failed". I haven't been able to solve this issue yet!
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by Octocontrabass »

How are you launching QEMU? How did you install QEMU?
osdev199
Posts: 16
Joined: Tue Apr 16, 2024 9:50 am

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by osdev199 »

Code: Select all

$ qemu-system-x86_64 -M q35 -smbios type=0,uefi=on -bios /usr/share/ovmf/OVMF.fd -enable-kvm -cpu host -drive format=raw,file=disk.img,if=none,id=NVME1 -device nvme,drive=NVME1,serial=nvme-1 -trace pci_nvme*
I don't remember how did I install it. But as far as I know, when I added a password to my user account recently, this error began to appear. I'm already using `export DISPLAY=:0` in my .bashrc.
osdev199
Posts: 16
Joined: Tue Apr 16, 2024 9:50 am

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by osdev199 »

After asking on #qemu irc channel, I changed the DISPLAY value to 1 and it worked. Now in qemu, while resetting the controller during initialization, on clearing the CC.EN (bit #0) to 0, and writing it back, the new CC register value becomes 0 don't know why. However, the driver halts a bit later on the fatal error: CSTS.CFS is not 0!

I'm pasting the screenshot: https://drive.google.com/file/d/1Ay_8w7 ... sp=sharing
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by Octocontrabass »

You need to choose reasonable values for CC.IOSQES and CC.IOCQES.
mleks
Posts: 8
Joined: Fri May 31, 2024 2:05 am

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by mleks »

Please take a look at my code on this matter: https://github.com/MaciekLeks/bebok/blo ... e.zig#L905 . I have resolved the issue with sc=0x02 for sct=0x01. Now I'm struggling with sc=0x08. Good luck!
osdev199
Posts: 16
Joined: Tue Apr 16, 2024 9:50 am

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by osdev199 »

I don't like the virtual machine.

The others drivers I have checked have the same commands as mine and they are working fine.

If so, then why am I getting the error?
osdev199
Posts: 16
Joined: Tue Apr 16, 2024 9:50 am

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by osdev199 »

You can also resume the discussion in the issue that I have opened in the project:

https://github.com/robstat7/Raam/issues/4
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bug while creating the first i/o completion queue (NVMe over PCIe)

Post by Octocontrabass »

mleks wrote: Thu Aug 08, 2024 5:27 amsc=0x08
Invalid Interrupt Vector. You're using pin-based interrutps, so the interrupt vector needs to be 0. If you switch to MSI or MSI-X, the interrupt vector is the index in the list of MSI(-X) interrupts you've configured on the NVMe controller. The interrupt vector you need to use here is not the same as a CPU interrupt vector.
osdev199 wrote: Thu Aug 08, 2024 7:00 amI don't like the virtual machine.
Does your code work in the virtual machine?
Post Reply