Skip to contentSkip to conversation

mhi_bus: core: Return EBUSY if MHI ring is full

PATCH Superseded Jeffrey Hugo 4 participants 7 messages Feb 16, 2021 – Feb 17, 2021

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mhi_bus: core: Return EBUSY if MHI ring is full

From: Fan Wu <[email protected]>

Currently ENOMEM is returned when MHI ring is full. This error code is very misleading. Change to EBUSY instead.

---
 drivers/bus/mhi/core/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/mhi/core/main.c +1 -1
index f182736..21eb5fc 100644
@@ -996,7 +996,7 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info,
 
 	ret = mhi_is_ring_full(mhi_cntrl, tre_ring);
 	if (unlikely(ret)) {
-		ret = -ENOMEM;
+		ret = -EBUSY;
 		goto exit_unlock;
 	}
 
Signature · 2 lines
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#1 lore raw
Quoted 16 lines · Jeffrey Hugo

From: Fan Wu <[email protected]>

Currently ENOMEM is returned when MHI ring is full. This error code is very misleading. Change to EBUSY instead.

---
 drivers/bus/mhi/core/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/mhi/core/main.c +0 -0
index f182736..21eb5fc 100644

drivers/bus/mhi/core/main.c static int mhi_queue(struct mhi_device *mhi_dev, · line 1002

Quoted 8 lines
drivers/bus/mhi/core/main.c +1 -1
@@ -996,7 +996,7 @@ static int mhi_queue(struct mhi_device *mhi_dev,
 struct mhi_buf_info *buf_info,
 
 	ret = mhi_is_ring_full(mhi_cntrl, tre_ring);
 	if (unlikely(ret)) {
-		ret = -ENOMEM;
+		ret = -EBUSY;
 		goto exit_unlock;
 	}

ENOMEM is descriptive of the state of the ring since you basically cannot queue any more packets as no memory is currently available.

But I agree, it can be misleading for this API. How about EAGAIN in place of EBUSY, which tells the user to try the queue attempt again implying memory should become available as more elements are consumed by the device/client?

Thanks,
Bhaumik
---
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

#2 lore raw
Quoted 29 lines · Bhaumik Bhatt
Quoted 16 lines · Jeffrey Hugo

From: Fan Wu <[email protected]>

Currently ENOMEM is returned when MHI ring is full. This error code is very misleading. Change to EBUSY instead.

---
 drivers/bus/mhi/core/main.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/mhi/core/main.c +0 -0
index f182736..21eb5fc 100644

drivers/bus/mhi/core/main.c static int mhi_queue(struct mhi_device *mhi_dev, · line 1002

Quoted 8 lines
drivers/bus/mhi/core/main.c +1 -1
@@ -996,7 +996,7 @@ static int mhi_queue(struct mhi_device *mhi_dev,
 struct mhi_buf_info *buf_info,
 
      ret = mhi_is_ring_full(mhi_cntrl, tre_ring);
      if (unlikely(ret)) {
-        ret = -ENOMEM;
+        ret = -EBUSY;
          goto exit_unlock;
      }

ENOMEM is descriptive of the state of the ring since you basically cannot queue any more packets as no memory is currently available.

Quoted 3 lines

But I agree, it can be misleading for this API. How about EAGAIN in place of EBUSY, which tells the user to try the queue attempt again implying memory should become available as more elements are consumed by the device/client?

Fan and I think EAGAIN is fine. Will send a v2.

Signature · 3 lines
Jeffrey Hugo
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#3 lore raw
In reply to Jeffrey Hugo
Quoted 5 lines · Jeffrey Hugo

From: Fan Wu <[email protected]>

Currently ENOMEM is returned when MHI ring is full. This error code is very misleading. Change to EBUSY instead.

Please use the subject prefix:

"bus: mhi: ..."

Thanks,
Mani

Quoted 23 lines
---
 drivers/bus/mhi/core/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/mhi/core/main.c +1 -1
index f182736..21eb5fc 100644
@@ -996,7 +996,7 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info,
 
 	ret = mhi_is_ring_full(mhi_cntrl, tre_ring);
 	if (unlikely(ret)) {
-		ret = -ENOMEM;
+		ret = -EBUSY;
 		goto exit_unlock;
 	}
 
Signature · 2 lines
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#4 lore raw
In reply to Jeffrey Hugo
Quoted 5 lines · Jeffrey Hugo

From: Fan Wu <[email protected]>

Currently ENOMEM is returned when MHI ring is full. This error code is very misleading. Change to EBUSY instead.

Well, there is no space left in the ring, so it's no so misleading.

Regards,
Loic

#5 lore raw
Quoted 8 lines · Loic Poulain
Quoted 5 lines · Jeffrey Hugo

From: Fan Wu <[email protected]>

Currently ENOMEM is returned when MHI ring is full. This error code is very misleading. Change to EBUSY instead.

Well, there is no space left in the ring, so it's no so misleading.

ENOMEM is typically a memory allocation failure which is not what a client is going to think of regarding the ring, and it's not a unique failure code in this case. gen_tre can also return ENOMEM, which makes it difficult for the client to know if there is some significant failure, or they might just need to wait (assuming that is something the client can do).

Signature · 3 lines
Jeffrey Hugo
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#6 lore raw
Quoted 9 lines · Jeffrey Hugo
Quoted 7 lines · Loic Poulain
Quoted 5 lines · Jeffrey Hugo

From: Fan Wu <[email protected]>

Currently ENOMEM is returned when MHI ring is full. This error code is very misleading. Change to EBUSY instead.

Quoted 8 lines
Quoted 1 line

Well, there is no space left in the ring, so it's no so misleading.

ENOMEM is typically a memory allocation failure which is not what a client is going to think of regarding the ring, and it's not a unique failure code in this case. gen_tre can also return ENOMEM, which makes it difficult for the client to know if there is some significant failure, or they might just need to wait (assuming that is something the client can do).

Yes, fair enough, I overlooked the other thread, -EAGAIN would indeed make sense.

Regards,
Loic