Page MenuHomeFreeBSD

nvme: Fix PRP list size calculation
Needs ReviewPublic

Authored by mengzhuo1203_gmail.com on Wed, Oct 22, 9:17 AM.
Tags
None
Referenced Files
F133905953: D53256.id.diff
Wed, Oct 29, 7:31 AM
F133904339: D53256.diff
Wed, Oct 29, 7:18 AM
Unknown Object (File)
Mon, Oct 27, 2:17 PM
Unknown Object (File)
Sun, Oct 26, 3:58 PM
Unknown Object (File)
Sat, Oct 25, 6:34 AM
Unknown Object (File)
Thu, Oct 23, 3:50 PM
Unknown Object (File)
Thu, Oct 23, 3:50 PM
Unknown Object (File)
Thu, Oct 23, 7:15 AM
Subscribers

Details

Reviewers
imp
Summary

The PRP list size calculation did not account for the PRP list page
itself when handling maximum transfer sizes. This could lead to
insufficient PRP list allocation when the transfer size exactly
matches max_xfer_size.

Add +1 to the PRP list size calculation to ensure adequate
space for the PRP list structure itself.

PR 290249

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/dev/nvme/nvme_qpair.c
566

I don't think this is not quite right. For exactly a max_xfer_size, we'd put the first buffer into PRP1, and then the rest int he page pointed to by PRP2. Since we have the extra pointer here, the calculation is exact, even when the I/O isn't aligned.

sys/dev/nvme/nvme_qpair.c
566

To clarify, after reading the context a little bit: are you saying that the page for the PRP list is already accounted for in this calculation because it's effectively offset by one page out of that max_xfer_size data going into PRP1?

@mengzhuo1203_gmail.com I think it would be helpful if you could walk us through how you came to the conclusion that this was the problem, so that we can better understand the side effect the addition here has that fixed the hardware you're working with.

sys/dev/nvme/nvme_qpair.c
566

So for max xfer, we need maxxfer/pagesize +1 PRPs. The first one goes in PRP1. PRP2 pounts to a page with maxxfer/pagesize entries. I don't see how we'd need +1 here which is computing the space for the prp2 indorect page(s).