summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/boot/dts/qcom/msm8998-v2.dtsi3
-rw-r--r--drivers/clk/qcom/clk-cpu-osm.c113
-rw-r--r--drivers/soc/qcom/spcom.c64
3 files changed, 135 insertions, 45 deletions
diff --git a/arch/arm/boot/dts/qcom/msm8998-v2.dtsi b/arch/arm/boot/dts/qcom/msm8998-v2.dtsi
index 99975877658d..fa7cdd5194a3 100644
--- a/arch/arm/boot/dts/qcom/msm8998-v2.dtsi
+++ b/arch/arm/boot/dts/qcom/msm8998-v2.dtsi
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2017 The Linux Foundation. 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
@@ -298,6 +298,7 @@
&devfreq_memlat_0 {
qcom,core-dev-table =
+ < 300000 1525 >,
< 595200 3143 >,
< 1324800 4173 >,
< 1555200 5859 >,
diff --git a/drivers/clk/qcom/clk-cpu-osm.c b/drivers/clk/qcom/clk-cpu-osm.c
index ab6a1384ffbd..5ed0dba189f7 100644
--- a/drivers/clk/qcom/clk-cpu-osm.c
+++ b/drivers/clk/qcom/clk-cpu-osm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, The Linux Foundation. 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
@@ -88,6 +88,7 @@ enum clk_osm_trace_packet_id {
#define CORE_COUNT_VAL(val) ((val & GENMASK(18, 16)) >> 16)
#define SINGLE_CORE 1
#define MAX_CORE_COUNT 4
+#define DEBUG_REG_NUM 3
#define ENABLE_REG 0x1004
#define INDEX_REG 0x1150
@@ -321,6 +322,13 @@ static struct dentry *osm_debugfs_base;
static struct regulator *vdd_pwrcl;
static struct regulator *vdd_perfcl;
+const char *clk_panic_reg_names[] = {"WDOG_DOMAIN_PSTATE_STATUS",
+ "WDOG_PROGRAM_COUNTER",
+ "APM_STATUS"};
+
+const int clk_panic_reg_offsets[] = {WDOG_DOMAIN_PSTATE_STATUS,
+ WDOG_PROGRAM_COUNTER};
+
static const struct regmap_config osm_qcom_regmap_config = {
.reg_bits = 32,
.reg_stride = 4,
@@ -336,6 +344,7 @@ struct clk_osm {
struct platform_device *vdd_dev;
void *vbases[NUM_BASES];
unsigned long pbases[NUM_BASES];
+ void __iomem *debug_regs[DEBUG_REG_NUM];
spinlock_t lock;
u32 cpu_reg_mask;
@@ -1366,6 +1375,64 @@ static int clk_osm_resources_init(struct platform_device *pdev)
perfcl_clk.acd_init = false;
}
+ pwrcl_clk.debug_regs[0] = devm_ioremap(&pdev->dev,
+ pwrcl_clk.pbases[OSM_BASE] +
+ clk_panic_reg_offsets[0],
+ 0x4);
+ if (!pwrcl_clk.debug_regs[0]) {
+ dev_err(&pdev->dev, "Failed to map %s debug register\n",
+ clk_panic_reg_names[0]);
+ return -ENOMEM;
+ }
+
+ pwrcl_clk.debug_regs[1] = devm_ioremap(&pdev->dev,
+ pwrcl_clk.pbases[OSM_BASE] +
+ clk_panic_reg_offsets[1],
+ 0x4);
+ if (!pwrcl_clk.debug_regs[1]) {
+ dev_err(&pdev->dev, "Failed to map %s debug register\n",
+ clk_panic_reg_names[1]);
+ return -ENOMEM;
+ }
+
+ pwrcl_clk.debug_regs[2] = devm_ioremap(&pdev->dev,
+ pwrcl_clk.apm_ctrl_status,
+ 0x4);
+ if (!pwrcl_clk.debug_regs[2]) {
+ dev_err(&pdev->dev, "Failed to map %s debug register\n",
+ clk_panic_reg_names[2]);
+ return -ENOMEM;
+ };
+
+ perfcl_clk.debug_regs[0] = devm_ioremap(&pdev->dev,
+ perfcl_clk.pbases[OSM_BASE] +
+ clk_panic_reg_offsets[0],
+ 0x4);
+ if (!perfcl_clk.debug_regs[0]) {
+ dev_err(&pdev->dev, "Failed to map %s debug register\n",
+ clk_panic_reg_names[0]);
+ return -ENOMEM;
+ }
+
+ perfcl_clk.debug_regs[1] = devm_ioremap(&pdev->dev,
+ perfcl_clk.pbases[OSM_BASE] +
+ clk_panic_reg_offsets[1],
+ 0x4);
+ if (!perfcl_clk.debug_regs[1]) {
+ dev_err(&pdev->dev, "Failed to map %s debug register\n",
+ clk_panic_reg_names[1]);
+ return -ENOMEM;
+ }
+
+ perfcl_clk.debug_regs[2] = devm_ioremap(&pdev->dev,
+ perfcl_clk.apm_ctrl_status,
+ 0x4);
+ if (!perfcl_clk.debug_regs[2]) {
+ dev_err(&pdev->dev, "Failed to map %s debug register\n",
+ clk_panic_reg_names[2]);
+ return -ENOMEM;
+ };
+
vdd_pwrcl = devm_regulator_get(&pdev->dev, "vdd-pwrcl");
if (IS_ERR(vdd_pwrcl)) {
rc = PTR_ERR(vdd_pwrcl);
@@ -2859,36 +2926,16 @@ static int clk_osm_panic_callback(struct notifier_block *nfb,
unsigned long event,
void *data)
{
- void __iomem *virt_addr;
- u32 value, reg;
+ int i;
+ u32 value;
struct clk_osm *c = container_of(nfb,
struct clk_osm,
panic_notifier);
- reg = c->pbases[OSM_BASE] + WDOG_DOMAIN_PSTATE_STATUS;
- virt_addr = ioremap(reg, 0x4);
- if (virt_addr != NULL) {
- value = readl_relaxed(virt_addr);
- pr_err("DOM%d_PSTATE_STATUS[0x%08x]=0x%08x\n", c->cluster_num,
- reg, value);
- iounmap(virt_addr);
- }
-
- reg = c->pbases[OSM_BASE] + WDOG_PROGRAM_COUNTER;
- virt_addr = ioremap(reg, 0x4);
- if (virt_addr != NULL) {
- value = readl_relaxed(virt_addr);
- pr_err("DOM%d_PROGRAM_COUNTER[0x%08x]=0x%08x\n", c->cluster_num,
- reg, value);
- iounmap(virt_addr);
- }
-
- virt_addr = ioremap(c->apm_ctrl_status, 0x4);
- if (virt_addr != NULL) {
- value = readl_relaxed(virt_addr);
- pr_err("APM_CTLER_STATUS_%d[0x%08x]=0x%08x\n", c->cluster_num,
- c->apm_ctrl_status, value);
- iounmap(virt_addr);
+ for (i = 0; i < DEBUG_REG_NUM; i++) {
+ value = readl_relaxed(c->debug_regs[i]);
+ pr_err("%s_%d=0x%08x\n", clk_panic_reg_names[i],
+ c->cluster_num, value);
}
return NOTIFY_OK;
@@ -3020,17 +3067,17 @@ static int clk_cpu_osm_driver_probe(struct platform_device *pdev)
clk_data->clk_num = num_clks;
- rc = clk_osm_resources_init(pdev);
+ rc = clk_osm_parse_dt_configs(pdev);
if (rc) {
- if (rc != -EPROBE_DEFER)
- dev_err(&pdev->dev, "resources init failed, rc=%d\n",
- rc);
+ dev_err(&pdev->dev, "Unable to parse device tree configurations\n");
return rc;
}
- rc = clk_osm_parse_dt_configs(pdev);
+ rc = clk_osm_resources_init(pdev);
if (rc) {
- dev_err(&pdev->dev, "Unable to parse device tree configurations\n");
+ if (rc != -EPROBE_DEFER)
+ dev_err(&pdev->dev, "resources init failed, rc=%d\n",
+ rc);
return rc;
}
diff --git a/drivers/soc/qcom/spcom.c b/drivers/soc/qcom/spcom.c
index e8ea99827403..9b71083e4f27 100644
--- a/drivers/soc/qcom/spcom.c
+++ b/drivers/soc/qcom/spcom.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, The Linux Foundation. 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
@@ -274,6 +274,8 @@ static int spcom_open(struct spcom_channel *ch, unsigned int timeout_msec);
static int spcom_close(struct spcom_channel *ch);
static void spcom_notify_rx_abort(void *handle, const void *priv,
const void *pkt_priv);
+static struct spcom_channel *spcom_find_channel_by_name(const char *name);
+static int spcom_unlock_ion_buf(struct spcom_channel *ch, int fd);
/**
* spcom_is_ready() - driver is initialized and ready.
@@ -347,6 +349,9 @@ static int spcom_create_predefined_channels_chardev(void)
static void spcom_link_state_notif_cb(struct glink_link_state_cb_info *cb_info,
void *priv)
{
+ struct spcom_channel *ch = NULL;
+ const char *ch_name = "sp_kernel";
+
spcom_dev->link_state = cb_info->link_state;
pr_debug("spcom_link_state_notif_cb called. transport = %s edge = %s\n",
@@ -359,6 +364,17 @@ static void spcom_link_state_notif_cb(struct glink_link_state_cb_info *cb_info,
break;
case GLINK_LINK_STATE_DOWN:
pr_err("GLINK_LINK_STATE_DOWN.\n");
+
+ /*
+ * Free all the SKP ION buffers that were locked
+ * for SPSS app swapping, when remote subsystem reset.
+ */
+ pr_debug("Free all SKP ION buffers on SSR.\n");
+ ch = spcom_find_channel_by_name(ch_name);
+ if (!ch)
+ pr_err("failed to find channel [%s].\n", ch_name);
+ else
+ spcom_unlock_ion_buf(ch, SPCOM_ION_FD_UNLOCK_ALL);
break;
default:
pr_err("unknown link_state [%d].\n", cb_info->link_state);
@@ -1643,24 +1659,18 @@ static int spcom_handle_lock_ion_buf_command(struct spcom_channel *ch,
}
/**
- * spcom_handle_unlock_ion_buf_command() - Unlock an ION buffer.
+ * spcom_unlock_ion_buf() - Unlock an ION buffer.
*
* Unlock an ION buffer, let it be free, when it is no longer being used by
* the remote subsystem.
*/
-static int spcom_handle_unlock_ion_buf_command(struct spcom_channel *ch,
- void *cmd_buf, int size)
+static int spcom_unlock_ion_buf(struct spcom_channel *ch, int fd)
{
- struct spcom_user_command *cmd = cmd_buf;
- int fd = cmd->arg;
struct ion_client *ion_client = spcom_dev->ion_client;
int i;
+ bool found = false;
- if (size != sizeof(*cmd)) {
- pr_err("cmd size [%d] , expected [%d].\n",
- (int) size, (int) sizeof(*cmd));
- return -EINVAL;
- }
+ pr_debug("Unlock ion buf ch [%s] fd [%d].\n", ch->name, fd);
/* Check ION client */
if (ion_client == NULL) {
@@ -1669,6 +1679,8 @@ static int spcom_handle_unlock_ion_buf_command(struct spcom_channel *ch,
}
if (fd == (int) SPCOM_ION_FD_UNLOCK_ALL) {
+ pr_debug("unlocked ALL ion buf ch [%s].\n", ch->name);
+ found = true;
/* unlock all ION buf */
for (i = 0 ; i < ARRAY_SIZE(ch->ion_handle_table) ; i++) {
if (ch->ion_handle_table[i] != NULL) {
@@ -1686,15 +1698,45 @@ static int spcom_handle_unlock_ion_buf_command(struct spcom_channel *ch,
ch->ion_handle_table[i] = NULL;
ch->ion_fd_table[i] = -1;
pr_debug("unlocked ion buf#[%d].\n", i);
+ found = true;
break;
}
}
}
+ if (!found) {
+ pr_err("ch [%s] fd [%d] was not found.\n", ch->name, fd);
+ return -ENODEV;
+ }
+
return 0;
}
/**
+ * spcom_handle_unlock_ion_buf_command() - Unlock an ION buffer.
+ *
+ * Unlock an ION buffer, let it be free, when it is no longer being used by
+ * the remote subsystem.
+ */
+static int spcom_handle_unlock_ion_buf_command(struct spcom_channel *ch,
+ void *cmd_buf, int size)
+{
+ int ret;
+ struct spcom_user_command *cmd = cmd_buf;
+ int fd = cmd->arg;
+
+ if (size != sizeof(*cmd)) {
+ pr_err("cmd size [%d] , expected [%d].\n",
+ (int) size, (int) sizeof(*cmd));
+ return -EINVAL;
+ }
+
+ ret = spcom_unlock_ion_buf(ch, fd);
+
+ return ret;
+}
+
+/**
* spcom_handle_fake_ssr_command() - Handle fake ssr command from user space.
*/
static int spcom_handle_fake_ssr_command(struct spcom_channel *ch, int arg)