msm: pil: Store start address and size of images into IMEM
With relocatable image support there is no easy way to determine
from a ramdump where a particular image was loaded into DDR
without carefully parsing the kernel image and chasing a bunch of
pointers around. Simplify this task by writing the name of the
image and the start address and size of the image to IMEM.
Each record takes up exactly 20 bytes and there are only 10
records allocated. To ensure that we don't overwrite other
records, fail pil_desc_init() if we've already allocated all
available records.
Change-Id: I1e76a30d83bfc97ba418cdab96aa6410884d561b
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/arch/arm/mach-msm/peripheral-loader.c b/arch/arm/mach-msm/peripheral-loader.c
index e3a3563..0b89c75 100644
--- a/arch/arm/mach-msm/peripheral-loader.c
+++ b/arch/arm/mach-msm/peripheral-loader.c
@@ -28,9 +28,13 @@
#include <linux/msm_ion.h>
#include <linux/list.h>
#include <linux/list_sort.h>
+#include <linux/idr.h>
#include <asm/uaccess.h>
#include <asm/setup.h>
+#include <asm-generic/io-64-nonatomic-lo-hi.h>
+
+#include <mach/msm_iomap.h>
#include "peripheral-loader.h"
@@ -39,6 +43,8 @@
#define pil_info(desc, fmt, ...) \
dev_info(desc->dev, "%s: " fmt, desc->name, ##__VA_ARGS__)
+#define PIL_IMAGE_INFO_BASE (MSM_IMEM_BASE + 0x94c)
+
/**
* proxy_timeout - Override for proxy vote timeouts
* -1: Use driver-specified timeout
@@ -80,6 +86,18 @@
};
/**
+ * struct pil_image_info - information in IMEM about image and where it is loaded
+ * @name: name of image (may or may not be NULL terminated)
+ * @start: indicates physical address where image starts (little endian)
+ * @size: size of image (little endian)
+ */
+struct pil_image_info {
+ char name[8];
+ __le64 start;
+ __le32 size;
+} __attribute__((__packed__));
+
+/**
* struct pil_priv - Private state for a pil_desc
* @proxy: work item used to run the proxy unvoting routine
* @wlock: wakelock to prevent suspend during pil_boot
@@ -110,6 +128,8 @@
phys_addr_t region_start;
phys_addr_t region_end;
struct ion_handle *region;
+ struct pil_image_info __iomem *info;
+ int id;
};
static struct ion_client *ion;
@@ -337,6 +357,10 @@
priv->base_addr = min_addr_n;
}
+ writeq(priv->region_start, &priv->info->start);
+ writel_relaxed(priv->region_end - priv->region_start,
+ &priv->info->size);
+
return ret;
}
@@ -380,6 +404,9 @@
struct pil_priv *priv = desc->priv;
struct pil_seg *p, *tmp;
+ writeq(0, &priv->info->start);
+ writel_relaxed(0, &priv->info->size);
+
if (priv->region)
ion_free(ion, priv->region);
priv->region = NULL;
@@ -593,6 +620,8 @@
}
EXPORT_SYMBOL(pil_shutdown);
+static DEFINE_IDA(pil_ida);
+
/**
* pil_desc_init() - Initialize a pil descriptor
* @desc: descriptor to intialize
@@ -605,6 +634,9 @@
int pil_desc_init(struct pil_desc *desc)
{
struct pil_priv *priv;
+ int id;
+ void __iomem *addr;
+ size_t len;
/* Ignore users who don't make any sense */
WARN(desc->ops->proxy_unvote && !desc->proxy_timeout,
@@ -619,6 +651,18 @@
desc->priv = priv;
priv->desc = desc;
+ priv->id = id = ida_simple_get(&pil_ida, 0, 10, GFP_KERNEL);
+ if (id < 0) {
+ kfree(priv);
+ return id;
+ }
+ addr = PIL_IMAGE_INFO_BASE + sizeof(struct pil_image_info) * id;
+ priv->info = (struct pil_image_info __iomem *)addr;
+
+ len = min(strlen(desc->name), sizeof(priv->info->name));
+ memset_io(priv->info->name, 0, sizeof(priv->info->name));
+ memcpy_toio(priv->info->name, desc->name, len);
+
snprintf(priv->wname, sizeof(priv->wname), "pil-%s", desc->name);
wake_lock_init(&priv->wlock, WAKE_LOCK_SUSPEND, priv->wname);
INIT_DELAYED_WORK(&priv->proxy, pil_proxy_work);
@@ -637,6 +681,7 @@
struct pil_priv *priv = desc->priv;
if (priv) {
+ ida_simple_remove(&pil_ida, priv->id);
flush_delayed_work(&priv->proxy);
wake_lock_destroy(&priv->wlock);
}