mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4] bus: mhi: host: fix endianness of BHI vector table
@ 2025-05-19 14:58 Alexander Wilhelm
  2025-05-20  4:04 ` Krishna Chaitanya Chundru
  2025-06-17 10:39 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Wilhelm @ 2025-05-19 14:58 UTC (permalink / raw)
  To: Manivannan Sadhasivam; +Cc: Jeff Hugo, mhi, linux-arm-msm, linux-kernel

On big endian platform like PowerPC the MHI bus does not start properly.
The following example shows the error messages by using qcn9274 wireless
radio module with ath12k driver:

    ath12k_pci 0001:01:00.0: BAR 0: assigned [mem 0xc00000000-0xc001fffff 64bit]
    ath12k_pci 0001:01:00.0: MSI vectors: 1
    ath12k_pci 0001:01:00.0: Hardware name: qcn9274 hw2.0
    ath12k_pci 0001:01:00.0: failed to set mhi state: POWER_ON(2)
    ath12k_pci 0001:01:00.0: failed to start mhi: -110
    ath12k_pci 0001:01:00.0: failed to power up :-110
    ath12k_pci 0001:01:00.0: failed to create soc core: -110
    ath12k_pci 0001:01:00.0: failed to init core: -110
    ath12k_pci: probe of 0001:01:00.0 failed with error -110

Fix it by swapping DMA address and size of the BHI vector table.

Fixes: 6cd330ae76ff ("bus: mhi: core: Add support for ringing channel/event ring doorbells")
Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
---
Changes in v2:
  - Set __le64 type for dma_addr and size.

Changes in v3:
  - Improve the clarity of the commit message.

Changes in v4:
  - Add missing fixes tag.
  - Fix commit message character width.

 drivers/bus/mhi/host/boot.c     | 8 ++++----
 drivers/bus/mhi/host/internal.h | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/mhi/host/boot.c b/drivers/bus/mhi/host/boot.c
index efa3b6dddf4d..205d83ac069f 100644
--- a/drivers/bus/mhi/host/boot.c
+++ b/drivers/bus/mhi/host/boot.c
@@ -31,8 +31,8 @@ int mhi_rddm_prepare(struct mhi_controller *mhi_cntrl,
 	int ret;
 
 	for (i = 0; i < img_info->entries - 1; i++, mhi_buf++, bhi_vec++) {
-		bhi_vec->dma_addr = mhi_buf->dma_addr;
-		bhi_vec->size = mhi_buf->len;
+		bhi_vec->dma_addr = cpu_to_le64(mhi_buf->dma_addr);
+		bhi_vec->size = cpu_to_le64(mhi_buf->len);
 	}
 
 	dev_dbg(dev, "BHIe programming for RDDM\n");
@@ -431,8 +431,8 @@ static void mhi_firmware_copy_bhie(struct mhi_controller *mhi_cntrl,
 	while (remainder) {
 		to_cpy = min(remainder, mhi_buf->len);
 		memcpy(mhi_buf->buf, buf, to_cpy);
-		bhi_vec->dma_addr = mhi_buf->dma_addr;
-		bhi_vec->size = to_cpy;
+		bhi_vec->dma_addr = cpu_to_le64(mhi_buf->dma_addr);
+		bhi_vec->size = cpu_to_le64(to_cpy);
 
 		buf += to_cpy;
 		remainder -= to_cpy;
diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/internal.h
index ce566f7d2e92..1dbc3f736161 100644
--- a/drivers/bus/mhi/host/internal.h
+++ b/drivers/bus/mhi/host/internal.h
@@ -25,8 +25,8 @@ struct mhi_ctxt {
 };
 
 struct bhi_vec_entry {
-	u64 dma_addr;
-	u64 size;
+	__le64 dma_addr;
+	__le64 size;
 };
 
 enum mhi_fw_load_type {
-- 
2.34.1


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

* Re: [PATCH v4] bus: mhi: host: fix endianness of BHI vector table
  2025-05-19 14:58 [PATCH v4] bus: mhi: host: fix endianness of BHI vector table Alexander Wilhelm
@ 2025-05-20  4:04 ` Krishna Chaitanya Chundru
  2025-06-17 10:39 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Krishna Chaitanya Chundru @ 2025-05-20  4:04 UTC (permalink / raw)
  To: Alexander Wilhelm, Manivannan Sadhasivam
  Cc: Jeff Hugo, mhi, linux-arm-msm, linux-kernel



