From patchwork Fri Jun 30 15:14:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 106716 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp6052973obb; Fri, 30 Jun 2017 08:15:08 -0700 (PDT) X-Received: by 10.98.31.6 with SMTP id f6mr23232659pff.27.1498835708118; Fri, 30 Jun 2017 08:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498835708; cv=none; d=google.com; s=arc-20160816; b=eNxU5+mVFkeTijdjHOM/O1NT79O3lonBNOeB8OfLySTr85Qjj2yaSxRtkZzEc88YLc SqhJiU3+F6UGE8ZfJd20Hbgfi87B7nJpXTMJzAihwAmHZMmjmMCBMlUbeEm3toqMBN75 43XdnWAAFwc3h48CnUpt55mg/oAZkOE6cki2sv5HSPO7RByXubc494AtYXxRlV8pQD5N eVq5/0FJZoxUyWedX36cUvBi/tGF0W797ovndr6MoDhCqIOcJxjCpfa/nGNrzy1gjkpM Ii+Uqb0PNfJQLh9EsvVENZoQjW6alD2hDU90MlucjmJnru+47ee1WqAyr2VR2/HHqc9G 1b6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=6xcLOzGrPxuVYIoG5MV0HsW0lnKwcmfuMbBtvDKQnzA=; b=zP+kdqdbsRUmdl75gPCvQnYEw2CiAJeLSHNLf7M0qTGD8oOnjcl7rnP/Gk33NfBZr6 B2jeyrJEd1uoWUy0aiiMPLDq+wkzphbr+mo7ur1e7QQc73WuQ5CAVzgxe7NM+LuJN0Tq iDILn1oY1qGJ3aNcNN2I2Gn5roQ+cO8p5ZxJGMXiCU/a+pFMgHgzJYHHalFt7cmbS1Y0 NMFdn3o+EtwMShuH3S5SXZordRxOsE43iwwFALbWMrg6jy8LueB7LrzKhd7029w+0nEs By3AanHrk+w6rWo+IBatiKarff0oKki809W3667Cn2VYjMwmY2PQgUcIi2L0w4oHRYmK wiDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g185si5924613pfc.19.2017.06.30.08.15.07; Fri, 30 Jun 2017 08:15:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751799AbdF3PO6 (ORCPT + 25 others); Fri, 30 Jun 2017 11:14:58 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43538 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751701AbdF3PO4 (ORCPT ); Fri, 30 Jun 2017 11:14:56 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7DAC880D; Fri, 30 Jun 2017 08:14:55 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (e107155-lin.cambridge.arm.com [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 99D963F41F; Fri, 30 Jun 2017 08:14:54 -0700 (PDT) From: Sudeep Holla To: LKML , Jassi Brar Cc: Sudeep Holla , Alexey Klimov , Jassi Brar Subject: [PATCH 2/2] mailbox: mailbox-test: don't rely on rx_buffer content to signal data ready Date: Fri, 30 Jun 2017 16:14:41 +0100 Message-Id: <1498835681-23975-2-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498835681-23975-1-git-send-email-sudeep.holla@arm.com> References: <1498835681-23975-1-git-send-email-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently we rely on the first byte of the Rx buffer to check if there's any data available to be read. If the first byte of the received buffer is zero (i.e. null character), then we fail to signal that data is available even when it's available. Instead introduce a boolean variable to track the data availability and update it in the channel receive callback as ready and clear it when the data is read. Cc: Jassi Brar Fixes: baef9a35d246 ("mailbox: mailbox-test: add support for fasync/poll") Signed-off-by: Sudeep Holla --- drivers/mailbox/mailbox-test.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index 97fb956bb6e0..93f3d4d61fa7 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -30,6 +30,7 @@ #define MBOX_HEXDUMP_MAX_LEN (MBOX_HEXDUMP_LINE_LEN * \ (MBOX_MAX_MSG_LEN / MBOX_BYTES_PER_LINE)) +static bool mbox_data_ready; static struct dentry *root_debugfs_dir; struct mbox_test_device { @@ -152,16 +153,14 @@ static ssize_t mbox_test_message_write(struct file *filp, static bool mbox_test_message_data_ready(struct mbox_test_device *tdev) { - unsigned char data; + bool data_ready; unsigned long flags; spin_lock_irqsave(&tdev->lock, flags); - data = tdev->rx_buffer[0]; + data_ready = mbox_data_ready; spin_unlock_irqrestore(&tdev->lock, flags); - if (data != '\0') - return true; - return false; + return data_ready; } static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf, @@ -223,6 +222,7 @@ static ssize_t mbox_test_message_read(struct file *filp, char __user *userbuf, *(touser + l) = '\0'; memset(tdev->rx_buffer, 0, MBOX_MAX_MSG_LEN); + mbox_data_ready = false; spin_unlock_irqrestore(&tdev->lock, flags); @@ -292,6 +292,7 @@ static void mbox_test_receive_message(struct mbox_client *client, void *message) message, MBOX_MAX_MSG_LEN); memcpy(tdev->rx_buffer, message, MBOX_MAX_MSG_LEN); } + mbox_data_ready = true; spin_unlock_irqrestore(&tdev->lock, flags); wake_up_interruptible(&tdev->waitq);