diff options
Diffstat (limited to 'drivers/misc/cxl/vphb.c')
-rw-r--r-- | drivers/misc/cxl/vphb.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c index 1a99c9c7a6fb..7908633d9204 100644 --- a/drivers/misc/cxl/vphb.c +++ b/drivers/misc/cxl/vphb.c | |||
@@ -44,6 +44,7 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev) | |||
44 | { | 44 | { |
45 | struct pci_controller *phb; | 45 | struct pci_controller *phb; |
46 | struct cxl_afu *afu; | 46 | struct cxl_afu *afu; |
47 | struct cxl_context *ctx; | ||
47 | 48 | ||
48 | phb = pci_bus_to_host(dev->bus); | 49 | phb = pci_bus_to_host(dev->bus); |
49 | afu = (struct cxl_afu *)phb->private_data; | 50 | afu = (struct cxl_afu *)phb->private_data; |
@@ -56,7 +57,30 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev) | |||
56 | set_dma_ops(&dev->dev, &dma_nommu_ops); | 57 | set_dma_ops(&dev->dev, &dma_nommu_ops); |
57 | set_dma_offset(&dev->dev, PAGE_OFFSET); | 58 | set_dma_offset(&dev->dev, PAGE_OFFSET); |
58 | 59 | ||
59 | return _cxl_pci_associate_default_context(dev, afu); | 60 | /* |
61 | * Allocate a context to do cxl things too. If we eventually do real | ||
62 | * DMA ops, we'll need a default context to attach them to | ||
63 | */ | ||
64 | ctx = cxl_dev_context_init(dev); | ||
65 | if (IS_ERR(ctx)) | ||
66 | return false; | ||
67 | dev->dev.archdata.cxl_ctx = ctx; | ||
68 | |||
69 | return (cxl_ops->afu_check_and_enable(afu) == 0); | ||
70 | } | ||
71 | |||
72 | static void cxl_pci_disable_device(struct pci_dev *dev) | ||
73 | { | ||
74 | struct cxl_context *ctx = cxl_get_context(dev); | ||
75 | |||
76 | if (ctx) { | ||
77 | if (ctx->status == STARTED) { | ||
78 | dev_err(&dev->dev, "Default context started\n"); | ||
79 | return; | ||
80 | } | ||
81 | dev->dev.archdata.cxl_ctx = NULL; | ||
82 | cxl_release_context(ctx); | ||
83 | } | ||
60 | } | 84 | } |
61 | 85 | ||
62 | static resource_size_t cxl_pci_window_alignment(struct pci_bus *bus, | 86 | 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 = | |||
190 | { | 214 | { |
191 | .probe_mode = cxl_pci_probe_mode, | 215 | .probe_mode = cxl_pci_probe_mode, |
192 | .enable_device_hook = cxl_pci_enable_device_hook, | 216 | .enable_device_hook = cxl_pci_enable_device_hook, |
193 | .disable_device = _cxl_pci_disable_device, | 217 | .disable_device = cxl_pci_disable_device, |
194 | .release_device = _cxl_pci_disable_device, | 218 | .release_device = cxl_pci_disable_device, |
195 | .window_alignment = cxl_pci_window_alignment, | 219 | .window_alignment = cxl_pci_window_alignment, |
196 | .reset_secondary_bus = cxl_pci_reset_secondary_bus, | 220 | .reset_secondary_bus = cxl_pci_reset_secondary_bus, |
197 | .setup_msi_irqs = cxl_setup_msi_irqs, | 221 | .setup_msi_irqs = cxl_setup_msi_irqs, |