linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
@ 2015-09-04  6:20 Andrew Donnellan
  2015-09-06 23:58 ` Ian Munsie
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Andrew Donnellan @ 2015-09-04  6:20 UTC (permalink / raw)
  To: linuxppc-dev

cxl_pci_enable_device_hook() is called when attempting to enable an AFU
sitting on a vPHB. At present, the state of the underlying CXL card's PCI
channel is only checked when it calls cxl_afu_check_and_enable() at the
very end, after it has already set DMA options and initialised a default
context.

Check the CXL card's link status before setting DMA options or initialising
a default context. If the link is down, print a warning and return
immediately.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---
 drivers/misc/cxl/vphb.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
index 6dd16a6..1972fb6 100644
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -48,6 +48,11 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)
 
 	phb = pci_bus_to_host(dev->bus);
 	afu = (struct cxl_afu *)phb->private_data;
+
+	if (!cxl_adapter_link_ok(afu->adapter))
+		dev_warn(&dev->dev, "%s: Device link is down, refusing to enable AFU\n", __func__);
+		return false;
+
 	set_dma_ops(&dev->dev, &dma_direct_ops);
 	set_dma_offset(&dev->dev, PAGE_OFFSET);
 
-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

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

* Re: [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-04  6:20 [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline Andrew Donnellan
@ 2015-09-06 23:58 ` Ian Munsie
  2015-09-07  0:22   ` Andrew Donnellan
  2015-09-07  0:47 ` Andrew Donnellan
  2015-09-07  0:52 ` [PATCH v2] " Andrew Donnellan
  2 siblings, 1 reply; 12+ messages in thread
From: Ian Munsie @ 2015-09-06 23:58 UTC (permalink / raw)
  To: andrew.donnellan; +Cc: linuxppc-dev

Excerpts from andrew.donnellan's message of 2015-09-04 16:20:24 +1000:
> +    if (!cxl_adapter_link_ok(afu->adapter))
> +        dev_warn(&dev->dev, "%s: Device link is down, refusing to enable AFU\n", __func__);
> +        return false;

Based on the indentation it looks like you meant to add some curly
brackets here.

-Ian

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

* Re: [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-06 23:58 ` Ian Munsie
@ 2015-09-07  0:22   ` Andrew Donnellan
  2015-09-07  6:33     ` Ian Munsie
  0 siblings, 1 reply; 12+ messages in thread
From: Andrew Donnellan @ 2015-09-07  0:22 UTC (permalink / raw)
  To: linuxppc-dev



On 07/09/15 09:58, Ian Munsie wrote:
> Excerpts from andrew.donnellan's message of 2015-09-04 16:20:24 +1000:
>> +    if (!cxl_adapter_link_ok(afu->adapter))
>> +        dev_warn(&dev->dev, "%s: Device link is down, refusing to enable AFU\n", __func__);
>> +        return false;
>
> Based on the indentation it looks like you meant to add some curly
> brackets here.

Indeed I did, and I'd even thought I'd tested it... this is why I 
shouldn't be allowed to submit patches at 4pm on Fridays...

Will submit V2.

(FWIW, I'm a firm believer in braces around single statements in 
conditionals to avoid mistakes like this, but CodingStyle disagrees...)


Andrew


-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

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

