Merge "soc: qcom: glink_spi_xprt: Add support for GLink SPI Transport"

This commit is contained in:
Linux Build Service Account 2016-08-10 12:41:52 -07:00 committed by Gerrit - the friendly Code Review server
commit 21583fd29e
7 changed files with 2308 additions and 11 deletions

View file

@ -0,0 +1,44 @@
Qualcomm Technologies, Inc. G-link SPI Transport
Required properties:
-compatible : should be "qcom,glink-spi-xprt".
-label : the name of the subsystem this link connects to.
Optional properties:
-qcom,remote-fifo-config: Reference to the FIFO configuratio in the remote
processor.
-qcom,qos-config: Reference to the qos configuration elements.It depends on
ramp-time.
-qcom,ramp-time: Worst case time in microseconds to transition to this power
state. Power states are numbered by array index position.
Example:
glink_spi_xprt_wdsp: qcom,glink-spi-xprt-wdsp {
compatible = "qcom,glink-spi-xprt";
label = "wdsp";
qcom,remote-fifo-config = <&glink_fifo_wdsp>;
qcom,qos-config = <&glink_qos_wdsp>;
qcom,ramp-time = <0x10>,
<0x20>,
<0x30>,
<0x40>;
};
glink_fifo_wdsp: qcom,glink-fifo-config-wdsp {
compatible = "qcom,glink-fifo-config";
qcom,out-read-idx-reg = <0x12000>;
qcom,out-write-idx-reg = <0x12004>;
qcom,in-read-idx-reg = <0x1200C>;
qcom,in-write-idx-reg = <0x12010>;
};
glink_qos_wdsp: qcom,glink-qos-config-wdsp {
compatible = "qcom,glink-qos-config";
qcom,flow-info = <0x80 0x0>,
<0x70 0x1>,
<0x60 0x2>,
<0x50 0x3>;
qcom,mtu-size = <0x800>;
qcom,tput-stats-cycle = <0xa>;
};

View file

@ -104,6 +104,16 @@ config MSM_GLINK_SMEM_NATIVE_XPRT
transport to only connecting with entities internal to the transport to only connecting with entities internal to the
System-on-Chip. System-on-Chip.
config MSM_GLINK_SPI_XPRT
depends on MSM_GLINK
tristate "Generic Link (G-Link) SPI Transport"
help
G-Link SPI Transport is a Transport plug-in developed over SPI
bus. This transport plug-in performs marshaling of G-Link
commands & data to the appropriate SPI bus wire format and
allows for G-Link communication with remote subsystems that are
external to the System-on-Chip.
config MSM_SPCOM config MSM_SPCOM
depends on MSM_GLINK depends on MSM_GLINK
bool "Secure Processor Communication over GLINK" bool "Secure Processor Communication over GLINK"

View file

@ -11,6 +11,7 @@ obj-$(CONFIG_MSM_GLINK) += glink.o glink_debugfs.o glink_ssr.o
obj-$(CONFIG_MSM_GLINK_LOOPBACK_SERVER) += glink_loopback_server.o obj-$(CONFIG_MSM_GLINK_LOOPBACK_SERVER) += glink_loopback_server.o
obj-$(CONFIG_MSM_GLINK_SMD_XPRT) += glink_smd_xprt.o obj-$(CONFIG_MSM_GLINK_SMD_XPRT) += glink_smd_xprt.o
obj-$(CONFIG_MSM_GLINK_SMEM_NATIVE_XPRT)+= glink_smem_native_xprt.o obj-$(CONFIG_MSM_GLINK_SMEM_NATIVE_XPRT)+= glink_smem_native_xprt.o
obj-$(CONFIG_MSM_GLINK_SPI_XPRT) += glink_spi_xprt.o
obj-$(CONFIG_MSM_SMEM_LOGGING) += smem_log.o obj-$(CONFIG_MSM_SMEM_LOGGING) += smem_log.o
obj-$(CONFIG_MSM_SYSMON_GLINK_COMM) += sysmon-glink.o sysmon-qmi.o obj-$(CONFIG_MSM_SYSMON_GLINK_COMM) += sysmon-glink.o sysmon-qmi.o
obj-$(CONFIG_ARCH_MSM8996) += kryo-l2-accessors.o obj-$(CONFIG_ARCH_MSM8996) += kryo-l2-accessors.o

