summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-07 13:23:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-07 13:23:33 -0400
commitc90fca951e90ba470a3dc6087667edffcf8db21b (patch)
treeb131279a9290826e78884ee706cc0a4f1d82be4e /drivers
parentc0ab85267e25e34ce8b7e4429f0ef01fa0795b80 (diff)
parentff5bc793e47b537bf3e904fada585e102c54dd8b (diff)
Merge tag 'powerpc-4.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc updates from Michael Ellerman: "Notable changes: - Support for split PMD page table lock on 64-bit Book3S (Power8/9). - Add support for HAVE_RELIABLE_STACKTRACE, so we properly support live patching again. - Add support for patching barrier_nospec in copy_from_user() and syscall entry. - A couple of fixes for our data breakpoints on Book3S. - A series from Nick optimising TLB/mm handling with the Radix MMU. - Numerous small cleanups to squash sparse/gcc warnings from Mathieu Malaterre. - Several series optimising various parts of the 32-bit code from Christophe Leroy. - Removal of support for two old machines, "SBC834xE" and "C2K" ("GEFanuc,C2K"), which is why the diffstat has so many deletions. And many other small improvements & fixes. There's a few out-of-area changes. Some minor ftrace changes OK'ed by Steve, and a fix to our powernv cpuidle driver. Then there's a series touching mm, x86 and fs/proc/task_mmu.c, which cleans up some details around pkey support. It was ack'ed/reviewed by Ingo & Dave and has been in next for several weeks. Thanks to: Akshay Adiga, Alastair D'Silva, Alexey Kardashevskiy, Al Viro, Andrew Donnellan, Aneesh Kumar K.V, Anju T Sudhakar, Arnd Bergmann, Balbir Singh, Cédric Le Goater, Christophe Leroy, Christophe Lombard, Colin Ian King, Dave Hansen, Fabio Estevam, Finn Thain, Frederic Barrat, Gautham R. Shenoy, Haren Myneni, Hari Bathini, Ingo Molnar, Jonathan Neuschäfer, Josh Poimboeuf, Kamalesh Babulal, Madhavan Srinivasan, Mahesh Salgaonkar, Mark Greer, Mathieu Malaterre, Matthew Wilcox, Michael Neuling, Michal Suchanek, Naveen N. Rao, Nicholas Piggin, Nicolai Stange, Olof Johansson, Paul Gortmaker, Paul Mackerras, Peter Rosin, Pridhiviraj Paidipeddi, Ram Pai, Rashmica Gupta, Ravi Bangoria, Russell Currey, Sam Bobroff, Samuel Mendoza-Jonas, Segher Boessenkool, Shilpasri G Bhat, Simon Guo, Souptick Joarder, Stewart Smith, Thiago Jung Bauermann, Torsten Duwe, Vaibhav Jain, Wei Yongjun, Wolfram Sang, Yisheng Xie, YueHaibing" * tag 'powerpc-4.18-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (251 commits) powerpc/64s/radix: Fix missing ptesync in flush_cache_vmap cpuidle: powernv: Fix promotion from snooze if next state disabled powerpc: fix build failure by disabling attribute-alias warning in pci_32 ocxl: Fix missing unlock on error in afu_ioctl_enable_p9_wait() powerpc-opal: fix spelling mistake "Uniterrupted" -> "Uninterrupted" powerpc: fix spelling mistake: "Usupported" -> "Unsupported" powerpc/pkeys: Detach execute_only key on !PROT_EXEC powerpc/powernv: copy/paste - Mask SO bit in CR powerpc: Remove core support for Marvell mv64x60 hostbridges powerpc/boot: Remove core support for Marvell mv64x60 hostbridges powerpc/boot: Remove support for Marvell mv64x60 i2c controller powerpc/boot: Remove support for Marvell MPSC serial controller powerpc/embedded6xx: Remove C2K board support powerpc/lib: optimise PPC32 memcmp powerpc/lib: optimise 32 bits __clear_user() powerpc/time: inline arch_vtime_task_switch() powerpc/Makefile: set -mcpu=860 flag for the 8xx powerpc: Implement csum_ipv6_magic in assembly powerpc/32: Optimise __csum_partial() powerpc/lib: Adjust .balign inside string functions for PPC32 ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cpuidle/cpuidle-powernv.c32
-rw-r--r--drivers/hwmon/ibmpowernv.c9
-rw-r--r--drivers/macintosh/via-pmu.c18
-rw-r--r--drivers/macintosh/windfarm_pm121.c2
-rw-r--r--drivers/macintosh/windfarm_pm81.c2
-rw-r--r--drivers/macintosh/windfarm_pm91.c2
-rw-r--r--drivers/misc/cxl/pci.c4
-rw-r--r--drivers/misc/cxl/sysfs.c16
-rw-r--r--drivers/misc/ocxl/context.c5
-rw-r--r--drivers/misc/ocxl/file.c80
-rw-r--r--drivers/misc/ocxl/link.c38
-rw-r--r--drivers/misc/ocxl/ocxl_internal.h1
-rw-r--r--drivers/tty/hvc/hvc_opal.c1
13 files changed, 180 insertions, 30 deletions
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
index 1a8234e706bc..d29e4f041efe 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -43,9 +43,31 @@ struct stop_psscr_table {
43 43
44static struct stop_psscr_table stop_psscr_table[CPUIDLE_STATE_MAX] __read_mostly; 44static struct stop_psscr_table stop_psscr_table[CPUIDLE_STATE_MAX] __read_mostly;
45 45
46static u64 snooze_timeout __read_mostly; 46static u64 default_snooze_timeout __read_mostly;
47static bool snooze_timeout_en __read_mostly; 47static bool snooze_timeout_en __read_mostly;
48 48
49static u64 get_snooze_timeout(struct cpuidle_device *dev,
50 struct cpuidle_driver *drv,
51 int index)
52{
53 int i;
54
55 if (unlikely(!snooze_timeout_en))
56 return default_snooze_timeout;
57
58 for (i = index + 1; i < drv->state_count; i++) {
59 struct cpuidle_state *s = &drv->states[i];
60 struct cpuidle_state_usage *su = &dev->states_usage[i];
61
62 if (s->disabled || su->disable)
63 continue;
64
65 return s->target_residency * tb_ticks_per_usec;
66 }
67
68 return default_snooze_timeout;
69}
70
49static int snooze_loop(struct cpuidle_device *dev, 71static int snooze_loop(struct cpuidle_device *dev,
50 struct cpuidle_driver *drv, 72 struct cpuidle_driver *drv,
51 int index) 73 int index)
@@ -56,7 +78,7 @@ static int snooze_loop(struct cpuidle_device *dev,
56 78
57 local_irq_enable(); 79 local_irq_enable();
58 80
59 snooze_exit_time = get_tb() + snooze_timeout; 81 snooze_exit_time = get_tb() + get_snooze_timeout(dev, drv, index);
60 ppc64_runlatch_off(); 82 ppc64_runlatch_off();
61 HMT_very_low(); 83 HMT_very_low();
62 while (!need_resched()) { 84 while (!need_resched()) {
@@ -465,11 +487,9 @@ static int powernv_idle_probe(void)
465 cpuidle_state_table = powernv_states; 487 cpuidle_state_table = powernv_states;
466 /* Device tree can indicate more idle states */ 488 /* Device tree can indicate more idle states */
467 max_idle_state = powernv_add_idle_states(); 489 max_idle_state = powernv_add_idle_states();
468 if (max_idle_state > 1) { 490 default_snooze_timeout = TICK_USEC * tb_ticks_per_usec;
491 if (max_idle_state > 1)
469 snooze_timeout_en = true; 492 snooze_timeout_en = true;
470 snooze_timeout = powernv_states[1].target_residency *
471 tb_ticks_per_usec;
472 }
473 } else 493 } else
474 return -ENODEV; 494 return -ENODEV;
475 495
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c
index 5ccdd0b52650..0298745d46e4 100644
--- a/drivers/hwmon/ibmpowernv.c
+++ b/drivers/hwmon/ibmpowernv.c
@@ -51,6 +51,7 @@ enum sensors {
51 POWER_SUPPLY, 51 POWER_SUPPLY,
52 POWER_INPUT, 52 POWER_INPUT,
53 CURRENT, 53 CURRENT,
54 ENERGY,
54 MAX_SENSOR_TYPE, 55 MAX_SENSOR_TYPE,
55}; 56};
56 57
@@ -78,6 +79,7 @@ static struct sensor_group {
78 { "in" }, 79 { "in" },
79 { "power" }, 80 { "power" },
80 { "curr" }, 81 { "curr" },
82 { "energy" },
81}; 83};
82 84
83struct sensor_data { 85struct sensor_data {
@@ -101,9 +103,10 @@ static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
101 struct sensor_data *sdata = container_of(devattr, struct sensor_data, 103 struct sensor_data *sdata = container_of(devattr, struct sensor_data,
102 dev_attr); 104 dev_attr);
103 ssize_t ret; 105 ssize_t ret;
104 u32 x; 106 u64 x;
107
108 ret = opal_get_sensor_data_u64(sdata->id, &x);
105 109
106 ret = opal_get_sensor_data(sdata->id, &x);
107 if (ret) 110 if (ret)
108 return ret; 111 return ret;
109 112
@@ -114,7 +117,7 @@ static ssize_t show_sensor(struct device *dev, struct device_attribute *devattr,
114 else if (sdata->type == POWER_INPUT) 117 else if (sdata->type == POWER_INPUT)
115 x *= 1000000; 118 x *= 1000000;
116 119
117 return sprintf(buf, "%u\n", x); 120 return sprintf(buf, "%llu\n", x);
118} 121}
119 122
120static ssize_t show_label(struct device *dev, struct device_attribute *devattr, 123static ssize_t show_label(struct device *dev, struct device_attribute *devattr,
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 6663893f41c4..25c1ce811053 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -274,7 +274,7 @@ int __init find_via_pmu(void)
274 u64 taddr; 274 u64 taddr;
275 const u32 *reg; 275 const u32 *reg;
276 276
277 if (via != 0) 277 if (via)
278 return 1; 278 return 1;
279 vias = of_find_node_by_name(NULL, "via-pmu"); 279 vias = of_find_node_by_name(NULL, "via-pmu");
280 if (vias == NULL) 280 if (vias == NULL)
@@ -1115,7 +1115,7 @@ pmu_queue_request(struct adb_request *req)
1115 req->complete = 0; 1115 req->complete = 0;
1116 1116
1117 spin_lock_irqsave(&pmu_lock, flags); 1117 spin_lock_irqsave(&pmu_lock, flags);
1118 if (current_req != 0) { 1118 if (current_req) {
1119 last_req->next = req; 1119 last_req->next = req;
1120 last_req = req; 1120 last_req = req;
1121 } else { 1121 } else {
@@ -1190,7 +1190,7 @@ pmu_start(void)
1190 /* assert pmu_state == idle */ 1190 /* assert pmu_state == idle */
1191 /* get the packet to send */ 1191 /* get the packet to send */
1192 req = current_req; 1192 req = current_req;
1193 if (req == 0 || pmu_state != idle 1193 if (!req || pmu_state != idle
1194 || (/*req->reply_expected && */req_awaiting_reply)) 1194 || (/*req->reply_expected && */req_awaiting_reply))
1195 return; 1195 return;
1196 1196
@@ -1345,7 +1345,7 @@ next:
1345 if ((1 << pirq) & PMU_INT_ADB) { 1345 if ((1 << pirq) & PMU_INT_ADB) {
1346 if ((data[0] & PMU_INT_ADB_AUTO) == 0) { 1346 if ((data[0] & PMU_INT_ADB_AUTO) == 0) {
1347 struct adb_request *req = req_awaiting_reply; 1347 struct adb_request *req = req_awaiting_reply;
1348 if (req == 0) { 1348 if (!req) {
1349 printk(KERN_ERR "PMU: extra ADB reply\n"); 1349 printk(KERN_ERR "PMU: extra ADB reply\n");
1350 return; 1350 return;
1351 } 1351 }
@@ -1712,7 +1712,7 @@ pmu_shutdown(void)
1712int 1712int
1713pmu_present(void) 1713pmu_present(void)
1714{ 1714{
1715 return via != 0; 1715 return via != NULL;
1716} 1716}
1717 1717
1718#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32) 1718#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
@@ -2044,7 +2044,7 @@ pmu_open(struct inode *inode, struct file *file)
2044 unsigned long flags; 2044 unsigned long flags;
2045 2045
2046 pp = kmalloc(sizeof(struct pmu_private), GFP_KERNEL); 2046 pp = kmalloc(sizeof(struct pmu_private), GFP_KERNEL);
2047 if (pp == 0) 2047 if (!pp)
2048 return -ENOMEM; 2048 return -ENOMEM;
2049 pp->rb_get = pp->rb_put = 0; 2049 pp->rb_get = pp->rb_put = 0;
2050 spin_lock_init(&pp->lock); 2050 spin_lock_init(&pp->lock);
@@ -2070,7 +2070,7 @@ pmu_read(struct file *file, char __user *buf,
2070 unsigned long flags; 2070 unsigned long flags;
2071 int ret = 0; 2071 int ret = 0;
2072 2072
2073 if (count < 1 || pp == 0) 2073 if (count < 1 || !pp)
2074 return -EINVAL; 2074 return -EINVAL;
2075 if (!access_ok(VERIFY_WRITE, buf, count)) 2075 if (!access_ok(VERIFY_WRITE, buf, count))
2076 return -EFAULT; 2076 return -EFAULT;
@@ -2127,7 +2127,7 @@ pmu_fpoll(struct file *filp, poll_table *wait)
2127 __poll_t mask = 0; 2127 __poll_t mask = 0;
2128 unsigned long flags; 2128 unsigned long flags;
2129 2129
2130 if (pp == 0) 2130 if (!pp)
2131 return 0; 2131 return 0;
2132 poll_wait(filp, &pp->wait, wait); 2132 poll_wait(filp, &pp->wait, wait);
2133 spin_lock_irqsave(&pp->lock, flags); 2133 spin_lock_irqsave(&pp->lock, flags);
@@ -2143,7 +2143,7 @@ pmu_release(struct inode *inode, struct file *file)
2143 struct pmu_private *pp = file->private_data; 2143 struct pmu_private *pp = file->private_data;
2144 unsigned long flags; 2144 unsigned long flags;
2145 2145
2146 if (pp != 0) { 2146 if (pp) {
2147 file->private_data = NULL; 2147 file->private_data = NULL;
2148 spin_lock_irqsave(&all_pvt_lock, flags); 2148 spin_lock_irqsave(&all_pvt_lock, flags);
2149 list_del(&pp->list); 2149 list_del(&pp->list);
diff --git a/drivers/macintosh/windfarm_pm121.c b/drivers/macintosh/windfarm_pm121.c
index 4d72d8f58cb6..97634e030991 100644
--- a/drivers/macintosh/windfarm_pm121.c
+++ b/drivers/macintosh/windfarm_pm121.c
@@ -710,7 +710,7 @@ static void pm121_create_cpu_fans(void)
710 wf_cpu_pid_init(&pm121_cpu_state->pid, &pid_param); 710 wf_cpu_pid_init(&pm121_cpu_state->pid, &pid_param);
711 711
712 pr_debug("pm121: CPU Fan control initialized.\n"); 712 pr_debug("pm121: CPU Fan control initialized.\n");
713 pr_debug(" ttarged=%d.%03d, tmax=%d.%03d, min=%d RPM, max=%d RPM,\n", 713 pr_debug(" ttarget=%d.%03d, tmax=%d.%03d, min=%d RPM, max=%d RPM,\n",
714 FIX32TOPRINT(pid_param.ttarget), FIX32TOPRINT(pid_param.tmax), 714 FIX32TOPRINT(pid_param.ttarget), FIX32TOPRINT(pid_param.tmax),
715 pid_param.min, pid_param.max); 715 pid_param.min, pid_param.max);
716 716
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c
index d9ea45581b9e..346c91744442 100644
--- a/drivers/macintosh/windfarm_pm81.c
+++ b/drivers/macintosh/windfarm_pm81.c
@@ -455,7 +455,7 @@ static void wf_smu_create_cpu_fans(void)
455 wf_cpu_pid_init(&wf_smu_cpu_fans->pid, &pid_param); 455 wf_cpu_pid_init(&wf_smu_cpu_fans->pid, &pid_param);
456 456
457 DBG("wf: CPU Fan control initialized.\n"); 457 DBG("wf: CPU Fan control initialized.\n");
458 DBG(" ttarged=%d.%03d, tmax=%d.%03d, min=%d RPM, max=%d RPM\n", 458 DBG(" ttarget=%d.%03d, tmax=%d.%03d, min=%d RPM, max=%d RPM\n",
459 FIX32TOPRINT(pid_param.ttarget), FIX32TOPRINT(pid_param.tmax), 459 FIX32TOPRINT(pid_param.ttarget), FIX32TOPRINT(pid_param.tmax),
460 pid_param.min, pid_param.max); 460 pid_param.min, pid_param.max);
461 461
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c
index 7fd73dcb2b0a..a8a47c62a74b 100644
--- a/drivers/macintosh/windfarm_pm91.c
+++ b/drivers/macintosh/windfarm_pm91.c
@@ -200,7 +200,7 @@ static void wf_smu_create_cpu_fans(void)
200 wf_cpu_pid_init(&wf_smu_cpu_fans->pid, &pid_param); 200 wf_cpu_pid_init(&wf_smu_cpu_fans->pid, &pid_param);
201 201
202 DBG("wf: CPU Fan control initialized.\n"); 202 DBG("wf: CPU Fan control initialized.\n");
203 DBG(" ttarged=%d.%03d, tmax=%d.%03d, min=%d RPM, max=%d RPM\n", 203 DBG(" ttarget=%d.%03d, tmax=%d.%03d, min=%d RPM, max=%d RPM\n",
204 FIX32TOPRINT(pid_param.ttarget), FIX32TOPRINT(pid_param.tmax), 204 FIX32TOPRINT(pid_param.ttarget), FIX32TOPRINT(pid_param.tmax),
205 pid_param.min, pid_param.max); 205 pid_param.min, pid_param.max);
206 206
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index 4d6736f9d463..429d6de1dde7 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -514,9 +514,9 @@ static int init_implementation_adapter_regs_psl9(struct cxl *adapter,
514 cxl_p1_write(adapter, CXL_PSL9_FIR_CNTL, psl_fircntl); 514 cxl_p1_write(adapter, CXL_PSL9_FIR_CNTL, psl_fircntl);
515 515
516 /* Setup the PSL to transmit packets on the PCIe before the 516 /* Setup the PSL to transmit packets on the PCIe before the
517 * CAPP is enabled 517 * CAPP is enabled. Make sure that CAPP virtual machines are disabled
518 */ 518 */
519 cxl_p1_write(adapter, CXL_PSL9_DSNDCTL, 0x0001001000002A10ULL); 519 cxl_p1_write(adapter, CXL_PSL9_DSNDCTL, 0x0001001000012A10ULL);
520 520
521 /* 521 /*
522 * A response to an ASB_Notify request is returned by the 522 * A response to an ASB_Notify request is returned by the
diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
index 4b5a4c5d3c01..629e2e156412 100644
--- a/drivers/misc/cxl/sysfs.c
+++ b/drivers/misc/cxl/sysfs.c
@@ -353,12 +353,20 @@ static ssize_t prefault_mode_store(struct device *device,
353 struct cxl_afu *afu = to_cxl_afu(device); 353 struct cxl_afu *afu = to_cxl_afu(device);
354 enum prefault_modes mode = -1; 354 enum prefault_modes mode = -1;
355 355
356 if (!strncmp(buf, "work_element_descriptor", 23))
357 mode = CXL_PREFAULT_WED;
358 if (!strncmp(buf, "all", 3))
359 mode = CXL_PREFAULT_ALL;
360 if (!strncmp(buf, "none", 4)) 356 if (!strncmp(buf, "none", 4))
361 mode = CXL_PREFAULT_NONE; 357 mode = CXL_PREFAULT_NONE;
358 else {
359 if (!radix_enabled()) {
360
361 /* only allowed when not in radix mode */
362 if (!strncmp(buf, "work_element_descriptor", 23))
363 mode = CXL_PREFAULT_WED;
364 if (!strncmp(buf, "all", 3))
365 mode = CXL_PREFAULT_ALL;
366 } else {
367 dev_err(device, "Cannot prefault with radix enabled\n");
368 }
369 }
362 370
363 if (mode == -1) 371 if (mode == -1)
364 return -EINVAL; 372 return -EINVAL;
diff --git a/drivers/misc/ocxl/context.c b/drivers/misc/ocxl/context.c
index 909e8807824a..95f74623113e 100644
--- a/drivers/misc/ocxl/context.c
+++ b/drivers/misc/ocxl/context.c
@@ -34,6 +34,8 @@ int ocxl_context_init(struct ocxl_context *ctx, struct ocxl_afu *afu,
34 mutex_init(&ctx->xsl_error_lock); 34 mutex_init(&ctx->xsl_error_lock);
35 mutex_init(&ctx->irq_lock); 35 mutex_init(&ctx->irq_lock);
36 idr_init(&ctx->irq_idr); 36 idr_init(&ctx->irq_idr);
37 ctx->tidr = 0;
38
37 /* 39 /*
38 * Keep a reference on the AFU to make sure it's valid for the 40 * Keep a reference on the AFU to make sure it's valid for the
39 * duration of the life of the context 41 * duration of the life of the context
@@ -65,6 +67,7 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr)
65{ 67{
66 int rc; 68 int rc;
67 69
70 // Locks both status & tidr
68 mutex_lock(&ctx->status_mutex); 71 mutex_lock(&ctx->status_mutex);
69 if (ctx->status != OPENED) { 72 if (ctx->status != OPENED) {
70 rc = -EIO; 73 rc = -EIO;
@@ -72,7 +75,7 @@ int ocxl_context_attach(struct ocxl_context *ctx, u64 amr)
72 } 75 }
73 76
74 rc = ocxl_link_add_pe(ctx->afu->fn->link, ctx->pasid, 77 rc = ocxl_link_add_pe(ctx->afu->fn->link, ctx->pasid,
75 current->mm->context.id, 0, amr, current->mm, 78 current->mm->context.id, ctx->tidr, amr, current->mm,
76 xsl_fault_error, ctx); 79 xsl_fault_error, ctx);
77 if (rc) 80 if (rc)
78 goto out; 81 goto out;
diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
index 038509e5d031..e6a607488f8a 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c
@@ -5,6 +5,8 @@
5#include <linux/sched/signal.h> 5#include <linux/sched/signal.h>
6#include <linux/uaccess.h> 6#include <linux/uaccess.h>
7#include <uapi/misc/ocxl.h> 7#include <uapi/misc/ocxl.h>
8#include <asm/reg.h>
9#include <asm/switch_to.h>
8#include "ocxl_internal.h" 10#include "ocxl_internal.h"
9 11
10 12
@@ -123,11 +125,77 @@ static long afu_ioctl_get_metadata(struct ocxl_context *ctx,
123 return 0; 125 return 0;
124} 126}
125 127
128#ifdef CONFIG_PPC64
129static long afu_ioctl_enable_p9_wait(struct ocxl_context *ctx,
130 struct ocxl_ioctl_p9_wait __user *uarg)
131{
132 struct ocxl_ioctl_p9_wait arg;
133
134 memset(&arg, 0, sizeof(arg));
135
136 if (cpu_has_feature(CPU_FTR_P9_TIDR)) {
137 enum ocxl_context_status status;
138
139 // Locks both status & tidr
140 mutex_lock(&ctx->status_mutex);
141 if (!ctx->tidr) {
142 if (set_thread_tidr(current)) {
143 mutex_unlock(&ctx->status_mutex);
144 return -ENOENT;
145 }
146
147 ctx->tidr = current->thread.tidr;
148 }
149
150 status = ctx->status;
151 mutex_unlock(&ctx->status_mutex);
152
153 if (status == ATTACHED) {
154 int rc;
155 struct link *link = ctx->afu->fn->link;
156
157 rc = ocxl_link_update_pe(link, ctx->pasid, ctx->tidr);
158 if (rc)
159 return rc;
160 }
161
162 arg.thread_id = ctx->tidr;
163 } else
164 return -ENOENT;
165
166 if (copy_to_user(uarg, &arg, sizeof(arg)))
167 return -EFAULT;
168
169 return 0;
170}
171#endif
172
173
174static long afu_ioctl_get_features(struct ocxl_context *ctx,
175 struct ocxl_ioctl_features __user *uarg)
176{
177 struct ocxl_ioctl_features arg;
178
179 memset(&arg, 0, sizeof(arg));
180
181#ifdef CONFIG_PPC64
182 if (cpu_has_feature(CPU_FTR_P9_TIDR))
183 arg.flags[0] |= OCXL_IOCTL_FEATURES_FLAGS0_P9_WAIT;
184#endif
185
186 if (copy_to_user(uarg, &arg, sizeof(arg)))
187 return -EFAULT;
188
189 return 0;
190}
191
126#define CMD_STR(x) (x == OCXL_IOCTL_ATTACH ? "ATTACH" : \ 192#define CMD_STR(x) (x == OCXL_IOCTL_ATTACH ? "ATTACH" : \
127 x == OCXL_IOCTL_IRQ_ALLOC ? "IRQ_ALLOC" : \ 193 x == OCXL_IOCTL_IRQ_ALLOC ? "IRQ_ALLOC" : \
128 x == OCXL_IOCTL_IRQ_FREE ? "IRQ_FREE" : \ 194 x == OCXL_IOCTL_IRQ_FREE ? "IRQ_FREE" : \
129 x == OCXL_IOCTL_IRQ_SET_FD ? "IRQ_SET_FD" : \ 195 x == OCXL_IOCTL_IRQ_SET_FD ? "IRQ_SET_FD" : \
130 x == OCXL_IOCTL_GET_METADATA ? "GET_METADATA" : \ 196 x == OCXL_IOCTL_GET_METADATA ? "GET_METADATA" : \
197 x == OCXL_IOCTL_ENABLE_P9_WAIT ? "ENABLE_P9_WAIT" : \
198 x == OCXL_IOCTL_GET_FEATURES ? "GET_FEATURES" : \
131 "UNKNOWN") 199 "UNKNOWN")
132 200
133static long afu_ioctl(struct file *file, unsigned int cmd, 201static long afu_ioctl(struct file *file, unsigned int cmd,
@@ -186,6 +254,18 @@ static long afu_ioctl(struct file *file, unsigned int cmd,
186 (struct ocxl_ioctl_metadata __user *) args); 254 (struct ocxl_ioctl_metadata __user *) args);
187 break; 255 break;
188 256
257#ifdef CONFIG_PPC64
258 case OCXL_IOCTL_ENABLE_P9_WAIT:
259 rc = afu_ioctl_enable_p9_wait(ctx,
260 (struct ocxl_ioctl_p9_wait __user *) args);
261 break;
262#endif
263
264 case OCXL_IOCTL_GET_FEATURES:
265 rc = afu_ioctl_get_features(ctx,
266 (struct ocxl_ioctl_features __user *) args);
267 break;
268
189 default: 269 default:
190 rc = -EINVAL; 270 rc = -EINVAL;
191 } 271 }
diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c
index f30790582dc0..88876ae8f330 100644
--- a/drivers/misc/ocxl/link.c
+++ b/drivers/misc/ocxl/link.c
@@ -544,6 +544,42 @@ unlock:
544} 544}
545EXPORT_SYMBOL_GPL(ocxl_link_add_pe); 545EXPORT_SYMBOL_GPL(ocxl_link_add_pe);
546 546
547int ocxl_link_update_pe(void *link_handle, int pasid, __u16 tid)
548{
549 struct link *link = (struct link *) link_handle;
550 struct spa *spa = link->spa;
551 struct ocxl_process_element *pe;
552 int pe_handle, rc;
553
554 if (pasid > SPA_PASID_MAX)
555 return -EINVAL;
556
557 pe_handle = pasid & SPA_PE_MASK;
558 pe = spa->spa_mem + pe_handle;
559
560 mutex_lock(&spa->spa_lock);
561
562 pe->tid = tid;
563
564 /*
565 * The barrier makes sure the PE is updated
566 * before we clear the NPU context cache below, so that the
567 * old PE cannot be reloaded erroneously.
568 */
569 mb();
570
571 /*
572 * hook to platform code
573 * On powerpc, the entry needs to be cleared from the context
574 * cache of the NPU.
575 */
576 rc = pnv_ocxl_spa_remove_pe_from_cache(link->platform_data, pe_handle);
577 WARN_ON(rc);
578
579 mutex_unlock(&spa->spa_lock);
580 return rc;
581}
582
547int ocxl_link_remove_pe(void *link_handle, int pasid) 583int ocxl_link_remove_pe(void *link_handle, int pasid)
548{ 584{
549 struct link *link = (struct link *) link_handle; 585 struct link *link = (struct link *) link_handle;
@@ -599,7 +635,7 @@ int ocxl_link_remove_pe(void *link_handle, int pasid)
599 * On powerpc, the entry needs to be cleared from the context 635 * On powerpc, the entry needs to be cleared from the context
600 * cache of the NPU. 636 * cache of the NPU.
601 */ 637 */
602 rc = pnv_ocxl_spa_remove_pe(link->platform_data, pe_handle); 638 rc = pnv_ocxl_spa_remove_pe_from_cache(link->platform_data, pe_handle);
603 WARN_ON(rc); 639 WARN_ON(rc);
604 640
605 pe_data = radix_tree_delete(&spa->pe_tree, pe_handle); 641 pe_data = radix_tree_delete(&spa->pe_tree, pe_handle);
diff --git a/drivers/misc/ocxl/ocxl_internal.h b/drivers/misc/ocxl/ocxl_internal.h
index 5d421824afd9..a32f2151029f 100644
--- a/drivers/misc/ocxl/ocxl_internal.h
+++ b/drivers/misc/ocxl/ocxl_internal.h
@@ -77,6 +77,7 @@ struct ocxl_context {
77 struct ocxl_xsl_error xsl_error; 77 struct ocxl_xsl_error xsl_error;
78 struct mutex irq_lock; 78 struct mutex irq_lock;
79 struct idr irq_idr; 79 struct idr irq_idr;
80 u16 tidr; // Thread ID used for P9 wait implementation
80}; 81};
81 82
82struct ocxl_process_element { 83struct ocxl_process_element {
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index 2ed07ca6389e..9645c0062a90 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -318,7 +318,6 @@ static void udbg_init_opal_common(void)
318 udbg_putc = udbg_opal_putc; 318 udbg_putc = udbg_opal_putc;
319 udbg_getc = udbg_opal_getc; 319 udbg_getc = udbg_opal_getc;
320 udbg_getc_poll = udbg_opal_getc_poll; 320 udbg_getc_poll = udbg_opal_getc_poll;
321 tb_ticks_per_usec = 0x200; /* Make udelay not suck */
322} 321}
323 322
324void __init hvc_opal_init_early(void) 323void __init hvc_opal_init_early(void)