aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSricharan R <sricharan@codeaurora.org>2016-01-27 18:21:34 +0530
committerSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2016-02-29 14:53:31 +0000
commitda397b817fc30708594c14e5cd489cefdaec54dd (patch)
treeade0a8896feed0b62b99167741734b351c2608e1
parenta1bbe4c8d24743e9cf91ea89cc950fe2cc579da8 (diff)
drivers: soc: qcom: Remove smem and ssr support from glink xprt
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
-rw-r--r--drivers/soc/qcom/glink_smem_native_xprt.c765
1 files changed, 3 insertions, 762 deletions
diff --git a/drivers/soc/qcom/glink_smem_native_xprt.c b/drivers/soc/qcom/glink_smem_native_xprt.c
index b3f19121abfe9..2a2b8864388dc 100644
--- a/drivers/soc/qcom/glink_smem_native_xprt.c
+++ b/drivers/soc/qcom/glink_smem_native_xprt.c
@@ -33,7 +33,6 @@
#include <linux/spinlock.h>
#include <linux/srcu.h>
#include <linux/wait.h>
-#include <soc/qcom/smem.h>
#include <soc/qcom/tracer_pkt.h>
#include "glink_core_if.h"
#include "glink_private.h"
@@ -43,7 +42,6 @@
#define FIFO_FULL_RESERVE 8
#define FIFO_ALIGNMENT 8
#define TX_BLOCKED_CMD_RESERVE 8 /* size of struct read_notif_request */
-#define SMEM_CH_DESC_SIZE 32
#define RPM_TOC_ID 0x67727430
#define RPM_TX_FIFO_ID 0x61703272
#define RPM_RX_FIFO_ID 0x72326170
@@ -111,26 +109,6 @@ struct channel_desc {
};
/**
- * struct mailbox_config_info - description of a mailbox tranposrt channel
- * @tx_read_index: Offset into the tx fifo where data should be read from.
- * @tx_write_index: Offset into the tx fifo where new data will be placed.
- * @tx_size: Size of the transmit fifo in bytes.
- * @rx_read_index: Offset into the rx fifo where data should be read from.
- * @rx_write_index: Offset into the rx fifo where new data will be placed.
- * @rx_size: Size of the receive fifo in bytes.
- * @fifo: The fifos for the channel.
- */
-struct mailbox_config_info {
- uint32_t tx_read_index;
- uint32_t tx_write_index;
- uint32_t tx_size;
- uint32_t rx_read_index;
- uint32_t rx_write_index;
- uint32_t rx_size;
- char fifo[]; /* tx fifo, then rx fifo */
-};
-
-/**
* struct edge_info - local information for managing a single complete edge
* @xprt_if: The transport interface registered with the
* glink core associated with this edge.
@@ -139,7 +117,6 @@ struct mailbox_config_info {
* @intentless: True if this edge runs in intentless mode.
* @irq_disabled: Flag indicating the whether interrupt is enabled
* or disabled.
- * @remote_proc_id: The SMEM processor id for the remote side.
* @rx_reset_reg: Reference to the register to reset the rx irq
* line, if applicable.
* @out_irq_reg: Reference to the register to send an irq to the
@@ -173,7 +150,6 @@ struct mailbox_config_info {
* @task: Handle to the task context used to run @kworker.
* @use_ref: Active uses of this transport use this to grab
* a reference. Used for ssr synchronization.
- * @in_ssr: Signals if this transport is in ssr.
* @rx_lock: Used to serialize concurrent instances of rx
* processing.
* @deferred_cmds: List of deferred commands that need to be
@@ -181,14 +157,12 @@ struct mailbox_config_info {
* @num_pw_states: Size of @ramp_time_us.
* @ramp_time_us: Array of ramp times in microseconds where array
* index position represents a power state.
- * @mailbox: Mailbox transport channel description reference.
*/
struct edge_info {
struct glink_transport_if xprt_if;
struct glink_core_transport_cfg xprt_cfg;
bool intentless;
bool irq_disabled;
- uint32_t remote_proc_id;
void __iomem *rx_reset_reg;
void __iomem *out_irq_reg;
uint32_t out_irq_mask;
@@ -211,12 +185,10 @@ struct edge_info {
struct kthread_worker kworker;
struct task_struct *task;
struct srcu_struct use_ref;
- bool in_ssr;
spinlock_t rx_lock;
struct list_head deferred_cmds;
uint32_t num_pw_states;
unsigned long *ramp_time_us;
- struct mailbox_config_info *mailbox;
};
/**
@@ -243,7 +215,6 @@ static uint32_t negotiate_features_v1(struct glink_transport_if *if_ptr,
uint32_t features);
static void register_debugfs_info(struct edge_info *einfo);
-static struct edge_info *edge_infos[NUM_SMEM_SUBSYSTEMS];
static DEFINE_MUTEX(probe_lock);
static struct glink_core_version versions[] = {
{1, TRACER_PKT_FEATURE, negotiate_features_v1},
@@ -265,34 +236,6 @@ static void send_irq(struct edge_info *einfo)
}
/**
- * read_from_fifo() - memcpy from fifo memory
- * @dest: Destination address.
- * @src: Source address.
- * @num_bytes: Number of bytes to copy.
- *
- * Return: Destination address.
- */
-static void *read_from_fifo(void *dest, const void *src, size_t num_bytes)
-{
- memcpy_fromio(dest, src, num_bytes);
- return dest;
-}
-
-/**
- * write_to_fifo() - memcpy to fifo memory
- * @dest: Destination address.
- * @src: Source address.
- * @num_bytes: Number of bytes to copy.
- *
- * Return: Destination address.
- */
-static void *write_to_fifo(void *dest, const void *src, size_t num_bytes)
-{
- memcpy_toio(dest, src, num_bytes);
- return dest;
-}
-
-/**
* memcpy32_toio() - memcpy to word access only memory
* @dest: Destination address.
* @src: Source address.
@@ -313,7 +256,7 @@ static void *memcpy32_toio(void *dest, const void *src, size_t num_bytes)
num_bytes /= sizeof(uint32_t);
while (num_bytes--)
- __raw_writel_no_log(*src_local++, dest_local++);
+ __raw_writel(*src_local++, dest_local++);
return dest;
}
@@ -339,7 +282,7 @@ static void *memcpy32_fromio(void *dest, const void *src, size_t num_bytes)
num_bytes /= sizeof(uint32_t);
while (num_bytes--)
- *dest_local++ = __raw_readl_no_log(src_local++);
+ *dest_local++ = __raw_readl(src_local++);
return dest;
}
@@ -626,14 +569,10 @@ static int fifo_tx(struct edge_info *einfo, const void *data, int len)
spin_unlock_irqrestore(&einfo->write_lock, flags);
prepare_to_wait(&einfo->tx_blocked_queue, &wait,
TASK_UNINTERRUPTIBLE);
- if (fifo_write_avail(einfo) < len && !einfo->in_ssr)
+ if (fifo_write_avail(einfo) < len)
schedule();
finish_wait(&einfo->tx_blocked_queue, &wait);
spin_lock_irqsave(&einfo->write_lock, flags);
- if (einfo->in_ssr) {
- spin_unlock_irqrestore(&einfo->write_lock, flags);
- return -EFAULT;
- }
}
ret = fifo_write(einfo, data, len);
spin_unlock_irqrestore(&einfo->write_lock, flags);
@@ -776,18 +715,6 @@ static bool queue_cmd(struct edge_info *einfo, void *cmd, void *data)
*/
static bool get_rx_fifo(struct edge_info *einfo)
{
- if (einfo->mailbox) {
- einfo->rx_fifo = &einfo->mailbox->fifo[einfo->mailbox->tx_size];
- einfo->rx_fifo_size = einfo->mailbox->rx_size;
- } else {
- einfo->rx_fifo = smem_get_entry(SMEM_GLINK_NATIVE_XPRT_FIFO_1,
- &einfo->rx_fifo_size,
- einfo->remote_proc_id,
- SMEM_ITEM_CACHED_FLAG);
- if (!einfo->rx_fifo)
- return false;
- }
-
return true;
}
@@ -831,14 +758,9 @@ static void __rx_worker(struct edge_info *einfo, bool atomic_ctx)
srcu_read_unlock(&einfo->use_ref, rcu_id);
return;
}
- einfo->in_ssr = false;
einfo->xprt_if.glink_core_if_ptr->link_up(&einfo->xprt_if);
}
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return;
- }
if (!atomic_ctx) {
if (einfo->tx_resume_needed && fifo_write_avail(einfo)) {
einfo->tx_resume_needed = false;
@@ -870,8 +792,6 @@ static void __rx_worker(struct edge_info *einfo, bool atomic_ctx)
spin_lock_irqsave(&einfo->rx_lock, flags);
while (fifo_read_avail(einfo) ||
(!atomic_ctx && !list_empty(&einfo->deferred_cmds))) {
- if (einfo->in_ssr)
- break;
if (!atomic_ctx && !list_empty(&einfo->deferred_cmds)) {
d_cmd = list_first_entry(&einfo->deferred_cmds,
@@ -1190,10 +1110,6 @@ static void tx_cmd_version(struct glink_transport_if *if_ptr, uint32_t version,
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return;
- }
cmd.id = VERSION_CMD;
cmd.version = version;
@@ -1225,10 +1141,6 @@ static void tx_cmd_version_ack(struct glink_transport_if *if_ptr,
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return;
- }
cmd.id = VERSION_ACK_CMD;
cmd.version = version;
@@ -1256,10 +1168,6 @@ static uint32_t set_version(struct glink_transport_if *if_ptr, uint32_t version,
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return 0;
- }
ret = einfo->intentless ?
GCAP_INTENTLESS | GCAP_SIGNALS : GCAP_SIGNALS;
@@ -1297,10 +1205,6 @@ static int tx_cmd_ch_open(struct glink_transport_if *if_ptr, uint32_t lcid,
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return -EFAULT;
- }
cmd.id = OPEN_CMD;
cmd.lcid = lcid;
@@ -1347,10 +1251,6 @@ static int tx_cmd_ch_close(struct glink_transport_if *if_ptr, uint32_t lcid)
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return -EFAULT;
- }
cmd.id = CLOSE_CMD;
cmd.lcid = lcid;
@@ -1384,10 +1284,6 @@ static void tx_cmd_ch_remote_open_ack(struct glink_transport_if *if_ptr,
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return;
- }
cmd.id = OPEN_ACK_CMD;
cmd.rcid = rcid;
@@ -1418,10 +1314,6 @@ static void tx_cmd_ch_remote_close_ack(struct glink_transport_if *if_ptr,
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return;
- }
cmd.id = CLOSE_ACK_CMD;
cmd.rcid = rcid;
@@ -1432,45 +1324,6 @@ static void tx_cmd_ch_remote_close_ack(struct glink_transport_if *if_ptr,
}
/**
- * ssr() - process a subsystem restart notification of a transport
- * @if_ptr: The transport to restart
- *
- * Return: 0 on success or standard Linux error code.
- */
-static int ssr(struct glink_transport_if *if_ptr)
-{
- struct edge_info *einfo;
- struct deferred_cmd *cmd;
-
- einfo = container_of(if_ptr, struct edge_info, xprt_if);
-
- BUG_ON(einfo->remote_proc_id == SMEM_RPM);
-
- einfo->in_ssr = true;
- wake_up_all(&einfo->tx_blocked_queue);
-
- synchronize_srcu(&einfo->use_ref);
-
- while (!list_empty(&einfo->deferred_cmds)) {
- cmd = list_first_entry(&einfo->deferred_cmds,
- struct deferred_cmd, list_node);
- list_del(&cmd->list_node);
- kfree(cmd->data);
- kfree(cmd);
- }
-
- einfo->tx_resume_needed = false;
- einfo->tx_blocked_signal_sent = false;
- einfo->rx_fifo = NULL;
- einfo->rx_fifo_size = 0;
- einfo->tx_ch_desc->write_index = 0;
- einfo->rx_ch_desc->read_index = 0;
- einfo->xprt_if.glink_core_if_ptr->link_down(&einfo->xprt_if);
-
- return 0;
-}
-
-/**
* int wait_link_down() - Check status of read/write indices
* @if_ptr: The transport to check
*
@@ -1576,10 +1429,6 @@ static int tx_cmd_local_rx_intent(struct glink_transport_if *if_ptr,
return -EOPNOTSUPP;
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return -EFAULT;
- }
cmd.id = RX_INTENT_CMD;
cmd.lcid = lcid;
@@ -1618,10 +1467,6 @@ static void tx_cmd_local_rx_done(struct glink_transport_if *if_ptr,
return;
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return;
- }
cmd.id = reuse ? RX_DONE_W_REUSE_CMD : RX_DONE_CMD;
cmd.lcid = lcid;
@@ -1663,10 +1508,6 @@ static int tx_cmd_rx_intent_req(struct glink_transport_if *if_ptr,
return -EOPNOTSUPP;
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return -EFAULT;
- }
cmd.id = RX_INTENT_REQ_CMD,
cmd.lcid = lcid;
@@ -1705,10 +1546,6 @@ static int tx_cmd_remote_rx_intent_req_ack(struct glink_transport_if *if_ptr,
return -EOPNOTSUPP;
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return -EFAULT;
- }
cmd.id = RX_INTENT_REQ_ACK_CMD,
cmd.lcid = lcid;
@@ -1746,10 +1583,6 @@ static int tx_cmd_set_sigs(struct glink_transport_if *if_ptr, uint32_t lcid,
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return -EFAULT;
- }
cmd.id = SIGNALS_CMD,
cmd.lcid = lcid;
@@ -1776,10 +1609,6 @@ static int poll(struct glink_transport_if *if_ptr, uint32_t lcid)
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return -EFAULT;
- }
if (fifo_read_avail(einfo)) {
__rx_worker(einfo, true);
@@ -1811,10 +1640,6 @@ static int mask_rx_irq(struct glink_transport_if *if_ptr, uint32_t lcid,
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return -EFAULT;
- }
irq_chip = irq_get_chip(einfo->irq_line);
if (!irq_chip) {
@@ -1882,10 +1707,6 @@ static int tx_data(struct glink_transport_if *if_ptr, uint16_t cmd_id,
einfo = container_of(if_ptr, struct edge_info, xprt_if);
rcu_id = srcu_read_lock(&einfo->use_ref);
- if (einfo->in_ssr) {
- srcu_read_unlock(&einfo->use_ref, rcu_id);
- return -EFAULT;
- }
if (einfo->intentless &&
(pctx->size_remaining != pctx->size || cmd_id == TRACER_PKT_CMD)) {
@@ -2063,7 +1884,6 @@ static void init_xprt_if(struct edge_info *einfo)
einfo->xprt_if.tx_cmd_ch_close = tx_cmd_ch_close;
einfo->xprt_if.tx_cmd_ch_remote_open_ack = tx_cmd_ch_remote_open_ack;
einfo->xprt_if.tx_cmd_ch_remote_close_ack = tx_cmd_ch_remote_close_ack;
- einfo->xprt_if.ssr = ssr;
einfo->xprt_if.allocate_rx_intent = allocate_rx_intent;
einfo->xprt_if.deallocate_rx_intent = deallocate_rx_intent;
einfo->xprt_if.tx_cmd_local_rx_intent = tx_cmd_local_rx_intent;
@@ -2097,266 +1917,6 @@ static void init_xprt_cfg(struct edge_info *einfo, const char *name)
einfo->xprt_cfg.max_iid = SZ_2G;
}
-/**
- * parse_qos_dt_params() - Parse the power states from DT
- * @dev: Reference to the platform device for a specific edge.
- * @einfo: Edge information for the edge probe function is called.
- *
- * Return: 0 on success, standard error code otherwise.
- */
-static int parse_qos_dt_params(struct device_node *node,
- struct edge_info *einfo)
-{
- int rc;
- int i;
- char *key;
- uint32_t *arr32;
- uint32_t num_states;
-
- key = "qcom,ramp-time";
- if (!of_find_property(node, key, &num_states))
- return -ENODEV;
-
- num_states /= sizeof(uint32_t);
-
- einfo->num_pw_states = num_states;
-
- arr32 = kmalloc_array(num_states, sizeof(uint32_t), GFP_KERNEL);
- if (!arr32)
- return -ENOMEM;
-
- einfo->ramp_time_us = kmalloc_array(num_states, sizeof(unsigned long),
- GFP_KERNEL);
- if (!einfo->ramp_time_us) {
- rc = -ENOMEM;
- goto mem_alloc_fail;
- }
-
- rc = of_property_read_u32_array(node, key, arr32, num_states);
- if (rc) {
- rc = -ENODEV;
- goto invalid_key;
- }
- for (i = 0; i < num_states; i++)
- einfo->ramp_time_us[i] = arr32[i];
-
- rc = 0;
- return rc;
-
-invalid_key:
- kfree(einfo->ramp_time_us);
-mem_alloc_fail:
- kfree(arr32);
- return rc;
-}
-
-/**
- * subsys_name_to_id() - translate a subsystem name to a processor id
- * @name: The subsystem name to look up.
- *
- * Return: The processor id corresponding to @name or standard Linux error code.
- */
-static int subsys_name_to_id(const char *name)
-{
- if (!name)
- return -ENODEV;
-
- if (!strcmp(name, "apss"))
- return SMEM_APPS;
- if (!strcmp(name, "dsps"))
- return SMEM_DSPS;
- if (!strcmp(name, "lpass"))
- return SMEM_Q6;
- if (!strcmp(name, "mpss"))
- return SMEM_MODEM;
- if (!strcmp(name, "rpm"))
- return SMEM_RPM;
- if (!strcmp(name, "wcnss"))
- return SMEM_WCNSS;
- if (!strcmp(name, "spss"))
- return SMEM_SPSS;
- return -ENODEV;
-}
-
-static int glink_smem_native_probe(struct platform_device *pdev)
-{
- struct device_node *node;
- struct device_node *phandle_node;
- struct edge_info *einfo;
- int rc;
- char *key;
- const char *subsys_name;
- uint32_t irq_line;
- uint32_t irq_mask;
- struct resource *r;
-
- node = pdev->dev.of_node;
-
- einfo = kzalloc(sizeof(*einfo), GFP_KERNEL);
- if (!einfo) {
- pr_err("%s: edge_info allocation failed\n", __func__);
- rc = -ENOMEM;
- goto edge_info_alloc_fail;
- }
-
- key = "label";
- subsys_name = of_get_property(node, key, NULL);
- if (!subsys_name) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "interrupts";
- irq_line = irq_of_parse_and_map(node, 0);
- if (!irq_line) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "qcom,irq-mask";
- rc = of_property_read_u32(node, key, &irq_mask);
- if (rc) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "irq-reg-base";
- r = platform_get_resource_byname(pdev, IORESOURCE_MEM, key);
- if (!r) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- if (subsys_name_to_id(subsys_name) == -ENODEV) {
- pr_err("%s: unknown subsystem: %s\n", __func__, subsys_name);
- rc = -ENODEV;
- goto invalid_key;
- }
- einfo->remote_proc_id = subsys_name_to_id(subsys_name);
-
- init_xprt_cfg(einfo, subsys_name);
- init_xprt_if(einfo);
- spin_lock_init(&einfo->write_lock);
- init_waitqueue_head(&einfo->tx_blocked_queue);
- init_kthread_work(&einfo->kwork, rx_worker);
- init_kthread_worker(&einfo->kworker);
- einfo->read_from_fifo = read_from_fifo;
- einfo->write_to_fifo = write_to_fifo;
- init_srcu_struct(&einfo->use_ref);
- spin_lock_init(&einfo->rx_lock);
- INIT_LIST_HEAD(&einfo->deferred_cmds);
-
- mutex_lock(&probe_lock);
- if (edge_infos[einfo->remote_proc_id]) {
- pr_err("%s: duplicate subsys %s is not valid\n", __func__,
- subsys_name);
- rc = -ENODEV;
- mutex_unlock(&probe_lock);
- goto invalid_key;
- }
- edge_infos[einfo->remote_proc_id] = einfo;
- mutex_unlock(&probe_lock);
-
- einfo->out_irq_mask = irq_mask;
- einfo->out_irq_reg = ioremap_nocache(r->start, resource_size(r));
- if (!einfo->out_irq_reg) {
- pr_err("%s: unable to map irq reg\n", __func__);
- rc = -ENOMEM;
- goto ioremap_fail;
- }
-
- einfo->task = kthread_run(kthread_worker_fn, &einfo->kworker,
- "smem_native_%s", subsys_name);
- if (IS_ERR(einfo->task)) {
- rc = PTR_ERR(einfo->task);
- pr_err("%s: kthread_run failed %d\n", __func__, rc);
- goto kthread_fail;
- }
-
- einfo->tx_ch_desc = smem_alloc(SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR,
- SMEM_CH_DESC_SIZE,
- einfo->remote_proc_id,
- 0);
- if (PTR_ERR(einfo->tx_ch_desc) == -EPROBE_DEFER) {
- rc = -EPROBE_DEFER;
- goto smem_alloc_fail;
- }
- if (!einfo->tx_ch_desc) {
- pr_err("%s: smem alloc of ch descriptor failed\n", __func__);
- rc = -ENOMEM;
- goto smem_alloc_fail;
- }
- einfo->rx_ch_desc = einfo->tx_ch_desc + 1;
-
- einfo->tx_fifo_size = SZ_16K;
- einfo->tx_fifo = smem_alloc(SMEM_GLINK_NATIVE_XPRT_FIFO_0,
- einfo->tx_fifo_size,
- einfo->remote_proc_id,
- SMEM_ITEM_CACHED_FLAG);
- if (!einfo->tx_fifo) {
- pr_err("%s: smem alloc of tx fifo failed\n", __func__);
- rc = -ENOMEM;
- goto smem_alloc_fail;
- }
-
- key = "qcom,qos-config";
- phandle_node = of_parse_phandle(node, key, 0);
- if (phandle_node && !(of_get_glink_core_qos_cfg(phandle_node,
- &einfo->xprt_cfg)))
- parse_qos_dt_params(node, einfo);
-
- rc = glink_core_register_transport(&einfo->xprt_if, &einfo->xprt_cfg);
- if (rc == -EPROBE_DEFER)
- goto reg_xprt_fail;
- if (rc) {
- pr_err("%s: glink core register transport failed: %d\n",
- __func__, rc);
- goto reg_xprt_fail;
- }
-
- einfo->irq_line = irq_line;
- rc = request_irq(irq_line, irq_handler,
- IRQF_TRIGGER_RISING | IRQF_NO_SUSPEND | IRQF_SHARED,
- node->name, einfo);
- if (rc < 0) {
- pr_err("%s: request_irq on %d failed: %d\n", __func__, irq_line,
- rc);
- goto request_irq_fail;
- }
- rc = enable_irq_wake(irq_line);
- if (rc < 0)
- pr_err("%s: enable_irq_wake() failed on %d\n", __func__,
- irq_line);
-
- register_debugfs_info(einfo);
- /* fake an interrupt on this edge to see if the remote side is up */
- irq_handler(0, einfo);
- return 0;
-
-request_irq_fail:
- glink_core_unregister_transport(&einfo->xprt_if);
-reg_xprt_fail:
-smem_alloc_fail:
- flush_kthread_worker(&einfo->kworker);
- kthread_stop(einfo->task);
- einfo->task = NULL;
-kthread_fail:
- iounmap(einfo->out_irq_reg);
-ioremap_fail:
- mutex_lock(&probe_lock);
- edge_infos[einfo->remote_proc_id] = NULL;
- mutex_unlock(&probe_lock);
-invalid_key:
-missing_key:
- kfree(einfo);
-edge_info_alloc_fail:
- return rc;
-}
-
static int glink_rpm_native_probe(struct platform_device *pdev)
{
struct device_node *node;
@@ -2416,13 +1976,6 @@ static int glink_rpm_native_probe(struct platform_device *pdev)
goto missing_key;
}
- if (subsys_name_to_id(subsys_name) == -ENODEV) {
- pr_err("%s: unknown subsystem: %s\n", __func__, subsys_name);
- rc = -ENODEV;
- goto invalid_key;
- }
- einfo->remote_proc_id = subsys_name_to_id(subsys_name);
-
init_xprt_cfg(einfo, subsys_name);
init_xprt_if(einfo);
spin_lock_init(&einfo->write_lock);
@@ -2436,17 +1989,6 @@ static int glink_rpm_native_probe(struct platform_device *pdev)
spin_lock_init(&einfo->rx_lock);
INIT_LIST_HEAD(&einfo->deferred_cmds);
- mutex_lock(&probe_lock);
- if (edge_infos[einfo->remote_proc_id]) {
- pr_err("%s: duplicate subsys %s is not valid\n", __func__,
- subsys_name);
- rc = -ENODEV;
- mutex_unlock(&probe_lock);
- goto invalid_key;
- }
- edge_infos[einfo->remote_proc_id] = einfo;
- mutex_unlock(&probe_lock);
-
einfo->out_irq_mask = irq_mask;
einfo->out_irq_reg = ioremap_nocache(irq_r->start,
resource_size(irq_r));
@@ -2595,263 +2137,6 @@ kthread_fail:
msgram_ioremap_fail:
iounmap(einfo->out_irq_reg);
irq_ioremap_fail:
- mutex_lock(&probe_lock);
- edge_infos[einfo->remote_proc_id] = NULL;
- mutex_unlock(&probe_lock);
-invalid_key:
-missing_key:
- kfree(einfo);
-edge_info_alloc_fail:
- return rc;
-}
-
-static int glink_mailbox_probe(struct platform_device *pdev)
-{
- struct device_node *node;
- struct edge_info *einfo;
- int rc;
- char *key;
- const char *subsys_name;
- uint32_t irq_line;
- uint32_t irq_mask;
- struct resource *irq_r;
- struct resource *mbox_loc_r;
- struct resource *mbox_size_r;
- struct resource *rx_reset_r;
- void *mbox_loc;
- void *mbox_size;
- struct mailbox_config_info *mbox_cfg;
- uint32_t mbox_cfg_size;
- phys_addr_t cfg_p_addr;
-
- node = pdev->dev.of_node;
-
- einfo = kzalloc(sizeof(*einfo), GFP_KERNEL);
- if (!einfo) {
- rc = -ENOMEM;
- goto edge_info_alloc_fail;
- }
-
- key = "label";
- subsys_name = of_get_property(node, key, NULL);
- if (!subsys_name) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "interrupts";
- irq_line = irq_of_parse_and_map(node, 0);
- if (!irq_line) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "qcom,irq-mask";
- rc = of_property_read_u32(node, key, &irq_mask);
- if (rc) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "irq-reg-base";
- irq_r = platform_get_resource_byname(pdev, IORESOURCE_MEM, key);
- if (!irq_r) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "mbox-loc-addr";
- mbox_loc_r = platform_get_resource_byname(pdev, IORESOURCE_MEM, key);
- if (!mbox_loc_r) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "mbox-loc-size";
- mbox_size_r = platform_get_resource_byname(pdev, IORESOURCE_MEM, key);
- if (!mbox_size_r) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "irq-rx-reset";
- rx_reset_r = platform_get_resource_byname(pdev, IORESOURCE_MEM, key);
- if (!irq_r) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "qcom,tx-ring-size";
- rc = of_property_read_u32(node, key, &einfo->tx_fifo_size);
- if (rc) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- key = "qcom,rx-ring-size";
- rc = of_property_read_u32(node, key, &einfo->rx_fifo_size);
- if (rc) {
- pr_err("%s: missing key %s\n", __func__, key);
- rc = -ENODEV;
- goto missing_key;
- }
-
- if (subsys_name_to_id(subsys_name) == -ENODEV) {
- pr_err("%s: unknown subsystem: %s\n", __func__, subsys_name);
- rc = -ENODEV;
- goto invalid_key;
- }
- einfo->remote_proc_id = subsys_name_to_id(subsys_name);
-
- init_xprt_cfg(einfo, subsys_name);
- einfo->xprt_cfg.name = "mailbox";
- init_xprt_if(einfo);
- spin_lock_init(&einfo->write_lock);
- init_waitqueue_head(&einfo->tx_blocked_queue);
- init_kthread_work(&einfo->kwork, rx_worker);
- init_kthread_worker(&einfo->kworker);
- einfo->read_from_fifo = read_from_fifo;
- einfo->write_to_fifo = write_to_fifo;
- init_srcu_struct(&einfo->use_ref);
- spin_lock_init(&einfo->rx_lock);
- INIT_LIST_HEAD(&einfo->deferred_cmds);
-
- mutex_lock(&probe_lock);
- if (edge_infos[einfo->remote_proc_id]) {
- pr_err("%s: duplicate subsys %s is not valid\n", __func__,
- subsys_name);
- rc = -ENODEV;
- mutex_unlock(&probe_lock);
- goto invalid_key;
- }
- edge_infos[einfo->remote_proc_id] = einfo;
- mutex_unlock(&probe_lock);
-
- einfo->out_irq_mask = irq_mask;
- einfo->out_irq_reg = ioremap_nocache(irq_r->start,
- resource_size(irq_r));
- if (!einfo->out_irq_reg) {
- pr_err("%s: unable to map irq reg\n", __func__);
- rc = -ENOMEM;
- goto irq_ioremap_fail;
- }
-
- mbox_loc = ioremap_nocache(mbox_loc_r->start,
- resource_size(mbox_loc_r));
- if (!mbox_loc) {
- pr_err("%s: unable to map mailbox location reg\n", __func__);
- rc = -ENOMEM;
- goto mbox_loc_ioremap_fail;
- }
-
- mbox_size = ioremap_nocache(mbox_size_r->start,
- resource_size(mbox_size_r));
- if (!mbox_size) {
- pr_err("%s: unable to map mailbox size reg\n", __func__);
- rc = -ENOMEM;
- goto mbox_size_ioremap_fail;
- }
-
- einfo->rx_reset_reg = ioremap_nocache(rx_reset_r->start,
- resource_size(rx_reset_r));
- if (!einfo->rx_reset_reg) {
- pr_err("%s: unable to map rx reset reg\n", __func__);
- rc = -ENOMEM;
- goto rx_reset_ioremap_fail;
- }
-
- einfo->task = kthread_run(kthread_worker_fn, &einfo->kworker,
- "smem_native_%s", subsys_name);
- if (IS_ERR(einfo->task)) {
- rc = PTR_ERR(einfo->task);
- pr_err("%s: kthread_run failed %d\n", __func__, rc);
- goto kthread_fail;
- }
-
- mbox_cfg_size = sizeof(*mbox_cfg) + einfo->tx_fifo_size +
- einfo->rx_fifo_size;
- mbox_cfg = smem_alloc(SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR,
- mbox_cfg_size,
- einfo->remote_proc_id,
- 0);
- if (PTR_ERR(mbox_cfg) == -EPROBE_DEFER) {
- rc = -EPROBE_DEFER;
- goto smem_alloc_fail;
- }
- if (!mbox_cfg) {
- pr_err("%s: smem alloc of mailbox struct failed\n", __func__);
- rc = -ENOMEM;
- goto smem_alloc_fail;
- }
- einfo->mailbox = mbox_cfg;
- einfo->tx_ch_desc = (struct channel_desc *)(&mbox_cfg->tx_read_index);
- einfo->rx_ch_desc = (struct channel_desc *)(&mbox_cfg->rx_read_index);
- mbox_cfg->tx_size = einfo->tx_fifo_size;
- mbox_cfg->rx_size = einfo->rx_fifo_size;
- einfo->tx_fifo = &mbox_cfg->fifo[0];
-
- rc = glink_core_register_transport(&einfo->xprt_if, &einfo->xprt_cfg);
- if (rc == -EPROBE_DEFER)
- goto reg_xprt_fail;
- if (rc) {
- pr_err("%s: glink core register transport failed: %d\n",
- __func__, rc);
- goto reg_xprt_fail;
- }
-
- einfo->irq_line = irq_line;
- rc = request_irq(irq_line, irq_handler,
- IRQF_TRIGGER_HIGH | IRQF_NO_SUSPEND | IRQF_SHARED,
- node->name, einfo);
- if (rc < 0) {
- pr_err("%s: request_irq on %d failed: %d\n", __func__, irq_line,
- rc);
- goto request_irq_fail;
- }
- rc = enable_irq_wake(irq_line);
- if (rc < 0)
- pr_err("%s: enable_irq_wake() failed on %d\n", __func__,
- irq_line);
-
- register_debugfs_info(einfo);
-
- writel_relaxed(mbox_cfg_size, mbox_size);
- cfg_p_addr = smem_virt_to_phys(mbox_cfg);
- writel_relaxed(lower_32_bits(cfg_p_addr), mbox_loc);
- writel_relaxed(upper_32_bits(cfg_p_addr), mbox_loc + 4);
- send_irq(einfo);
- iounmap(mbox_size);
- iounmap(mbox_loc);
- return 0;
-
-request_irq_fail:
- glink_core_unregister_transport(&einfo->xprt_if);
-reg_xprt_fail:
-smem_alloc_fail:
- flush_kthread_worker(&einfo->kworker);
- kthread_stop(einfo->task);
- einfo->task = NULL;
-kthread_fail:
- iounmap(einfo->rx_reset_reg);
-rx_reset_ioremap_fail:
- iounmap(mbox_size);
-mbox_size_ioremap_fail:
- iounmap(mbox_loc);
-mbox_loc_ioremap_fail:
- iounmap(einfo->out_irq_reg);
-irq_ioremap_fail:
- mutex_lock(&probe_lock);
- edge_infos[einfo->remote_proc_id] = NULL;
- mutex_unlock(&probe_lock);
-invalid_key:
missing_key:
kfree(einfo);
edge_info_alloc_fail:
@@ -2898,8 +2183,6 @@ ID|EDGE |TX READ |TX WRITE |TX SIZE |RX READ |RX WRITE |RX SIZE
if (!einfo)
return;
- seq_printf(s, "%02i|%-10s|", einfo->remote_proc_id,
- einfo->xprt_cfg.edge);
if (!einfo->rx_fifo)
seq_puts(s, "Link Not Up\n");
else
@@ -2953,20 +2236,6 @@ static void register_debugfs_info(struct edge_info *einfo)
}
#endif /* CONFIG_DEBUG_FS */
-static struct of_device_id smem_match_table[] = {
- { .compatible = "qcom,glink-smem-native-xprt" },
- {},
-};
-
-static struct platform_driver glink_smem_native_driver = {
- .probe = glink_smem_native_probe,
- .driver = {
- .name = "msm_glink_smem_native_xprt",
- .owner = THIS_MODULE,
- .of_match_table = smem_match_table,
- },
-};
-
static struct of_device_id rpm_match_table[] = {
{ .compatible = "qcom,glink-rpm-native-xprt" },
{},
@@ -2981,31 +2250,10 @@ static struct platform_driver glink_rpm_native_driver = {
},
};
-static struct of_device_id mailbox_match_table[] = {
- { .compatible = "qcom,glink-mailbox-xprt" },
- {},
-};
-
-static struct platform_driver glink_mailbox_driver = {
- .probe = glink_mailbox_probe,
- .driver = {
- .name = "msm_glink_mailbox_xprt",
- .owner = THIS_MODULE,
- .of_match_table = mailbox_match_table,
- },
-};
-
static int __init glink_smem_native_xprt_init(void)
{
int rc;
- rc = platform_driver_register(&glink_smem_native_driver);
- if (rc) {
- pr_err("%s: glink_smem_native_driver register failed %d\n",
- __func__, rc);
- return rc;
- }
-
rc = platform_driver_register(&glink_rpm_native_driver);
if (rc) {
pr_err("%s: glink_rpm_native_driver register failed %d\n",
@@ -3013,13 +2261,6 @@ static int __init glink_smem_native_xprt_init(void)
return rc;
}
- rc = platform_driver_register(&glink_mailbox_driver);
- if (rc) {
- pr_err("%s: glink_mailbox_driver register failed %d\n",
- __func__, rc);
- return rc;
- }
-
return 0;
}
arch_initcall(glink_smem_native_xprt_init);