All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: pressure: bmp280: fix runtime suspend/resume crash
@ 2016-07-27 20:32 Linus Walleij
  2016-08-08 17:48 ` H. Nikolaus Schaller
  2016-08-15 14:47 ` Jonathan Cameron
  0 siblings, 2 replies; 3+ messages in thread
From: Linus Walleij @ 2016-07-27 20:32 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio, Akinobu Mita, H . Nikolaus Schaller,
	Matt Ranostay, Peter Meerwald-Stadler
  Cc: Christoph Mair, Vlad Dogaru, Hartmut Knaack, Marek Belisko,
	Eric Andersson, Neil Brown, Linus Walleij

In commit 3d838118c6aa ("iio: pressure: bmp280: add power management")

For some reason the code in the runtime suspend/resume hooks
got wrong (I suspect in the ambition to cut down boilerplate)
and it seems it was tested without CONFIG_PM and crashes like
so for me:

Unable to handle kernel NULL pointer dereference at virtual address 0000000c
pgd = c0204000
[0000000c] *pgd=00000000
Internal error: Oops: 5 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 1 PID: 89 Comm: kworker/1:2 Not tainted
  4.7.0-03348-g90dc3680458a-dirty #99
Hardware name: Generic DT based system
Workqueue: pm pm_runtime_work
task: df3c6300 ti: dec8a000 task.ti: dec8a000
PC is at regulator_disable+0x0/0x6c
LR is at bmp280_runtime_suspend+0x3c/0xa4

Dereferencing the BMP280 state container properly fixes the problem,
sorry for screwing up.

