Ian Munsie | a19bd79 | 2016-07-14 07:17:04 +1000 | [diff] [blame] | 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 | |
| 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); |
Christophe Jaillet | bb81733 | 2016-10-30 22:40:47 +0100 | [diff] [blame] | 23 | if (IS_ERR(ctx)) |
Ian Munsie | a19bd79 | 2016-07-14 07:17:04 +1000 | [diff] [blame] | 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 | |
| 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 */ |