From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Marcus Folkesson <marcus.folkesson@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
Tomohiro Yoshidomi <sylph23k@gmail.com>,
David Herrmann <dh.herrmann@gmail.com>,
Philippe Ombredanne <pombredanne@nexb.com>,
Kate Stewart <kstewart@linuxfoundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-input@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] input: pxrc: new driver for PhoenixRC Flight Controller Adapter
Date: Fri, 19 Jan 2018 15:24:32 -0800 [thread overview]
Message-ID: <20180119232432.xygulmwpkw3vogls@dtor-ws> (raw)
In-Reply-To: <20180117135840.GA10949@gmail.com>
On Wed, Jan 17, 2018 at 02:58:40PM +0100, Marcus Folkesson wrote:
> Hello Dmitry,
>
> On Tue, Jan 16, 2018 at 03:16:25PM -0800, Dmitry Torokhov wrote:
> > Hi Marcus,
> >
> > On Sat, Jan 13, 2018 at 09:15:32PM +0100, Marcus Folkesson wrote:
> > > This driver let you plug in your RC controller to the adapter and
> > > use it as input device in various RC simulators.
> > >
> > > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > > ---
> > > v3:
> > > - Use RUDDER and MISC instead of TILT_X and TILT_Y
> > > - Drop kref and anchor
> > > - Rework URB handling
> > > - Add PM support
> >
> > How did you test the PM support? By default the autopm is disabled on
> > USB devices; you need to enable it by writing to sysfs (I believe you
> > need to 'echo "auto" > /sys/bus/usb/<device>/power/control) and see if
> > it gets autosuspended when not in use and resumed after you start
> > interacting with it.
>
> The test I've done is simply reading from the input device and then call
> `pm-suspend`.
> It works, suspend is called and reset_resume() will submit the URB
> again. Without the PM code, the application did not read any events upon
> resume.
We are talking about different things. You are testing system suspend,
whereas I was talking about runtime suspend (that's what
usb_autopm_get_interface() and friends does). It is disabled by default
and you need to enable it by writing into sysfs as I mentioned above.
Then, after a few seconds of not touching the device you should see the
USB interface going into low power state and the device shoudl correctly
implement remote wakeup signal to wake up the host controller/port when
user touches it. If the device does not implement this correctly, then
after suspending it will "die".
>
> However, I found another tricky part.
> If I enable autosuspend (as you suggest) it will suspend when noone is
> using the device. Good.
>
> But when someone is opening the device, input_dev->users is counted up
> to 1 before resume() is called.
> Is this intended?
>
> This code (from resume()) will therefor allways submit the URB:
>
> if (input_dev->users && usb_submit_urb(pxrc->urb, GFP_NOIO) < 0)
>
>
> Then open() is called and fails because the urb is allready submitted.
>
> input_dev->users is only incremented in input.c:input_open_device() what
> I can tell?
It is intended, but I guess we should not be using input_dev->users in
resume(), but rather have a local flag in your driver structure trhat
you update at the right time (i.e. after you submit USB in pxrc_open()).
I suppose we need the same fix in synaptics_usb.c...
>
> I will move the submitting code to reset_resume() instead.
You need both resume() and reset_resume(), they are called in different
cases and you need to restart IO in both cases.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2018-01-19 23:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-13 20:15 [PATCH v3] input: pxrc: new driver for PhoenixRC Flight Controller Adapter Marcus Folkesson
2018-01-16 23:16 ` Dmitry Torokhov
2018-01-17 13:58 ` Marcus Folkesson
2018-01-19 23:24 ` Dmitry Torokhov [this message]
2018-01-20 21:07 ` Marcus Folkesson
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=20180119232432.xygulmwpkw3vogls@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=corbet@lwn.net \
--cc=dh.herrmann@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kstewart@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcus.folkesson@gmail.com \
--cc=pombredanne@nexb.com \
--cc=sylph23k@gmail.com \
/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 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).