On 5/19/2025 8:28 PM, Alexander Wilhelm wrote:
> On big endian platform like PowerPC the MHI bus does not start properly.
> The following example shows the error messages by using qcn9274 wireless
> radio module with ath12k driver:
> 
>      ath12k_pci 0001:01:00.0: BAR 0: assigned [mem 0xc00000000-0xc001fffff 64bit]
>      ath12k_pci 0001:01:00.0: MSI vectors: 1
>      ath12k_pci 0001:01:00.0: Hardware name: qcn9274 hw2.0
>      ath12k_pci 0001:01:00.0: failed to set mhi state: POWER_ON(2)
>      ath12k_pci 0001:01:00.0: failed to start mhi: -110
>      ath12k_pci 0001:01:00.0: failed to power up :-110
>      ath12k_pci 0001:01:00.0: failed to create soc core: -110
>      ath12k_pci 0001:01:00.0: failed to init core: -110
>      ath12k_pci: probe of 0001:01:00.0 failed with error -110
> 
> Fix it by swapping DMA address and size of the BHI vector table.
> 
> Fixes: 6cd330ae76ff ("bus: mhi: core: Add support for ringing channel/event ring doorbells")
> Signed-off-by: Alexander Wilhelm <alexander.wilhelm@westermo.com>
> Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
> ---
> Changes in v2:
>    - Set __le64 type for dma_addr and size.
> 
> Changes in v3:
>    - Improve the clarity of the commit message.
> 
> Changes in v4:
>    - Add missing fixes tag.
>    - Fix commit message character width.
> 
>   drivers/bus/mhi/host/boot.c     | 8 ++++----
>   drivers/bus/mhi/host/internal.h | 4 ++--
>   2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/bus/mhi/host/boot.c b/drivers/bus/mhi/host/boot.c
> index efa3b6dddf4d..205d83ac069f 100644
> --- a/drivers/bus/mhi/host/boot.c
> +++ b/drivers/bus/mhi/host/boot.c
> @@ -31,8 +31,8 @@ int mhi_rddm_prepare(struct mhi_controller *mhi_cntrl,
>   	int ret;
>   
>   	for (i = 0; i < img_info->entries - 1; i++, mhi_buf++, bhi_vec++) {
> -		bhi_vec->dma_addr = mhi_buf->dma_addr;
> -		bhi_vec->size = mhi_buf->len;
> +		bhi_vec->dma_addr = cpu_to_le64(mhi_buf->dma_addr);
> +		bhi_vec->size = cpu_to_le64(mhi_buf->len);
>   	}
>   
>   	dev_dbg(dev, "BHIe programming for RDDM\n");
> @@ -431,8 +431,8 @@ static void mhi_firmware_copy_bhie(struct mhi_controller *mhi_cntrl,
>   	while (remainder) {
>   		to_cpy = min(remainder, mhi_buf->len);
>   		memcpy(mhi_buf->buf, buf, to_cpy);
> -		bhi_vec->dma_addr = mhi_buf->dma_addr;
> -		bhi_vec->size = to_cpy;
> +		bhi_vec->dma_addr = cpu_to_le64(mhi_buf->dma_addr);
> +		bhi_vec->size = cpu_to_le64(to_cpy);
>   
>   		buf += to_cpy;
>   		remainder -= to_cpy;
> diff --git a/drivers/bus/mhi/host/internal.h b/drivers/bus/mhi/host/internal.h
> index ce566f7d2e92..1dbc3f736161 100644
> --- a/drivers/bus/mhi/host/internal.h
> +++ b/drivers/bus/mhi/host/internal.h
> @@ -25,8 +25,8 @@ struct mhi_ctxt {
>   };
>   
>   struct bhi_vec_entry {
> -	u64 dma_addr;
> -	u64 size;
> +	__le64 dma_addr;
> +	__le64 size;
>   };
>   
>   enum mhi_fw_load_type {

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

* Re: [PATCH v4] bus: mhi: host: fix endianness of BHI vector table
  2025-05-19 14:58 [PATCH v4] bus: mhi: host: fix endianness of BHI vector table Alexander Wilhelm
  2025-05-20  4:04 ` Krishna Chaitanya Chundru
@ 2025-06-17 10:39 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2025-06-17 10:39 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Alexander Wilhelm
  Cc: Jeff Hugo, mhi, linux-arm-msm, linux-kernel


On Mon, 19 May 2025 16:58:37 +0200, Alexander Wilhelm wrote:
> On big endian platform like PowerPC the MHI bus does not start properly.
> The following example shows the error messages by using qcn9274 wireless
> radio module with ath12k driver:
> 
>     ath12k_pci 0001:01:00.0: BAR 0: assigned [mem 0xc00000000-0xc001fffff 64bit]
>     ath12k_pci 0001:01:00.0: MSI vectors: 1
>     ath12k_pci 0001:01:00.0: Hardware name: qcn9274 hw2.0
>     ath12k_pci 0001:01:00.0: failed to set mhi state: POWER_ON(2)
>     ath12k_pci 0001:01:00.0: failed to start mhi: -110
>     ath12k_pci 0001:01:00.0: failed to power up :-110
>     ath12k_pci 0001:01:00.0: failed to create soc core: -110
>     ath12k_pci 0001:01:00.0: failed to init core: -110
>     ath12k_pci: probe of 0001:01:00.0 failed with error -110
> 
> [...]

Applied, thanks!

[1/1] bus: mhi: host: fix endianness of BHI vector table
      commit: 3010503f3e064d6145095cc6612456e4950ae618

Best regards,
-- 
Manivannan Sadhasivam <mani@kernel.org>


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

end of thread, other threads:[~2025-06-17 10:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-19 14:58 [PATCH v4] bus: mhi: host: fix endianness of BHI vector table Alexander Wilhelm
2025-05-20  4:04 ` Krishna Chaitanya Chundru
2025-06-17 10:39 ` Manivannan Sadhasivam

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

all inboxes | Powered by JetHome®