aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/soc
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2015-09-02 18:46:46 -0400
committerAndy Gross <agross@codeaurora.org>2015-10-14 15:51:20 -0400
commitf02dc82523a72619a10e24355c7b2f12c6814d52 (patch)
tree10cb23429120a5d45237f219ae75b542a827ded1 /drivers/soc
parent9806884d8cd552e6926c162a022cc4b948f4abc8 (diff)
soc: qcom: smd: Represent channel layout in structures
The rx and tx channel info are laid out in memory next to each other, and there are two types of channel info structures, byte based and word based. We have 4 pointers to these info structures, when we really only need two to point to the different types of structures. Encapsulate the byte based and word based tx/rx structures in a "channel pair" structure that describes the layout of memory and reduces the number of pointers in the smd channel structure by two. Reviewed-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Andy Gross <agross@codeaurora.org>
Diffstat (limited to 'drivers/soc')
-rw-r--r--drivers/soc/qcom/smd.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/drivers/soc/qcom/smd.c b/drivers/soc/qcom/smd.c
index beaea1d5169f..3efa3670ce18 100644
--- a/drivers/soc/qcom/smd.c
+++ b/drivers/soc/qcom/smd.c
@@ -65,7 +65,9 @@
65 */ 65 */
66 66
67struct smd_channel_info; 67struct smd_channel_info;
68struct smd_channel_info_pair;
68struct smd_channel_info_word; 69struct smd_channel_info_word;
70struct smd_channel_info_word_pair;
69 71
70#define SMD_ALLOC_TBL_COUNT 2 72#define SMD_ALLOC_TBL_COUNT 2
71#define SMD_ALLOC_TBL_SIZE 64 73#define SMD_ALLOC_TBL_SIZE 64
@@ -151,10 +153,8 @@ enum smd_channel_state {
151 * @name: name of the channel 153 * @name: name of the channel
152 * @state: local state of the channel 154 * @state: local state of the channel
153 * @remote_state: remote state of the channel 155 * @remote_state: remote state of the channel
154 * @tx_info: byte aligned outgoing channel info 156 * @info: byte aligned outgoing/incoming channel info
155 * @rx_info: byte aligned incoming channel info 157 * @info_word: word aligned outgoing/incoming channel info
156 * @tx_info_word: word aligned outgoing channel info
157 * @rx_info_word: word aligned incoming channel info
158 * @tx_lock: lock to make writes to the channel mutually exclusive 158 * @tx_lock: lock to make writes to the channel mutually exclusive
159 * @fblockread_event: wakeup event tied to tx fBLOCKREADINTR 159 * @fblockread_event: wakeup event tied to tx fBLOCKREADINTR
160 * @tx_fifo: pointer to the outgoing ring buffer 160 * @tx_fifo: pointer to the outgoing ring buffer
@@ -175,11 +175,8 @@ struct qcom_smd_channel {
175 enum smd_channel_state state; 175 enum smd_channel_state state;
176 enum smd_channel_state remote_state; 176 enum smd_channel_state remote_state;
177 177
178 struct smd_channel_info *tx_info; 178 struct smd_channel_info_pair *info;
179 struct smd_channel_info *rx_info; 179 struct smd_channel_info_word_pair *info_word;
180
181 struct smd_channel_info_word *tx_info_word;
182 struct smd_channel_info_word *rx_info_word;
183 180
184 struct mutex tx_lock; 181 struct mutex tx_lock;
185 wait_queue_head_t fblockread_event; 182 wait_queue_head_t fblockread_event;
@@ -228,6 +225,11 @@ struct smd_channel_info {
228 u32 head; 225 u32 head;
229}; 226};
230 227
228struct smd_channel_info_pair {
229 struct smd_channel_info tx;
230 struct smd_channel_info rx;
231};
232
231/* 233/*
232 * Format of the smd_info smem items, for word aligned channels. 234 * Format of the smd_info smem items, for word aligned channels.
233 */ 235 */
@@ -245,25 +247,30 @@ struct smd_channel_info_word {
245 u32 head; 247 u32 head;
246}; 248};
247 249
250struct smd_channel_info_word_pair {
251 struct smd_channel_info_word tx;
252 struct smd_channel_info_word rx;
253};
254
248#define GET_RX_CHANNEL_INFO(channel, param) \ 255#define GET_RX_CHANNEL_INFO(channel, param) \
249 (channel->rx_info_word ? \ 256 (channel->info_word ? \
250 channel->rx_info_word->param : \ 257 channel->info_word->rx.param : \
251 channel->rx_info->param) 258 channel->info->rx.param)
252 259
253#define SET_RX_CHANNEL_INFO(channel, param, value) \ 260#define SET_RX_CHANNEL_INFO(channel, param, value) \
254 (channel->rx_info_word ? \ 261 (channel->info_word ? \
255 (channel->rx_info_word->param = value) : \ 262 (channel->info_word->rx.param = value) : \
256 (channel->rx_info->param = value)) 263 (channel->info->rx.param = value))
257 264
258#define GET_TX_CHANNEL_INFO(channel, param) \ 265#define GET_TX_CHANNEL_INFO(channel, param) \
259 (channel->tx_info_word ? \ 266 (channel->info_word ? \
260 channel->tx_info_word->param : \ 267 channel->info_word->tx.param : \
261 channel->tx_info->param) 268 channel->info->tx.param)
262 269
263#define SET_TX_CHANNEL_INFO(channel, param, value) \ 270#define SET_TX_CHANNEL_INFO(channel, param, value) \
264 (channel->tx_info_word ? \ 271 (channel->info_word ? \
265 (channel->tx_info_word->param = value) : \ 272 (channel->info_word->tx.param = value) : \
266 (channel->tx_info->param = value)) 273 (channel->info->tx.param = value))
267 274
268/** 275/**
269 * struct qcom_smd_alloc_entry - channel allocation entry 276 * struct qcom_smd_alloc_entry - channel allocation entry
@@ -412,7 +419,7 @@ static size_t qcom_smd_channel_peek(struct qcom_smd_channel *channel,
412 unsigned tail; 419 unsigned tail;
413 size_t len; 420 size_t len;
414 421
415 word_aligned = channel->rx_info_word != NULL; 422 word_aligned = channel->info_word;
416 tail = GET_RX_CHANNEL_INFO(channel, tail); 423 tail = GET_RX_CHANNEL_INFO(channel, tail);
417 424
418 len = min_t(size_t, count, channel->fifo_size - tail); 425 len = min_t(size_t, count, channel->fifo_size - tail);
@@ -627,7 +634,7 @@ static int qcom_smd_write_fifo(struct qcom_smd_channel *channel,
627 unsigned head; 634 unsigned head;
628 size_t len; 635 size_t len;
629 636
630 word_aligned = channel->tx_info_word != NULL; 637 word_aligned = channel->info_word;
631 head = GET_TX_CHANNEL_INFO(channel, head); 638 head = GET_TX_CHANNEL_INFO(channel, head);
632 639
633 len = min_t(size_t, count, channel->fifo_size - head); 640 len = min_t(size_t, count, channel->fifo_size - head);
@@ -670,7 +677,7 @@ int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len)
670 int ret; 677 int ret;
671 678
672 /* Word aligned channels only accept word size aligned data */ 679 /* Word aligned channels only accept word size aligned data */
673 if (channel->rx_info_word != NULL && len % 4) 680 if (channel->info_word && len % 4)
674 return -EINVAL; 681 return -EINVAL;
675 682
676 ret = mutex_lock_interruptible(&channel->tx_lock); 683 ret = mutex_lock_interruptible(&channel->tx_lock);
@@ -1000,11 +1007,9 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
1000 * use. 1007 * use.
1001 */ 1008 */
1002 if (info_size == 2 * sizeof(struct smd_channel_info_word)) { 1009 if (info_size == 2 * sizeof(struct smd_channel_info_word)) {
1003 channel->tx_info_word = info; 1010 channel->info_word = info;
1004 channel->rx_info_word = info + sizeof(struct smd_channel_info_word);
1005 } else if (info_size == 2 * sizeof(struct smd_channel_info)) { 1011 } else if (info_size == 2 * sizeof(struct smd_channel_info)) {
1006 channel->tx_info = info; 1012 channel->info = info;
1007 channel->rx_info = info + sizeof(struct smd_channel_info);
1008 } else { 1013 } else {
1009 dev_err(smd->dev, 1014 dev_err(smd->dev,
1010 "channel info of size %zu not supported\n", info_size); 1015 "channel info of size %zu not supported\n", info_size);