Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1467329ybh; Thu, 23 Jul 2020 09:33:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPWTxCWwtWb+jt5UQ1PTHX+BGIORZ6bcukaCyrBQ6/4nuYZBLTUAeIZaGP/gvMKgBKg/32 X-Received: by 2002:a17:906:8392:: with SMTP id p18mr5516298ejx.24.1595521985227; Thu, 23 Jul 2020 09:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595521985; cv=none; d=google.com; s=arc-20160816; b=EUMdRCruUz+9Dvctn4cmvlVbhCQcYuyCEqDbstQ1INCCfz8Nj78ycMzzxdUU9Ja3oh jOBnmxADITMMu2gG5SHAG02C29FZJ4jBvAMTheBfkFO/736DwN+2ttTBk5O8rKFnPSKS +UqevCKWQNHWw+C+Frlj+gl3MeuPP9gfRZcScWGz5ldYXhKcSC/esOJRudj4GdpCJUIn XRyS/8pEjSFXcUJ72Re0Kwo3yS7I8zShL+oqUzA3Z6At5lcpxs0tGw9Q35Dgd0/hPhoe OxIfCzqqCQEpuk3HtF69XAfX8wCnrSWXf1yWaG7ld4x/mvzvNOLgK4vqDXoAMg9LQvU2 i8cA== 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=mn16eWRC+nyEu5oMUwy8h/mvV3GfiFNpJ4FryeKJgqA=; b=YMvxqCilBpuRwDeTvZcyLztZI5M3AWVaR3TcXtXvTNPXPEYVH70+IpXldwxCoLgB/M x1yY5MlALR/qF3yO3QJs8wuKURtE1xM9X1m0TCjxBBMEhjZJM6AHYAuxLoGGdk9Bk5Si /tA1dwmGR6yiDggseb0mJD7qBN3Vb5C7OOzFCiA3a/91SjH/VnzdXTZU/Za0sO6zb9td we8oT25ZGaKcvBkp3qyzfahLnEUMxr1tXa7BykcQp2wBDqqLlRGHxIUTpAtQvprX9Jr7 uvBhaMeZJcCgqa1d0V5xBoxbA9/Nf/CAaqrOydSOOQMrQaugdnXZ/wTq0SB0rXfONgZ7 +aQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bO22246C; 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 bc17si2168993edb.392.2020.07.23.09.32.42; Thu, 23 Jul 2020 09:33:05 -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=bO22246C; 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 S1729811AbgGWQcQ (ORCPT + 99 others); Thu, 23 Jul 2020 12:32:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:49818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgGWQcP (ORCPT ); Thu, 23 Jul 2020 12:32:15 -0400 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 A0ACC206F4; Thu, 23 Jul 2020 16:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595521934; bh=UsE0AfyyH9ASPhZTnv7rHkKV2A1QkqMr7Pj3l5isRpU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=bO22246CLB+6Y85wT9sR8OfksIMvslPN0d6PY6Z1fDrwncHCz7S7WQGLe4vDVJHRF xHNUH0d8FJaQhBWKzmQf+3JWJdo0M0jl3QCXzSyAnkfHV0Cj6YH7haYvdpblpiWsoO wlLNFtk5bP/EiZlb5mKEGbxK9+kzU1HMLchHxM8M= Received: by mail-ed1-f42.google.com with SMTP id d18so4973452edv.6; Thu, 23 Jul 2020 09:32:14 -0700 (PDT) X-Gm-Message-State: AOAM532QQlAIqN8HVPlzreYM+OHg4eTrw7YHxmbr/+BaGkW2d5mlrmhm 8Pe0iG1k7zUJ+L0L6PmIA/UCSM0Ofc+iTpekFQ== X-Received: by 2002:a50:e617:: with SMTP id y23mr4915055edm.47.1595521933191; Thu, 23 Jul 2020 09:32:13 -0700 (PDT) MIME-Version: 1.0 References: <1595303971-8793-1-git-send-email-neal.liu@mediatek.com> <1595303971-8793-3-git-send-email-neal.liu@mediatek.com> <1595389756.20193.12.camel@mtkswgap22> <1595484707.26237.12.camel@mtkswgap22> In-Reply-To: <1595484707.26237.12.camel@mtkswgap22> From: Chun-Kuang Hu Date: Fri, 24 Jul 2020 00:32:02 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 2/2] soc: mediatek: add mtk-devapc driver To: Neal Liu Cc: Chun-Kuang Hu , 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=8823=E6=97= =A5 =E9=80=B1=E5=9B=9B =E4=B8=8B=E5=8D=882:11=E5=AF=AB=E9=81=93=EF=BC=9A > > Hi Chun-Kuang, > > On Wed, 2020-07-22 at 22:25 +0800, Chun-Kuang Hu wrote: > > Hi, Neal: > > > > Neal Liu =E6=96=BC 2020=E5=B9=B47=E6=9C=8822=E6= =97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8A=E5=8D=8811:49=E5=AF=AB=E9=81=93=EF=BC= =9A > > > > > > Hi Chun-Kuang, > > > > > > On Wed, 2020-07-22 at 07:21 +0800, Chun-Kuang Hu wrote: > > > > Hi, Neal: > > > > > > > > Neal Liu =E6=96=BC 2020=E5=B9=B47=E6=9C=882= 1=E6=97=A5 =E9=80=B1=E4=BA=8C =E4=B8=8B=E5=8D=8812:00=E5=AF=AB=E9=81=93=EF= =BC=9A > > > > > > > > > > > > > > + > > > > > +/* > > > > > + * mtk_devapc_dump_vio_dbg - get the violation index and dump th= e full violation > > > > > + * debug information. > > > > > + */ > > > > > +static bool mtk_devapc_dump_vio_dbg(struct mtk_devapc_context *c= tx, u32 vio_idx) > > > > > +{ > > > > > + u32 shift_bit; > > > > > + > > > > > + if (check_vio_mask(ctx, vio_idx)) > > > > > + return false; > > > > > + > > > > > + if (!check_vio_status(ctx, vio_idx)) > > > > > + return false; > > > > > + > > > > > + shift_bit =3D get_shift_group(ctx, vio_idx); > > > > > + > > > > > + if (sync_vio_dbg(ctx, shift_bit)) > > > > > + return false; > > > > > + > > > > > + devapc_extract_vio_dbg(ctx); > > > > > > > > I think get_shift_group(), sync_vio_dbg(), and > > > > devapc_extract_vio_dbg() should be moved out of vio_idx for-loop (t= he > > > > loop in devapc_violation_irq()) because these three function is not > > > > related to vio_idx. > > > > Another question: when multiple vio_idx violation occur, vio_addr i= s > > > > related to which one vio_idx? The latest happened one? > > > > > > > > > > Actually, it's related to vio_idx. But we don't use it directly on th= ese > > > function. I think below snip code might be better way to understand i= t. > > > > > > for (...) > > > { > > > check_vio_mask() > > > check_vio_status() > > > > > > // if get vio_idx, mask it temporarily > > > mask_module_irq(true) > > > clear_vio_status() > > > > > > // dump violation info > > > get_shift_group() > > > sync_vio_dbg() > > > devapc_extract_vio_dbg() > > > > > > // unmask > > > mask_module_irq(false) > > > } > > > > This snip code does not explain any thing. I could rewrite this code as= : > > > > for (...) > > { > > check_vio_mask() > > check_vio_status() > > > > // if get vio_idx, mask it temporarily > > mask_module_irq(true) > > clear_vio_status() > > // unmask > > mask_module_irq(false) > > } > > > > // dump violation info > > get_shift_group() > > sync_vio_dbg() > > devapc_extract_vio_dbg() > > > > And my version is identical with your version, isn't it? > > Sorry, I did not explain it clearly. Let's me try again. > The reason why I put "dump violation info" between mask & unmask context > is because it has to stop interrupt first before dump violation info, > and then unmask it to prepare next violation. > These sequence guarantee that if multiple violation is triggered, we > still have information to debug. > If the code sequence in your version and multiple violation is > triggered, there might be no any information but keeps entering ISR. > Finally, system might be abnormal and watchdog timeout. > In this case, we still don't have any information to debug. I still don't understand why no information to debug. For example when vio_idx 5, 10, 15 has violation, You would mask vio_idx 5 to get information, but vio_idx 10, 15 does not mask yet. In your words, when vio_idx 10, 15 not mask, you would not get any debug information when you process vio_idx 5. In my version, I would clear all status, why keeps entering ISR? > > > > > > > > > About your question, vio_addr would be the first one. > > > > So other vio_addr would be dropped? Or hardware would keep all > > vio_addr and you have some way to get all vio_addr? > > > > In this case, hardware will drop other violation info and keep the first > one until it been handled. Does 'handled' mean status is cleared? Regards, Chun-Kuang. > > > > > > > > > + > > > > > + return true; > > > > > +} > > > > > + > > > > > +/* > > > > > + * 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= *ctx) > > > > > +{ > > > > > + u32 vio_idx; > > > > > + > > > > > + for (vio_idx =3D 0; vio_idx < ctx->vio_idx_num; vio_idx++= ) { > > > > > + if (!mtk_devapc_dump_vio_dbg(ctx, vio_idx)) > > > > > + continue; > > > > > + > > > > > + /* Ensure that violation info are written before > > > > > + * further operations > > > > > + */ > > > > > + smp_mb(); > > > > > + > > > > > + /* > > > > > + * Mask slave's irq before clearing vio status. > > > > > + * Must do it to avoid nested interrupt and preve= nt > > > > > + * unexpected behavior. > > > > > + */ > > > > > + mask_module_irq(ctx, vio_idx, true); > > > > > + > > > > > + clear_vio_status(ctx, vio_idx); > > > > > + > > > > > + mask_module_irq(ctx, vio_idx, false); > > > > > + } > > > > > + > > > > > + return IRQ_HANDLED; > > > > > +} > > > > > + > > > > > +/*