* [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements
@ 2023-02-06 22:12 Bastien Nocera
2023-02-06 22:12 ` [PATCH v2 2/3] HID: logitech-hidpp: Retry commands when device is busy Bastien Nocera
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Bastien Nocera @ 2023-02-06 22:12 UTC (permalink / raw)
To: linux-input
Cc: linux-kernel, Jiri Kosina, Benjamin Tissoires,
Peter F . Patel-Schneider, Filipe Laíns,
Nestor Lopez Casado
This should help us figure out some hairy problems with some devices.
Signed-off-by: Bastien Nocera <hadess@hadess.net>
---
Fixed kernel test bot warning:
drivers/hid/hid-logitech-hidpp.c: In function 'hidpp_send_fap_command_sync':
>> drivers/hid/hid-logitech-hidpp.c:343:25: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Wformat=]
343 | "Invalid number of parameters passed to command (%d != %ld)\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/hid/hid-logitech-hidpp.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index f44ba7be3cc5..1952d8d3b6b2 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -338,8 +338,13 @@ static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp,
struct hidpp_report *message;
int ret;
- if (param_count > sizeof(message->fap.params))
+ if (param_count > sizeof(message->fap.params)) {
+ hid_dbg(hidpp->hid_dev,
+ "Invalid number of parameters passed to command (%d != %llu)\n",
+ param_count,
+ (unsigned long long) sizeof(message->fap.params));
return -EINVAL;
+ }
message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL);
if (!message)
@@ -3440,11 +3445,17 @@ static int hi_res_scroll_enable(struct hidpp_device *hidpp)
ret = hidpp10_enable_scrolling_acceleration(hidpp);
multiplier = 8;
}
- if (ret)
+ if (ret) {
+ hid_dbg(hidpp->hid_dev,
+ "Could not enable hi-res scrolling: %d\n", ret);
return ret;
+ }
- if (multiplier == 0)
+ if (multiplier == 0) {
+ hid_dbg(hidpp->hid_dev,
+ "Invalid multiplier 0 from device, setting it to 1\n");
multiplier = 1;
+ }
hidpp->vertical_wheel_counter.wheel_multiplier = multiplier;
hid_dbg(hidpp->hid_dev, "wheel multiplier = %d\n", multiplier);
--
2.39.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/3] HID: logitech-hidpp: Retry commands when device is busy
2023-02-06 22:12 [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements Bastien Nocera
@ 2023-02-06 22:12 ` Bastien Nocera
2023-02-09 14:50 ` Benjamin Tissoires
2023-02-06 22:12 ` [PATCH v2 3/3] HID: logitech-hidpp: Add myself to authors Bastien Nocera
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Bastien Nocera @ 2023-02-06 22:12 UTC (permalink / raw)
To: linux-input
Cc: linux-kernel, Jiri Kosina, Benjamin Tissoires,
Peter F . Patel-Schneider, Filipe Laíns,
Nestor Lopez Casado
Handle the busy error coming from the device or receiver. The
documentation says a busy error can be returned when:
"
Device (or receiver) cannot answer immediately to this request
for any reason i.e:
- already processing a request from the same or another SW
- pipe full
"
Signed-off-by: Bastien Nocera <hadess@hadess.net>
---
Same as v1
drivers/hid/hid-logitech-hidpp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 1952d8d3b6b2..9e94026de437 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -295,6 +295,7 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
*/
*response = *message;
+retry:
ret = __hidpp_send_report(hidpp->hid_dev, message);
if (ret) {
@@ -321,6 +322,10 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
response->report_id == REPORT_ID_HIDPP_VERY_LONG) &&
response->fap.feature_index == HIDPP20_ERROR) {
ret = response->fap.params[1];
+ if (ret == HIDPP20_ERROR_BUSY) {
+ dbg_hid("%s:got busy hidpp 2.0 error %02X, retrying\n", __func__, ret);
+ goto retry;
+ }
dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret);
goto exit;
}
--
2.39.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/3] HID: logitech-hidpp: Add myself to authors
2023-02-06 22:12 [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements Bastien Nocera
2023-02-06 22:12 ` [PATCH v2 2/3] HID: logitech-hidpp: Retry commands when device is busy Bastien Nocera
@ 2023-02-06 22:12 ` Bastien Nocera
2023-02-09 14:53 ` Benjamin Tissoires
2023-02-09 14:54 ` [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements Benjamin Tissoires
2023-02-09 15:39 ` (subset) " Benjamin Tissoires
3 siblings, 1 reply; 9+ messages in thread
From: Bastien Nocera @ 2023-02-06 22:12 UTC (permalink / raw)
To: linux-input
Cc: linux-kernel, Jiri Kosina, Benjamin Tissoires,
Peter F . Patel-Schneider, Filipe Laíns,
Nestor Lopez Casado
Signed-off-by: Bastien Nocera <hadess@hadess.net>
---
Same as v1
drivers/hid/hid-logitech-hidpp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 9e94026de437..03b77ca03081 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -30,6 +30,7 @@
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");
MODULE_AUTHOR("Nestor Lopez Casado <nlopezcasad@logitech.com>");
+MODULE_AUTHOR("Bastien Nocera <hadess@hadess.net>");
static bool disable_tap_to_click;
module_param(disable_tap_to_click, bool, 0644);
--
2.39.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] HID: logitech-hidpp: Retry commands when device is busy
2023-02-06 22:12 ` [PATCH v2 2/3] HID: logitech-hidpp: Retry commands when device is busy Bastien Nocera
@ 2023-02-09 14:50 ` Benjamin Tissoires
2023-02-09 15:50 ` Bastien Nocera
0 siblings, 1 reply; 9+ messages in thread
From: Benjamin Tissoires @ 2023-02-09 14:50 UTC (permalink / raw)
To: Bastien Nocera
Cc: linux-input, linux-kernel, Jiri Kosina,
Peter F . Patel-Schneider, Filipe Laíns,
Nestor Lopez Casado
On Feb 06 2023, Bastien Nocera wrote:
> Handle the busy error coming from the device or receiver. The
> documentation says a busy error can be returned when:
> "
> Device (or receiver) cannot answer immediately to this request
> for any reason i.e:
> - already processing a request from the same or another SW
> - pipe full
> "
>
> Signed-off-by: Bastien Nocera <hadess@hadess.net>
> ---
>
> Same as v1
>
> drivers/hid/hid-logitech-hidpp.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index 1952d8d3b6b2..9e94026de437 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -295,6 +295,7 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
> */
> *response = *message;
>
> +retry:
> ret = __hidpp_send_report(hidpp->hid_dev, message);
>
> if (ret) {
> @@ -321,6 +322,10 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
> response->report_id == REPORT_ID_HIDPP_VERY_LONG) &&
> response->fap.feature_index == HIDPP20_ERROR) {
> ret = response->fap.params[1];
> + if (ret == HIDPP20_ERROR_BUSY) {
> + dbg_hid("%s:got busy hidpp 2.0 error %02X, retrying\n", __func__, ret);
> + goto retry;
I must confess, I blocked a little bit there to decide whether or not
using goto here was OK.
But then I reliazed that there is no way to leave that function if the
device is buggy and constantly sends back ERROR_BUSY. So I am not very
found of the idea of having that got after all.
Would you mind respinning that patch with a bounded loop for the retries
instead of using a goto? I'd like the driver to give up after a few
retries if the device is not fair.
Cheers,
Benjamin
> + }
> dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret);
> goto exit;
> }
> --
> 2.39.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] HID: logitech-hidpp: Add myself to authors
2023-02-06 22:12 ` [PATCH v2 3/3] HID: logitech-hidpp: Add myself to authors Bastien Nocera
@ 2023-02-09 14:53 ` Benjamin Tissoires
2023-02-09 15:50 ` Bastien Nocera
0 siblings, 1 reply; 9+ messages in thread
From: Benjamin Tissoires @ 2023-02-09 14:53 UTC (permalink / raw)
To: Bastien Nocera
Cc: linux-input, linux-kernel, Jiri Kosina,
Peter F . Patel-Schneider, Filipe Laíns,
Nestor Lopez Casado
On Feb 06 2023, Bastien Nocera wrote:
> Signed-off-by: Bastien Nocera <hadess@hadess.net>
> ---
>
> Same as v1
>
> drivers/hid/hid-logitech-hidpp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index 9e94026de437..03b77ca03081 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -30,6 +30,7 @@
> MODULE_LICENSE("GPL");
> MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");
> MODULE_AUTHOR("Nestor Lopez Casado <nlopezcasad@logitech.com>");
> +MODULE_AUTHOR("Bastien Nocera <hadess@hadess.net>");
Just FTR, I have asked Bastien to set himself as an author given all of
the work he has been doing on this and to have one more person to be the
go-to person from folks having an issue.
And Bastien, would you mind adding yourself to the MAINTAINERS file too?
This way you'll get Cc-ed when people submit patches.
Cheers,
Benjamin
>
> static bool disable_tap_to_click;
> module_param(disable_tap_to_click, bool, 0644);
> --
> 2.39.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements
2023-02-06 22:12 [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements Bastien Nocera
2023-02-06 22:12 ` [PATCH v2 2/3] HID: logitech-hidpp: Retry commands when device is busy Bastien Nocera
2023-02-06 22:12 ` [PATCH v2 3/3] HID: logitech-hidpp: Add myself to authors Bastien Nocera
@ 2023-02-09 14:54 ` Benjamin Tissoires
2023-02-09 15:39 ` (subset) " Benjamin Tissoires
3 siblings, 0 replies; 9+ messages in thread
From: Benjamin Tissoires @ 2023-02-09 14:54 UTC (permalink / raw)
To: Bastien Nocera
Cc: linux-input, linux-kernel, Jiri Kosina,
Peter F . Patel-Schneider, Filipe Laíns,
Nestor Lopez Casado
On Feb 06 2023, Bastien Nocera wrote:
> This should help us figure out some hairy problems with some devices.
>
> Signed-off-by: Bastien Nocera <hadess@hadess.net>
FWIW, I am currently testing this patch and will probably push it today.
Cheers,
Benjamin
> ---
>
> Fixed kernel test bot warning:
> drivers/hid/hid-logitech-hidpp.c: In function 'hidpp_send_fap_command_sync':
> >> drivers/hid/hid-logitech-hidpp.c:343:25: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'unsigned int' [-Wformat=]
> 343 | "Invalid number of parameters passed to command (%d != %ld)\n",
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> drivers/hid/hid-logitech-hidpp.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
> index f44ba7be3cc5..1952d8d3b6b2 100644
> --- a/drivers/hid/hid-logitech-hidpp.c
> +++ b/drivers/hid/hid-logitech-hidpp.c
> @@ -338,8 +338,13 @@ static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp,
> struct hidpp_report *message;
> int ret;
>
> - if (param_count > sizeof(message->fap.params))
> + if (param_count > sizeof(message->fap.params)) {
> + hid_dbg(hidpp->hid_dev,
> + "Invalid number of parameters passed to command (%d != %llu)\n",
> + param_count,
> + (unsigned long long) sizeof(message->fap.params));
> return -EINVAL;
> + }
>
> message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL);
> if (!message)
> @@ -3440,11 +3445,17 @@ static int hi_res_scroll_enable(struct hidpp_device *hidpp)
> ret = hidpp10_enable_scrolling_acceleration(hidpp);
> multiplier = 8;
> }
> - if (ret)
> + if (ret) {
> + hid_dbg(hidpp->hid_dev,
> + "Could not enable hi-res scrolling: %d\n", ret);
> return ret;
> + }
>
> - if (multiplier == 0)
> + if (multiplier == 0) {
> + hid_dbg(hidpp->hid_dev,
> + "Invalid multiplier 0 from device, setting it to 1\n");
> multiplier = 1;
> + }
>
> hidpp->vertical_wheel_counter.wheel_multiplier = multiplier;
> hid_dbg(hidpp->hid_dev, "wheel multiplier = %d\n", multiplier);
> --
> 2.39.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (subset) [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements
2023-02-06 22:12 [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements Bastien Nocera
` (2 preceding siblings ...)
2023-02-09 14:54 ` [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements Benjamin Tissoires
@ 2023-02-09 15:39 ` Benjamin Tissoires
3 siblings, 0 replies; 9+ messages in thread
From: Benjamin Tissoires @ 2023-02-09 15:39 UTC (permalink / raw)
To: linux-input, Bastien Nocera
Cc: linux-kernel, Jiri Kosina, Peter F . Patel-Schneider,
Filipe Laíns, Nestor Lopez Casado
On Mon, 06 Feb 2023 23:12:54 +0100, Bastien Nocera wrote:
> This should help us figure out some hairy problems with some devices.
>
>
Applied to hid/hid.git (for-6.3/logitech), thanks!
[1/3] HID: logitech-hidpp: Add more debug statements
https://git.kernel.org/hid/hid/c/db5167cfaa0a
Cheers,
--
Benjamin Tissoires <benjamin.tissoires@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/3] HID: logitech-hidpp: Add myself to authors
2023-02-09 14:53 ` Benjamin Tissoires
@ 2023-02-09 15:50 ` Bastien Nocera
0 siblings, 0 replies; 9+ messages in thread
From: Bastien Nocera @ 2023-02-09 15:50 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: linux-input, linux-kernel, Jiri Kosina,
Peter F . Patel-Schneider, Filipe Laíns,
Nestor Lopez Casado
On Thu, 2023-02-09 at 15:53 +0100, Benjamin Tissoires wrote:
> On Feb 06 2023, Bastien Nocera wrote:
> > Signed-off-by: Bastien Nocera <hadess@hadess.net>
> > ---
> >
> > Same as v1
> >
> > drivers/hid/hid-logitech-hidpp.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-
> > logitech-hidpp.c
> > index 9e94026de437..03b77ca03081 100644
> > --- a/drivers/hid/hid-logitech-hidpp.c
> > +++ b/drivers/hid/hid-logitech-hidpp.c
> > @@ -30,6 +30,7 @@
> > MODULE_LICENSE("GPL");
> > MODULE_AUTHOR("Benjamin Tissoires
> > <benjamin.tissoires@gmail.com>");
> > MODULE_AUTHOR("Nestor Lopez Casado <nlopezcasad@logitech.com>");
> > +MODULE_AUTHOR("Bastien Nocera <hadess@hadess.net>");
>
> Just FTR, I have asked Bastien to set himself as an author given all
> of
> the work he has been doing on this and to have one more person to be
> the
> go-to person from folks having an issue.
>
> And Bastien, would you mind adding yourself to the MAINTAINERS file
> too?
> This way you'll get Cc-ed when people submit patches.
Done in v3 specifically for the hidpp file.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/3] HID: logitech-hidpp: Retry commands when device is busy
2023-02-09 14:50 ` Benjamin Tissoires
@ 2023-02-09 15:50 ` Bastien Nocera
0 siblings, 0 replies; 9+ messages in thread
From: Bastien Nocera @ 2023-02-09 15:50 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: linux-input, linux-kernel, Jiri Kosina,
Peter F . Patel-Schneider, Filipe Laíns,
Nestor Lopez Casado
On Thu, 2023-02-09 at 15:50 +0100, Benjamin Tissoires wrote:
> On Feb 06 2023, Bastien Nocera wrote:
> > Handle the busy error coming from the device or receiver. The
> > documentation says a busy error can be returned when:
> > "
> > Device (or receiver) cannot answer immediately to this request
> > for any reason i.e:
> > - already processing a request from the same or another SW
> > - pipe full
> > "
> >
> > Signed-off-by: Bastien Nocera <hadess@hadess.net>
> > ---
> >
> > Same as v1
> >
> > drivers/hid/hid-logitech-hidpp.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-
> > logitech-hidpp.c
> > index 1952d8d3b6b2..9e94026de437 100644
> > --- a/drivers/hid/hid-logitech-hidpp.c
> > +++ b/drivers/hid/hid-logitech-hidpp.c
> > @@ -295,6 +295,7 @@ static int hidpp_send_message_sync(struct
> > hidpp_device *hidpp,
> > */
> > *response = *message;
> >
> > +retry:
> > ret = __hidpp_send_report(hidpp->hid_dev, message);
> >
> > if (ret) {
> > @@ -321,6 +322,10 @@ static int hidpp_send_message_sync(struct
> > hidpp_device *hidpp,
> > response->report_id ==
> > REPORT_ID_HIDPP_VERY_LONG) &&
> > response->fap.feature_index ==
> > HIDPP20_ERROR) {
> > ret = response->fap.params[1];
> > + if (ret == HIDPP20_ERROR_BUSY) {
> > + dbg_hid("%s:got busy hidpp 2.0 error %02X,
> > retrying\n", __func__, ret);
> > + goto retry;
>
> I must confess, I blocked a little bit there to decide whether or not
> using goto here was OK.
>
> But then I reliazed that there is no way to leave that function if
> the
> device is buggy and constantly sends back ERROR_BUSY. So I am not
> very
> found of the idea of having that got after all.
>
> Would you mind respinning that patch with a bounded loop for the
> retries
> instead of using a goto? I'd like the driver to give up after a few
> retries if the device is not fair.
Done in v3.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-02-09 15:50 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06 22:12 [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements Bastien Nocera
2023-02-06 22:12 ` [PATCH v2 2/3] HID: logitech-hidpp: Retry commands when device is busy Bastien Nocera
2023-02-09 14:50 ` Benjamin Tissoires
2023-02-09 15:50 ` Bastien Nocera
2023-02-06 22:12 ` [PATCH v2 3/3] HID: logitech-hidpp: Add myself to authors Bastien Nocera
2023-02-09 14:53 ` Benjamin Tissoires
2023-02-09 15:50 ` Bastien Nocera
2023-02-09 14:54 ` [PATCH v2 1/3] HID: logitech-hidpp: Add more debug statements Benjamin Tissoires
2023-02-09 15:39 ` (subset) " Benjamin Tissoires
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.