Opened 5 years ago

Last modified 2 months ago

#9910 new enhancement

NVMe devices support

Reported by: korli Owned by: nobody
Priority: high Milestone: R1
Component: Drivers/Disk Version: R1/Development
Keywords: NVMe Cc: luroh, phoudoin
Blocked By: Blocking: #14454
Has a Patch: no Platform: All

Description

Qemu 1.6+ offers support for this device type.

Change History (17)

comment:1 Changed 5 years ago by korli

Version: R1/alpha4.1R1/Development

comment:2 Changed 5 years ago by korli

Type: bugenhancement

comment:3 Changed 2 years ago by kallisti5

High level: NVMe is a alternate attachment of SSD devices directly to the PCIe bus. NVMe devices use a "lightweight" communication protocol which is used instead of AHCI.

https://en.wikipedia.org/wiki/NVM_Express

NVMe essentially replaces AHCI for SSD devices. We likely need to get more information on NVMe and see if AHCI can be used until native NVMe support is created.

Since i'm pretty sure AHCI is still available on NVMe devices, i'm dropping the priority of this ticket for now. If the AHCI emulation ever goes away (or isn't available 100% of the time) we should bump up the priority of this one.

comment:4 Changed 2 years ago by kallisti5

Priority: normallow

comment:5 Changed 2 years ago by kallisti5

Keywords: NVMe added

comment:6 in reply to:  3 Changed 2 years ago by korli

Replying to kallisti5:

Since i'm pretty sure AHCI is still available on NVMe devices, i'm dropping the priority of this ticket for now. If the AHCI emulation ever goes away (or isn't available 100% of the time) we should bump up the priority of this one.

I really wonder where you got the idea that NVMe devices can be used with AHCI emulation. Care to elaborate since you're "sure"? :)

comment:7 Changed 2 years ago by kallisti5

Hm. I did a bit more reading and you're correct. I saw mentions of NVMe aware BIOS AHCI emulation, but it was more of a "BIOS has support to boot directly from NVMe devices"

So yeah, NVMe is actually *really* important as we won't support installing to systems with NVMe devices (and those systems seem to be growing in numbers)

Bumping this one to high.

The "workaround" for now is to purchase M.2 SSD's that aren't NVMe :-|

comment:8 Changed 2 years ago by kallisti5

Priority: lowhigh

comment:9 Changed 2 years ago by kallisti5

Linux kernel NVMe PCIe identification: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/nvme/host/pci.c#n2101

FreeBSD driver: https://github.com/freebsd/freebsd/tree/master/sys/dev/nvme

It doesn't look like *too* daunting of a project (esp since QEMU seems to emulate it)

Maybe someone out there will feel zesty and take a crack at it :-)

comment:10 Changed 2 years ago by kallisti5

I don't think we need to implement a bus like AHCI, IDE, SCSI, etc. Since NVMe devices are attached like PCIe devices, there really isn't a common controller. As such any implementation should likely live here:

http://cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/drivers/disk

The norflash or usb_disk driver would make a good template as it attaches a random block device as a drive:

http://cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/drivers/disk/norflash http://cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/drivers/disk/usb/usb_disk

Examples of drivers detecting supported PCI/PCIe devices:

http://cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/drivers/graphics/nvidia/driver.c http://cgit.haiku-os.org/haiku/tree/src/add-ons/kernel/drivers/graphics/radeon_hd/driver.cpp

comment:11 Changed 19 months ago by luroh

Cc: luroh added

comment:12 Changed 17 months ago by phoudoin

Cc: phoudoin added

comment:13 Changed 17 months ago by phoudoin

VirtualBox emulates NVMe controllers too since 5.1.22, FYI.

comment:14 Changed 6 months ago by waddlesplash

There's a BSD-licensed userspace NVMe implementation here: https://github.com/hgst/libnvme

It needs libpciaccess (which we have a working port of) and libnuma (which we do not), but it doesn't look like porting it to kernel space and Haiku-specific APIs would be too hard.

comment:15 Changed 2 months ago by KapiX

Blocking: 14454 added

comment:16 Changed 2 months ago by cb88

All M.2 SSD's can optionally support SATA, however it's common for the faster ones to only support NVME without backward compatibility. Both B and M key interfaces support Sata, but even then there is no guarantee that the mobo or ssd supports both. I'd imagine in bios emulation of AHCI for purely NVME devices is almost nonexistant.

B key = 2x PCIE + SATA (you have to check your drive and mobo specs)
M key = 4x PCIE + SATA       "                              "
B+M key = SATA (always as it lacks the PCIE I/O)

An M keyed drive is least likely to support SATA.

Haiku should probably put Host Memory Buffer support for NVMe drives on the TODO list also. As it allows a massive speed, up for recent cheaper, and therefore common, "cacheless" drives. This basically means dedicating a chunk of memory to the SSD similar to integrated graphics. https://www.flashmemorysummit.com/English/Collaterals/Proceedings/2015/20150813_FJ31_Chen_Dorgello.pdf

Last edited 2 months ago by cb88 (previous) (diff)

comment:17 Changed 2 months ago by waddlesplash

AFAIK, "Host Memory Buffer" support is pretty trivial to add once you bring up the controller itself.

I started work on a NVMe driver offline based on libnvme; I should get it posted somewhere.

Note: See TracTickets for help on using tickets.