public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 RESEND 0/3] soc: qcom: extend interface for big endian support
@ 2025-11-18  6:53 Alexander Wilhelm
  2025-11-18  6:53 ` [PATCH v4 RESEND 1/3] soc: qcom: introduce new QMI encode/decode macros Alexander Wilhelm
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Alexander Wilhelm @ 2025-11-18  6:53 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio; +Cc: linux-arm-msm, linux-kernel

Currently, the QMI interface only works on little endian systems due to how
it encodes and decodes data. Most QMI related data structures are defined
in CPU native order and do not use endian specific types.

Add support for endian conversion of basic element types in the QMI
encoding and decoding logic. Fix the handling of QMI_DATA_LEN fields to
ensure correct interpretation on big endian systems. These changes are
required to allow QMI to operate correctly across architectures with
different endianness.
---
Changes in v4:
- Rebase on latest ath master.
- Drop ath12k patch to make a standalone one.
- Remove `Fixes:` tags as big endian is not yet supported.

Changes in v3:
- Rebase on latest ath master.
- Using a generic encoding/decoding macro causes sparse to complain about
  type violations. Use separate macros for each basic element type instead.

Changes in v2:
- Handle QMI conversion within the QMI subsystem instead of the driver.

Alexander Wilhelm (3):
  soc: qcom: introduce new QMI encode/decode macros
  soc: qcom: fix QMI encoding/decoding for basic elements
  soc: qcom: preserve CPU endianness for QMI_DATA_LEN

 drivers/soc/qcom/qmi_encdec.c | 101 ++++++++++++++++++++++++++++------
 1 file changed, 84 insertions(+), 17 deletions(-)


base-commit: 38cf754c15eeb0d80fbf52c933da10edb33d7906
-- 
2.43.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v4 RESEND 1/3] soc: qcom: introduce new QMI encode/decode macros
  2025-11-18  6:53 [PATCH v4 RESEND 0/3] soc: qcom: extend interface for big endian support Alexander Wilhelm
@ 2025-11-18  6:53 ` Alexander Wilhelm
  2025-11-19  8:04   ` Dmitry Baryshkov
  2025-11-18  6:53 ` [PATCH v4 RESEND 2/3] soc: qcom: fix QMI encoding/decoding for basic elements Alexander Wilhelm
  2025-11-18  6:53 ` [PATCH v4 RESEND 3/3] soc: qcom: preserve CPU endianness for QMI_DATA_LEN Alexander Wilhelm
  2 siblings, 1 reply; 9+ messages in thread
From: Alexander Wilhelm @ 2025-11-18  6:53 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio; +Cc: linux-arm-msm, linux-kernel

Introduce new QMI encode/decode macros for each basic element type. It
allows us to further distribute and handle endianness conversion of basic
element types of different size.

Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
---
 drivers/soc/qcom/qmi_encdec.c | 56 +++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/drivers/soc/qcom/qmi_encdec.c b/drivers/soc/qcom/qmi_encdec.c
index 7660a960fb45..1f9091458d72 100644
--- a/drivers/soc/qcom/qmi_encdec.c
+++ b/drivers/soc/qcom/qmi_encdec.c
@@ -30,6 +30,34 @@ do { \
 	p_src = (u8 *)p_src + size; \
 } while (0)
 
+#define QMI_ENCDEC_ENCODE_U8(p_dst, p_src) \
+do { \
+	memcpy(p_dst, p_src, sizeof(u8)); \
+	p_dst = (u8 *)p_dst + sizeof(u8); \
+	p_src = (u8 *)p_src + sizeof(u8); \
+} while (0)
+
+#define QMI_ENCDEC_ENCODE_U16(p_dst, p_src) \
+do { \
+	*(__le16 *)p_dst = __cpu_to_le16(*(u16 *)p_src); \
+	p_dst = (u8 *)p_dst + sizeof(u16); \
+	p_src = (u8 *)p_src + sizeof(u16); \
+} while (0)
+
+#define QMI_ENCDEC_ENCODE_U32(p_dst, p_src) \
+do { \
+	*(__le32 *)p_dst = __cpu_to_le32(*(u32 *)p_src); \
+	p_dst = (u8 *)p_dst + sizeof(u32); \
+	p_src = (u8 *)p_src + sizeof(u32); \
+} while (0)
+
+#define QMI_ENCDEC_ENCODE_U64(p_dst, p_src) \
+do { \
+	*(__le64 *)p_dst = __cpu_to_le64(*(u64 *)p_src); \
+	p_dst = (u8 *)p_dst + sizeof(u64); \
+	p_src = (u8 *)p_src + sizeof(u64); \
+} while (0)
+
 #define QMI_ENCDEC_DECODE_N_BYTES(p_dst, p_src, size) \
 do { \
 	memcpy(p_dst, p_src, size); \
@@ -37,6 +65,34 @@ do { \
 	p_src = (u8 *)p_src + size; \
 } while (0)
 
+#define QMI_ENCDEC_DECODE_U8(p_dst, p_src) \
+do { \
+	memcpy(p_dst, p_src, sizeof(u8)); \
+	p_dst = (u8 *)p_dst + sizeof(u8); \
+	p_src = (u8 *)p_src + sizeof(u8); \
+} while (0)
+
+#define QMI_ENCDEC_DECODE_U16(p_dst, p_src) \
+do { \
+	*(u16 *)p_dst = __le16_to_cpu(*(__le16 *)p_src); \
+	p_dst = (u8 *)p_dst + sizeof(u16); \
+	p_src = (u8 *)p_src + sizeof(u16); \
+} while (0)
+
+#define QMI_ENCDEC_DECODE_U32(p_dst, p_src) \
+do { \
+	*(u32 *)p_dst = __le32_to_cpu(*(__le32 *)p_src); \
+	p_dst = (u8 *)p_dst + sizeof(u32); \
+	p_src = (u8 *)p_src + sizeof(u32); \
+} while (0)
+
+#define QMI_ENCDEC_DECODE_U64(p_dst, p_src) \
+do { \
+	*(u64 *)p_dst = __le64_to_cpu(*(__le64 *)p_src); \
+	p_dst = (u8 *)p_dst + sizeof(u64); \
+	p_src = (u8 *)p_src + sizeof(u64); \
+} while (0)
+
 #define UPDATE_ENCODE_VARIABLES(temp_si, buf_dst, \
 				encoded_bytes, tlv_len, encode_tlv, rc) \
 do { \
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 RESEND 2/3] soc: qcom: fix QMI encoding/decoding for basic elements
  2025-11-18  6:53 [PATCH v4 RESEND 0/3] soc: qcom: extend interface for big endian support Alexander Wilhelm
  2025-11-18  6:53 ` [PATCH v4 RESEND 1/3] soc: qcom: introduce new QMI encode/decode macros Alexander Wilhelm
