Re: [PATCH] soc: qcom: cmd-db: Make endian-agnostic

2018-04-17 Thread Lina Iyer

On Tue, Apr 17 2018 at 11:22 -0600, Lina Iyer wrote:

On Thu, Apr 12 2018 at 16:41 -0600, Stephen Boyd wrote:

This driver deals with memory that is stored in little-endian format.
Update the structures with the proper little-endian types and then
do the proper conversions when reading the fields. Note that we compare
the ids with a memcmp() because we already pad out the string 'id' field
to exactly 8 bytes with the strncpy() onto the stack.

Cc: Mahesh Sivasubramanian 
Cc: Lina Iyer 
Cc: Bjorn Andersson 
Cc: Evan Green 
Signed-off-by: Stephen Boyd 
---

Changes from inline patch:
* Fixed magic
* Made function for memcmp()
*

drivers/soc/qcom/cmd-db.c | 116 +-
1 file changed, 65 insertions(+), 51 deletions(-)

@@ -99,8 +90,34 @@ struct cmd_db_header {
* h/w accelerator and request a resource state.
*/

+static const char CMD_DB_MAGIC[] = { 0xdb, 0x30, 0x03, 0x0c };
+

This works now.


+static bool cmd_db_magic_matches(struct cmd_db_header *header)
+{
+   __le32 *magic = >magic_num;
+
+   return memcmp(magic, CMD_DB_MAGIC, sizeof(CMD_DB_MAGIC)) == 0;
+}
+
static struct cmd_db_header *cmd_db_header;

Could  you move this up, along with other declarations?


+
+static inline void *rsc_to_entry_header(struct rsc_hdr *hdr)
+{
+   u16 offset = le16_to_cpu(hdr->header_offset);
+
+   return cmd_db_header->data + offset;


I noticed that the data was incorrect, with the above and I did it to
read the correct data.


Spoke too soon. Let me test more and report.
-- Lina


return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset);

+}
+
+static inline void *
+rsc_offset(struct rsc_hdr *hdr, struct entry_header *ent)
+{
+   u16 offset = le16_to_cpu(hdr->header_offset);
+   u16 loffset = le16_to_cpu(ent->offset);
+
+   return cmd_db_header->data + offset + loffset;

As well here -
return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset +
loffset);

+}
+


Thanks,
Lina



Re: [PATCH] soc: qcom: cmd-db: Make endian-agnostic

2018-04-17 Thread Lina Iyer

On Tue, Apr 17 2018 at 11:22 -0600, Lina Iyer wrote:

On Thu, Apr 12 2018 at 16:41 -0600, Stephen Boyd wrote:

This driver deals with memory that is stored in little-endian format.
Update the structures with the proper little-endian types and then
do the proper conversions when reading the fields. Note that we compare
the ids with a memcmp() because we already pad out the string 'id' field
to exactly 8 bytes with the strncpy() onto the stack.

Cc: Mahesh Sivasubramanian 
Cc: Lina Iyer 
Cc: Bjorn Andersson 
Cc: Evan Green 
Signed-off-by: Stephen Boyd 
---

Changes from inline patch:
* Fixed magic
* Made function for memcmp()
*

drivers/soc/qcom/cmd-db.c | 116 +-
1 file changed, 65 insertions(+), 51 deletions(-)

@@ -99,8 +90,34 @@ struct cmd_db_header {
* h/w accelerator and request a resource state.
*/

+static const char CMD_DB_MAGIC[] = { 0xdb, 0x30, 0x03, 0x0c };
+

This works now.


+static bool cmd_db_magic_matches(struct cmd_db_header *header)
+{
+   __le32 *magic = >magic_num;
+
+   return memcmp(magic, CMD_DB_MAGIC, sizeof(CMD_DB_MAGIC)) == 0;
+}
+
static struct cmd_db_header *cmd_db_header;

Could  you move this up, along with other declarations?


+
+static inline void *rsc_to_entry_header(struct rsc_hdr *hdr)
+{
+   u16 offset = le16_to_cpu(hdr->header_offset);
+
+   return cmd_db_header->data + offset;


I noticed that the data was incorrect, with the above and I did it to
read the correct data.


Spoke too soon. Let me test more and report.
-- Lina


return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset);

+}
+
+static inline void *
+rsc_offset(struct rsc_hdr *hdr, struct entry_header *ent)
+{
+   u16 offset = le16_to_cpu(hdr->header_offset);
+   u16 loffset = le16_to_cpu(ent->offset);
+
+   return cmd_db_header->data + offset + loffset;

As well here -
return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset +
loffset);

+}
+


Thanks,
Lina



Re: [PATCH] soc: qcom: cmd-db: Make endian-agnostic

2018-04-17 Thread Lina Iyer

On Thu, Apr 12 2018 at 16:41 -0600, Stephen Boyd wrote:

This driver deals with memory that is stored in little-endian format.
Update the structures with the proper little-endian types and then
do the proper conversions when reading the fields. Note that we compare
the ids with a memcmp() because we already pad out the string 'id' field
to exactly 8 bytes with the strncpy() onto the stack.

Cc: Mahesh Sivasubramanian 
Cc: Lina Iyer 
Cc: Bjorn Andersson 
Cc: Evan Green 
Signed-off-by: Stephen Boyd 
---

Changes from inline patch:
* Fixed magic
* Made function for memcmp()
*

drivers/soc/qcom/cmd-db.c | 116 +-
1 file changed, 65 insertions(+), 51 deletions(-)

