All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Tomlinson <edt@aei.ca>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>,
	Michael Poole <mdpoole@troilus.org>,
	linux-input@vger.kernel.org,
	Marcel Holtmann <marcel@holtmann.org>,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] Provide a driver for the Apple Magic Mouse - opps
Date: Sun, 14 Feb 2010 09:22:41 -0500	[thread overview]
Message-ID: <201002140922.42014.edt@aei.ca> (raw)
In-Reply-To: <20100214080344.GA4423@core.coreip.homeip.net>

On Sunday 14 February 2010 03:03:44 Dmitry Torokhov wrote:
> On Sat, Feb 13, 2010 at 02:29:29PM -0500, Ed Tomlinson wrote:
> > On Wednesday 10 February 2010 08:57:37 Jiri Kosina wrote:
> > > On Tue, 9 Feb 2010, Michael Poole wrote:
> > > 
> > > > I think this patch is ready for real review.  The Magic Mouse requires
> > > > that a driver send an unlock Report(Feature) command, similar to the
> > > > Wacom wireless tablet and Sixaxis controller quirks.  This turns on an
> > > > Input Report that isn't published in the input Report descriptor that
> > > > contains touch data (and usually overrides the normal motion and click
> > > > Report).
> > > > 
> > > > Because the mouse has only one switch and no scroll wheel, the driver
> > > > (under control of parameters) emulates a middle button and scroll wheel.
> > > > User space could also ignore and/or re-synthesize those events based on
> > > > the reported events.
> > > > 
> > > > The first patch exports hid_register_report() so the driver can turn on
> > > > the multitouch report.  The second patch adds the device ID and the
> > > > driver.  Some user-space tools to talk to the mouse directly (that is,
> > > > when it is not associated with the host's HIDP stack) are at
> > > > http://github.com/entrope/linux-magicmouse .
> > > 
> > > I have applied the driver into apple_magic_mouse branch and merged this 
> > > branch into for-next, so it should appear in the upcoming linux-next.
> > 
> 
> > This driver (or the hid changes) can triggers an opps.  What I did was
> > start X.  Turn on the magic mouse.  It connected on input7&8.  Then I
> > powered it off and on.  This time it conneced on input9&10.  Then I
> > exited X and got the opps.  Note my X does not hotplug the magic
> > mouse.  I've also included a trace of the udev events that generated
> > the log below (if there was a remove after X stopped it would not be
> > included).  To my eyes it looks like we leak an input device (there is
> > not a remove event for input8).
> >
> 
> Indeed, we seem to be missing call to input_unregister_device() in
> magicmouse_remove().

How does this look?  With this udevadm shows input8 being removed and
there is no more opps.

----
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index f94b3e4..71a8669 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -429,8 +429,11 @@ static int magicmouse_probe(struct hid_device *hdev,
 
 static void magicmouse_remove(struct hid_device *hdev)
 {
+	struct magicmouse_sc *msc;
+	msc = hid_get_drvdata(hdev);
+	input_unregister_device(msc->input);
 	hid_hw_stop(hdev);
-	kfree(hid_get_drvdata(hdev));
+	kfree(msc);
 }
 
 static const struct hid_device_id magic_mice[] = {
----

Thanks
Ed

WARNING: multiple messages have this Message-ID (diff)
From: Ed Tomlinson <edt-Yad3+ZauZac@public.gmane.org>
To: Dmitry Torokhov
	<dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Jiri Kosina <jkosina-AlSwsSmVLrQ@public.gmane.org>,
	Michael Poole <mdpoole-IZmAEv5cUt1AfugRpC6u6w@public.gmane.org>,
	linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Marcel Holtmann <marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 0/2] Provide a driver for the Apple Magic Mouse - opps
Date: Sun, 14 Feb 2010 09:22:41 -0500	[thread overview]
Message-ID: <201002140922.42014.edt@aei.ca> (raw)
In-Reply-To: <20100214080344.GA4423-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>

On Sunday 14 February 2010 03:03:44 Dmitry Torokhov wrote:
> On Sat, Feb 13, 2010 at 02:29:29PM -0500, Ed Tomlinson wrote:
> > On Wednesday 10 February 2010 08:57:37 Jiri Kosina wrote:
> > > On Tue, 9 Feb 2010, Michael Poole wrote:
> > > 
> > > > I think this patch is ready for real review.  The Magic Mouse requires
> > > > that a driver send an unlock Report(Feature) command, similar to the
> > > > Wacom wireless tablet and Sixaxis controller quirks.  This turns on an
> > > > Input Report that isn't published in the input Report descriptor that
> > > > contains touch data (and usually overrides the normal motion and click
> > > > Report).
> > > > 
> > > > Because the mouse has only one switch and no scroll wheel, the driver
> > > > (under control of parameters) emulates a middle button and scroll wheel.
> > > > User space could also ignore and/or re-synthesize those events based on
> > > > the reported events.
> > > > 
> > > > The first patch exports hid_register_report() so the driver can turn on
> > > > the multitouch report.  The second patch adds the device ID and the
> > > > driver.  Some user-space tools to talk to the mouse directly (that is,
> > > > when it is not associated with the host's HIDP stack) are at
> > > > http://github.com/entrope/linux-magicmouse .
> > > 
> > > I have applied the driver into apple_magic_mouse branch and merged this 
> > > branch into for-next, so it should appear in the upcoming linux-next.
> > 
> 
> > This driver (or the hid changes) can triggers an opps.  What I did was
> > start X.  Turn on the magic mouse.  It connected on input7&8.  Then I
> > powered it off and on.  This time it conneced on input9&10.  Then I
> > exited X and got the opps.  Note my X does not hotplug the magic
> > mouse.  I've also included a trace of the udev events that generated
> > the log below (if there was a remove after X stopped it would not be
> > included).  To my eyes it looks like we leak an input device (there is
> > not a remove event for input8).
> >
> 
> Indeed, we seem to be missing call to input_unregister_device() in
> magicmouse_remove().

How does this look?  With this udevadm shows input8 being removed and
there is no more opps.

----
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index f94b3e4..71a8669 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -429,8 +429,11 @@ static int magicmouse_probe(struct hid_device *hdev,
 
 static void magicmouse_remove(struct hid_device *hdev)
 {
+	struct magicmouse_sc *msc;
+	msc = hid_get_drvdata(hdev);
+	input_unregister_device(msc->input);
 	hid_hw_stop(hdev);
-	kfree(hid_get_drvdata(hdev));
+	kfree(msc);
 }
 
 static const struct hid_device_id magic_mice[] = {
----

Thanks
Ed

  reply	other threads:[~2010-02-14 14:22 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 14:20 [PATCH 0/3] HID: make raw output callback more flexible Jiri Kosina
2010-01-29 14:20 ` [PATCH 1/3] HID: make raw reports possible for both feature and output reports Jiri Kosina
2010-01-29 14:20 ` [PATCH 2/3] HID: Implement Wacom quirk in the kernel Jiri Kosina
2010-01-29 17:14   ` Ping Cheng
2010-02-03 14:50     ` Jiri Kosina
2010-01-29 14:21 ` [PATCH 3/3] HID: Enable Sixaxis controller over Bluetooth Jiri Kosina
2010-01-29 16:39 ` [PATCH 0/3] HID: make raw output callback more flexible Bastien Nocera
2010-01-30  0:46   ` Michael Poole
2010-01-30  0:46     ` Michael Poole
2010-01-30 14:11     ` Bastien Nocera
2010-01-31  3:27       ` Michael Poole
2010-01-31  3:27         ` Michael Poole
2010-02-03  1:25       ` Michael Poole
2010-02-03  1:25         ` Michael Poole
2010-02-03  9:47         ` Bastien Nocera
     [not found]           ` <alpine.LNX.2.00.1002031202040.15395@pobox.suse.cz>
2010-02-03 12:48             ` Jiri Kosina
2010-02-03 12:49               ` [PATCH 1/3] HID: make raw reports possible for both feature and output reports Jiri Kosina
2010-02-03 14:14                 ` Marcel Holtmann
2010-02-03 14:37                   ` Jiri Kosina
2010-02-03 12:49               ` [PATCH 2/3] HID: Implement Wacom quirk in the kernel Jiri Kosina
2010-02-03 14:19                 ` Marcel Holtmann
2010-02-03 14:40                   ` Jiri Kosina
2010-02-03 12:50               ` [PATCH 3/3] HID: Enable Sixaxis controller over Bluetooth Jiri Kosina
2010-02-03 14:17                 ` Marcel Holtmann
2010-02-03 14:42                   ` Jiri Kosina
2010-02-04 12:26       ` [PATCH] Bluetooth: Keep a copy of each HID device's report descriptor Michael Poole
2010-02-04 14:23         ` Marcel Holtmann
2010-02-05 17:23           ` Michael Poole
2010-02-05 17:23             ` Michael Poole
2010-02-05 17:51             ` Marcel Holtmann
2010-02-09  2:06               ` Ed Tomlinson
2010-02-09  7:22                 ` Justin Mattock
2010-02-09  7:22                   ` Justin Mattock
2010-02-09 10:14                   ` Bastien Nocera
2010-02-09 10:14                     ` Bastien Nocera
2010-02-09 12:36                     ` Ed Tomlinson
2010-02-09 12:40                       ` Jiri Kosina
2010-02-09 13:10                         ` [PATCH 0/2] Provide a driver for the Apple Magic Mouse Michael Poole
2010-02-09 13:10                           ` Michael Poole
2010-02-09 13:11                           ` [PATCH 1/2] " Michael Poole
2010-02-09 13:11                             ` Michael Poole
2010-02-09 13:11                             ` Michael Poole
2010-02-09 13:13                           ` [PATCH 2/2] Add a device " Michael Poole
2010-02-09 13:13                             ` Michael Poole
2010-02-10 13:06                             ` Jiri Kosina
2010-02-10 13:06                               ` Jiri Kosina
2010-02-10 13:58                               ` Jiri Kosina
2010-02-10 13:58                                 ` Jiri Kosina
2010-02-10 18:20                             ` Dmitry Torokhov
2010-02-10 20:31                               ` Michael Poole
2010-02-10 20:31                                 ` Michael Poole
2010-02-10 20:31                                 ` Michael Poole
2010-02-11  5:32                               ` [PATCH] hid-magicmouse: Coding style and probe failure fixes Michael Poole
2010-02-11  5:32                                 ` Michael Poole
2010-02-11  6:55                                 ` Dmitry Torokhov
2010-02-11  6:55                                   ` Dmitry Torokhov
2010-02-11 10:26                                 ` Jiri Kosina
2010-02-11 23:10                                   ` Michael Poole
2010-02-11  3:05                             ` [PATCH 2/2] Add a device driver for the Apple Magic Mouse Ed Tomlinson
2010-02-11  3:05                               ` Ed Tomlinson
2010-02-11  3:20                               ` Michael Poole
2010-02-11  3:20                                 ` Michael Poole
2010-02-11  3:20                                 ` Michael Poole
2010-02-11 12:51                                 ` [PATCH 2/2] Add a device driver for the Apple Magic Mouse (2.6.32.8) Ed Tomlinson
2010-02-09 21:37                           ` [PATCH 0/2] Provide a driver for the Apple Magic Mouse Justin P. Mattock
2010-02-09 21:37                             ` Justin P. Mattock
2010-02-10 13:57                           ` Jiri Kosina
2010-02-10 13:57                             ` Jiri Kosina
2010-02-13 19:29                             ` [PATCH 0/2] Provide a driver for the Apple Magic Mouse - opps Ed Tomlinson
2010-02-14  8:03                               ` Dmitry Torokhov
2010-02-14 14:22                                 ` Ed Tomlinson [this message]
2010-02-14 14:22                                   ` Ed Tomlinson
2010-02-15  7:11                                   ` Dmitry Torokhov
2010-02-15 12:42                                     ` Ed Tomlinson
2010-02-15 12:42                                       ` Ed Tomlinson
2010-02-15 12:44                                     ` Ed Tomlinson
2010-02-16 12:57                                       ` Jiri Kosina
2010-02-16 12:34                                     ` Ed Tomlinson
2010-02-16 12:55                                       ` Jiri Kosina
2010-02-14 22:24                             ` [PATCH 1/1] Enable xy scrolling for Apple Magic Mouse Ed Tomlinson
2010-02-14 22:24                               ` Ed Tomlinson
2010-02-14 22:51                               ` Michael Poole
2010-02-14 22:51                                 ` Michael Poole
2010-02-14 23:58                                 ` Ed Tomlinson
2010-02-14 23:58                                   ` Ed Tomlinson
2010-02-15  7:18                                   ` Dmitry Torokhov
2010-02-15 12:50                                     ` Ed Tomlinson
2010-02-15 12:50                                       ` Ed Tomlinson
2010-02-15  0:18                                 ` Ed Tomlinson
2010-02-09 15:03                     ` [PATCH] Bluetooth: Keep a copy of each HID device's report descriptor Justin P. Mattock
2010-02-05 12:49         ` Bastien Nocera
2010-02-05 13:27           ` Marcel Holtmann
2010-01-30 14:13 ` [PATCH 0/3] HID: make raw output callback more flexible Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201002140922.42014.edt@aei.ca \
    --to=edt@aei.ca \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mdpoole@troilus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.