hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/arch/powerpc/platforms/ps3/device-init.c
....@@ -1,21 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * PS3 device registration routines.
34 *
45 * Copyright (C) 2007 Sony Computer Entertainment Inc.
56 * Copyright 2007 Sony Corp.
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; version 2 of the License.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
197 */
208
219 #include <linux/delay.h>
....@@ -25,6 +13,7 @@
2513 #include <linux/init.h>
2614 #include <linux/slab.h>
2715 #include <linux/reboot.h>
16
+#include <linux/rcuwait.h>
2817
2918 #include <asm/firmware.h>
3019 #include <asm/lv1call.h>
....@@ -354,9 +343,7 @@
354343 repo->dev_index, repo->dev_type, port, blk_size, num_blocks,
355344 num_regions);
356345
357
- p = kzalloc(sizeof(struct ps3_storage_device) +
358
- num_regions * sizeof(struct ps3_storage_region),
359
- GFP_KERNEL);
346
+ p = kzalloc(struct_size(p, regions, num_regions), GFP_KERNEL);
360347 if (!p) {
361348 result = -ENOMEM;
362349 goto fail_malloc;
....@@ -684,7 +671,8 @@
684671 spinlock_t lock;
685672 u64 tag;
686673 u64 lv1_status;
687
- struct completion done;
674
+ struct rcuwait wait;
675
+ bool done;
688676 };
689677
690678 enum ps3_notify_type {
....@@ -726,7 +714,8 @@
726714 pr_debug("%s:%u: completed, status 0x%llx\n", __func__,
727715 __LINE__, status);
728716 dev->lv1_status = status;
729
- complete(&dev->done);
717
+ dev->done = true;
718
+ rcuwait_wake_up(&dev->wait);
730719 }
731720 spin_unlock(&dev->lock);
732721 return IRQ_HANDLED;
....@@ -739,12 +728,12 @@
739728 unsigned long flags;
740729 int res;
741730
742
- init_completion(&dev->done);
743731 spin_lock_irqsave(&dev->lock, flags);
744732 res = write ? lv1_storage_write(dev->sbd.dev_id, 0, 0, 1, 0, lpar,
745733 &dev->tag)
746734 : lv1_storage_read(dev->sbd.dev_id, 0, 0, 1, 0, lpar,
747735 &dev->tag);
736
+ dev->done = false;
748737 spin_unlock_irqrestore(&dev->lock, flags);
749738 if (res) {
750739 pr_err("%s:%u: %s failed %d\n", __func__, __LINE__, op, res);
....@@ -752,14 +741,10 @@
752741 }
753742 pr_debug("%s:%u: notification %s issued\n", __func__, __LINE__, op);
754743
755
- res = swait_event_interruptible_exclusive(dev->done.wait,
756
- dev->done.done || kthread_should_stop());
744
+ rcuwait_wait_event(&dev->wait, dev->done || kthread_should_stop(), TASK_IDLE);
745
+
757746 if (kthread_should_stop())
758747 res = -EINTR;
759
- if (res) {
760
- pr_debug("%s:%u: interrupted %s\n", __func__, __LINE__, op);
761
- return res;
762
- }
763748
764749 if (dev->lv1_status) {
765750 pr_err("%s:%u: %s not completed, status 0x%llx\n", __func__,
....@@ -824,6 +809,7 @@
824809 }
825810
826811 spin_lock_init(&dev.lock);
812
+ rcuwait_init(&dev.wait);
827813
828814 res = request_irq(irq, ps3_notification_interrupt, 0,
829815 "ps3_notification", &dev);