phb.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #include <linux/pci.h>
  10. #include "cxl.h"
  11. bool _cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu)
  12. {
  13. struct cxl_context *ctx;
  14. /*
  15. * Allocate a context to do cxl things to. This is used for interrupts
  16. * in the peer model using a real phb, and if we eventually do DMA ops
  17. * in the virtual phb, we'll need a default context to attach them to.
  18. */
  19. ctx = cxl_dev_context_init(dev);
  20. if (!ctx)
  21. return false;
  22. dev->dev.archdata.cxl_ctx = ctx;
  23. return (cxl_ops->afu_check_and_enable(afu) == 0);
  24. }
  25. /* exported via cxl_base */
  26. void _cxl_pci_disable_device(struct pci_dev *dev)
  27. {
  28. struct cxl_context *ctx = cxl_get_context(dev);
  29. if (ctx) {
  30. if (ctx->status == STARTED) {
  31. dev_err(&dev->dev, "Default context started\n");
  32. return;
  33. }
  34. dev->dev.archdata.cxl_ctx = NULL;
  35. cxl_release_context(ctx);
  36. }
  37. }
  38. /* exported via cxl_base */