From patchwork Thu Nov 16 05:31:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 119006 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5178045qgn; Wed, 15 Nov 2017 21:31:52 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ3y5FBHlBGE92d6YQUHWE5EDgDuW80YflrYBOeza5V4hv4XORv9cYWw3+X/MstWUeff/7Q X-Received: by 10.98.218.67 with SMTP id w3mr610643pfl.128.1510810312517; Wed, 15 Nov 2017 21:31:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510810312; cv=none; d=google.com; s=arc-20160816; b=yOBXq+DvCIzWX9lPDfF5bZmxTOL+NamhMVoZuHley8Y7m3/q8UcenYF+fsTKco5Zcs xv5lCYps3279WSH+4nUZS+oHkzXsjakMeYxNVhRa7XQL8bAiffX8m9rI4kQ0MtUOfYQc UUvx2QU2qGq9a0R2QSCZ3MefpUH88j4bemfYePgVpoYdZC+nMqUqtuVi268P8CiLZ79N 8U3NqjFLqbOZ6bbz01lfwqhCVNGMg7/vsgRLWE2JM1p1BoViYiw5Hi/4WiSAFAFdfuft YGlsYNaF3PAqpemptk3S7MKvf6IUlaXuja6ZRBSNZkhneteKBSw3Er+e40KlWQ9uQCQl Z/MQ== 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 :dkim-signature:arc-authentication-results; bh=e3+OPJaJylSC94SU468lr4itsWN7JTQoaGFBcI1TZRU=; b=OxSAAbVVQfHarR7L+gAR856hGa2dpSaEu7O9KWSdGF2+N0938A/OWcfQf+I4Ygma1K aoZ/riGS4Na3kEZha8uVpsLqwmBZrw80Joh4rnCFb8UqqZAhVyHbCOI8xaOWiAVZo24D E5yzIQbhsUszOO+FbZjvTbCEB5T224DD7TQ75aFMSRd8xcykpSKw6lpQYB6Z3RULIeil BbyEkLk3jLNd0WV0Y/uK6PfqEx8KntJWMec+6W9zboMYTzr6k0ANmzNP5g3ICsaPQ6kq Gj5Umc4I5BIGeyHtENtZiK7R2lL3KcecpCMzDZ8CSeVKslhsvcWssDc+MtrAtsZB/hhH ogqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EHO7PH6c; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n24si304147pfa.108.2017.11.15.21.31.52; Wed, 15 Nov 2017 21:31:52 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=EHO7PH6c; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934743AbdKPFbt (ORCPT + 28 others); Thu, 16 Nov 2017 00:31:49 -0500 Received: from mail-ot0-f195.google.com ([74.125.82.195]:50752 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759712AbdKPFbb (ORCPT ); Thu, 16 Nov 2017 00:31:31 -0500 Received: by mail-ot0-f195.google.com with SMTP id g104so9510231otg.7 for ; Wed, 15 Nov 2017 21:31:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=e3+OPJaJylSC94SU468lr4itsWN7JTQoaGFBcI1TZRU=; b=EHO7PH6cFIPH9Tp03dtKDovnLSEY1/2RcH0+QV9Rwp+8zHJQz8DeqXcMwzMGd7NTDz GaJKB6dYsIFcWFx7YubGTSPXjTE/NzusW367TSwWieM1BmD1JgIbWI23VoEjNJYbBRJW od7yZheDCIqZmygEbtCD7bE5LXr/u3uTsA74Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=e3+OPJaJylSC94SU468lr4itsWN7JTQoaGFBcI1TZRU=; b=d8A6ss+sL4FRe9w1lDYtuFmJAoBA5TmwqAV7iydOVEPZxmmrep5VMqfmfAr+DmgIW1 c8OfGE8zqT8raF/eYi/atIMkhGLw+zIMws9kMICE8zd/y4j+RRq8vq1GU4pE8qrWHPSX lN8dHcMUo3+Q1CiUb/f6UIj9+RiK9/iikLmgoimEDYaQ0RrT5kVFetfMgIlwFl/68VNo bevG2avA08XAAlQUBY/Py/ViHkS2iq4cl9urUV3+zhBK7XcIYjDYnTHUz1RpAnhpY+sU 46n6qgqtWzPolQgKg6m4gsd7Rj9+3y8tEv4NbHmjIPSapu2jcLGTKq8YUZ1Hf27v1cfg AOTQ== X-Gm-Message-State: AJaThX41z9CNpvCP/U1qhBEjESk1CU+cnmuWzeCUVXTdAoSS3+UGx7bE iFcH96C8N7D5SvjJVg0SVcouDA== X-Received: by 10.157.38.66 with SMTP id a60mr327716otb.112.1510810290809; Wed, 15 Nov 2017 21:31:30 -0800 (PST) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id u16sm160694otd.78.2017.11.15.21.31.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Nov 2017 21:31:30 -0800 (PST) From: Bjorn Andersson To: Jassi Brar , Sudeep Holla Cc: linux-kernel@vger.kernel.org, Alexey Klimov Subject: [PATCH] mailbox: txdone_method shouldn't always be reset Date: Wed, 15 Nov 2017 21:31:26 -0800 Message-Id: <20171116053126.28640-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A client that knows how to drive txdone would temporarily "upgrade" the method to TXDONE_BY_ACK. But with the introduction of commit 33cd7123ac0ba ("mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone") there is no longer a distinction between a channel in "upgraded" state or a channel for a controller that only supports TXDONE_BY_ACK. So upon freeing the channel it will be "downgraded" to TXDONE_BY_POLL. But a channel that operates with the txdone method of TXDONE_BY_POLL requires that the controller implements the last_tx_done callback and that the associated hrtimer was initialized when the controller was registered. So the core now relies on the fact that subsequent calls to mbox_request_channel() "upgrades" the channel to TXDONE_BY_ACK or it will dereference the non-initialized hrtimer. The intention of commit 33cd7123ac0ba ("mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone") is to not restart the hrtimer when the channel is in an "upgraded" state. So this patch reverts the commit, in order to never leave the channel is a invalid state, and instead only start the timer when we're in the "non-upgraded" POLL state. Fixes: 33cd7123ac0ba ("mailbox: reset txdone_method TXDONE_BY_POLL if client knows_txdone") Signed-off-by: Bjorn Andersson --- drivers/mailbox/mailbox.c | 6 +++--- drivers/mailbox/pcc.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) -- 2.15.0 diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 674b35f402f5..da8d666a8c56 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -85,7 +85,7 @@ static void msg_submit(struct mbox_chan *chan) exit: spin_unlock_irqrestore(&chan->lock, flags); - if (!err && (chan->txdone_method & TXDONE_BY_POLL)) + if (!err && chan->txdone_method == TXDONE_BY_POLL) /* kick start the timer immediately to avoid delays */ hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL); } @@ -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_ACK) + if (chan->txdone_method == (TXDONE_BY_POLL | 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 3ef7f036ceea..e5a69679cfa2 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c @@ -265,7 +265,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); @@ -311,7 +311,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_ACK) + if (chan->txdone_method == (TXDONE_BY_POLL | TXDONE_BY_ACK)) chan->txdone_method = TXDONE_BY_POLL; spin_unlock_irqrestore(&chan->lock, flags);