From: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>
To: Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Cc: linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Jacob Chen <jacob2.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Jacob Chen <jacob-chen-fyOeoxGR3m/QT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] pinctrl: rockchip: don't disable clk when irq mask is already set
Date: Tue, 27 Sep 2016 00:35:18 +0200 [thread overview]
Message-ID: <3592219.tUs91je5kA@phil> (raw)
In-Reply-To: <fb4ec747-fde3-142b-1963-be3b9cfab260-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Am Samstag, 24. September 2016, 18:24:11 CEST schrieb Shawn Lin:
> On 2016/9/24 2:26, Jacob Chen wrote:
> > From: Jacob Chen <jacob2.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
> >
> > In some drivers, disable_irq() call don't be symmetric with enable_irq()
> > , disable_irq() will be called before call free_irq().
>
> Which upstream drivers you refer to?
>
> Shouldn't it be the unbalanced call for these drivers?
>
> > But both disable_irq() and free_irq() will call
> > rockchip_irq_gc_mask_set_bit,>
> > and clk_disable() will be called more times than clk_enable(), which will
> >
> > cause bugs.
> >
> > I think we can correct that by checking of mask.If mask is already set, do
> > nothing.
> Looks like a little hacky to me.
that may be true, but on first glance I tend to agree with Jacob.
Look for example at (a driver using disable_irq I picked at random) drivertc/
rtcrs/-tps6586x.c .
In its probe function it does devm_request_irq directly followed by
disable_irq on its alarm interrupt. The interrupt only gets enabled again if
the rtc alarm gets enabled. So you can easily run into the disable + free case
there as well. Similar probably in a lot of other drivers.
Heiko
>
> > Change-Id: If19912c7658253e15531c04db6c70fdbffd5960a
>
> remove this.
>
> > Signed-off-by: Jacob Chen <jacob2.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
> > ---
> >
> > drivers/pinctrl/pinctrl-rockchip.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/pinctrl/pinctrl-rockchip.c
> > b/drivers/pinctrl/pinctrl-rockchip.c index c6c04ac..9a8804a 100644
> > --- a/drivers/pinctrl/pinctrl-rockchip.c
> > +++ b/drivers/pinctrl/pinctrl-rockchip.c
> > @@ -2334,8 +2334,12 @@ static void rockchip_irq_gc_mask_clr_bit(struct
> > irq_data *d)>
> > void rockchip_irq_gc_mask_set_bit(struct irq_data *d)
> > {
> >
> > struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
> >
> > + struct irq_chip_type *ct = irq_data_get_chip_type(d);
> >
> > struct rockchip_pin_bank *bank = gc->private;
> >
> > + if (*ct->mask_cache & d->mask)
> > + return;
> > +
> >
> > irq_gc_mask_set_bit(d);
> > clk_disable(bank->clk);
> >
> > }
> >
> > --
> > 2.7.4
> >
> >
> > _______________________________________________
> > Linux-rockchip mailing list
> > Linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> > http://lists.infradead.org/mailman/listinfo/linux-rockchip
WARNING: multiple messages have this Message-ID (diff)
From: Heiko Stuebner <heiko@sntech.de>
To: Shawn Lin <shawn.lin@rock-chips.com>
Cc: Jacob Chen <jacob-chen@iotwrt.com>,
linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org,
linus.walleij@linaro.org, Jacob Chen <jacob2.chen@rock-chips.com>,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH] pinctrl: rockchip: don't disable clk when irq mask is already set
Date: Tue, 27 Sep 2016 00:35:18 +0200 [thread overview]
Message-ID: <3592219.tUs91je5kA@phil> (raw)
In-Reply-To: <fb4ec747-fde3-142b-1963-be3b9cfab260@rock-chips.com>
Am Samstag, 24. September 2016, 18:24:11 CEST schrieb Shawn Lin:
> On 2016/9/24 2:26, Jacob Chen wrote:
> > From: Jacob Chen <jacob2.chen@rock-chips.com>
> >
> > In some drivers, disable_irq() call don't be symmetric with enable_irq()
> > , disable_irq() will be called before call free_irq().
>
> Which upstream drivers you refer to?
>
> Shouldn't it be the unbalanced call for these drivers?
>
> > But both disable_irq() and free_irq() will call
> > rockchip_irq_gc_mask_set_bit,>
> > and clk_disable() will be called more times than clk_enable(), which will
> >
> > cause bugs.
> >
> > I think we can correct that by checking of mask.If mask is already set, do
> > nothing.
> Looks like a little hacky to me.
that may be true, but on first glance I tend to agree with Jacob.
Look for example at (a driver using disable_irq I picked at random) drivertc/
rtcrs/-tps6586x.c .
In its probe function it does devm_request_irq directly followed by
disable_irq on its alarm interrupt. The interrupt only gets enabled again if
the rtc alarm gets enabled. So you can easily run into the disable + free case
there as well. Similar probably in a lot of other drivers.
Heiko
>
> > Change-Id: If19912c7658253e15531c04db6c70fdbffd5960a
>
> remove this.
>
> > Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
> > ---
> >
> > drivers/pinctrl/pinctrl-rockchip.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/pinctrl/pinctrl-rockchip.c
> > b/drivers/pinctrl/pinctrl-rockchip.c index c6c04ac..9a8804a 100644
> > --- a/drivers/pinctrl/pinctrl-rockchip.c
> > +++ b/drivers/pinctrl/pinctrl-rockchip.c
> > @@ -2334,8 +2334,12 @@ static void rockchip_irq_gc_mask_clr_bit(struct
> > irq_data *d)>
> > void rockchip_irq_gc_mask_set_bit(struct irq_data *d)
> > {
> >
> > struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
> >
> > + struct irq_chip_type *ct = irq_data_get_chip_type(d);
> >
> > struct rockchip_pin_bank *bank = gc->private;
> >
> > + if (*ct->mask_cache & d->mask)
> > + return;
> > +
> >
> > irq_gc_mask_set_bit(d);
> > clk_disable(bank->clk);
> >
> > }
> >
> > --
> > 2.7.4
> >
> >
> > _______________________________________________
> > Linux-rockchip mailing list
> > Linux-rockchip@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2016-09-26 22:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 18:26 [PATCH] pinctrl: rockchip: don't disable clk when irq mask is already set Jacob Chen
2016-09-24 10:24 ` Shawn Lin
2016-09-24 14:42 ` 陈豪
[not found] ` <fb4ec747-fde3-142b-1963-be3b9cfab260-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-09-26 22:35 ` Heiko Stuebner [this message]
2016-09-26 22:35 ` Heiko Stuebner
2016-09-29 7:29 ` Shawn Lin
2016-09-29 7:29 ` Shawn Lin
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=3592219.tUs91je5kA@phil \
--to=heiko-4mtyjxux2i+zqb+pc5nmwq@public.gmane.org \
--cc=jacob-chen-fyOeoxGR3m/QT0dZR+AlfA@public.gmane.org \
--cc=jacob2.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.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 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.