devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neal Liu <neal.liu@mediatek.com>
To: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Neal Liu <neal.liu@mediatek.com>,
	Rob Herring <robh+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	<devicetree@vger.kernel.org>,
	wsd_upstream <wsd_upstream@mediatek.com>,
	lkml <linux-kernel@vger.kernel.org>,
	"moderated list:ARM/Mediatek SoC support" 
	<linux-mediatek@lists.infradead.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v2 2/2] soc: mediatek: add mtk-devapc driver
Date: Tue, 14 Jul 2020 11:06:52 +0800	[thread overview]
Message-ID: <1594696012.26207.11.camel@mtkswgap22> (raw)
In-Reply-To: <CAAOTY_931nJb2Ove5NzfAWX=xy0D3oj6y5d0ThRsvhANFf1_BQ@mail.gmail.com>

Hi Chun-Kuang,

On Mon, 2020-07-13 at 22:20 +0800, Chun-Kuang Hu wrote:
> Hi, Neal:
> 
> Neal Liu <neal.liu@mediatek.com> 於 2020年7月13日 週一 下午4:27寫道:
> >
> > Hi Chun-Kuang,
> >
> > Thanks for your review.
> >
> > On Fri, 2020-07-10 at 22:21 +0800, Chun-Kuang Hu wrote:
> > > Hi, Neal:
> > >
> > > Neal Liu <neal.liu@mediatek.com> 於 2020年7月10日 週五 上午11:23寫道:
> > > >
> > > > Hi Chun-Kuang,
> > > >
> > > > Thanks for your review.
> > > >
> > > > On Thu, 2020-07-09 at 21:01 +0800, Chun-Kuang Hu wrote:
> > > > > Hi, Neal:
> > > > >
> > > > > Neal Liu <neal.liu@mediatek.com> 於 2020年7月9日 週四 下午5:13寫道:
> > > > > >
> > > > > > MediaTek bus fabric provides TrustZone security support and data
> > > > > > protection to prevent slaves from being accessed by unexpected
> > > > > > masters.
> > > > > > The security violation is logged and sent to the processor for
> > > > > > further analysis or countermeasures.
> > > > > >
> > > > > > Any occurrence of security violation would raise an interrupt, and
> > > > > > it will be handled by mtk-devapc driver. The violation
> > > > > > information is printed in order to find the murderer.
> > > > > >
> > > > > > Signed-off-by: Neal Liu <neal.liu@mediatek.com>
> > > > >
> > > > > [snip]
> > > > >
> > > > > > +
> > > > > > +static u32 get_shift_group(struct mtk_devapc_context *devapc_ctx,
> > > > > > +                          int slave_type, int vio_idx)
> > > > >
> > > > > vio_idx  is useless, so remove it.
> > > > >
> > > >
> > > > yes, my mistake. I'll remove it on next patch.
> > > >
> > > > > > +{
> > > > > > +       u32 vio_shift_sta;
> > > > > > +       void __iomem *reg;
> > > > > > +       int bit;
> > > > > > +
> > > > > > +       reg = mtk_devapc_pd_get(devapc_ctx, slave_type, VIO_SHIFT_STA, 0);
> > > > > > +       vio_shift_sta = readl(reg);
> > > > > > +
> > > > > > +       for (bit = 0; bit < 32; bit++) {
> > > > > > +               if ((vio_shift_sta >> bit) & 0x1)
> > > > > > +                       break;
> > > > > > +       }
> > > > > > +
> > > > > > +       return bit;
> > > > > > +}
> > > > > > +
> > > > >
> > > > > [snip]
> > > > >
> > > > > > +
> > > > > > +/*
> > > > > > + * devapc_violation_irq - the devapc Interrupt Service Routine (ISR) will dump
> > > > > > + *                       violation information including which master violates
> > > > > > + *                       access slave.
> > > > > > + */
> > > > > > +static irqreturn_t devapc_violation_irq(int irq_number,
> > > > > > +                                       struct mtk_devapc_context *devapc_ctx)
> > > > > > +{
> > > > > > +       const struct mtk_device_info **device_info;
> > > > > > +       int slave_type_num;
> > > > > > +       int vio_idx = -1;
> > > > > > +       int slave_type;
> > > > > > +
> > > > > > +       slave_type_num = devapc_ctx->slave_type_num;
> > > > > > +       device_info = devapc_ctx->device_info;
> > > > > > +
> > > > > > +       for (slave_type = 0; slave_type < slave_type_num; slave_type++) {
> > > > >
> > > > > If slave_type_num is 1, I think the code should be simpler.
> > > >
> > > > slave_type_num is depends on DT data, it's not always 1.
> > >
> > > Please change commit title to "add mt6779 mtk-devapc driver". This
> > > patch is just for mt6779. If slave_type_num = 1 in mt6779, there is
> > > only one slave and we don't need a slave_type variable. Add
> > > slave_type_num in the patch of adding one SoC which has multiple
> > > slaves.
> >
> > If slave_type_num value is passed from DT data, could we still assume
> > its value? Does it make sense to have this strong assumption?
> 
> Maintainer has asked you to move this data from device tree to driver
> [1], I doubt you could get this data from device tree. Even though
> device tree has this property, this driver support only mt6779 now, so
> it's not necessary to have slave_type_num because slave type is only
> 1. I think we should not consider support multiple SoC in this patch.
> 
> [1] https://urldefense.com/v3/__https://patchwork.kernel.org/patch/11653911/__;!!CTRNKA9wMg0ARbw!2H8CQE__ALAhGUhNaL7yB1LXLskBkymEfb2FST0jrbJgmOMKa8-AeJXMAyUkHjAl$ 
> 

Okay, I'll follow maintainer's suggestion.

> >
> > I'm going to remove mtk_device_info struct array, and pass all SoC
> > specific data from DT.
> > Is it okay to keep slave_type_num as a variance?
> >
> > >
> > > >
> > > > >
> > > > > > +               if (!mtk_devapc_dump_vio_dbg(devapc_ctx, slave_type, &vio_idx))
> > > > > > +                       continue;
> > > > > > +
> > > > > > +               /* Ensure that violation info are written before
> > > > > > +                * further operations
> > > > > > +                */
> > > > > > +               smp_mb();
> > > > > > +
> > > > > > +               mask_module_irq(devapc_ctx, slave_type, vio_idx, true);
> > > > >
> > > > > Why do you mask irq?
> > > >
> > > > It has to mask slave's irq before clear violation status.
> > > > It's one of hardware design.
> > >
> > > If don't do this before clear_vio_status, what would happen? The clear
> > > would fail?
> >
> > If we don't mask slave's irq before clear vio status, It might trigger
> > another interrupt before current ISR finished. The nested interrupt will
> > have unexpected behavior and hardware state machine goes wrong.
> 
> This hardware is so special. For general hardware, only clear status
> would let hardware stop interrupt. Please add a comment about this
> special hardware behavior.

I'll double confirm and add comment if it's necessary.

> 
> >
> > >
> > > >
> > > > >
> > > > > > +
> > > > > > +               clear_vio_status(devapc_ctx, slave_type, vio_idx);
> > > > > > +
> > > > > > +               mask_module_irq(devapc_ctx, slave_type, vio_idx, false);
> > > > > > +       }
> > > > > > +
> > > > > > +       return IRQ_HANDLED;
> > > > > > +}
> > > > > > +
> > > > > > +/*
> > > > > > + * start_devapc - initialize devapc status and start receiving interrupt
> > > > > > + *               while devapc violation is triggered.
> > > > > > + */
> > > > >
> > > > > [snip]
> > > > >
> > > > > > +
> > > > > > +struct mtk_device_info {
> > > > > > +       int sys_index;
> > > > >
> > > > > Useless, so remove it.
> > > >
> > > > We need to print it as our debug information.
> > > > But I did not apply it on this patch, I'll add it on next patch.
> > >
> > > I think vio address is enough to find out the murder, so remove it in
> > > this patch. If it provide another information, add it in another patch
> > > and describe clear about what is this and how to use this information.
> > >
> >
> > Okay, it make sense. I'll remove it in next patches.
> >
> > > >
> > > > >
> > > > > > +       int ctrl_index;
> > > > >
> > > > > Ditto.
> > > > >
> > > > > Regards,
> > > > > Chun-Kuang.
> > > > >
> > > > > > +       int vio_index;
> > > > > > +};
> > > > > > +
> > > >
> >


  reply	other threads:[~2020-07-14  3:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09  9:12 [PATCH v2] Add MediaTek MT6779 devapc driver Neal Liu
2020-07-09  9:12 ` [PATCH v2 1/2] dt-bindings: devapc: add bindings for mtk-devapc Neal Liu
2020-07-10 10:41   ` Matthias Brugger
2020-07-14  3:17     ` Neal Liu
2020-07-09  9:12 ` [PATCH v2 2/2] soc: mediatek: add mtk-devapc driver Neal Liu
2020-07-09 13:01   ` Chun-Kuang Hu
2020-07-10  3:23     ` Neal Liu
2020-07-10 14:21       ` Chun-Kuang Hu
2020-07-13  8:27         ` Neal Liu
2020-07-13 14:20           ` Chun-Kuang Hu
2020-07-14  3:06             ` Neal Liu [this message]
2020-07-10 12:14   ` Matthias Brugger
2020-07-13  7:45     ` Neal Liu
2020-07-13 11:16       ` Matthias Brugger
2020-07-14  2:45         ` Neal Liu
2020-07-15 23:46   ` Chun-Kuang Hu
2020-07-16  3:42     ` Neal Liu

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=1594696012.26207.11.camel@mtkswgap22 \
    --to=neal.liu@mediatek.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=devicetree@vger.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=robh+dt@kernel.org \
    --cc=wsd_upstream@mediatek.com \
    /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;
as well as URLs for NNTP newsgroup(s).