Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1413133pxu; Fri, 27 Nov 2020 06:46:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHlGHprrrRgPGhAw2ZzmtYvNlhtXZz3pkS/XFYyqmJXIixft/P830hzDE9b8sVrBRaLPqA X-Received: by 2002:a50:85c6:: with SMTP id q6mr8457984edh.126.1606488386470; Fri, 27 Nov 2020 06:46:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606488386; cv=none; d=google.com; s=arc-20160816; b=yYmvBWoIm9NygEU6DqXvoihMfbGf5X78Zo6rprKmr/g2jtsOejmoBUmmBOZhs+kZi4 2zwx3eMPbO6pBHjrc7jLiG8R0NoyiTNsSUljPAekXnCEAFEb5xK/ys4JRJqf/kkyC62+ Q9WsJQkDPsmncSg4v8C1xk57i6+rCvcV+3deRHbtf/2SWKpMhaPS9jVtCAZ/ns5/c29X cs8nbeqjU5SoRd1kivAWklLJF7preTWaECTXeOFh7dOnIUkWd/9wx1LsF2St8NMGKRjj 7X7BqO0heZfSoB6hxhF8PmbIKNbEcuKce7Ao/rVSSuqE2FRM8xdP9JeLg1cs8c0e8Ege Fong== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=eN348t+DVTOJwwENaEsg3UPb+ura1xTv3MUFasVZIVU=; b=u3BYgNyIiyP8IU5OhudHRCeQR0cAm+qyNLWKqrAg20bWlp3fKC9ypypdVyyYQkYEsz vI7eSg962VYkDwaA9xPAVx9bHwa/6xd4g8QuHn2mdAMhdglleBDJl8SvC+WQbP+eUOVI QaDNRJanTU8StZQXneNvB5bY3euudcNC1ZfaUZq51as8qOPKDSF/PPeq0g06Vkp1E7cb 3aPOfMfHlZ98NuRYXqWqRN1LcTCyre5X4bbxcKSNzHChU0Rei6eu3T/EH3PlkKVUufrZ OpSll9wXDApBLQP2CRpqRIKiwMaRmocOu1OFS3yZxWO9Se4JvmE/HPrGP249W9R+BMX2 jWwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z3aqRElI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bl4si5873064ejb.642.2020.11.27.06.46.00; Fri, 27 Nov 2020 06:46:26 -0800 (PST) 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=@kernel.org header.s=default header.b=z3aqRElI; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730869AbgK0Omq (ORCPT + 99 others); Fri, 27 Nov 2020 09:42:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:60474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730815AbgK0Omp (ORCPT ); Fri, 27 Nov 2020 09:42:45 -0500 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 46CDB221EB for ; Fri, 27 Nov 2020 14:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606488164; bh=Pc3HE3oATSYy+RsR0Pk0wV7ktVprytMyLWTEFH8OE2o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=z3aqRElIHhZYMqUN2sSDvPkoxA7Wr5e8i6DzYvMaOZl1d0+MQSEXEKmcenxnJrpgC idbgOh2vJGiiESs7HS8JwjoEApbpEb0f10SxxquXXtQMupCYLE/VZmMRpg6fIo8ETx iWw6VK+x9A18iUuTS5FHj6VIn8uW64XKLcpXU1zo= Received: by mail-ej1-f43.google.com with SMTP id o9so7960538ejg.1 for ; Fri, 27 Nov 2020 06:42:44 -0800 (PST) X-Gm-Message-State: AOAM533noiUbSwE9HGIi/O7VJ5NpkinjaxwvZpBdZ7EmOusQrnCU5y6V emPipilOTXbJBtIhBEAWX9YvcXhV75iyaYvReg== X-Received: by 2002:a17:907:720e:: with SMTP id dr14mr8170327ejc.303.1606488162650; Fri, 27 Nov 2020 06:42:42 -0800 (PST) MIME-Version: 1.0 References: <20201102000438.29225-1-chunkuang.hu@kernel.org> <4c00864c-a706-d73b-a8fb-e8e473db3f79@gmail.com> In-Reply-To: <4c00864c-a706-d73b-a8fb-e8e473db3f79@gmail.com> From: Chun-Kuang Hu Date: Fri, 27 Nov 2020 22:42:31 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] soc / drm: mediatek: cmdq: Remove timeout handler in helper function To: Matthias Brugger Cc: Chun-Kuang Hu , linux-kernel , DRI Development , "moderated list:ARM/Mediatek SoC support" , Linux ARM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Matthias: Matthias Brugger =E6=96=BC 2020=E5=B9=B411=E6=9C= =8827=E6=97=A5 =E9=80=B1=E4=BA=94 =E4=B8=8B=E5=8D=888:40=E5=AF=AB=E9=81=93= =EF=BC=9A > > Hi Chun-Kuang, > > On 20/11/2020 00:46, Chun-Kuang Hu wrote: > > Hi, Matthias: > > > > I've provided the example for why of this patch. How do you think > > about this patch? > > > > Patch looks good to me. If you want to take it through your tree you can = add my > Acked-by: Matthias Brugger > > Beware that you might need a stable tag for it, so that I can merge it in= to my > soc branch, in case there are more changes to cmdq-helper. I would like this patch to go into your tree because this patch mainly modify cmdq helper. Even though this patch is one of the series "Mediatek DRM driver detect CMDQ execution timeout by vblank IRQ" [1], I would wait for this patch get into mainline then send the next patch. Regards, Chun-Kuang. > > Regards, > Matthias > > > Regards, > > Chun-Kuang. > > > > Chun-Kuang Hu =E6=96=BC 2020=E5=B9=B411=E6=9C= =882=E6=97=A5 =E9=80=B1=E4=B8=80 =E4=B8=8A=E5=8D=888:04=E5=AF=AB=E9=81=93= =EF=BC=9A > >> > >> For each client driver, its timeout handler need to dump hardware regi= ster > >> or its state machine information, and their way to detect timeout are > >> also different, so remove timeout handler in helper function and > >> let client driver implement its own timeout handler. > >> > >> Signed-off-by: Chun-Kuang Hu > >> --- > >> v1 is one patch in series "Mediatek DRM driver detect CMDQ execution > >> timeout by vblank IRQ", but according to Jassi's suggestion [1], send > >> each patch in different series. > >> > >> [2] is an example that different client has different way to calculate > >> timeout. Some client driver care about each packet's execution time, b= ut > >> some client driver care about the total execution time for all packets= . > >> > >> [1] > >> https://patchwork.kernel.org/project/linux-mediatek/cover/202009272304= 22.11610-1-chunkuang.hu@kernel.org/ > >> [2] > >> https://patchwork.kernel.org/project/linux-mediatek/patch/202010220941= 52.17662-1-houlong.wei@mediatek.com/ > >> > >> Changes in v2: > >> 1. Rebase onto Linux 5.10-rc1 > >> --- > >> drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +- > >> drivers/soc/mediatek/mtk-cmdq-helper.c | 41 +----------------------= -- > >> include/linux/soc/mediatek/mtk-cmdq.h | 10 +----- > >> 3 files changed, 3 insertions(+), 51 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm= /mediatek/mtk_drm_crtc.c > >> index ac038572164d..4be5d1fccf2e 100644 > >> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > >> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > >> @@ -824,8 +824,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev= , > >> #if IS_REACHABLE(CONFIG_MTK_CMDQ) > >> mtk_crtc->cmdq_client =3D > >> cmdq_mbox_create(mtk_crtc->mmsys_dev, > >> - drm_crtc_index(&mtk_crtc->bas= e), > >> - 2000); > >> + drm_crtc_index(&mtk_crtc->bas= e)); > >> if (IS_ERR(mtk_crtc->cmdq_client)) { > >> dev_dbg(dev, "mtk_crtc %d failed to create mailbox cl= ient, writing register by CPU now\n", > >> drm_crtc_index(&mtk_crtc->base)); > >> diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/medi= atek/mtk-cmdq-helper.c > >> index 505651b0d715..280d3bd9f675 100644 > >> --- a/drivers/soc/mediatek/mtk-cmdq-helper.c > >> +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c > >> @@ -70,14 +70,7 @@ int cmdq_dev_get_client_reg(struct device *dev, > >> } > >> EXPORT_SYMBOL(cmdq_dev_get_client_reg); > >> > >> -static void cmdq_client_timeout(struct timer_list *t) > >> -{ > >> - struct cmdq_client *client =3D from_timer(client, t, timer); > >> - > >> - dev_err(client->client.dev, "cmdq timeout!\n"); > >> -} > >> - > >> -struct cmdq_client *cmdq_mbox_create(struct device *dev, int index, u= 32 timeout) > >> +struct cmdq_client *cmdq_mbox_create(struct device *dev, int index) > >> { > >> struct cmdq_client *client; > >> > >> @@ -85,12 +78,6 @@ struct cmdq_client *cmdq_mbox_create(struct device = *dev, int index, u32 timeout) > >> if (!client) > >> return (struct cmdq_client *)-ENOMEM; > >> > >> - client->timeout_ms =3D timeout; > >> - if (timeout !=3D CMDQ_NO_TIMEOUT) { > >> - spin_lock_init(&client->lock); > >> - timer_setup(&client->timer, cmdq_client_timeout, 0); > >> - } > >> - client->pkt_cnt =3D 0; > >> client->client.dev =3D dev; > >> client->client.tx_block =3D false; > >> client->client.knows_txdone =3D true; > >> @@ -112,11 +99,6 @@ EXPORT_SYMBOL(cmdq_mbox_create); > >> > >> void cmdq_mbox_destroy(struct cmdq_client *client) > >> { > >> - if (client->timeout_ms !=3D CMDQ_NO_TIMEOUT) { > >> - spin_lock(&client->lock); > >> - del_timer_sync(&client->timer); > >> - spin_unlock(&client->lock); > >> - } > >> mbox_free_channel(client->chan); > >> kfree(client); > >> } > >> @@ -449,18 +431,6 @@ static void cmdq_pkt_flush_async_cb(struct cmdq_c= b_data data) > >> struct cmdq_task_cb *cb =3D &pkt->cb; > >> struct cmdq_client *client =3D (struct cmdq_client *)pkt->cl; > >> > >> - if (client->timeout_ms !=3D CMDQ_NO_TIMEOUT) { > >> - unsigned long flags =3D 0; > >> - > >> - spin_lock_irqsave(&client->lock, flags); > >> - if (--client->pkt_cnt =3D=3D 0) > >> - del_timer(&client->timer); > >> - else > >> - mod_timer(&client->timer, jiffies + > >> - msecs_to_jiffies(client->timeout_ms)= ); > >> - spin_unlock_irqrestore(&client->lock, flags); > >> - } > >> - > >> dma_sync_single_for_cpu(client->chan->mbox->dev, pkt->pa_base= , > >> pkt->cmd_buf_size, DMA_TO_DEVICE); > >> if (cb->cb) { > >> @@ -473,7 +443,6 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmd= q_async_flush_cb cb, > >> void *data) > >> { > >> int err; > >> - unsigned long flags =3D 0; > >> struct cmdq_client *client =3D (struct cmdq_client *)pkt->cl; > >> > >> pkt->cb.cb =3D cb; > >> @@ -484,14 +453,6 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cm= dq_async_flush_cb cb, > >> dma_sync_single_for_device(client->chan->mbox->dev, pkt->pa_b= ase, > >> pkt->cmd_buf_size, DMA_TO_DEVICE); > >> > >> - if (client->timeout_ms !=3D CMDQ_NO_TIMEOUT) { > >> - spin_lock_irqsave(&client->lock, flags); > >> - if (client->pkt_cnt++ =3D=3D 0) > >> - mod_timer(&client->timer, jiffies + > >> - msecs_to_jiffies(client->timeout_ms)= ); > >> - spin_unlock_irqrestore(&client->lock, flags); > >> - } > >> - > >> err =3D mbox_send_message(client->chan, pkt); > >> if (err < 0) > >> return err; > >> diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc= /mediatek/mtk-cmdq.h > >> index 960704d75994..8e9996610978 100644 > >> --- a/include/linux/soc/mediatek/mtk-cmdq.h > >> +++ b/include/linux/soc/mediatek/mtk-cmdq.h > >> @@ -11,7 +11,6 @@ > >> #include > >> #include > >> > >> -#define CMDQ_NO_TIMEOUT 0xffffffffu > >> #define CMDQ_ADDR_HIGH(addr) ((u32)(((addr) >> 16) & GENMASK(31, 0= ))) > >> #define CMDQ_ADDR_LOW(addr) ((u16)(addr) | BIT(1)) > >> > >> @@ -24,12 +23,8 @@ struct cmdq_client_reg { > >> }; > >> > >> struct cmdq_client { > >> - spinlock_t lock; > >> - u32 pkt_cnt; > >> struct mbox_client client; > >> struct mbox_chan *chan; > >> - struct timer_list timer; > >> - u32 timeout_ms; /* in unit of microsecond */ > >> }; > >> > >> /** > >> @@ -51,13 +46,10 @@ int cmdq_dev_get_client_reg(struct device *dev, > >> * cmdq_mbox_create() - create CMDQ mailbox client and channel > >> * @dev: device of CMDQ mailbox client > >> * @index: index of CMDQ mailbox channel > >> - * @timeout: timeout of a pkt execution by GCE, in unit of microsec= ond, set > >> - * CMDQ_NO_TIMEOUT if a timer is not used. > >> * > >> * Return: CMDQ mailbox client pointer > >> */ > >> -struct cmdq_client *cmdq_mbox_create(struct device *dev, int index, > >> - u32 timeout); > >> +struct cmdq_client *cmdq_mbox_create(struct device *dev, int index); > >> > >> /** > >> * cmdq_mbox_destroy() - destroy CMDQ mailbox client and channel > >> -- > >> 2.17.1 > >>