From: Guenter Roeck <linux@roeck-us.net>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Srinivas Neeli <srinivas.neeli@amd.com>,
wim@linux-watchdog.org, shubhrajyoti.datta@amd.com,
michal.simek@amd.com, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org
Cc: linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
git@amd.com
Subject: Re: [PATCH 2/3] watchdog: xilinx_wwdt: Add Versal window watchdog support
Date: Sun, 2 Oct 2022 09:29:32 -0700 [thread overview]
Message-ID: <1cb7fdb7-ebad-a61e-490c-80e6c9feab2b@roeck-us.net> (raw)
In-Reply-To: <c1e34c50-50ac-0e06-3af7-a1eec886bf07@linaro.org>
On 9/30/22 03:35, Krzysztof Kozlowski wrote:
> On 27/09/2022 13:02, Srinivas Neeli wrote:
>> +
>> +static void xwwdt_clk_disable_unprepare(void *data)
>> +{
>> + clk_disable_unprepare(data);
>
> If watchdog is stopped and then device unbound, don't you have double
> disable? IOW, where is matching clk_enable?
>
After looking into the entire driver code, I see the problem:
clk_disable() is called in the stop function. That is wrong;
if the clock is disabled in the stop function, it needs to be
enabled in the start function (which is not currently the case).
In that situation, using the devm_ callback when unloading the
driver isn't possible (or, rather, would require checking if the
clock is enabled before disabling it).
Thanks,
Guenter
>> +}
>> +
>> +static const struct watchdog_info xilinx_wwdt_ident = {
>> + .options = WDIOF_KEEPALIVEPING |
>> + WDIOF_SETTIMEOUT,
>> + .firmware_version = 1,
>> + .identity = "xlnx_window watchdog",
>> +};
>> +
>> +static const struct watchdog_ops xilinx_wwdt_ops = {
>> + .owner = THIS_MODULE,
>> + .start = xilinx_wwdt_start,
>> + .stop = xilinx_wwdt_stop,
>> + .set_timeout = xilinx_wwdt_set_timeout,
>> + .ping = xilinx_wwdt_keepalive,
>> +};
>> +
>> +static int xwwdt_probe(struct platform_device *pdev)
>> +{
>> + struct watchdog_device *xilinx_wwdt_wdd;
>> + struct device *dev = &pdev->dev;
>> + struct xwwdt_device *xdev;
>> + int ret;
>> +
>> + xdev = devm_kzalloc(dev, sizeof(*xdev), GFP_KERNEL);
>> + if (!xdev)
>> + return -ENOMEM;
>> +
>> + xilinx_wwdt_wdd = &xdev->xilinx_wwdt_wdd;
>> + xilinx_wwdt_wdd->info = &xilinx_wwdt_ident;
>> + xilinx_wwdt_wdd->ops = &xilinx_wwdt_ops;
>> + xilinx_wwdt_wdd->parent = dev;
>> +
>> + xdev->base = devm_platform_ioremap_resource(pdev, 0);
>> + if (IS_ERR(xdev->base))
>> + return PTR_ERR(xdev->base);
>> +
>> + xdev->clk = devm_clk_get(dev, NULL);
>> + if (IS_ERR(xdev->clk))
>> + return PTR_ERR(xdev->clk);
>> +
>> + xdev->freq = clk_get_rate(xdev->clk);
>> + if (!xdev->freq)
>> + return -EINVAL;
>> +
>> + ret = clk_prepare_enable(xdev->clk);
>> + if (ret) {
>> + dev_err(dev, "unable to enable clock\n");
>> + return ret;
>> + }
>> +
>> + ret = devm_add_action_or_reset(dev, xwwdt_clk_disable_unprepare,
>> + xdev->clk);
>> + if (ret)
>> + return ret;
>> +
>> + xilinx_wwdt_wdd->timeout = XWWDT_DEFAULT_TIMEOUT;
>> + xilinx_wwdt_wdd->min_timeout = XWWDT_MIN_TIMEOUT;
>> + xilinx_wwdt_wdd->max_timeout = XWWDT_MAX_TIMEOUT;
>> +
>> + ret = watchdog_init_timeout(xilinx_wwdt_wdd,
>> + xwwdt_timeout, &pdev->dev);
>> + if (ret)
>> + dev_info(&pdev->dev, "Configured default timeout value\n");
>> +
>> + spin_lock_init(&xdev->spinlock);
>> + watchdog_set_drvdata(xilinx_wwdt_wdd, xdev);
>> +
>> + ret = devm_watchdog_register_device(dev, xilinx_wwdt_wdd);
>> + if (ret)
>> + return ret;
>> +
>> + dev_info(dev, "Xilinx window watchdog Timer with timeout %ds\n",
>> + xilinx_wwdt_wdd->timeout);
>> +
>> + return 0;
>> +}
>> +
>> +static const struct of_device_id xwwdt_of_match[] = {
>> + { .compatible = "xlnx,versal-wwdt-1.0", },
>> + {},
>> +};
>> +MODULE_DEVICE_TABLE(of, xwwdt_of_match);
>> +
>> +static struct platform_driver xwwdt_driver = {
>> + .probe = xwwdt_probe,
>> + .driver = {
>> + .name = "Xilinx window watchdog",
>
> Do you see spaces in other names of drivers?
>
> Best regards,
> Krzysztof
>
next prev parent reply other threads:[~2022-10-02 16:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 11:02 [PATCH 0/3] watchdog: xilinx_wwdt: Add Versal watchdog support Srinivas Neeli
2022-09-27 11:02 ` [PATCH 1/3] dt-bindings: watchdog: xlnx,versal-wwdt: Add binding documentation for xilinx window watchdog device Srinivas Neeli
2022-09-29 22:20 ` Rob Herring
2022-09-30 10:31 ` Krzysztof Kozlowski
2022-09-27 11:02 ` [PATCH 2/3] watchdog: xilinx_wwdt: Add Versal window watchdog support Srinivas Neeli
2022-09-30 10:35 ` Krzysztof Kozlowski
2022-10-02 16:06 ` Guenter Roeck
2022-10-02 16:29 ` Guenter Roeck [this message]
2022-10-03 7:00 ` Krzysztof Kozlowski
2022-10-02 16:25 ` Guenter Roeck
2022-10-11 6:27 ` Neeli, Srinivas
2022-11-03 16:51 ` Neeli, Srinivas
2022-11-03 17:24 ` Guenter Roeck
2022-11-06 15:16 ` Neeli, Srinivas
2022-12-01 11:08 ` Michal Simek
2022-12-01 15:56 ` Guenter Roeck
2022-10-03 2:06 ` kernel test robot
2022-09-27 11:02 ` [PATCH 3/3] MAINTAINERS: Add fragment for Xilinx watchdog drivers Srinivas Neeli
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=1cb7fdb7-ebad-a61e-490c-80e6c9feab2b@roeck-us.net \
--to=linux@roeck-us.net \
--cc=devicetree@vger.kernel.org \
--cc=git@amd.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=robh+dt@kernel.org \
--cc=shubhrajyoti.datta@amd.com \
--cc=srinivas.neeli@amd.com \
--cc=wim@linux-watchdog.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 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).