mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Stefan Kerkmann <s.kerkmann@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 3/3] arm: mach-imx: tzasc: convert to cpu_is_mx8xyz macros
Date: Wed, 28 Feb 2024 14:17:07 +0100	[thread overview]
Message-ID: <6366bb10-adc4-4a00-ade4-eb4e301a379f@pengutronix.de> (raw)
In-Reply-To: <Zd8TjbHuzD0G81yW@pengutronix.de>

Hi Sascha,

On 28.02.24 12:05, Sascha Hauer wrote:
> On Wed, Feb 28, 2024 at 09:46:51AM +0100, Stefan Kerkmann wrote:
>> Hi Sascha,
>>
>> On 27.02.24 09:44, Sascha Hauer wrote:
>>> On Mon, Feb 26, 2024 at 03:40:23PM +0100, Stefan Kerkmann wrote:
>>>> Instead of passing in configuration parameters at runtime we can utilize
>>>> the `cpu_is_mx8xyz` macro family to determine which bits should be set.
>>>>
>>>> As the tzasc driver is imx specific, all functions are prefixed with
>>>> `imx8m_` as well.
>>>>
>>>> Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
>>>> ---
>>>>   arch/arm/mach-imx/atf.c   |  8 ++++----
>>>>   arch/arm/mach-imx/imx8m.c |  2 +-
>>>>   arch/arm/mach-imx/tzasc.c | 25 +++++--------------------
>>>>   include/mach/imx/tzasc.h  |  8 ++------
>>>>   4 files changed, 12 insertions(+), 31 deletions(-)
>>>>
>>>> diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
>>>> index e8060ebd95..9cbc38ef11 100644
>>>> --- a/arch/arm/mach-imx/atf.c
>>>> +++ b/arch/arm/mach-imx/atf.c
>>>> @@ -158,7 +158,7 @@ __noreturn void __imx8mm_load_and_start_image_via_tfa(void *bl33)
>>>>   		size_t bl32_size;
>>>>   		void *bl32_image;
>>>> -		imx8mm_tzc380_init();
>>>> +		imx8m_tzc380_init();
>>>
>>> I am not so sure about this patch. So far the whole PBL is coded in the
>>> way that we inherently know the SoC type from the code path chosen.
>>>
>>> This patch changes this. It doesn't really matter for this patch, but it
>>> sends a sign how we want to solve this in future.
>>
>> Let's see if I can persuade you that this is a good thing :-).
>>
>>> One implication of this patch is that cpu_is_mx() is a runtime decision,
>>> so code paths behind an unused cpu_is_mx() can't be discarded anymore.
>>
>> My argument here is that the overhead in code size is probably neglect able
>> in most cases, as most of the code paths are still discarded:
>>
>> 1. If there is only one ARCH selected e.g., `CONFIG_ARCH_IMX8MM` the
>> `cpu_is_mx8mm()` macro is still evaluated at compile time. As the
>> `__imx_cpu_type` variable is only assigned and never read it can be stripped
>> away by the compiler/linker and become a nop.
>>
>> 2. Runtime evaluation is only selected if a second arch is enabled for the
>> build. But even then the runtime decision is only compiled in for the two
>> selected arches, as all other `cpu_is_xyz` macros still evaluate at compile
>> time to false. So code paths that don't touch the selected arches will still
>> be stripped.
>>
>>> Another thing is that the usage of cpu_is() has the tendency to lead to
>>> cascades of if (cpu_is_x() || cpu_is_y() || cpu_is_z()) which is not
>>> paticularly nice to read.
>>>
>>
>> That is arguably subjective :-).
>>
>> For me as a developer that is new to barebox, it was confusing to find two
>> different styles of arch dependent code. I prefer the `cpu_is_xyz` style
>> approach which is used in barebox proper much more.
>>
>> In the case of the TZC380 driver the pseudo (as they are probably optimized
>> away) runtime arguments to the init functions seem unnecessarily
>> complicated, as does the approach to define aliases to the same function for
>> all arches. The if style is clearer in intend as it keeps the distinction
>> between the arches local to the parts that are actually different. Which is
>> straight forward to read IMHO.
> 
> Ok, let's see where this brings us. Can you rebase on current next?
> Some of the code you are modifying went to drivers/soc/imx/soc-imx8m.c
> recently.
> 

Great :-)! I've rebased and sent a v2 of this patch set.

> Sascha
> 

Cheers,
Stefan

-- 
Pengutronix e.K.                       | Stefan Kerkmann             |
Steuerwalder Str. 21                   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany              | Phone: +49-5121-206917-128  |
Amtsgericht Hildesheim, HRA 2686       | Fax:   +49-5121-206917-9    |



      reply	other threads:[~2024-02-28 13:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 14:40 [PATCH 0/3] arm: mach-imx: tzasc: port lock id_swap_bypass bit Stefan Kerkmann
2024-02-26 14:40 ` [PATCH 1/3] arm: mach-imx: tzasc: " Stefan Kerkmann
2024-02-26 16:02   ` Ahmad Fatoum
2024-02-26 16:38   ` ZHIZHIKIN Andrey
2024-02-26 14:40 ` [PATCH 2/3] arm: mach-imx: set cpu type in pbl Stefan Kerkmann
2024-02-26 16:15   ` Ahmad Fatoum
2024-02-26 14:40 ` [PATCH 3/3] arm: mach-imx: tzasc: convert to cpu_is_mx8xyz macros Stefan Kerkmann
2024-02-26 16:10   ` Ahmad Fatoum
2024-02-27  8:44   ` Sascha Hauer
2024-02-28  8:46     ` Stefan Kerkmann
2024-02-28  9:06       ` Ahmad Fatoum
2024-02-28 11:05       ` Sascha Hauer
2024-02-28 13:17         ` Stefan Kerkmann [this message]

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=6366bb10-adc4-4a00-ade4-eb4e301a379f@pengutronix.de \
    --to=s.kerkmann@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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