diff mbox series

HID: i2c-hid: Prefer asynchronous probe

Message ID 20200902214250.1.I63d3f1c93f88cb0cda5161c42e97decb4a63a571@changeid
State Accepted
Commit eafb2203626aedb599cc80aadcba533c917b53b0
Headers show
Series HID: i2c-hid: Prefer asynchronous probe | expand

Commit Message

Doug Anderson Sept. 3, 2020, 4:43 a.m. UTC
Adding printouts to the i2c_hid_probe() function shows that it takes
quite some time.  It used to take about 70 ms, but after commit
eef4016243e9 ("HID: i2c-hid: Always sleep 60ms after I2C_HID_PWR_ON
commands") it takes about 190 ms.  This is not tons of time but it's
not trivial.  Because we haven't yet specified that we'd prefer
asynchronous probe for this driver then, if the driver is builtin to
the kernel, we'll wait for this driver to finish before we start
probes for more drivers.  Let's set the flag to enable asynchronous
for this driver so that other drivers aren't blocked from probing
until we finish.

Since this driver can be configured as a module and modules are
always asynchronously probed this is quite a safe change and will
benefit anyone who has a reason to build this driver into the kernel
instead of using it as a module.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

 drivers/hid/i2c-hid/i2c-hid-core.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Doug Anderson Sept. 3, 2020, 3:22 p.m. UTC | #1
Hi,

On Wed, Sep 2, 2020 at 9:43 PM Douglas Anderson <dianders@chromium.org> wrote:
>
> Adding printouts to the i2c_hid_probe() function shows that it takes
> quite some time.  It used to take about 70 ms, but after commit
> eef4016243e9 ("HID: i2c-hid: Always sleep 60ms after I2C_HID_PWR_ON
> commands") it takes about 190 ms.  This is not tons of time but it's
> not trivial.  Because we haven't yet specified that we'd prefer
> asynchronous probe for this driver then, if the driver is builtin to
> the kernel, we'll wait for this driver to finish before we start
> probes for more drivers.  Let's set the flag to enable asynchronous
> for this driver so that other drivers aren't blocked from probing
> until we finish.
>
> Since this driver can be configured as a module and modules are
> always asynchronously probed this is quite a safe change and will
> benefit anyone who has a reason to build this driver into the kernel
> instead of using it as a module.
>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
>  drivers/hid/i2c-hid/i2c-hid-core.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
> index 87ff93bf76ba..c898bd8617f9 100644
> --- a/drivers/hid/i2c-hid/i2c-hid-core.c
> +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
> @@ -1280,8 +1280,10 @@ static struct i2c_driver i2c_hid_driver = {
>         .driver = {
>                 .name   = "i2c_hid",
>                 .pm     = &i2c_hid_pm,
> +               .probe_type = PROBE_PREFER_ASYNCHRONOUS,
>                 .acpi_match_table = ACPI_PTR(i2c_hid_acpi_match),
>                 .of_match_table = of_match_ptr(i2c_hid_of_match),
> +

Boy, I'm not sure how I managed to introduce this extra whitespace
without noticing.  Sorry!  :(  If the patch looks good I'm happy to
re-post or I'm happy if a maintainer wants to fix my mistake when
applying.

-Doug
Jiri Kosina Sept. 9, 2020, 6:39 a.m. UTC | #2
On Wed, 2 Sep 2020, Douglas Anderson wrote:

> Adding printouts to the i2c_hid_probe() function shows that it takes
> quite some time.  It used to take about 70 ms, but after commit
> eef4016243e9 ("HID: i2c-hid: Always sleep 60ms after I2C_HID_PWR_ON
> commands") it takes about 190 ms.  This is not tons of time but it's
> not trivial.  Because we haven't yet specified that we'd prefer
> asynchronous probe for this driver then, if the driver is builtin to
> the kernel, we'll wait for this driver to finish before we start
> probes for more drivers.  Let's set the flag to enable asynchronous
> for this driver so that other drivers aren't blocked from probing
> until we finish.
> 
> Since this driver can be configured as a module and modules are
> always asynchronously probed this is quite a safe change and will
> benefit anyone who has a reason to build this driver into the kernel
> instead of using it as a module.
> 
> Signed-off-by: Douglas Anderson <dianders@chromium.org>

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 87ff93bf76ba..c898bd8617f9 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -1280,8 +1280,10 @@  static struct i2c_driver i2c_hid_driver = {
 	.driver = {
 		.name	= "i2c_hid",
 		.pm	= &i2c_hid_pm,
+		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.acpi_match_table = ACPI_PTR(i2c_hid_acpi_match),
 		.of_match_table = of_match_ptr(i2c_hid_of_match),
+
 	},
 
 	.probe		= i2c_hid_probe,