Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp433870pxa; Tue, 4 Aug 2020 08:59:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK+F30bTR5luV7aRLighDeqxQWBTqYQIz43euTcXOWmFRCtoRCdR604iLzRWZ0V0JMWlaJ X-Received: by 2002:a17:906:388b:: with SMTP id q11mr23238501ejd.100.1596556741637; Tue, 04 Aug 2020 08:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596556741; cv=none; d=google.com; s=arc-20160816; b=bK+DN0q4l3ylhXZpdU2Nf6/3hcXKOZmTj/Q4XnWirQEyvkm7rRL0eACiLrEZjSqL/6 wHyBcoN7Nsgoy6w+3kYRAZ1dAa+qjuYQz/ZByV50IG9/zAdFOM0UeY3xLUHUIce24m/+ YMhzjedVTx+Z9uiZVOaCr2oGdTbTDCuciNr2FwCnTEWxE00WijJzg7/k/RJac58KT22/ E1yBOe8p+ZOJw1orlz5tN4OGboo4k8uJAQM55XsDJWC2U/5MPhkq0LMEOJQRQd29+bmn NCVaTwQky4EBrxhAyhdKV5yV4u3Oao5GOgj4Hpc5VPc/REa+dsPLgteJSh4Di/M5c708 28TA== 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=uFdUWQ6BLn6Ij0X9U5ljc4wgsuuyNXrM3D2qM0n82TE=; b=oNwF6B/DeQeUSPOMxsAX5m+/l5U86WG2E75aEaJ+1rBhj7babSPyJy/Kfc4cqB0C/i 9/t9+o0SQWmWKl2+V0drDZnMaNgh0PcG+E0yrCpKlOWhe6L5fMlBlHNDH8+mZA4hIrMj ghAT7Rn7NcoiVXGIsx64iAMtkFahu8F46jG1DhNyg+H2hoEKE82bADpsxPCtEyzTS8nC 6aXT3mttjvbfboy6srIdWR6hpkYfnGolZRdAXsQNnHaW8MXmlKzSO8ywkTytYhXlg8I5 WDpRJxHbt0Jwrz6d5UUdyYtDq/fDc8XE1RPlPR1z7jRU1OjcCaWDe7Ek6ITmvCqReh17 qzIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Gn27xIYB; 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 rv7si12442490ejb.641.2020.08.04.08.58.37; Tue, 04 Aug 2020 08:59: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=Gn27xIYB; 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 S1728689AbgHDP4O (ORCPT + 99 others); Tue, 4 Aug 2020 11:56:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:56376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726398AbgHDP4L (ORCPT ); Tue, 4 Aug 2020 11:56:11 -0400 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.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 DCEF522BED; Tue, 4 Aug 2020 15:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596556571; bh=r9szaxcb0fGCAe0HMLSnjnkiEt8lN82rikVx3Wzyc8k=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Gn27xIYBRAdQ0HUbjrU0tl+T1HMHIOKi4NVP/JyyaE6gJ7Bdx/AQ+UqqHhNAgPxHU i+QHBYY/kYwJXZ29c9+zCWHKfuN+QTEA/tURLegO5jnKftEtEvMU94Y8SwrVDTH9kO 7j9BEUqKjSaLkvJZ+eelyokQWgMscR0UTF6YnBWA= Received: by mail-ed1-f44.google.com with SMTP id m20so20779504eds.2; Tue, 04 Aug 2020 08:56:10 -0700 (PDT) X-Gm-Message-State: AOAM531JTRoeA4xeqB9qDGRXC1DsePAzuVzqsf5ubUeh7Hf38lewg7Lt 7aSLXPIKZUMqwcxstzw+GtH+JC9/RM2pnsk6BA== X-Received: by 2002:a50:e109:: with SMTP id h9mr7783463edl.47.1596556569352; Tue, 04 Aug 2020 08:56:09 -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> <1596427295.22971.20.camel@mtkswgap22> <1596506892.17917.2.camel@mtkswgap22> In-Reply-To: <1596506892.17917.2.camel@mtkswgap22> From: Chun-Kuang Hu Date: Tue, 4 Aug 2020 23:55:57 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 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 Neal Liu =E6=96=BC 2020=E5=B9=B48=E6=9C=884=E6=97= =A5 =E9=80=B1=E4=BA=8C =E4=B8=8A=E5=8D=8810:08=E5=AF=AB=E9=81=93=EF=BC=9A > > On Tue, 2020-08-04 at 00:04 +0800, Chun-Kuang Hu wrote: > > Hi, Neal: > > > > Neal Liu =E6=96=BC 2020=E5=B9=B48=E6=9C=883=E6= =97=A5 =E9=80=B1=E4=B8=80 =E4=B8=8B=E5=8D=8812:01=E5=AF=AB=E9=81=93=EF=BC= =9A > > > > > > Hi Chun-Kuang, > > > > > > On Sat, 2020-08-01 at 08:12 +0800, Chun-Kuang Hu wrote: > > > > Hi, Neal: > > > > > > > > This patch is for "mediatek,mt6779-devapc", so I think commit title > > > > should show the SoC ID. > > > > > > Okay, I'll change title to 'soc:mediatek: add mt6779 devapc driver'. > > > > > > > > > > > Neal Liu =E6=96=BC 2020=E5=B9=B47=E6=9C=882= 9=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, an= d > > > > > 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] > > > > > > > > > + > > > > > +struct mtk_devapc_context { > > > > > + struct device *dev; > > > > > + u32 vio_idx_num; > > > > > + void __iomem *devapc_pd_base; > > > > > + struct mtk_devapc_vio_info *vio_info; > > > > > + const struct mtk_devapc_pd_offset *offset; > > > > > + const struct mtk_devapc_vio_dbgs *vio_dbgs; > > > > > +}; > > > > > > > > I think this structure should separate the constant part. The const= ant part is: > > > > > > > > struct mtk_devapc_data { > > > > const u32 vio_idx_num; > > > > const struct mtk_devapc_pd_offset *offset; /* I would like to > > > > remove struct mtk_devapc_pd_offset and directly put its member into > > > > this structure */ > > > > const struct mtk_devapc_vio_dbgs *vio_dbgs; /* This may disappe= ar */ > > > > }; > > > > > > > > And the context is: > > > > > > > > struct mtk_devapc_context { > > > > struct device *dev; > > > > void __iomem *devapc_pd_base; > > > > const struct mtk_devapc_data *data; > > > > }; > > > > > > > > So when you define this, you would not waste memory to store non-co= nstant data. > > > > > > > > static const struct mtk_devapc_data devapc_mt6779 =3D { > > > > .vio_idx_num =3D 510, > > > > .offset =3D &mt6779_pd_offset, > > > > .vio_dbgs =3D &mt6779_vio_dbgs, > > > > }; > > > > > > > > > > Sorry, I still don't understand why this refactoring will not waste > > > memory to store non-constant data. Could you explain more details? > > > To my understanding, we still also have to allocate memory to store d= ev > > > & devapc_pd_base. > > > > In some situation, it is. You make the non-constant data a global > > variable. I think the context data should be dynamic allocated. If > > this driver is not probed, the non-constant data occupy the memory. > > > > I got your point! In this case, we can save these 2 data structure > space, right? > > struct device *dev; > void __iomem *devapc_pd_base; Right. > > I'll refactoring this data structures on next patch. Thanks ! > > > Regards, > > Chun-Kuang. > > > > > > > > > Regards, > > > > Chun-Kuang. > > > > > > > > > + > > > > > +#endif /* __MTK_DEVAPC_H__ */ > > > > > -- > > > > > 1.7.9.5 > > > > > _______________________________________________ > > > > > Linux-mediatek mailing list > > > > > Linux-mediatek@lists.infradead.org > > > > > http://lists.infradead.org/mailman/listinfo/linux-mediatek > > > >