Skip to contentSkip to conversation

drm/bridge: analogix_dp: Don't return -EBUSY when msg->size is 0 in aux transaction

PATCH In review zain wang 2 participants 5 messages Feb 13, 2017 – Feb 20, 2017

Subsystems (5)
lore
Share & tools
lore

zain wang

author
#0 lore raw

PATCH 1/1 drm/bridge: analogix_dp: Don't return -EBUSY when msg->size is 0 in aux transaction

The analogix_dp_transfer() will return -EBUSY if num_transferred is zero. But sometimes we will send a bare address packet to start the transaction, like drm_dp_i2c_xfer() show:

	......
	/* Send a bare address packet to start the transaction.
	 * Zero sized messages specify an address only (bare
	 * address) transaction.
	 */
	msg.buffer = NULL;
	msg.size = 0;
	err = drm_dp_i2c_do_msg(aux, &msg);
	......

In this case, the msg->size is zero, so the num_transferred will be zero too. We can't return -EBUSY here, let's we return num_transferred if num_transferred equals msg->size.

---
 drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +1 -1
index 303083a..5384aca 100644
@@ -1162,5 +1162,5 @@ ssize_t analogix_dp_transfer(struct analogix_dp_device *dp,
 		 (msg->request & ~DP_AUX_I2C_MOT) == DP_AUX_NATIVE_READ)
 		msg->reply = DP_AUX_NATIVE_REPLY_ACK;
 
-	return num_transferred > 0 ? num_transferred : -EBUSY;
+	return (num_transferred == msg->size) ? num_transferred : -EBUSY;
 }
Signature · 1 line
1.9.1
author
#1 lore raw

Hi Sean,

Could you give some comments for this patch?

Thanks
Zain

Quoted 27 lines · zain wang

The analogix_dp_transfer() will return -EBUSY if num_transferred is zero. But sometimes we will send a bare address packet to start the transaction, like drm_dp_i2c_xfer() show:

	......
	/* Send a bare address packet to start the transaction.
	 * Zero sized messages specify an address only (bare
	 * address) transaction.
	 */
	msg.buffer = NULL;
	msg.size = 0;
	err = drm_dp_i2c_do_msg(aux, &msg);
	......

In this case, the msg->size is zero, so the num_transferred will be zero too. We can't return -EBUSY here, let's we return num_transferred if num_transferred equals msg->size.

---
  drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +0 -0
index 303083a..5384aca 100644

drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c ssize_t analogix_dp_transfer(struct analogix_dp_device *dp, · line 1166

Quoted 6 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +1 -1
@@ -1162,5 +1162,5 @@ ssize_t analogix_dp_transfer(struct analogix_dp_device *dp,
  		 (msg->request & ~DP_AUX_I2C_MOT) == DP_AUX_NATIVE_READ)
  		msg->reply = DP_AUX_NATIVE_REPLY_ACK;
 
-	return num_transferred > 0 ? num_transferred : -EBUSY;
+	return (num_transferred == msg->size) ? num_transferred : -EBUSY;
  }

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#2 lore raw
In reply to zain wang

Hi Zain,

Quoted 14 lines · zain wang

The analogix_dp_transfer() will return -EBUSY if num_transferred is zero. But sometimes we will send a bare address packet to start the transaction, like drm_dp_i2c_xfer() show:

        ......
        /* Send a bare address packet to start the transaction.
         * Zero sized messages specify an address only (bare
         * address) transaction.
         */
        msg.buffer = NULL;
        msg.size = 0;
        err = drm_dp_i2c_do_msg(aux, &msg);
        ......
Quoted 4 lines

In this case, the msg->size is zero, so the num_transferred will be zero too. We can't return -EBUSY here, let's we return num_transferred if num_transferred equals msg->size.

Please see my question inline.

Quoted 10 lines
---
 drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +0 -0
index 303083a..5384aca 100644

drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c ssize_t analogix_dp_transfer(struct analogix_dp_device *dp, · line 1165

Quoted 5 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +1 -1
@@ -1162,5 +1162,5 @@ ssize_t analogix_dp_transfer(struct analogix_dp_device *dp,
                 (msg->request & ~DP_AUX_I2C_MOT) == DP_AUX_NATIVE_READ)
                msg->reply = DP_AUX_NATIVE_REPLY_ACK;
 
-       return num_transferred > 0 ? num_transferred : -EBUSY;
+       return (num_transferred == msg->size) ? num_transferred : -EBUSY;

I might be missing something but, looking at the code, I don't see any possibility of num_transferred ever being different than msg->size. To be honest, it doesn't seem to even make any sense keeping the local variable there, because msg->size can be simply always returned, as errors are handled by jumping to aux_error label.

Best regards,
Tomasz

author
#3 lore raw

Hi Tomasz,

Quoted 35 lines · Tomasz Figa

Hi Zain,

Quoted 13 lines · zain wang

The analogix_dp_transfer() will return -EBUSY if num_transferred is zero. But sometimes we will send a bare address packet to start the transaction, like drm_dp_i2c_xfer() show:

         ......
         /* Send a bare address packet to start the transaction.
          * Zero sized messages specify an address only (bare
          * address) transaction.
          */
         msg.buffer = NULL;
         msg.size = 0;
         err = drm_dp_i2c_do_msg(aux, &msg);
         ......
Quoted 4 lines

In this case, the msg->size is zero, so the num_transferred will be zero too. We can't return -EBUSY here, let's we return num_transferred if num_transferred equals msg->size.

Please see my question inline.

Quoted 13 lines
---
  drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +0 -0
index 303083a..5384aca 100644
@@ -1162,5 +1162,5 @@ ssize_t analogix_dp_transfer(struct analogix_dp_device *dp,
                  (msg->request & ~DP_AUX_I2C_MOT) == DP_AUX_NATIVE_READ)
                 msg->reply = DP_AUX_NATIVE_REPLY_ACK;
 
Quoted 7 lines

drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c ssize_t analogix_dp_transfer(struct analogix_dp_device *dp, · line 1165

Quoted 2 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +1 -1
-       return num_transferred > 0 ? num_transferred : -EBUSY;
+       return (num_transferred == msg->size) ? num_transferred : -EBUSY;

I might be missing something but, looking at the code, I don't see any possibility of num_transferred ever being different than msg->size. To be honest, it doesn't seem to even make any sense keeping the local variable there, because msg->size can be simply always returned, as errors are handled by jumping to aux_error label.

Yeah, I agree with you.
The better way to fix this issue is to revert the changes https://patchwork.kernel.org/patch/9411711/
(returning num_transferred directly may be better here)

Maybe we can revert the changes above with some new comment. @Sean, How do you think about Tomasz's comment?

Thanks
Zain

Quoted 6 lines

Best regards,
Tomasz

#4 lore raw
Quoted 21 lines · Zain Wang
Quoted 11 lines · Tomasz Figa
Quoted 10 lines · zain wang
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +0 -0
index 303083a..5384aca 100644
@@ -1162,5 +1162,5 @@ ssize_t analogix_dp_transfer(struct
 analogix_dp_device *dp,
                  (msg->request & ~DP_AUX_I2C_MOT) == DP_AUX_NATIVE_READ)
                 msg->reply = DP_AUX_NATIVE_REPLY_ACK;
 
Quoted 8 lines

drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c ssize_t analogix_dp_transfer(struct analogix_dp_device *dp, · line 1165

Quoted 2 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +1 -1
-       return num_transferred > 0 ? num_transferred : -EBUSY;
+       return (num_transferred == msg->size) ? num_transferred : -EBUSY;

I might be missing something but, looking at the code, I don't see any possibility of num_transferred ever being different than msg->size. To be honest, it doesn't seem to even make any sense keeping the local variable there, because msg->size can be simply always returned, as errors are handled by jumping to aux_error label.

Quoted 4 lines

Yeah, I agree with you.
The better way to fix this issue is to revert the changes
https://patchwork.kernel.org/patch/9411711/
(returning num_transferred directly may be better here)

I think it's still not enough to clean up the code completely. It should be just enough to remove num_transferred completely and simply return msg->size at the end.

Best regards,
Tomasz
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel