SMEM/SMD/SMD_RPM big endian support + tidying
Subsystems (3)
v2 cover SMEM/SMD/SMD_RPM big endian support + tidying
This supersedes the 3 "series" of patches to move smem to big endian, smd to big endian, and make qcom_smem_get() return a pointer.
I've moved the qcom_smem_get() returning a pointer part to the beginning of the series so it can be applied earlier if desired. I imagine the first 7 patches can go through arm-soc, and the last patch Mark can pick up anytime. All patches tested on apq8074 dragonboard.
I've already written the patches to add __ioread32_copy(), but I'm holding them until -rc1 drops because I'd rather not involve even more people in this series just yet.
Stephen Boyd (8):
soc: qcom: Make qcom_smem_get() return a pointer
soc: qcom: smem: Handle big endian CPUs
soc: qcom: smd: Represent channel layout in structures
soc: qcom: smd: Use __iowrite32_copy() instead of open-coding it
soc: qcom: smd: Remove use of VLAIS
soc: qcom: smd: Handle big endian CPUs
soc: qcom: smd_rpm: Handle big endian CPUs
regulator: qcom_smd: Handle big endian CPUs
drivers/regulator/qcom_smd-regulator.c | 28 ++-- drivers/soc/qcom/smd-rpm.c | 68 ++++---- drivers/soc/qcom/smd.c | 259 +++++++++++++++++------------ drivers/soc/qcom/smem.c | 293 +++++++++++++++++++-------------- include/linux/soc/qcom/smem.h | 2 +- 5 files changed, 374 insertions(+), 276 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 1/8 soc: qcom: Make qcom_smem_get() return a pointer
Passing a void ** almost always requires a cast at the call site. Instead of littering the code with casts every time this function is called, have qcom_smem_get() return a void pointer to the location of the smem item. This frees the caller from having to cast the pointer.
---
Changes since v1:
* Moved to before the smem big endian patch
drivers/soc/qcom/smd.c | 30 +++++++++--------- drivers/soc/qcom/smem.c | 72 +++++++++++++++++++------------------------ include/linux/soc/qcom/smem.h | 2 +- 3 files changed, 48 insertions(+), 56 deletions(-)
drivers/soc/qcom/smd.c +15 -15
@@ -978,10 +978,11 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *edspin_lock_init (&channel->recv_lock);init_waitqueue_head (&channel->fblockread_event); - ret =qcom_smem_get (edge->remote_pid, smem_info_item, (void **)&info, - &info_size); -if (ret) + info =qcom_smem_get (edge->remote_pid, smem_info_item, &info_size); +if (IS_ERR (info)) { + ret =PTR_ERR (info); goto free_name_and_channel; + }/* * Use the size of the item to figure out which channel info struct to
@@ -1000,10 +1001,11 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed goto free_name_and_channel; } - ret =qcom_smem_get (edge->remote_pid, smem_fifo_item, &fifo_base, - &fifo_size); -if (ret) + fifo_base =qcom_smem_get (edge->remote_pid, smem_fifo_item, &fifo_size); +if (IS_ERR (fifo_base)) { + ret =PTR_ERR (fifo_base); goto free_name_and_channel; + }/* The channel consist of a rx and tx fifo of equal size */ fifo_size /=2 ;
@@ -1040,16 +1042,13 @@ static void qcom_discover_channels(struct qcom_smd_edge *edge)unsigned long flags;unsigned fifo_id;unsigned info_id; -int ret;int tbl;int i;for (tbl =0 ; tbl <SMD_ALLOC_TBL_COUNT ; tbl++) { - ret =qcom_smem_get (edge->remote_pid, - smem_items[tbl].alloc_tbl_id, - (void **)&alloc_tbl, -NULL ); -if (ret <0 ) + alloc_tbl =qcom_smem_get (edge->remote_pid, + smem_items[tbl].alloc_tbl_id,NULL ); +if (IS_ERR (alloc_tbl))continue ;for (i =0 ; i <SMD_ALLOC_TBL_SIZE ; i++) {
@@ -1227,11 +1226,12 @@ static int qcom_smd_probe(struct platform_device *pdev)int num_edges;int ret;int i =0 ; +void *p;/* Wait for smem */ - ret =qcom_smem_get (QCOM_SMEM_HOST_ANY , smem_items[0 ].alloc_tbl_id,NULL ,NULL ); -if (ret == -EPROBE_DEFER ) -return ret; + p =qcom_smem_get (QCOM_SMEM_HOST_ANY , smem_items[0 ].alloc_tbl_id,NULL ); +if (PTR_ERR (p) == -EPROBE_DEFER ) +return PTR_ERR (p); num_edges =of_get_available_child_count (pdev->dev.of_node); array_size =sizeof (*smd) + num_edges *sizeof (struct qcom_smd_edge );
drivers/soc/qcom/smem.c +32 -40
144 lines not on this page · raw message
include/linux/soc/qcom/smem.h +1 -1
@@ -4,7 +4,7 @@#define QCOM_SMEM_HOST_ANY -1int qcom_smem_alloc (unsigned host,unsigned item,size_t size); -int qcom_smem_get (unsigned host,unsigned item,void **ptr,size_t *size); +void *qcom_smem_get (unsigned host,unsigned item,size_t *size);int qcom_smem_get_free_space (unsigned host);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 1/8] soc: qcom: Make qcom_smem_get() return a pointer
Quoted 6 lines · Stephen Boyd
Passing a void ** almost always requires a cast at the call site. Instead of littering the code with casts every time this function is called, have
qcom_smem_get()return a void pointer to the location of the smem item. This frees the caller from having to cast the pointer.
PATCH v2 2/8 soc: qcom: smem: Handle big endian CPUs
In reply to Stephen BoydThe contents of smem are always in little endian, but the smem driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
---
Changes since v1:
* Rebased on top of qcom_smem_get() returning a pointer
drivers/soc/qcom/smem.c | 229 +++++++++++++++++++++++++++++------------------- 1 file changed, 138 insertions(+), 91 deletions(-)
drivers/soc/qcom/smem.c +138 -91
@@ -92,9 +92,9 @@* @params: parameters to the command */ struct smem_proc_comm { -u32 command; -u32 status; -u32 params[2 ]; +__le32 command; +__le32 status; +__le32 params[2 ]; };/**
@@ -106,10 +106,10 @@ struct smem_proc_comm {* the default region. bits 0,1 are reserved */ struct smem_global_entry { -u32 allocated; -u32 offset; -u32 size; -u32 aux_base;/* bits 1:0 reserved */ +__le32 allocated; +__le32 offset; +__le32 size; +__le32 aux_base;/* bits 1:0 reserved */ };#define AUX_BASE_MASK 0xfffffffc
@@ -125,11 +125,11 @@ struct smem_global_entry {*/ struct smem_header {struct smem_proc_comm proc_comm[4 ]; -u32 version[32 ]; -u32 initialized; -u32 free_offset; -u32 available; -u32 reserved; +__le32 version[32 ]; +__le32 initialized; +__le32 free_offset; +__le32 available; +__le32 reserved;struct smem_global_entry toc[SMEM_ITEM_COUNT ]; };
@@ -143,12 +143,12 @@ struct smem_header {* @reserved: reserved entries for later use */ struct smem_ptable_entry { -u32 offset; -u32 size; -u32 flags; -u16 host0; -u16 host1; -u32 reserved[8 ]; +__le32 offset; +__le32 size; +__le32 flags; +__le16 host0; +__le16 host1; +__le32 reserved[8 ]; };/**
@@ -160,13 +160,14 @@ struct smem_ptable_entry {* @entry: list of @smem_ptable_entry for the @num_entries partitions */ struct smem_ptable { -u32 magic; -u32 version; -u32 num_entries; -u32 reserved[5 ]; +u8 magic[4 ]; +__le32 version; +__le32 num_entries; +__le32 reserved[5 ];struct smem_ptable_entry entry[]; }; -#define SMEM_PTABLE_MAGIC 0x434f5424/* "$TOC" */ + +static const u8 SMEM_PTABLE_MAGIC [] = {0x24 ,0x54 ,0x4f ,0x43 };/* "$TOC" */ /** * struct smem_partition_header - header of the partitions
@@ -181,15 +182,16 @@ struct smem_ptable {* @reserved: for now reserved entries */ struct smem_partition_header { -u32 magic; -u16 host0; -u16 host1; -u32 size; -u32 offset_free_uncached; -u32 offset_free_cached; -u32 reserved[3 ]; +u8 magic[4 ]; +__le16 host0; +__le16 host1; +__le32 size; +__le32 offset_free_uncached; +__le32 offset_free_cached; +__le32 reserved[3 ]; }; -#define SMEM_PART_MAGIC 0x54525024/* "$PRT" */ + +static const u8 SMEM_PART_MAGIC [] = {0x24 ,0x50 ,0x52 ,0x54 };/** * struct smem_private_entry - header of each item in the private partition
@@ -201,12 +203,12 @@ struct smem_partition_header {* @reserved: for now reserved entry */ struct smem_private_entry { -u16 canary; -u16 item; -u32 size;/* includes padding bytes */ -u16 padding_data; -u16 padding_hdr; -u32 reserved; +u16 canary;/* bytes are the same so no swapping needed */ +__le16 item; +__le32 size;/* includes padding bytes */ +__le16 padding_data; +__le16 padding_hdr; +__le32 reserved; };#define SMEM_PRIVATE_CANARY 0xa5a5
@@ -242,6 +244,45 @@ struct qcom_smem {struct smem_region regions[0 ]; }; +static struct smem_private_entry * +phdr_to_last_private_entry (struct smem_partition_header *phdr) +{ +void *p = phdr; + +return p +le32_to_cpu (phdr->offset_free_uncached); +} + +static void *phdr_to_first_cached_entry (struct smem_partition_header *phdr) +{ +void *p = phdr; + +return p +le32_to_cpu (phdr->offset_free_cached); +} + +static struct smem_private_entry * +phdr_to_first_private_entry (struct smem_partition_header *phdr) +{ +void *p = phdr; + +return p +sizeof (*phdr); +} + +static struct smem_private_entry * +private_entry_next (struct smem_private_entry *e) +{ +void *p = e; + +return p +sizeof (*e) +le16_to_cpu (e->padding_hdr) + +le32_to_cpu (e->size); +} + +static void *entry_to_item (struct smem_private_entry *e) +{ +void *p = e; + +return p +sizeof (*e) +le16_to_cpu (e->padding_hdr); +} +/* Pointer to the one and only smem handle */ static struct qcom_smem *__smem;
@@ -254,16 +295,16 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem, size_t size) {struct smem_partition_header *phdr; -struct smem_private_entry *hdr; +struct smem_private_entry *hdr, *end;size_t alloc_size; -void *p; +void *cached; phdr = smem->partitions[host]; + hdr =phdr_to_first_private_entry (phdr); + end =phdr_to_last_private_entry (phdr); + cached =phdr_to_first_cached_entry (phdr); - p = (void *)phdr +sizeof (*phdr); -while (p < (void *)phdr + phdr->offset_free_uncached) { - hdr = p; - +while (hdr < end) {if (hdr->canary !=SMEM_PRIVATE_CANARY ) { dev_err(smem->dev, "Found invalid canary in host %d partition\n",
@@ -271,24 +312,23 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem,return -EINVAL ; } -if (hdr->item == item) +if (le16_to_cpu (hdr->item) == item)return -EEXIST ; - p +=sizeof (*hdr) + hdr->padding_hdr + hdr->size; + hdr =private_entry_next (hdr); }/* Check that we don't grow into the cached region */ alloc_size =sizeof (*hdr) +ALIGN (size,8 ); -if (p + alloc_size >= (void *)phdr + phdr->offset_free_cached) { +if ((void *)hdr + alloc_size >= cached) {dev_err (smem->dev,"Out of memory\n" );return -ENOSPC ; } - hdr = p; hdr->canary =SMEM_PRIVATE_CANARY ; - hdr->item = item; - hdr->size =ALIGN (size,8 ); - hdr->padding_data = hdr->size - size; + hdr->item =cpu_to_le16 (item); + hdr->size =cpu_to_le32 (ALIGN (size,8 )); + hdr->padding_data =cpu_to_le16 (le32_to_cpu (hdr->size) - size); hdr->padding_hdr =0 ;/*
@@ -297,7 +337,7 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem,* gets a consistent view of the linked list. */ wmb (); - phdr->offset_free_uncached += alloc_size; +le32_add_cpu (&phdr->offset_free_uncached, alloc_size);return 0 ; }
@@ -318,11 +358,11 @@ static int qcom_smem_alloc_global(struct qcom_smem *smem,return -EEXIST ; size =ALIGN (size,8 ); -if (WARN_ON (size > header->available)) +if (WARN_ON (size >le32_to_cpu (header->available)))return -ENOMEM ; entry->offset = header->free_offset; - entry->size = size; + entry->size =cpu_to_le32 (size);/* * Ensure the header is consistent before we mark the item allocated,
@@ -330,10 +370,10 @@ static int qcom_smem_alloc_global(struct qcom_smem *smem,* even though they do not take the spinlock on read. */ wmb (); - entry->allocated =1 ; + entry->allocated =cpu_to_le32 (1 ); - header->free_offset += size; - header->available -= size; +le32_add_cpu (&header->free_offset, size); +le32_add_cpu (&header->available, -size);return 0 ; }
@@ -396,15 +436,15 @@ static void *qcom_smem_get_global(struct qcom_smem *smem,if (!entry->allocated)return ERR_PTR (-ENXIO ); - aux_base = entry->aux_base &AUX_BASE_MASK ; + aux_base =le32_to_cpu (entry->aux_base) &AUX_BASE_MASK ;for (i =0 ; i < smem->num_regions; i++) { area = &smem->regions[i];if (area->aux_base == aux_base || !aux_base) {if (size !=NULL ) - *size = entry->size; -return area->virt_base + entry->offset; + *size =le32_to_cpu (entry->size); +return area->virt_base +le32_to_cpu (entry->offset); } }
@@ -417,30 +457,29 @@ static void *qcom_smem_get_private(struct qcom_smem *smem, size_t *size) {struct smem_partition_header *phdr; -struct smem_private_entry *hdr; -void *p; +struct smem_private_entry *e, *end; phdr = smem->partitions[host]; + e =phdr_to_first_private_entry (phdr); + end =phdr_to_last_private_entry (phdr); - p = (void *)phdr +sizeof (*phdr); -while (p < (void *)phdr + phdr->offset_free_uncached) { - hdr = p; - -if (hdr->canary !=SMEM_PRIVATE_CANARY ) { +while (e < end) { +if (e->canary !=SMEM_PRIVATE_CANARY ) {dev_err (smem->dev,"Found invalid canary in host %d partition\n" , host);return ERR_PTR (-EINVAL ); } -if (hdr->item == item) { +if (le16_to_cpu (e->item) == item) {if (size !=NULL ) - *size = hdr->size - hdr->padding_data; + *size =le32_to_cpu (e->size) - +le16_to_cpu (e->padding_data); -return p +sizeof (*hdr) + hdr->padding_hdr; +return entry_to_item (e); } - p +=sizeof (*hdr) + hdr->padding_hdr + hdr->size; + e =private_entry_next (e); }return ERR_PTR (-ENOENT );
@@ -500,10 +539,11 @@ int qcom_smem_get_free_space(unsigned host)if (host <SMEM_HOST_COUNT && __smem->partitions[host]) { phdr = __smem->partitions[host]; - ret = phdr->offset_free_cached - phdr->offset_free_uncached; + ret =le32_to_cpu (phdr->offset_free_cached) - +le32_to_cpu (phdr->offset_free_uncached); }else { header = __smem->regions[0 ].virt_base; - ret = header->available; + ret =le32_to_cpu (header->available); }return ret;
@@ -512,7 +552,7 @@ EXPORT_SYMBOL(qcom_smem_get_free_space);static int qcom_smem_get_sbl_version (struct qcom_smem *smem) { -unsigned *versions; +__le32 *versions;size_t size; versions =qcom_smem_get_global (smem,SMEM_ITEM_VERSION , &size);
@@ -526,7 +566,7 @@ static int qcom_smem_get_sbl_version(struct qcom_smem *smem)return -EINVAL ; } -return versions[SMEM_MASTER_SBL_VERSION_INDEX ]; +return le32_to_cpu (versions[SMEM_MASTER_SBL_VERSION_INDEX ]); } static int qcom_smem_enumerate_partitions(struct qcom_smem *smem,
@@ -536,35 +576,38 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem,struct smem_ptable_entry *entry;struct smem_ptable *ptable;unsigned remote_host; +u32 version, host0, host1;int i; ptable = smem->regions[0 ].virt_base + smem->regions[0 ].size -SZ_4K ; -if (ptable->magic !=SMEM_PTABLE_MAGIC ) +if (memcmp (ptable->magic,SMEM_PTABLE_MAGIC ,sizeof (ptable->magic)))return 0 ; -if (ptable->version !=1 ) { + version =le32_to_cpu (ptable->version); +if (version !=1 ) {dev_err (smem->dev, -"Unsupported partition header version %d\n" , - ptable->version); +"Unsupported partition header version %d\n" , version);return -EINVAL ; } -for (i =0 ; i < ptable->num_entries; i++) { +for (i =0 ; i <le32_to_cpu (ptable->num_entries); i++) { entry = &ptable->entry[i]; + host0 =le16_to_cpu (entry->host0); + host1 =le16_to_cpu (entry->host1); -if (entry->host0 != local_host && entry->host1 != local_host) +if (host0 != local_host && host1 != local_host)continue ; -if (!entry->offset) +if (!le32_to_cpu (entry->offset))continue ; -if (!entry->size) +if (!le32_to_cpu (entry->size))continue ; -if (entry->host0 == local_host) - remote_host = entry->host1; +if (host0 == local_host) + remote_host = host1;else - remote_host = entry->host0; + remote_host = host0;if (remote_host >=SMEM_HOST_COUNT ) { dev_err(smem->dev,
@@ -580,21 +623,24 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem,return -EINVAL ; } - header = smem->regions[0 ].virt_base + entry->offset; + header = smem->regions[0 ].virt_base +le32_to_cpu (entry->offset); + host0 =le16_to_cpu (header->host0); + host1 =le16_to_cpu (header->host1); -if (header->magic !=SMEM_PART_MAGIC ) { +if (memcmp (header->magic,SMEM_PART_MAGIC , +sizeof (header->magic))) {dev_err (smem->dev,"Partition %d has invalid magic\n" , i);return -EINVAL ; } -if (header->host0 != local_host && header->host1 != local_host) { +if (host0 != local_host && host1 != local_host) {dev_err (smem->dev,"Partition %d hosts are invalid\n" , i);return -EINVAL ; } -if (header->host0 != remote_host && header->host1 != remote_host) { +if (host0 != remote_host && host1 != remote_host) {dev_err (smem->dev,"Partition %d hosts are invalid\n" , i);return -EINVAL ;
@@ -606,7 +652,7 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem,return -EINVAL ; } -if (header->offset_free_uncached > header->size) { +if (le32_to_cpu (header->offset_free_uncached) >le32_to_cpu (header->size)) {dev_err (smem->dev,"Partition %d has invalid free pointer\n" , i);return -EINVAL ;
@@ -690,7 +736,8 @@ static int qcom_smem_probe(struct platform_device *pdev) } header = smem->regions[0 ].virt_base; -if (header->initialized !=1 || header->reserved) { +if (le32_to_cpu (header->initialized) !=1 || +le32_to_cpu (header->reserved)) {dev_err (&pdev->dev,"SMEM is not initialized by SBL\n" );return -EINVAL ; }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 2/8] soc: qcom: smem: Handle big endian CPUs
Quoted 5 lines · Stephen Boyd
The contents of smem are always in little endian, but the smem driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
PATCH v2 3/8 soc: qcom: smd: Represent channel layout in structures
In reply to Stephen BoydThe 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.
---
Changes from v1:
* Renamed structures smd_channel_info{_word}_pair
drivers/soc/qcom/smd.c | 61 +++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 28 deletions(-)
drivers/soc/qcom/smd.c +33 -28
@@ -65,7 +65,9 @@*/ struct smd_channel_info ; +struct smd_channel_info_pair ;struct smd_channel_info_word ; +struct smd_channel_info_word_pair ;#define SMD_ALLOC_TBL_COUNT 2#define SMD_ALLOC_TBL_SIZE 64
@@ -151,10 +153,8 @@ enum smd_channel_state {* @name: name of the channel * @state: local state of the channel * @remote_state: remote state of the channel -* @tx_info: byte aligned outgoing channel info -* @rx_info: byte aligned incoming channel info -* @tx_info_word: word aligned outgoing channel info -* @rx_info_word: word aligned incoming channel info +* @info: byte aligned outgoing/incoming channel info +* @info_word: word aligned outgoing/incoming channel info * @tx_lock: lock to make writes to the channel mutually exclusive * @fblockread_event: wakeup event tied to tx fBLOCKREADINTR * @tx_fifo: pointer to the outgoing ring buffer
@@ -175,11 +175,8 @@ struct qcom_smd_channel {enum smd_channel_state state;enum smd_channel_state remote_state; -struct smd_channel_info *tx_info; -struct smd_channel_info *rx_info; - -struct smd_channel_info_word *tx_info_word; -struct smd_channel_info_word *rx_info_word; +struct smd_channel_info_pair *info; +struct smd_channel_info_word_pair *info_word;struct mutex tx_lock;wait_queue_head_t fblockread_event;
@@ -228,6 +225,11 @@ struct smd_channel_info {u32 head; }; +struct smd_channel_info_pair { +struct smd_channel_info tx; +struct smd_channel_info rx; +}; +/* * Format of the smd_info smem items, for word aligned channels. */
@@ -245,25 +247,30 @@ struct smd_channel_info_word {u32 head; }; +struct smd_channel_info_word_pair { +struct smd_channel_info_word tx; +struct smd_channel_info_word rx; +}; +#define GET_RX_CHANNEL_INFO (channel, param) \ - (channel->rx_info_word ? \ - channel->rx_info_word->param : \ - channel->rx_info->param) + (channel->info_word ? \ + channel->info_word->rx.param : \ + channel->info->rx.param)#define SET_RX_CHANNEL_INFO (channel, param, value) \ - (channel->rx_info_word ? \ - (channel->rx_info_word->param = value) : \ - (channel->rx_info->param = value)) + (channel->info_word ? \ + (channel->info_word->rx.param = value) : \ + (channel->info->rx.param = value))#define GET_TX_CHANNEL_INFO (channel, param) \ - (channel->tx_info_word ? \ - channel->tx_info_word->param : \ - channel->tx_info->param) + (channel->info_word ? \ + channel->info_word->tx.param : \ + channel->info->tx.param)#define SET_TX_CHANNEL_INFO (channel, param, value) \ - (channel->tx_info_word ? \ - (channel->tx_info_word->param = value) : \ - (channel->tx_info->param = value)) + (channel->info_word ? \ + (channel->info_word->tx.param = value) : \ + (channel->info->tx.param = value))/** * struct qcom_smd_alloc_entry - channel allocation entry
@@ -412,7 +419,7 @@ static size_t qcom_smd_channel_peek(struct qcom_smd_channel *channel,unsigned tail;size_t len; - word_aligned = channel->rx_info_word !=NULL ; + word_aligned = channel->info_word; tail =GET_RX_CHANNEL_INFO (channel, tail); 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,unsigned head;size_t len; - word_aligned = channel->tx_info_word !=NULL ; + word_aligned = channel->info_word; head =GET_TX_CHANNEL_INFO (channel, head); 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)int ret;/* Word aligned channels only accept word size aligned data */ -if (channel->rx_info_word !=NULL && len %4 ) +if (channel->info_word && len %4 )return -EINVAL ; ret =mutex_lock_interruptible (&channel->tx_lock);
@@ -989,11 +996,9 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed* use. */ if (info_size ==2 *sizeof (struct smd_channel_info_word )) { - channel->tx_info_word = info; - channel->rx_info_word = info +sizeof (struct smd_channel_info_word ); + channel->info_word = info; }else if (info_size ==2 *sizeof (struct smd_channel_info )) { - channel->tx_info = info; - channel->rx_info = info +sizeof (struct smd_channel_info ); + channel->info = info; }else {dev_err (smd->dev,"channel info of size %zu not supported\n" , info_size);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 4/8 soc: qcom: smd: Use __iowrite32_copy() instead of open-coding it
In reply to Stephen BoydWe already have a function to do this and it silences some sparse warnings along the way.
---
No changes
drivers/soc/qcom/smd.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/soc/qcom/smd.c +4 -9
@@ -371,20 +371,15 @@ static void qcom_smd_channel_set_state(struct qcom_smd_channel *channel,/* * Copy count bytes of data using 32bit accesses, if that's required. */ -static void smd_copy_to_fifo (void __iomem *_dst, -const void *_src, +static void smd_copy_to_fifo (void __iomem *dst, +const void *src,size_t count,bool word_aligned) { -u32 *dst = (u32 *)_dst; -u32 *src = (u32 *)_src; -if (word_aligned) { - count /=sizeof (u32); -while (count--) -writel_relaxed (*src++, dst++); +__iowrite32_copy (dst, src, count /sizeof (u32)); }else { -memcpy_toio (_dst, _src, count); +memcpy_toio (dst, src, count); } }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 5/8 soc: qcom: smd: Remove use of VLAIS
In reply to Stephen BoydUsage of VLAIS prevents clang from compiling this file, and it also opens us to the possibility of allocating a large structure on the stack to the point that we blow past the limit of the kernel stack. Remove the VLAIS and allocate a structure on the heap with kmalloc so that we're safer and more clang friendly.
---
Changes from v1:
* New patch
drivers/soc/qcom/smd-rpm.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
drivers/soc/qcom/smd-rpm.c +19 -13
@@ -17,6 +17,7 @@#include <linux/of_platform.h> #include <linux/io.h> #include <linux/interrupt.h> +#include <linux/slab.h> #include <linux/soc/qcom/smd.h> #include <linux/soc/qcom/smd-rpm.h>
@@ -104,30 +105,34 @@ int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm,static unsigned msg_id =1 ;int left;int ret; -struct {struct qcom_rpm_header hdr;struct qcom_rpm_request req; -u8 payload[count]; - } pkt; +u8 payload[]; + } *pkt; +size_t size =sizeof (*pkt) + count;/* SMD packets to the RPM may not exceed 256 bytes */ -if (WARN_ON (sizeof (pkt) >=256 )) +if (WARN_ON (size >=256 ))return -EINVAL ; + pkt =kmalloc (size,GFP_KERNEL ); +if (!pkt) +return -ENOMEM ; +mutex_lock (&rpm->lock); - pkt.hdr.service_type =RPM_SERVICE_TYPE_REQUEST ; - pkt.hdr.length =sizeof (struct qcom_rpm_request ) + count; + pkt->hdr.service_type =RPM_SERVICE_TYPE_REQUEST ; + pkt->hdr.length =sizeof (struct qcom_rpm_request ) + count; - pkt.req.msg_id = msg_id++; - pkt.req.flags =BIT (state); - pkt.req.type = type; - pkt.req.id = id; - pkt.req.data_len = count; -memcpy (pkt.payload, buf, count); + pkt->req.msg_id = msg_id++; + pkt->req.flags =BIT (state); + pkt->req.type = type; + pkt->req.id = id; + pkt->req.data_len = count; +memcpy (pkt->payload, buf, count); - ret =qcom_smd_send (rpm->rpm_channel, &pkt,sizeof (pkt)); + ret =qcom_smd_send (rpm->rpm_channel, pkt,sizeof (*pkt));if (ret) goto out;
@@ -138,6 +143,7 @@ int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm, ret = rpm->ack_status; out: +kfree (pkt);mutex_unlock (&rpm->lock);return ret; }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 5/8] soc: qcom: smd: Remove use of VLAIS
Quoted 6 lines · Stephen Boyd
Usage of VLAIS prevents clang from compiling this file, and it also opens us to the possibility of allocating a large structure on the stack to the point that we blow past the limit of the kernel stack. Remove the VLAIS and allocate a structure on the heap with kmalloc so that we're safer and more clang friendly.
Re: [PATCH v2 5/8] soc: qcom: smd: Remove use of VLAIS
In reply to Stephen BoydQuoted 6 lines · Stephen Boyd
Usage of VLAIS prevents clang from compiling this file, and it also opens us to the possibility of allocating a large structure on the stack to the point that we blow past the limit of the kernel stack. Remove the VLAIS and allocate a structure on the heap with kmalloc so that we're safer and more clang friendly.
[..]
Quoted 1 line
drivers/soc/qcom/smd-rpm.c +0
-0
[..]
Quoted 9 lines
drivers/soc/qcom/smd-rpm.c +3
-2struct {struct qcom_rpm_header hdr;struct qcom_rpm_request req; -u8 payload[count]; - } pkt; +u8 payload[]; + } *pkt; +size_t size =sizeof (*pkt) + count;
[..]
drivers/soc/qcom/smd-rpm.c int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm, · line 135
Quoted 3 lines
drivers/soc/qcom/smd-rpm.c +1
-1- ret =qcom_smd_send (rpm->rpm_channel, &pkt,sizeof (pkt)); + ret =qcom_smd_send (rpm->rpm_channel, pkt,sizeof (*pkt));
It would be good if we actually include the request in the packet and not just the headers :)
s/sizeof(*pkt)/size/
Sorry for not spotting this before, made my device not boot now that it showed up in linux-next. And oddly the 8974 RPM seems to just ack the messages, without any indication of the request being truncated...
@Andy, I presume this is only on your -next, can you update the commit? Or do you want a patch for it?
With this tiny change what we have on next-20150921 seems to work fine.
Regards,
Bjorn
Re: [PATCH v2 5/8] soc: qcom: smd: Remove use of VLAIS
Quoted 30 lines · Bjorn Andersson
Quoted 6 lines · Stephen Boyd
Usage of VLAIS prevents clang from compiling this file, and it also opens us to the possibility of allocating a large structure on the stack to the point that we blow past the limit of the kernel stack. Remove the VLAIS and allocate a structure on the heap with kmalloc so that we're safer and more clang friendly.
[..]
Quoted 1 line
drivers/soc/qcom/smd-rpm.c +0
-0[..]
Quoted 9 lines
drivers/soc/qcom/smd-rpm.c +3
-2struct {struct qcom_rpm_header hdr;struct qcom_rpm_request req; -u8 payload[count]; - } pkt; +u8 payload[]; + } *pkt; +size_t size =sizeof (*pkt) + count;[..]
drivers/soc/qcom/smd-rpm.c int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm, · line 135
Quoted 3 lines
drivers/soc/qcom/smd-rpm.c +1
-1- ret =qcom_smd_send (rpm->rpm_channel, &pkt,sizeof (pkt)); + ret =qcom_smd_send (rpm->rpm_channel, pkt,sizeof (*pkt));It would be good if we actually include the request in the packet and not just the headers :)
s/sizeof(*pkt)/size/
Quoted 7 lines
Sorry for not spotting this before, made my device not boot now that it showed up in linux-next. And oddly the 8974 RPM seems to just ack the messages, without any indication of the request being truncated...
@Andy, I presume this is only on your -next, can you update the commit? Or do you want a patch for it?
I can fix it up.
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 6/8 soc: qcom: smd: Handle big endian CPUs
In reply to Stephen BoydThe smd structures are always in little endian, but the smd driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
---
Changes from v1:
* hdr and pkt_len marked as __le32
* FLAG instead of INFO8
drivers/soc/qcom/smd.c | 181 +++++++++++++++++++++++++++++++------------------ 1 file changed, 116 insertions(+), 65 deletions(-)
drivers/soc/qcom/smd.c +116 -65
@@ -212,7 +212,7 @@ struct qcom_smd {* Format of the smd_info smem items, for byte aligned channels. */ struct smd_channel_info { -u32 state; +__le32 state;u8 fDSR;u8 fCTS;u8 fCD;
@@ -221,8 +221,8 @@ struct smd_channel_info {u8 fTAIL;u8 fSTATE;u8 fBLOCKREADINTR; -u32 tail; -u32 head; +__le32 tail; +__le32 head; };struct smd_channel_info_pair {
@@ -234,17 +234,17 @@ struct smd_channel_info_pair {* Format of the smd_info smem items, for word aligned channels. */ struct smd_channel_info_word { -u32 state; -u32 fDSR; -u32 fCTS; -u32 fCD; -u32 fRI; -u32 fHEAD; -u32 fTAIL; -u32 fSTATE; -u32 fBLOCKREADINTR; -u32 tail; -u32 head; +__le32 state; +__le32 fDSR; +__le32 fCTS; +__le32 fCD; +__le32 fRI; +__le32 fHEAD; +__le32 fTAIL; +__le32 fSTATE; +__le32 fBLOCKREADINTR; +__le32 tail; +__le32 head; };struct smd_channel_info_word_pair {
@@ -252,25 +252,73 @@ struct smd_channel_info_word_pair {struct smd_channel_info_word rx; }; -#define GET_RX_CHANNEL_INFO (channel, param) \ - (channel->info_word ? \ - channel->info_word->rx.param : \ - channel->info->rx.param) - -#define SET_RX_CHANNEL_INFO (channel, param, value) \ - (channel->info_word ? \ - (channel->info_word->rx.param = value) : \ - (channel->info->rx.param = value)) - -#define GET_TX_CHANNEL_INFO (channel, param) \ - (channel->info_word ? \ - channel->info_word->tx.param : \ - channel->info->tx.param) - -#define SET_TX_CHANNEL_INFO (channel, param, value) \ - (channel->info_word ? \ - (channel->info_word->tx.param = value) : \ - (channel->info->tx.param = value)) +#define GET_RX_CHANNEL_FLAG (channel, param) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->rx.param) != sizeof(u8)); \ + channel->info_word ? \ + le32_to_cpu(channel->info_word->rx.param) : \ + channel->info->rx.param; \ + }) + +#define GET_RX_CHANNEL_INFO (channel, param) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->rx.param) != sizeof(u32)); \ + le32_to_cpu(channel->info_word ? \ + channel->info_word->rx.param : \ + channel->info->rx.param); \ + }) + +#define SET_RX_CHANNEL_FLAG (channel, param, value) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->rx.param) != sizeof(u8)); \ + if (channel->info_word) \ + channel->info_word->rx.param = cpu_to_le32(value); \ + else \ + channel->info->rx.param = value; \ + }) + +#define SET_RX_CHANNEL_INFO (channel, param, value) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->rx.param) != sizeof(u32)); \ + if (channel->info_word) \ + channel->info_word->rx.param = cpu_to_le32(value); \ + else \ + channel->info->rx.param = cpu_to_le32(value); \ + }) + +#define GET_TX_CHANNEL_FLAG (channel, param) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->tx.param) != sizeof(u8)); \ + channel->info_word ? \ + le32_to_cpu(channel->info_word->tx.param) : \ + channel->info->tx.param; \ + }) + +#define GET_TX_CHANNEL_INFO (channel, param) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->tx.param) != sizeof(u32)); \ + le32_to_cpu(channel->info_word ? \ + channel->info_word->tx.param : \ + channel->info->tx.param); \ + }) + +#define SET_TX_CHANNEL_FLAG (channel, param, value) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->tx.param) != sizeof(u8)); \ + if (channel->info_word) \ + channel->info_word->tx.param = cpu_to_le32(value); \ + else \ + channel->info->tx.param = value; \ + }) + +#define SET_TX_CHANNEL_INFO (channel, param, value) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->tx.param) != sizeof(u32)); \ + if (channel->info_word) \ + channel->info_word->tx.param = cpu_to_le32(value); \ + else \ + channel->info->tx.param = cpu_to_le32(value); \ + })/** * struct qcom_smd_alloc_entry - channel allocation entry
@@ -281,9 +329,9 @@ struct smd_channel_info_word_pair {*/ struct qcom_smd_alloc_entry {u8 name[20 ]; -u32 cid; -u32 flags; -u32 ref_count; +__le32 cid; +__le32 flags; +__le32 ref_count; } __packed;#define SMD_CHANNEL_FLAGS_EDGE_MASK 0xff
@@ -312,14 +360,14 @@ static void qcom_smd_signal_channel(struct qcom_smd_channel *channel)static void qcom_smd_channel_reset (struct qcom_smd_channel *channel) {SET_TX_CHANNEL_INFO (channel, state,SMD_CHANNEL_CLOSED ); -SET_TX_CHANNEL_INFO (channel, fDSR,0 ); -SET_TX_CHANNEL_INFO (channel, fCTS,0 ); -SET_TX_CHANNEL_INFO (channel, fCD,0 ); -SET_TX_CHANNEL_INFO (channel, fRI,0 ); -SET_TX_CHANNEL_INFO (channel, fHEAD,0 ); -SET_TX_CHANNEL_INFO (channel, fTAIL,0 ); -SET_TX_CHANNEL_INFO (channel, fSTATE,1 ); -SET_TX_CHANNEL_INFO (channel, fBLOCKREADINTR,0 ); +SET_TX_CHANNEL_FLAG (channel, fDSR,0 ); +SET_TX_CHANNEL_FLAG (channel, fCTS,0 ); +SET_TX_CHANNEL_FLAG (channel, fCD,0 ); +SET_TX_CHANNEL_FLAG (channel, fRI,0 ); +SET_TX_CHANNEL_FLAG (channel, fHEAD,0 ); +SET_TX_CHANNEL_FLAG (channel, fTAIL,0 ); +SET_TX_CHANNEL_FLAG (channel, fSTATE,1 ); +SET_TX_CHANNEL_FLAG (channel, fBLOCKREADINTR,0 );SET_TX_CHANNEL_INFO (channel, head,0 );SET_TX_CHANNEL_INFO (channel, tail,0 );
@@ -357,12 +405,12 @@ static void qcom_smd_channel_set_state(struct qcom_smd_channel *channel,dev_dbg (edge->smd->dev,"set_state(%s, %d)\n" , channel->name, state); -SET_TX_CHANNEL_INFO (channel, fDSR, is_open); -SET_TX_CHANNEL_INFO (channel, fCTS, is_open); -SET_TX_CHANNEL_INFO (channel, fCD, is_open); +SET_TX_CHANNEL_FLAG (channel, fDSR, is_open); +SET_TX_CHANNEL_FLAG (channel, fCTS, is_open); +SET_TX_CHANNEL_FLAG (channel, fCD, is_open);SET_TX_CHANNEL_INFO (channel, state, state); -SET_TX_CHANNEL_INFO (channel, fSTATE,1 ); +SET_TX_CHANNEL_FLAG (channel, fSTATE,1 ); channel->state = state;qcom_smd_signal_channel (channel);
@@ -397,7 +445,7 @@ static void smd_copy_from_fifo(void *_dst,if (word_aligned) { count /=sizeof (u32);while (count--) - *dst++ =readl_relaxed (src++); + *dst++ =__raw_readl (src++); }else {memcpy_fromio (_dst, _src, count); }
@@ -493,7 +541,7 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel) {bool need_state_scan = false;int remote_state; -u32 pktlen; +__le32 pktlen;int avail;int ret;
@@ -504,10 +552,10 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel) need_state_scan = true; }/* Indicate that we have seen any state change */ -SET_RX_CHANNEL_INFO (channel, fSTATE,0 ); +SET_RX_CHANNEL_FLAG (channel, fSTATE,0 );/* Signal waiting qcom_smd_send() about the interrupt */ -if (!GET_TX_CHANNEL_INFO (channel, fBLOCKREADINTR)) +if (!GET_TX_CHANNEL_FLAG (channel, fBLOCKREADINTR))wake_up_interruptible (&channel->fblockread_event);/* Don't consume any data until we've opened the channel */
@@ -515,7 +563,7 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel) goto out;/* Indicate that we've seen the new data */ -SET_RX_CHANNEL_INFO (channel, fHEAD,0 ); +SET_RX_CHANNEL_FLAG (channel, fHEAD,0 );/* Consume data */ for (;;) {
@@ -524,7 +572,7 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel)if (!channel->pkt_size && avail >=SMD_PACKET_HEADER_LEN ) {qcom_smd_channel_peek (channel, &pktlen,sizeof (pktlen));qcom_smd_channel_advance (channel,SMD_PACKET_HEADER_LEN ); - channel->pkt_size = pktlen; + channel->pkt_size =le32_to_cpu (pktlen); }else if (channel->pkt_size && avail >= channel->pkt_size) { ret =qcom_smd_channel_recv_single (channel);if (ret)
@@ -535,10 +583,10 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel) }/* Indicate that we have seen and updated tail */ -SET_RX_CHANNEL_INFO (channel, fTAIL,1 ); +SET_RX_CHANNEL_FLAG (channel, fTAIL,1 );/* Signal the remote that we've consumed the data (if requested) */ -if (!GET_RX_CHANNEL_INFO (channel, fBLOCKREADINTR)) { +if (!GET_RX_CHANNEL_FLAG (channel, fBLOCKREADINTR)) {/* Ensure ordering of channel info updates */ wmb ();
@@ -667,7 +715,7 @@ static int qcom_smd_write_fifo(struct qcom_smd_channel *channel,*/ int qcom_smd_send (struct qcom_smd_channel *channel,const void *data,int len) { -u32 hdr[5 ] = {len,}; +__le32 hdr[5 ] = {cpu_to_le32 (len), };int tlen =sizeof (hdr) + len;int ret;
@@ -685,7 +733,7 @@ int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len) goto out; } -SET_TX_CHANNEL_INFO (channel, fBLOCKREADINTR,1 ); +SET_TX_CHANNEL_FLAG (channel, fBLOCKREADINTR,1 ); ret = wait_event_interruptible(channel->fblockread_event, qcom_smd_get_tx_avail(channel) >= tlen ||
@@ -693,15 +741,15 @@ int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len)if (ret) goto out; -SET_TX_CHANNEL_INFO (channel, fBLOCKREADINTR,0 ); +SET_TX_CHANNEL_FLAG (channel, fBLOCKREADINTR,0 ); } -SET_TX_CHANNEL_INFO (channel, fTAIL,0 ); +SET_TX_CHANNEL_FLAG (channel, fTAIL,0 );qcom_smd_write_fifo (channel, hdr,sizeof (hdr));qcom_smd_write_fifo (channel, data, len); -SET_TX_CHANNEL_INFO (channel, fHEAD,1 ); +SET_TX_CHANNEL_FLAG (channel, fHEAD,1 );/* Ensure ordering of channel info updates */ wmb ();
@@ -1044,6 +1092,7 @@ static void qcom_discover_channels(struct qcom_smd_edge *edge)unsigned info_id;int tbl;int i; +u32 eflags, cid;for (tbl =0 ; tbl <SMD_ALLOC_TBL_COUNT ; tbl++) { alloc_tbl = qcom_smem_get(edge->remote_pid,
@@ -1053,6 +1102,7 @@ static void qcom_discover_channels(struct qcom_smd_edge *edge)for (i =0 ; i <SMD_ALLOC_TBL_SIZE ; i++) { entry = &alloc_tbl[i]; + eflags =le32_to_cpu (entry->flags);if (test_bit (i, edge->allocated[tbl]))continue ;
@@ -1062,14 +1112,15 @@ static void qcom_discover_channels(struct qcom_smd_edge *edge)if (!entry->name[0 ])continue ; -if (!(entry->flags &SMD_CHANNEL_FLAGS_PACKET )) +if (!(eflags &SMD_CHANNEL_FLAGS_PACKET ))continue ; -if ((entry->flags &SMD_CHANNEL_FLAGS_EDGE_MASK ) != edge->edge_id) +if ((eflags &SMD_CHANNEL_FLAGS_EDGE_MASK ) != edge->edge_id)continue ; - info_id = smem_items[tbl].info_base_id + entry->cid; - fifo_id = smem_items[tbl].fifo_base_id + entry->cid; + cid =le32_to_cpu (entry->cid); + info_id = smem_items[tbl].info_base_id + cid; + fifo_id = smem_items[tbl].fifo_base_id + cid; channel =qcom_smd_create_channel (edge, info_id, fifo_id, entry->name);if (IS_ERR (channel))
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 6/8] soc: qcom: smd: Handle big endian CPUs
Quoted 5 lines · Stephen Boyd
The smd structures are always in little endian, but the smd driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
PATCH v3 6/8 soc: qcom: smd: Handle big endian CPUs
In reply to Stephen BoydThe smd structures are always in little endian, but the smd driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
---
Changes from v2:
* Respin due to some conflicts that appeared since last posting.
drivers/soc/qcom/smd.c | 181 +++++++++++++++++++++++++++++++------------------ 1 file changed, 116 insertions(+), 65 deletions(-)
drivers/soc/qcom/smd.c +116 -65
@@ -212,7 +212,7 @@ struct qcom_smd {* Format of the smd_info smem items, for byte aligned channels. */ struct smd_channel_info { -u32 state; +__le32 state;u8 fDSR;u8 fCTS;u8 fCD;
@@ -221,8 +221,8 @@ struct smd_channel_info {u8 fTAIL;u8 fSTATE;u8 fBLOCKREADINTR; -u32 tail; -u32 head; +__le32 tail; +__le32 head; };struct smd_channel_info_pair {
@@ -234,17 +234,17 @@ struct smd_channel_info_pair {* Format of the smd_info smem items, for word aligned channels. */ struct smd_channel_info_word { -u32 state; -u32 fDSR; -u32 fCTS; -u32 fCD; -u32 fRI; -u32 fHEAD; -u32 fTAIL; -u32 fSTATE; -u32 fBLOCKREADINTR; -u32 tail; -u32 head; +__le32 state; +__le32 fDSR; +__le32 fCTS; +__le32 fCD; +__le32 fRI; +__le32 fHEAD; +__le32 fTAIL; +__le32 fSTATE; +__le32 fBLOCKREADINTR; +__le32 tail; +__le32 head; };struct smd_channel_info_word_pair {
@@ -252,25 +252,73 @@ struct smd_channel_info_word_pair {struct smd_channel_info_word rx; }; -#define GET_RX_CHANNEL_INFO (channel, param) \ - (channel->info_word ? \ - channel->info_word->rx.param : \ - channel->info->rx.param) - -#define SET_RX_CHANNEL_INFO (channel, param, value) \ - (channel->info_word ? \ - (channel->info_word->rx.param = value) : \ - (channel->info->rx.param = value)) - -#define GET_TX_CHANNEL_INFO (channel, param) \ - (channel->info_word ? \ - channel->info_word->tx.param : \ - channel->info->tx.param) - -#define SET_TX_CHANNEL_INFO (channel, param, value) \ - (channel->info_word ? \ - (channel->info_word->tx.param = value) : \ - (channel->info->tx.param = value)) +#define GET_RX_CHANNEL_FLAG (channel, param) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->rx.param) != sizeof(u8)); \ + channel->info_word ? \ + le32_to_cpu(channel->info_word->rx.param) : \ + channel->info->rx.param; \ + }) + +#define GET_RX_CHANNEL_INFO (channel, param) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->rx.param) != sizeof(u32)); \ + le32_to_cpu(channel->info_word ? \ + channel->info_word->rx.param : \ + channel->info->rx.param); \ + }) + +#define SET_RX_CHANNEL_FLAG (channel, param, value) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->rx.param) != sizeof(u8)); \ + if (channel->info_word) \ + channel->info_word->rx.param = cpu_to_le32(value); \ + else \ + channel->info->rx.param = value; \ + }) + +#define SET_RX_CHANNEL_INFO (channel, param, value) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->rx.param) != sizeof(u32)); \ + if (channel->info_word) \ + channel->info_word->rx.param = cpu_to_le32(value); \ + else \ + channel->info->rx.param = cpu_to_le32(value); \ + }) + +#define GET_TX_CHANNEL_FLAG (channel, param) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->tx.param) != sizeof(u8)); \ + channel->info_word ? \ + le32_to_cpu(channel->info_word->tx.param) : \ + channel->info->tx.param; \ + }) + +#define GET_TX_CHANNEL_INFO (channel, param) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->tx.param) != sizeof(u32)); \ + le32_to_cpu(channel->info_word ? \ + channel->info_word->tx.param : \ + channel->info->tx.param); \ + }) + +#define SET_TX_CHANNEL_FLAG (channel, param, value) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->tx.param) != sizeof(u8)); \ + if (channel->info_word) \ + channel->info_word->tx.param = cpu_to_le32(value); \ + else \ + channel->info->tx.param = value; \ + }) + +#define SET_TX_CHANNEL_INFO (channel, param, value) \ + ({ \ + BUILD_BUG_ON(sizeof(channel->info->tx.param) != sizeof(u32)); \ + if (channel->info_word) \ + channel->info_word->tx.param = cpu_to_le32(value); \ + else \ + channel->info->tx.param = cpu_to_le32(value); \ + })/** * struct qcom_smd_alloc_entry - channel allocation entry
@@ -281,9 +329,9 @@ struct smd_channel_info_word_pair {*/ struct qcom_smd_alloc_entry {u8 name[20 ]; -u32 cid; -u32 flags; -u32 ref_count; +__le32 cid; +__le32 flags; +__le32 ref_count; } __packed;#define SMD_CHANNEL_FLAGS_EDGE_MASK 0xff
@@ -312,14 +360,14 @@ static void qcom_smd_signal_channel(struct qcom_smd_channel *channel)static void qcom_smd_channel_reset (struct qcom_smd_channel *channel) {SET_TX_CHANNEL_INFO (channel, state,SMD_CHANNEL_CLOSED ); -SET_TX_CHANNEL_INFO (channel, fDSR,0 ); -SET_TX_CHANNEL_INFO (channel, fCTS,0 ); -SET_TX_CHANNEL_INFO (channel, fCD,0 ); -SET_TX_CHANNEL_INFO (channel, fRI,0 ); -SET_TX_CHANNEL_INFO (channel, fHEAD,0 ); -SET_TX_CHANNEL_INFO (channel, fTAIL,0 ); -SET_TX_CHANNEL_INFO (channel, fSTATE,1 ); -SET_TX_CHANNEL_INFO (channel, fBLOCKREADINTR,1 ); +SET_TX_CHANNEL_FLAG (channel, fDSR,0 ); +SET_TX_CHANNEL_FLAG (channel, fCTS,0 ); +SET_TX_CHANNEL_FLAG (channel, fCD,0 ); +SET_TX_CHANNEL_FLAG (channel, fRI,0 ); +SET_TX_CHANNEL_FLAG (channel, fHEAD,0 ); +SET_TX_CHANNEL_FLAG (channel, fTAIL,0 ); +SET_TX_CHANNEL_FLAG (channel, fSTATE,1 ); +SET_TX_CHANNEL_FLAG (channel, fBLOCKREADINTR,1 );SET_TX_CHANNEL_INFO (channel, head,0 );SET_TX_CHANNEL_INFO (channel, tail,0 );
@@ -357,12 +405,12 @@ static void qcom_smd_channel_set_state(struct qcom_smd_channel *channel,dev_dbg (edge->smd->dev,"set_state(%s, %d)\n" , channel->name, state); -SET_TX_CHANNEL_INFO (channel, fDSR, is_open); -SET_TX_CHANNEL_INFO (channel, fCTS, is_open); -SET_TX_CHANNEL_INFO (channel, fCD, is_open); +SET_TX_CHANNEL_FLAG (channel, fDSR, is_open); +SET_TX_CHANNEL_FLAG (channel, fCTS, is_open); +SET_TX_CHANNEL_FLAG (channel, fCD, is_open);SET_TX_CHANNEL_INFO (channel, state, state); -SET_TX_CHANNEL_INFO (channel, fSTATE,1 ); +SET_TX_CHANNEL_FLAG (channel, fSTATE,1 ); channel->state = state;qcom_smd_signal_channel (channel);
@@ -397,7 +445,7 @@ static void smd_copy_from_fifo(void *_dst,if (word_aligned) { count /=sizeof (u32);while (count--) - *dst++ =readl_relaxed (src++); + *dst++ =__raw_readl (src++); }else {memcpy_fromio (_dst, _src, count); }
@@ -493,7 +541,7 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel) {bool need_state_scan = false;int remote_state; -u32 pktlen; +__le32 pktlen;int avail;int ret;
@@ -504,10 +552,10 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel) need_state_scan = true; }/* Indicate that we have seen any state change */ -SET_RX_CHANNEL_INFO (channel, fSTATE,0 ); +SET_RX_CHANNEL_FLAG (channel, fSTATE,0 );/* Signal waiting qcom_smd_send() about the interrupt */ -if (!GET_TX_CHANNEL_INFO (channel, fBLOCKREADINTR)) +if (!GET_TX_CHANNEL_FLAG (channel, fBLOCKREADINTR))wake_up_interruptible (&channel->fblockread_event);/* Don't consume any data until we've opened the channel */
@@ -515,7 +563,7 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel) goto out;/* Indicate that we've seen the new data */ -SET_RX_CHANNEL_INFO (channel, fHEAD,0 ); +SET_RX_CHANNEL_FLAG (channel, fHEAD,0 );/* Consume data */ for (;;) {
@@ -524,7 +572,7 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel)if (!channel->pkt_size && avail >=SMD_PACKET_HEADER_LEN ) {qcom_smd_channel_peek (channel, &pktlen,sizeof (pktlen));qcom_smd_channel_advance (channel,SMD_PACKET_HEADER_LEN ); - channel->pkt_size = pktlen; + channel->pkt_size =le32_to_cpu (pktlen); }else if (channel->pkt_size && avail >= channel->pkt_size) { ret =qcom_smd_channel_recv_single (channel);if (ret)
@@ -535,10 +583,10 @@ static bool qcom_smd_channel_intr(struct qcom_smd_channel *channel) }/* Indicate that we have seen and updated tail */ -SET_RX_CHANNEL_INFO (channel, fTAIL,1 ); +SET_RX_CHANNEL_FLAG (channel, fTAIL,1 );/* Signal the remote that we've consumed the data (if requested) */ -if (!GET_RX_CHANNEL_INFO (channel, fBLOCKREADINTR)) { +if (!GET_RX_CHANNEL_FLAG (channel, fBLOCKREADINTR)) {/* Ensure ordering of channel info updates */ wmb ();
@@ -667,7 +715,7 @@ static int qcom_smd_write_fifo(struct qcom_smd_channel *channel,*/ int qcom_smd_send (struct qcom_smd_channel *channel,const void *data,int len) { -u32 hdr[5 ] = {len,}; +__le32 hdr[5 ] = {cpu_to_le32 (len), };int tlen =sizeof (hdr) + len;int ret;
@@ -685,7 +733,7 @@ int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len) goto out; } -SET_TX_CHANNEL_INFO (channel, fBLOCKREADINTR,0 ); +SET_TX_CHANNEL_FLAG (channel, fBLOCKREADINTR,0 ); ret = wait_event_interruptible(channel->fblockread_event, qcom_smd_get_tx_avail(channel) >= tlen ||
@@ -693,15 +741,15 @@ int qcom_smd_send(struct qcom_smd_channel *channel, const void *data, int len)if (ret) goto out; -SET_TX_CHANNEL_INFO (channel, fBLOCKREADINTR,1 ); +SET_TX_CHANNEL_FLAG (channel, fBLOCKREADINTR,1 ); } -SET_TX_CHANNEL_INFO (channel, fTAIL,0 ); +SET_TX_CHANNEL_FLAG (channel, fTAIL,0 );qcom_smd_write_fifo (channel, hdr,sizeof (hdr));qcom_smd_write_fifo (channel, data, len); -SET_TX_CHANNEL_INFO (channel, fHEAD,1 ); +SET_TX_CHANNEL_FLAG (channel, fHEAD,1 );/* Ensure ordering of channel info updates */ wmb ();
@@ -1044,6 +1092,7 @@ static void qcom_discover_channels(struct qcom_smd_edge *edge)unsigned info_id;int tbl;int i; +u32 eflags, cid;for (tbl =0 ; tbl <SMD_ALLOC_TBL_COUNT ; tbl++) { alloc_tbl = qcom_smem_get(edge->remote_pid,
@@ -1053,6 +1102,7 @@ static void qcom_discover_channels(struct qcom_smd_edge *edge)for (i =0 ; i <SMD_ALLOC_TBL_SIZE ; i++) { entry = &alloc_tbl[i]; + eflags =le32_to_cpu (entry->flags);if (test_bit (i, edge->allocated[tbl]))continue ;
@@ -1062,14 +1112,15 @@ static void qcom_discover_channels(struct qcom_smd_edge *edge)if (!entry->name[0 ])continue ; -if (!(entry->flags &SMD_CHANNEL_FLAGS_PACKET )) +if (!(eflags &SMD_CHANNEL_FLAGS_PACKET ))continue ; -if ((entry->flags &SMD_CHANNEL_FLAGS_EDGE_MASK ) != edge->edge_id) +if ((eflags &SMD_CHANNEL_FLAGS_EDGE_MASK ) != edge->edge_id)continue ; - info_id = smem_items[tbl].info_base_id + entry->cid; - fifo_id = smem_items[tbl].fifo_base_id + entry->cid; + cid =le32_to_cpu (entry->cid); + info_id = smem_items[tbl].info_base_id + cid; + fifo_id = smem_items[tbl].fifo_base_id + cid; channel =qcom_smd_create_channel (edge, info_id, fifo_id, entry->name);if (IS_ERR (channel))
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 7/8 soc: qcom: smd_rpm: Handle big endian CPUs
In reply to Stephen BoydThe smd rpm structures are always in little endian, but this driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
---
Changes from v1:
* New patch
drivers/soc/qcom/smd-rpm.c | 50 ++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 24 deletions(-)
drivers/soc/qcom/smd-rpm.c +26 -24
@@ -45,8 +45,8 @@ struct qcom_smd_rpm {* @length: length of the payload */ struct qcom_rpm_header { -u32 service_type; -u32 length; +__le32 service_type; +__le32 length; };/**
@@ -58,11 +58,11 @@ struct qcom_rpm_header {* @data_len: length of the payload following this header */ struct qcom_rpm_request { -u32 msg_id; -u32 flags; -u32 type; -u32 id; -u32 data_len; +__le32 msg_id; +__le32 flags; +__le32 type; +__le32 id; +__le32 data_len; };/**
@@ -75,10 +75,10 @@ struct qcom_rpm_request {* Multiple of these messages can be stacked in an rpm message. */ struct qcom_rpm_message { -u32 msg_type; -u32 length; +__le32 msg_type; +__le32 length;union { -u32 msg_id; +__le32 msg_id;u8 message[0 ]; }; };
@@ -122,14 +122,14 @@ int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm,mutex_lock (&rpm->lock); - pkt->hdr.service_type =RPM_SERVICE_TYPE_REQUEST ; - pkt->hdr.length =sizeof (struct qcom_rpm_request ) + count; + pkt->hdr.service_type =cpu_to_le32 (RPM_SERVICE_TYPE_REQUEST ); + pkt->hdr.length =cpu_to_le32 (sizeof (struct qcom_rpm_request ) + count); - pkt->req.msg_id = msg_id++; - pkt->req.flags =BIT (state); - pkt->req.type = type; - pkt->req.id = id; - pkt->req.data_len = count; + pkt->req.msg_id =cpu_to_le32 (msg_id++); + pkt->req.flags =cpu_to_le32 (BIT (state)); + pkt->req.type =cpu_to_le32 (type); + pkt->req.id =cpu_to_le32 (id); + pkt->req.data_len =cpu_to_le32 (count);memcpy (pkt->payload, buf, count); ret =qcom_smd_send (rpm->rpm_channel, pkt,sizeof (*pkt));
@@ -154,27 +154,29 @@ static int qcom_smd_rpm_callback(struct qcom_smd_device *qsdev, size_t count) {const struct qcom_rpm_header *hdr = data; +size_t hdr_length =le32_to_cpu (hdr->length);const struct qcom_rpm_message *msg;struct qcom_smd_rpm *rpm =dev_get_drvdata (&qsdev->dev);const u8 *buf = data +sizeof (struct qcom_rpm_header ); -const u8 *end = buf + hdr->length; +const u8 *end = buf + hdr_length;char msgbuf[32 ];int status =0 ; -u32 len; +u32 len, msg_length; -if (hdr->service_type !=RPM_SERVICE_TYPE_REQUEST || - hdr->length <sizeof (struct qcom_rpm_message )) { +if (le32_to_cpu (hdr->service_type) !=RPM_SERVICE_TYPE_REQUEST || + hdr_length <sizeof (struct qcom_rpm_message )) {dev_err (&qsdev->dev,"invalid request\n" );return 0 ; }while (buf < end) { msg = (struct qcom_rpm_message *)buf; -switch (msg->msg_type) { + msg_length =le32_to_cpu (msg->length); +switch (le32_to_cpu (msg->msg_type)) {case RPM_MSG_TYPE_MSG_ID :break ;case RPM_MSG_TYPE_ERR : - len =min_t (u32,ALIGN (msg->length,4 ),sizeof (msgbuf)); + len =min_t (u32,ALIGN (msg_length,4 ),sizeof (msgbuf));memcpy_fromio (msgbuf, msg->message, len); msgbuf[len -1 ] =0 ;
@@ -185,7 +187,7 @@ static int qcom_smd_rpm_callback(struct qcom_smd_device *qsdev,break ; } - buf =PTR_ALIGN (buf +2 *sizeof (u32) + msg->length,4 ); + buf =PTR_ALIGN (buf +2 *sizeof (u32) + msg_length,4 ); } rpm->ack_status = status;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 7/8] soc: qcom: smd_rpm: Handle big endian CPUs
Quoted 5 lines · Stephen Boyd
The smd rpm structures are always in little endian, but this driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
PATCH v2 8/8 regulator: qcom_smd: Handle big endian CPUs
In reply to Stephen BoydThe smd rpm structures are always in little endian, but this driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
---
Changes from v1:
* New patch
drivers/regulator/qcom_smd-regulator.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/regulator/qcom_smd-regulator.c +14 -14
@@ -36,9 +36,9 @@ struct qcom_rpm_reg { };struct rpm_regulator_req { -u32 key; -u32 nbytes; -u32 value; +__le32 key; +__le32 nbytes; +__le32 value; };#define RPM_KEY_SWEN 0x6e657773/* "swen" */
@@ -62,9 +62,9 @@ static int rpm_reg_enable(struct regulator_dev *rdev)struct rpm_regulator_req req;int ret; - req.key =RPM_KEY_SWEN ; - req.nbytes =sizeof (u32); - req.value =1 ; + req.key =cpu_to_le32 (RPM_KEY_SWEN ); + req.nbytes =cpu_to_le32 (sizeof (u32)); + req.value =cpu_to_le32 (1 ); ret =rpm_reg_write_active (vreg, &req,sizeof (req));if (!ret)
@@ -86,8 +86,8 @@ static int rpm_reg_disable(struct regulator_dev *rdev)struct rpm_regulator_req req;int ret; - req.key =RPM_KEY_SWEN ; - req.nbytes =sizeof (u32); + req.key =cpu_to_le32 (RPM_KEY_SWEN ); + req.nbytes =cpu_to_le32 (sizeof (u32)); req.value =0 ; ret =rpm_reg_write_active (vreg, &req,sizeof (req));
@@ -113,9 +113,9 @@ static int rpm_reg_set_voltage(struct regulator_dev *rdev,struct rpm_regulator_req req;int ret =0 ; - req.key =RPM_KEY_UV ; - req.nbytes =sizeof (u32); - req.value = min_uV; + req.key =cpu_to_le32 (RPM_KEY_UV ); + req.nbytes =cpu_to_le32 (sizeof (u32)); + req.value =cpu_to_le32 (min_uV); ret =rpm_reg_write_active (vreg, &req,sizeof (req));if (!ret)
@@ -129,9 +129,9 @@ static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA)struct qcom_rpm_reg *vreg =rdev_get_drvdata (rdev);struct rpm_regulator_req req; - req.key =RPM_KEY_MA ; - req.nbytes =sizeof (u32); - req.value = load_uA; + req.key =cpu_to_le32 (RPM_KEY_MA ); + req.nbytes =cpu_to_le32 (sizeof (u32)); + req.value =cpu_to_le32 (load_uA);return rpm_reg_write_active (vreg, &req,sizeof (req)); }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Mark Brown
maintainerApplied "regulator: qcom_smd: Handle big endian CPUs" to the regulator tree
The patch
regulator: qcom_smd: Handle big endian CPUs
has been applied to the regulator tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
2c652a98ca556cca7749c184f0246315367bfad4Mon Sep 17 00:00:00 2001
From: Stephen Boyd <[email protected]>
Date: Wed, 2 Sep 2015 15:46:51 -0700
Subject: [PATCH] regulator: qcom_smd: Handle big endian CPUs
The smd rpm structures are always in little endian, but this driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
--- drivers/regulator/qcom_smd-regulator.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/regulator/qcom_smd-regulator.c +14 -14
@@ -36,9 +36,9 @@ struct qcom_rpm_reg { };struct rpm_regulator_req { -u32 key; -u32 nbytes; -u32 value; +__le32 key; +__le32 nbytes; +__le32 value; };#define RPM_KEY_SWEN 0x6e657773/* "swen" */
@@ -62,9 +62,9 @@ static int rpm_reg_enable(struct regulator_dev *rdev)struct rpm_regulator_req req;int ret; - req.key =RPM_KEY_SWEN ; - req.nbytes =sizeof (u32); - req.value =1 ; + req.key =cpu_to_le32 (RPM_KEY_SWEN ); + req.nbytes =cpu_to_le32 (sizeof (u32)); + req.value =cpu_to_le32 (1 ); ret =rpm_reg_write_active (vreg, &req,sizeof (req));if (!ret)
@@ -86,8 +86,8 @@ static int rpm_reg_disable(struct regulator_dev *rdev)struct rpm_regulator_req req;int ret; - req.key =RPM_KEY_SWEN ; - req.nbytes =sizeof (u32); + req.key =cpu_to_le32 (RPM_KEY_SWEN ); + req.nbytes =cpu_to_le32 (sizeof (u32)); req.value =0 ; ret =rpm_reg_write_active (vreg, &req,sizeof (req));
@@ -113,9 +113,9 @@ static int rpm_reg_set_voltage(struct regulator_dev *rdev,struct rpm_regulator_req req;int ret =0 ; - req.key =RPM_KEY_UV ; - req.nbytes =sizeof (u32); - req.value = min_uV; + req.key =cpu_to_le32 (RPM_KEY_UV ); + req.nbytes =cpu_to_le32 (sizeof (u32)); + req.value =cpu_to_le32 (min_uV); ret =rpm_reg_write_active (vreg, &req,sizeof (req));if (!ret)
@@ -129,9 +129,9 @@ static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA)struct qcom_rpm_reg *vreg =rdev_get_drvdata (rdev);struct rpm_regulator_req req; - req.key =RPM_KEY_MA ; - req.nbytes =sizeof (u32); - req.value = load_uA; + req.key =cpu_to_le32 (RPM_KEY_MA ); + req.nbytes =cpu_to_le32 (sizeof (u32)); + req.value =cpu_to_le32 (load_uA);return rpm_reg_write_active (vreg, &req,sizeof (req)); }
Signature · 1 line
2.5.0
Re: [PATCH v2 8/8] regulator: qcom_smd: Handle big endian CPUs
In reply to Stephen BoydQuoted 5 lines · Stephen Boyd
The smd rpm structures are always in little endian, but this driver is not capable of being used on big endian CPUs. Annotate the little endian data members and update the code to do the proper byte swapping.
Quoted 12 lines · Stephen Boyd
This supersedes the 3 "series" of patches to move smem to big endian, smd to big endian, and make
qcom_smem_get()return a pointer.I've moved the
qcom_smem_get()returning a pointer part to the beginning of the series so it can be applied earlier if desired. I imagine the first 7 patches can go through arm-soc, and the last patch Mark can pick up anytime. All patches tested on apq8074 dragonboard.I've already written the patches to add
__ioread32_copy(), but I'm holding them until -rc1 drops because I'd rather not involve even more people in this series just yet.
All of these look fine to me.
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project