linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Neal Liu <neal.liu@mediatek.com>
To: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: devicetree@vger.kernel.org,
	wsd_upstream <wsd_upstream@mediatek.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Neal Liu <neal.liu@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	"moderated list:ARM/Mediatek SoC support"
	<linux-mediatek@lists.infradead.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/2] soc: mediatek: devapc: add devapc-mt6873 driver
Date: Mon, 15 Jun 2020 10:43:14 +0800	[thread overview]
Message-ID: <1592188994.18525.11.camel@mtkswgap22> (raw)
In-Reply-To: <CAAOTY_8W7FLrjKbNt+WHXjsBzgn_E7n5stKjv94RBnF7ktVuiA@mail.gmail.com>

Hi Chun-Kuang,


On Sun, 2020-06-14 at 11:26 +0800, Chun-Kuang Hu wrote:
> Hi, Neal:
> 
> Neal Liu <neal.liu@mediatek.com> 於 2020年6月9日 週二 下午6:25寫道:
> >
> > MT6873 bus frabric provides TrustZone security support and data
> > protection to prevent slaves from being accessed by unexpected
> > masters.
> > The security violations are 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 devapc-mt6873 driver. The violation
> > information is printed in order to find the murderer.
> >
> > Signed-off-by: Neal Liu <neal.liu@mediatek.com>
> > ---
> 
> [snip]
> 
> > +
> > +       /* 50 */
> > +       {-1, -1, 50, "OOB_way_en", true},
> > +       {-1, -1, 51, "OOB_way_en", true},
> > +       {-1, -1, 52, "OOB_way_en", true},
> > +       {-1, -1, 53, "OOB_way_en", true},
> > +       {-1, -1, 54, "OOB_way_en", true},
> > +       {-1, -1, 55, "OOB_way_en", true},
> > +       {-1, -1, 56, "Decode_error", true},
> > +       {-1, -1, 57, "Decode_error", true},
> > +       {-1, -1, 58, "DISP_PWM", false},
> > +       {-1, -1, 59, "IMP_IIC_WRAP", false},
> > +
> > +       /* 60 */
> > +       {-1, -1, 60, "DEVICE_APC_PERI_PAR__AO", false},
> > +       {-1, -1, 61, "DEVICE_APC_PERI_PAR_PDN", false},
> 
> You does not process the item whose enable_vio_irq is false, so I
> think you should remove these items and remove enable_vio_irq because
> the rest item's enable_vio_irq would always be true.

In some users, they can decide which slaves they want to enable or
disable violation irq in different product. We remain this property for
compatibility.

