mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul-pl Chen (陳柏霖)" <Paul-pl.Chen@mediatek.com>
To: "robh@kernel.org" <robh@kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "Sunny Shen (沈姍姍)" <Sunny.Shen@mediatek.com>,
	"Sirius Wang (王皓昱)" <Sirius.Wang@mediatek.com>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"Xiandong Wang (王先冬)" <Xiandong.Wang@mediatek.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"fshao@chromium.org" <fshao@chromium.org>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"Singo Chang (張興國)" <Singo.Chang@mediatek.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"treapking@chromium.org" <treapking@chromium.org>
Subject: Re: [PATCH v2 07/15] soc: mediatek: mutex: refactor SOF settings for output components
Date: Wed, 2 Apr 2025 03:30:49 +0000	[thread overview]
Message-ID: <c3041f64d64425510f9c591efb2d056960f4f469.camel@mediatek.com> (raw)
In-Reply-To: <754df305-9767-47be-8f98-4e287c56808e@collabora.com>

On Mon, 2025-03-24 at 18:12 +0100, AngeloGioacchino Del Regno wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Il 21/03/25 10:33, paul-pl.chen ha scritto:
> > From: Nancy Lin <nancy.lin@mediatek.com>
> > 
> > Refactor SOF settings by adding mtk_mutex_get_output_comp_sof()
> > and extracting SOF logic from mtk_mutex_add_comp()
> > and mtk_mutex_remove_comp().
> > 
> > - Added mtk_mutex_add_comp_sof() and mtk_mutex_remove_comp_sof()
> >    for SOF settings.
> > - Reused the switch case for SOF IDs.
> > - Separated MOD and SOF logic.
> > 
> 
> This also needs more than one commit.
> 
> The cleanups go in a commit doing only cleanups.
> 
Hi AngeloGioacchino, 
Based on your advice, I'm considering dividing the changes as follows:

Commit 1:refactor SOF settings for output components

- Added mtk_mutex_add_comp_sof() and mtk_mutex_remove_comp_sof()
   for SOF settings.
- Separated MOD and SOF logic.

Commit 2: 
- Reused the switch case for SOF IDs.