Fixes: 3d838118c6aa ("iio: pressure: bmp280: add power management")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/pressure/bmp280-core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 6943688e66df..724fefd4af00 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove);
 #ifdef CONFIG_PM
 static int bmp280_runtime_suspend(struct device *dev)
 {
-	struct bmp280_data *data = dev_get_drvdata(dev);
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
 
 	ret = regulator_disable(data->vdda);
@@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev)
 
 static int bmp280_runtime_resume(struct device *dev)
 {
-	struct bmp280_data *data = dev_get_drvdata(dev);
+	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct bmp280_data *data = iio_priv(indio_dev);
 	int ret;
 
 	ret = regulator_enable(data->vddd);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: pressure: bmp280: fix runtime suspend/resume crash
  2016-07-27 20:32 [PATCH] iio: pressure: bmp280: fix runtime suspend/resume crash Linus Walleij
@ 2016-08-08 17:48 ` H. Nikolaus Schaller
  2016-08-15 14:47 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: H. Nikolaus Schaller @ 2016-08-08 17:48 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jonathan Cameron, linux-iio, Akinobu Mita, Matt Ranostay,
	Peter Meerwald-Stadler, Christoph Mair, Vlad Dogaru,
	Hartmut Knaack, Marek Belisko, Eric Andersson, Neil Brown

Hi Linus,
I can confirm that the crash exists.

But is it possible to download / pull the patch from somewhere?
It did not yet appear in linux-next. Is it applied to some other git =
repo?

Unfortunately linux-iio isn't available in patchwork.kernel.org and this =
patch didn't cc: to lkml.

And the trick I just recently learned how to download it from gmane does =
not work any more.

Finally markinfo does not appear to have a binary download either which =
preserves subject&headers.

	http://marc.info/?l=3Dlinux-iio&m=3D146965159217655&w=3D2

Well, I can still pull from this e-mail or copy&paste into a text file, =
but sometimes formatting can go wrong.

BR and thanks,
Nikolaus


> Am 27.07.2016 um 22:32 schrieb Linus Walleij =
<linus.walleij@linaro.org>:
>=20
> In commit 3d838118c6aa ("iio: pressure: bmp280: add power management")
>=20
> For some reason the code in the runtime suspend/resume hooks
> got wrong (I suspect in the ambition to cut down boilerplate)
> and it seems it was tested without CONFIG_PM and crashes like
> so for me:
>=20
> Unable to handle kernel NULL pointer dereference at virtual address =
0000000c
> pgd =3D c0204000
> [0000000c] *pgd=3D00000000
> Internal error: Oops: 5 [#1] PREEMPT SMP ARM
> Modules linked in:
> CPU: 1 PID: 89 Comm: kworker/1:2 Not tainted
>  4.7.0-03348-g90dc3680458a-dirty #99
> Hardware name: Generic DT based system
> Workqueue: pm pm_runtime_work
> task: df3c6300 ti: dec8a000 task.ti: dec8a000
> PC is at regulator_disable+0x0/0x6c
> LR is at bmp280_runtime_suspend+0x3c/0xa4
>=20
> Dereferencing the BMP280 state container properly fixes the problem,
> sorry for screwing up.
>=20
> Fixes: 3d838118c6aa ("iio: pressure: bmp280: add power management")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/iio/pressure/bmp280-core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>=20
> diff --git a/drivers/iio/pressure/bmp280-core.c =
b/drivers/iio/pressure/bmp280-core.c
> index 6943688e66df..724fefd4af00 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove);
> #ifdef CONFIG_PM
> static int bmp280_runtime_suspend(struct device *dev)
> {
> -	struct bmp280_data *data =3D dev_get_drvdata(dev);
> +	struct iio_dev *indio_dev =3D dev_get_drvdata(dev);
> +	struct bmp280_data *data =3D iio_priv(indio_dev);
> 	int ret;
>=20
> 	ret =3D regulator_disable(data->vdda);
> @@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device =
*dev)
>=20
> static int bmp280_runtime_resume(struct device *dev)
> {
> -	struct bmp280_data *data =3D dev_get_drvdata(dev);
> +	struct iio_dev *indio_dev =3D dev_get_drvdata(dev);
> +	struct bmp280_data *data =3D iio_priv(indio_dev);
> 	int ret;
>=20
> 	ret =3D regulator_enable(data->vddd);
> --=20
> 2.7.4
>=20

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: pressure: bmp280: fix runtime suspend/resume crash
  2016-07-27 20:32 [PATCH] iio: pressure: bmp280: fix runtime suspend/resume crash Linus Walleij
  2016-08-08 17:48 ` H. Nikolaus Schaller
@ 2016-08-15 14:47 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-08-15 14:47 UTC (permalink / raw)
  To: Linus Walleij, linux-iio, Akinobu Mita, H . Nikolaus Schaller,
	Matt Ranostay, Peter Meerwald-Stadler
  Cc: Christoph Mair, Vlad Dogaru, Hartmut Knaack, Marek Belisko,
	Eric Andersson, Neil Brown

On 27/07/16 21:32, Linus Walleij wrote:
> In commit 3d838118c6aa ("iio: pressure: bmp280: add power management")
> 
> For some reason the code in the runtime suspend/resume hooks
> got wrong (I suspect in the ambition to cut down boilerplate)
> and it seems it was tested without CONFIG_PM and crashes like
> so for me:
> 
> Unable to handle kernel NULL pointer dereference at virtual address 0000000c
> pgd = c0204000
> [0000000c] *pgd=00000000
> Internal error: Oops: 5 [#1] PREEMPT SMP ARM
> Modules linked in:
> CPU: 1 PID: 89 Comm: kworker/1:2 Not tainted
>   4.7.0-03348-g90dc3680458a-dirty #99
> Hardware name: Generic DT based system
> Workqueue: pm pm_runtime_work
> task: df3c6300 ti: dec8a000 task.ti: dec8a000
> PC is at regulator_disable+0x0/0x6c
> LR is at bmp280_runtime_suspend+0x3c/0xa4
> 
> Dereferencing the BMP280 state container properly fixes the problem,
> sorry for screwing up.
> 
> Fixes: 3d838118c6aa ("iio: pressure: bmp280: add power management")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Applied and marked for staging.  Thanks,

Jonathan
> ---
>  drivers/iio/pressure/bmp280-core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 6943688e66df..724fefd4af00 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -1079,7 +1079,8 @@ EXPORT_SYMBOL(bmp280_common_remove);
>  #ifdef CONFIG_PM
>  static int bmp280_runtime_suspend(struct device *dev)
>  {
> -	struct bmp280_data *data = dev_get_drvdata(dev);
> +	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> +	struct bmp280_data *data = iio_priv(indio_dev);
>  	int ret;
>  
>  	ret = regulator_disable(data->vdda);
> @@ -1090,7 +1091,8 @@ static int bmp280_runtime_suspend(struct device *dev)
>  
>  static int bmp280_runtime_resume(struct device *dev)
>  {
> -	struct bmp280_data *data = dev_get_drvdata(dev);
> +	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> +	struct bmp280_data *data = iio_priv(indio_dev);
>  	int ret;
>  
>  	ret = regulator_enable(data->vddd);
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-15 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-27 20:32 [PATCH] iio: pressure: bmp280: fix runtime suspend/resume crash Linus Walleij
2016-08-08 17:48 ` H. Nikolaus Schaller
2016-08-15 14:47 ` Jonathan Cameron

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.