lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANMq1KC0nDNRUGm8Y5Lw1nH1uecYx7FnG9sWY=Gg9RhisroafA@mail.gmail.com>
Date:   Sat, 31 Oct 2020 09:49:11 +0800
From:   Nicolas Boichat <drinkcat@...omium.org>
To:     Houlong Wei <houlong.wei@...iatek.com>
Cc:     Matthias Brugger <matthias.bgg@...il.com>,
        Jassi Brar <jassisinghbrar@...il.com>,
        Daniel Kurtz <djkurtz@...omium.org>,
        lkml <linux-kernel@...r.kernel.org>,
        linux-arm Mailing List <linux-arm-kernel@...ts.infradead.org>,
        "moderated list:ARM/Mediatek SoC support" 
        <linux-mediatek@...ts.infradead.org>,
        srv_heupstream <srv_heupstream@...iatek.com>,
        CK HU <ck.hu@...iatek.com>,
        Bibby Hsieh <bibby.hsieh@...iatek.com>,
        Daoyuan Huang <daoyuan.huang@...iatek.com>,
        Dennis-YC Hsieh <dennis-yc.hsieh@...iatek.com>,
        ginny.chen@...iatek.com,
        Yongqiang Niu <yongqiang.niu@...iatek.com>,
        Nicolas Boichat <drinkcat@...omium.org>
Subject: Re: [PATCH] soc: mediatek: cmdq: fixup possible timeout issue

Thanks for the patch.

On Thu, Oct 22, 2020 at 5:44 PM Houlong Wei <houlong.wei@...iatek.com> wrote:
>
> Fixes: 576f1b4bc802 ("soc: mediatek: Add Mediatek CMDQ helper")

nit: This belongs right next to the Sob line, but I guess/hope
Matthias can help you fix that ,-)

>
> There may be possible timeout issue when lots of cmdq packets are
> flushed to the same cmdq client. The necessary modifications are as
> below.
> 1.Adjust the timer timeout period as client->timeout_ms * client->pkt_cnt.
> 2.Optimize the time to start the timer.
>

Reviewed-by: Nicolas Boichat <drinkcat@...omium.org>

> Signed-off-by: Houlong Wei <houlong.wei@...iatek.com>
> ---
>  drivers/soc/mediatek/mtk-cmdq-helper.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
> index dc644cfb6419..31142c193527 100644
> --- a/drivers/soc/mediatek/mtk-cmdq-helper.c
> +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
> @@ -350,7 +350,8 @@ static void cmdq_pkt_flush_async_cb(struct cmdq_cb_data data)
>                         del_timer(&client->timer);
>                 else
>                         mod_timer(&client->timer, jiffies +
> -                                 msecs_to_jiffies(client->timeout_ms));
> +                                 msecs_to_jiffies(client->timeout_ms *
> +                                                  client->pkt_cnt));
>                 spin_unlock_irqrestore(&client->lock, flags);
>         }
>
> @@ -379,9 +380,7 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_async_flush_cb cb,
>
>         if (client->timeout_ms != CMDQ_NO_TIMEOUT) {
>                 spin_lock_irqsave(&client->lock, flags);
> -               if (client->pkt_cnt++ == 0)
> -                       mod_timer(&client->timer, jiffies +
> -                                 msecs_to_jiffies(client->timeout_ms));
> +               client->pkt_cnt++;
>                 spin_unlock_irqrestore(&client->lock, flags);
>         }
>
> @@ -391,6 +390,21 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_async_flush_cb cb,
>         /* We can send next packet immediately, so just call txdone. */
>         mbox_client_txdone(client->chan, 0);
>
> +       if (client->timeout_ms != CMDQ_NO_TIMEOUT) {
> +               spin_lock_irqsave(&client->lock, flags);
> +               /*
> +                * GCE HW maybe execute too quickly and the callback function
> +                * may be invoked earlier. If this happens, pkt_cnt is reduced
> +                * by 1 in cmdq_pkt_flush_async_cb(). The timer is set only if
> +                * pkt_cnt is greater than 0.
> +                */
> +               if (client->pkt_cnt > 0)
> +                       mod_timer(&client->timer, jiffies +
> +                                 msecs_to_jiffies(client->timeout_ms *
> +                                                  client->pkt_cnt));
> +               spin_unlock_irqrestore(&client->lock, flags);
> +       }
> +
>         return 0;
>  }
>  EXPORT_SYMBOL(cmdq_pkt_flush_async);
> --
> 2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