• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014-2016 IBM Corp.
3  *
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  */
9 
10 #include <linux/pci.h>
11 #include "cxl.h"
12 
_cxl_pci_associate_default_context(struct pci_dev * dev,struct cxl_afu * afu)13 bool _cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu)
14 {
15 	struct cxl_context *ctx;
16 
17 	/*
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.
21 	 */
22 	ctx = cxl_dev_context_init(dev);
23 	if (!ctx)
24 		return false;
25 	dev->dev.archdata.cxl_ctx = ctx;
26 
27 	return (cxl_ops->afu_check_and_enable(afu) == 0);
28 }
29 /* exported via cxl_base */
30 
_cxl_pci_disable_device(struct pci_dev * dev)31 void _cxl_pci_disable_device(struct pci_dev *dev)
32 {
33 	struct cxl_context *ctx = cxl_get_context(dev);
34 
35 	if (ctx) {
36 		if (ctx->status == STARTED) {
37 			dev_err(&dev->dev, "Default context started\n");
38 			return;
39 		}
40 		dev->dev.archdata.cxl_ctx = NULL;
41 		cxl_release_context(ctx);
42 	}
43 }
44 /* exported via cxl_base */
45