[PATCH V2 1/2] nvme-core: replace ctrl page size with a macro

Keith Busch kbusch at kernel.org
Tue Jul 14 12:44:05 EDT 2020


On Mon, Jul 13, 2020 at 09:42:10AM +0200, Christoph Hellwig wrote:
> On Thu, Jul 09, 2020 at 04:40:24PM -0700, Chaitanya Kulkarni wrote:
> >  static int nvme_npages(unsigned size, struct nvme_dev *dev)
> >  {
> > -	unsigned nprps = DIV_ROUND_UP(size + dev->ctrl.page_size,
> > -				      dev->ctrl.page_size);
> > +	unsigned nprps = DIV_ROUND_UP(size + NVME_CTRL_PAGE_SIZE,
> > +						NVME_CTRL_PAGE_SIZE);
> >  	return DIV_ROUND_UP(8 * nprps, PAGE_SIZE - 8);
> 
> This looks like the existing code here is wrong, as DIV_ROUND_UP already
> adds the page size itself.  But that is better left for another patch..

The extra addition is for when the starting address has a page offset,
which may require an extra PRP than DIV_ROUND_UP would return without
the addition.



More information about the Linux-nvme mailing list