Skip to content

Commit f18a4e1

Browse files
fbarratmpe
authored andcommitted
Revert "cxl: Allow a default context to be associated with an external pci_dev"
Remove abandonned capi support for the Mellanox CX4. This reverts commit a19bd79. Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com> Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 322dc4a commit f18a4e1

7 files changed

Lines changed: 28 additions & 97 deletions

File tree

‎drivers/misc/cxl/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ccflags-$(CONFIG_PPC_WERROR) += -Werror
44

55
cxl-y += main.o file.o irq.o fault.o native.o
66
cxl-y += context.o sysfs.o pci.o trace.o
7-
cxl-y += vphb.o phb.o api.o cxllib.o
7+
cxl-y += vphb.o api.o cxllib.o
88
cxl-$(CONFIG_PPC_PSERIES) += flash.o guest.o of.o hcalls.o
99
cxl-$(CONFIG_DEBUG_FS) += debugfs.o
1010
obj-$(CONFIG_CXL) += cxl.o

‎drivers/misc/cxl/base.c‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -106,41 +106,6 @@ int cxl_update_properties(struct device_node *dn,
106106
}
107107
EXPORT_SYMBOL_GPL(cxl_update_properties);
108108

109-
/*
110-
* API calls into the driver that may be called from the PHB code and must be
111-
* built in.
112-
*/
113-
bool cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu)
114-
{
115-
bool ret;
116-
struct cxl_calls *calls;
117-
118-
calls = cxl_calls_get();
119-
if (!calls)
120-
return false;
121-
122-
ret = calls->cxl_pci_associate_default_context(dev, afu);
123-
124-
cxl_calls_put(calls);
125-
126-
return ret;
127-
}
128-
EXPORT_SYMBOL_GPL(cxl_pci_associate_default_context);
129-
130-
void cxl_pci_disable_device(struct pci_dev *dev)
131-
{
132-
struct cxl_calls *calls;
133-
134-
calls = cxl_calls_get();
135-
if (!calls)
136-
return;
137-
138-
calls->cxl_pci_disable_device(dev);
139-
140-
cxl_calls_put(calls);
141-
}
142-
EXPORT_SYMBOL_GPL(cxl_pci_disable_device);
143-
144109
static int __init cxl_base_init(void)
145110
{
146111
struct device_node *np;

‎drivers/misc/cxl/cxl.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -867,15 +867,9 @@ static inline bool cxl_is_power9_dd1(void)
867867
ssize_t cxl_pci_afu_read_err_buffer(struct cxl_afu *afu, char *buf,
868868
loff_t off, size_t count);
869869

870-
/* Internal functions wrapped in cxl_base to allow PHB to call them */
871-
bool _cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu);
872-
void _cxl_pci_disable_device(struct pci_dev *dev);
873870

874871
struct cxl_calls {
875872
void (*cxl_slbia)(struct mm_struct *mm);
876-
bool (*cxl_pci_associate_default_context)(struct pci_dev *dev, struct cxl_afu *afu);
877-
void (*cxl_pci_disable_device)(struct pci_dev *dev);
878-
879873
struct module *owner;
880874
};
881875
int register_cxl_calls(struct cxl_calls *calls);

‎drivers/misc/cxl/main.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ static inline void cxl_slbia_core(struct mm_struct *mm)
104104

105105
static struct cxl_calls cxl_calls = {
106106
.cxl_slbia = cxl_slbia_core,
107-
.cxl_pci_associate_default_context = _cxl_pci_associate_default_context,
108-
.cxl_pci_disable_device = _cxl_pci_disable_device,
109107
.owner = THIS_MODULE,
110108
};
111109

‎drivers/misc/cxl/phb.c‎

Lines changed: 0 additions & 44 deletions
This file was deleted.

‎drivers/misc/cxl/vphb.c‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)
4444
{
4545
struct pci_controller *phb;
4646
struct cxl_afu *afu;
47+
struct cxl_context *ctx;
4748

4849
phb = pci_bus_to_host(dev->bus);
4950
afu = (struct cxl_afu *)phb->private_data;
@@ -56,7 +57,30 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)
5657
set_dma_ops(&dev->dev, &dma_nommu_ops);
5758
set_dma_offset(&dev->dev, PAGE_OFFSET);
5859

59-
return _cxl_pci_associate_default_context(dev, afu);
60+
/*
61+
* Allocate a context to do cxl things too. If we eventually do real
62+
* DMA ops, we'll need a default context to attach them to
63+
*/
64+
ctx = cxl_dev_context_init(dev);
65+
if (IS_ERR(ctx))
66+
return false;
67+
dev->dev.archdata.cxl_ctx = ctx;
68+
69+
return (cxl_ops->afu_check_and_enable(afu) == 0);
70+
}
71+
72+
static void cxl_pci_disable_device(struct pci_dev *dev)
73+
{
74+
struct cxl_context *ctx = cxl_get_context(dev);
75+
76+
if (ctx) {
77+
if (ctx->status == STARTED) {
78+
dev_err(&dev->dev, "Default context started\n");
79+
return;
80+
}
81+
dev->dev.archdata.cxl_ctx = NULL;
82+
cxl_release_context(ctx);
83+
}
6084
}
6185

6286
static resource_size_t cxl_pci_window_alignment(struct pci_bus *bus,
@@ -190,8 +214,8 @@ static struct pci_controller_ops cxl_pci_controller_ops =
190214
{
191215
.probe_mode = cxl_pci_probe_mode,
192216
.enable_device_hook = cxl_pci_enable_device_hook,
193-
.disable_device = _cxl_pci_disable_device,
194-
.release_device = _cxl_pci_disable_device,
217+
.disable_device = cxl_pci_disable_device,
218+
.release_device = cxl_pci_disable_device,
195219
.window_alignment = cxl_pci_window_alignment,
196220
.reset_secondary_bus = cxl_pci_reset_secondary_bus,
197221
.setup_msi_irqs = cxl_setup_msi_irqs,

‎include/misc/cxl-base.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#ifndef _MISC_CXL_BASE_H
1111
#define _MISC_CXL_BASE_H
1212

13-
#include <misc/cxl.h>
14-
1513
#ifdef CONFIG_CXL_BASE
1614

1715
#define CXL_IRQ_RANGES 4
@@ -41,17 +39,13 @@ static inline void cxl_ctx_put(void)
4139
struct cxl_afu *cxl_afu_get(struct cxl_afu *afu);
4240
void cxl_afu_put(struct cxl_afu *afu);
4341
void cxl_slbia(struct mm_struct *mm);
44-
bool cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu);
45-
void cxl_pci_disable_device(struct pci_dev *dev);
4642

4743
#else /* CONFIG_CXL_BASE */
4844

4945
static inline bool cxl_ctx_in_use(void) { return false; }
5046
static inline struct cxl_afu *cxl_afu_get(struct cxl_afu *afu) { return NULL; }
5147
static inline void cxl_afu_put(struct cxl_afu *afu) {}
5248
static inline void cxl_slbia(struct mm_struct *mm) {}
53-
static inline bool cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu) { return false; }
54-
static inline void cxl_pci_disable_device(struct pci_dev *dev) {}
5549

5650
#endif /* CONFIG_CXL_BASE */
5751

0 commit comments

Comments
 (0)