Peripheral image loader (PIL)
cover Peripheral image loader (PIL)
These patches add support for PIL, a peripheral image loader. More details can be found in the third patch or the second patch's commit text.
Saravana Kannan (1):
msm: documentation: Add pil documentation
Stephen Boyd (2):
msm: 8660: Add clock control regions to iomap
msm: Peripheral Image Loader (PIL) driver
Documentation/arm/msm/pil.txt | 267 ++++++++++ arch/arm/mach-msm/Kconfig | 13 + arch/arm/mach-msm/Makefile | 2 + arch/arm/mach-msm/include/mach/msm_iomap-8x60.h | 8 + arch/arm/mach-msm/include/mach/peripheral-loader.h | 23 + arch/arm/mach-msm/io.c | 2 + arch/arm/mach-msm/peripheral-loader.c | 402 +++++++++++++++ arch/arm/mach-msm/peripheral-loader.h | 38 ++ arch/arm/mach-msm/peripheral-reset.c | 528 ++++++++++++++++++++ 9 files changed, 1283 insertions(+), 0 deletions(-) create mode 100644 Documentation/arm/msm/pil.txt create mode 100644 arch/arm/mach-msm/include/mach/peripheral-loader.h create mode 100644 arch/arm/mach-msm/peripheral-loader.c create mode 100644 arch/arm/mach-msm/peripheral-loader.h create mode 100644 arch/arm/mach-msm/peripheral-reset.c
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 1/3 msm: 8660: Add clock control regions to iomap
--- arch/arm/mach-msm/include/mach/msm_iomap-8x60.h | 8 ++++++++ arch/arm/mach-msm/io.c | 2 ++ 2 files changed, 10 insertions(+), 0 deletions(-)
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h +8 -0
@@ -53,6 +53,14 @@#define MSM_TLMM_PHYS 0x00800000#define MSM_TLMM_SIZE SZ_16K +#define MSM_CLK_CTL_BASE IOMEM(0xFA010000) +#define MSM_CLK_CTL_PHYS 0x00900000 +#define MSM_CLK_CTL_SIZE SZ_16K + +#define MSM_LPASS_CLK_CTL_BASE IOMEM(0xFA015000) +#define MSM_LPASS_CLK_CTL_PHYS 0x28000000 +#define MSM_LPASS_CLK_CTL_SIZE SZ_4K +#define MSM_SHARED_RAM_BASE IOMEM(0xF0100000)#define MSM_SHARED_RAM_SIZE SZ_1M
arch/arm/mach-msm/io.c +2 -0
@@ -108,6 +108,8 @@ static struct map_desc msm8x60_io_desc[] __initdata = {MSM_CHIP_DEVICE (TMR0 ,MSM8X60 ),MSM_DEVICE (ACC ),MSM_DEVICE (GCC ), +MSM_DEVICE (CLK_CTL ), + MSM_DEVICE(LPASS_CLK_CTL), };void __init msm_map_msm8x60_io (void )
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 1/3] msm: 8660: Add clock control regions to iomap
Hello.
Quoted 1 line · Stephen Boyd
Change-Id: I9e72f10d0da1d6aaaaf7df85d33b998edf424f6f
This shouldn't be here.
Quoted 1 line
Signed-off-by Stephen Boyd<[email protected]>
[...]
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h line 58
Quoted 11 lines
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h +3
-0@@ -53,6 +53,14 @@#define MSM_TLMM_PHYS 0x00800000#define MSM_TLMM_SIZE SZ_16K +#define MSM_CLK_CTL_BASE IOMEM(0xFA010000) +#define MSM_CLK_CTL_PHYS 0x00900000 +#define MSM_CLK_CTL_SIZE SZ_16K
Surrounding code separates the macro names from values by tabs, and you're
using spaces. Should be more consistent...
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h line 65
Quoted 6 lines
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h +4
-0+#define MSM_LPASS_CLK_CTL_BASE IOMEM(0xFA015000) +#define MSM_LPASS_CLK_CTL_PHYS 0x28000000 +#define MSM_LPASS_CLK_CTL_SIZE SZ_4K +#define MSM_SHARED_RAM_BASE IOMEM(0xF0100000)#define MSM_SHARED_RAM_SIZE SZ_1M
WBR, Sergei
Re: [PATCH 1/3] msm: 8660: Add clock control regions to iomap
Quoted 7 lines · Sergei Shtylyov
Hello.
Quoted 1 line · Stephen Boyd
Change-Id: I9e72f10d0da1d6aaaaf7df85d33b998edf424f6f
This shouldn't be here.
I can remove the Change-Id when applying the patch, if there aren't any other comments.
David
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 1/3] msm: 8660: Add clock control regions to iomap
In reply to Sergei ShtylyovQuoted 10 lines · Sergei Shtylyov
Quoted 10 lines
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h +0
-0@@ -53,6 +53,14 @@#define MSM_TLMM_PHYS 0x00800000#define MSM_TLMM_SIZE SZ_16K
Quoted 6 lines
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h line 58
Quoted 3 lines
arch/arm/mach-msm/include/mach/msm_iomap-8x60.h +3
-0+#define MSM_CLK_CTL_BASE IOMEM(0xFA010000) +#define MSM_CLK_CTL_PHYS 0x00900000 +#define MSM_CLK_CTL_SIZE SZ_16KSurrounding code separates the macro names from values by tabs, and
you're using spaces. Should be more consistent...
Thanks, will fix.
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 2/3 msm: Peripheral Image Loader (PIL) driver
In reply to Stephen BoydOn 8660, the modem, dsp, and sensors peripherals require their firmware to be loaded into memory before they can be properly taken out of reset.
Drivers are expected to call pil_get() when they wish to load a peripheral. This will initiate multiple firmware_request()s for the metadata and image blobs for a peripheral. Once the image has been loaded into memory, it is validated and brought out of reset via the peripheral reset driver.
When drivers have completed using the peripheral they are expected to call pil_put(). This decrements a reference count on the peripheral and shuts down the device if it is no longer in use.
This driver also exposes a debugfs interface. The top level directory 'pil' contains a set of files (one file for each pil device). Writing 'get' to a file will call pil_get() with the device name. Writing 'put' to a file will call pil_put() with the device. Reading the file will return the reference count for the device.
The layout looks like this:
- pil |- dsps |- q6 |- modem
--- arch/arm/mach-msm/Kconfig | 13 + arch/arm/mach-msm/Makefile | 2 + arch/arm/mach-msm/include/mach/peripheral-loader.h | 23 + arch/arm/mach-msm/peripheral-loader.c | 402 +++++++++++++++ arch/arm/mach-msm/peripheral-loader.h | 38 ++ arch/arm/mach-msm/peripheral-reset.c | 528 ++++++++++++++++++++ 6 files changed, 1006 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-msm/include/mach/peripheral-loader.h create mode 100644 arch/arm/mach-msm/peripheral-loader.c create mode 100644 arch/arm/mach-msm/peripheral-loader.h create mode 100644 arch/arm/mach-msm/peripheral-reset.c
arch/arm/mach-msm/Kconfig +13 -0
@@ -210,4 +210,17 @@ config IOMMU_API config MSM_SCM bool + +config MSM_PIL + bool "Peripheral image loading (PIL)" + select FW_LOADER + select MSM_SCM + depends on ARCH_MSM8X60 + help + Some peripherals need to be loaded into memory before they can be + brought out of reset. + + Say yes to support these devices. + + endif
arch/arm/mach-msm/Makefile +2 -0
@@ -38,3 +38,5 @@ endif else obj-y += gpio.o endif + +obj-$(CONFIG_MSM_PIL) += peripheral-loader.o peripheral-reset.o
arch/arm/mach-msm/include/mach/peripheral-loader.h new file +23 -0
@@ -0,0 +1,23 @@ +/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#ifndef __MACH_PERIPHERAL_LOADER_H +#define __MACH_PERIPHERAL_LOADER_H + +#ifdef CONFIG_MSM_PIL +extern void *pil_get (const char *name); +extern void pil_put (void *peripheral_handle); +#else +static inline void *pil_get (const char *name) {return NULL ; } +static inline void pil_put (void *peripheral_handle) { } +#endif + +#endif
arch/arm/mach-msm/peripheral-loader.c new file +402 -0
402 lines not on this page · raw message
arch/arm/mach-msm/peripheral-loader.h new file +38 -0
@@ -0,0 +1,38 @@ +/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ +#ifndef __MACH_PERIPHERAL_LOADER_H +#define __MACH_PERIPHERAL_LOADER_H + +#include <linux/list.h> +#include <linux/mutex.h> +#include <linux/platform_device.h> + +struct pil_reset_ops { +int (*init_image)(const u8 *metadata,size_t size); +int (*verify_blob)(u32 phy_addr,size_t size); +int (*auth_and_reset)(void ); +int (*shutdown)(void ); +}; + +struct pil_device { +const char *name; +const char *depends_on; +int count; +struct mutex lock; +struct platform_device pdev; +struct list_head list; +struct pil_reset_ops *ops; +}; + +extern int msm_pil_add_device (struct pil_device *pil); + +#endif
arch/arm/mach-msm/peripheral-reset.c new file +528 -0
528 lines not on this page · raw message
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 2/3] msm: Peripheral Image Loader (PIL) driver
Quoted 9 lines · Stephen Boyd
On 8660, the modem, dsp, and sensors peripherals require their firmware to be loaded into memory before they can be properly taken out of reset.
Drivers are expected to call
pil_get()when they wish to load a peripheral. This will initiate multiple firmware_request()s for the metadata and image blobs for a peripheral. Once the image has been loaded into memory, it is validated and brought out of reset via the peripheral reset driver.
Why can't this be part of the generic firmware request API ?
Quoted 1 line
Change-Id: I041139464bbd3b646b82370ab540f40b0ac9af6b
Can't have Change-Id's ..
Quoted 34 lines
Reviewed-by Saravana Kannan <[email protected]>Signed-off-by Stephen Boyd <[email protected]>--- arch/arm/mach-msm/Kconfig | 13 + arch/arm/mach-msm/Makefile | 2 + arch/arm/mach-msm/include/mach/peripheral-loader.h | 23 + arch/arm/mach-msm/peripheral-loader.c | 402 +++++++++++++++ arch/arm/mach-msm/peripheral-loader.h | 38 ++ arch/arm/mach-msm/peripheral-reset.c | 528 ++++++++++++++++++++ 6 files changed, 1006 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-msm/include/mach/peripheral-loader.h create mode 100644 arch/arm/mach-msm/peripheral-loader.c create mode 100644 arch/arm/mach-msm/peripheral-loader.h create mode 100644 arch/arm/mach-msm/peripheral-reset.carch/arm/mach-msm/Kconfig +8
-0@@ -210,4 +210,17 @@ config IOMMU_API config MSM_SCM bool + +config MSM_PIL + bool "Peripheral image loading (PIL)" + select FW_LOADER + select MSM_SCM + depends on ARCH_MSM8X60 + help + Some peripherals need to be loaded into memory before theycan be
arch/arm/mach-msm/Kconfig config IOMMU_API · line 225
Quoted 5 lines
arch/arm/mach-msm/Kconfig +5
-0+ brought out of reset. + + Say yes to support these devices. + +
You shouldn't be adding anything like this to the Kconfig. To me if you add stuff like this it's a big red flag.
I didn't review the rest sign it might be wasted effort on my part..
Daniel
Re: [PATCH 2/3] msm: Peripheral Image Loader (PIL) driver
Quoted 5 lines · Daniel Walker
Quoted 4 lines · Stephen Boyd
On 8660, the modem, dsp, and sensors peripherals require their firmware to be loaded into memory before they can be properly taken out of reset.
Quoted 7 lines
Quoted 5 lines
Drivers are expected to call
pil_get()when they wish to load a peripheral. This will initiate multiple firmware_request()s for the metadata and image blobs for a peripheral. Once the image has been loaded into memory, it is validated and brought out of reset via the peripheral reset driver.Why can't this be part of the generic firmware request API ?
Can you clarify what you mean by this? The firmware request API is used to get the firmware itself, which this code uses. This code is what manages making those calls for the various MSM peripherals that require firmware.
Quoted 17 lines
Quoted 17 lines
arch/arm/mach-msm/Kconfig +8
-0@@ -210,4 +210,17 @@ config IOMMU_API config MSM_SCM bool + +config MSM_PIL + bool "Peripheral image loading (PIL)" + select FW_LOADER + select MSM_SCM + depends on ARCH_MSM8X60 + help + Some peripherals need to be loaded into memory before theycan be
Quoted 8 lines
arch/arm/mach-msm/Kconfig config IOMMU_API · line 225
Quoted 5 lines
arch/arm/mach-msm/Kconfig +5
-0+ brought out of reset. + + Say yes to support these devices. + +You shouldn't be adding anything like this to the
Kconfig. To me if you add stuff like this it's a big red flag.
Can you clarify what you mean "stuff like this".
It seems to me that this option should be selected by the drivers that need it, since it doesn't make sense to have this if there are no drivers that need it, and it is required when those drivers are included.
I do think there are valid hardware configurations that don't have any peripherals needing firmware, and would think that those should be able to avoid requiring the code to manage that. Saravana/Stephen can clarify that, though.
Thanks,
David
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 2/3] msm: Peripheral Image Loader (PIL) driver
Quoted 53 lines · David Brown
Quoted 5 lines · Daniel Walker
Quoted 4 lines · Stephen Boyd
On 8660, the modem, dsp, and sensors peripherals require their firmware to be loaded into memory before they can be properly taken out of reset.
Quoted 7 lines
Quoted 5 lines
Drivers are expected to call
pil_get()when they wish to load a peripheral. This will initiate multiple firmware_request()s for the metadata and image blobs for a peripheral. Once the image has been loaded into memory, it is validated and brought out of reset via the peripheral reset driver.Why can't this be part of the generic firmware request API ?
Can you clarify what you mean by this? The firmware request API is used to get the firmware itself, which this code uses. This code is what manages making those calls for the various MSM peripherals that require firmware.
Quoted 17 lines
Quoted 17 lines
arch/arm/mach-msm/Kconfig +8
-0@@ -210,4 +210,17 @@ config IOMMU_API config MSM_SCM bool + +config MSM_PIL + bool "Peripheral image loading (PIL)" + select FW_LOADER + select MSM_SCM + depends on ARCH_MSM8X60 + help + Some peripherals need to be loaded into memory before theycan be
Quoted 8 lines
arch/arm/mach-msm/Kconfig config IOMMU_API · line 225
Quoted 5 lines
arch/arm/mach-msm/Kconfig +5
-0+ brought out of reset. + + Say yes to support these devices. + +You shouldn't be adding anything like this to the
Kconfig. To me if you add stuff like this it's a big red flag.Can you clarify what you mean "stuff like this".
It seems to me that this option should be selected by the drivers that need it, since it doesn't make sense to have this if there are no drivers that need it, and it is required when those drivers are included.
Quoted 4 lines
I do think there are valid hardware configurations that don't have any peripherals needing firmware, and would think that those should be able to avoid requiring the code to manage that. Saravana/Stephen can clarify that, though.
Correct. There are plenty of Qualcomm SoCs that don't need this driver. There are also valid 8660 configurations that would not need this.
Thanks,
Saravana
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 2/3] msm: Peripheral Image Loader (PIL) driver
Quoted 54 lines · Saravana Kannan
Quoted 53 lines · David Brown
Quoted 5 lines · Daniel Walker
Quoted 4 lines · Stephen Boyd
On 8660, the modem, dsp, and sensors peripherals require their firmware to be loaded into memory before they can be properly taken out of reset.
Quoted 7 lines
Quoted 5 lines
Drivers are expected to call
pil_get()when they wish to load a peripheral. This will initiate multiple firmware_request()s for the metadata and image blobs for a peripheral. Once the image has been loaded into memory, it is validated and brought out of reset via the peripheral reset driver.Why can't this be part of the generic firmware request API ?
Can you clarify what you mean by this? The firmware request API is used to get the firmware itself, which this code uses. This code is what manages making those calls for the various MSM peripherals that require firmware.
Quoted 17 lines
Quoted 17 lines
arch/arm/mach-msm/Kconfig +8
-0@@ -210,4 +210,17 @@ config IOMMU_API config MSM_SCM bool + +config MSM_PIL + bool "Peripheral image loading (PIL)" + select FW_LOADER + select MSM_SCM + depends on ARCH_MSM8X60 + help + Some peripherals need to be loaded into memory before theycan be
Quoted 8 lines
arch/arm/mach-msm/Kconfig config IOMMU_API · line 225
Quoted 5 lines
arch/arm/mach-msm/Kconfig +5
-0+ brought out of reset. + + Say yes to support these devices. + +You shouldn't be adding anything like this to the
Kconfig. To me if you add stuff like this it's a big red flag.Can you clarify what you mean "stuff like this".
It seems to me that this option should be selected by the drivers that need it, since it doesn't make sense to have this if there are no drivers that need it, and it is required when those drivers are included.
Quoted 7 lines
Quoted 4 lines
I do think there are valid hardware configurations that don't have any peripherals needing firmware, and would think that those should be able to avoid requiring the code to manage that. Saravana/Stephen can clarify that, though.
Correct. There are plenty of Qualcomm SoCs that don't need this driver. There are also valid 8660 configurations that would not need this.
Being a driver it shouldn't be in mach-msm.
Daniel
Re: [PATCH 2/3] msm: Peripheral Image Loader (PIL) driver
In reply to David BrownQuoted 13 lines · David Brown
Quoted 11 lines · Daniel Walker
Quoted 9 lines · Stephen Boyd
On 8660, the modem, dsp, and sensors peripherals require their firmware to be loaded into memory before they can be properly taken out of reset.
Drivers are expected to call
pil_get()when they wish to load a peripheral. This will initiate multiple firmware_request()s for the metadata and image blobs for a peripheral. Once the image has been loaded into memory, it is validated and brought out of reset via the peripheral reset driver.
Quoted 6 lines
Quoted 1 line
Why can't this be part of the generic firmware request API ?
Can you clarify what you mean by this? The firmware request API is used to get the firmware itself, which this code uses. This code is what manages making those calls for the various MSM peripherals that require firmware.
I'm suggesting that you make this part of a generic set of API's .
Quoted 26 lines
Quoted 17 lines
Quoted 17 lines
arch/arm/mach-msm/Kconfig +8
-0@@ -210,4 +210,17 @@ config IOMMU_API config MSM_SCM bool + +config MSM_PIL + bool "Peripheral image loading (PIL)" + select FW_LOADER + select MSM_SCM + depends on ARCH_MSM8X60 + help + Some peripherals need to be loaded into memory before theycan be
Quoted 8 lines
arch/arm/mach-msm/Kconfig config IOMMU_API · line 225
Quoted 5 lines
arch/arm/mach-msm/Kconfig +5
-0+ brought out of reset. + + Say yes to support these devices. + +You shouldn't be adding anything like this to the
Kconfig. To me if you add stuff like this it's a big red flag.
Quoted 1 line
Can you clarify what you mean "stuff like this".
I was commenting on a Kconfig option so "stuff like this" is a Kconfig option like the one I was commenting on.
Quoted 4 lines
It seems to me that this option should be selected by the drivers that need it, since it doesn't make sense to have this if there are no drivers that need it, and it is required when those drivers are included.
You want as few selectable Kconfig options in the mach-msm Kconfig as possible.
Danil
Re: [PATCH 2/3] msm: Peripheral Image Loader (PIL) driver
In reply to Daniel WalkerQuoted 5 lines · Daniel Walker
Quoted 4 lines · Stephen Boyd
On 8660, the modem, dsp, and sensors peripherals require their firmware to be loaded into memory before they can be properly taken out of reset.
Quoted 7 lines
Quoted 5 lines
Drivers are expected to call
pil_get()when they wish to load a peripheral. This will initiate multiple firmware_request()s for the metadata and image blobs for a peripheral. Once the image has been loaded into memory, it is validated and brought out of reset via the peripheral reset driver.Why can't this be part of the generic firmware request API ?
The generic firmware request API gets a blob from userspace. The PIL driver uses this interface to get blobs. The additions here are:
- ref counting, per-name
- peripheral reset sequence, per-name
- configurable loading mechanism, secure vs. non-secure
- common format for retrieving metadata to verify image integrity
Since several peripherals need this exact sequence, it made sense to create a small driver for this functionality.
Quoted 4 lines
Quoted 2 lines
Change-Id: I041139464bbd3b646b82370ab540f40b0ac9af6b
Can't have Change-Id's ..
Dave noted this for the first patch in the series. For subsequent postings, Steve will remove the Change-Ids. Otherwise, Dave said he would remove them prior to adding them to the MSM tree.
Quoted 43 lines
Quoted 34 lines
Reviewed-by Saravana Kannan <[email protected]>Signed-off-by Stephen Boyd <[email protected]>--- arch/arm/mach-msm/Kconfig | 13 + arch/arm/mach-msm/Makefile | 2 + arch/arm/mach-msm/include/mach/peripheral-loader.h | 23 + arch/arm/mach-msm/peripheral-loader.c | 402 +++++++++++++++ arch/arm/mach-msm/peripheral-loader.h | 38 ++ arch/arm/mach-msm/peripheral-reset.c | 528 ++++++++++++++++++++ 6 files changed, 1006 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-msm/include/mach/peripheral-loader.h create mode 100644 arch/arm/mach-msm/peripheral-loader.c create mode 100644 arch/arm/mach-msm/peripheral-loader.h create mode 100644 arch/arm/mach-msm/peripheral-reset.carch/arm/mach-msm/Kconfig +8
-0@@ -210,4 +210,17 @@ config IOMMU_API config MSM_SCM bool + +config MSM_PIL + bool "Peripheral image loading (PIL)" + select FW_LOADER + select MSM_SCM + depends on ARCH_MSM8X60 + help + Some peripherals need to be loaded into memory before theycan be
arch/arm/mach-msm/Kconfig config IOMMU_API · line 225
Quoted 5 lines
arch/arm/mach-msm/Kconfig +5
-0+ brought out of reset. + + Say yes to support these devices. + +You shouldn't be adding anything like this to the
Kconfig. To me if you add stuff like this it's a big red flag.
Quoted 3 lines
I didn't review the rest sign it might be wasted effort on my part..
Daniel
Would you elaborate on your objection here? Should the Kconfig be dropped and the Makefile use 'obj-$(ARCH_MSM8X60)'? That doesn't make sense to me since we already have a 2nd architecture, 8960, that uses PIL. How do you think this should be handled? Thanks.
- Bryan
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 3/3 msm: documentation: Add pil documentation
In reply to Stephen BoydFrom: Saravana Kannan <[email protected]>
--- Documentation/arm/msm/pil.txt | 264 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 264 insertions(+), 0 deletions(-) create mode 100644 Documentation/arm/msm/pil.txt
Documentation/arm/msm/pil.txt new file +264 -0
@@ -0,0 +1,264 @@ +Introduction +============ + +The PIL (Peripheral Image Loader) driver loads peripheral images into memory +and interfaces with the Peripheral Authentication Service (PAS) to +authenticate and reset peripherals embedded in the SoC. + +The PAS could either be running under secure mode in the application +processor (secure boot support) or be running as a non-secure kernel driver +(non-secure boot support). + +The PIL driver also does housekeeping to handle cases where more than one +client driver is using the same peripheral. + +Some examples of peripherals are modem, DSP and sensors. + +Hardware description +==================== + +The memory used by the peripherals for code and data storage will be +accessible as normal memory to the application processor. + +The non-secure code (Linux kernel) will have read/write permissions to the +peripheral memory by default. + +The PAS will have access to a MPU (memory protection unit) that can lock away +the pages of memory from the Linux kernel. It will also have access to +registers that can reset each peripheral. + +Software description +==================== + +The PAS provides the following three APIs: + +* Init image - Takes as input the peripheral id and firmware metadata and + returns a status indicating the authenticity of the firmware metadata. The + firmware metadata consists of a standard ELF32 header followed by a program + header table and an optional blob of data used to authenticate the metadata + and the rest of the firmware. + +* Verify segment - Takes as input the firmware segment id and the length of + the segment. Authenticates whatever amount (specified by the "length" + parameter) of the firmware segment that has been loaded and removes + non-secure mode read/write permissions for the pages belonging to the + firmware segment. Allows multiple calls for the same firmware segment to + allow partial loading and authentication. + +* Auth and Reset - Verifies all the necessary firmware segments have been + loaded and authenticated and then resets the peripheral. + +The user space is expected to provide the firmware metadata and firmware +segments as separate files on persistent storage. See "Interface" section for +further details. + +The PIL driver will use the request_firmware API provided by the Linux kernel +to read the firmware and firmware metadata from persistent storage. + +When a client driver requests for a peripheral to be enabled, the PIL driver +increments the reference count for that peripheral, loads the firmware +metadata and calls the PAS Init Image API that initializes the authentication +state machine using the firmware metadata. + +If the initialization succeeds, the PIL driver loads the appropriate firmware +segments into their respective memory locations and call the PAS Verify +segment API on each of the loaded segments to authenticate and lock it. + +After all the firmware segments have been successfully loaded and +authenticated, the PAS Auth and Reset API is called to reset the peripheral +and initiate its boot sequence. + +A peripheral enable request to the PIL driver will block until it succeeds +(or fails) to initiate the peripheral boot sequence but will NOT block until +the peripheral is ready. It is not possible to block until a peripheral is +ready since the semantics of "ready" is subjective to the caller. + +The PIL driver will maintain a reference count for each of the peripherals. +So, if a peripheral is already under use and another client driver requests +for the peripheral to be enabled, the PIL driver will immediately return a +value to indicate success. + +When all the client drivers of a particular peripheral no longer need the +peripheral and the reference count reaches zero, the PIL driver can cleanly +shut down the peripheral. Since a lot of drivers in their current state can't +handle a peripheral restart, the PIL driver will never let the reference +count go back to zero. + +All information about a peripheral, like firmware filenames, peripheral ID +passed to PAS, etc, will be hard coded in the PIL driver. + +All the PIL APIs will execute in the context of the caller. This includes +calls from the PIL driver to the PAS driver. The PAS driver might decide to +switch into secure mode from a separate workqueue or in the same context as +the caller, but that shouldn't have any implications for the PIL API callers +since all the PIL APIs are blocking calls. + +Dependencies: +------------- +* Firmware class (CONFIG_FW_LOADER) for using the request_firmware API to + load firmware from persistent storage. +* PAS to authenticate firmware and bring a peripheral out of reset. + +Error cases: +------------ +The PIL driver could fail to enable a peripheral for several reasons like not +having enough memory to load firmware and metadata, being unable to +communicate with the PAS, the PAS returning with an error, etc. For all +possible error cases, the PIL driver does not perform any retries and returns +an appropriate error code. The client drivers should always check for success +before trying to access the peripheral. + +Design +====== + +Design goals: +------------- +* The PIL driver must be agnostic to the actual format and method used to + authenticate the firmware. +* Allow for future expansion to support demand loading of parts of firmware + for each peripheral. +* Move most of the work into the preprocessing/building stage of the firmware. +* Provide an API to the client drivers that absolves them from having to know + the structure or names of the firmware in persistent storage. +* Handle multiple client drivers wanting to enable the same peripheral. + + +Design reasons: +--------------- +The user space is expected to provide the firmware metadata and segments as +separate files for the following reasons: +* Don't need to load the whole ELF file if the authentication info is + invalid. +* Works better during low memory conditions since the amount of memory used + at any given instant when loading one segment at a time is smaller than + loading the whole ELF file. +* Since an ELF segment in memory can be much bigger than on file, having a + flat binary would waste a lot of space due to zero-fills. +* Allows for future enhancements to the loading procedure. + +Design tradeoffs: +----------------- +* With appropriate changes to the request_firmware API, the firmware blobs + could be directly loaded into the right memory location. But due to the + additional work and community approval that would be needed for modifying + the request_firmware API, we load the firmware blobs into kernel memory and + then copy them into the appropriate locations. + +Alternate designs: +------------------ +One of the alternate designs that were considered required the firmware to be +a flat binary. Although this design would simplify the PIL driver, it would +result in the waste of a lot of persistent storage space (due to large +zero-fills), prevent demand loading of segments in the future and use a lot +more memory while loading the firmware. + +Software layering: +------------------ +The peripheral authentication, reset and shutdown implementation is factored +away into a Peripheral Authentication Service driver to allow the PIL driver +to be agnostic of secure vs. non-secure boot and the mechanisms needed for +communicating with any code that might be running in secure mode. + +Power Management +================ + +Some of the peripherals might support being turned off when not in use. +Support for this might be disabled in the initial implementation of the PIL +driver since many of the existing drivers can not handle peripheral restart. + +SMP/multi-core +============== + +Will use mutexes to protected data that might be shared (reference count, +etc). + +Security +======== + +The PIL driver must validate the physical memory addresses specified in the +ELF and program header table before loading firmware segments to make sure +it's not overwriting any memory used by the kernel and possibly PMEM regions +(if it can be done without being an ugly hack). The PIL driver might need to +maintain a white list or black list of physical memory address ranges to +perform the address validation. + +Performance +=========== + +As mentioned in the design section, the loading of firmware segments is not +optimal and has room for improvement. + +Interface +========= + +In kernel APIs: +void * pil_get(char *peripheral_name) + - Enables (if not already enabled) a peripheral and returns a handle + that can be used to disable the peripheral at a later time. If + peripheral can't be enabled successfully, then returns an error + (use IS_ERR) indicating the reason. + +void pil_put(void *peripheral_handle) + - Inform PIL that this client no longer needs the peripheral to be + active. Does not necessarily mean that the peripheral would be + disabled or powered off. + + +User space APIs: +All firmware must be located in the path that is expected by the hotplug (or +compatible) daemon. A hotplug (or compatible) daemon should be running and be +able to handle events from the kernel requesting for a firmware file. + +The basename of the firmware files will depend on the peripheral. For a given +peripheral, the metadata filename should end with a ".mdt" and the firmware +segment files should end with ".bXX" where XX denotes the index of the +firmware segment starting from 0. + +Android hotplug compatible daemon expects the firmware files to be under +/etc/firmware. + +Driver parameters +================= + +No module or kernel command line parameters supported. + +Config options +============== + +This driver is enabled using the MSM_PIL kernel config option and will +depend on the CONFIG_FW_LOADER being available. + +Dependencies +============ + +Depends on firmware class module for the request_firmware API. + +Interacts with the PAS to authenticate the firmware and to initiate the boot +sequence of a peripheral. + +Doesn't communicate with other processors since the secure code, if any, will +be running on the application processor cores. + +User space utilities +==================== + +None. + +Other +===== + +The firmware_class driver might be changed in the future to directly load the +firmware into memory locations provided by the caller of request_firmware(). + +Known issues +============ + +None. + +To do +===== + +* Modify request_firmware() to directly copy firmware blobs into the + appropriate memory locations. +* Add support for demand loading of firmware segments. +* Add support for forced peripheral restarts.
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.