* [PATCH] HID: rmi: Make sure the HID device is opened on resume @ 2017-07-23 1:15 Lyude 2017-07-23 9:54 ` Andy Shevchenko 2017-07-24 8:15 ` Benjamin Tissoires 0 siblings, 2 replies; 9+ messages in thread From: Lyude @ 2017-07-23 1:15 UTC (permalink / raw) To: linux-input Cc: Lyude, Andrew Duggan, stable, Jiri Kosina, Benjamin Tissoires, linux-kernel So it looks like that suspend/resume has actually always been broken on hid-rmi. The fact it worked was a rather silly coincidence that was relying on the HID device to already be opened upon resume. This means that so long as anything was reading the /dev/input/eventX node for for an RMI device, it would suspend and resume correctly. As well, if nothing happened to be keeping the HID device away it would shut off, then the RMI driver would get confused on resume when it stopped responding and explode. So, call hid_hw_open() in rmi_post_resume() so we make sure that the device is alive before we try talking to it. This fixes RMI device suspend/resume over HID. Signed-off-by: Lyude <lyude@redhat.com> Cc: Andrew Duggan <aduggan@synaptics.com> Cc: stable@vger.kernel.org --- drivers/hid/hid-rmi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index 5b40c2614599..e7d124f9a27f 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c @@ -431,22 +431,29 @@ static int rmi_post_resume(struct hid_device *hdev) { struct rmi_data *data = hid_get_drvdata(hdev); struct rmi_device *rmi_dev = data->xport.rmi_dev; - int ret; + int ret = 0; if (!(data->device_flags & RMI_DEVICE)) return 0; - ret = rmi_reset_attn_mode(hdev); + /* Make sure the HID device is ready to receive events */ + ret = hid_hw_open(hdev); if (ret) return ret; + ret = rmi_reset_attn_mode(hdev); + if (ret) + goto out; + ret = rmi_driver_resume(rmi_dev, false); if (ret) { hid_warn(hdev, "Failed to resume device: %d\n", ret); - return ret; + goto out; } - return 0; +out: + hid_hw_close(hdev); + return ret; } #endif /* CONFIG_PM */ -- 2.13.3 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] HID: rmi: Make sure the HID device is opened on resume 2017-07-23 1:15 [PATCH] HID: rmi: Make sure the HID device is opened on resume Lyude @ 2017-07-23 9:54 ` Andy Shevchenko 2017-07-24 17:45 ` Lyude Paul 2017-07-24 8:15 ` Benjamin Tissoires 1 sibling, 1 reply; 9+ messages in thread From: Andy Shevchenko @ 2017-07-23 9:54 UTC (permalink / raw) To: Lyude Cc: linux-input, Andrew Duggan, stable, Jiri Kosina, Benjamin Tissoires, linux-kernel@vger.kernel.org On Sun, Jul 23, 2017 at 4:15 AM, Lyude <lyude@redhat.com> wrote: > So, call hid_hw_open() in rmi_post_resume() so we make sure that the > device is alive before we try talking to it. > > This fixes RMI device suspend/resume over HID. > - int ret; > + int ret = 0; What's the point? > > if (!(data->device_flags & RMI_DEVICE)) > return 0; > > - ret = rmi_reset_attn_mode(hdev); > + /* Make sure the HID device is ready to receive events */ > + ret = hid_hw_open(hdev); > if (ret) > return ret; -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] HID: rmi: Make sure the HID device is opened on resume 2017-07-23 9:54 ` Andy Shevchenko @ 2017-07-24 17:45 ` Lyude Paul 2017-07-24 19:28 ` Jiri Kosina 0 siblings, 1 reply; 9+ messages in thread From: Lyude Paul @ 2017-07-24 17:45 UTC (permalink / raw) To: Andy Shevchenko Cc: linux-input, Andrew Duggan, stable, Jiri Kosina, Benjamin Tissoires, linux-kernel@vger.kernel.org On Sun, 2017-07-23 at 12:54 +0300, Andy Shevchenko wrote: > On Sun, Jul 23, 2017 at 4:15 AM, Lyude <lyude@redhat.com> wrote: > > > So, call hid_hw_open() in rmi_post_resume() so we make sure that > > the > > device is alive before we try talking to it. > > > > This fixes RMI device suspend/resume over HID. > > - int ret; > > + int ret = 0; > > What's the point? So that we can use the same out: label at the end of the function that calls hid_hw_close() to return success. This being said though I just realized that setting ret will initialize it to 0 anyway, so I guess this can be dropped > > > > > if (!(data->device_flags & RMI_DEVICE)) > > return 0; > > > > - ret = rmi_reset_attn_mode(hdev); > > + /* Make sure the HID device is ready to receive events */ > > + ret = hid_hw_open(hdev); > > if (ret) > > return ret; > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] HID: rmi: Make sure the HID device is opened on resume 2017-07-24 17:45 ` Lyude Paul @ 2017-07-24 19:28 ` Jiri Kosina 2017-07-24 19:46 ` Lyude Paul 0 siblings, 1 reply; 9+ messages in thread From: Jiri Kosina @ 2017-07-24 19:28 UTC (permalink / raw) To: Lyude Paul Cc: Andy Shevchenko, linux-input, Andrew Duggan, stable, Benjamin Tissoires, linux-kernel@vger.kernel.org On Mon, 24 Jul 2017, Lyude Paul wrote: > > > So, call hid_hw_open() in rmi_post_resume() so we make sure that > > > the > > > device is alive before we try talking to it. > > > > > > This fixes RMI device suspend/resume over HID. > > > - int ret; > > > + int ret = 0; > > > > What's the point? > So that we can use the same out: label at the end of the function that > calls hid_hw_close() to return success. This being said though I just > realized that setting ret will initialize it to 0 anyway, so I guess > this can be dropped Andy's point was that hid_hw_open() is obviously re-initializing the ret before its first use as a return value, so there is no need to initialize it at a declaration time. -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] HID: rmi: Make sure the HID device is opened on resume 2017-07-24 19:28 ` Jiri Kosina @ 2017-07-24 19:46 ` Lyude Paul 0 siblings, 0 replies; 9+ messages in thread From: Lyude Paul @ 2017-07-24 19:46 UTC (permalink / raw) To: Jiri Kosina Cc: Andy Shevchenko, linux-input, Andrew Duggan, stable, Benjamin Tissoires, linux-kernel@vger.kernel.org Yeah I noticed that, sorry if my response wasn't very clear! Should probably wait to have my morning coffee before responding to these messages :P On Mon, 2017-07-24 at 21:28 +0200, Jiri Kosina wrote: > On Mon, 24 Jul 2017, Lyude Paul wrote: > > > > > So, call hid_hw_open() in rmi_post_resume() so we make sure > > > > that > > > > the > > > > device is alive before we try talking to it. > > > > > > > > This fixes RMI device suspend/resume over HID. > > > > - int ret; > > > > + int ret = 0; > > > > > > What's the point? > > > > So that we can use the same out: label at the end of the function > > that > > calls hid_hw_close() to return success. This being said though I > > just > > realized that setting ret will initialize it to 0 anyway, so I > > guess > > this can be dropped > > Andy's point was that hid_hw_open() is obviously re-initializing the > ret > before its first use as a return value, so there is no need to > initialize > it at a declaration time. > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] HID: rmi: Make sure the HID device is opened on resume 2017-07-23 1:15 [PATCH] HID: rmi: Make sure the HID device is opened on resume Lyude 2017-07-23 9:54 ` Andy Shevchenko @ 2017-07-24 8:15 ` Benjamin Tissoires 2017-07-24 17:49 ` Lyude Paul 1 sibling, 1 reply; 9+ messages in thread From: Benjamin Tissoires @ 2017-07-24 8:15 UTC (permalink / raw) To: Lyude; +Cc: linux-input, Andrew Duggan, stable, Jiri Kosina, linux-kernel On Jul 22 2017 or thereabouts, Lyude wrote: > So it looks like that suspend/resume has actually always been broken on > hid-rmi. The fact it worked was a rather silly coincidence that was > relying on the HID device to already be opened upon resume. This means > that so long as anything was reading the /dev/input/eventX node for for > an RMI device, it would suspend and resume correctly. As well, if > nothing happened to be keeping the HID device away it would shut off, > then the RMI driver would get confused on resume when it stopped > responding and explode. Oh, good finding. However, given that there are few other drivers not calling hid_hw_open during their .reset_resume() callback and those drivers also are communicating with the device, I wonder if we should not have something more generic, that will call hid_hw_open/close in the transport layer directly. I do not recall having seen bugs for Wacom devices, so maybe this is something i2c-hid related, but it wouldn't hurt I guess to open/close the device before calling reset_resume. Cheers, Benjamin > > So, call hid_hw_open() in rmi_post_resume() so we make sure that the > device is alive before we try talking to it. > > This fixes RMI device suspend/resume over HID. > > Signed-off-by: Lyude <lyude@redhat.com> > Cc: Andrew Duggan <aduggan@synaptics.com> > Cc: stable@vger.kernel.org > --- > drivers/hid/hid-rmi.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c > index 5b40c2614599..e7d124f9a27f 100644 > --- a/drivers/hid/hid-rmi.c > +++ b/drivers/hid/hid-rmi.c > @@ -431,22 +431,29 @@ static int rmi_post_resume(struct hid_device *hdev) > { > struct rmi_data *data = hid_get_drvdata(hdev); > struct rmi_device *rmi_dev = data->xport.rmi_dev; > - int ret; > + int ret = 0; > > if (!(data->device_flags & RMI_DEVICE)) > return 0; > > - ret = rmi_reset_attn_mode(hdev); > + /* Make sure the HID device is ready to receive events */ > + ret = hid_hw_open(hdev); > if (ret) > return ret; > > + ret = rmi_reset_attn_mode(hdev); > + if (ret) > + goto out; > + > ret = rmi_driver_resume(rmi_dev, false); > if (ret) { > hid_warn(hdev, "Failed to resume device: %d\n", ret); > - return ret; > + goto out; > } > > - return 0; > +out: > + hid_hw_close(hdev); > + return ret; > } > #endif /* CONFIG_PM */ > > -- > 2.13.3 > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] HID: rmi: Make sure the HID device is opened on resume 2017-07-24 8:15 ` Benjamin Tissoires @ 2017-07-24 17:49 ` Lyude Paul 2017-09-08 7:16 ` Benjamin Tissoires 0 siblings, 1 reply; 9+ messages in thread From: Lyude Paul @ 2017-07-24 17:49 UTC (permalink / raw) To: Benjamin Tissoires Cc: linux-input, Andrew Duggan, stable, Jiri Kosina, linux-kernel On Mon, 2017-07-24 at 10:15 +0200, Benjamin Tissoires wrote: > On Jul 22 2017 or thereabouts, Lyude wrote: > > So it looks like that suspend/resume has actually always been > > broken on > > hid-rmi. The fact it worked was a rather silly coincidence that was > > relying on the HID device to already be opened upon resume. This > > means > > that so long as anything was reading the /dev/input/eventX node for > > for > > an RMI device, it would suspend and resume correctly. As well, if > > nothing happened to be keeping the HID device away it would shut > > off, > > then the RMI driver would get confused on resume when it stopped > > responding and explode. > > Oh, good finding. However, given that there are few other drivers not > calling hid_hw_open during their .reset_resume() callback and those > drivers also are communicating with the device, I wonder if we should > not have something more generic, that will call hid_hw_open/close in > the > transport layer directly. This sounds like a good idea, especially since a call like this is rather easy to miss. I will look into doing that for v2 > > I do not recall having seen bugs for Wacom devices, so maybe this is > something i2c-hid related, but it wouldn't hurt I guess to open/close > the device before calling reset_resume. > > Cheers, > Benjamin > > > > > So, call hid_hw_open() in rmi_post_resume() so we make sure that > > the > > device is alive before we try talking to it. > > > > This fixes RMI device suspend/resume over HID. > > > > Signed-off-by: Lyude <lyude@redhat.com> > > Cc: Andrew Duggan <aduggan@synaptics.com> > > Cc: stable@vger.kernel.org > > --- > > drivers/hid/hid-rmi.c | 15 +++++++++++---- > > 1 file changed, 11 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c > > index 5b40c2614599..e7d124f9a27f 100644 > > --- a/drivers/hid/hid-rmi.c > > +++ b/drivers/hid/hid-rmi.c > > @@ -431,22 +431,29 @@ static int rmi_post_resume(struct hid_device > > *hdev) > > { > > struct rmi_data *data = hid_get_drvdata(hdev); > > struct rmi_device *rmi_dev = data->xport.rmi_dev; > > - int ret; > > + int ret = 0; > > > > if (!(data->device_flags & RMI_DEVICE)) > > return 0; > > > > - ret = rmi_reset_attn_mode(hdev); > > + /* Make sure the HID device is ready to receive events */ > > + ret = hid_hw_open(hdev); > > if (ret) > > return ret; > > > > + ret = rmi_reset_attn_mode(hdev); > > + if (ret) > > + goto out; > > + > > ret = rmi_driver_resume(rmi_dev, false); > > if (ret) { > > hid_warn(hdev, "Failed to resume device: %d\n", > > ret); > > - return ret; > > + goto out; > > } > > > > - return 0; > > +out: > > + hid_hw_close(hdev); > > + return ret; > > } > > #endif /* CONFIG_PM */ > > > > -- > > 2.13.3 > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] HID: rmi: Make sure the HID device is opened on resume 2017-07-24 17:49 ` Lyude Paul @ 2017-09-08 7:16 ` Benjamin Tissoires 2017-09-08 13:01 ` Jiri Kosina 0 siblings, 1 reply; 9+ messages in thread From: Benjamin Tissoires @ 2017-09-08 7:16 UTC (permalink / raw) To: Lyude Paul; +Cc: linux-input, Andrew Duggan, stable, Jiri Kosina, linux-kernel On Jul 24 2017 or thereabouts, Lyude Paul wrote: > On Mon, 2017-07-24 at 10:15 +0200, Benjamin Tissoires wrote: > > On Jul 22 2017 or thereabouts, Lyude wrote: > > > So it looks like that suspend/resume has actually always been > > > broken on > > > hid-rmi. The fact it worked was a rather silly coincidence that was > > > relying on the HID device to already be opened upon resume. This > > > means > > > that so long as anything was reading the /dev/input/eventX node for > > > for > > > an RMI device, it would suspend and resume correctly. As well, if > > > nothing happened to be keeping the HID device away it would shut > > > off, > > > then the RMI driver would get confused on resume when it stopped > > > responding and explode. > > > > Oh, good finding. However, given that there are few other drivers not > > calling hid_hw_open during their .reset_resume() callback and those > > drivers also are communicating with the device, I wonder if we should > > not have something more generic, that will call hid_hw_open/close in > > the > > transport layer directly. > This sounds like a good idea, especially since a call like this is > rather easy to miss. I will look into doing that for v2 I know I requested a v2, but meanwhile some users are experiencing delays at resume: https://bugzilla.kernel.org/show_bug.cgi?id=196851 Jiri, could you take this one in v4.14 (maybe with @stable) and we'll figure out a way to fix this properly later (looks like the .resume and .reset_resume are called from the transport drivers, not hid-core, so we might need a little bit of testing). In its current form (with the nitpick Andy noticed): Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Cheers, Benjamin > > > > I do not recall having seen bugs for Wacom devices, so maybe this is > > something i2c-hid related, but it wouldn't hurt I guess to open/close > > the device before calling reset_resume. > > > > Cheers, > > Benjamin > > > > > > > > So, call hid_hw_open() in rmi_post_resume() so we make sure that > > > the > > > device is alive before we try talking to it. > > > > > > This fixes RMI device suspend/resume over HID. > > > > > > Signed-off-by: Lyude <lyude@redhat.com> > > > Cc: Andrew Duggan <aduggan@synaptics.com> > > > Cc: stable@vger.kernel.org > > > --- > > > drivers/hid/hid-rmi.c | 15 +++++++++++---- > > > 1 file changed, 11 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c > > > index 5b40c2614599..e7d124f9a27f 100644 > > > --- a/drivers/hid/hid-rmi.c > > > +++ b/drivers/hid/hid-rmi.c > > > @@ -431,22 +431,29 @@ static int rmi_post_resume(struct hid_device > > > *hdev) > > > { > > > struct rmi_data *data = hid_get_drvdata(hdev); > > > struct rmi_device *rmi_dev = data->xport.rmi_dev; > > > - int ret; > > > + int ret = 0; > > > > > > if (!(data->device_flags & RMI_DEVICE)) > > > return 0; > > > > > > - ret = rmi_reset_attn_mode(hdev); > > > + /* Make sure the HID device is ready to receive events */ > > > + ret = hid_hw_open(hdev); > > > if (ret) > > > return ret; > > > > > > + ret = rmi_reset_attn_mode(hdev); > > > + if (ret) > > > + goto out; > > > + > > > ret = rmi_driver_resume(rmi_dev, false); > > > if (ret) { > > > hid_warn(hdev, "Failed to resume device: %d\n", > > > ret); > > > - return ret; > > > + goto out; > > > } > > > > > > - return 0; > > > +out: > > > + hid_hw_close(hdev); > > > + return ret; > > > } > > > #endif /* CONFIG_PM */ > > > > > > -- > > > 2.13.3 > > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] HID: rmi: Make sure the HID device is opened on resume 2017-09-08 7:16 ` Benjamin Tissoires @ 2017-09-08 13:01 ` Jiri Kosina 0 siblings, 0 replies; 9+ messages in thread From: Jiri Kosina @ 2017-09-08 13:01 UTC (permalink / raw) To: Benjamin Tissoires Cc: Lyude Paul, linux-input, Andrew Duggan, stable, linux-kernel On Fri, 8 Sep 2017, Benjamin Tissoires wrote: > I know I requested a v2, but meanwhile some users are experiencing > delays at resume: > https://bugzilla.kernel.org/show_bug.cgi?id=196851 > > Jiri, could you take this one in v4.14 (maybe with @stable) and we'll > figure out a way to fix this properly later (looks like the .resume and > .reset_resume are called from the transport drivers, not hid-core, so we > might need a little bit of testing). > > In its current form (with the nitpick Andy noticed): > Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Ok, makes sense. Now applied to for-4.14/upstream-fixes. Thanks, -- Jiri Kosina SUSE Labs ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-09-08 13:02 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-23 1:15 [PATCH] HID: rmi: Make sure the HID device is opened on resume Lyude 2017-07-23 9:54 ` Andy Shevchenko 2017-07-24 17:45 ` Lyude Paul 2017-07-24 19:28 ` Jiri Kosina 2017-07-24 19:46 ` Lyude Paul 2017-07-24 8:15 ` Benjamin Tissoires 2017-07-24 17:49 ` Lyude Paul 2017-09-08 7:16 ` Benjamin Tissoires 2017-09-08 13:01 ` Jiri Kosina
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).