From: Akinobu Mita Date: Wed, 6 Sep 2017 10:15:31 +0000 (+0200) Subject: nvme-pci: use appropriate initial chunk size for HMB allocation X-Git-Tag: v4.13.5~106 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2e81e134465ed6fb4287d25d4e274ea436bf6936;p=users%2Fdwmw2%2Flinux.git nvme-pci: use appropriate initial chunk size for HMB allocation commit 30f92d62e5b41a94de2d0bbd677a6ea2fcfed74f upstream. The initial chunk size for host memory buffer allocation is currently PAGE_SIZE << MAX_ORDER. MAX_ORDER order allocation is usually failed without CONFIG_DMA_CMA. So the HMB allocation is retried with chunk size PAGE_SIZE << (MAX_ORDER - 1) in general, but there is no problem if the retry allocation works correctly. Signed-off-by: Akinobu Mita [hch: rebased] Signed-off-by: Christoph Hellwig Reviewed-by: Keith Busch Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 399684685e774..48216d349ee0f 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1677,7 +1677,7 @@ static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred) u32 chunk_size; /* start big and work our way down */ - for (chunk_size = min_t(u64, preferred, PAGE_SIZE << MAX_ORDER); + for (chunk_size = min_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES); chunk_size >= PAGE_SIZE * 2; chunk_size /= 2) { if (!__nvme_alloc_host_mem(dev, preferred, chunk_size)) {