From: Guenter Roeck <linux@roeck-us.net>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [v2] usb: typec: fusb302: Fix debugfs mutex initialisation
Date: Mon, 18 Mar 2019 11:18:41 -0700 [thread overview]
Message-ID: <20190318181841.GA25132@roeck-us.net> (raw)
On Mon, Mar 18, 2019 at 05:49:06PM +0000, Marc Zyngier wrote:
> Running a kernel with the fusb302 driver and lockdep enabled
> leads to an unpleasant warning:
>
> [ 4.617477] INFO: trying to register non-static key.
> [ 4.617930] the code is fine but needs lockdep annotation.
> [ 4.618418] turning off the locking correctness validator.
> [ 4.618913] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.1.0-rc1-00007-g3542533f3fc9 #13
> [ 4.619620] Hardware name: rockchip evb_rk3399/evb_rk3399, BIOS 2019.04-rc3-00124-g2feec69fb1 03/15/2019
> [ 4.620454] Call trace:
> [ 4.620693] dump_backtrace+0x0/0x138
> [ 4.621028] show_stack+0x24/0x30
> [ 4.621336] dump_stack+0xbc/0x104
> [ 4.621649] register_lock_class+0x594/0x598
> [ 4.622036] __lock_acquire+0x80/0x11b8
> [ 4.622384] lock_acquire+0xdc/0x260
> [ 4.622711] __mutex_lock+0x90/0x8a0
> [ 4.623037] mutex_lock_nested+0x3c/0x50
> [ 4.623394] _fusb302_log+0x88/0x1f0
> [ 4.623721] fusb302_log+0x7c/0xa0
> [ 4.624033] tcpm_init+0x5c/0x190
> [ 4.624336] tcpm_init+0x3c/0x130
> [ 4.624640] tcpm_register_port+0x574/0x878
> [ 4.625019] fusb302_probe+0x2c8/0x590
>
> Despite what the message says, the code isn't fine, as it tries to
> make use of the fusb302_log facility pretty early. This requires the
> logbuffer_lock mutex to be initialised, but that only happens much
> later. Boo.
>
> Hoist the fusb302_debugfs_init call before tcpm_register_port so that
> we can enjoy a working mutex. At Guenter's request, also add teardown
> of the debugfs facility on the error path.
>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/usb/typec/tcpm/fusb302.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
> index e9344997329c..76cb8be6f3eb 100644
> --- a/drivers/usb/typec/tcpm/fusb302.c
> +++ b/drivers/usb/typec/tcpm/fusb302.c
> @@ -1790,12 +1790,13 @@ static int fusb302_probe(struct i2c_client *client,
> goto destroy_workqueue;
> }
>
> + fusb302_debugfs_init(chip);
> chip->tcpm_port = tcpm_register_port(&client->dev, &chip->tcpc_dev);
> if (IS_ERR(chip->tcpm_port)) {
> ret = PTR_ERR(chip->tcpm_port);
> if (ret != -EPROBE_DEFER)
> dev_err(dev, "cannot register tcpm port, ret=%d", ret);
> - goto destroy_workqueue;
> + goto unregister_debugfs;
> }
>
> ret = devm_request_threaded_irq(chip->dev, chip->gpio_int_n_irq,
> @@ -1807,13 +1808,14 @@ static int fusb302_probe(struct i2c_client *client,
> goto tcpm_unregister_port;
> }
> enable_irq_wake(chip->gpio_int_n_irq);
> - fusb302_debugfs_init(chip);
> i2c_set_clientdata(client, chip);
>
> return ret;
>
> tcpm_unregister_port:
> tcpm_unregister_port(chip->tcpm_port);
> +unregister_debugfs:
> + fusb302_debugfs_exit(chip);
> destroy_workqueue:
> destroy_workqueue(chip->wq);
>
> --
> 2.20.1
>
WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: Marc Zyngier <marc.zyngier@arm.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] usb: typec: fusb302: Fix debugfs mutex initialisation
Date: Mon, 18 Mar 2019 11:18:41 -0700 [thread overview]
Message-ID: <20190318181841.GA25132@roeck-us.net> (raw)
In-Reply-To: <20190318174906.10429-1-marc.zyngier@arm.com>
On Mon, Mar 18, 2019 at 05:49:06PM +0000, Marc Zyngier wrote:
> Running a kernel with the fusb302 driver and lockdep enabled
> leads to an unpleasant warning:
>
> [ 4.617477] INFO: trying to register non-static key.
> [ 4.617930] the code is fine but needs lockdep annotation.
> [ 4.618418] turning off the locking correctness validator.
> [ 4.618913] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.1.0-rc1-00007-g3542533f3fc9 #13
> [ 4.619620] Hardware name: rockchip evb_rk3399/evb_rk3399, BIOS 2019.04-rc3-00124-g2feec69fb1 03/15/2019
> [ 4.620454] Call trace:
> [ 4.620693] dump_backtrace+0x0/0x138
> [ 4.621028] show_stack+0x24/0x30
> [ 4.621336] dump_stack+0xbc/0x104
> [ 4.621649] register_lock_class+0x594/0x598
> [ 4.622036] __lock_acquire+0x80/0x11b8
> [ 4.622384] lock_acquire+0xdc/0x260
> [ 4.622711] __mutex_lock+0x90/0x8a0
> [ 4.623037] mutex_lock_nested+0x3c/0x50
> [ 4.623394] _fusb302_log+0x88/0x1f0
> [ 4.623721] fusb302_log+0x7c/0xa0
> [ 4.624033] tcpm_init+0x5c/0x190
> [ 4.624336] tcpm_init+0x3c/0x130
> [ 4.624640] tcpm_register_port+0x574/0x878
> [ 4.625019] fusb302_probe+0x2c8/0x590
>
> Despite what the message says, the code isn't fine, as it tries to
> make use of the fusb302_log facility pretty early. This requires the
> logbuffer_lock mutex to be initialised, but that only happens much
> later. Boo.
>
> Hoist the fusb302_debugfs_init call before tcpm_register_port so that
> we can enjoy a working mutex. At Guenter's request, also add teardown
> of the debugfs facility on the error path.
>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
> ---
> drivers/usb/typec/tcpm/fusb302.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
> index e9344997329c..76cb8be6f3eb 100644
> --- a/drivers/usb/typec/tcpm/fusb302.c
> +++ b/drivers/usb/typec/tcpm/fusb302.c
> @@ -1790,12 +1790,13 @@ static int fusb302_probe(struct i2c_client *client,
> goto destroy_workqueue;
> }
>
> + fusb302_debugfs_init(chip);
> chip->tcpm_port = tcpm_register_port(&client->dev, &chip->tcpc_dev);
> if (IS_ERR(chip->tcpm_port)) {
> ret = PTR_ERR(chip->tcpm_port);
> if (ret != -EPROBE_DEFER)
> dev_err(dev, "cannot register tcpm port, ret=%d", ret);
> - goto destroy_workqueue;
> + goto unregister_debugfs;
> }
>
> ret = devm_request_threaded_irq(chip->dev, chip->gpio_int_n_irq,
> @@ -1807,13 +1808,14 @@ static int fusb302_probe(struct i2c_client *client,
> goto tcpm_unregister_port;
> }
> enable_irq_wake(chip->gpio_int_n_irq);
> - fusb302_debugfs_init(chip);
> i2c_set_clientdata(client, chip);
>
> return ret;
>
> tcpm_unregister_port:
> tcpm_unregister_port(chip->tcpm_port);
> +unregister_debugfs:
> + fusb302_debugfs_exit(chip);
> destroy_workqueue:
> destroy_workqueue(chip->wq);
>
> --
> 2.20.1
>
next reply other threads:[~2019-03-18 18:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-18 18:18 Guenter Roeck [this message]
2019-03-18 18:18 ` [PATCH v2] usb: typec: fusb302: Fix debugfs mutex initialisation Guenter Roeck
-- strict thread matches above, loose matches on Subject: below --
2019-03-22 8:38 [v2] " Heikki Krogerus
2019-03-22 8:38 ` [PATCH v2] " Heikki Krogerus
2019-03-21 16:02 [v2] " Marc Zyngier
2019-03-21 16:02 ` [PATCH v2] " Marc Zyngier
2019-03-21 13:24 [v2] " Heikki Krogerus
2019-03-21 13:24 ` [PATCH v2] " Heikki Krogerus
2019-03-20 16:34 [v2] " Heikki Krogerus
2019-03-20 16:34 ` [PATCH v2] " Heikki Krogerus
2019-03-20 16:07 [v2] " Marc Zyngier
2019-03-20 16:07 ` [PATCH v2] " Marc Zyngier
2019-03-19 12:18 [v2] " Marc Zyngier
2019-03-19 12:18 ` [PATCH v2] " Marc Zyngier
2019-03-19 11:45 [v2] " Heikki Krogerus
2019-03-19 11:45 ` [PATCH v2] " Heikki Krogerus
2019-03-18 17:49 [v2] " Marc Zyngier
2019-03-18 17:49 ` [PATCH v2] " Marc Zyngier
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=20190318181841.GA25132@roeck-us.net \
--to=linux@roeck-us.net \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=marc.zyngier@arm.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 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.