From: Nicholas Mc Guire <der.herr@hofr.at>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] video: treat signal like timeout as failure
Date: Thu, 29 Jan 2015 09:43:15 +0000 [thread overview]
Message-ID: <20150129094315.GC23666@opentech.at> (raw)
In-Reply-To: <20150126125905.GI26493@n2100.arm.linux.org.uk>
On Mon, 26 Jan 2015, Russell King - ARM Linux wrote:
> On Tue, Jan 20, 2015 at 06:23:50AM +0100, Nicholas Mc Guire wrote:
> > if(!wait_for_completion_interruptible_timeout(...))
> > only handles the timeout case - this patch adds handling the
> > signal case the same as timeout and cleans up.
> >
> > Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
> > ---
> >
> > Only the timeout case was being handled, return of 0 in
> > wait_for_completion_interruptible_timeout, the signal case (-ERESTARTSYS)
> > was treated just like the case of successful completion, which is most
> > likely not reasonable.
> >
> > Note that exynos_mipi_dsi_wr_data/exynos_mipi_dsi_rd_data return values
> > are not checked at the call sites in s6e8ax0.c (cmd_read/cmd_write)!
> >
> > This patch simply treats the signal case the same way as the timeout case,
> > by releasing locks and returning 0 - which might not be the right thing to
> > do - this needs a review by someone knowing the details of this driver.
> >
> > Patch is against 3.19.0-rc5 -next-20150119
> >
> > Patch was only compile-tested with exynos_defconfig
> >
> > drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c | 17 +++++++++++------
> > 1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c b/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c
> > index 2358a2f..55a7a45 100644
> > --- a/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c
> > +++ b/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c
> > @@ -157,6 +157,7 @@ int exynos_mipi_dsi_wr_data(struct mipi_dsim_device *dsim, unsigned int data_id,
> > const unsigned char *data0, unsigned int data_size)
> > {
> > unsigned int check_rx_ack = 0;
> > + long timeout;
> >
> > if (dsim->state = DSIM_STATE_ULPS) {
> > dev_err(dsim->dev, "state is ULPS.\n");
> > @@ -244,9 +245,11 @@ int exynos_mipi_dsi_wr_data(struct mipi_dsim_device *dsim, unsigned int data_id,
> > exynos_mipi_dsi_wr_tx_header(dsim, data_id, data_size & 0xff,
> > (data_size & 0xff00) >> 8);
> >
> > - if (!wait_for_completion_interruptible_timeout(&dsim_wr_comp,
> > - MIPI_FIFO_TIMEOUT)) {
> > - dev_warn(dsim->dev, "command write timeout.\n");
> > + timeout = wait_for_completion_interruptible_timeout(
> > + &dsim_wr_comp, MIPI_FIFO_TIMEOUT);
> > + if (timeout <= 0) {
> > + dev_warn(dsim->dev,
> > + "command write timed-out/interrupted.\n");
>
> This is really silly. Let's say that the program which results in
> this function called is using signals (eg, alarm() with SIGALRM, or
> asynchronous IO with SIGIO, etc).
>
> Why should having a SIGALRM raised print a kernel message? If this
> happens a lot, it will result in the kernel log being flooded with
> these messages.
>
> Signals should not be seen as exceptional conditions. For some programs,
> they are merely asynchronous events which are a normal part of the
> programs operation (eg, SIGIO, SIGALRM, etc.)
>
> Please, if you are going to handle signals, then handle them properly.
> If you're not going to handle them properly, don't use a wait that
> caters for them - use wait_for_completion_killable_timeout() which
> doesn't finish waiting on a signal unless the signal is going to result
> in the death of the program.
>
the current code would treat the signal case identical with the
completion success case - and that hardly can be the intention
so while it might not be necessary to call printk in the signal
case it should in some way be handled - if there is not need to
handle signals then it might be more resonable to use
wait_for_completion_timeout which is not interruptible.
So the key issue here is not that a signal should necessarily print
a message but that it should not be treated as the success case. The
current code will only treat timeout as an error condition and a received
signal (implying that the condition being waited for is most likely not
satisfied) as a successful completion.
thx!
hofrat
WARNING: multiple messages have this Message-ID (diff)
From: Nicholas Mc Guire <der.herr@hofr.at>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Inki Dae <inki.dae@samsung.com>,
linux-fbdev@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
Donghwa Lee <dh09.lee@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
Kukjin Kim <kgene@kernel.org>,
Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] video: treat signal like timeout as failure
Date: Thu, 29 Jan 2015 10:43:15 +0100 [thread overview]
Message-ID: <20150129094315.GC23666@opentech.at> (raw)
In-Reply-To: <20150126125905.GI26493@n2100.arm.linux.org.uk>
On Mon, 26 Jan 2015, Russell King - ARM Linux wrote:
> On Tue, Jan 20, 2015 at 06:23:50AM +0100, Nicholas Mc Guire wrote:
> > if(!wait_for_completion_interruptible_timeout(...))
> > only handles the timeout case - this patch adds handling the
> > signal case the same as timeout and cleans up.
> >
> > Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
> > ---
> >
> > Only the timeout case was being handled, return of 0 in
> > wait_for_completion_interruptible_timeout, the signal case (-ERESTARTSYS)
> > was treated just like the case of successful completion, which is most
> > likely not reasonable.
> >
> > Note that exynos_mipi_dsi_wr_data/exynos_mipi_dsi_rd_data return values
> > are not checked at the call sites in s6e8ax0.c (cmd_read/cmd_write)!
> >
> > This patch simply treats the signal case the same way as the timeout case,
> > by releasing locks and returning 0 - which might not be the right thing to
> > do - this needs a review by someone knowing the details of this driver.
> >
> > Patch is against 3.19.0-rc5 -next-20150119
> >
> > Patch was only compile-tested with exynos_defconfig
> >
> > drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c | 17 +++++++++++------
> > 1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c b/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c
> > index 2358a2f..55a7a45 100644
> > --- a/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c
> > +++ b/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c
> > @@ -157,6 +157,7 @@ int exynos_mipi_dsi_wr_data(struct mipi_dsim_device *dsim, unsigned int data_id,
> > const unsigned char *data0, unsigned int data_size)
> > {
> > unsigned int check_rx_ack = 0;
> > + long timeout;
> >
> > if (dsim->state == DSIM_STATE_ULPS) {
> > dev_err(dsim->dev, "state is ULPS.\n");
> > @@ -244,9 +245,11 @@ int exynos_mipi_dsi_wr_data(struct mipi_dsim_device *dsim, unsigned int data_id,
> > exynos_mipi_dsi_wr_tx_header(dsim, data_id, data_size & 0xff,
> > (data_size & 0xff00) >> 8);
> >
> > - if (!wait_for_completion_interruptible_timeout(&dsim_wr_comp,
> > - MIPI_FIFO_TIMEOUT)) {
> > - dev_warn(dsim->dev, "command write timeout.\n");
> > + timeout = wait_for_completion_interruptible_timeout(
> > + &dsim_wr_comp, MIPI_FIFO_TIMEOUT);
> > + if (timeout <= 0) {
> > + dev_warn(dsim->dev,
> > + "command write timed-out/interrupted.\n");
>
> This is really silly. Let's say that the program which results in
> this function called is using signals (eg, alarm() with SIGALRM, or
> asynchronous IO with SIGIO, etc).
>
> Why should having a SIGALRM raised print a kernel message? If this
> happens a lot, it will result in the kernel log being flooded with
> these messages.
>
> Signals should not be seen as exceptional conditions. For some programs,
> they are merely asynchronous events which are a normal part of the
> programs operation (eg, SIGIO, SIGALRM, etc.)
>
> Please, if you are going to handle signals, then handle them properly.
> If you're not going to handle them properly, don't use a wait that
> caters for them - use wait_for_completion_killable_timeout() which
> doesn't finish waiting on a signal unless the signal is going to result
> in the death of the program.
>
the current code would treat the signal case identical with the
completion success case - and that hardly can be the intention
so while it might not be necessary to call printk in the signal
case it should in some way be handled - if there is not need to
handle signals then it might be more resonable to use
wait_for_completion_timeout which is not interruptible.
So the key issue here is not that a signal should necessarily print
a message but that it should not be treated as the success case. The
current code will only treat timeout as an error condition and a received
signal (implying that the condition being waited for is most likely not
satisfied) as a successful completion.
thx!
hofrat
WARNING: multiple messages have this Message-ID (diff)
From: der.herr@hofr.at (Nicholas Mc Guire)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] video: treat signal like timeout as failure
Date: Thu, 29 Jan 2015 10:43:15 +0100 [thread overview]
Message-ID: <20150129094315.GC23666@opentech.at> (raw)
In-Reply-To: <20150126125905.GI26493@n2100.arm.linux.org.uk>
On Mon, 26 Jan 2015, Russell King - ARM Linux wrote:
> On Tue, Jan 20, 2015 at 06:23:50AM +0100, Nicholas Mc Guire wrote:
> > if(!wait_for_completion_interruptible_timeout(...))
> > only handles the timeout case - this patch adds handling the
> > signal case the same as timeout and cleans up.
> >
> > Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
> > ---
> >
> > Only the timeout case was being handled, return of 0 in
> > wait_for_completion_interruptible_timeout, the signal case (-ERESTARTSYS)
> > was treated just like the case of successful completion, which is most
> > likely not reasonable.
> >
> > Note that exynos_mipi_dsi_wr_data/exynos_mipi_dsi_rd_data return values
> > are not checked at the call sites in s6e8ax0.c (cmd_read/cmd_write)!
> >
> > This patch simply treats the signal case the same way as the timeout case,
> > by releasing locks and returning 0 - which might not be the right thing to
> > do - this needs a review by someone knowing the details of this driver.
> >
> > Patch is against 3.19.0-rc5 -next-20150119
> >
> > Patch was only compile-tested with exynos_defconfig
> >
> > drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c | 17 +++++++++++------
> > 1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c b/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c
> > index 2358a2f..55a7a45 100644
> > --- a/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c
> > +++ b/drivers/video/fbdev/exynos/exynos_mipi_dsi_common.c
> > @@ -157,6 +157,7 @@ int exynos_mipi_dsi_wr_data(struct mipi_dsim_device *dsim, unsigned int data_id,
> > const unsigned char *data0, unsigned int data_size)
> > {
> > unsigned int check_rx_ack = 0;
> > + long timeout;
> >
> > if (dsim->state == DSIM_STATE_ULPS) {
> > dev_err(dsim->dev, "state is ULPS.\n");
> > @@ -244,9 +245,11 @@ int exynos_mipi_dsi_wr_data(struct mipi_dsim_device *dsim, unsigned int data_id,
> > exynos_mipi_dsi_wr_tx_header(dsim, data_id, data_size & 0xff,
> > (data_size & 0xff00) >> 8);
> >
> > - if (!wait_for_completion_interruptible_timeout(&dsim_wr_comp,
> > - MIPI_FIFO_TIMEOUT)) {
> > - dev_warn(dsim->dev, "command write timeout.\n");
> > + timeout = wait_for_completion_interruptible_timeout(
> > + &dsim_wr_comp, MIPI_FIFO_TIMEOUT);
> > + if (timeout <= 0) {
> > + dev_warn(dsim->dev,
> > + "command write timed-out/interrupted.\n");
>
> This is really silly. Let's say that the program which results in
> this function called is using signals (eg, alarm() with SIGALRM, or
> asynchronous IO with SIGIO, etc).
>
> Why should having a SIGALRM raised print a kernel message? If this
> happens a lot, it will result in the kernel log being flooded with
> these messages.
>
> Signals should not be seen as exceptional conditions. For some programs,
> they are merely asynchronous events which are a normal part of the
> programs operation (eg, SIGIO, SIGALRM, etc.)
>
> Please, if you are going to handle signals, then handle them properly.
> If you're not going to handle them properly, don't use a wait that
> caters for them - use wait_for_completion_killable_timeout() which
> doesn't finish waiting on a signal unless the signal is going to result
> in the death of the program.
>
the current code would treat the signal case identical with the
completion success case - and that hardly can be the intention
so while it might not be necessary to call printk in the signal
case it should in some way be handled - if there is not need to
handle signals then it might be more resonable to use
wait_for_completion_timeout which is not interruptible.
So the key issue here is not that a signal should necessarily print
a message but that it should not be treated as the success case. The
current code will only treat timeout as an error condition and a received
signal (implying that the condition being waited for is most likely not
satisfied) as a successful completion.
thx!
hofrat
next prev parent reply other threads:[~2015-01-29 9:43 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-20 5:23 [PATCH] video: treat signal like timeout as failure Nicholas Mc Guire
2015-01-20 5:23 ` Nicholas Mc Guire
2015-01-20 5:23 ` Nicholas Mc Guire
2015-01-26 12:50 ` Tomi Valkeinen
2015-01-26 12:50 ` Tomi Valkeinen
2015-01-26 12:50 ` Tomi Valkeinen
2015-01-26 12:59 ` Russell King - ARM Linux
2015-01-26 12:59 ` Russell King - ARM Linux
2015-01-26 12:59 ` Russell King - ARM Linux
2015-01-29 9:43 ` Nicholas Mc Guire [this message]
2015-01-29 9:43 ` Nicholas Mc Guire
2015-01-29 9:43 ` Nicholas Mc Guire
2015-03-10 12:43 ` Tomi Valkeinen
2015-03-10 12:43 ` Tomi Valkeinen
2015-03-10 12:43 ` Tomi Valkeinen
2015-03-10 12:51 ` Nicholas Mc Guire
2015-03-10 12:51 ` Nicholas Mc Guire
2015-03-10 12:51 ` Nicholas Mc Guire
2015-03-10 14:15 ` Russell King - ARM Linux
2015-03-10 14:15 ` Russell King - ARM Linux
2015-03-10 14:15 ` Russell King - ARM Linux
2015-03-10 14:39 ` Nicholas Mc Guire
2015-03-10 14:39 ` Nicholas Mc Guire
2015-03-10 14:39 ` Nicholas Mc Guire
2015-03-10 14:46 ` Russell King - ARM Linux
2015-03-10 14:46 ` Russell King - ARM Linux
2015-03-10 14:46 ` Russell King - ARM Linux
2015-03-10 14:55 ` Tomi Valkeinen
2015-03-10 14:55 ` Tomi Valkeinen
2015-03-10 14:55 ` Tomi Valkeinen
2015-03-10 15:26 ` Russell King - ARM Linux
2015-03-10 15:26 ` Russell King - ARM Linux
2015-03-10 15:26 ` Russell King - ARM Linux
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=20150129094315.GC23666@opentech.at \
--to=der.herr@hofr.at \
--cc=linux-arm-kernel@lists.infradead.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.