Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2057764ybg; Thu, 30 Jul 2020 09:17:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhjq3+iY/BgBOJ8wVQh4wCufoNqEkNiDTxeCab5N3LeRZDFNJOjQyrTD4YqWko5lRwUtm7 X-Received: by 2002:a17:906:1db1:: with SMTP id u17mr3252177ejh.72.1596125821544; Thu, 30 Jul 2020 09:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596125821; cv=none; d=google.com; s=arc-20160816; b=Jjhwz8ykkFGBEUiSawz5hB3f7qTdqawie/+MgG+YUmgdlusjViPaOghHdd0R+TTwpR G0Zb/ssQbRP75pKUnUiACqaLvx2TQFCobyvLtW8dwgOeFzlB5M/DtOclTULS6I+1RBaL nrtneVRBjfm/e2QZA3LofKVNdS2JBX2Ja1uf7gS4P1q6lZsloXpK8d9uFSkpf9DqCFiG jIqbsF/zOQOm9E3WHWjoXbWuX4frRyQsKO6SKvOHIoMk1OCScwpvRxfuoI8Am1htsMWl 3B3Ecn40pgUOXwKoNWU0eXemrmIizJMKPDkDMYuLF3aWnrklwxeQIpJ3c/xeoddbd2BK buoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Hz0f5neoa95cGB0h7S3XQWTVegrlA2+C1yVnV+ejw/Y=; b=yQRaRce/G77PpWWtKWIyM1AhVrqP/DJxieF5VRlo9eBJ4X3IH/s/86lNWRxnm0OPum eRqwv4S++Ykr58kzkJIF6J/u+pIlUZ7cFaHLeyxu57+V1P39zb/80wLRMAUiGPBLqlAd zXxWSbODF+TQ4fSOvbjPia/1YlLqgMlms4P/wGVHzurPYvcQbO8cV0A7ll2X4Rv/Buze 056qipyLGh/iQ0feJSfIjVO5bGQ4vryZpE/hrxYErAZSn/YVw6h/nb6RAQ+8w5eFVJo2 C8ngXMS6oqOznKoz0g3fSyPZf2r2MAk3U5OnbBvyp0hY/zqNHSWOTcl6AeQr8SR+z2/v SNBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yiVMnIgs; 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 l14si3258323ejz.730.2020.07.30.09.16.37; Thu, 30 Jul 2020 09:17:01 -0700 (PDT) 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=yiVMnIgs; 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 S1729937AbgG3QOg (ORCPT + 99 others); Thu, 30 Jul 2020 12:14:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:46450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbgG3QOf (ORCPT ); Thu, 30 Jul 2020 12:14:35 -0400 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 BA43D21744; Thu, 30 Jul 2020 16:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596125675; bh=0aMZNuZZ87P262TCTl7JTgVhH1Sd45zJlDg8CK8T17s=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=yiVMnIgskP2MdSlOX5zT5x+tdbya179aoYyaCEUrpUeGda7zpzQRm9WryG6OIZHzA m/MrEV0bMeZUKvzKnFR1Wo1BPiQE8tzfxC+sAOpcPVu29Gx58+xwFLr/PQ3DXj4l2w du6EYkGprZwG2z3Gz7OpHBMHrOXCAV3rV9UcyfHY= Received: by mail-ed1-f46.google.com with SMTP id q4so17149966edv.13; Thu, 30 Jul 2020 09:14:34 -0700 (PDT) X-Gm-Message-State: AOAM532t83zsQOxGeKaKLY2sGB1cFsaCdRjDOFOzzjOll0REJ1m+vPZY m0npOMeJkDkv5bp/lGuqcI3Va+fqDhRvyVTF9Q== X-Received: by 2002:a05:6402:38c:: with SMTP id o12mr3509657edv.271.1596125673214; Thu, 30 Jul 2020 09:14:33 -0700 (PDT) MIME-Version: 1.0 References: <1596010690-13178-1-git-send-email-neal.liu@mediatek.com> <1596010690-13178-3-git-send-email-neal.liu@mediatek.com> In-Reply-To: <1596010690-13178-3-git-send-email-neal.liu@mediatek.com> From: Chun-Kuang Hu Date: Fri, 31 Jul 2020 00:14:20 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 2/2] soc: mediatek: add mtk-devapc driver To: Neal Liu Cc: Rob Herring , Matthias Brugger , devicetree@vger.kernel.org, wsd_upstream , lkml , "moderated list:ARM/Mediatek SoC support" , Linux ARM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Neal: Neal Liu =E6=96=BC 2020=E5=B9=B47=E6=9C=8829=E6=97= =A5 =E9=80=B1=E4=B8=89 =E4=B8=8B=E5=8D=884:29=E5=AF=AB=E9=81=93=EF=BC=9A > > 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 > --- [snip] > + > +/* > + * devapc_extract_vio_dbg - extract full violation information after doi= ng > + * shift mechanism. > + */ > +static void devapc_extract_vio_dbg(struct mtk_devapc_context *ctx) > +{ > + const struct mtk_devapc_vio_dbgs *vio_dbgs; > + struct mtk_devapc_vio_info *vio_info; > + void __iomem *vio_dbg0_reg; > + void __iomem *vio_dbg1_reg; > + u32 dbg0; > + > + vio_dbg0_reg =3D ctx->devapc_pd_base + ctx->offset->vio_dbg0; > + vio_dbg1_reg =3D ctx->devapc_pd_base + ctx->offset->vio_dbg1; > + > + vio_dbgs =3D ctx->vio_dbgs; > + vio_info =3D ctx->vio_info; > + > + /* Starts to extract violation information */ > + dbg0 =3D readl(vio_dbg0_reg); > + vio_info->vio_addr =3D readl(vio_dbg1_reg); > + > + vio_info->master_id =3D (dbg0 & vio_dbgs->mstid.mask) >> > + vio_dbgs->mstid.start; > + vio_info->domain_id =3D (dbg0 & vio_dbgs->dmnid.mask) >> > + vio_dbgs->dmnid.start; > + vio_info->write =3D ((dbg0 & vio_dbgs->vio_w.mask) >> > + vio_dbgs->vio_w.start) =3D=3D 1; > + vio_info->read =3D ((dbg0 & vio_dbgs->vio_r.mask) >> > + vio_dbgs->vio_r.start) =3D=3D 1; > + vio_info->vio_addr_high =3D (dbg0 & vio_dbgs->addr_h.mask) >> > + vio_dbgs->addr_h.start; I would like to define the type of ctx->vio_info to be struct mtk_devapc_vio_dbgs { u32 mstid:16; u32 dmnid:6; u32 vio_w:1; u32 vio_r:1; u32 addr_h:4; u32 resv:4; }; so the code would like the simple way ctx->vio_info =3D (struct mtk_devapc_vio_dbgs)readl(vio_dbg1_reg); Regards, Chun-Kuang. > + > + devapc_vio_info_print(ctx); > +} > +