Commit f52b5c9
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 9706f4d commit f52b5c9
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 | | |
| |||
2300 | 2302 | | |
2301 | 2303 | | |
2302 | 2304 | | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
2303 | 2312 | | |
2304 | 2313 | | |
2305 | 2314 | | |
| |||
2316 | 2325 | | |
2317 | 2326 | | |
2318 | 2327 | | |
| 2328 | + | |
2319 | 2329 | | |
2320 | 2330 | | |
2321 | 2331 | | |
| |||
2358 | 2368 | | |
2359 | 2369 | | |
2360 | 2370 | | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
2361 | 2458 | | |
2362 | 2459 | | |
2363 | 2460 | | |
| |||
2418 | 2515 | | |
2419 | 2516 | | |
2420 | 2517 | | |
| 2518 | + | |
2421 | 2519 | | |
2422 | 2520 | | |
2423 | 2521 | | |
| |||
0 commit comments