Skip to content

Commit bd89108

Browse files
Wolfram Sanggregkh
authored andcommitted
mailbox: mailbox-test: make data_ready a per-instance variable
[ Upstream commit 6e937f4 ] While not the default case, multiple tests can be run simultaneously. Then, data_ready being a global variable will be overwritten and the per-instance lock will not help. Turn the global variable into a per-instance one to avoid this problem. Fixes: e339c80 ("mailbox: mailbox-test: don't rely on rx_buffer content to signal data ready") Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e4b893b commit bd89108

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

drivers/mailbox/mailbox-test.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#define MBOX_HEXDUMP_MAX_LEN (MBOX_HEXDUMP_LINE_LEN * \
2929
(MBOX_MAX_MSG_LEN / MBOX_BYTES_PER_LINE))
3030

31-
static bool mbox_data_ready;
32-
3331
struct mbox_test_device {
3432
struct device *dev;
3533
void __iomem *tx_mmio;
@@ -42,6 +40,7 @@ struct mbox_test_device {
4240
spinlock_t lock;
4341
struct mutex mutex;
4442
wait_queue_head_t waitq;
43+
bool data_ready;
4544
struct fasync_struct *async_queue;
4645
struct dentry *root_debugfs_dir;
4746
};
@@ -162,7 +161,7 @@ static bool mbox_test_message_data_ready(struct mbox_test_device *tdev)
162161
unsigned long flags;
163162

164163
spin_lock_irqsave(&tdev->lock, flags);
165-
data_ready = mbox_data_ready;
164+
data_ready = tdev->data_ready;
166165
spin_unlock_irqrestore(&tdev->lock, flags);
167166

168167
return data_ready;
@@ -227,7 +226,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf,
227226
*(touser + l) = '\0';
228227

229228
memset(tdev->rx_buffer, 0, MBOX_MAX_MSG_LEN);
230-
mbox_data_ready = false;
229+
tdev->data_ready = false;
231230

232231
spin_unlock_irqrestore(&tdev->lock, flags);
233232

@@ -297,7 +296,7 @@ static void mbox_test_receive_message(struct mbox_client *client, void *message)
297296
message, MBOX_MAX_MSG_LEN);
298297
memcpy(tdev->rx_buffer, message, MBOX_MAX_MSG_LEN);
299298
}
300-
mbox_data_ready = true;
299+
tdev->data_ready = true;
301300
spin_unlock_irqrestore(&tdev->lock, flags);
302301

303302
wake_up_interruptible(&tdev->waitq);

0 commit comments

Comments
 (0)