Page 1 of 2
Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Mon Aug 05, 2024 6:55 am
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.
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Mon Aug 05, 2024 11:09 am
by Octocontrabass
osdev199 wrote: ↑Mon Aug 05, 2024 6:55 amit is failing with the status code 2
What's the status code type?
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Mon Aug 05, 2024 11:15 am
by osdev199
status code type is 1 (Command Specific Status).
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Mon Aug 05, 2024 11:50 am
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.
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Mon Aug 05, 2024 6:06 pm
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.
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Mon Aug 05, 2024 8:39 pm
by Octocontrabass
What is the value of the CAP register?
Have you tried your driver in a virtual machine like QEMU?
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Tue Aug 06, 2024 12:05 am
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!
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Tue Aug 06, 2024 1:24 am
by Octocontrabass
How are you launching QEMU? How did you install QEMU?
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Tue Aug 06, 2024 1:53 am
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.
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Tue Aug 06, 2024 1:46 pm
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
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Tue Aug 06, 2024 5:45 pm
by Octocontrabass
You need to choose reasonable values for CC.IOSQES and CC.IOCQES.
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Thu Aug 08, 2024 5:27 am
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!
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Thu Aug 08, 2024 7:00 am
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?
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Thu Aug 08, 2024 7:03 am
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
Re: Bug while creating the first i/o completion queue (NVMe over PCIe)
Posted: Thu Aug 08, 2024 8:21 pm
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?