Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1039105pxu; Fri, 16 Oct 2020 02:09:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyq154jjhG+lPLsu4x6lKX46cpR8tZjYD1eJ5Aefe436Dw4UhxWHy4a14Q8yLwN8PQu2AG X-Received: by 2002:a50:950e:: with SMTP id u14mr2695378eda.260.1602839387782; Fri, 16 Oct 2020 02:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602839387; cv=none; d=google.com; s=arc-20160816; b=0rakQ5FjcfgVHxWuTxAeLnPVuOn9UHHEf8ExQr6aHkZSf4w61p9IXpG15t+6RyL3Te X3BdYQ/RaSa7cVUpow+4vxUUQbzQhrSnZa+EXKhs2KwlpCQnvzJvwKdYr4VldR4eB2j7 pTzBpkQHdpF5qCO9M/XBUJkcvuXCfMI4cGj4UKu0YaWUTJ3VqxCoawtCvKdrpufkflWH tOIYJxwbKTwQy34tZ9Gd6S9C4oLr/TX/a307w5oExfrXWzYOK+iyVTgu4IgEohqHTZlM OSZALFHTTG0z+nGM8QOjYbFkFbMpE7CzA7N8XTNbC4dS7ErM+uRJvub5Es6wfFAAh4dJ ItCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ssdnG2DybiGRW5XSHXxRLh1LbmDnndBK+ukKY2HWxWQ=; b=dHoXiLtAG/4yBszuKIK96EY7moc9P9n0EqtZPS3YjPMNNw++slbWsQB2IX3jSA9t0B mRxVauPRik3wWHiNZZuEBQNfb20YKL/CrkYYpaDieVUecHpMMHtOaZ2hM1o/ZLwWGg75 g4ZlJ7jtIsK9II99/Qi5SRBkbv1wWxI236jLqomwec5HcPf9zt5NUyShkJWe2FXigMKy /Ieh/PSkQL9ynAeSl+tg4Ml2uczHDJUWnBRQ8Y2DoZ8qgQobUbCsvI6ZzUMz2BARqJiM Q1Ma4H9xacgUvKQIClEGaKmtuvrxW+vsJGsAvf2JyFwUwFMZgzDYLjNMAKAB3Ynilm/S inxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce21si1313943edb.223.2020.10.16.02.09.25; Fri, 16 Oct 2020 02:09:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405202AbgJPIwU (ORCPT + 99 others); Fri, 16 Oct 2020 04:52:20 -0400 Received: from foss.arm.com ([217.140.110.172]:59538 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404836AbgJPIwT (ORCPT ); Fri, 16 Oct 2020 04:52:19 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E59ED30E; Fri, 16 Oct 2020 01:52:18 -0700 (PDT) Received: from localhost (unknown [10.1.199.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 866173F719; Fri, 16 Oct 2020 01:52:18 -0700 (PDT) Date: Fri, 16 Oct 2020 09:52:17 +0100 From: Ionela Voinescu To: Jassi Brar Cc: Jerome Brunet , Kevin Hilman , "open list:ARM/Amlogic Meson..." , Da Xue , Linux Kernel Mailing List Subject: Re: [PATCH] mailbox: cancel timer before starting it Message-ID: <20201016085217.GA12323@arm.com> References: <20200923123916.1115962-1-jbrunet@baylibre.com> <20201015134628.GA11989@arm.com> <1jlfg7k2ux.fsf@starbuckisacylon.baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 15 Oct 2020 at 13:45:54 (-0500), Jassi Brar wrote: [..] > > >> --- a/drivers/mailbox/mailbox.c > > >> +++ b/drivers/mailbox/mailbox.c > > >> @@ -82,9 +82,13 @@ static void msg_submit(struct mbox_chan *chan) > > >> exit: > > >> spin_unlock_irqrestore(&chan->lock, flags); > > >> > > >> - if (!err && (chan->txdone_method & TXDONE_BY_POLL)) > > >> - /* kick start the timer immediately to avoid delays */ > > >> + if (!err && (chan->txdone_method & TXDONE_BY_POLL)) { > > >> + /* Disable the timer if already active ... */ > > >> + hrtimer_cancel(&chan->mbox->poll_hrt); > > >> + > > >> + /* ... and kick start it immediately to avoid delays */ > > >> hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL); > > >> + } > > >> } > > >> > > >> static void tx_tick(struct mbox_chan *chan, int r) > > > > > > I've tracked a regression back to this commit. Details to reproduce: > > > > Hi Ionela, > > > > I don't have access to your platform and I don't get what is going on > > from the log below. > > > > Could you please give us a bit more details about what is going on ? > > > > All this patch does is add hrtimer_cancel(). > > * It is needed if the timer had already been started, which is > > appropriate AFAIU > > * It is a NO-OP is the timer is not active. > > > Can you please try using hrtimer_try_to_cancel() instead ? > Yes, using hrtimer_try_to_cancel() instead works for me. But doesn't this limit how effective this change is? AFAIU, this will possibly only reduce the chances for the race condition, but not solve it. Thanks, Ionela. > thanks