Lines Matching +full:slice +full:- +full:per +full:- +full:line
1 // SPDX-License-Identifier: GPL-2.0-or-later
23 #include <misc/cxl-base.h>
45 dev_warn(&afu->dev, "WARNING: CXL AFU SLBIA timed out!\n"); in cxl_afu_slbia()
46 return -EBUSY; in cxl_afu_slbia()
51 if (!cxl_ops->link_ok(afu->adapter, afu)) in cxl_afu_slbia()
52 return -EIO; in cxl_afu_slbia()
62 if (ctx->mm != mm) in _cxl_slbia()
65 pr_devel("%s matched mm - card: %i afu: %i pe: %i\n", __func__, in _cxl_slbia()
66 ctx->afu->adapter->adapter_num, ctx->afu->slice, ctx->pe); in _cxl_slbia()
68 spin_lock_irqsave(&ctx->sste_lock, flags); in _cxl_slbia()
70 memset(ctx->sstp, 0, ctx->sst_size); in _cxl_slbia()
71 spin_unlock_irqrestore(&ctx->sste_lock, flags); in _cxl_slbia()
73 cxl_afu_slbia(ctx->afu); in _cxl_slbia()
81 int card, slice, id; in cxl_slbia_core() local
88 spin_lock(&adapter->afu_list_lock); in cxl_slbia_core()
89 for (slice = 0; slice < adapter->slices; slice++) { in cxl_slbia_core()
90 afu = adapter->afu[slice]; in cxl_slbia_core()
91 if (!afu || !afu->enabled) in cxl_slbia_core()
94 idr_for_each_entry(&afu->contexts_idr, ctx, id) in cxl_slbia_core()
98 spin_unlock(&adapter->afu_list_lock); in cxl_slbia_core()
116 ctx->sst_size = PAGE_SIZE; in cxl_alloc_sst()
117 ctx->sst_lru = 0; in cxl_alloc_sst()
118 ctx->sstp = (struct cxl_sste *)get_zeroed_page(GFP_KERNEL); in cxl_alloc_sst()
119 if (!ctx->sstp) { in cxl_alloc_sst()
121 return -ENOMEM; in cxl_alloc_sst()
123 pr_devel("SSTP allocated at 0x%p\n", ctx->sstp); in cxl_alloc_sst()
125 vsid = get_kernel_vsid((u64)ctx->sstp, mmu_kernel_ssize) << 12; in cxl_alloc_sst()
130 size = (((u64)ctx->sst_size >> 8) - 1) << CXL_SSTP0_An_SegTableSize_SHIFT; in cxl_alloc_sst()
133 return -EINVAL; in cxl_alloc_sst()
142 sstp0 |= vsid >> (50-14); /* Top 14 bits of VSID */ in cxl_alloc_sst()
143 sstp1 |= (vsid << (64-(50-14))) & ~ea_mask; in cxl_alloc_sst()
144 sstp1 |= (u64)ctx->sstp & ea_mask; in cxl_alloc_sst()
148 (u64)ctx->sstp, (u64)ctx->sstp & ESID_MASK, mmu_kernel_ssize, vsid, sstp0, sstp1); in cxl_alloc_sst()
151 ctx->sstp0 = sstp0; in cxl_alloc_sst()
152 ctx->sstp1 = sstp1; in cxl_alloc_sst()
164 * We want to regroup up to 4 integers per line, which means they in cxl_dump_debug_buffer()
190 get_device(&adapter->dev); in get_cxl_adapter()
208 adapter->adapter_num = i; in cxl_alloc_adapter_nr()
215 idr_remove(&cxl_adapter_idr, adapter->adapter_num); in cxl_remove_adapter_nr()
225 spin_lock_init(&adapter->afu_list_lock); in cxl_alloc_adapter()
230 if (dev_set_name(&adapter->dev, "card%i", adapter->adapter_num)) in cxl_alloc_adapter()
234 atomic_set(&adapter->contexts_num, -1); in cxl_alloc_adapter()
244 struct cxl_afu *cxl_alloc_afu(struct cxl *adapter, int slice) in cxl_alloc_afu() argument
251 afu->adapter = adapter; in cxl_alloc_afu()
252 afu->dev.parent = &adapter->dev; in cxl_alloc_afu()
253 afu->dev.release = cxl_ops->release_afu; in cxl_alloc_afu()
254 afu->slice = slice; in cxl_alloc_afu()
255 idr_init(&afu->contexts_idr); in cxl_alloc_afu()
256 mutex_init(&afu->contexts_lock); in cxl_alloc_afu()
257 spin_lock_init(&afu->afu_cntl_lock); in cxl_alloc_afu()
258 atomic_set(&afu->configured_state, -1); in cxl_alloc_afu()
259 afu->prefault_mode = CXL_PREFAULT_NONE; in cxl_alloc_afu()
260 afu->irqs_max = afu->adapter->user_irqs; in cxl_alloc_afu()
267 if (afu->modes_supported & CXL_MODE_DIRECTED) in cxl_afu_select_best_mode()
268 return cxl_ops->afu_activate_mode(afu, CXL_MODE_DIRECTED); in cxl_afu_select_best_mode()
270 if (afu->modes_supported & CXL_MODE_DEDICATED) in cxl_afu_select_best_mode()
271 return cxl_ops->afu_activate_mode(afu, CXL_MODE_DEDICATED); in cxl_afu_select_best_mode()
273 dev_warn(&afu->dev, "No supported programming modes available\n"); in cxl_afu_select_best_mode()
282 rc = atomic_inc_unless_negative(&adapter->contexts_num); in cxl_adapter_context_get()
283 return rc ? 0 : -EBUSY; in cxl_adapter_context_get()
288 atomic_dec_if_positive(&adapter->contexts_num); in cxl_adapter_context_put()
294 /* no active contexts -> contexts_num == 0 */ in cxl_adapter_context_lock()
295 rc = atomic_cmpxchg(&adapter->contexts_num, 0, -1); in cxl_adapter_context_lock()
296 return rc ? -EBUSY : 0; in cxl_adapter_context_lock()
301 int val = atomic_cmpxchg(&adapter->contexts_num, -1, 0); in cxl_adapter_context_unlock()
304 * contexts lock taken -> contexts_num == -1 in cxl_adapter_context_unlock()
309 if (val != -1) { in cxl_adapter_context_unlock()
310 atomic_set(&adapter->contexts_num, 0); in cxl_adapter_context_unlock()
321 return -EINVAL; in init_cxl()