* [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-04  6:20 [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline Andrew Donnellan
  2015-09-06 23:58 ` Ian Munsie
@ 2015-09-07  0:47 ` Andrew Donnellan
  2015-09-07  1:01   ` Ian Munsie
  2015-09-07  0:52 ` [PATCH v2] " Andrew Donnellan
  2 siblings, 1 reply; 12+ messages in thread
From: Andrew Donnellan @ 2015-09-07  0:47 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mikey, imunsie, dja

cxl_pci_enable_device_hook() is called when attempting to enable an AFU
sitting on a vPHB. At present, the state of the underlying CXL card's PCI
channel is only checked when it calls cxl_afu_check_and_enable() at the
very end, after it has already set DMA options and initialised a default
context.

Check the CXL card's link status before setting DMA options or initialising
a default context. If the link is down, print a warning and return
immediately.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---
 drivers/misc/cxl/vphb.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
index 6dd16a6..94b5208 100644
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -48,6 +48,12 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)
 
 	phb = pci_bus_to_host(dev->bus);
 	afu = (struct cxl_afu *)phb->private_data;
+
+	if (!cxl_adapter_link_ok(afu->adapter)) {
+		dev_warn(&dev->dev, "%s: Device link is down, refusing to enable AFU\n", __func__);
+		return false;
+	}
+
 	set_dma_ops(&dev->dev, &dma_direct_ops);
 	set_dma_offset(&dev->dev, PAGE_OFFSET);
 
-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

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

* [PATCH v2] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-04  6:20 [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline Andrew Donnellan
  2015-09-06 23:58 ` Ian Munsie
  2015-09-07  0:47 ` Andrew Donnellan
@ 2015-09-07  0:52 ` Andrew Donnellan
  2015-09-07  1:09   ` Ian Munsie
                     ` (2 more replies)
  2 siblings, 3 replies; 12+ messages in thread
From: Andrew Donnellan @ 2015-09-07  0:52 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mikey, imunsie, dja

cxl_pci_enable_device_hook() is called when attempting to enable an AFU
sitting on a vPHB. At present, the state of the underlying CXL card's PCI
channel is only checked when it calls cxl_afu_check_and_enable() at the
very end, after it has already set DMA options and initialised a default
context.

Check the CXL card's link status before setting DMA options or initialising
a default context. If the link is down, print a warning and return
immediately.

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---
 drivers/misc/cxl/vphb.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
index 6dd16a6..94b5208 100644
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -48,6 +48,12 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)
 
 	phb = pci_bus_to_host(dev->bus);
 	afu = (struct cxl_afu *)phb->private_data;
+
+	if (!cxl_adapter_link_ok(afu->adapter)) {
+		dev_warn(&dev->dev, "%s: Device link is down, refusing to enable AFU\n", __func__);
+		return false;
+	}
+
 	set_dma_ops(&dev->dev, &dma_direct_ops);
 	set_dma_offset(&dev->dev, PAGE_OFFSET);
 
-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

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

* Re: [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-07  0:47 ` Andrew Donnellan
@ 2015-09-07  1:01   ` Ian Munsie
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Munsie @ 2015-09-07  1:01 UTC (permalink / raw)
  To: andrew.donnellan; +Cc: linuxppc-dev, mikey, dja

That looks better :)

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

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

* Re: [PATCH v2] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-07  0:52 ` [PATCH v2] " Andrew Donnellan
@ 2015-09-07  1:09   ` Ian Munsie
  2015-09-07  2:53   ` Michael Ellerman
  2015-09-08 12:05   ` [v2] " Michael Ellerman
  2 siblings, 0 replies; 12+ messages in thread
From: Ian Munsie @ 2015-09-07  1:09 UTC (permalink / raw)
  To: andrew.donnellan; +Cc: linuxppc-dev, mikey, dja

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

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

* Re: [PATCH v2] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-07  0:52 ` [PATCH v2] " Andrew Donnellan
  2015-09-07  1:09   ` Ian Munsie
@ 2015-09-07  2:53   ` Michael Ellerman
  2015-09-07  4:00     ` Andrew Donnellan
  2015-09-08 12:05   ` [v2] " Michael Ellerman
  2 siblings, 1 reply; 12+ messages in thread
From: Michael Ellerman @ 2015-09-07  2:53 UTC (permalink / raw)
  To: Andrew Donnellan; +Cc: linuxppc-dev, mikey, imunsie, dja

On Mon, 2015-09-07 at 10:52 +1000, Andrew Donnellan wrote:
> cxl_pci_enable_device_hook() is called when attempting to enable an AFU
> sitting on a vPHB. At present, the state of the underlying CXL card's PCI
> channel is only checked when it calls cxl_afu_check_and_enable() at the
> very end, after it has already set DMA options and initialised a default
> context.
> 
> Check the CXL card's link status before setting DMA options or initialising
> a default context. If the link is down, print a warning and return
> immediately.

Is this a fix targetting 4.3 (current release) and/or stable, or something for
next?

cheers

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

* Re: [PATCH v2] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-07  2:53   ` Michael Ellerman
@ 2015-09-07  4:00     ` Andrew Donnellan
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Donnellan @ 2015-09-07  4:00 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, mikey, imunsie, dja

On 07/09/15 12:53, Michael Ellerman wrote:
> Is this a fix targetting 4.3 (current release) and/or stable, or something for
> next?

4.3 - this fix is related to cxl's EEH support which has been merged for 
4.3.

For the record, since I neglected to add this earlier:

---
Changes from v1:
- Insert braces so that "return false" is within if block


-- 
Andrew Donnellan              Software Engineer, OzLabs
andrew.donnellan@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited

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

* Re: [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-07  0:22   ` Andrew Donnellan
@ 2015-09-07  6:33     ` Ian Munsie
  2015-09-07  8:43       ` Michael Ellerman
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Munsie @ 2015-09-07  6:33 UTC (permalink / raw)
  To: andrew.donnellan; +Cc: linuxppc-dev

No worries. I've been caught out by something similar in the past when I
assumed that something like this:

if (foo)
	/*
	 * A big long
	 * multiline
	 * block comment!
	 */
	 do_something()

would surely already have curly brackets around it ;-)

Excerpts from andrew.donnellan's message of 2015-09-07 10:22:31 +1000:
> 
> On 07/09/15 09:58, Ian Munsie wrote:
> > Excerpts from andrew.donnellan's message of 2015-09-04 16:20:24 +1000:
> >> +    if (!cxl_adapter_link_ok(afu->adapter))
> >> +        dev_warn(&dev->dev, "%s: Device link is down, refusing to enable AFU\n", __func__);
> >> +        return false;
> >
> > Based on the indentation it looks like you meant to add some curly
> > brackets here.
> 
> Indeed I did, and I'd even thought I'd tested it... this is why I 
> shouldn't be allowed to submit patches at 4pm on Fridays...
> 
> Will submit V2.
> 
> (FWIW, I'm a firm believer in braces around single statements in 
> conditionals to avoid mistakes like this, but CodingStyle disagrees...)
> 
> 
> Andrew
> 

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

* Re: [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-07  6:33     ` Ian Munsie
@ 2015-09-07  8:43       ` Michael Ellerman
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2015-09-07  8:43 UTC (permalink / raw)
  To: Ian Munsie; +Cc: andrew.donnellan, linuxppc-dev

On Mon, 2015-09-07 at 16:33 +1000, Ian Munsie wrote:
> No worries. I've been caught out by something similar in the past when I
> assumed that something like this:
> 
> if (foo)
> 	/*
> 	 * A big long
> 	 * multiline
> 	 * block comment!
> 	 */
> 	 do_something()
> 
> would surely already have curly brackets around it ;-)

You guys can do whatever you like for the cxl code.

cheers

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

* Re: [v2] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
  2015-09-07  0:52 ` [PATCH v2] " Andrew Donnellan
  2015-09-07  1:09   ` Ian Munsie
  2015-09-07  2:53   ` Michael Ellerman
@ 2015-09-08 12:05   ` Michael Ellerman
  2 siblings, 0 replies; 12+ messages in thread
From: Michael Ellerman @ 2015-09-08 12:05 UTC (permalink / raw)
  To: Andrew Donnellan, linuxppc-dev; +Cc: mikey, imunsie, dja

On Mon, 2015-07-09 at 00:52:58 UTC, Andrew Donnellan wrote:
> cxl_pci_enable_device_hook() is called when attempting to enable an AFU
> sitting on a vPHB. At present, the state of the underlying CXL card's PCI
> channel is only checked when it calls cxl_afu_check_and_enable() at the
> very end, after it has already set DMA options and initialised a default
> context.
> 
> Check the CXL card's link status before setting DMA options or initialising
> a default context. If the link is down, print a warning and return
> immediately.
> 
> Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> Acked-by: Ian Munsie <imunsie@au1.ibm.com>

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/7d1647dc4ba0a61fec5381c1

cheers

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

end of thread, other threads:[~2015-09-08 12:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-04  6:20 [PATCH] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline Andrew Donnellan
2015-09-06 23:58 ` Ian Munsie
2015-09-07  0:22   ` Andrew Donnellan
2015-09-07  6:33     ` Ian Munsie
2015-09-07  8:43       ` Michael Ellerman
2015-09-07  0:47 ` Andrew Donnellan
2015-09-07  1:01   ` Ian Munsie
2015-09-07  0:52 ` [PATCH v2] " Andrew Donnellan
2015-09-07  1:09   ` Ian Munsie
2015-09-07  2:53   ` Michael Ellerman
2015-09-07  4:00     ` Andrew Donnellan
2015-09-08 12:05   ` [v2] " Michael Ellerman

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).