Commit 582cb2a
nvme-pci: manually allocate Host Memory Buffer segments on arm64
The Host Memory Buffer allocation algorithm interacts badly with arm64
platforms with no IOMMU for PCIe devices, such as BCM2711/BCM2712.
The discontiguous VA allocation in nvme_host_mem_alloc_single() always
fails, so nvme_alloc_host_mem_multi() falls back to the DMA coherent
allocation scheme. On arm64, this will come out of CMA by default.
Recent DRAM-less SSDs will request significant amounts of host memory -
up to 128MB. As NVMe devices are set up early in boot, CMA is
mostly-free so it ends up being claimed by a driver using it for opaque
device-exclusive buffers. The divide-and-conquer allocation strategy
also paradoxically results in increased CMA pressure if portions are
already reserved.
PCIe NVMe controllers implement a variably-sized HMB descriptor table,
typically ranging from 32 to 256 entries in size. Therefore, aside from
implementation-specific costs in the controller doing more granular
look-ups, providing smaller orders is acceptable. Failing to provide a
HMB does not prevent the controller from functioning.
Create an alternate implementation for arm64 that creates a scatterlist
and directly assigns contiguous pages from the buddy allocator, retrying
with smaller orders on failure. This will avoid CMA by default.
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>1 parent 50e6e32 commit 582cb2a
1 file changed
Lines changed: 98 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
| 190 | + | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| |||
2371 | 2373 | | |
2372 | 2374 | | |
2373 | 2375 | | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
2374 | 2383 | | |
2375 | 2384 | | |
2376 | 2385 | | |
| |||
2387 | 2396 | | |
2388 | 2397 | | |
2389 | 2398 | | |
| 2399 | + | |
2390 | 2400 | | |
2391 | 2401 | | |
2392 | 2402 | | |
| |||
2429 | 2439 | | |
2430 | 2440 | | |
2431 | 2441 | | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
2432 | 2529 | | |
2433 | 2530 | | |
2434 | 2531 | | |
| |||
2489 | 2586 | | |
2490 | 2587 | | |
2491 | 2588 | | |
| 2589 | + | |
2492 | 2590 | | |
2493 | 2591 | | |
2494 | 2592 | | |
| |||
0 commit comments