From patchwork Fri Jun 30 15:14:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 106715 Delivered-To: patch@linaro.org Received: by 10.182.135.102 with SMTP id pr6csp6052957obb; Fri, 30 Jun 2017 08:15:07 -0700 (PDT) X-Received: by 10.99.168.71 with SMTP id i7mr5720138pgp.279.1498835707647; Fri, 30 Jun 2017 08:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498835707; cv=none; d=google.com; s=arc-20160816; b=lc8s/miLgbL9AMnQihRlzSJg7LqrjOQh6aoUPwmOUne9QzZAyvLNmT4JwncM1kU1yT G1NZ0bPDL9NQajBARzAmqWZ+bdLY0mXTELogQB9JNRu6Ms+hW64v9S1DN2Kdk044geR6 +fiEbIzmQqGfCzvhDfF8b4rAZgk7WxY6Iz7gZ2V/w2LnQQf2oFzvMDypT9vqeBmTNuza ijxQDr+bhILEiF3oxr4kaKSXBjUem2RSQowTQYGtjaWVcuOHUMUPz+SWHxpRKQJgwSIZ xDI19o3hjeN6QGUqK+SbB8GCFdS755h7ekZuBXThPOPMXSPMaKbF6pCuAa43cpxvy7Nm YGiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=BvppY/sRVVZgjAF1MPTVfbb1V6pvauXaN8HvizmmtMk=; b=eaR9t/9bejI8lbsoi97e2Fv9ZcYZZBfYnhwQujTggo2sohVFLlFBRnqSu2+PTdoeEd IiHjoJnO7xgXu5QOBSzQUltssDSZNX59vBF3La3J0tGFg1xkjhmHRlxmJUM70ELBsqoc RucO1P9kHJxqHCJtjRVJbtoj+01fRpdLMm38YG1TZwVRuBY6atb1XsRcfqht5poAzKOa MwaHw1VW6OZUzxPw8+iqH7+H7fDhEYd3Xnh5R3qQZhRJyzKFABuYjfISN0j/X3wPxYQc Ge/q0jdJ1xUeaN4VZjzBnRGUwKv8QU9JzAwWTBtKsOjeQoLzV78TmCL9he/MOHAX+UnD 5oZw== 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:07 -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 S1751695AbdF3POx (ORCPT + 25 others); Fri, 30 Jun 2017 11:14:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43526 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750975AbdF3POw (ORCPT ); Fri, 30 Jun 2017 11:14:52 -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 C45E580D; Fri, 30 Jun 2017 08:14:51 -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 E12D93F41F; Fri, 30 Jun 2017 08:14:50 -0700 (PDT) From: Sudeep Holla To: LKML , Jassi Brar Cc: Sudeep Holla , Alexey Klimov , Jassi Brar Subject: [PATCH 1/2] mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone Date: Fri, 30 Jun 2017 16:14:40 +0100 Message-Id: <1498835681-23975-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the mailbox framework sets txdone_method to TXDONE_BY_POLL if the controller sets txdone_by_poll. However some clients can have a mechanism to do TXDONE_BY_ACK which they can specify by knows_txdone. However, we endup setting both TXDONE_BY_POLL and TXDONE_BY_ACK in that case. In such scenario, we may end up with below warnings as the tx ticker is run both by mailbox framework and the client. WARNING: CPU: 1 PID: 0 at kernel/time/hrtimer.c:805 hrtimer_forward+0x88/0xd8 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.12.0-rc5 #242 Hardware name: ARM LTD ARM Juno Development Platform task: ffff8009768ca700 task.stack: ffff8009768f8000 PC is at hrtimer_forward+0x88/0xd8 LR is at txdone_hrtimer+0xd4/0xf8 Call trace: hrtimer_forward+0x88/0xd8 __hrtimer_run_queues+0xe4/0x158 hrtimer_interrupt+0xa4/0x220 arch_timer_handler_phys+0x30/0x40 handle_percpu_devid_irq+0x78/0x130 generic_handle_irq+0x24/0x38 __handle_domain_irq+0x5c/0xb8 gic_handle_irq+0x54/0xa8 This patch fixes the issue by resetting TXDONE_BY_POLL if client has set knows_txdone. Cc: Alexey Klimov Cc: Jassi Brar Signed-off-by: Sudeep Holla --- drivers/mailbox/mailbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 537f4f6d009b..8da30f833262 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -351,7 +351,7 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index) init_completion(&chan->tx_complete); if (chan->txdone_method == TXDONE_BY_POLL && cl->knows_txdone) - chan->txdone_method |= TXDONE_BY_ACK; + chan->txdone_method = TXDONE_BY_ACK; spin_unlock_irqrestore(&chan->lock, flags); 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);