* [PATCH] cxl: fix NULL dereference in cxl_context_init() on PowerVM guests
@ 2016-07-28 5:39 Andrew Donnellan
2016-07-28 5:58 ` Ian Munsie
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andrew Donnellan @ 2016-07-28 5:39 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: imunsie, fbarrat, huyn
Commit f67a6722d650 ("cxl: Workaround PE=0 hardware limitation in Mellanox
CX4") added a "min_pe" field to struct cxl_service_layer_ops, to allow us
to work around a Mellanox CX-4 hardware limitation.
When allocating the PE number in cxl_context_init(), we read from
ctx->afu->adapter->native->sl_ops->min_pe to get the minimum PE number.
Unsurprisingly, in a PowerVM guest ctx->afu->adapter->native is NULL, and
guests don't have a cxl_service_layer_ops struct anywhere.
Move min_pe from struct cxl_service_layer_ops to struct cxl so it's
accessible in both native and PowerVM environments. For the Mellanox CX-4,
set the min_pe value in set_sl_ops().
Fixes: f67a6722d650 ("cxl: Workaround PE=0 hardware limitation in Mellanox CX4")
Reported-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---
drivers/misc/cxl/context.c | 3 +--
drivers/misc/cxl/cxl.h | 2 +-
drivers/misc/cxl/pci.c | 3 ++-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/cxl/context.c b/drivers/misc/cxl/context.c
index bdee9a0..c466ee2 100644
--- a/drivers/misc/cxl/context.c
+++ b/drivers/misc/cxl/context.c
@@ -90,8 +90,7 @@ int cxl_context_init(struct cxl_context *ctx, struct cxl_afu *afu, bool master,
*/
mutex_lock(&afu->contexts_lock);
idr_preload(GFP_KERNEL);
- i = idr_alloc(&ctx->afu->contexts_idr, ctx,
- ctx->afu->adapter->native->sl_ops->min_pe,
+ i = idr_alloc(&ctx->afu->contexts_idr, ctx, ctx->afu->adapter->min_pe,
ctx->afu->num_procs, GFP_NOWAIT);
idr_preload_end();
mutex_unlock(&afu->contexts_lock);
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 19b132f..76f8b94 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -549,7 +549,6 @@ struct cxl_service_layer_ops {
u64 (*timebase_read)(struct cxl *adapter);
int capi_mode;
bool needs_reset_before_disable;
- int min_pe;
};
struct cxl_native {
@@ -591,6 +590,7 @@ struct cxl {
struct bin_attribute cxl_attr;
int adapter_num;
int user_irqs;
+ int min_pe;
u64 ps_size;
u16 psl_rev;
u16 base_image;
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 3c8d0d2..bbf5fc9 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1552,14 +1552,15 @@ static const struct cxl_service_layer_ops xsl_ops = {
.write_timebase_ctrl = write_timebase_ctrl_xsl,
.timebase_read = timebase_read_xsl,
.capi_mode = OPAL_PHB_CAPI_MODE_DMA,
- .min_pe = 1, /* Workaround for Mellanox CX4 HW bug */
};
static void set_sl_ops(struct cxl *adapter, struct pci_dev *dev)
{
if (dev->vendor == PCI_VENDOR_ID_MELLANOX && dev->device == 0x1013) {
+ /* Mellanox CX-4 */
dev_info(&adapter->dev, "Device uses an XSL\n");
adapter->native->sl_ops = &xsl_ops;
+ adapter->min_pe = 1; /* Workaround for CX-4 hardware bug */
} else {
dev_info(&adapter->dev, "Device uses a PSL\n");
adapter->native->sl_ops = &psl_ops;
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com IBM Australia Limited
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cxl: fix NULL dereference in cxl_context_init() on PowerVM guests
2016-07-28 5:39 [PATCH] cxl: fix NULL dereference in cxl_context_init() on PowerVM guests Andrew Donnellan
@ 2016-07-28 5:58 ` Ian Munsie
2016-07-28 8:45 ` Frederic Barrat
2016-08-09 11:26 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Ian Munsie @ 2016-07-28 5:58 UTC (permalink / raw)
To: andrew.donnellan; +Cc: linuxppc-dev, Michael Ellerman, Huy Nguyen, fbarrat
Whoops!
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cxl: fix NULL dereference in cxl_context_init() on PowerVM guests
2016-07-28 5:39 [PATCH] cxl: fix NULL dereference in cxl_context_init() on PowerVM guests Andrew Donnellan
2016-07-28 5:58 ` Ian Munsie
@ 2016-07-28 8:45 ` Frederic Barrat
2016-08-09 11:26 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Frederic Barrat @ 2016-07-28 8:45 UTC (permalink / raw)
To: Andrew Donnellan, linuxppc-dev, mpe; +Cc: imunsie, huyn
Le 28/07/2016 à 07:39, Andrew Donnellan a écrit :
> Commit f67a6722d650 ("cxl: Workaround PE=0 hardware limitation in Mellanox
> CX4") added a "min_pe" field to struct cxl_service_layer_ops, to allow us
> to work around a Mellanox CX-4 hardware limitation.
>
> When allocating the PE number in cxl_context_init(), we read from
> ctx->afu->adapter->native->sl_ops->min_pe to get the minimum PE number.
> Unsurprisingly, in a PowerVM guest ctx->afu->adapter->native is NULL, and
> guests don't have a cxl_service_layer_ops struct anywhere.
>
> Move min_pe from struct cxl_service_layer_ops to struct cxl so it's
> accessible in both native and PowerVM environments. For the Mellanox CX-4,
> set the min_pe value in set_sl_ops().
>
> Fixes: f67a6722d650 ("cxl: Workaround PE=0 hardware limitation in Mellanox CX4")
> Reported-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
> Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: cxl: fix NULL dereference in cxl_context_init() on PowerVM guests
2016-07-28 5:39 [PATCH] cxl: fix NULL dereference in cxl_context_init() on PowerVM guests Andrew Donnellan
2016-07-28 5:58 ` Ian Munsie
2016-07-28 8:45 ` Frederic Barrat
@ 2016-08-09 11:26 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2016-08-09 11:26 UTC (permalink / raw)
To: Andrew Donnellan, linuxppc-dev; +Cc: huyn, imunsie, fbarrat
On Thu, 2016-28-07 at 05:39:41 UTC, Andrew Donnellan wrote:
> Commit f67a6722d650 ("cxl: Workaround PE=0 hardware limitation in Mellanox
> CX4") added a "min_pe" field to struct cxl_service_layer_ops, to allow us
> to work around a Mellanox CX-4 hardware limitation.
>
> When allocating the PE number in cxl_context_init(), we read from
> ctx->afu->adapter->native->sl_ops->min_pe to get the minimum PE number.
> Unsurprisingly, in a PowerVM guest ctx->afu->adapter->native is NULL, and
> guests don't have a cxl_service_layer_ops struct anywhere.
>
> Move min_pe from struct cxl_service_layer_ops to struct cxl so it's
> accessible in both native and PowerVM environments. For the Mellanox CX-4,
> set the min_pe value in set_sl_ops().
>
> Fixes: f67a6722d650 ("cxl: Workaround PE=0 hardware limitation in Mellanox CX4")
> Reported-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
> Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> Acked-by: Ian Munsie <imunsie@au1.ibm.com>
> Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Applied to powerpc fixes, thanks.
https://git.kernel.org/powerpc/c/164793379ad3b7ef5fc5a28260
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-09 11:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-28 5:39 [PATCH] cxl: fix NULL dereference in cxl_context_init() on PowerVM guests Andrew Donnellan
2016-07-28 5:58 ` Ian Munsie
2016-07-28 8:45 ` Frederic Barrat
2016-08-09 11:26 ` Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.