@@ -99,8 +90,34 @@ struct cmd_db_header {
 * h/w accelerator and request a resource state.
 */

+static const char CMD_DB_MAGIC[] = { 0xdb, 0x30, 0x03, 0x0c };
+

This works now.


+static bool cmd_db_magic_matches(struct cmd_db_header *header)
+{
+   __le32 *magic = >magic_num;
+
+   return memcmp(magic, CMD_DB_MAGIC, sizeof(CMD_DB_MAGIC)) == 0;
+}
+
static struct cmd_db_header *cmd_db_header;

Could  you move this up, along with other declarations?


+
+static inline void *rsc_to_entry_header(struct rsc_hdr *hdr)
+{
+   u16 offset = le16_to_cpu(hdr->header_offset);
+
+   return cmd_db_header->data + offset;


I noticed that the data was incorrect, with the above and I did it to
read the correct data.

return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset);

+}
+
+static inline void *
+rsc_offset(struct rsc_hdr *hdr, struct entry_header *ent)
+{
+   u16 offset = le16_to_cpu(hdr->header_offset);
+   u16 loffset = le16_to_cpu(ent->offset);
+
+   return cmd_db_header->data + offset + loffset;

As well here -
return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset +
loffset);

+}
+


Thanks,
Lina



Re: [PATCH] soc: qcom: cmd-db: Make endian-agnostic

2018-04-17 Thread Lina Iyer

On Thu, Apr 12 2018 at 16:41 -0600, Stephen Boyd wrote:

This driver deals with memory that is stored in little-endian format.
Update the structures with the proper little-endian types and then
do the proper conversions when reading the fields. Note that we compare
the ids with a memcmp() because we already pad out the string 'id' field
to exactly 8 bytes with the strncpy() onto the stack.

Cc: Mahesh Sivasubramanian 
Cc: Lina Iyer 
Cc: Bjorn Andersson 
Cc: Evan Green 
Signed-off-by: Stephen Boyd 
---

Changes from inline patch:
* Fixed magic
* Made function for memcmp()
*

drivers/soc/qcom/cmd-db.c | 116 +-
1 file changed, 65 insertions(+), 51 deletions(-)

@@ -99,8 +90,34 @@ struct cmd_db_header {
 * h/w accelerator and request a resource state.
 */

+static const char CMD_DB_MAGIC[] = { 0xdb, 0x30, 0x03, 0x0c };
+

This works now.


+static bool cmd_db_magic_matches(struct cmd_db_header *header)
+{
+   __le32 *magic = >magic_num;
+
+   return memcmp(magic, CMD_DB_MAGIC, sizeof(CMD_DB_MAGIC)) == 0;
+}
+
static struct cmd_db_header *cmd_db_header;

Could  you move this up, along with other declarations?


+
+static inline void *rsc_to_entry_header(struct rsc_hdr *hdr)
+{
+   u16 offset = le16_to_cpu(hdr->header_offset);
+
+   return cmd_db_header->data + offset;


I noticed that the data was incorrect, with the above and I did it to
read the correct data.

return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset);

+}
+
+static inline void *
+rsc_offset(struct rsc_hdr *hdr, struct entry_header *ent)
+{
+   u16 offset = le16_to_cpu(hdr->header_offset);
+   u16 loffset = le16_to_cpu(ent->offset);
+
+   return cmd_db_header->data + offset + loffset;

As well here -
return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset +
loffset);

+}
+


Thanks,
Lina



Re: [PATCH] soc: qcom: cmd-db: Make endian-agnostic

2018-04-16 Thread Evan Green
On Thu, Apr 12, 2018 at 3:41 PM Stephen Boyd  wrote:

> This driver deals with memory that is stored in little-endian format.
> Update the structures with the proper little-endian types and then
> do the proper conversions when reading the fields. Note that we compare
> the ids with a memcmp() because we already pad out the string 'id' field
> to exactly 8 bytes with the strncpy() onto the stack.

> Cc: Mahesh Sivasubramanian 
> Cc: Lina Iyer 
> Cc: Bjorn Andersson 
> Cc: Evan Green 
> Signed-off-by: Stephen Boyd 
> ---

> Changes from inline patch:
>   * Fixed magic
>   * Made function for memcmp()
>   *

>   drivers/soc/qcom/cmd-db.c | 116 +-
>   1 file changed, 65 insertions(+), 51 deletions(-)

> Sent by a computer through tubes


Reviewed-by: Evan Green 


Re: [PATCH] soc: qcom: cmd-db: Make endian-agnostic

2018-04-16 Thread Evan Green
On Thu, Apr 12, 2018 at 3:41 PM Stephen Boyd  wrote:

> This driver deals with memory that is stored in little-endian format.
> Update the structures with the proper little-endian types and then
> do the proper conversions when reading the fields. Note that we compare
> the ids with a memcmp() because we already pad out the string 'id' field
> to exactly 8 bytes with the strncpy() onto the stack.

> Cc: Mahesh Sivasubramanian 
> Cc: Lina Iyer 
> Cc: Bjorn Andersson 
> Cc: Evan Green 
> Signed-off-by: Stephen Boyd 
> ---

> Changes from inline patch:
>   * Fixed magic
>   * Made function for memcmp()
>   *

>   drivers/soc/qcom/cmd-db.c | 116 +-
>   1 file changed, 65 insertions(+), 51 deletions(-)

> Sent by a computer through tubes


Reviewed-by: Evan Green