From: "Andreas Färber" <afaerber@suse.de>
To: Ben Whitten <ben.whitten@gmail.com>,
linux-clk <linux-clk@vger.kernel.org>
Cc: devicetree <devicetree@vger.kernel.org>,
Maxime Ripard <maxime.ripard@bootlin.com>,
netdev@vger.kernel.org,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@codeaurora.org>,
"linux-lpwan@lists.infradead.org"
<linux-lpwan@lists.infradead.org>,
linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
Russell King <linux@armlinux.org.uk>,
"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3 lora-next 5/5] net: lora: sx125x sx1301: allow radio to register as a clk provider
Date: Mon, 31 Dec 2018 14:27:06 +0100 [thread overview]
Message-ID: <a5fd0ea3-c2d1-add2-87bc-b0fd9bbc926b@suse.de> (raw)
In-Reply-To: <491d1a46-c112-1106-9f25-14149f0dcbd0@suse.de>
Am 30.12.18 um 11:55 schrieb Andreas Färber:
> Am 29.12.18 um 21:16 schrieb Andreas Färber:
>> `sudo ip link set lora2 up` froze my system, with both
>> lora1 and lora2 being sx1301. [...]
>>
>> Investigating...
>
> I've bisected and confirmed that it was indeed this patch that regresses
> for one of my SX1301 concentrators.
[...]
> We never return from the sx125x_clkout_enable() performing the
> regmap_field_write() on our regmap_bus, which in turn uses a SPI regmap
> in sx1301_regmap_bus_read().
>
> A notable difference between my two concentrators is that the working
> one is using spi-gpio driver, the regressing one spi-sun6i.
>
> Two things stood out in spi-sun6i: It uses a completion (I do not run
> into its timeout warning!), and it uses clk_{get,set}_rate().
>
> Given that observed symptoms were CPU stalls, workqueue [freezes] and RCU
> problems, requiring a power-cycle to recover, I wonder whether we are
> running into some atomic/locking issue with clk_enable()? Is it valid at
> all to use SPI/regmap for clk_enable()? If it is, is there a known issue
> specific to spi-sun6i (A64) in 4.20.0?
I've now hacked together a test case: delaying the regmap operation to a
work queue (violating the .enable contract of a stable clk on return!)
and having our caller poll afterwards for the operation to finish. Guess
what, below gross hack makes it work again on both cards... :/
Is this hinting at an issue with spi-sun6i clk_get_rate()'s prepare_lock
vs. our clk_enable()'s enable_lock? I grep'ed around and spi-sun6i is
not the only SPI driver using clk_get_rate() in transfer_one...
Thanks for any hints,
Andreas
diff --git a/drivers/net/lora/sx125x.c b/drivers/net/lora/sx125x.c
index 597b882379ac..095ca40e5de7 100644
--- a/drivers/net/lora/sx125x.c
+++ b/drivers/net/lora/sx125x.c
@@ -11,6 +11,7 @@
#include <linux/clk.h>
#include <linux/clk-provider.h>
+#include <linux/delay.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
@@ -49,6 +50,9 @@ struct sx125x_priv {
struct device *dev;
struct regmap *regmap;
struct regmap_field
*regmap_fields[ARRAY_SIZE(sx125x_regmap_fields)];
+
+ struct workqueue_struct *clk_wq;
+ struct work_struct clk_out_enable_work;
};
#define to_clkout(_hw) container_of(_hw, struct sx125x_priv, clkout_hw)
@@ -81,8 +85,17 @@ static int sx125x_clkout_enable(struct clk_hw *hw)
{
struct sx125x_priv *priv = to_clkout(hw);
+ dev_info(priv->dev, "enabling clkout...\n");
+ queue_work(priv->clk_wq, &priv->clk_out_enable_work);
+ return 0;
+}
+
+static void sx125x_clk_out_enable_work_handler(struct work_struct *ws)
+{
+ struct sx125x_priv *priv = container_of(ws, struct sx125x_priv,
clk_out_enable_work);
+
dev_info(priv->dev, "enabling clkout\n");
- return sx125x_field_write(priv, F_CLK_OUT, 1);
+ sx125x_field_write(priv, F_CLK_OUT, 1);
}
static void sx125x_clkout_disable(struct clk_hw *hw)
@@ -230,6 +243,9 @@ static int __maybe_unused sx125x_regmap_probe(struct
device *dev, struct regmap
}
}
+ priv->clk_wq = alloc_workqueue("sx127x_wq", WQ_FREEZABLE |
WQ_MEM_RECLAIM, 0);
+ INIT_WORK(&priv->clk_out_enable_work,
sx125x_clk_out_enable_work_handler);
+
dev_info(dev, "SX125x module probed\n");
return 0;
@@ -237,6 +253,10 @@ static int __maybe_unused
sx125x_regmap_probe(struct device *dev, struct regmap
static int __maybe_unused sx125x_regmap_remove(struct device *dev)
{
+ struct sx125x_priv *priv = dev_get_drvdata(dev);
+
+ destroy_workqueue(priv->clk_wq);
+
dev_info(dev, "SX125x module removed\n");
return 0;
diff --git a/drivers/net/lora/sx130x.c b/drivers/net/lora/sx130x.c
index 7ac7de9eda46..4ae6699d38ad 100644
--- a/drivers/net/lora/sx130x.c
+++ b/drivers/net/lora/sx130x.c
@@ -11,6 +11,7 @@
#include <linux/bitops.h>
#include <linux/clk.h>
+#include <linux/clk-provider.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/lora.h>
@@ -391,6 +392,10 @@ static int sx130x_loradev_open(struct net_device
*netdev)
goto err_clk_enable;
}
+ do {
+ usleep_range(100, 1000);
+ } while (!__clk_is_enabled(priv->clk32m));
+
ret = sx130x_field_write(priv, F_GLOBAL_EN, 1);
if (ret) {
dev_err(priv->dev, "enable global clocks failed (%d)\n",
ret);
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2018-12-31 13:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1539361567-3602-1-git-send-email-ben.whitten@lairdtech.com>
[not found] ` <1539361567-3602-6-git-send-email-ben.whitten@lairdtech.com>
2018-12-29 19:25 ` [PATCH v3 lora-next 5/5] net: lora: sx125x sx1301: allow radio to register as a clk provider Andreas Färber
2018-12-29 20:16 ` Andreas Färber
2018-12-30 10:55 ` Andreas Färber
2018-12-31 13:27 ` Andreas Färber [this message]
2018-12-31 17:50 ` Mark Brown
2018-12-31 22:56 ` Andreas Färber
2019-01-02 0:44 ` Andreas Färber
2019-01-03 12:37 ` Mark Brown
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=a5fd0ea3-c2d1-add2-87bc-b0fd9bbc926b@suse.de \
--to=afaerber@suse.de \
--cc=ben.whitten@gmail.com \
--cc=broonie@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-lpwan@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.ripard@bootlin.com \
--cc=mturquette@baylibre.com \
--cc=netdev@vger.kernel.org \
--cc=sboyd@codeaurora.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