> 
> > +};
> > +
> > +static struct mtk_device_num mtk6873_devices_num[] = {
> > +       {SLAVE_TYPE_INFRA, VIO_SLAVE_NUM_INFRA},
> > +       {SLAVE_TYPE_PERI, VIO_SLAVE_NUM_PERI},
> > +       {SLAVE_TYPE_PERI2, VIO_SLAVE_NUM_PERI2},
> > +       {SLAVE_TYPE_PERI_PAR, VIO_SLAVE_NUM_PERI_PAR},
> > +};
> > +
> > +static struct PERIAXI_ID_INFO peri_mi_id_to_master[] = {
> > +       {"THERM2",       { 0, 0, 0 } },
> > +       {"SPM",          { 0, 1, 0 } },
> > +       {"CCU",          { 0, 0, 1 } },
> > +       {"THERM",        { 0, 1, 1 } },
> > +       {"SPM_DRAMC",    { 1, 1, 0 } },
> 
> The bits { 1, 1, 0 } equal to a number 0x3, I thiink you should use a
> number instead of bits and everything would be more easy.

We would like to keep it because the bit value contains more than 0/1,
it might be '2' in some cases. '2' means it can be 0 or 1. This totally
by hardware design & implementation.

> > +};
> > +
> 
> [snip]
> 
> > +
> > +/*
> > + * mtk_devapc_vio_check - check violation shift status is raised or not.
> > + *
> > + * Returns the value of violation shift status reg
> > + */
> > +static void mtk_devapc_vio_check(int slave_type, int *shift_bit)
> > +{
> > +       u32 slave_type_num = mtk_devapc_ctx->soc->slave_type_num;
> > +       struct mtk_devapc_vio_info *vio_info;
> > +       u32 vio_shift_sta;
> > +       int i;
> > +
> > +       if (slave_type >= slave_type_num) {
> 
> This never happen, so remove it.

Indeed, thanks

> 
> > +               pr_err(PFX "%s: param check failed, %s:0x%x\n",
> > +                      __func__, "slave_type", slave_type);
> > +               return;
> > +       }
> > +
> > +       vio_info = mtk_devapc_ctx->soc->vio_info;
> > +       vio_shift_sta = readl(mtk_devapc_pd_get(slave_type, VIO_SHIFT_STA, 0));
> > +
> > +       if (!vio_shift_sta) {
> > +               pr_info(PFX "violation is triggered before. %s:0x%x\n",
> > +                       "shift_bit", *shift_bit);
> > +
> > +       } else if (vio_shift_sta & (0x1UL << *shift_bit)) {
> > +               pr_debug(PFX "%s: 0x%x is matched with %s:%d\n",
> > +                        "vio_shift_sta", vio_shift_sta,
> > +                        "shift_bit", *shift_bit);
> > +
> > +       } else {
> > +               pr_info(PFX "%s: 0x%x is not matched with %s:%d\n",
> > +                       "vio_shift_sta", vio_shift_sta,
> > +                       "shift_bit", *shift_bit);
> > +
> > +               for (i = 0; i < MOD_NO_IN_1_DEVAPC * 2; i++) {
> > +                       if (vio_shift_sta & (0x1 << i)) {
> > +                               *shift_bit = i;
> > +                               break;
> > +                       }
> > +               }
> > +       }
> > +
> > +       vio_info->shift_sta_bit = *shift_bit;
> > +}
> > +
> > +static void devapc_extract_vio_dbg(int slave_type)
> > +{
> > +       u32 slave_type_num = mtk_devapc_ctx->soc->slave_type_num;
> > +       void __iomem *vio_dbg0_reg, *vio_dbg1_reg, *vio_dbg2_reg;
> > +       const struct mtk_infra_vio_dbg_desc *vio_dbgs;
> > +       struct mtk_devapc_vio_info *vio_info;
> > +       u32 dbg0;
> > +
> > +       if (slave_type >= slave_type_num) {
> 
> Ditto.

Indeed, thanks

> 
> Regards,
> Chun-Kuang.
> 
> > +               pr_err(PFX "%s: param check failed, %s:0x%x\n",
> > +                      __func__, "slave_type", slave_type);
> > +               return;
> > +       }
> > +
> > +       vio_dbg0_reg = mtk_devapc_pd_get(slave_type, VIO_DBG0, 0);
> > +       vio_dbg1_reg = mtk_devapc_pd_get(slave_type, VIO_DBG1, 0);
> > +       vio_dbg2_reg = mtk_devapc_pd_get(slave_type, VIO_DBG2, 0);
> > +
> > +       vio_dbgs = mtk_devapc_ctx->soc->vio_dbgs;
> > +       vio_info = mtk_devapc_ctx->soc->vio_info;
> > +
> > +       /* Extract violation information */
> > +       dbg0 = readl(vio_dbg0_reg);
> > +       vio_info->master_id = readl(vio_dbg1_reg);
> > +       vio_info->vio_addr = readl(vio_dbg2_reg);
> > +
> > +       vio_info->domain_id = (dbg0 & vio_dbgs->vio_dbg_dmnid)
> > +               >> vio_dbgs->vio_dbg_dmnid_start_bit;
> > +       vio_info->write = ((dbg0 & vio_dbgs->vio_dbg_w_vio)
> > +                       >> vio_dbgs->vio_dbg_w_vio_start_bit) == 1;
> > +       vio_info->read = ((dbg0 & vio_dbgs->vio_dbg_r_vio)
> > +                       >> vio_dbgs->vio_dbg_r_vio_start_bit) == 1;
> > +       vio_info->vio_addr_high = (dbg0 & vio_dbgs->vio_addr_high)
> > +               >> vio_dbgs->vio_addr_high_start_bit;
> > +
> > +       devapc_vio_info_print();
> > +}
> > +
> > +/*

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-06-15  2:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09 10:24 Add MediaTek MT6873 devapc driver Neal Liu
2020-06-09 10:24 ` [PATCH 1/2] dt-bindings: devapc: add bindings for devapc-mt6873 Neal Liu
2020-06-09 17:27   ` Rob Herring
     [not found] ` <1591698261-22639-3-git-send-email-neal.liu@mediatek.com>
2020-06-09 16:01   ` [PATCH 2/2] soc: mediatek: devapc: add devapc-mt6873 driver Chun-Kuang Hu
2020-06-11  9:26     ` Neal Liu
2020-06-11 11:01       ` Chun-Kuang Hu
2020-06-12  3:04         ` Neal Liu
2020-06-12 15:27           ` Chun-Kuang Hu
2020-06-15  2:12             ` Neal Liu
2020-06-12 23:20   ` Chun-Kuang Hu
2020-06-16  6:45     ` Neal Liu
2020-06-14  3:26   ` Chun-Kuang Hu
2020-06-15  2:43     ` Neal Liu [this message]
2020-06-15 14:14       ` Chun-Kuang Hu
2020-06-15 14:17         ` Chun-Kuang Hu
2020-06-16  6:09           ` Neal Liu
2020-06-15 15:51   ` Chun-Kuang Hu
2020-06-16  6:19     ` Neal Liu
2020-06-09 17:32 ` Add MediaTek MT6873 devapc driver Rob Herring
2020-06-24  3:51   ` 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=1592188994.18525.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).