From patchwork Tue Jul 25 20:07:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 108693 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp14485obm; Tue, 25 Jul 2017 13:08:03 -0700 (PDT) X-Received: by 10.99.94.66 with SMTP id s63mr20807172pgb.253.1501013283401; Tue, 25 Jul 2017 13:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501013283; cv=none; d=google.com; s=arc-20160816; b=ii++C/PG+zSTzJHq/X06a79aZtSp0Bn03TTQqitGa2J4hzSlOTKYcUdrFOnRVa58Q6 11Prq1k0YCSQVUX/fnNFaOaCI6/fFyeSvow+cg3fqttPdG6Rvlml5PzqXlKgUpb7Wm7p Jg2Wg+qjAA2d9PNIusKDgFwQ202fNlCZTDkMms2PuUIxiCd314JkxiH+83jSH4jHZmDn RiZ5hBaozH1DlkuoZYSiRI0aVKXm9ODAKijgjuqeKq4tbCQV/XzTGLvNRgy3gbd4jiNG TpsW8RdfkuxQ1QgyEz/q0mNQUcNoTrs5Iwem2UvcencImwwnf6mMi5gx+duxIprwmDrP EP1Q== 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:dkim-signature:arc-authentication-results; bh=1SNuNSf6A475X+VvnYVOgQe2E3+wXWNqY6LrfsINF1c=; b=O0ZNvfoQzp3kXqqB7dyykYic5MwOCX9jRJg1E/PJed6T5bEbb28akbJPQz6Z3cZolu EjRJVZsA2a3x80w8UMZ6NcP0hrgQ5zH/CPvbzW3bmpQatOS+PyA0N4sT5VzM5g+e8Ili QxUB4gFPrZRilI16lw/eSSg7ZxxKbECKbpaaxTBxarZmcsnY8+ZGrkWTwELOqmIjR8cZ HN1AJC/CeUIQxvSbbw+xvBwtbsNdcrF6BqkmX8+d5kJRr0ev0580kMSAcUBDZARk4Qxa 6LOdZWeRMUSmM9+0cu6BabuPBCxgGMf1wTl4aA+g77aVLfkYl7nhJcpDiHTxd7h+ePx3 TLzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=dWV0uPOC; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 h10si8970990plk.237.2017.07.25.13.08.02; Tue, 25 Jul 2017 13:08:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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.b=dWV0uPOC; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1753465AbdGYUIB (ORCPT + 6 others); Tue, 25 Jul 2017 16:08:01 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:33264 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753276AbdGYUH7 (ORCPT ); Tue, 25 Jul 2017 16:07:59 -0400 Received: by mail-pg0-f44.google.com with SMTP id g14so25601117pgu.0 for ; Tue, 25 Jul 2017 13:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1SNuNSf6A475X+VvnYVOgQe2E3+wXWNqY6LrfsINF1c=; b=dWV0uPOC51dc85CkRaqUQzeffPxmDg9H+J1U36PAJmoUH3iK0PRQvCyirctO9JqH56 IwwlV0sMciMC5EV3nc47bom1iNEC/4zGkSiOc86pXUsoQHD9n0yi0UfKgQg9CH8YYTqx wKKcRcwLrTd4eFEtBCcVtGlAbBMhc4IXgfHAc= 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:in-reply-to :references; bh=1SNuNSf6A475X+VvnYVOgQe2E3+wXWNqY6LrfsINF1c=; b=HBHIRiqHdZ63EgNCagXtx/8FaFpRHOpO8tOpmh5uFLQpoyqFPyso9PASykIEHLUUUy FSjVUgGltEov3+MRyEgppCyQHQx2OM8ctI6wkH5sVMFoRo92CO30JYjZ4DAnK897bOHF M5tkE258QsANqNnnRb786G9maGvyaBX4aGpJlaot96goAZSETDPDoEHY98pssRo1/ybo gYmWkmDSxMqRAg13Nw+jm64iSt0n/+egcfYmVU2SFDZKwR1QTt9x987aMEq5ZTmVJZr4 7XkcBv5Wvcpu1oc00zh8ZmgRHG544V3GY7KiWHAYwxVWo3cIwjZfp7xubotysZddhKlJ UWtw== X-Gm-Message-State: AIVw110XTrQCZOlDZTp9RJcBkGjnxIF603WBCb4Q9vQJVXRMQLs+U033 rleiA9kCIkwfOq0RWNd9YQ== X-Received: by 10.99.43.8 with SMTP id r8mr20254868pgr.313.1501013278970; Tue, 25 Jul 2017 13:07:58 -0700 (PDT) Received: from localhost.localdomain ([106.51.135.235]) by smtp.gmail.com with ESMTPSA id c76sm27684356pfj.91.2017.07.25.13.07.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 13:07:57 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Sudeep Holla , Jassi Brar Subject: [PATCH for-4.4 11/13] mailbox: skip complete wait event if timer expired Date: Wed, 26 Jul 2017 01:37:19 +0530 Message-Id: <1501013241-31961-12-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501013241-31961-1-git-send-email-amit.pundir@linaro.org> References: <1501013241-31961-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sudeep Holla commit cc6eeaa3029a6dbcb4ad41b1f92876483bd88965 upstream. If a wait_for_completion_timeout() call returns due to a timeout, complete() can get called after returning from the wait which is incorrect and can cause subsequent transmissions on a channel to fail. Since the wait_for_completion_timeout() sees the completion variable is non-zero caused by the erroneous/spurious complete() call, and it immediately returns without waiting for the time as expected by the client. This patch fixes the issue by skipping complete() call for the timer expiry. Fixes: 2b6d83e2b8b7 ("mailbox: Introduce framework for mailbox") Reported-by: Alexey Klimov Signed-off-by: Sudeep Holla Signed-off-by: Jassi Brar Signed-off-by: Amit Pundir --- drivers/mailbox/mailbox.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 6e03717318b0..233af2ce9b8c 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -108,7 +108,7 @@ static void tx_tick(struct mbox_chan *chan, int r) if (mssg && chan->cl->tx_done) chan->cl->tx_done(chan->cl, mssg, r); - if (chan->cl->tx_block) + if (r != -ETIME && chan->cl->tx_block) complete(&chan->tx_complete); } @@ -272,8 +272,8 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg) ret = wait_for_completion_timeout(&chan->tx_complete, wait); if (ret == 0) { - t = -EIO; - tx_tick(chan, -EIO); + t = -ETIME; + tx_tick(chan, t); } }