Linux 4.16.11
[linux/fpc-iii.git] / drivers / misc / cxl / phb.c
blob6ec69ada19f480ce62c1763e8b473a923f87951b
1 /*
2 * Copyright 2014-2016 IBM Corp.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
10 #include <linux/pci.h>
11 #include "cxl.h"
13 bool _cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu)
15 struct cxl_context *ctx;
18 * Allocate a context to do cxl things to. This is used for interrupts
19 * in the peer model using a real phb, and if we eventually do DMA ops
20 * in the virtual phb, we'll need a default context to attach them to.
22 ctx = cxl_dev_context_init(dev);
23 if (IS_ERR(ctx))
24 return false;
25 dev->dev.archdata.cxl_ctx = ctx;
27 return (cxl_ops->afu_check_and_enable(afu) == 0);
29 /* exported via cxl_base */
31 void _cxl_pci_disable_device(struct pci_dev *dev)
33 struct cxl_context *ctx = cxl_get_context(dev);
35 if (ctx) {
36 if (ctx->status == STARTED) {
37 dev_err(&dev->dev, "Default context started\n");
38 return;
40 dev->dev.archdata.cxl_ctx = NULL;
41 cxl_release_context(ctx);
44 /* exported via cxl_base */