@ 2025-11-18  6:53 ` Alexander Wilhelm
  2025-11-19  8:03   ` Dmitry Baryshkov
  2025-11-18  6:53 ` [PATCH v4 RESEND 3/3] soc: qcom: preserve CPU endianness for QMI_DATA_LEN Alexander Wilhelm
  2 siblings, 1 reply; 9+ messages in thread
From: Alexander Wilhelm @ 2025-11-18  6:53 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio; +Cc: linux-arm-msm, linux-kernel

Extend the QMI byte encoding and decoding logic to support multiple basic
data type sizes (u8, u16, u32, u64) using existing macros. Ensure correct
handling of data sizes and proper byte order conversion on big-endian
platforms by consistently applying these macros during encoding and
decoding of basic elements.

Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
---
 drivers/soc/qcom/qmi_encdec.c | 46 +++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/soc/qcom/qmi_encdec.c b/drivers/soc/qcom/qmi_encdec.c
index 1f9091458d72..90a48fa7ecf4 100644
--- a/drivers/soc/qcom/qmi_encdec.c
+++ b/drivers/soc/qcom/qmi_encdec.c
@@ -23,13 +23,6 @@
 	*p_length |= ((u8)*p_src) << 8; \
 } while (0)
 
-#define QMI_ENCDEC_ENCODE_N_BYTES(p_dst, p_src, size) \
-do { \
-	memcpy(p_dst, p_src, size); \
-	p_dst = (u8 *)p_dst + size; \
-	p_src = (u8 *)p_src + size; \
-} while (0)
-
 #define QMI_ENCDEC_ENCODE_U8(p_dst, p_src) \
 do { \
 	memcpy(p_dst, p_src, sizeof(u8)); \
@@ -58,13 +51,6 @@ do { \
 	p_src = (u8 *)p_src + sizeof(u64); \
 } while (0)
 
-#define QMI_ENCDEC_DECODE_N_BYTES(p_dst, p_src, size) \
-do { \
-	memcpy(p_dst, p_src, size); \
-	p_dst = (u8 *)p_dst + size; \
-	p_src = (u8 *)p_src + size; \
-} while (0)
-
 #define QMI_ENCDEC_DECODE_U8(p_dst, p_src) \
 do { \
 	memcpy(p_dst, p_src, sizeof(u8)); \
@@ -225,7 +211,21 @@ static int qmi_encode_basic_elem(void *buf_dst, const void *buf_src,
 	u32 i, rc = 0;
 
 	for (i = 0; i < elem_len; i++) {
-		QMI_ENCDEC_ENCODE_N_BYTES(buf_dst, buf_src, elem_size);
+		switch (elem_size) {
+		case sizeof(u8):
+			QMI_ENCDEC_ENCODE_U8(buf_dst, buf_src);
+			break;
+		case sizeof(u16):
+			QMI_ENCDEC_ENCODE_U16(buf_dst, buf_src);
+			break;
+		case sizeof(u32):
+			QMI_ENCDEC_ENCODE_U32(buf_dst, buf_src);
+			break;
+		case sizeof(u64):
+			QMI_ENCDEC_ENCODE_U64(buf_dst, buf_src);
+			break;
+		}
+
 		rc += elem_size;
 	}
 
@@ -508,7 +508,21 @@ static int qmi_decode_basic_elem(void *buf_dst, const void *buf_src,
 	u32 i, rc = 0;
 
 	for (i = 0; i < elem_len; i++) {
-		QMI_ENCDEC_DECODE_N_BYTES(buf_dst, buf_src, elem_size);
+		switch (elem_size) {
+		case sizeof(u8):
+			QMI_ENCDEC_DECODE_U8(buf_dst, buf_src);
+			break;
+		case sizeof(u16):
+			QMI_ENCDEC_DECODE_U16(buf_dst, buf_src);
+			break;
+		case sizeof(u32):
+			QMI_ENCDEC_DECODE_U32(buf_dst, buf_src);
+			break;
+		case sizeof(u64):
+			QMI_ENCDEC_DECODE_U64(buf_dst, buf_src);
+			break;
+		}
+
 		rc += elem_size;
 	}
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v4 RESEND 3/3] soc: qcom: preserve CPU endianness for QMI_DATA_LEN
  2025-11-18  6:53 [PATCH v4 RESEND 0/3] soc: qcom: extend interface for big endian support Alexander Wilhelm
  2025-11-18  6:53 ` [PATCH v4 RESEND 1/3] soc: qcom: introduce new QMI encode/decode macros Alexander Wilhelm
  2025-11-18  6:53 ` [PATCH v4 RESEND 2/3] soc: qcom: fix QMI encoding/decoding for basic elements Alexander Wilhelm
@ 2025-11-18  6:53 ` Alexander Wilhelm
  2025-11-19  9:06   ` Dmitry Baryshkov
  2 siblings, 1 reply; 9+ messages in thread
From: Alexander Wilhelm @ 2025-11-18  6:53 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio; +Cc: linux-arm-msm, linux-kernel

To ensure correct handling of endianness in the QMI subsystem, the
QMI_DATA_LEN field used in host-side drivers remains in CPU-native byte
order. Remove unnecessary endianness conversions, considering that
QMI_DATA_LEN is always of type `u32` on the host. On the QMI wire
interface, however, its representation is variable and may use either 1 or
2 bytes.

Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
---
 drivers/soc/qcom/qmi_encdec.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/qcom/qmi_encdec.c b/drivers/soc/qcom/qmi_encdec.c
index 90a48fa7ecf4..b92af573e715 100644
--- a/drivers/soc/qcom/qmi_encdec.c
+++ b/drivers/soc/qcom/qmi_encdec.c
@@ -396,6 +396,7 @@ static int qmi_encode(const struct qmi_elem_info *ei_array, void *out_buf,
 			break;
 
 		case QMI_DATA_LEN:
+			memcpy(&data_len_value, buf_src, sizeof(u32));
 			data_len_sz = temp_ei->elem_size == sizeof(u8) ?
 					sizeof(u8) : sizeof(u16);
 			/* Check to avoid out of range buffer access */
@@ -406,13 +407,11 @@ static int qmi_encode(const struct qmi_elem_info *ei_array, void *out_buf,
 				return -ETOOSMALL;
 			}
 			if (data_len_sz == sizeof(u8)) {
-				val8 = *(u8 *)buf_src;
-				data_len_value = (u32)val8;
+				val8 = data_len_value;
 				rc = qmi_encode_basic_elem(buf_dst, &val8,
 							   1, data_len_sz);
 			} else {
-				val16 = *(u16 *)buf_src;
-				data_len_value = (u32)le16_to_cpu(val16);
+				val16 = data_len_value;
 				rc = qmi_encode_basic_elem(buf_dst, &val16,
 							   1, data_len_sz);
 			}
@@ -695,7 +694,6 @@ static int qmi_decode(const struct qmi_elem_info *ei_array, void *out_c_struct,
 	int rc;
 	u8 val8;
 	u16 val16;
-	u32 val32;
 
 	while (decoded_bytes < in_buf_len) {
 		if (dec_level >= 2 && temp_ei->data_type == QMI_EOTI)
@@ -743,8 +741,7 @@ static int qmi_decode(const struct qmi_elem_info *ei_array, void *out_c_struct,
 							   1, data_len_sz);
 				data_len_value = (u32)val16;
 			}
-			val32 = cpu_to_le32(data_len_value);
-			memcpy(buf_dst, &val32, sizeof(u32));
+			memcpy(buf_dst, &data_len_value, sizeof(u32));
 			temp_ei = temp_ei + 1;
 			buf_dst = out_c_struct + temp_ei->offset;
 			tlv_len -= data_len_sz;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 RESEND 2/3] soc: qcom: fix QMI encoding/decoding for basic elements
  2025-11-18  6:53 ` [PATCH v4 RESEND 2/3] soc: qcom: fix QMI encoding/decoding for basic elements Alexander Wilhelm
