Skip to content

Commit

Permalink
cxl: abort cxl_pci_enable_device_hook() if PCI channel is offline
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
  • Loading branch information
Andrew Donnellan authored and Michael Ellerman committed Sep 7, 2015
1 parent fa14486 commit 7d1647d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/misc/cxl/vphb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7d1647d

Please sign in to comment.