]> git.ipfire.org Git - people/ms/u-boot.git/commit
nvme: Handle zero Maximum Data Transfer Size (MDTS)
authorBin Meng <bmeng.cn@gmail.com>
Thu, 3 Aug 2017 09:31:02 +0000 (02:31 -0700)
committerTom Rini <trini@konsulko.com>
Sun, 13 Aug 2017 19:17:33 +0000 (15:17 -0400)
commitbeb5f521392e7da208455f3bf0c86bc141c0879d
tree23ea2f79212bfd284430336e34b2992835d5001f
parentf81d83d53454a108f0317c1debd8af7edc8413be
nvme: Handle zero Maximum Data Transfer Size (MDTS)

Maximum Data Transfer Size (MDTS) field indicates the maximum
data transfer size between the host and the controller. The
host should not submit a command that exceeds this transfer
size. The value is in units of the minimum memory page size
and is reported as a power of two (2^n).

The spec also says: a value of 0h indicates no restrictions
on transfer size. On the real NVMe card this is normally not
0 due to hardware restrictions, but with QEMU emulated NVMe
device it reports as 0. In nvme_blk_read/write() below we
have the following algorithm for maximum number of logic
blocks per transfer:

u16 lbas = 1 << (dev->max_transfer_shift - ns->lba_shift);

dev->max_transfer_shift being 0 will for sure cause lbas to
overflow. Let's use 20. With this fix, the NVMe driver works
on QEMU emulated NVMe device.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
drivers/nvme/nvme.c