diff mbox

[v2] cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline

Message ID 1441587178-5581-1-git-send-email-andrew.donnellan@au1.ibm.com (mailing list archive)
State Accepted
Delegated to: Michael Ellerman
Headers show

Commit Message

Andrew Donnellan Sept. 7, 2015, 12:52 a.m. UTC
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(+)

Comments

Ian Munsie Sept. 7, 2015, 1:09 a.m. UTC | #1
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Michael Ellerman Sept. 7, 2015, 2:53 a.m. UTC | #2
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
Andrew Donnellan Sept. 7, 2015, 4 a.m. UTC | #3
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
Michael Ellerman Sept. 8, 2015, 12:05 p.m. UTC | #4
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
diff mbox

Patch

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