forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cxl: Allow a default context to be associated with an external pci_dev
The cxl kernel API has a concept of a default context associated with each PCI device under the virtual PHB. The Mellanox CX4 will also use the cxl kernel API, but it does not use a virtual PHB - rather, the AFU appears as a physical function as a peer to the networking functions. In order to allow the kernel API to work with those networking functions, we will need to associate a default context with them as well. To this end, refactor the corresponding code to do this in vphb.c and export it so that it can be called from the PHB code. Signed-off-by: Ian Munsie <[email protected]> Reviewed-by: Frederic Barrat <[email protected]> Reviewed-by: Andrew Donnellan <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
- Loading branch information
Showing
7 changed files
with
97 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2014-2016 IBM Corp. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version | ||
* 2 of the License, or (at your option) any later version. | ||
*/ | ||
|
||
#include <linux/pci.h> | ||
#include "cxl.h" | ||
|
||
bool _cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu) | ||
{ | ||
struct cxl_context *ctx; | ||
|
||
/* | ||
* Allocate a context to do cxl things to. This is used for interrupts | ||
* in the peer model using a real phb, and if we eventually do DMA ops | ||
* in the virtual phb, we'll need a default context to attach them to. | ||
*/ | ||
ctx = cxl_dev_context_init(dev); | ||
if (!ctx) | ||
return false; | ||
dev->dev.archdata.cxl_ctx = ctx; | ||
|
||
return (cxl_ops->afu_check_and_enable(afu) == 0); | ||
} | ||
/* exported via cxl_base */ | ||
|
||
void _cxl_pci_disable_device(struct pci_dev *dev) | ||
{ | ||
struct cxl_context *ctx = cxl_get_context(dev); | ||
|
||
if (ctx) { | ||
if (ctx->status == STARTED) { | ||
dev_err(&dev->dev, "Default context started\n"); | ||
return; | ||
} | ||
dev->dev.archdata.cxl_ctx = NULL; | ||
cxl_release_context(ctx); | ||
} | ||
} | ||
/* exported via cxl_base */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters