diff mbox

[v2] cxl: Fix number of allocated pages in SPA

Message ID 1444141189-16621-1-git-send-email-clombard@linux.vnet.ibm.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Christophe Lombard Oct. 6, 2015, 2:19 p.m. UTC
This moves the initialisation of the num_procs to before the SPA
allocation.
The field 'num_procs' of the structure cxl_afu is not updated to the
right value (maximum number of processes that can be supported by
the AFU) when the pages are allocated (i.e. when  cxl_alloc_spa() is called).
The number of allocates pages depends on the max number of processes.

Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
---
 drivers/misc/cxl/native.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ian Munsie Oct. 7, 2015, 3:51 a.m. UTC | #1
The explanation probably still needs to be expanded more (e.g. this
could cause a crash for an AFU that supports more than about a thousand
processes) - see my other email in reply to v1 for more, but I'm happy
for this to go in as is (but ultimately that's mpe's call).

It should also be CCd to stable, this bug was introduced before the
driver was originally upstreamed, we just never hit it because all our
AFUs are limited to less processes by their interrupt requirements.

Cc: stable <stable@vger.kernel.org>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>

Excerpts from Christophe Lombard's message of 2015-10-07 01:19:49 +1100:
> This moves the initialisation of the num_procs to before the SPA
> allocation.
> The field 'num_procs' of the structure cxl_afu is not updated to the
> right value (maximum number of processes that can be supported by
> the AFU) when the pages are allocated (i.e. when  cxl_alloc_spa() is called).
> The number of allocates pages depends on the max number of processes.
> 
> Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
> ---
>  drivers/misc/cxl/native.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
> index b37f2e8..d2e75c8 100644
> --- a/drivers/misc/cxl/native.c
> +++ b/drivers/misc/cxl/native.c
> @@ -457,6 +457,7 @@ static int activate_afu_directed(struct cxl_afu *afu)
>  
>      dev_info(&afu->dev, "Activating AFU directed mode\n");
>  
> +    afu->num_procs = afu->max_procs_virtualised;
>      if (afu->spa == NULL) {
>          if (cxl_alloc_spa(afu))
>              return -ENOMEM;
> @@ -468,7 +469,6 @@ static int activate_afu_directed(struct cxl_afu *afu)
>      cxl_p1n_write(afu, CXL_PSL_ID_An, CXL_PSL_ID_An_F | CXL_PSL_ID_An_L);
>  
>      afu->current_mode = CXL_MODE_DIRECTED;
> -    afu->num_procs = afu->max_procs_virtualised;
>  
>      if ((rc = cxl_chardev_m_afu_add(afu)))
>          return rc;
Michael Ellerman Oct. 7, 2015, 4:09 a.m. UTC | #2
On Wed, 2015-10-07 at 14:51 +1100, Ian Munsie wrote:
> The explanation probably still needs to be expanded more (e.g. this
> could cause a crash for an AFU that supports more than about a thousand
> processes) - see my other email in reply to v1 for more, but I'm happy
> for this to go in as is (but ultimately that's mpe's call).
> 
> It should also be CCd to stable, this bug was introduced before the
> driver was originally upstreamed, we just never hit it because all our
> AFUs are limited to less processes by their interrupt requirements.
> 
> Cc: stable <stable@vger.kernel.org>

So the driver went into 3.18, so this should be:

Cc: stable <stable@vger.kernel.org> # 3.18+

One of you please resend with a coherent change log with all the details
included.

cheers
diff mbox

Patch

diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index b37f2e8..d2e75c8 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -457,6 +457,7 @@  static int activate_afu_directed(struct cxl_afu *afu)
 
 	dev_info(&afu->dev, "Activating AFU directed mode\n");
 
+	afu->num_procs = afu->max_procs_virtualised;
 	if (afu->spa == NULL) {
 		if (cxl_alloc_spa(afu))
 			return -ENOMEM;
@@ -468,7 +469,6 @@  static int activate_afu_directed(struct cxl_afu *afu)
 	cxl_p1n_write(afu, CXL_PSL_ID_An, CXL_PSL_ID_An_F | CXL_PSL_ID_An_L);
 
 	afu->current_mode = CXL_MODE_DIRECTED;
-	afu->num_procs = afu->max_procs_virtualised;
 
 	if ((rc = cxl_chardev_m_afu_add(afu)))
 		return rc;