From: Guenter Roeck <linux@roeck-us.net>
To: Tomas Winkler <tomas.winkler@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Wim Van Sebroeck <wim@iguana.be>
Cc: Alexander Usyskin <alexander.usyskin@intel.com>,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [char-misc-next v2 7/7] watchdog: mei_wdt: re-register device on event
Date: Fri, 18 Dec 2015 09:05:29 -0800 [thread overview]
Message-ID: <56743CD9.3000708@roeck-us.net> (raw)
In-Reply-To: <1450363780-30008-8-git-send-email-tomas.winkler@intel.com>
On 12/17/2015 06:49 AM, Tomas Winkler wrote:
> From: Alexander Usyskin <alexander.usyskin@intel.com>
>
> For Intel SKL platform the ME device can inform the host via
> asynchronous notification that the watchdog feature was activated
> on the device. The activation doesn't require reboot.
> In that case the driver registers the watchdog device with the kernel.
> In the same manner the feature can be deactivated without reboot
> in that case the watchdog device should be unregistered.
>
> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
I am not really happy about the watchdog device appearing and disappearing
dynamically. This wreaks havoc with any standard watchdog application.
Isn't there a better way to handle this ? How about just registering the
watchdog device and return an error in the access functions if it is disabled ?
Thanks,
Guenter
> V2: rework un/registration in runtime
>
> drivers/watchdog/mei_wdt.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 42 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/watchdog/mei_wdt.c b/drivers/watchdog/mei_wdt.c
> index 00d1b8e630b7..cd79920c473b 100644
> --- a/drivers/watchdog/mei_wdt.c
> +++ b/drivers/watchdog/mei_wdt.c
> @@ -87,6 +87,7 @@ static const char *mei_wdt_state_str(enum mei_wdt_state state)
> * @state: watchdog internal state
> * @resp_required: ping required response
> * @response: ping response
> + * @unregister: unregister worker
> * @timeout: watchdog current timeout
> *
> * @dbgfs_dir: debugfs dir entry
> @@ -101,6 +102,7 @@ struct mei_wdt {
> enum mei_wdt_state state;
> bool resp_required;
> struct completion response;
> + struct work_struct unregister;
> u16 timeout;
>
> #if IS_ENABLED(CONFIG_DEBUG_FS)
> @@ -237,6 +239,13 @@ static void mei_wdt_unregister(struct mei_wdt *wdt)
> mutex_unlock(&wdt->reg_lock);
> }
>
> +static void mei_wdt_unregister_work(struct work_struct *work)
> +{
> + struct mei_wdt *wdt = container_of(work, struct mei_wdt, unregister);
> +
> + mei_wdt_unregister(wdt);
> +}
> +
> /**
> * mei_wdt_register - register with the watchdog subsystem
> *
> @@ -350,8 +359,13 @@ static void mei_wdt_event_rx(struct mei_cl_device *cldev)
> return;
> }
>
> - if (wdt->state == MEI_WDT_RUNNING)
> + if (wdt->state == MEI_WDT_RUNNING) {
> + if (res.wdstate & MEI_WDT_WDSTATE_NOT_REQUIRED) {
> + wdt->state = MEI_WDT_NOT_REQUIRED;
> + schedule_work(&wdt->unregister);
> + }
> goto out;
> + }
>
> if (wdt->state == MEI_WDT_PROBE) {
> if (res.wdstate & MEI_WDT_WDSTATE_NOT_REQUIRED) {
> @@ -372,6 +386,21 @@ out:
> complete(&wdt->response);
> }
>
> +/*
> + * mei_wdt_notify_event - callback for event notification
> + *
> + * @cldev: bus device
> + */
> +static void mei_wdt_notify_event(struct mei_cl_device *cldev)
> +{
> + struct mei_wdt *wdt = mei_cldev_get_drvdata(cldev);
> +
> + if (wdt->state != MEI_WDT_NOT_REQUIRED)
> + return;
> + wdt->state = MEI_WDT_IDLE;
> + mei_wdt_register(wdt);
> +}
> +
> /**
> * mei_wdt_event - callback for event receive
> *
> @@ -384,6 +413,9 @@ static void mei_wdt_event(struct mei_cl_device *cldev,
> {
> if (events & BIT(MEI_CL_EVENT_RX))
> mei_wdt_event_rx(cldev);
> +
> + if (events & BIT(MEI_CL_EVENT_NOTIF))
> + mei_wdt_notify_event(cldev);
> }
>
> /**
> @@ -543,6 +575,7 @@ static int mei_wdt_probe(struct mei_cl_device *cldev,
> wdt->resp_required = mei_cldev_ver(cldev) > 0x1;
> mutex_init(&wdt->reg_lock);
> wdt->is_registered = false;
> + INIT_WORK(&wdt->unregister, mei_wdt_unregister_work);
> init_completion(&wdt->response);
>
> mei_cldev_set_drvdata(cldev, wdt);
> @@ -553,9 +586,13 @@ static int mei_wdt_probe(struct mei_cl_device *cldev,
> goto err_out;
> }
>
> - ret = mei_cldev_register_event_cb(wdt->cldev, BIT(MEI_CL_EVENT_RX),
> + ret = mei_cldev_register_event_cb(wdt->cldev,
> + BIT(MEI_CL_EVENT_RX) |
> + BIT(MEI_CL_EVENT_NOTIF),
> mei_wdt_event, NULL);
> - if (ret) {
> +
> + /* on legacy devices notification is not supported */
> + if (ret && ret != -EOPNOTSUPP) {
> dev_err(&cldev->dev, "Could not register event ret=%d\n", ret);
> goto err_disable;
> }
> @@ -599,6 +636,8 @@ static int mei_wdt_remove(struct mei_cl_device *cldev)
> if (!completion_done(&wdt->response))
> complete(&wdt->response);
>
> + cancel_work_sync(&wdt->unregister);
> +
> mei_wdt_unregister(wdt);
>
> kref_put(&wdt->refcnt, mei_wdt_release);
>
next prev parent reply other threads:[~2015-12-18 17:05 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-17 14:49 [char-misc-next v2 0/7] mei: create proper iAMT watchdog driver Tomas Winkler
2015-12-17 14:49 ` [char-misc-next v2 1/7] mei: drop nfc leftovers from the mei driver Tomas Winkler
2015-12-17 14:49 ` [char-misc-next v2 2/7] mei: wd: drop the watchdog code from the core " Tomas Winkler
2015-12-17 14:49 ` [char-misc-next v2 3/7] watchdog: mei_wdt: implement MEI iAMT watchdog driver Tomas Winkler
2015-12-18 16:39 ` Guenter Roeck
2015-12-17 14:49 ` [char-misc-next 4/7] watchdog: mei_wdt: add status debugfs entry Tomas Winkler
2015-12-18 16:43 ` Guenter Roeck
2015-12-20 9:44 ` Winkler, Tomas
2015-12-20 10:40 ` Guenter Roeck
2015-12-20 11:54 ` Winkler, Tomas
2015-12-17 14:49 ` [char-misc-next v2 5/7] mei: bus: whitelist the watchdog client Tomas Winkler
2015-12-17 14:49 ` [char-misc-next v2 6/7] watchdog: mei_wdt: register wd device only if required Tomas Winkler
2015-12-18 16:58 ` Guenter Roeck
2015-12-20 12:23 ` Winkler, Tomas
2015-12-20 18:16 ` Guenter Roeck
2015-12-17 14:49 ` [char-misc-next v2 7/7] watchdog: mei_wdt: re-register device on event Tomas Winkler
2015-12-18 17:05 ` Guenter Roeck [this message]
2015-12-18 17:19 ` One Thousand Gnomes
2015-12-18 17:50 ` Guenter Roeck
2015-12-18 18:14 ` One Thousand Gnomes
2015-12-20 12:53 ` Winkler, Tomas
2015-12-20 12:53 ` Winkler, Tomas
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=56743CD9.3000708@roeck-us.net \
--to=linux@roeck-us.net \
--cc=alexander.usyskin@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=tomas.winkler@intel.com \
--cc=wim@iguana.be \
/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.