Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme-pci: implement the HMB entry number and size limitations

Adds support for the new Host Memory Buffer Minimum Descriptor Entry Size
and Host Memory Maximum Descriptors Entries field that were added in
TP 4002 HMB Enhancements. These allow the controller to advertise
limits for the usual number of segments in the host memory buffer, as
well as a minimum usable per-segment size.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>

+13 -2
+2
drivers/nvme/host/core.c
··· 1897 ctrl->cntlid = le16_to_cpu(id->cntlid); 1898 ctrl->hmpre = le32_to_cpu(id->hmpre); 1899 ctrl->hmmin = le32_to_cpu(id->hmmin); 1900 } 1901 1902 kfree(id);
··· 1897 ctrl->cntlid = le16_to_cpu(id->cntlid); 1898 ctrl->hmpre = le32_to_cpu(id->hmpre); 1899 ctrl->hmmin = le32_to_cpu(id->hmmin); 1900 + ctrl->hmminds = le32_to_cpu(id->hmminds); 1901 + ctrl->hmmaxd = le16_to_cpu(id->hmmaxd); 1902 } 1903 1904 kfree(id);
+3
drivers/nvme/host/nvme.h
··· 181 u64 ps_max_latency_us; 182 bool apst_enabled; 183 184 u32 hmpre; 185 u32 hmmin; 186 187 /* Fabrics only */ 188 u16 sqsize;
··· 181 u64 ps_max_latency_us; 182 bool apst_enabled; 183 184 + /* PCIe only: */ 185 u32 hmpre; 186 u32 hmmin; 187 + u32 hmminds; 188 + u16 hmmaxd; 189 190 /* Fabrics only */ 191 u16 sqsize;
+5 -1
drivers/nvme/host/pci.c
··· 1625 tmp = (preferred + chunk_size - 1); 1626 do_div(tmp, chunk_size); 1627 max_entries = tmp; 1628 descs = dma_zalloc_coherent(dev->dev, max_entries * sizeof(*descs), 1629 &descs_dma, GFP_KERNEL); 1630 if (!descs) ··· 1685 1686 /* start big and work our way down */ 1687 for (chunk_size = min_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES); 1688 - chunk_size >= PAGE_SIZE * 2; 1689 chunk_size /= 2) { 1690 if (!__nvme_alloc_host_mem(dev, preferred, chunk_size)) { 1691 if (!min || dev->host_mem_size >= min)
··· 1625 tmp = (preferred + chunk_size - 1); 1626 do_div(tmp, chunk_size); 1627 max_entries = tmp; 1628 + 1629 + if (dev->ctrl.hmmaxd && dev->ctrl.hmmaxd < max_entries) 1630 + max_entries = dev->ctrl.hmmaxd; 1631 + 1632 descs = dma_zalloc_coherent(dev->dev, max_entries * sizeof(*descs), 1633 &descs_dma, GFP_KERNEL); 1634 if (!descs) ··· 1681 1682 /* start big and work our way down */ 1683 for (chunk_size = min_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES); 1684 + chunk_size >= max_t(u32, dev->ctrl.hmminds * 4096, PAGE_SIZE * 2); 1685 chunk_size /= 2) { 1686 if (!__nvme_alloc_host_mem(dev, preferred, chunk_size)) { 1687 if (!min || dev->host_mem_size >= min)
+3 -1
include/linux/nvme.h
··· 226 __le16 mntmt; 227 __le16 mxtmt; 228 __le32 sanicap; 229 - __u8 rsvd332[180]; 230 __u8 sqes; 231 __u8 cqes; 232 __le16 maxcmd;
··· 226 __le16 mntmt; 227 __le16 mxtmt; 228 __le32 sanicap; 229 + __le32 hmminds; 230 + __le16 hmmaxd; 231 + __u8 rsvd338[174]; 232 __u8 sqes; 233 __u8 cqes; 234 __le16 maxcmd;