All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olof Johansson <olof@lixom.net>
To: Tomasz Figa <t.figa@samsung.com>
Cc: linux-samsung-soc@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kyungmin.park@samsung.com,
	kgene.kim@samsung.com, linux@arm.linux.org.uk, arnd@arndb.de
Subject: Re: [PATCH 2/5] ARM: Add interface for registering and calling firmware-specific operations
Date: Fri, 21 Sep 2012 22:50:15 -0700	[thread overview]
Message-ID: <20120922055015.GD32245@quad.lixom.net> (raw)
In-Reply-To: <1347524018-19301-3-git-send-email-t.figa@samsung.com>

On Thu, Sep 13, 2012 at 10:13:35AM +0200, Tomasz Figa wrote:
> Some boards are running with secure firmware running in TrustZone secure
> world, which changes the way some things have to be initialized.
> 
> This patch adds an interface for platforms to specify available firmware
> operations and call them.
> 
> A wrapper macro, call_firmware_op(), checks if the operation is provided
> and calls it if so, otherwise returns 0.
> 
> By default no operations are provided.
> 
> This is a follow-up on the patch by Kyungmin Park:
> [PATCH v5 1/2] ARM: Make a compile firmware conditionally
> http://thread.gmane.org/gmane.linux.ports.arm.kernel/183607/focus=183988
> 
> Example of use:
> 
> In code using firmware ops:
> 
> 	__raw_writel(virt_to_phys(exynos4_secondary_startup),
> 		CPU1_BOOT_REG);
> 
> 	/* Call Exynos specific smc call */
> 	do_firmware_op(cpu_boot, cpu);
> 
> 	gic_raise_softirq(cpumask_of(cpu), 1);
> 
> In board-/platform-specific code:
> 
> 	static int platformX_do_idle(void)
> 	{
> 		/* tell platformX firmware to enter idle */
> 	        return 0;
> 	}
> 
> 	static void platformX_cpu_boot(int i)
> 	{
> 		/* tell platformX firmware to boot CPU i */
> 	}
> 
> 	static const struct firmware_ops platformX_firmware_ops __initdata = {
> 		.do_idle	= exynos_do_idle,
> 		.cpu_boot	= exynos_cpu_boot,
> 		/* cpu_boot_reg not available on platformX */
> 	};
> 
> 	static void __init board_init_early(void)
> 	{
> 	        register_firmware_ops(&platformX_firmware_ops);
> 	}
> 
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Signed-off-by: Tomasz Figa <t.figa@samsung.com>
> ---
>  arch/arm/common/Makefile        |  2 ++
>  arch/arm/common/firmware.c      | 18 ++++++++++++++++++
>  arch/arm/include/asm/firmware.h | 30 ++++++++++++++++++++++++++++++
>  3 files changed, 50 insertions(+)
>  create mode 100644 arch/arm/common/firmware.c
>  create mode 100644 arch/arm/include/asm/firmware.h
> 
> diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
> index e8a4e58..55d4182 100644
> --- a/arch/arm/common/Makefile
> +++ b/arch/arm/common/Makefile
> @@ -2,6 +2,8 @@
>  # Makefile for the linux kernel.
>  #
>  
> +obj-y += firmware.o
> +
>  obj-$(CONFIG_ARM_GIC)		+= gic.o
>  obj-$(CONFIG_ARM_VIC)		+= vic.o
>  obj-$(CONFIG_ICST)		+= icst.o
> diff --git a/arch/arm/common/firmware.c b/arch/arm/common/firmware.c
> new file mode 100644
> index 0000000..27ddccb
> --- /dev/null
> +++ b/arch/arm/common/firmware.c
> @@ -0,0 +1,18 @@
> +/*
> + * Copyright (C) 2012 Samsung Electronics.
> + * Kyungmin Park <kyungmin.park@samsung.com>
> + * Tomasz Figa <t.figa@samsung.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/suspend.h>
> +
> +#include <asm/firmware.h>
> +
> +static const struct firmware_ops default_firmware_ops;
> +
> +const struct firmware_ops *firmware_ops = &default_firmware_ops;
> diff --git a/arch/arm/include/asm/firmware.h b/arch/arm/include/asm/firmware.h
> new file mode 100644
> index 0000000..ed51b02
> --- /dev/null
> +++ b/arch/arm/include/asm/firmware.h
> @@ -0,0 +1,30 @@
> +/*
> + * Copyright (C) 2012 Samsung Electronics.
> + * Kyungmin Park <kyungmin.park@samsung.com>
> + * Tomasz Figa <t.figa@samsung.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef __ASM_ARM_FIRMWARE_H
> +#define __ASM_ARM_FIRMWARE_H
> +
> +struct firmware_ops {
> +	int (*do_idle)(void);
> +	void (*cpu_boot)(int cpu);
> +	void __iomem *(*cpu_boot_reg)(int cpu);
> +};
> +
> +extern const struct firmware_ops *firmware_ops;
> +
> +#define call_firmware_op(op, ...)					\
> +	((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : 0)

I think this will cause sparse warnings for call_firmware_op(cpu_boot_reg)
if there are no ops defined, since the '0' isn't annotated as __iomem. And
you can't annotate it since the other function pointers don't need it.

I think you might be better off with stub functions as fallbacks instead of
allowing and checking for NULL here.


-Olof

WARNING: multiple messages have this Message-ID (diff)
From: olof@lixom.net (Olof Johansson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/5] ARM: Add interface for registering and calling firmware-specific operations
Date: Fri, 21 Sep 2012 22:50:15 -0700	[thread overview]
Message-ID: <20120922055015.GD32245@quad.lixom.net> (raw)
In-Reply-To: <1347524018-19301-3-git-send-email-t.figa@samsung.com>

On Thu, Sep 13, 2012 at 10:13:35AM +0200, Tomasz Figa wrote:
> Some boards are running with secure firmware running in TrustZone secure
> world, which changes the way some things have to be initialized.
> 
> This patch adds an interface for platforms to specify available firmware
> operations and call them.
> 
> A wrapper macro, call_firmware_op(), checks if the operation is provided
> and calls it if so, otherwise returns 0.
> 
> By default no operations are provided.
> 
> This is a follow-up on the patch by Kyungmin Park:
> [PATCH v5 1/2] ARM: Make a compile firmware conditionally
> http://thread.gmane.org/gmane.linux.ports.arm.kernel/183607/focus=183988
> 
> Example of use:
> 
> In code using firmware ops:
> 
> 	__raw_writel(virt_to_phys(exynos4_secondary_startup),
> 		CPU1_BOOT_REG);
> 
> 	/* Call Exynos specific smc call */
> 	do_firmware_op(cpu_boot, cpu);
> 
> 	gic_raise_softirq(cpumask_of(cpu), 1);
> 
> In board-/platform-specific code:
> 
> 	static int platformX_do_idle(void)
> 	{
> 		/* tell platformX firmware to enter idle */
> 	        return 0;
> 	}
> 
> 	static void platformX_cpu_boot(int i)
> 	{
> 		/* tell platformX firmware to boot CPU i */
> 	}
> 
> 	static const struct firmware_ops platformX_firmware_ops __initdata = {
> 		.do_idle	= exynos_do_idle,
> 		.cpu_boot	= exynos_cpu_boot,
> 		/* cpu_boot_reg not available on platformX */
> 	};
> 
> 	static void __init board_init_early(void)
> 	{
> 	????????register_firmware_ops(&platformX_firmware_ops);
> 	}
> 
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Signed-off-by: Tomasz Figa <t.figa@samsung.com>
> ---
>  arch/arm/common/Makefile        |  2 ++
>  arch/arm/common/firmware.c      | 18 ++++++++++++++++++
>  arch/arm/include/asm/firmware.h | 30 ++++++++++++++++++++++++++++++
>  3 files changed, 50 insertions(+)
>  create mode 100644 arch/arm/common/firmware.c
>  create mode 100644 arch/arm/include/asm/firmware.h
> 
> diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
> index e8a4e58..55d4182 100644
> --- a/arch/arm/common/Makefile
> +++ b/arch/arm/common/Makefile
> @@ -2,6 +2,8 @@
>  # Makefile for the linux kernel.
>  #
>  
> +obj-y += firmware.o
> +
>  obj-$(CONFIG_ARM_GIC)		+= gic.o
>  obj-$(CONFIG_ARM_VIC)		+= vic.o
>  obj-$(CONFIG_ICST)		+= icst.o
> diff --git a/arch/arm/common/firmware.c b/arch/arm/common/firmware.c
> new file mode 100644
> index 0000000..27ddccb
> --- /dev/null
> +++ b/arch/arm/common/firmware.c
> @@ -0,0 +1,18 @@
> +/*
> + * Copyright (C) 2012 Samsung Electronics.
> + * Kyungmin Park <kyungmin.park@samsung.com>
> + * Tomasz Figa <t.figa@samsung.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/suspend.h>
> +
> +#include <asm/firmware.h>
> +
> +static const struct firmware_ops default_firmware_ops;
> +
> +const struct firmware_ops *firmware_ops = &default_firmware_ops;
> diff --git a/arch/arm/include/asm/firmware.h b/arch/arm/include/asm/firmware.h
> new file mode 100644
> index 0000000..ed51b02
> --- /dev/null
> +++ b/arch/arm/include/asm/firmware.h
> @@ -0,0 +1,30 @@
> +/*
> + * Copyright (C) 2012 Samsung Electronics.
> + * Kyungmin Park <kyungmin.park@samsung.com>
> + * Tomasz Figa <t.figa@samsung.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef __ASM_ARM_FIRMWARE_H
> +#define __ASM_ARM_FIRMWARE_H
> +
> +struct firmware_ops {
> +	int (*do_idle)(void);
> +	void (*cpu_boot)(int cpu);
> +	void __iomem *(*cpu_boot_reg)(int cpu);
> +};
> +
> +extern const struct firmware_ops *firmware_ops;
> +
> +#define call_firmware_op(op, ...)					\
> +	((firmware_ops->op) ? firmware_ops->op(__VA_ARGS__) : 0)

I think this will cause sparse warnings for call_firmware_op(cpu_boot_reg)
if there are no ops defined, since the '0' isn't annotated as __iomem. And
you can't annotate it since the other function pointers don't need it.

I think you might be better off with stub functions as fallbacks instead of
allowing and checking for NULL here.


-Olof

  parent reply	other threads:[~2012-09-22  5:50 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13  8:13 [PATCH 0/5] ARM: EXYNOS: Add secure firmware support Tomasz Figa
2012-09-13  8:13 ` Tomasz Figa
2012-09-13  8:13 ` [PATCH 1/5] ARM: EXYNOS: Add IO mapping for non-secure SYSRAM Tomasz Figa
2012-09-13  8:13   ` Tomasz Figa
2012-09-13  8:13 ` [PATCH 2/5] ARM: Add interface for registering and calling firmware-specific operations Tomasz Figa
2012-09-13  8:13   ` Tomasz Figa
2012-09-13  8:25   ` Tomasz Figa
2012-09-13  8:25     ` Tomasz Figa
2012-09-22  5:50   ` Olof Johansson [this message]
2012-09-22  5:50     ` Olof Johansson
2012-09-22  6:01     ` Kyungmin Park
2012-09-22  6:01       ` Kyungmin Park
2012-09-22  6:23       ` Olof Johansson
2012-09-22  6:23         ` Olof Johansson
2012-09-22 13:17         ` Tomasz Figa
2012-09-22 13:17           ` Tomasz Figa
2012-09-22 13:22         ` Russell King - ARM Linux
2012-09-22 13:22           ` Russell King - ARM Linux
2012-09-13  8:13 ` [PATCH 3/5] ARM: EXYNOS: Add support for secure monitor calls Tomasz Figa
2012-09-13  8:13   ` Tomasz Figa
2012-09-13  8:13 ` [PATCH 4/5] ARM: EXYNOS: Add support for Exynos secure firmware Tomasz Figa
2012-09-13  8:13   ` Tomasz Figa
2012-09-16  0:44   ` Olof Johansson
2012-09-16  0:44     ` Olof Johansson
2012-09-19 10:10     ` Tomasz Figa
2012-09-19 10:10       ` Tomasz Figa
2012-09-22  5:39       ` Olof Johansson
2012-09-22  5:39         ` Olof Johansson
2012-09-22  5:57         ` Kyungmin Park
2012-09-22  5:57           ` Kyungmin Park
2012-09-22  6:36           ` Olof Johansson
2012-09-22  6:36             ` Olof Johansson
2012-09-22  6:39             ` Kyungmin Park
2012-09-22  6:39               ` Kyungmin Park
2012-09-24 14:39     ` Tomasz Figa
2012-09-24 14:39       ` Tomasz Figa
2012-09-13  8:13 ` [PATCH 5/5] ARM: EXYNOS: Add secure firmware support to secondary CPU bring-up Tomasz Figa
2012-09-13  8:13   ` Tomasz Figa
2012-09-19 13:29 ` [PATCH 0/5] ARM: EXYNOS: Add secure firmware support Tomasz Figa
2012-09-19 13:29   ` Tomasz Figa
2012-09-21  8:39   ` Kyungmin Park
2012-09-21  8:39     ` Kyungmin Park
2012-09-22  5:52     ` Olof Johansson
2012-09-22  5:52       ` Olof Johansson

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=20120922055015.GD32245@quad.lixom.net \
    --to=olof@lixom.net \
    --cc=arnd@arndb.de \
    --cc=kgene.kim@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=t.figa@samsung.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.