aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/cxl/native.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 13:12:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 13:12:41 -0400
commitc04a5880299eab3da8c10547db96ea9cdffd44a6 (patch)
tree8708b60e410780ce8ea2074335033b016cab4c4f /drivers/misc/cxl/native.c
parenta1c28b75a95808161cacbb3531c418abe248994e (diff)
parent138a076496e61c68ebc1dcccc088705826bbe26d (diff)
Merge tag 'powerpc-4.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc updates from Michael Ellerman: "Highlights: - Support for Power ISA 3.0 (Power9) Radix Tree MMU from Aneesh Kumar K.V - Live patching support for ppc64le (also merged via livepatching.git) Various cleanups & minor fixes from: - Aaro Koskinen, Alexey Kardashevskiy, Andrew Donnellan, Aneesh Kumar K.V, Chris Smart, Daniel Axtens, Frederic Barrat, Gavin Shan, Ian Munsie, Lennart Sorensen, Madhavan Srinivasan, Mahesh Salgaonkar, Markus Elfring, Michael Ellerman, Oliver O'Halloran, Paul Gortmaker, Paul Mackerras, Rashmica Gupta, Russell Currey, Suraj Jitindar Singh, Thiago Jung Bauermann, Valentin Rothberg, Vipin K Parashar. General: - Update LMB associativity index during DLPAR add/remove from Nathan Fontenot - Fix branching to OOL handlers in relocatable kernel from Hari Bathini - Add support for userspace Power9 copy/paste from Chris Smart - Always use STRICT_MM_TYPECHECKS from Michael Ellerman - Add mask of possible MMU features from Michael Ellerman PCI: - Enable pass through of NVLink to guests from Alexey Kardashevskiy - Cleanups in preparation for powernv PCI hotplug from Gavin Shan - Don't report error in eeh_pe_reset_and_recover() from Gavin Shan - Restore initial state in eeh_pe_reset_and_recover() from Gavin Shan - Revert "powerpc/eeh: Fix crash in eeh_add_device_early() on Cell" from Guilherme G Piccoli - Remove the dependency on EEH struct in DDW mechanism from Guilherme G Piccoli selftests: - Test cp_abort during context switch from Chris Smart - Add several tests for transactional memory support from Rashmica Gupta perf: - Add support for sampling interrupt register state from Anju T - Add support for unwinding perf-stackdump from Chandan Kumar cxl: - Configure the PSL for two CAPI ports on POWER8NVL from Philippe Bergheaud - Allow initialization on timebase sync failures from Frederic Barrat - Increase timeout for detection of AFU mmio hang from Frederic Barrat - Handle num_of_processes larger than can fit in the SPA from Ian Munsie - Ensure PSL interrupt is configured for contexts with no AFU IRQs from Ian Munsie - Add kernel API to allow a context to operate with relocate disabled from Ian Munsie - Check periodically the coherent platform function's state from Christophe Lombard Freescale: - Updates from Scott: "Contains 86xx fixes, minor device tree fixes, an erratum workaround, and a kconfig dependency fix." * tag 'powerpc-4.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (192 commits) powerpc/86xx: Fix PCI interrupt map definition powerpc/86xx: Move pci1 definition to the include file powerpc/fsl: Fix build of the dtb embedded kernel images powerpc/fsl: Fix rcpm compatible string powerpc/fsl: Remove FSL_SOC dependency from FSL_LBC powerpc/fsl-pci: Add a workaround for PCI 5 errata powerpc/fsl: Fix SPI compatible on t208xrdb and t1040rdb powerpc/powernv/npu: Add PE to PHB's list powerpc/powernv: Fix insufficient memory allocation powerpc/iommu: Remove the dependency on EEH struct in DDW mechanism Revert "powerpc/eeh: Fix crash in eeh_add_device_early() on Cell" powerpc/eeh: Drop unnecessary label in eeh_pe_change_owner() powerpc/eeh: Ignore handlers in eeh_pe_reset_and_recover() powerpc/eeh: Restore initial state in eeh_pe_reset_and_recover() powerpc/eeh: Don't report error in eeh_pe_reset_and_recover() Revert "powerpc/powernv: Exclude root bus in pnv_pci_reset_secondary_bus()" powerpc/powernv/npu: Enable NVLink pass through powerpc/powernv/npu: Rework TCE Kill handling powerpc/powernv/npu: Add set/unset window helpers powerpc/powernv/ioda2: Export debug helper pe_level_printk() ...
Diffstat (limited to 'drivers/misc/cxl/native.c')
-rw-r--r--drivers/misc/cxl/native.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index ecf7557cd657..55d8a1459f28 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -186,16 +186,25 @@ static int spa_max_procs(int spa_size)
186 186
187int cxl_alloc_spa(struct cxl_afu *afu) 187int cxl_alloc_spa(struct cxl_afu *afu)
188{ 188{
189 unsigned spa_size;
190
189 /* Work out how many pages to allocate */ 191 /* Work out how many pages to allocate */
190 afu->native->spa_order = 0; 192 afu->native->spa_order = 0;
191 do { 193 do {
192 afu->native->spa_order++; 194 afu->native->spa_order++;
193 afu->native->spa_size = (1 << afu->native->spa_order) * PAGE_SIZE; 195 spa_size = (1 << afu->native->spa_order) * PAGE_SIZE;
196
197 if (spa_size > 0x100000) {
198 dev_warn(&afu->dev, "num_of_processes too large for the SPA, limiting to %i (0x%x)\n",
199 afu->native->spa_max_procs, afu->native->spa_size);
200 afu->num_procs = afu->native->spa_max_procs;
201 break;
202 }
203
204 afu->native->spa_size = spa_size;
194 afu->native->spa_max_procs = spa_max_procs(afu->native->spa_size); 205 afu->native->spa_max_procs = spa_max_procs(afu->native->spa_size);
195 } while (afu->native->spa_max_procs < afu->num_procs); 206 } while (afu->native->spa_max_procs < afu->num_procs);
196 207
197 WARN_ON(afu->native->spa_size > 0x100000); /* Max size supported by the hardware */
198
199 if (!(afu->native->spa = (struct cxl_process_element *) 208 if (!(afu->native->spa = (struct cxl_process_element *)
200 __get_free_pages(GFP_KERNEL | __GFP_ZERO, afu->native->spa_order))) { 209 __get_free_pages(GFP_KERNEL | __GFP_ZERO, afu->native->spa_order))) {
201 pr_err("cxl_alloc_spa: Unable to allocate scheduled process area\n"); 210 pr_err("cxl_alloc_spa: Unable to allocate scheduled process area\n");
@@ -486,8 +495,9 @@ static u64 calculate_sr(struct cxl_context *ctx)
486 if (mfspr(SPRN_LPCR) & LPCR_TC) 495 if (mfspr(SPRN_LPCR) & LPCR_TC)
487 sr |= CXL_PSL_SR_An_TC; 496 sr |= CXL_PSL_SR_An_TC;
488 if (ctx->kernel) { 497 if (ctx->kernel) {
489 sr |= CXL_PSL_SR_An_R | (mfmsr() & MSR_SF); 498 if (!ctx->real_mode)
490 sr |= CXL_PSL_SR_An_HV; 499 sr |= CXL_PSL_SR_An_R;
500 sr |= (mfmsr() & MSR_SF) | CXL_PSL_SR_An_HV;
491 } else { 501 } else {
492 sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R; 502 sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
493 sr &= ~(CXL_PSL_SR_An_HV); 503 sr &= ~(CXL_PSL_SR_An_HV);
@@ -526,6 +536,15 @@ static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr)
526 ctx->elem->common.sstp0 = cpu_to_be64(ctx->sstp0); 536 ctx->elem->common.sstp0 = cpu_to_be64(ctx->sstp0);
527 ctx->elem->common.sstp1 = cpu_to_be64(ctx->sstp1); 537 ctx->elem->common.sstp1 = cpu_to_be64(ctx->sstp1);
528 538
539 /*
540 * Ensure we have the multiplexed PSL interrupt set up to take faults
541 * for kernel contexts that may not have allocated any AFU IRQs at all:
542 */
543 if (ctx->irqs.range[0] == 0) {
544 ctx->irqs.offset[0] = ctx->afu->native->psl_hwirq;
545 ctx->irqs.range[0] = 1;
546 }
547
529 for (r = 0; r < CXL_IRQ_RANGES; r++) { 548 for (r = 0; r < CXL_IRQ_RANGES; r++) {
530 ctx->elem->ivte_offsets[r] = cpu_to_be16(ctx->irqs.offset[r]); 549 ctx->elem->ivte_offsets[r] = cpu_to_be16(ctx->irqs.offset[r]);
531 ctx->elem->ivte_ranges[r] = cpu_to_be16(ctx->irqs.range[r]); 550 ctx->elem->ivte_ranges[r] = cpu_to_be16(ctx->irqs.range[r]);