Commit 2224b671 authored by Ian Munsie's avatar Ian Munsie Committed by Michael Ellerman

cxl: Fix allocating a minimum of 2 pages for the SPA

The Scheduled Process Area is allocated dynamically with enough pages to
fit at least as many processes as the AFU descriptor indicated. Since
the calculation is non-trivial, it does this by calculating how many
processes could fit in an allocation of a given order, and increasing
that order until it can fit enough processes or hits the maximum
supported size.

Currently, it will start this search using a SPA of 2 pages instead of
1. This can waste a page of memory if the AFU's maximum number of
supported processes was small enough to fit in one page.

Fix the algorithm to start the search at 1 page.
Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
Reviewed-by: default avatarFrederic Barrat <fbarrat@linux.vnet.ibm.com>
Reviewed-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 49e9c99f
...@@ -189,7 +189,7 @@ int cxl_alloc_spa(struct cxl_afu *afu) ...@@ -189,7 +189,7 @@ int cxl_alloc_spa(struct cxl_afu *afu)
unsigned spa_size; unsigned spa_size;
/* Work out how many pages to allocate */ /* Work out how many pages to allocate */
afu->native->spa_order = 0; afu->native->spa_order = -1;
do { do {
afu->native->spa_order++; afu->native->spa_order++;
spa_size = (1 << afu->native->spa_order) * PAGE_SIZE; spa_size = (1 << afu->native->spa_order) * PAGE_SIZE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment