From patchwork Thu Sep 28 10:18:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 114402 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp555326qgf; Thu, 28 Sep 2017 03:19:06 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA/bmdGqDvR8q52flsitakfa2xBf1cMUDaSw+UW7aRVbLVuIl4zinBDNQ8h7FhC/wD89nfJ X-Received: by 10.98.34.149 with SMTP id p21mr3939961pfj.322.1506593946392; Thu, 28 Sep 2017 03:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506593946; cv=none; d=google.com; s=arc-20160816; b=P/pDoZR02Wt/k7TYuP1MmnNrud8GunWRB8Zy0MZXprtNIIg9c/4z/bkw5A1tGwQaHB FNeE/M7mf991/LopuIK/7ahrGyeTZ0ZzPXEIQyEigNpsNsa+b0GxV2RCpEiI76A22jhk DUbM7Lc+ntfLZpJQ46ah+yMc2QhmEmFZS+rLmmI0L2M6MpyC/RvwOJ9zA97bfzN62tdr PBAopi3aBn4KisgeT9o9d8j/lTlFO054QPyltjZwJVv7A5z+LfJ4RMpYLVY56oW6Hbmn zv9XmosVozeNJH2662R/gEjIK2Nc6PW+MmkzLgFU37H+br4JQSH1X1aBJ+lkbel/daBf ReuA== 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=BUm8VLeczkYZ66oiz+nLAa6sZ0Vu2HEnYZCHZTzdvBA=; b=stBDrbKENrI5S7cIeHg8VlXOWkxNqcyz/3l2FBQhBGxLRnCv2rhM6uh1qi87vetebz PoQfkbo2DySBFjT7AW5OGVPTt+23pSOghGIYM+uKPXNyZ8N2z2jqq2xYukCXjWt3IOQV 6i6MJNXqfALqyVf//Qylg9F0yag6M9w8cl3mQ3rj8to0meU7VRU0kcVbRcb5s4HsHG+a O8VnUTA2giubE2B0w7AENVGjBeVTUlkM9fZZ8du2ZUFIBOAWHkYEIY6hqwIFPUUWna8g po34sCBHFOLX2rfJpj/AVz4v7WwHOWHE4GhmUvmVpEBgu3M+dHZkIKtI0QFIkQ999zaL chFA== 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 c23si1122002pfc.443.2017.09.28.03.19.06; Thu, 28 Sep 2017 03:19:06 -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 S1752681AbdI1KTD (ORCPT + 26 others); Thu, 28 Sep 2017 06:19:03 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:54640 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbdI1KTC (ORCPT ); Thu, 28 Sep 2017 06:19:02 -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 2A19C1529; Thu, 28 Sep 2017 03:19:02 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1AA803F3E1; Thu, 28 Sep 2017 03:19:00 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Jassi Brar Cc: Sudeep Holla , Alexey Klimov , Jassi Brar Subject: [RESEND][PATCH 1/2] mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone Date: Thu, 28 Sep 2017 11:18:52 +0100 Message-Id: <1506593933-5857-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 | 4 ++-- drivers/mailbox/pcc.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 537f4f6d009b..674b35f402f5 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); @@ -418,7 +418,7 @@ void mbox_free_channel(struct mbox_chan *chan) spin_lock_irqsave(&chan->lock, flags); chan->cl = NULL; chan->active_req = NULL; - if (chan->txdone_method == (TXDONE_BY_POLL | TXDONE_BY_ACK)) + if (chan->txdone_method == TXDONE_BY_ACK) chan->txdone_method = TXDONE_BY_POLL; module_put(chan->mbox->dev->driver->owner); diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index 9b7005e1345e..27c2294be51a 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -266,7 +266,7 @@ struct mbox_chan *pcc_mbox_request_channel(struct mbox_client *cl, 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); @@ -312,7 +312,7 @@ void pcc_mbox_free_channel(struct mbox_chan *chan) spin_lock_irqsave(&chan->lock, flags); chan->cl = NULL; chan->active_req = NULL; - if (chan->txdone_method == (TXDONE_BY_POLL | TXDONE_BY_ACK)) + if (chan->txdone_method == TXDONE_BY_ACK) chan->txdone_method = TXDONE_BY_POLL; spin_unlock_irqrestore(&chan->lock, flags); From patchwork Thu Sep 28 10:18:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 114403 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp555408qgf; Thu, 28 Sep 2017 03:19:12 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC00dBXjHmAqJGGro981CHBsnD1ML/HsUJhKhykhqS7PtRDzJ4VGyYtkMwK+qYHi8CmnBb4 X-Received: by 10.159.245.146 with SMTP id a18mr3630260pls.26.1506593952683; Thu, 28 Sep 2017 03:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506593952; cv=none; d=google.com; s=arc-20160816; b=HeTn40MHzh3lT94scCLqVqwGMNnCWZi0Ul5cgV0fzQriOWMlGAl+VOVIXKuAnAF6im 8C0juCclnCpLl5JRZoiwLiWMAxExAoOJl1ZelppvrWuNLYIq4Khag9J1an0uPbkbyfPH YyAMbgzTG0X/Bjzr2uMkKYcaO7TMEwAwtawRUUrBTe+G8iiKFQ1489kt/tt0a2U0dy5B El4F0EnVENDt764KslxzFnHQ1lb7/9KuRfuulZYJaQcCdYpaIH5whDTwlBDIOKDvQ67M OpmczXUWynsC6cpcxOaA09JfzC71Sn6gwVsNRzGLM/0F0kqmQ+efdGI0Gb2p+Q9bSMjA WMdQ== 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=z0MmhIphceu09yqW+rE74WUCkrWCTTHyZhV7c3FlMxz2liAysPajHONvGsOLw4Pj4t c7hC9cBqq3R7MccKHMYDcE+H6O9AkEliAiugAspz8Zm36TZlPAX+DqVzbSRjdSqm2gg9 A+Ve9DOrb3aiVEehk0FqDdcI64LTXZ9kgPu3IIKzWItVNwpC5WYCxu/4CFRLilLaDlBR wV+rie5H30rz1YgjrUrkxIXNqGdAXXM46ofP5dfrY/J3RNbbcGQ7s/6Q/vMvDVgSJSMt JSQsOevH+35p//264xxwL5fPUPbIKNm1/ib1ZRowc9g/y60gR5YJUA3ge2qj9WA2qIhr crPw== 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 77si1109447pfz.364.2017.09.28.03.19.12; Thu, 28 Sep 2017 03:19:12 -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 S1752817AbdI1KTK (ORCPT + 26 others); Thu, 28 Sep 2017 06:19:10 -0400 Received: from foss.arm.com ([217.140.101.70]:54650 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752688AbdI1KTF (ORCPT ); Thu, 28 Sep 2017 06:19:05 -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 9E2841529; Thu, 28 Sep 2017 03:19:05 -0700 (PDT) Received: from e107155-lin.cambridge.arm.com (unknown [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B36253F3E1; Thu, 28 Sep 2017 03:19:04 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Jassi Brar Cc: Sudeep Holla , Jassi Brar Subject: [RESEND][PATCH 2/2] mailbox: mailbox-test: don't rely on rx_buffer content to signal data ready Date: Thu, 28 Sep 2017 11:18:53 +0100 Message-Id: <1506593933-5857-2-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506593933-5857-1-git-send-email-sudeep.holla@arm.com> References: <1506593933-5857-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);