View file

@ -372,10 +372,10 @@ static struct channel_ctx *ch_name_to_ch_ctx_create(
const char *name); const char *name);
static void ch_push_remote_rx_intent(struct channel_ctx *ctx, size_t size, static void ch_push_remote_rx_intent(struct channel_ctx *ctx, size_t size,
uint32_t riid); uint32_t riid, void *cookie);
static int ch_pop_remote_rx_intent(struct channel_ctx *ctx, size_t size, static int ch_pop_remote_rx_intent(struct channel_ctx *ctx, size_t size,
uint32_t *riid_ptr, size_t *intent_size); uint32_t *riid_ptr, size_t *intent_size, void **cookie);
static struct glink_core_rx_intent *ch_push_local_rx_intent( static struct glink_core_rx_intent *ch_push_local_rx_intent(
struct channel_ctx *ctx, const void *pkt_priv, size_t size); struct channel_ctx *ctx, const void *pkt_priv, size_t size);
@ -1139,11 +1139,12 @@ bool ch_check_duplicate_riid(struct channel_ctx *ctx, int riid)
* @ctx: Local channel context * @ctx: Local channel context
* @size: Size of Intent * @size: Size of Intent
* @riid_ptr: Pointer to return value of remote intent ID * @riid_ptr: Pointer to return value of remote intent ID
* @cookie: Transport-specific cookie to return
* *
* This functions searches for an RX intent that is >= to the requested size. * This functions searches for an RX intent that is >= to the requested size.
*/ */
int ch_pop_remote_rx_intent(struct channel_ctx *ctx, size_t size, int ch_pop_remote_rx_intent(struct channel_ctx *ctx, size_t size,
uint32_t *riid_ptr, size_t *intent_size) uint32_t *riid_ptr, size_t *intent_size, void **cookie)
{ {
struct glink_core_rx_intent *intent; struct glink_core_rx_intent *intent;
struct glink_core_rx_intent *intent_tmp; struct glink_core_rx_intent *intent_tmp;
@ -1177,6 +1178,7 @@ int ch_pop_remote_rx_intent(struct channel_ctx *ctx, size_t size,
intent->intent_size); intent->intent_size);
*riid_ptr = intent->id; *riid_ptr = intent->id;
*intent_size = intent->intent_size; *intent_size = intent->intent_size;
*cookie = intent->cookie;
kfree(intent); kfree(intent);
spin_unlock_irqrestore( spin_unlock_irqrestore(
&ctx->rmt_rx_intent_lst_lock_lhc2, flags); &ctx->rmt_rx_intent_lst_lock_lhc2, flags);
@ -1192,11 +1194,12 @@ int ch_pop_remote_rx_intent(struct channel_ctx *ctx, size_t size,
* @ctx: Local channel context * @ctx: Local channel context
* @size: Size of Intent * @size: Size of Intent
* @riid: Remote intent ID * @riid: Remote intent ID
* @cookie: Transport-specific cookie to cache
* *
* This functions adds a remote RX intent to the remote RX intent list. * This functions adds a remote RX intent to the remote RX intent list.
*/ */
void ch_push_remote_rx_intent(struct channel_ctx *ctx, size_t size, void ch_push_remote_rx_intent(struct channel_ctx *ctx, size_t size,
uint32_t riid) uint32_t riid, void *cookie)
{ {
struct glink_core_rx_intent *intent; struct glink_core_rx_intent *intent;
unsigned long flags; unsigned long flags;
@ -1225,6 +1228,7 @@ void ch_push_remote_rx_intent(struct channel_ctx *ctx, size_t size,
} }
intent->id = riid; intent->id = riid;
intent->intent_size = size; intent->intent_size = size;
intent->cookie = cookie;
spin_lock_irqsave(&ctx->rmt_rx_intent_lst_lock_lhc2, flags); spin_lock_irqsave(&ctx->rmt_rx_intent_lst_lock_lhc2, flags);
list_add_tail(&intent->list, &ctx->rmt_rx_intent_list); list_add_tail(&intent->list, &ctx->rmt_rx_intent_list);
@ -2794,6 +2798,7 @@ static int glink_tx_common(void *handle, void *pkt_priv,
bool is_atomic = bool is_atomic =
tx_flags & (GLINK_TX_SINGLE_THREADED | GLINK_TX_ATOMIC); tx_flags & (GLINK_TX_SINGLE_THREADED | GLINK_TX_ATOMIC);
unsigned long flags; unsigned long flags;
void *cookie = NULL;
if (!size) if (!size)
return -EINVAL; return -EINVAL;
@ -2826,7 +2831,7 @@ static int glink_tx_common(void *handle, void *pkt_priv,
} }
/* find matching rx intent (first-fit algorithm for now) */ /* find matching rx intent (first-fit algorithm for now) */
if (ch_pop_remote_rx_intent(ctx, size, &riid, &intent_size)) { if (ch_pop_remote_rx_intent(ctx, size, &riid, &intent_size, &cookie)) {
if (!(tx_flags & GLINK_TX_REQ_INTENT)) { if (!(tx_flags & GLINK_TX_REQ_INTENT)) {
/* no rx intent available */ /* no rx intent available */
GLINK_ERR_CH(ctx, GLINK_ERR_CH(ctx,
@ -2856,7 +2861,7 @@ static int glink_tx_common(void *handle, void *pkt_priv,
} }
while (ch_pop_remote_rx_intent(ctx, size, &riid, while (ch_pop_remote_rx_intent(ctx, size, &riid,
&intent_size)) { &intent_size, &cookie)) {
rwref_get(&ctx->ch_state_lhb2); rwref_get(&ctx->ch_state_lhb2);
rwref_read_put(&ctx->ch_state_lhb2); rwref_read_put(&ctx->ch_state_lhb2);
if (is_atomic) { if (is_atomic) {
@ -2928,7 +2933,7 @@ static int glink_tx_common(void *handle, void *pkt_priv,
is_atomic ? GFP_ATOMIC : GFP_KERNEL); is_atomic ? GFP_ATOMIC : GFP_KERNEL);
if (!tx_info) { if (!tx_info) {
GLINK_ERR_CH(ctx, "%s: No memory for allocation\n", __func__); GLINK_ERR_CH(ctx, "%s: No memory for allocation\n", __func__);
ch_push_remote_rx_intent(ctx, intent_size, riid); ch_push_remote_rx_intent(ctx, intent_size, riid, cookie);
rwref_read_put(&ctx->ch_state_lhb2); rwref_read_put(&ctx->ch_state_lhb2);
return -ENOMEM; return -ENOMEM;
} }
@ -2946,6 +2951,7 @@ static int glink_tx_common(void *handle, void *pkt_priv,
tx_info->vprovider = vbuf_provider; tx_info->vprovider = vbuf_provider;
tx_info->pprovider = pbuf_provider; tx_info->pprovider = pbuf_provider;
tx_info->intent_size = intent_size; tx_info->intent_size = intent_size;
tx_info->cookie = cookie;
/* schedule packet for transmit */ /* schedule packet for transmit */
if ((tx_flags & GLINK_TX_SINGLE_THREADED) && if ((tx_flags & GLINK_TX_SINGLE_THREADED) &&
@ -3577,6 +3583,10 @@ int glink_xprt_name_to_id(const char *name, uint16_t *id)
*id = SMEM_XPRT_ID; *id = SMEM_XPRT_ID;
return 0; return 0;
} }
if (!strcmp(name, "spi")) {
*id = SPIV2_XPRT_ID;
return 0;
}
if (!strcmp(name, "smd_trans")) { if (!strcmp(name, "smd_trans")) {
*id = SMD_TRANS_XPRT_ID; *id = SMD_TRANS_XPRT_ID;
return 0; return 0;
@ -4844,7 +4854,35 @@ static void glink_core_remote_rx_intent_put(struct glink_transport_if *if_ptr,
return; return;
} }
ch_push_remote_rx_intent(ctx, size, riid); ch_push_remote_rx_intent(ctx, size, riid, NULL);
rwref_put(&ctx->ch_state_lhb2);
}
/**
* glink_core_remote_rx_intent_put_cookie() - Receive remove intent
*
* @if_ptr: Pointer to transport instance
* @rcid: Remote Channel ID
* @riid: Remote Intent ID
* @size: Size of the remote intent ID
* @cookie: Transport-specific cookie to cache
*/
static void glink_core_remote_rx_intent_put_cookie(
struct glink_transport_if *if_ptr,
uint32_t rcid, uint32_t riid, size_t size, void *cookie)
{
struct channel_ctx *ctx;
ctx = xprt_rcid_to_ch_ctx_get(if_ptr->glink_core_priv, rcid);
if (!ctx) {
/* unknown rcid received - this shouldn't happen */
GLINK_ERR_XPRT(if_ptr->glink_core_priv,
"%s: invalid rcid received %u\n", __func__,
(unsigned)rcid);
return;
}
ch_push_remote_rx_intent(ctx, size, riid, cookie);
rwref_put(&ctx->ch_state_lhb2); rwref_put(&ctx->ch_state_lhb2);
} }
@ -5050,6 +5088,7 @@ void glink_core_rx_cmd_tx_done(struct glink_transport_if *if_ptr,
struct glink_core_tx_pkt *tx_pkt; struct glink_core_tx_pkt *tx_pkt;
unsigned long flags; unsigned long flags;
size_t intent_size; size_t intent_size;
void *cookie;
ctx = xprt_rcid_to_ch_ctx_get(if_ptr->glink_core_priv, rcid); ctx = xprt_rcid_to_ch_ctx_get(if_ptr->glink_core_priv, rcid);
if (!ctx) { if (!ctx) {
@ -5082,11 +5121,12 @@ void glink_core_rx_cmd_tx_done(struct glink_transport_if *if_ptr,
ctx->notify_tx_done(ctx, ctx->user_priv, tx_pkt->pkt_priv, ctx->notify_tx_done(ctx, ctx->user_priv, tx_pkt->pkt_priv,
tx_pkt->data ? tx_pkt->data : tx_pkt->iovec); tx_pkt->data ? tx_pkt->data : tx_pkt->iovec);
intent_size = tx_pkt->intent_size; intent_size = tx_pkt->intent_size;
cookie = tx_pkt->cookie;
ch_remove_tx_pending_remote_done(ctx, tx_pkt); ch_remove_tx_pending_remote_done(ctx, tx_pkt);
spin_unlock_irqrestore(&ctx->tx_lists_lock_lhc3, flags); spin_unlock_irqrestore(&ctx->tx_lists_lock_lhc3, flags);
if (reuse) if (reuse)
ch_push_remote_rx_intent(ctx, intent_size, riid); ch_push_remote_rx_intent(ctx, intent_size, riid, cookie);
rwref_put(&ctx->ch_state_lhb2); rwref_put(&ctx->ch_state_lhb2);
} }
@ -5525,6 +5565,8 @@ static struct glink_core_if core_impl = {
.rx_get_pkt_ctx = glink_core_rx_get_pkt_ctx, .rx_get_pkt_ctx = glink_core_rx_get_pkt_ctx,
.rx_put_pkt_ctx = glink_core_rx_put_pkt_ctx, .rx_put_pkt_ctx = glink_core_rx_put_pkt_ctx,
.rx_cmd_remote_rx_intent_put = glink_core_remote_rx_intent_put, .rx_cmd_remote_rx_intent_put = glink_core_remote_rx_intent_put,
.rx_cmd_remote_rx_intent_put_cookie =
glink_core_remote_rx_intent_put_cookie,
.rx_cmd_remote_rx_intent_req = glink_core_rx_cmd_remote_rx_intent_req, .rx_cmd_remote_rx_intent_req = glink_core_rx_cmd_remote_rx_intent_req,
.rx_cmd_rx_intent_req_ack = glink_core_rx_cmd_rx_intent_req_ack, .rx_cmd_rx_intent_req_ack = glink_core_rx_cmd_rx_intent_req_ack,
.rx_cmd_tx_done = glink_core_rx_cmd_tx_done, .rx_cmd_tx_done = glink_core_rx_cmd_tx_done,

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License version 2 and
@ -64,6 +64,7 @@ struct glink_core_version {
* iovec: Pointer to vector buffer if the transport passes a vector buffer * iovec: Pointer to vector buffer if the transport passes a vector buffer
* vprovider: Virtual address-space buffer provider for a vector buffer * vprovider: Virtual address-space buffer provider for a vector buffer
* pprovider: Physical address-space buffer provider for a vector buffer * pprovider: Physical address-space buffer provider for a vector buffer
* cookie: Private transport specific cookie
* pkt_priv: G-Link core owned packet-private data * pkt_priv: G-Link core owned packet-private data
* list: G-Link core owned list node * list: G-Link core owned list node
* bounce_buf: Pointer to the temporary/internal bounce buffer * bounce_buf: Pointer to the temporary/internal bounce buffer
@ -78,6 +79,7 @@ struct glink_core_rx_intent {
void *iovec; void *iovec;
void * (*vprovider)(void *iovec, size_t offset, size_t *size); void * (*vprovider)(void *iovec, size_t offset, size_t *size);
void * (*pprovider)(void *iovec, size_t offset, size_t *size); void * (*pprovider)(void *iovec, size_t offset, size_t *size);
void *cookie;
/* G-Link-Core-owned elements - please ignore */ /* G-Link-Core-owned elements - please ignore */
struct list_head list; struct list_head list;
@ -151,6 +153,9 @@ struct glink_core_if {
struct glink_core_rx_intent *intent_ptr, bool complete); struct glink_core_rx_intent *intent_ptr, bool complete);
void (*rx_cmd_remote_rx_intent_put)(struct glink_transport_if *if_ptr, void (*rx_cmd_remote_rx_intent_put)(struct glink_transport_if *if_ptr,
uint32_t rcid, uint32_t riid, size_t size); uint32_t rcid, uint32_t riid, size_t size);
void (*rx_cmd_remote_rx_intent_put_cookie)(
struct glink_transport_if *if_ptr, uint32_t rcid,
uint32_t riid, size_t size, void *cookie);
void (*rx_cmd_tx_done)(struct glink_transport_if *if_ptr, uint32_t rcid, void (*rx_cmd_tx_done)(struct glink_transport_if *if_ptr, uint32_t rcid,
uint32_t riid, bool reuse); uint32_t riid, bool reuse);
void (*rx_cmd_remote_rx_intent_req)(struct glink_transport_if *if_ptr, void (*rx_cmd_remote_rx_intent_req)(struct glink_transport_if *if_ptr,

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License version 2 and
@ -28,6 +28,7 @@ enum buf_type {
enum xprt_ids { enum xprt_ids {
SMEM_XPRT_ID = 100, SMEM_XPRT_ID = 100,
SPIV2_XPRT_ID = SMEM_XPRT_ID,
SMD_TRANS_XPRT_ID = 200, SMD_TRANS_XPRT_ID = 200,
LLOOP_XPRT_ID = 300, LLOOP_XPRT_ID = 300,
MOCK_XPRT_HIGH_ID = 390, MOCK_XPRT_HIGH_ID = 390,
@ -56,6 +57,7 @@ enum xprt_ids {
* @iovec: Pointer to the vector buffer packet. * @iovec: Pointer to the vector buffer packet.
* @vprovider: Packet-specific virtual buffer provider function. * @vprovider: Packet-specific virtual buffer provider function.
* @pprovider: Packet-specific physical buffer provider function. * @pprovider: Packet-specific physical buffer provider function.
* @cookie: Transport-specific cookie
* @pkt_ref: Active references to the packet. * @pkt_ref: Active references to the packet.
*/ */
struct glink_core_tx_pkt { struct glink_core_tx_pkt {
@ -73,6 +75,7 @@ struct glink_core_tx_pkt {
void *iovec; void *iovec;
void * (*vprovider)(void *iovec, size_t offset, size_t *size); void * (*vprovider)(void *iovec, size_t offset, size_t *size);
void * (*pprovider)(void *iovec, size_t offset, size_t *size); void * (*pprovider)(void *iovec, size_t offset, size_t *size);
void *cookie;
struct rwref_lock pkt_ref; struct rwref_lock pkt_ref;
}; };