i guess we need somebody knowing the driver more…i do not understand this exactly…maybe it it like you wrote…but why the semaphore is blocked before first call of mt7615_mcu_patch_sem_ctrl
? that does not make sense for me
Neither does to me. One explanation is that it may be locked by something else elsewhere, maybe not intentionally. Or even that the semaphore is stored in non-volatile memory on the mt7615 hardware, which of course, it doesn’t make sense.
how is your exact debug-code ( mt7615's semaphore returned an error.
) ? maybe you treat PATCH_IS_DL
or PATCH_NOT_DL_SEM_SUCCESS as error. i guess first returns PATCH_IS_DL and returns 0 without releasing the semaphore…second failes with -EAGAIN
because semaphore is still locked
int ret;
struct {
__le32 op;
} req = {
.op = cpu_to_le32(get ? PATCH_SEM_GET : PATCH_SEM_RELEASE),
};
if (get)
pr_alert("DEBUG: Attempting to lock mt7615's semaphore.\n");
else
pr_alert("DEBUG: Attempting to unlock mt7615's semaphore.\n");
ret = __mt76_mcu_send_msg(&dev->mt76, MCU_CMD_PATCH_SEM_CONTROL,
&req, sizeof(req), true);
switch(ret)
{
case PATCH_IS_DL:
pr_alert("DEBUG: mt7615's semaphore was already locked (by whom?).\n");
break;
case PATCH_NOT_DL_SEM_SUCCESS:
pr_alert("DEBUG: mt7615's semaphore was locked.\n");
break;
default:
pr_alert("DEBUG: mt7615's semaphore returned an error.\n");
break;
}
return ret;
I know I could reduce some lines of code using ternary operators, but I preferred to avoid issues later.
i see in 893369b769c18ad14d57f731428d97a7c04dfec6 “mt7615: mcu: remove skb_ret from mt7615_mcu_msg_send” the mt7615_mcu_patch_sem_ctrl function is changed
Now that you mention this change, it seems that only the first byte is status
, while the others are reserved. Knowing that, I’ve added another print: pr_alert("DEBUG: __mt76_mcu_send_msg() returned 0x%08x", ret);
.
It worked, more or less… It printed 0xffffff92. I assume the communication is done using little-endian since the request uses __le32
. Assuming that, 0x92 is the status, while 0xff are the reserved bytes…
Of course, if the 4 bytes are compared, the switch is doomed to fail miserably. But even if the reserved bytes are ignored we’re left with 0x92, which is still invalid:
enum {
PATCH_NOT_DL_SEM_FAIL = 0x0,
PATCH_IS_DL = 0x1,
PATCH_NOT_DL_SEM_SUCCESS = 0x2,
PATCH_REL_SEM_SUCCESS = 0x3
};