Home | History | Annotate | Download | only in ic
History log of /src/sys/dev/ic/ld_nvme.c
RevisionDateAuthorComments
 1.26  13-Apr-2025  rin ld(4): Convert blkno argument for sc_dump() to daddr_t

PR kern/59153

(1) For backends that accept 64-bit block address, i.e.,
nvme(4), virtio(4), aac(4), iop(4), and mainbus(usermode/4),
this should enable to dump beyond 2Gi blocks.

(2) sdmmc(4) backend allows to dump up to the last block.

(3) For other backends, block address is handled as `int`.
Some of them may support blocks up to 4Gi, but I do not have
enough time to examine datasheets. So, continue to reject >2Gi
blocks as before.

XXX
This is KABI change, and cannot be pulled up into netbsd-{10,9}.

XXX
Compile-test only (for amd64/ALL) due to lack of large SSDs ;)

Thanks mlelstv@ for discussion and careful review!!
 1.25  30-Jul-2022  mlelstv aprint_error_dev is for autoconfig messages, use device_printf instead.
 1.24  22-Sep-2020  kardel PR kern/55674:
move name space availability check from ld_nvme.c:ld_nvme_attach()
to nvme.c:nvme_rescan().
this avoids allocation of ld(4) instances for every possible
name space, even if it is not usable. it also reduces the device
node flood generated from that strategy.
 1.23  01-Oct-2019  mlelstv Don't attach an ld device if the format descriptor is unsupported/unused.
 1.22  26-Apr-2019  mlelstv branches: 1.22.2;
Expose device type. You can query it with e.g. drvctl -p ld0 disk-info/type.

Missing in previous commit.
 1.21  01-Dec-2018  jdolecek support DIOCSCACHE + DKCACHE_WRITE if volatile write cache is present

fix the Get Features call for DIOCGCACHE to actually retrieve the current
value properly
 1.20  18-Apr-2018  nonaka branches: 1.20.2;
nvmectl(8): Add big-endian support.

from FreeBSD nvmecontolr(8) r329824.
 1.19  16-Mar-2018  jdolecek refactor the locking code around DIOCGCACHE handling to be reusable
for other infrequent commands

it uses single condvar for simplicity, and uses it both when waiting
for ccb or command completion - this is fine, since usually there
will be just one such command qeueued anyway

use this to finally properly implement DIOCCACHESYNC - return only after
the command is confirmed as completed by the controller
 1.18  23-Jan-2018  pgoyette branches: 1.18.2;
Add "bufq_fcfs" requirement to all those driver modules that explicitly
request it in their calls to bufq_alloc().
 1.17  09-Aug-2017  mlelstv branches: 1.17.2;
While ld(4) is MP safe, many backends are not.

Add a flag for backends that are MP safe. Take KERNEL_LOCK when calling
into a backend that doesn't have the flag set. Do the same for the
discard routine.

Fixes PR 52462.
 1.16  27-Apr-2017  jdolecek branches: 1.16.2;
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective
 1.15  05-Apr-2017  jdolecek branches: 1.15.4;
expose disk device FUA/DPO support via DIOCGCACHE, and allow the flags
to be set for I/O; implement support in sd(4) and nvme(4)

discussed on tech-kern
 1.14  28-Feb-2017  jdolecek change DIOCCACHESYNC to not issue the FLUSH command at all when the controller
has no volatile write cache
 1.13  28-Feb-2017  jdolecek implement DIOCGCACHE
 1.12  27-Feb-2017  jdolecek remote extra pasted line
 1.11  27-Feb-2017  jdolecek refactor the ld(4) DIOCCACHESYNC hook into general ioctl hook, so that attachments
would be able to implement arbitrary other ioctls
 1.10  01-Nov-2016  jdolecek branches: 1.10.2;
pass maxphys from device rather then assuming MAXPHYS; it's clipped in ld(4)
if bigger then MAXPHYS

multiply the queue size by number of queues for ld(4) sc_maxqueuecnt, so
that ld_diskstart() would try to use full capacity, instead of throttling
to one queue worth of commands
 1.9  20-Oct-2016  jdolecek revert rev. 1.7 - seems the polling damages command queue on live system
 1.8  27-Sep-2016  pgoyette Modularize the ld driver and all of its attachments. Ensure that all
parents are capable of rescan (or otherwise provide a means of attaching
children post-initialization).
 1.7  20-Sep-2016  jdolecek cache flush call must wait for completion; cap wait to 60 seconds just in case
controller won't respond
 1.6  19-Sep-2016  jdolecek on further thought, just remove the separately allocated nvme_ns_context
altogether and fold into nvme_ccb; allocating this separately just isn't useful
 1.5  18-Sep-2016  jdolecek must use PR_NOWAIT also during ldattach()/dkwedge discover, our i/o is there
called with a spin lock held, which triggers LOCKDEBUG panic
 1.4  18-Sep-2016  jdolecek fix several bugs, make nvme(4) MPSAFE by default and also bump default
number of ioq from 128 to 1024; tested with VirtualBox and QEMU

* remove NVME_INTMC/NVME_INTMS writes in hw intr handler as this is not MPSAFE,
fortunately they don't seem to be necessary; shaves two register writes
* need to use full mutex_enter() in nvme_q_complete(), to avoid small
race between one handler exiting the loop and another entering
* for MSI, handover the command result processing to softintr; unfortunately
can't easily do that for INTx interrupts as they require doorbell write
to deassert
* unlock/relock q->q_cq_mtx before calling ccb_done to avoid potential deadlocks
* make sure to destroy queue mutexes when destroying the queue (LOCKDEBUG)
* make ns ctx pool per-device, so that it's deallocated properly on module
unload
* handle ctx allocation failure in ld_nvme_dobio()
* remove splbio() calls in ld_nvme_dobio() and sync, the paths are exercised
only for dump/shutdown, and that already disables interrupts
* free the ns ctx in ld_nvme_biodone() before calling lddone() to avoid
memory starvation, as lddone() can trigger another i/o request
* be more careful with using PR_WAITOK, the paths are called from interrupt
context and there we can't wait
 1.3  16-Sep-2016  jdolecek change nvme(4) ld to use fcfs as default strategy to lower i/o processing
overhead and hence lower latency; the sorting doesn't provide any benefit
for SSDs
 1.2  16-Sep-2016  jdolecek modify ldattach() to have default strategy as a parameter
 1.1  01-May-2016  nonaka branches: 1.1.2; 1.1.4;
