[PATCH] thunderbolt: Process xdomain response packets synchronously

zhangjianrong posted 1 patch 3 months, 2 weeks ago
drivers/thunderbolt/ctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] thunderbolt: Process xdomain response packets synchronously
Posted by zhangjianrong 3 months, 2 weeks ago
Xdomain response packets don't belong to async event. It seems
no harm now but better to be fixed.

Signed-off-by: zhangjianrong <zhangjianrong5@huawei.com>
---
 drivers/thunderbolt/ctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
index 4bdb2d45e0bf..1873b64caf7c 100644
--- a/drivers/thunderbolt/ctl.c
+++ b/drivers/thunderbolt/ctl.c
@@ -461,6 +461,7 @@ static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame,
 	case TB_CFG_PKG_ERROR:
 	case TB_CFG_PKG_OVERRIDE:
 	case TB_CFG_PKG_RESET:
+	case TB_CFG_PKG_XDOMAIN_RESP:
 		if (*(__be32 *)(pkg->buffer + frame->size) != crc32) {
 			tb_ctl_err(pkg->ctl,
 				   "RX: checksum mismatch, dropping packet\n");
@@ -474,7 +475,6 @@ static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame,
 		break;
 
 	case TB_CFG_PKG_EVENT:
-	case TB_CFG_PKG_XDOMAIN_RESP:
 	case TB_CFG_PKG_XDOMAIN_REQ:
 		if (*(__be32 *)(pkg->buffer + frame->size) != crc32) {
 			tb_ctl_err(pkg->ctl,
-- 
2.34.1
Re: [PATCH] thunderbolt: Process xdomain response packets synchronously
Posted by Mika Westerberg 3 months, 2 weeks ago
On Wed, Jun 25, 2025 at 02:25:05PM +0800, zhangjianrong wrote:
> Xdomain response packets don't belong to async event. It seems
> no harm now but better to be fixed.

It seems odd but the protocol actually uses RESP packets also with requests
(probably a typo in the original specs but this is what Apple also
implemented so we need to support it). So we need to deal with them.

Did you try if this patch works against macOS for example?

> 
> Signed-off-by: zhangjianrong <zhangjianrong5@huawei.com>
> ---
>  drivers/thunderbolt/ctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c
> index 4bdb2d45e0bf..1873b64caf7c 100644
> --- a/drivers/thunderbolt/ctl.c
> +++ b/drivers/thunderbolt/ctl.c
> @@ -461,6 +461,7 @@ static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame,
>  	case TB_CFG_PKG_ERROR:
>  	case TB_CFG_PKG_OVERRIDE:
>  	case TB_CFG_PKG_RESET:
> +	case TB_CFG_PKG_XDOMAIN_RESP:
>  		if (*(__be32 *)(pkg->buffer + frame->size) != crc32) {
>  			tb_ctl_err(pkg->ctl,
>  				   "RX: checksum mismatch, dropping packet\n");
> @@ -474,7 +475,6 @@ static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame,
>  		break;
>  
>  	case TB_CFG_PKG_EVENT:
> -	case TB_CFG_PKG_XDOMAIN_RESP:
>  	case TB_CFG_PKG_XDOMAIN_REQ:
>  		if (*(__be32 *)(pkg->buffer + frame->size) != crc32) {
>  			tb_ctl_err(pkg->ctl,
> -- 
> 2.34.1