Message ID | 1423126602-6639-1-git-send-email-hofrat@osadl.org (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Hans Verkuil |
Headers |
Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from <linux-media-owner@vger.kernel.org>) id 1YJIJn-0000vW-CZ; Thu, 05 Feb 2015 10:01:47 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-6) with esmtp id 1YJIJl-0005f4-3Y; Thu, 05 Feb 2015 10:01:46 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752583AbbBEJB3 (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Thu, 5 Feb 2015 04:01:29 -0500 Received: from www.osadl.org ([62.245.132.105]:46916 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751784AbbBEJB3 (ORCPT <rfc822;linux-media@vger.kernel.org>); Thu, 5 Feb 2015 04:01:29 -0500 Received: from debian.hofrr.at (92-243-35-153.adsl.nanet.at [92.243.35.153] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id t1590k7c020593; Thu, 5 Feb 2015 10:00:47 +0100 From: Nicholas Mc Guire <hofrat@osadl.org> To: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Cc: Hans Verkuil <hans.verkuil@cisco.com>, Wolfram Sang <wsa@the-dreams.de>, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire <hofrat@osadl.org> Subject: [PATCH RFC] media: radio: handle timeouts Date: Thu, 5 Feb 2015 03:56:42 -0500 Message-Id: <1423126602-6639-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 1.7.10.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KHOP_SC_TOP_CIDR8, RDNS_DYNAMIC autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.2.5.85420 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, FROM_NAME_PHRASE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS ' |
Commit Message
Nicholas Mc Guire
Feb. 5, 2015, 8:56 a.m. UTC
Add handling for timeout case.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
Some error state/error information seems be get lost int the current code.
(line-numbers are from 3.19.0-rc7.
Assume that on line 827 core->write succeeds but the following
wait_for_completion_timeout times out and the radio->irq_received condition
is not satisfied resulting in goto out;
827 r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_AUTO_SEEK);
828 if (r)
829 goto out;
830
831 wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000));
832 if (!(radio->irq_received & WL1273_BL_EVENT))
833 goto out;
A similar situation is at line 955 - 859 where a tiemout could occure
and the reported value would be the success value from core->write.
852 reinit_completion(&radio->busy);
853 dev_dbg(radio->dev, "%s: BUSY\n", __func__);
854
855 r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_AUTO_SEEK);
856 if (r)
857 goto out;
858
859 wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000)
the problem is that the value of r now is the "success" value from core->write
and any timeout and/or failure to detect the expected interrupt is not
reported in
860 out:
861 dev_dbg(radio->dev, "%s: Err: %d\n", __func__, r);
862 return r;
Should the wait_for_completion_timeout not report the timeout event by setting
r to -ETIMEOUT ? respectively use if (!(radio->irq_received & WL1273_BL_EVENT))
to check and set -ETIMEOUT there ?
Comparing this with wl1273_fm_set_tx_freq - the below patch might be suitable
way to handle timeout - but this needs a review by someone who knows the
details of the driver - so this is really just a guess.
Patch was only compile tested with x86_64_defconfig + CONFIG_MEDIA_SUPPORT=m
CONFIG_MEDIA_CAMERA_SUPPORT=y, CONFIG_V4L_PLATFORM_DRIVERS=y,
CONFIG_MEDIA_RADIO_SUPPORT=y, RADIO_ADAPTER=y, CONFIG_RADIO_WL1273=m
Patch is against 3.19.0-rc7 (localversion-next is -next-20150204)
drivers/media/radio/radio-wl1273.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
Comments
Hi Nicholas, On 02/05/2015 09:56 AM, Nicholas Mc Guire wrote: > Add handling for timeout case. > > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> > --- > Some error state/error information seems be get lost int the current code. > (line-numbers are from 3.19.0-rc7. > > Assume that on line 827 core->write succeeds but the following > wait_for_completion_timeout times out and the radio->irq_received condition > is not satisfied resulting in goto out; > > 827 r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_AUTO_SEEK); > 828 if (r) > 829 goto out; > 830 > 831 wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000)); > 832 if (!(radio->irq_received & WL1273_BL_EVENT)) > 833 goto out; > > > A similar situation is at line 955 - 859 where a tiemout could occure > and the reported value would be the success value from core->write. > > 852 reinit_completion(&radio->busy); > 853 dev_dbg(radio->dev, "%s: BUSY\n", __func__); > 854 > 855 r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_AUTO_SEEK); > 856 if (r) > 857 goto out; > 858 > 859 wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000) > > the problem is that the value of r now is the "success" value from core->write > and any timeout and/or failure to detect the expected interrupt is not > reported in > > 860 out: > 861 dev_dbg(radio->dev, "%s: Err: %d\n", __func__, r); > 862 return r; > > Should the wait_for_completion_timeout not report the timeout event by setting > r to -ETIMEOUT ? respectively use if (!(radio->irq_received & WL1273_BL_EVENT)) > to check and set -ETIMEOUT there ? > > Comparing this with wl1273_fm_set_tx_freq - the below patch might be suitable > way to handle timeout - but this needs a review by someone who knows the > details of the driver - so this is really just a guess. While I am certainly not an expert, I agree that the current situation is bad. I'm taking your patch as-is, since returning a proper error here seems to make much more sense. Regards, Hans > > Patch was only compile tested with x86_64_defconfig + CONFIG_MEDIA_SUPPORT=m > CONFIG_MEDIA_CAMERA_SUPPORT=y, CONFIG_V4L_PLATFORM_DRIVERS=y, > CONFIG_MEDIA_RADIO_SUPPORT=y, RADIO_ADAPTER=y, CONFIG_RADIO_WL1273=m > > Patch is against 3.19.0-rc7 (localversion-next is -next-20150204) > > drivers/media/radio/radio-wl1273.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c > index 571c7f6..6830523 100644 > --- a/drivers/media/radio/radio-wl1273.c > +++ b/drivers/media/radio/radio-wl1273.c > @@ -828,9 +828,12 @@ static int wl1273_fm_set_seek(struct wl1273_device *radio, > if (r) > goto out; > > + /* wait for the FR IRQ */ > wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000)); > - if (!(radio->irq_received & WL1273_BL_EVENT)) > + if (!(radio->irq_received & WL1273_BL_EVENT)) { > + r = -ETIMEDOUT; > goto out; > + } > > radio->irq_received &= ~WL1273_BL_EVENT; > > @@ -856,7 +859,9 @@ static int wl1273_fm_set_seek(struct wl1273_device *radio, > if (r) > goto out; > > - wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000)); > + /* wait for the FR IRQ */ > + if (!wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000))) > + r = -ETIMEDOUT; > out: > dev_dbg(radio->dev, "%s: Err: %d\n", __func__, r); > return r; > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c index 571c7f6..6830523 100644 --- a/drivers/media/radio/radio-wl1273.c +++ b/drivers/media/radio/radio-wl1273.c @@ -828,9 +828,12 @@ static int wl1273_fm_set_seek(struct wl1273_device *radio, if (r) goto out; + /* wait for the FR IRQ */ wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000)); - if (!(radio->irq_received & WL1273_BL_EVENT)) + if (!(radio->irq_received & WL1273_BL_EVENT)) { + r = -ETIMEDOUT; goto out; + } radio->irq_received &= ~WL1273_BL_EVENT; @@ -856,7 +859,9 @@ static int wl1273_fm_set_seek(struct wl1273_device *radio, if (r) goto out; - wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000)); + /* wait for the FR IRQ */ + if (!wait_for_completion_timeout(&radio->busy, msecs_to_jiffies(1000))) + r = -ETIMEDOUT; out: dev_dbg(radio->dev, "%s: Err: %d\n", __func__, r); return r;