linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cxl: Fix number of allocated pages in SPA
@ 2015-10-02 14:01 Christophe Lombard
  2015-10-06  0:23 ` Ian Munsie
  2015-10-06  6:19 ` Michael Ellerman
  0 siblings, 2 replies; 6+ messages in thread
From: Christophe Lombard @ 2015-10-02 14:01 UTC (permalink / raw)
  To: imunsie; +Cc: linuxppc-dev

This moves the initialisation of the num_procs to before the SPA
allocation.

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;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxl: Fix number of allocated pages in SPA
  2015-10-02 14:01 [PATCH] cxl: Fix number of allocated pages in SPA Christophe Lombard
@ 2015-10-06  0:23 ` Ian Munsie
  2015-10-06  6:19 ` Michael Ellerman
  1 sibling, 0 replies; 6+ messages in thread
From: Ian Munsie @ 2015-10-06  0:23 UTC (permalink / raw)
  To: Christophe Lombard; +Cc: linuxppc-dev

Acked-by: Ian Munsie <imunsie@au1.ibm.com>

Excerpts from Christophe Lombard's message of 2015-10-03 00:01:25 +1000:
> This moves the initialisation of the num_procs to before the SPA
> allocation.
> 
> 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;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxl: Fix number of allocated pages in SPA
  2015-10-02 14:01 [PATCH] cxl: Fix number of allocated pages in SPA Christophe Lombard
  2015-10-06  0:23 ` Ian Munsie
@ 2015-10-06  6:19 ` Michael Ellerman
  2015-10-06  9:21   ` christophe lombard
  2015-10-07  3:24   ` Ian Munsie
  1 sibling, 2 replies; 6+ messages in thread
From: Michael Ellerman @ 2015-10-06  6:19 UTC (permalink / raw)
  To: Christophe Lombard; +Cc: imunsie, linuxppc-dev

On Fri, 2015-10-02 at 16:01 +0200, Christophe Lombard wrote:
> This moves the initialisation of the num_procs to before the SPA
> allocation.

Why? What does it fix? I can't tell from the diff or the change log.

cheers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxl: Fix number of allocated pages in SPA
  2015-10-06  6:19 ` Michael Ellerman
@ 2015-10-06  9:21   ` christophe lombard
  2015-10-07  3:24   ` Ian Munsie
  1 sibling, 0 replies; 6+ messages in thread
From: christophe lombard @ 2015-10-06  9:21 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, imunsie

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.

Thanks


On 06/10/2015 08:19, Michael Ellerman wrote:
> On Fri, 2015-10-02 at 16:01 +0200, Christophe Lombard wrote:
>> This moves the initialisation of the num_procs to before the SPA
>> allocation.
> Why? What does it fix? I can't tell from the diff or the change log.
>
> cheers
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxl: Fix number of allocated pages in SPA
  2015-10-06  6:19 ` Michael Ellerman
  2015-10-06  9:21   ` christophe lombard
@ 2015-10-07  3:24   ` Ian Munsie
  1 sibling, 0 replies; 6+ messages in thread
From: Ian Munsie @ 2015-10-07  3:24 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Christophe Lombard, linuxppc-dev

Excerpts from Michael Ellerman's message of 2015-10-06 17:19:02 +1100:
> On Fri, 2015-10-02 at 16:01 +0200, Christophe Lombard wrote:
> > This moves the initialisation of the num_procs to before the SPA
> > allocation.
> 
> Why? What does it fix? I can't tell from the diff or the change log.

This will mean we only ever allocate a fixed number of pages for the
scheduled process area (which in itself looks like it has a minor bug as
it will start trying at two pages instead of one), which will limit us
to 958 processes with 2 x 64K pages. If we actually try to use more
processes than that we'd probably overrun the buffer and corrupt memory
or crash.

The only reason we haven't hit this out in the field so far is any AFUs
the requires at least three interrupts per process is already limited to
less processes than that anyway (e.g. min of 4 interrupts limits it to
509 processes, and all the AFUs I'm aware of require at least that many
interrupts), but we could hit it on an AFU that requires 0, 1 or 2
interrupts per process, or when using 4K pages.

This fix should go to stable.

@Christophe, can you resend with this info in the commit message?

Cheers,
-Ian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] cxl: Fix number of allocated pages in SPA
  2015-10-07  4:09 [PATCH v2] " Michael Ellerman
@ 2015-10-07  5:07 ` Ian Munsie
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Munsie @ 2015-10-07  5:07 UTC (permalink / raw)
  To: Michael Ellerman, Christophe Lombard
  Cc: Michael Neuling, linuxppc-dev, Ian Munsie, stable

From: Christophe Lombard <clombard@linux.vnet.ibm.com>

The scheduled process area is currently allocated before assigning the
correct maximum processes to the AFU, which will mean we only ever
allocate a fixed number of pages for the scheduled process area. This
will limit us to 958 processes with 2 x 64K pages. If we try to use more
processes than that we'd probably overrun the buffer and corrupt memory
or crash.

AFUs that require three or more interrupts per process will not be
affected as they are already limited to less processes than that, but we
could hit it on an AFU that requires 0, 1 or 2 interrupts per process,
or when using 4K pages.

This patch moves the initialisation of the num_procs to before the SPA
allocation so that enough pages will be allocated for the number of
processes that the AFU supports.

Signed-off-by: Christophe Lombard <clombard@linux.vnet.ibm.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
Cc: stable <stable@vger.kernel.org> # 3.18+
---

Changes since v2:
 - Expanded commit message
Changes since v1:
 - Expanded commit message

 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;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-10-07  5:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-02 14:01 [PATCH] cxl: Fix number of allocated pages in SPA Christophe Lombard
2015-10-06  0:23 ` Ian Munsie
2015-10-06  6:19 ` Michael Ellerman
2015-10-06  9:21   ` christophe lombard
2015-10-07  3:24   ` Ian Munsie
2015-10-07  4:09 [PATCH v2] " Michael Ellerman
2015-10-07  5:07 ` [PATCH] " Ian Munsie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).