|
@@ -44,6 +44,7 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)
|
|
|
{
|
|
|
struct pci_controller *phb;
|
|
|
struct cxl_afu *afu;
|
|
|
+ struct cxl_context *ctx;
|
|
|
|
|
|
phb = pci_bus_to_host(dev->bus);
|
|
|
afu = (struct cxl_afu *)phb->private_data;
|
|
@@ -56,7 +57,30 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)
|
|
|
set_dma_ops(&dev->dev, &dma_nommu_ops);
|
|
|
set_dma_offset(&dev->dev, PAGE_OFFSET);
|
|
|
|
|
|
- return _cxl_pci_associate_default_context(dev, afu);
|
|
|
+ /*
|
|
|
+ * Allocate a context to do cxl things too. If we eventually do real
|
|
|
+ * DMA ops, we'll need a default context to attach them to
|
|
|
+ */
|
|
|
+ ctx = cxl_dev_context_init(dev);
|
|
|
+ if (IS_ERR(ctx))
|
|
|
+ return false;
|
|
|
+ dev->dev.archdata.cxl_ctx = ctx;
|
|
|
+
|
|
|
+ return (cxl_ops->afu_check_and_enable(afu) == 0);
|
|
|
+}
|
|
|
+
|
|
|
+static void cxl_pci_disable_device(struct pci_dev *dev)
|
|
|
+{
|
|
|
+ struct cxl_context *ctx = cxl_get_context(dev);
|
|
|
+
|
|
|
+ if (ctx) {
|
|
|
+ if (ctx->status == STARTED) {
|
|
|
+ dev_err(&dev->dev, "Default context started\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ dev->dev.archdata.cxl_ctx = NULL;
|
|
|
+ cxl_release_context(ctx);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
static resource_size_t cxl_pci_window_alignment(struct pci_bus *bus,
|
|
@@ -190,8 +214,8 @@ static struct pci_controller_ops cxl_pci_controller_ops =
|
|
|
{
|
|
|
.probe_mode = cxl_pci_probe_mode,
|
|
|
.enable_device_hook = cxl_pci_enable_device_hook,
|
|
|
- .disable_device = _cxl_pci_disable_device,
|
|
|
- .release_device = _cxl_pci_disable_device,
|
|
|
+ .disable_device = cxl_pci_disable_device,
|
|
|
+ .release_device = cxl_pci_disable_device,
|
|
|
.window_alignment = cxl_pci_window_alignment,
|
|
|
.reset_secondary_bus = cxl_pci_reset_secondary_bus,
|
|
|
.setup_msi_irqs = cxl_setup_msi_irqs,
|