* [PATCH] hid: fix incorrect return value for hid.
@ 2025-08-21 18:57 ShengYi Hung
0 siblings, 0 replies; 3+ messages in thread
From: ShengYi Hung @ 2025-08-21 18:57 UTC (permalink / raw)
To: qemu-devel; +Cc: ShengYi Hung
The return value of hid_keyboard_write is used to set the packet's actual_length.
Therefore, return 1 to indicate a successful transfer or it should be
considered as a wrong xfer.
Signed-off-by: ShengYi Hung <aokblast@FreeBSD.org>
Sponsored by: The FreeBSD Foundation
---
hw/input/hid.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/input/hid.c b/hw/input/hid.c
index 76bedc1844..5da9fee763 100644
--- a/hw/input/hid.c
+++ b/hw/input/hid.c
@@ -478,6 +478,7 @@ int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len)
ledstate |= QEMU_CAPS_LOCK_LED;
}
kbd_put_ledstate(ledstate);
+ return (1);
}
return 0;
}
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hid: fix incorrect return value for hid.
[not found] <20250915175730.27825-1-aokblast@FreeBSD.org>
@ 2025-09-18 6:14 ` Michael Tokarev
2025-09-18 8:35 ` ShengYi Hung
0 siblings, 1 reply; 3+ messages in thread
From: Michael Tokarev @ 2025-09-18 6:14 UTC (permalink / raw)
To: ShengYi Hung, qemu-trivial, QEMU Development
Please always send all patches to qemu-devel@ (cc'd)
(in this case, in addition to qemu-trivial@).
On 15.09.2025 20:57, ShengYi Hung wrote:
> The return value of hid_keyboard_write is used to set the packet's actual_length
> and pass to xhci directly to allow guest know how many byte actually processed.
> Therefore, return 1 to indicate a successful transfer or it will be
> considered as a wrong xfer.
>
> Signed-off-by: ShengYi Hung <aokblast@FreeBSD.org>
> ---
> hw/input/hid.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/hw/input/hid.c b/hw/input/hid.c
> index 76bedc1844..de24cd0ef0 100644
> --- a/hw/input/hid.c
> +++ b/hw/input/hid.c
> @@ -478,6 +478,7 @@ int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len)
> ledstate |= QEMU_CAPS_LOCK_LED;
> }
> kbd_put_ledstate(ledstate);
> + return 1;
> }
> return 0;
> }
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
and queued up to the trivial-patches tree.
It's an interesting one, I wonder what the consequences are -
for having this at 0 all the time, and for actually making it 1.
Did we miss a byte somewhere with current code?
Thanks,
/mjt
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hid: fix incorrect return value for hid.
2025-09-18 6:14 ` [PATCH] hid: fix incorrect return value for hid Michael Tokarev
@ 2025-09-18 8:35 ` ShengYi Hung
0 siblings, 0 replies; 3+ messages in thread
From: ShengYi Hung @ 2025-09-18 8:35 UTC (permalink / raw)
To: Michael Tokarev; +Cc: qemu-trivial, QEMU Development
Hello Michael:
Thanks for your review and reply, I sent the mail to qemud-devel about a
month ago but didn't receive any reply. Therefore, I send the mail to
qemu-trivial again and forget CC to qemu-devel. I will be careful next
time.
The consequence is that if the guest operating system want to check the
actual transfer length of a transfer, it may be regarded as a failed
transfer since the actual transfer length is zero originally.
Here is an example from FreeBSD:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=288968.
I have workarounded this issue by ignore any error from hid_write.
Interestingly, Parallel seems to share the same issue and can be
addressed with the same fix.
Michael Tokarev <mjt@tls.msk.ru> writes:
> Please always send all patches to qemu-devel@ (cc'd)
> (in this case, in addition to qemu-trivial@).
>
> On 15.09.2025 20:57, ShengYi Hung wrote:
>> The return value of hid_keyboard_write is used to set the packet's actual_length
>> and pass to xhci directly to allow guest know how many byte actually processed.
>> Therefore, return 1 to indicate a successful transfer or it will be
>> considered as a wrong xfer.
>> Signed-off-by: ShengYi Hung <aokblast@FreeBSD.org>
>> ---
>> hw/input/hid.c | 1 +
>> 1 file changed, 1 insertion(+)
>> diff --git a/hw/input/hid.c b/hw/input/hid.c
>> index 76bedc1844..de24cd0ef0 100644
>> --- a/hw/input/hid.c
>> +++ b/hw/input/hid.c
>> @@ -478,6 +478,7 @@ int hid_keyboard_write(HIDState *hs, uint8_t *buf, int len)
>> ledstate |= QEMU_CAPS_LOCK_LED;
>> }
>> kbd_put_ledstate(ledstate);
>> + return 1;
>> }
>> return 0;
>> }
>
> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
>
> and queued up to the trivial-patches tree.
>
> It's an interesting one, I wonder what the consequences are -
> for having this at 0 all the time, and for actually making it 1.
> Did we miss a byte somewhere with current code?
>
> Thanks,
>
> /mjt
--
Best Regards.
ShengYi Hung.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-18 13:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250915175730.27825-1-aokblast@FreeBSD.org>
2025-09-18 6:14 ` [PATCH] hid: fix incorrect return value for hid Michael Tokarev
2025-09-18 8:35 ` ShengYi Hung
2025-08-21 18:57 ShengYi Hung
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).