Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1480464pxu; Fri, 16 Oct 2020 13:07:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4mcIZLfkDnWrBVGvzqVNPLIfZQ6/lzSD0s2i0ZTRj7R/qdqjmItEAi/fjxPn+k4OwBMQu X-Received: by 2002:a17:907:94d2:: with SMTP id dn18mr5650270ejc.374.1602878827313; Fri, 16 Oct 2020 13:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602878827; cv=none; d=google.com; s=arc-20160816; b=YhT6He2V8RKVk/I8QySoIdI9nPnjIu6TIvMBIIDoCPlKuLanddWKt8irM4hwC31ziO ygcx/SSMhrshvlWTmRzypDW+iz1dnmqMTpLyttIEanCOLemYq5ft9TjU8o5NCiOAtHpb OHCVABsqAdpHIWlerhI8euyRDAT6CmSWaBTuhhkX0lJpRoMh86J4cb8jf2cx+IbxS/+k f+JufiUixoEAv14Z7Ev0KRARX81UX3WTArwYizHi/nQKM63bxavBq4jtgArUsNwi3qid qCTC6qgDs1d2FX69s43k8Toi6HCuy3CWypA51wEyUGthVygAZvqINJ7o3E+9HduVitZO zFMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to:subject :cc:to:from:user-agent:references:dkim-signature; bh=BqW8JiuIYvnXw5H3Z5hu1Iu1nuYkaGW3P8AQ8gC+FKM=; b=W3N2eBdnqmzh3RDw498oi9uRRAhfnxiF/uuVrwaSCFPcjWMJXu7a2NRCiAPkJFHeWO ASQm1/222JzljZ11a/JmaqHbi2YnuhOs2TjQZMgNsQQ76xYMVhizjlkC6fi9TezlMhxh U7bijSswhMt+eqAqeEd4nz+opPk+X10cWZ0yPdMnqvYNMInwDUqttNtLqto2Zlxm6aXa VPLpwo5OQ4yIED6OtCEa9WTMt2HxivGoLwwPTWi+zQBDscENi/CAAKaYQ3fNktR+kaO/ ks3GWM8PXDYs+GRq5694EeBfV8ZATa/qyCAl7a1iKOV/dMZ5/z/DTuwWXvIVZFtKW8v/ Tcdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=XGMTdoX+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si2318218ejg.300.2020.10.16.13.06.45; Fri, 16 Oct 2020 13:07:07 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=XGMTdoX+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408449AbgJPTcz (ORCPT + 99 others); Fri, 16 Oct 2020 15:32:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408131AbgJPTcz (ORCPT ); Fri, 16 Oct 2020 15:32:55 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE383C061755 for ; Fri, 16 Oct 2020 12:32:54 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id qp15so4802955ejb.3 for ; Fri, 16 Oct 2020 12:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=BqW8JiuIYvnXw5H3Z5hu1Iu1nuYkaGW3P8AQ8gC+FKM=; b=XGMTdoX+Gb7Re8mBkXzcfp7ph0rlqxum1dHeqeBiWns3aO0thPHJl4+fEhp+vawpfg JcE+EqdgCdYRH0t6sksouq6UihIaRxTB027K/2ksywUfcowTjJdzwVsSiXWItetd4bXV +8kiT8DyBDC01TToRWIVjPZgTjF6YBV0FZP3KOGw4d4KTruU8mPe5FZS8KTCC0WJxWws 6aTHw7codOkvRnaMIH4gVnB4cdCOmhJJJJFDSQXK+2cbXizW2ElLWAjtzk1rNP2Cbd4m nSD77rNpq6UgWTVjRZgVZRC9fi27j6aO+PSIOr+XVWPBPoieKHv5sL1+ada96FYz7tLX BbrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=BqW8JiuIYvnXw5H3Z5hu1Iu1nuYkaGW3P8AQ8gC+FKM=; b=DWSQZpC7QMgrJ1JnM5nvCd8G/yG/LPnIRS6oanO+86VwvW70TsedluPekIIEpfjQhp kHDde9QaMmntDmwYUHM3H5AjRD1UNnQgiHP2/lBea1cSiEpGmaycV2rYahjPs5TrdeYu CCMQa5I8KhNzpWm0UVToFYtE/1d9t7ZHFPvIKpCZW0jDO8N0MypxSw5yyRO2PhiaGB+k eXOlIs6ACOPMwP1n8dvdUJNg2IZxMdftdqFk62wMsh6U1hKd0FBfrB97eq6XIVBUUkmn ynOigH94R1BNN3pbBOYeMXhAo+/60KBfrQN6CIBKbXAYzj1hZwtaQBN7ELd6WsGWlOnl UYqQ== X-Gm-Message-State: AOAM530uyRMhxCc4yRrQ03zLIEaFUYPJKRjYORG+DzzxIKh++27d709u odGBXYL1M4XUVVVk2fPwTMcNfw== X-Received: by 2002:a17:906:c094:: with SMTP id f20mr5604777ejz.550.1602876773475; Fri, 16 Oct 2020 12:32:53 -0700 (PDT) Received: from localhost (82-65-169-74.subs.proxad.net. [82.65.169.74]) by smtp.gmail.com with ESMTPSA id u18sm2533174ejn.122.2020.10.16.12.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Oct 2020 12:32:52 -0700 (PDT) References: <20201016173020.12686-1-jassisinghbrar@gmail.com> <1jh7quj9sa.fsf@starbuckisacylon.baylibre.com> User-agent: mu4e 1.3.3; emacs 26.3 From: Jerome Brunet To: Jassi Brar Cc: Linux Kernel Mailing List , "open list\:ARM\/Amlogic Meson..." , Ionela Voinescu , Kevin Hilman , Da Xue , Sudeep Holla , Jassi Brar Subject: Re: [PATCH] mailbox: avoid timer start from callback In-reply-to: Date: Fri, 16 Oct 2020 21:32:52 +0200 Message-ID: <1jeelyj7a3.fsf@starbuckisacylon.baylibre.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 16 Oct 2020 at 20:45, Jassi Brar wrote: > On Fri, Oct 16, 2020 at 1:38 PM Jerome Brunet wrote: >> >> >> On Fri 16 Oct 2020 at 19:30, jassisinghbrar@gmail.com wrote: >> >> > From: Jassi Brar >> > >> > If the txdone is done by polling, it is possible for msg_submit() to start >> > the timer while txdone_hrtimer() callback is running. If the timer needs >> > recheduling, it could already be enqueued by the time hrtimer_forward_now() >> > is called, leading hrtimer to loudly complain. >> > >> > WARNING: CPU: 3 PID: 74 at kernel/time/hrtimer.c:932 hrtimer_forward+0xc4/0x110 >> > CPU: 3 PID: 74 Comm: kworker/u8:1 Not tainted 5.9.0-rc2-00236-gd3520067d01c-dirty #5 >> > Hardware name: Libre Computer AML-S805X-AC (DT) >> > Workqueue: events_freezable_power_ thermal_zone_device_check >> > pstate: 20000085 (nzCv daIf -PAN -UAO BTYPE=--) >> > pc : hrtimer_forward+0xc4/0x110 >> > lr : txdone_hrtimer+0xf8/0x118 >> > [...] >> > >> > This can be fixed by not starting the timer from the callback path. Which >> > requires the timer reloading as long as any message is queued on the >> > channel, and not just when current tx is not done yet. >> > >> > Signed-off-by: Jassi Brar >> > --- >> > drivers/mailbox/mailbox.c | 12 +++++++----- >> > 1 file changed, 7 insertions(+), 5 deletions(-) >> > >> > diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c >> > index 0b821a5b2db8..a093a6ecaa66 100644 >> > --- a/drivers/mailbox/mailbox.c >> > +++ b/drivers/mailbox/mailbox.c >> > @@ -82,9 +82,12 @@ 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 */ >> > - hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL); >> > + /* kick start the timer immediately to avoid delays */ >> > + if (!err && (chan->txdone_method & TXDONE_BY_POLL)) { >> > + /* but only if not already active */ >> >> It would solve the problem I reported as well but instead of running the >> check immediately (timer with value 0), we will have to wait for the >> next of the timer, it is already started. IOW, there might be a delay >> now. I don't know if this important for the mailbox - the existing >> comments in the code suggested it was. >> > That comment is for when the first message is queued on the channel, > which remains unimpacted. > So, do I have your tested/acked by ? Sure go ahead Acked-by: Jerome Brunet Tested-by: Jerome Brunet > > thnx,