Commit e21fee53 authored by Peter Zijlstra (Intel)'s avatar Peter Zijlstra (Intel) Committed by Peter Zijlstra

powerpc/ps3: Convert half completion to rcuwait

The PS3 notification interrupt and kthread use a hacked up completion to
communicate. Since we're wanting to change the completion implementation and
this is abuse anyway, replace it with a simple rcuwait since there is only ever
the one waiter.

AFAICT the kthread uses TASK_INTERRUPTIBLE to not increase loadavg, kthreads
cannot receive signals by default and this one doesn't look different. Use
TASK_IDLE instead.
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200321113241.930037873@linutronix.de
parent 80fbaf1c
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/rcuwait.h>
#include <asm/firmware.h> #include <asm/firmware.h>
#include <asm/lv1call.h> #include <asm/lv1call.h>
...@@ -670,7 +671,8 @@ struct ps3_notification_device { ...@@ -670,7 +671,8 @@ struct ps3_notification_device {
spinlock_t lock; spinlock_t lock;
u64 tag; u64 tag;
u64 lv1_status; u64 lv1_status;
struct completion done; struct rcuwait wait;
bool done;
}; };
enum ps3_notify_type { enum ps3_notify_type {
...@@ -712,7 +714,8 @@ static irqreturn_t ps3_notification_interrupt(int irq, void *data) ...@@ -712,7 +714,8 @@ static irqreturn_t ps3_notification_interrupt(int irq, void *data)
pr_debug("%s:%u: completed, status 0x%llx\n", __func__, pr_debug("%s:%u: completed, status 0x%llx\n", __func__,
__LINE__, status); __LINE__, status);
dev->lv1_status = status; dev->lv1_status = status;
complete(&dev->done); dev->done = true;
rcuwait_wake_up(&dev->wait);
} }
spin_unlock(&dev->lock); spin_unlock(&dev->lock);
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -725,12 +728,12 @@ static int ps3_notification_read_write(struct ps3_notification_device *dev, ...@@ -725,12 +728,12 @@ static int ps3_notification_read_write(struct ps3_notification_device *dev,
unsigned long flags; unsigned long flags;
int res; int res;
init_completion(&dev->done);
spin_lock_irqsave(&dev->lock, flags); spin_lock_irqsave(&dev->lock, flags);
res = write ? lv1_storage_write(dev->sbd.dev_id, 0, 0, 1, 0, lpar, res = write ? lv1_storage_write(dev->sbd.dev_id, 0, 0, 1, 0, lpar,
&dev->tag) &dev->tag)
: lv1_storage_read(dev->sbd.dev_id, 0, 0, 1, 0, lpar, : lv1_storage_read(dev->sbd.dev_id, 0, 0, 1, 0, lpar,
&dev->tag); &dev->tag);
dev->done = false;
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
if (res) { if (res) {
pr_err("%s:%u: %s failed %d\n", __func__, __LINE__, op, res); pr_err("%s:%u: %s failed %d\n", __func__, __LINE__, op, res);
...@@ -738,14 +741,10 @@ static int ps3_notification_read_write(struct ps3_notification_device *dev, ...@@ -738,14 +741,10 @@ static int ps3_notification_read_write(struct ps3_notification_device *dev,
} }
pr_debug("%s:%u: notification %s issued\n", __func__, __LINE__, op); pr_debug("%s:%u: notification %s issued\n", __func__, __LINE__, op);
res = wait_event_interruptible(dev->done.wait, rcuwait_wait_event(&dev->wait, dev->done || kthread_should_stop(), TASK_IDLE);
dev->done.done || kthread_should_stop());
if (kthread_should_stop()) if (kthread_should_stop())
res = -EINTR; res = -EINTR;
if (res) {
pr_debug("%s:%u: interrupted %s\n", __func__, __LINE__, op);
return res;
}
if (dev->lv1_status) { if (dev->lv1_status) {
pr_err("%s:%u: %s not completed, status 0x%llx\n", __func__, pr_err("%s:%u: %s not completed, status 0x%llx\n", __func__,
...@@ -810,6 +809,7 @@ static int ps3_probe_thread(void *data) ...@@ -810,6 +809,7 @@ static int ps3_probe_thread(void *data)
} }
spin_lock_init(&dev.lock); spin_lock_init(&dev.lock);
rcuwait_init(&dev.wait);
res = request_irq(irq, ps3_notification_interrupt, 0, res = request_irq(irq, ps3_notification_interrupt, 0,
"ps3_notification", &dev); "ps3_notification", &dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment