Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1563713 > unrolled thread

[PATCH 0/4] HID: wacom: fixes for next

Started byBenjamin Tissoires <benjamin.tissoires@redhat.com>
First post2017-01-20 16:30 +0100
Last post2017-01-23 11:10 +0100
Articles 8 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/4] HID: wacom: fixes for next Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-20 16:30 +0100
    [PATCH 3/4] HID: wacom: do not attempt to switch mode while in probe Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-20 16:30 +0100
    [PATCH 4/4] HID: wacom: do not shout an error on LED control Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-20 16:30 +0100
      Re: [PATCH 4/4] HID: wacom: do not shout an error on LED control Jason Gerecke <killertofu@gmail.com> - 2017-01-21 03:40 +0100
    [PATCH 1/4] HID: wacom: release the resources before leaving despite devm Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-20 16:30 +0100
    Re: [PATCH 0/4] HID: wacom: fixes for next Jason Gerecke <killertofu@gmail.com> - 2017-01-21 03:40 +0100
      Re: [PATCH 0/4] HID: wacom: fixes for next Benjamin Tissoires <benjamin.tissoires@redhat.com> - 2017-01-23 09:10 +0100
        Re: [PATCH 0/4] HID: wacom: fixes for next Jiri Kosina <jikos@kernel.org> - 2017-01-23 11:10 +0100

#1563713 — [PATCH 0/4] HID: wacom: fixes for next

FromBenjamin Tissoires <benjamin.tissoires@redhat.com>
Date2017-01-20 16:30 +0100
Subject[PATCH 0/4] HID: wacom: fixes for next
Message-ID<t1Jiy-vy-9@gated-at.bofh.it>
Hi,

well, these are non critical but nonetheless interesting fixes for
Wacom I was working on last week. I was waiting for the current v4.10
fix to be sent by Jason before pushing those out.

Cheers,
Benjamin

Benjamin Tissoires (4):
  HID: wacom: release the resources before leaving despite devm
  HID: wacom: remove warning while disconnecting devices
  HID: wacom: do not attempt to switch mode while in probe
  HID: wacom: do not shout an error on LED control

 drivers/hid/wacom.h     |  1 +
 drivers/hid/wacom_sys.c | 42 ++++++++++++++++++++++++++++++------------
 2 files changed, 31 insertions(+), 12 deletions(-)

-- 
2.9.3

[toc] | [next] | [standalone]


#1563714 — [PATCH 3/4] HID: wacom: do not attempt to switch mode while in probe

FromBenjamin Tissoires <benjamin.tissoires@redhat.com>
Date2017-01-20 16:30 +0100
Subject[PATCH 3/4] HID: wacom: do not attempt to switch mode while in probe
Message-ID<t1Jiy-vy-11@gated-at.bofh.it>
In reply to#1563713
The Intuos Pro seems to not like when we set the features right after
being powered up. Instead of waiting during probe, we can schedule the
switch mode and LED control in a deferred worker so that we don't have the
5 secs of delay from USB when the device is not accessible.

The USB timeout delays were really a pain because if you happen to unplug
the tablet while it is still waiting, you are just adding 5 second timeouts
to the USB stack. Which means that a new plug of the same tablet will also
gets delayed, and will also attempt to access the hardware while in
.probe(). So the tablet doesn't appear in the dmesg, the user unplug/replug
it to make it appearing... and so on so forth.

Really, this is for the best :)

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/wacom.h     |  1 +
 drivers/hid/wacom_sys.c | 27 ++++++++++++++++++++-------
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index 020956c..3f650ce6 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -165,6 +165,7 @@ struct wacom {
 	struct work_struct wireless_work;
 	struct work_struct battery_work;
 	struct work_struct remote_work;
+	struct delayed_work init_work;
 	struct wacom_remote *remote;
 	struct wacom_leds {
 		struct wacom_group_leds *groups;
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 4a2c88d..6acb422 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -497,11 +497,11 @@ static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
  * from the tablet, it is necessary to switch the tablet out of this
  * mode and into one which sends the full range of tablet data.
  */
-static int wacom_query_tablet_data(struct hid_device *hdev,
-		struct wacom_features *features)
+static int _wacom_query_tablet_data(struct wacom *wacom)
 {
-	struct wacom *wacom = hid_get_drvdata(hdev);
+	struct hid_device *hdev = wacom->hdev;
 	struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+	struct wacom_features *features = &wacom_wac->features;
 
 	if (hdev->bus == BUS_BLUETOOTH)
 		return wacom_bt_query_tablet_data(hdev, 1, features);
@@ -1437,11 +1437,23 @@ static int wacom_initialize_leds(struct wacom *wacom)
 			"cannot create sysfs group err: %d\n", error);
 		return error;
 	}
-	wacom_led_control(wacom);
 
 	return 0;
 }
 
+static void wacom_init_work(struct work_struct *work)
+{
+	struct wacom *wacom = container_of(work, struct wacom, init_work.work);
+
+	_wacom_query_tablet_data(wacom);
+	wacom_led_control(wacom);
+}
+
+static void wacom_query_tablet_data(struct wacom *wacom)
+{
+	schedule_delayed_work(&wacom->init_work, msecs_to_jiffies(1000));
+}
+
 static enum power_supply_property wacom_battery_props[] = {
 	POWER_SUPPLY_PROP_MODEL_NAME,
 	POWER_SUPPLY_PROP_PRESENT,
@@ -2115,7 +2127,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
 
 	if (!wireless) {
 		/* Note that if query fails it is not a hard failure */
-		wacom_query_tablet_data(hdev, features);
+		wacom_query_tablet_data(wacom);
 	}
 
 	/* touch only Bamboo doesn't support pen */
@@ -2445,6 +2457,7 @@ static int wacom_probe(struct hid_device *hdev,
 	wacom->usbdev = dev;
 	wacom->intf = intf;
 	mutex_init(&wacom->lock);
+	INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work);
 	INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
 	INIT_WORK(&wacom->battery_work, wacom_battery_work);
 	INIT_WORK(&wacom->remote_work, wacom_remote_work);
@@ -2486,6 +2499,7 @@ static void wacom_remove(struct hid_device *hdev)
 
 	hid_hw_stop(hdev);
 
+	cancel_delayed_work_sync(&wacom->init_work);
 	cancel_work_sync(&wacom->wireless_work);
 	cancel_work_sync(&wacom->battery_work);
 	cancel_work_sync(&wacom->remote_work);
@@ -2503,12 +2517,11 @@ static void wacom_remove(struct hid_device *hdev)
 static int wacom_resume(struct hid_device *hdev)
 {
 	struct wacom *wacom = hid_get_drvdata(hdev);
-	struct wacom_features *features = &wacom->wacom_wac.features;
 
 	mutex_lock(&wacom->lock);
 
 	/* switch to wacom mode first */
-	wacom_query_tablet_data(hdev, features);
+	_wacom_query_tablet_data(wacom);
 	wacom_led_control(wacom);
 
 	mutex_unlock(&wacom->lock);
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1563715 — [PATCH 4/4] HID: wacom: do not shout an error on LED control

FromBenjamin Tissoires <benjamin.tissoires@redhat.com>
Date2017-01-20 16:30 +0100
Subject[PATCH 4/4] HID: wacom: do not shout an error on LED control
Message-ID<t1Jiy-vy-19@gated-at.bofh.it>
In reply to#1563713
At plug, the tablet seems to output a -EPIPE when first accessing the
LED. The weird part is that the command is taken into account by the
tablet, but we shout an error in the dmesg.

Cut off the error so that users are happier.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/wacom_sys.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 6acb422..6acf3a3 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -803,8 +803,12 @@ static int wacom_led_control(struct wacom *wacom)
 		buf[4] = wacom->led.img_lum;
 	}
 
-	retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, buf_size,
-				  WAC_CMD_RETRIES);
+	/*
+	 * we do not use wacom_set_report because -EPIPE happens but is
+	 * not fatal, so do not shout something at the user.
+	 */
+	retval = hid_hw_raw_request(wacom->hdev, buf[0], buf, buf_size,
+				    HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
 	kfree(buf);
 
 	return retval;
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1564045 — Re: [PATCH 4/4] HID: wacom: do not shout an error on LED control

FromJason Gerecke <killertofu@gmail.com>
Date2017-01-21 03:40 +0100
SubjectRe: [PATCH 4/4] HID: wacom: do not shout an error on LED control
Message-ID<t1TKV-6SF-1@gated-at.bofh.it>
In reply to#1563715
I'm not super comfortable with hiding this error. If the tablet reacts
appropriately, I wouldn't think we'd get an EPIPE. Although its not
fatal, it still might be a symptom of something deeper...

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....



On Fri, Jan 20, 2017 at 7:20 AM, Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
> At plug, the tablet seems to output a -EPIPE when first accessing the
> LED. The weird part is that the command is taken into account by the
> tablet, but we shout an error in the dmesg.
>
> Cut off the error so that users are happier.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
>  drivers/hid/wacom_sys.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index 6acb422..6acf3a3 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
> @@ -803,8 +803,12 @@ static int wacom_led_control(struct wacom *wacom)
>                 buf[4] = wacom->led.img_lum;
>         }
>
> -       retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, buf_size,
> -                                 WAC_CMD_RETRIES);
> +       /*
> +        * we do not use wacom_set_report because -EPIPE happens but is
> +        * not fatal, so do not shout something at the user.
> +        */
> +       retval = hid_hw_raw_request(wacom->hdev, buf[0], buf, buf_size,
> +                                   HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
>         kfree(buf);
>
>         return retval;
> --
> 2.9.3
>

[toc] | [prev] | [next] | [standalone]


#1563716 — [PATCH 1/4] HID: wacom: release the resources before leaving despite devm

FromBenjamin Tissoires <benjamin.tissoires@redhat.com>
Date2017-01-20 16:30 +0100
Subject[PATCH 1/4] HID: wacom: release the resources before leaving despite devm
Message-ID<t1Jiy-vy-13@gated-at.bofh.it>
In reply to#1563713
In the general case, the resources are properly released by devm without
needing to do anything. However, when unplugging the wireless receiver,
the kernel segfaults from time to time while calling devres_release_all().

I think in that case the resources attempt to access hid_get_drvdata(hdev)
which has been set to null while leaving wacom_remove().

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/wacom_sys.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 23b272a..734100a 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -2495,6 +2495,8 @@ static void wacom_remove(struct hid_device *hdev)
 	if (hdev->bus == BUS_BLUETOOTH)
 		device_remove_file(&hdev->dev, &dev_attr_speed);
 
+	wacom_release_resources(wacom);
+
 	hid_set_drvdata(hdev, NULL);
 }
 
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1564046

FromJason Gerecke <killertofu@gmail.com>
Date2017-01-21 03:40 +0100
Message-ID<t1TKV-6SF-9@gated-at.bofh.it>
In reply to#1563713
Patches 1/3 look reasonable to me, though I've not run into the bugs
they aim to fix. For those:

Acked-by: Jason Gerecke <jason.gerecke@wacom.com>

As for patch 4, I have some additional reservations about hiding the
message... We can discuss that further in its thread.

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....



On Fri, Jan 20, 2017 at 7:20 AM, Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
> Hi,
>
> well, these are non critical but nonetheless interesting fixes for
> Wacom I was working on last week. I was waiting for the current v4.10
> fix to be sent by Jason before pushing those out.
>
> Cheers,
> Benjamin
>
> Benjamin Tissoires (4):
>   HID: wacom: release the resources before leaving despite devm
>   HID: wacom: remove warning while disconnecting devices
>   HID: wacom: do not attempt to switch mode while in probe
>   HID: wacom: do not shout an error on LED control
>
>  drivers/hid/wacom.h     |  1 +
>  drivers/hid/wacom_sys.c | 42 ++++++++++++++++++++++++++++++------------
>  2 files changed, 31 insertions(+), 12 deletions(-)
>
> --
> 2.9.3
>

[toc] | [prev] | [next] | [standalone]


#1564748

FromBenjamin Tissoires <benjamin.tissoires@redhat.com>
Date2017-01-23 09:10 +0100
Message-ID<t2HRn-3Xz-17@gated-at.bofh.it>
In reply to#1564046
On Jan 20 2017 or thereabouts, Jason Gerecke wrote:
> Patches 1/3 look reasonable to me, though I've not run into the bugs
> they aim to fix. For those:
> 
> Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
> 
> As for patch 4, I have some additional reservations about hiding the
> message... We can discuss that further in its thread.
> 

Yeah, I am fine dropping patch 4. Thanks for the review/tests Jason!

Cheers,
Benjamin

> Jason
> ---
> Now instead of four in the eights place /
> you’ve got three, ‘Cause you added one  /
> (That is to say, eight) to the two,     /
> But you can’t take seven from three,    /
> So you look at the sixty-fours....
> 
> 
> 
> On Fri, Jan 20, 2017 at 7:20 AM, Benjamin Tissoires
> <benjamin.tissoires@redhat.com> wrote:
> > Hi,
> >
> > well, these are non critical but nonetheless interesting fixes for
> > Wacom I was working on last week. I was waiting for the current v4.10
> > fix to be sent by Jason before pushing those out.
> >
> > Cheers,
> > Benjamin
> >
> > Benjamin Tissoires (4):
> >   HID: wacom: release the resources before leaving despite devm
> >   HID: wacom: remove warning while disconnecting devices
> >   HID: wacom: do not attempt to switch mode while in probe
> >   HID: wacom: do not shout an error on LED control
> >
> >  drivers/hid/wacom.h     |  1 +
> >  drivers/hid/wacom_sys.c | 42 ++++++++++++++++++++++++++++++------------
> >  2 files changed, 31 insertions(+), 12 deletions(-)
> >
> > --
> > 2.9.3
> >

[toc] | [prev] | [next] | [standalone]


#1564841

FromJiri Kosina <jikos@kernel.org>
Date2017-01-23 11:10 +0100
Message-ID<t2JJw-56E-37@gated-at.bofh.it>
In reply to#1564748
On Mon, 23 Jan 2017, Benjamin Tissoires wrote:

> > Patches 1/3 look reasonable to me, though I've not run into the bugs
> > they aim to fix. For those:
> > 
> > Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
> > 
> > As for patch 4, I have some additional reservations about hiding the
> > message... We can discuss that further in its thread.
> > 
> 
> Yeah, I am fine dropping patch 4. Thanks for the review/tests Jason!

I've applied patches 1-3. Thanks,

-- 
Jiri Kosina
SUSE Labs

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web