Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mailbox: mailbox-test: make data_ready a per-instance variable

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: e339c80af95e ("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>

authored by

Wolfram Sang and committed by
Jassi Brar
6e937f4e bbcf9af6

+4 -5
+4 -5
drivers/mailbox/mailbox-test.c
··· 28 28 #define MBOX_HEXDUMP_MAX_LEN (MBOX_HEXDUMP_LINE_LEN * \ 29 29 (MBOX_MAX_MSG_LEN / MBOX_BYTES_PER_LINE)) 30 30 31 - static bool mbox_data_ready; 32 - 33 31 struct mbox_test_device { 34 32 struct device *dev; 35 33 void __iomem *tx_mmio; ··· 40 42 spinlock_t lock; 41 43 struct mutex mutex; 42 44 wait_queue_head_t waitq; 45 + bool data_ready; 43 46 struct fasync_struct *async_queue; 44 47 struct dentry *root_debugfs_dir; 45 48 }; ··· 161 162 unsigned long flags; 162 163 163 164 spin_lock_irqsave(&tdev->lock, flags); 164 - data_ready = mbox_data_ready; 165 + data_ready = tdev->data_ready; 165 166 spin_unlock_irqrestore(&tdev->lock, flags); 166 167 167 168 return data_ready; ··· 226 227 *(touser + l) = '\0'; 227 228 228 229 memset(tdev->rx_buffer, 0, MBOX_MAX_MSG_LEN); 229 - mbox_data_ready = false; 230 + tdev->data_ready = false; 230 231 231 232 spin_unlock_irqrestore(&tdev->lock, flags); 232 233 ··· 296 297 message, MBOX_MAX_MSG_LEN); 297 298 memcpy(tdev->rx_buffer, message, MBOX_MAX_MSG_LEN); 298 299 } 299 - mbox_data_ready = true; 300 + tdev->data_ready = true; 300 301 spin_unlock_irqrestore(&tdev->lock, flags); 301 302 302 303 wake_up_interruptible(&tdev->waitq);