[PATCH 3/4] nvme-pci: use max of PRP or SGL for iod size
Keith Busch
kbusch at kernel.org
Wed Jul 8 18:26:49 EDT 2020
On Tue, Jul 07, 2020 at 05:58:30PM -0700, Chaitanya Kulkarni wrote:
> static size_t nvme_pci_iod_alloc_size(struct nvme_dev *dev,
> - unsigned int size, unsigned int nseg, bool use_sgl)
> + unsigned int size, unsigned int nseg)
> {
> - size_t alloc_size;
> + size_t npages_sgl = nvme_pci_npages_sgl(nseg);
> + size_t npages = nvme_npages(size, dev);
> + size_t alloc_size = sizeof(__le64 *);
>
> - if (use_sgl)
> - alloc_size = sizeof(__le64 *) * nvme_pci_npages_sgl(nseg);
> - else
> - alloc_size = sizeof(__le64 *) * nvme_npages(size, dev);
> + alloc_size *= (npages_sgl > npages ? npages_sgl : npages);
This would look better as:
alloc_size *= max(npages, npages_sgl);
More information about the Linux-nvme
mailing list