Added nvme(4) for Non-Volatile Memory Host Controller Interface devices.
Ported from OpenBSD.
 1.1.4.3  26-Apr-2017  pgoyette Sync with HEAD
 1.1.4.2  20-Mar-2017  pgoyette Sync with HEAD
 1.1.4.1  04-Nov-2016  pgoyette Sync with HEAD
 1.1.2.5  28-Aug-2017  skrll Sync with HEAD
 1.1.2.4  05-Dec-2016  skrll Sync with HEAD
 1.1.2.3  05-Oct-2016  skrll Sync with HEAD
 1.1.2.2  29-May-2016  skrll Sync with HEAD
 1.1.2.1  01-May-2016  skrll file ld_nvme.c was added on branch nick-nhusb on 2016-05-29 08:44:21 +0000
 1.10.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.15.4.1  02-May-2017  pgoyette Sync with HEAD - tag prg-localcount2-base1
 1.16.2.5  27-Sep-2020  martin Pull up following revision(s) (requested by kardel in ticket #1610):

sys/dev/ic/ld_nvme.c: revision 1.24 (patch)
sys/dev/ic/nvme.c: revision 1.50 (patch)

PR kern/55674:
move name space availability check from ld_nvme.c:ld_nvme_attach()
to nvme.c:nvme_rescan().
this avoids allocation of ld(4) instances for every possible
name space, even if it is not usable. it also reduces the device
node flood generated from that strategy.
 1.16.2.4  28-Oct-2019  martin Pull up following revision(s) (requested by mlelstv in ticket #1417):

sys/dev/ic/ld_nvme.c: revision 1.23

Don't attach an ld device if the format descriptor is unsupported/unused.
 1.16.2.3  19-Apr-2018  martin Pull up following revision(s) (requested by nonaka in ticket #781):

sbin/nvmectl/Makefile 1.4
sbin/nvmectl/bignum.c 1.2
sbin/nvmectl/devlist.c 1.3-1.5
sbin/nvmectl/firmware.c 1.3,1.4
sbin/nvmectl/identify.c 1.3-1.5
sbin/nvmectl/logpage.c 1.5-1.7
sbin/nvmectl/nvme.h 1.3
sbin/nvmectl/nvmectl.8 1.5
sbin/nvmectl/nvmectl.c 1.5-1.7
sbin/nvmectl/nvmectl.h 1.5-1.8
sbin/nvmectl/perftest.c 1.3-1.5
sbin/nvmectl/power.c 1.3,1.4
sbin/nvmectl/reset.c 1.2,1.3
sbin/nvmectl/util.c 1.1,1.2
sbin/nvmectl/wdc.c 1.2-1.4
sys/dev/ic/ld_nvme.c 1.20
sys/dev/ic/nvme.c 1.38,1.39
sys/dev/ic/nvmeio.h 1.2
sys/dev/ic/nvmereg.h 1.10,1.11
sys/dev/ic/nvmevar.h 1.16
sys/dev/pci/nvme_pci.c 1.20

nvmectl(8): Sync with FreeBSD nvmecontrol(8) r328763.

nvmectl(8): fix wdc command usage.

nvme(4): Added some delay before check RDY bit quirk when disabling device.
Pick from FreeBSD nvme(4) r326937.

Add some new structure fileds, opcodes and statuses from NVMe 1.3a.

nvmectl(8): Add big-endian support.
from FreeBSD nvmecontolr(8) r329824.

nvmectl(8): fix subcommand usage.

nvmectl(8): Remove some wdc subcommands from man page.
- wdc drive-log
- wdc get-crash-dump
- wdc purge
- wdc purge-monitor

Typos.

use setprogname()/getprogname(), do not hardcode the prognam name in fixed
strings
 1.16.2.2  18-Mar-2018  martin Pull up following revision(s) (requested by jdolecek in ticket #641):
sys/dev/ic/nvme.c: revision 1.34
sys/dev/ic/nvme.c: revision 1.35
sys/dev/ic/nvme.c: revision 1.36
sys/dev/ic/nvme.c: revision 1.37
sys/dev/ic/ld_nvme.c: revision 1.19
sys/dev/ic/nvmevar.h: revision 1.15

refactor the locking code around DIOCGCACHE handling to be reusable
for other infrequent commands,it uses single condvar for simplicity,
and uses it both when waiting for ccb or command completion - this
is fine, since usually there will be just one such command qeueued anyway
use this to finally properly implement DIOCCACHESYNC - return only after
the command is confirmed as completed by the controller.

switch handling of passthrough commands to use queue, instead of polling
should fix PR kern/53059 by Frank Kardel

fix passthrough command usage also in nvme_get_number_of_queues(), fixes
memory corruption and possible panic on boot

also remove now duplicate nvme_ccb_put() call from
nvme_get_number_of_queues()
 1.16.2.1  01-Sep-2017  martin Pull up following revision(s) (requested by mlelstv in ticket #261):
sys/dev/sdmmc/ld_sdmmc.c: revision 1.32
sys/dev/sdmmc/ld_sdmmc.c: revision 1.33
sys/dev/sdmmc/ld_sdmmc.c: revision 1.34
sys/dev/sdmmc/sdmmc_mem.c: revision 1.62
sys/dev/i2o/ld_iop.c: revision 1.39
sys/dev/ld.c: revision 1.102
sys/dev/ld.c: revision 1.103
sys/dev/dksubr.c: revision 1.98
sys/dev/dksubr.c: revision 1.99
sys/dev/sdmmc/sdmmcvar.h: revision 1.29
sys/dev/ic/ld_nvme.c: revision 1.17
sys/dev/ldvar.h: revision 1.31
sys/dev/ldvar.h: revision 1.32
sys/dev/ic/ld_cac.c: revision 1.31
sys/dev/pci/ld_virtio.c: revision 1.16
While ld(4) is MP safe, many backends are not.
Add a flag for backends that are MP safe. Take KERNEL_LOCK when calling
into a backend that doesn't have the flag set. Do the same for the
discard routine.
Fixes PR 52462.
Defer sdmmc discard operations to the sdmmc task queue. Fixes a panic
introduced by ld.c r1.102.
validate length for discard operation and split operation when byte length
doesn't fit into 'int'.
make the sc_discard interface for the ld backend asynchronous and
signal completion through new callback lddiscardend. Use a standard
struct buf to pass disk address and range instead of two off_t values.
make lddiscard synchronous again. This is a requirement of the current
ffs discard code.
Initialize error also in the case where len=0, which just succeeds.
while here, assert that the len is indeed non-negative. this is already
confirmed by sys_fdiscard, but let's be sure.
reported by: GCC, but with different compile flags
 1.17.2.2  03-Dec-2017  jdolecek update from HEAD
 1.17.2.1  09-Aug-2017  jdolecek file ld_nvme.c was added on branch tls-maxphys on 2017-12-03 11:37:03 +0000
 1.18.2.3  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.18.2.2  22-Apr-2018  pgoyette Sync with HEAD
 1.18.2.1  22-Mar-2018  pgoyette Synch with HEAD, resolve conflicts
 1.20.2.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.20.2.1  10-Jun-2019  christos Sync with HEAD
 1.22.2.2  27-Sep-2020  martin Pull up following revision(s) (requested by kardel in ticket #1094):

sys/dev/ic/ld_nvme.c: revision 1.24
sys/dev/ic/nvme.c: revision 1.50

PR kern/55674:
move name space availability check from ld_nvme.c:ld_nvme_attach()
to nvme.c:nvme_rescan().
this avoids allocation of ld(4) instances for every possible
name space, even if it is not usable. it also reduces the device
node flood generated from that strategy.
 1.22.2.1  28-Oct-2019  martin Pull up following revision(s) (requested by mlelstv in ticket #383):

sys/dev/ic/ld_nvme.c: revision 1.23

Don't attach an ld device if the format descriptor is unsupported/unused.

RSS XML Feed