Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp823552ybh; Wed, 15 Jul 2020 16:47:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAEf9OITp8E9ngJkOjEI2xVGvyeIl6G3HNIScfFyiQlBSqVu+i7DuMyzSlKUzaJZYzrPx1 X-Received: by 2002:a17:906:70cf:: with SMTP id g15mr1186402ejk.531.1594856867268; Wed, 15 Jul 2020 16:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594856867; cv=none; d=google.com; s=arc-20160816; b=q1kMujEu8aboZn+0YCeJ6lnr6vThgAcoVz5Zvlnc3wZPO/9KtDL9XSy4+/zk4TlYjj vPVTRZEwMQli5TIqxzTXp+vrl//LelP2eqnhMzPdHfZnLq3kXiA8/aVcnjdo0Vs0us2V xLe/VPCN+p0/lzof1JR1ZpKJlV5LMWJ7JvMBSP6wAlxTY/LSFK28uEyFkEU3+EwKs0W4 f59YV/cpSHSDGNRlzpb3iqOhQRU2mfS+QUHZ8GH9VoL+l/NBMBxj90RQgIqub+P4/3YA mBIoqXqcZJQvPTml3nzvErmnr/jXp7RlCgVf5/XzVkq1Y3Yb0qOKrjOepBvDEPukRJSq xmbQ== 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=i4kPDl6x6s03RRARtQudzOljIs5BKEw5fU8QbMk3s+k=; b=tK5tKbr+IOoQz5ZtSa+Xyvzwc/cGy3Tpc/aJSH7rlVW8sj0MRrtIOzvywHGS+AXL35 O2o1KWo4a/ieAnrbdirUOX/dWyaEMj1F4psG5r5heU/I+c/m8wDQzP9st0hhPmmRVbki YEh/4blsXHSwsyc3ZhYnFBtu24weYEKQ1pbiRmQXvMjcvg+zZWqZ4npPboFQUb9xMwe7 neTctjpnEwV5dI67r3ZanW+WE3GhbrqbljbMuw3kkP3fXhD+NE7qgEIEAz2TelzUjCs4 SG2nLH2HRUdwY8kahJPwr4xaLRnJS2Vc8ljhe8tsguaR7vGkPOP+MDXQD1oZD8DkNaff u2xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cYZW967h; 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 p16si2129533ejj.708.2020.07.15.16.47.25; Wed, 15 Jul 2020 16:47:47 -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=cYZW967h; 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 S1727058AbgGOXqw (ORCPT + 99 others); Wed, 15 Jul 2020 19:46:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:38022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbgGOXqw (ORCPT ); Wed, 15 Jul 2020 19:46:52 -0400 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 D5DE82072E; Wed, 15 Jul 2020 23:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594856812; bh=0Z67DEQDHtPE1jpEjdWwnW7bGURvhC5c7yF3Sjpr8hk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cYZW967hw78HF44rBPZbhDp74+Fd+k9NG8yQo6a39ZFC/RrcnhJ6l1FplyjoUsLrm FQsevYclY00Fz2eqEoFv+K3SCB82olAXFZcdd4hjHkAP04Pzv0CBfGSUBl69T9+uwx QCWEh/HsT2CBwvEiB8OsGm01nw7B6frzsh/OrI6w= Received: by mail-ej1-f44.google.com with SMTP id rk21so4339531ejb.2; Wed, 15 Jul 2020 16:46:51 -0700 (PDT) X-Gm-Message-State: AOAM532kg9G4jea9PAjzpCEwCelwqCRo5gplmvtz9bDuYmVSrDB8uDB1 26B+GzpQPWw1hFpMqjV5xtdTaad8obIQiyUOMw== X-Received: by 2002:a17:906:404e:: with SMTP id y14mr1294495ejj.260.1594856810429; Wed, 15 Jul 2020 16:46:50 -0700 (PDT) MIME-Version: 1.0 References: <1594285927-1840-1-git-send-email-neal.liu@mediatek.com> <1594285927-1840-3-git-send-email-neal.liu@mediatek.com> In-Reply-To: <1594285927-1840-3-git-send-email-neal.liu@mediatek.com> From: Chun-Kuang Hu Date: Thu, 16 Jul 2020 07:46:39 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 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=889=E6=97= =A5 =E9=80=B1=E5=9B=9B =E4=B8=8B=E5=8D=885:13=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] > + > +/* > + * mtk_devapc_dump_vio_dbg - shift & dump the violation debug informatio= n. > + */ > +static bool mtk_devapc_dump_vio_dbg(struct mtk_devapc_context *devapc_ct= x, > + int slave_type, int *vio_idx) > +{ > + const struct mtk_device_info **device_info; > + u32 shift_bit; > + int i; > + > + device_info =3D devapc_ctx->device_info; > + > + for (i =3D 0; i < get_vio_slave_num(slave_type); i++) { > + *vio_idx =3D device_info[slave_type][i].vio_index; > + > + if (check_vio_mask(devapc_ctx, slave_type, *vio_idx)) > + continue; I guess if one vio_idx is masked, its status would never be true. If my guess is right, I think you could skip check_vio_mask() and directly check_vio_status(). > + > + if (!check_vio_status(devapc_ctx, slave_type, *vio_idx)) > + continue; > + > + shift_bit =3D get_shift_group(devapc_ctx, slave_type, *vi= o_idx); > + > + if (!sync_vio_dbg(devapc_ctx, slave_type, shift_bit)) > + continue; > + > + devapc_extract_vio_dbg(devapc_ctx, slave_type); > + > + return true; I think multiple vio_idx would violate at the same time, why just process o= ne? Regards, Chun-Kuang. > + } > + > + return false; > +}