> > Signed-off-by: Nancy Lin <nancy.lin@mediatek.com>
> > Signed-off-by: Paul-pl Chen <paul-pl.chen@mediatek.com>
> > ---
> >   drivers/soc/mediatek/mtk-mutex.c       | 121 +++++++++++++++-----
> > -----
> >   include/linux/soc/mediatek/mtk-mutex.h |   4 +
> >   2 files changed, 79 insertions(+), 46 deletions(-)
> > 
> > diff --git a/drivers/soc/mediatek/mtk-mutex.c
> > b/drivers/soc/mediatek/mtk-mutex.c
> > index aaa965d4b050..c026ac0e6969 100644
> > --- a/drivers/soc/mediatek/mtk-mutex.c
> > +++ b/drivers/soc/mediatek/mtk-mutex.c
> > @@ -853,43 +853,84 @@ void mtk_mutex_unprepare(struct mtk_mutex
> > *mutex)
> >   }
> >   EXPORT_SYMBOL_GPL(mtk_mutex_unprepare);
> > 
> > -void mtk_mutex_add_comp(struct mtk_mutex *mutex,
> > -                     enum mtk_ddp_comp_id id)
> > +static int mtk_mutex_get_output_comp_sof(enum mtk_ddp_comp_id id)
> >   {
> > -     struct mtk_mutex_ctx *mtx = container_of(mutex, struct
> > mtk_mutex_ctx,
> > -                                              mutex[mutex->id]);
> > -     unsigned int reg;
> > -     unsigned int sof_id;
> > -     unsigned int offset;
> > -
> > -     WARN_ON(&mtx->mutex[mutex->id] != mutex);
> > -
> >       switch (id) {
> >       case DDP_COMPONENT_DSI0:
> > -             sof_id = MUTEX_SOF_DSI0;
> > -             break;
> > +             return MUTEX_SOF_DSI0;
> >       case DDP_COMPONENT_DSI1:
> > -             sof_id = MUTEX_SOF_DSI0;
> > -             break;
> > +             return MUTEX_SOF_DSI1;
> >       case DDP_COMPONENT_DSI2:
> > -             sof_id = MUTEX_SOF_DSI2;
> > -             break;
> > +             return MUTEX_SOF_DSI2;
> >       case DDP_COMPONENT_DSI3:
> > -             sof_id = MUTEX_SOF_DSI3;
> > -             break;
> > +             return MUTEX_SOF_DSI3;
> >       case DDP_COMPONENT_DPI0:
> > -             sof_id = MUTEX_SOF_DPI0;
> > -             break;
> > +             return MUTEX_SOF_DPI0;
> >       case DDP_COMPONENT_DPI1:
> > -             sof_id = MUTEX_SOF_DPI1;
> > -             break;
> > +             return MUTEX_SOF_DPI1;
> >       case DDP_COMPONENT_DP_INTF0:
> > -             sof_id = MUTEX_SOF_DP_INTF0;
> > -             break;
> > +             return MUTEX_SOF_DP_INTF0;
> >       case DDP_COMPONENT_DP_INTF1:
> > -             sof_id = MUTEX_SOF_DP_INTF1;
> > -             break;
> > +             return MUTEX_SOF_DP_INTF1;
> >       default:
> > +             break;
> > +     }
> > +
> > +     return -EINVAL;
> > +}
> > +
> > +void mtk_mutex_add_comp_sof(struct mtk_mutex *mutex, enum
> > mtk_ddp_comp_id id)
> > +{
> > +     struct mtk_mutex_ctx *mtx = container_of(mutex, struct
> > mtk_mutex_ctx,
> > +                                              mutex[mutex->id]);
> > +     int sof_id = mtk_mutex_get_output_comp_sof(id);
> > +     unsigned int offset;
> > +
> > +     if (sof_id < 0 || sof_id >= DDP_MUTEX_SOF_MAX)
> > +             return;
> > +
> > +     WARN_ON(&mtx->mutex[mutex->id] != mutex);
> > +
> > +     offset = DISP_REG_MUTEX_SOF(mtx->data->mutex_sof_reg, mutex-
> > >id);
> > +
> > +     writel_relaxed(mtx->data->mutex_sof[sof_id],
> > +                    mtx->regs + offset);
> 
> fits in one line
> 
> OK, I will fix it in one line. 
> > +}
> > +EXPORT_SYMBOL_GPL(mtk_mutex_add_comp_sof);
> > +
> > +void mtk_mutex_remove_comp_sof(struct mtk_mutex *mutex, enum
> > mtk_ddp_comp_id id)
> > +{
> > +     struct mtk_mutex_ctx *mtx = container_of(mutex, struct
> > mtk_mutex_ctx,
> > +                                              mutex[mutex->id]);
> > +     unsigned int reg;
> > +     int sof_id = mtk_mutex_get_output_comp_sof(id);
> > +     unsigned int offset;
> > +
> > +     if (sof_id < 0 || sof_id >= DDP_MUTEX_SOF_MAX)
> > +             return;
> > +
> > +     WARN_ON(&mtx->mutex[mutex->id] != mutex);
> > +
> > +     offset = DISP_REG_MUTEX_SOF(mtx->data->mutex_sof_reg, mutex-
> > >id);
> > +     reg = readl_relaxed(mtx->regs + offset);
> > +     reg &= ~(1 << mtx->data->mutex_sof[id]);
> > +
> > +     writel_relaxed(reg, mtx->regs + offset);
> > +}
> > +EXPORT_SYMBOL_GPL(mtk_mutex_remove_comp_sof);
> > +
> > +void mtk_mutex_add_comp(struct mtk_mutex *mutex,
> > +                     enum mtk_ddp_comp_id id)
> > +{
> > +     struct mtk_mutex_ctx *mtx = container_of(mutex, struct
> > mtk_mutex_ctx,
> > +                                              mutex[mutex->id]);
> > +     unsigned int reg;
> > +     unsigned int offset;
> > +     bool is_output_comp = !!mtk_mutex_get_output_comp_sof(id);
> > +
> > +     WARN_ON(&mtx->mutex[mutex->id] != mutex);
> > +
> 
> Looks like you can just do
> 
>         if (is_output_comp) {
>                 mtk_mutex_add_comp_sof(mutex, id);
>                 return;
>         }
> 
>         if (mtx->data->mutex_mod[id] < 32) { .....etc
> 
OK,

This is because the next patch [PATCH v2 08/15], 
we have to consider using the condition of "mtx->data->need_sof_mod" 
to set the register setting of DISP_REG_MUTEX_MOD.


> > +     if (!is_output_comp) {
> >               if (mtx->data->mutex_mod[id] < 32) {
> >                       offset = DISP_REG_MUTEX_MOD(mtx->data-
> > >mutex_mod_reg,
> >                                                   mutex->id);
> > @@ -902,12 +943,10 @@ void mtk_mutex_add_comp(struct mtk_mutex
> > *mutex,
> >                       reg |= 1 << (mtx->data->mutex_mod[id] - 32);
> >                       writel_relaxed(reg, mtx->regs + offset);
> >               }
> > -             return;
> >       }
> > 
> > -     writel_relaxed(mtx->data->mutex_sof[sof_id],
> > -                    mtx->regs +
> > -                    DISP_REG_MUTEX_SOF(mtx->data->mutex_sof_reg,
> > mutex->id));
> > +     if (is_output_comp)
> > +             mtk_mutex_add_comp_sof(mutex, id);
> >   }
> >   EXPORT_SYMBOL_GPL(mtk_mutex_add_comp);
> > 
> > @@ -918,24 +957,11 @@ void mtk_mutex_remove_comp(struct mtk_mutex
> > *mutex,
> >                                                mutex[mutex->id]);
> >       unsigned int reg;
> >       unsigned int offset;
> > +     bool is_output_comp = !!mtk_mutex_get_output_comp_sof(id);
> > 
> >       WARN_ON(&mtx->mutex[mutex->id] != mutex);
> > 
> > -     switch (id) {
> > -     case DDP_COMPONENT_DSI0:
> > -     case DDP_COMPONENT_DSI1:
> > -     case DDP_COMPONENT_DSI2:
> > -     case DDP_COMPONENT_DSI3:
> > -     case DDP_COMPONENT_DPI0:
> > -     case DDP_COMPONENT_DPI1:
> > -     case DDP_COMPONENT_DP_INTF0:
> > -     case DDP_COMPONENT_DP_INTF1:
> > -             writel_relaxed(MUTEX_SOF_SINGLE_MODE,
> > -                            mtx->regs +
> > -                            DISP_REG_MUTEX_SOF(mtx->data-
> > >mutex_sof_reg,
> > -                                               mutex->id));
> > -             break;
> > -     default:
> > +     if (!is_output_comp) {
> 
> same comment as before.
> 

OK,

This is because the next patch [PATCH v2 08/15], 
we have to consider using the condition of "mtx->data->need_sof_mod" 
to set the register setting of DISP_REG_MUTEX_MOD.


Best regards, 
Paul
> >               if (mtx->data->mutex_mod[id] < 32) {
> >                       offset = DISP_REG_MUTEX_MOD(mtx->data-
> > >mutex_mod_reg,
> >                                                   mutex->id);
> > @@ -948,8 +974,11 @@ void mtk_mutex_remove_comp(struct mtk_mutex
> > *mutex,
> >                       reg &= ~(1 << (mtx->data->mutex_mod[id] -
> > 32));
> >                       writel_relaxed(reg, mtx->regs + offset);
> >               }
> > -             break;
> >       }
> > +
> > +     if (is_output_comp)
> > +             mtk_mutex_remove_comp_sof(mutex, id);
> > +
> 
> Regards,
> Angelo
> 
> 


  reply	other threads:[~2025-04-02  3:30 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-21  9:33 [PATCH v2 00/15] Add MediaTek SoC DRM support for MT8196 paul-pl.chen
2025-03-21  9:33 ` [PATCH v2 01/15] dt-bindings: arm: mediatek: mmsys: add compatible " paul-pl.chen
2025-03-24  9:33   ` Krzysztof Kozlowski
2025-03-21  9:33 ` [PATCH v2 02/15] dt-bindings: soc: mediatek: add mutex yaml " paul-pl.chen
2025-03-24  9:34   ` Krzysztof Kozlowski
2025-03-21  9:33 ` [PATCH v2 03/15] dt-bindings: display: mediatek: add EXDMA " paul-pl.chen
2025-03-24  2:45   ` CK Hu (胡俊光)
2025-05-14 16:25     ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 04/15] dt-bindings: display: mediatek: add BLENDER " paul-pl.chen
2025-03-24  9:36   ` Krzysztof Kozlowski
2025-03-28  2:27     ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 05/15] dt-bindings: display: mediatek: add OUTPROC " paul-pl.chen
2025-03-24 16:02   ` Rob Herring
2025-04-01 15:44     ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 06/15] soc: mediatek: add mmsys support " paul-pl.chen
2025-03-24 17:09   ` AngeloGioacchino Del Regno
2025-04-02  4:06     ` Paul-pl Chen (陳柏霖)
2025-04-02  9:33       ` AngeloGioacchino Del Regno
2025-04-11  9:26         ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 07/15] soc: mediatek: mutex: refactor SOF settings for output components paul-pl.chen
2025-03-24 17:12   ` AngeloGioacchino Del Regno
2025-04-02  3:30     ` Paul-pl Chen (陳柏霖) [this message]
2025-03-21  9:33 ` [PATCH v2 08/15] soc: mediatek: mutex: add mutex support for MT8196 paul-pl.chen
2025-03-21  9:33 ` [PATCH v2 09/15] drm/mediatek: Refine OVL format convert API and export to public paul-pl.chen
2025-03-25  2:57   ` CK Hu (胡俊光)
2025-05-13 16:22     ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 10/15] drm/mediatek: add EXDMA support for MT8196 paul-pl.chen
2025-03-24  3:00   ` CK Hu (胡俊光)
2025-05-14 10:00     ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 11/15] drm/mediatek: add BLENDER " paul-pl.chen
2025-03-24  8:33   ` CK Hu (胡俊光)
2025-05-13 17:12     ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 12/15] drm/mediatek: add OUTPROC " paul-pl.chen
2025-03-24  9:00   ` CK Hu (胡俊光)
2025-03-28  2:57     ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 13/15] drm/mediatek: add ovlsys_adaptor " paul-pl.chen
2025-04-11  3:07   ` CK Hu (胡俊光)
2025-05-14 16:18     ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 14/15] drm/mediatek: Add support for multiple mmsys in the one mediatek-drm driver paul-pl.chen
2025-03-25  3:44   ` CK Hu (胡俊光)
2025-05-13 16:11     ` Paul-pl Chen (陳柏霖)
2025-03-21  9:33 ` [PATCH v2 15/15] drm/mediatek: Add support for MT8196 multiple mmsys paul-pl.chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c3041f64d64425510f9c591efb2d056960f4f469.camel@mediatek.com \
    --to=paul-pl.chen@mediatek.com \
    --cc=Jason-JH.Lin@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Singo.Chang@mediatek.com \
    --cc=Sirius.Wang@mediatek.com \
    --cc=Sunny.Shen@mediatek.com \
    --cc=Xiandong.Wang@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fshao@chromium.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=treapking@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®