@ 2025-11-19  8:03   ` Dmitry Baryshkov
  2025-11-19  8:10     ` Alexander Wilhelm
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Baryshkov @ 2025-11-19  8:03 UTC (permalink / raw)
  To: Alexander Wilhelm
  Cc: Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel

On Tue, Nov 18, 2025 at 07:53:40AM +0100, Alexander Wilhelm wrote:
> Extend the QMI byte encoding and decoding logic to support multiple basic
> data type sizes (u8, u16, u32, u64) using existing macros. Ensure correct
> handling of data sizes and proper byte order conversion on big-endian
> platforms by consistently applying these macros during encoding and
> decoding of basic elements.
> 
> Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
> ---
>  drivers/soc/qcom/qmi_encdec.c | 46 +++++++++++++++++++++++------------
>  1 file changed, 30 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/soc/qcom/qmi_encdec.c b/drivers/soc/qcom/qmi_encdec.c
> index 1f9091458d72..90a48fa7ecf4 100644
> --- a/drivers/soc/qcom/qmi_encdec.c
> +++ b/drivers/soc/qcom/qmi_encdec.c
> @@ -23,13 +23,6 @@
>  	*p_length |= ((u8)*p_src) << 8; \
>  } while (0)
>  
> -#define QMI_ENCDEC_ENCODE_N_BYTES(p_dst, p_src, size) \
> -do { \
> -	memcpy(p_dst, p_src, size); \
> -	p_dst = (u8 *)p_dst + size; \
> -	p_src = (u8 *)p_src + size; \
> -} while (0)
> -
>  #define QMI_ENCDEC_ENCODE_U8(p_dst, p_src) \
>  do { \
>  	memcpy(p_dst, p_src, sizeof(u8)); \
> @@ -58,13 +51,6 @@ do { \
>  	p_src = (u8 *)p_src + sizeof(u64); \
>  } while (0)
>  
> -#define QMI_ENCDEC_DECODE_N_BYTES(p_dst, p_src, size) \
> -do { \
> -	memcpy(p_dst, p_src, size); \
> -	p_dst = (u8 *)p_dst + size; \
> -	p_src = (u8 *)p_src + size; \
> -} while (0)
> -
>  #define QMI_ENCDEC_DECODE_U8(p_dst, p_src) \
>  do { \
>  	memcpy(p_dst, p_src, sizeof(u8)); \
> @@ -225,7 +211,21 @@ static int qmi_encode_basic_elem(void *buf_dst, const void *buf_src,
>  	u32 i, rc = 0;
>  
>  	for (i = 0; i < elem_len; i++) {
> -		QMI_ENCDEC_ENCODE_N_BYTES(buf_dst, buf_src, elem_size);
> +		switch (elem_size) {
> +		case sizeof(u8):
> +			QMI_ENCDEC_ENCODE_U8(buf_dst, buf_src);
> +			break;
> +		case sizeof(u16):
> +			QMI_ENCDEC_ENCODE_U16(buf_dst, buf_src);
> +			break;
> +		case sizeof(u32):
> +			QMI_ENCDEC_ENCODE_U32(buf_dst, buf_src);
> +			break;
> +		case sizeof(u64):
> +			QMI_ENCDEC_ENCODE_U64(buf_dst, buf_src);
> +			break;

default: scream?

> +		}
> +
>  		rc += elem_size;
>  	}
>  
> @@ -508,7 +508,21 @@ static int qmi_decode_basic_elem(void *buf_dst, const void *buf_src,
>  	u32 i, rc = 0;
>  
>  	for (i = 0; i < elem_len; i++) {
> -		QMI_ENCDEC_DECODE_N_BYTES(buf_dst, buf_src, elem_size);
> +		switch (elem_size) {
> +		case sizeof(u8):
> +			QMI_ENCDEC_DECODE_U8(buf_dst, buf_src);
> +			break;
> +		case sizeof(u16):
> +			QMI_ENCDEC_DECODE_U16(buf_dst, buf_src);
> +			break;
> +		case sizeof(u32):
> +			QMI_ENCDEC_DECODE_U32(buf_dst, buf_src);
> +			break;
> +		case sizeof(u64):
> +			QMI_ENCDEC_DECODE_U64(buf_dst, buf_src);
> +			break;

same here

> +		}
> +
>  		rc += elem_size;
>  	}
>  
> -- 
> 2.43.0
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 RESEND 1/3] soc: qcom: introduce new QMI encode/decode macros
  2025-11-18  6:53 ` [PATCH v4 RESEND 1/3] soc: qcom: introduce new QMI encode/decode macros Alexander Wilhelm
@ 2025-11-19  8:04   ` Dmitry Baryshkov
  2025-11-19  8:11     ` Alexander Wilhelm
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Baryshkov @ 2025-11-19  8:04 UTC (permalink / raw)
  To: Alexander Wilhelm
  Cc: Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel

On Tue, Nov 18, 2025 at 07:53:39AM +0100, Alexander Wilhelm wrote:
> Introduce new QMI encode/decode macros for each basic element type. It
> allows us to further distribute and handle endianness conversion of basic
> element types of different size.
> 
> Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
> ---
>  drivers/soc/qcom/qmi_encdec.c | 56 +++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)

Nit: I think it might be idiomatic to fold this into the next patch.
Nevertheless:


Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>



-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 RESEND 2/3] soc: qcom: fix QMI encoding/decoding for basic elements
  2025-11-19  8:03   ` Dmitry Baryshkov
@ 2025-11-19  8:10     ` Alexander Wilhelm
  0 siblings, 0 replies; 9+ messages in thread
From: Alexander Wilhelm @ 2025-11-19  8:10 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel

On Wed, Nov 19, 2025 at 10:03:41AM +0200, Dmitry Baryshkov wrote:
> On Tue, Nov 18, 2025 at 07:53:40AM +0100, Alexander Wilhelm wrote:
> > Extend the QMI byte encoding and decoding logic to support multiple basic
> > data type sizes (u8, u16, u32, u64) using existing macros. Ensure correct
> > handling of data sizes and proper byte order conversion on big-endian
> > platforms by consistently applying these macros during encoding and
> > decoding of basic elements.
> > 
> > Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
> > ---
> >  drivers/soc/qcom/qmi_encdec.c | 46 +++++++++++++++++++++++------------
> >  1 file changed, 30 insertions(+), 16 deletions(-)
> > 
> > diff --git a/drivers/soc/qcom/qmi_encdec.c b/drivers/soc/qcom/qmi_encdec.c
> > index 1f9091458d72..90a48fa7ecf4 100644
> > --- a/drivers/soc/qcom/qmi_encdec.c
> > +++ b/drivers/soc/qcom/qmi_encdec.c
> > @@ -23,13 +23,6 @@
> >  	*p_length |= ((u8)*p_src) << 8; \
> >  } while (0)
> >  
> > -#define QMI_ENCDEC_ENCODE_N_BYTES(p_dst, p_src, size) \
> > -do { \
> > -	memcpy(p_dst, p_src, size); \
> > -	p_dst = (u8 *)p_dst + size; \
> > -	p_src = (u8 *)p_src + size; \
> > -} while (0)
> > -
> >  #define QMI_ENCDEC_ENCODE_U8(p_dst, p_src) \
> >  do { \
> >  	memcpy(p_dst, p_src, sizeof(u8)); \
> > @@ -58,13 +51,6 @@ do { \
> >  	p_src = (u8 *)p_src + sizeof(u64); \
> >  } while (0)
> >  
> > -#define QMI_ENCDEC_DECODE_N_BYTES(p_dst, p_src, size) \
> > -do { \
> > -	memcpy(p_dst, p_src, size); \
> > -	p_dst = (u8 *)p_dst + size; \
> > -	p_src = (u8 *)p_src + size; \
> > -} while (0)
> > -
> >  #define QMI_ENCDEC_DECODE_U8(p_dst, p_src) \
> >  do { \
> >  	memcpy(p_dst, p_src, sizeof(u8)); \
> > @@ -225,7 +211,21 @@ static int qmi_encode_basic_elem(void *buf_dst, const void *buf_src,
> >  	u32 i, rc = 0;
> >  
> >  	for (i = 0; i < elem_len; i++) {
> > -		QMI_ENCDEC_ENCODE_N_BYTES(buf_dst, buf_src, elem_size);
> > +		switch (elem_size) {
> > +		case sizeof(u8):
> > +			QMI_ENCDEC_ENCODE_U8(buf_dst, buf_src);
> > +			break;
> > +		case sizeof(u16):
> > +			QMI_ENCDEC_ENCODE_U16(buf_dst, buf_src);
> > +			break;
> > +		case sizeof(u32):
> > +			QMI_ENCDEC_ENCODE_U32(buf_dst, buf_src);
> > +			break;
> > +		case sizeof(u64):
> > +			QMI_ENCDEC_ENCODE_U64(buf_dst, buf_src);
> > +			break;
> 
> default: scream?

Okay, I'll fix that in the next version. What would be the recommended default
approach? The QMI protocol only uses the sizes mentioned above, and previously
the data was simple memcpy'ed.


Best regards
Alexander Wilhelm

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 RESEND 1/3] soc: qcom: introduce new QMI encode/decode macros
  2025-11-19  8:04   ` Dmitry Baryshkov
@ 2025-11-19  8:11     ` Alexander Wilhelm
  0 siblings, 0 replies; 9+ messages in thread
From: Alexander Wilhelm @ 2025-11-19  8:11 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel

On Wed, Nov 19, 2025 at 10:04:27AM +0200, Dmitry Baryshkov wrote:
> On Tue, Nov 18, 2025 at 07:53:39AM +0100, Alexander Wilhelm wrote:
> > Introduce new QMI encode/decode macros for each basic element type. It
> > allows us to further distribute and handle endianness conversion of basic
> > element types of different size.
> > 
> > Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
> > ---
> >  drivers/soc/qcom/qmi_encdec.c | 56 +++++++++++++++++++++++++++++++++++
> >  1 file changed, 56 insertions(+)
> 
> Nit: I think it might be idiomatic to fold this into the next patch.
> Nevertheless:

Sure, I'll do it.

> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> 
> 
> 
> -- 
> With best wishes
> Dmitry


Best regards
Alexander Wilhelm

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 RESEND 3/3] soc: qcom: preserve CPU endianness for QMI_DATA_LEN
  2025-11-18  6:53 ` [PATCH v4 RESEND 3/3] soc: qcom: preserve CPU endianness for QMI_DATA_LEN Alexander Wilhelm
@ 2025-11-19  9:06   ` Dmitry Baryshkov
  0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Baryshkov @ 2025-11-19  9:06 UTC (permalink / raw)
  To: Alexander Wilhelm
  Cc: Bjorn Andersson, Konrad Dybcio, linux-arm-msm, linux-kernel

On Tue, Nov 18, 2025 at 07:53:41AM +0100, Alexander Wilhelm wrote:
> To ensure correct handling of endianness in the QMI subsystem, the
> QMI_DATA_LEN field used in host-side drivers remains in CPU-native byte
> order. Remove unnecessary endianness conversions, considering that
> QMI_DATA_LEN is always of type `u32` on the host. On the QMI wire
> interface, however, its representation is variable and may use either 1 or
> 2 bytes.
> 
> Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
> ---
>  drivers/soc/qcom/qmi_encdec.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-11-19  9:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18  6:53 [PATCH v4 RESEND 0/3] soc: qcom: extend interface for big endian support Alexander Wilhelm
2025-11-18  6:53 ` [PATCH v4 RESEND 1/3] soc: qcom: introduce new QMI encode/decode macros Alexander Wilhelm
2025-11-19  8:04   ` Dmitry Baryshkov
2025-11-19  8:11     ` Alexander Wilhelm
2025-11-18  6:53 ` [PATCH v4 RESEND 2/3] soc: qcom: fix QMI encoding/decoding for basic elements Alexander Wilhelm
2025-11-19  8:03   ` Dmitry Baryshkov
2025-11-19  8:10     ` Alexander Wilhelm
2025-11-18  6:53 ` [PATCH v4 RESEND 3/3] soc: qcom: preserve CPU endianness for QMI_DATA_LEN Alexander Wilhelm
2025-11-19  9:06   ` Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox