Message ID | 1481594282-12801-1-git-send-email-hofrat@osadl.org (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Sylwester Nawrocki |
Headers |
Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from <linux-media-owner@vger.kernel.org>) id 1cGcq8-0005sp-MD; Tue, 13 Dec 2016 02:29:12 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.84_2/mailfrontend-5) with esmtp id 1cGcq5-00049u-8D; Tue, 13 Dec 2016 03:29:11 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753347AbcLMC3H (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Mon, 12 Dec 2016 21:29:07 -0500 Received: from www.osadl.org ([62.245.132.105]:42451 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752965AbcLMC3H (ORCPT <rfc822;linux-media@vger.kernel.org>); Mon, 12 Dec 2016 21:29:07 -0500 X-Greylist: delayed 1893 seconds by postgrey-1.27 at vger.kernel.org; Mon, 12 Dec 2016 21:29:06 EST Received: from debian01.hofrr.at (92-243-34-74.adsl.nanet.at [92.243.34.74] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id uBD1uANN016942; Tue, 13 Dec 2016 02:56:10 +0100 From: Nicholas Mc Guire <hofrat@osadl.org> To: Mauro Carvalho Chehab <mchehab@kernel.org> Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>, Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Sakari Ailus <sakari.ailus@linux.intel.com>, Hans Verkuil <hans.verkuil@cisco.com>, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire <hofrat@osadl.org> Subject: [PATCH RFC] [media] s5k6aa: set usleep_range greater 0 Date: Tue, 13 Dec 2016 02:58:02 +0100 Message-Id: <1481594282-12801-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-0.9 required=6.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: 2016.12.13.22415 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1900_1999 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, FROM_NAME_PHRASE 0, LEGITIMATE_NEGATE 0, LEGITIMATE_SIGNS 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CP_URI_IN_BODY 0, __FROM_DOMAIN_IN_ANY_CC2 0, __FROM_DOMAIN_IN_RCPT 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MULTIPLE_RCPTS_CC_X2 0, __NO_HTML_TAG_RAW 0, __SANE_MSGID 0, __SINGLE_URI_TEXT 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS , __URI_WITH_PATH 0' |
Commit Message
Nicholas Mc Guire
Dec. 13, 2016, 1:58 a.m. UTC
As this is not in atomic context and it does not seem like a critical
timing setting a range of 1ms allows the timer subsystem to optimize
the hrtimer here.
Fixes: commit bfa8dd3a0524 ("[media] v4l: Add v4l2 subdev driver for S5K6AAFX sensor")
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
problem was located by coccinelle spatch
The problem is that usleep_range is calculating the delay by
exp = ktime_add_us(ktime_get(), min)
delta = (u64)(max - min) * NSEC_PER_USEC
so delta is set to 0
and then calls
schedule_hrtimeout_range(exp, 0,...)
effectively this means that the clock subsystem has no room to
optimize which makes little sense as this is not atomic context
anyway so there is not guaratee of precision here.
As this is not a critical delay it is set to a range of 4 to 5
milliseconds - this change needs a review by someone that knows
the details of the device though and preferably would increase
that range.
Patch was only compile tested with: x86_64_defconfig + MEDIA_SUPPORT=m
MEDIA_CAMERA_SUPPORT=y (implies VIDEO_V4L2=m)
MEDIA_DIGITAL_TV_SUPPORT=y, CONFIG_MEDIA_CONTROLLER=y,
CONFIG_VIDEO_V4L2_SUBDEV_API=y
Patch is against 4.9.0 (localversion-next is next-20161212)
drivers/media/i2c/s5k6aa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Nicholas, On Tue, Dec 13, 2016 at 02:58:02AM +0100, Nicholas Mc Guire wrote: > As this is not in atomic context and it does not seem like a critical > timing setting a range of 1ms allows the timer subsystem to optimize > the hrtimer here. I'd suggest not to. These delays are often directly visible to the user in use cases where attention is indeed paid to milliseconds. The same applies to register accesses. An delay of 0 to 100 µs isn't much as such, but when you multiply that with the number of accesses it begins to add up.
On 13/12/16 09:43, Sakari Ailus wrote: > Hi Nicholas, > > On Tue, Dec 13, 2016 at 02:58:02AM +0100, Nicholas Mc Guire wrote: >> As this is not in atomic context and it does not seem like a critical >> timing setting a range of 1ms allows the timer subsystem to optimize >> the hrtimer here. > I'd suggest not to. These delays are often directly visible to the user in > use cases where attention is indeed paid to milliseconds. > > The same applies to register accesses. An delay of 0 to 100 µs isn't much as > such, but when you multiply that with the number of accesses it begins to > add up. > Data sheet for this device [1] says STBYN deassertion to RSTN deassertion should be >50us, though this is actually referenced to MCLK startup. See Figure 36, Power-Up Sequence, page 42. I think the usleep range here could be greatly reduced and opened up to allow hr timer tweaks if desired. [1] http://www.bdtic.com/DataSheet/SAMSUNG/S5K6AAFX13.pdf Regards, Ian -- 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
On Tue, Dec 13, 2016 at 10:10:51AM +0000, Ian Arkver wrote: > On 13/12/16 09:43, Sakari Ailus wrote: > >Hi Nicholas, > > > >On Tue, Dec 13, 2016 at 02:58:02AM +0100, Nicholas Mc Guire wrote: > >>As this is not in atomic context and it does not seem like a critical > >>timing setting a range of 1ms allows the timer subsystem to optimize > >>the hrtimer here. > >I'd suggest not to. These delays are often directly visible to the user in > >use cases where attention is indeed paid to milliseconds. > > > >The same applies to register accesses. An delay of 0 to 100 µs isn't much as > >such, but when you multiply that with the number of accesses it begins to > >add up. > > > Data sheet for this device [1] says STBYN deassertion to RSTN deassertion > should be >50us, though this is actually referenced to MCLK startup. See > Figure 36, Power-Up Sequence, page 42. > > I think the usleep range here could be greatly reduced and opened up to > allow hr timer tweaks if desired. > > [1] http://www.bdtic.com/DataSheet/SAMSUNG/S5K6AAFX13.pdf Good point. Datasheets do not always tell everything though; it'd be good to get a comment from the original driver authors on why they've used the value which can now be found in the driver.
On 12/13/2016 02:58 AM, Nicholas Mc Guire wrote: > As this is not in atomic context and it does not seem like a critical > timing setting a range of 1ms allows the timer subsystem to optimize > the hrtimer here. > > Fixes: commit bfa8dd3a0524 ("[media] v4l: Add v4l2 subdev driver for S5K6AAFX sensor") > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> > --- Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> I'm not sure the "Fixes" tag is needed here. > Patch is against 4.9.0 (localversion-next is next-20161212) Ideally patches for the media subsystem should be normally based on master branch of the media tree (git://linuxtv.org/media_tree.git).
Hi Sylwester, On Tuesday 13 Dec 2016 13:38:52 Sylwester Nawrocki wrote: > On 12/13/2016 02:58 AM, Nicholas Mc Guire wrote: > > As this is not in atomic context and it does not seem like a critical > > timing setting a range of 1ms allows the timer subsystem to optimize > > the hrtimer here. > > > > Fixes: commit bfa8dd3a0524 ("[media] v4l: Add v4l2 subdev driver for > > S5K6AAFX sensor") Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> > > --- > > Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> > > I'm not sure the "Fixes" tag is needed here. > > > Patch is against 4.9.0 (localversion-next is next-20161212) > > Ideally patches for the media subsystem should be normally based on > master branch of the media tree (git://linuxtv.org/media_tree.git). As pointed out by Ian Arkver, the datasheet states the delay should be >50µs. Would it make sense to reduce the sleep duration to (3000, 4000) for instance (or possibly even lower), instead of increasing it ?
Hi Laurent, On 12/13/2016 03:10 PM, Laurent Pinchart wrote: > As pointed out by Ian Arkver, the datasheet states the delay should be >50µs. > Would it make sense to reduce the sleep duration to (3000, 4000) for instance > (or possibly even lower), instead of increasing it ? Theoretically it would make sense, I believe the delay call should really be part of the set_power callback. I think it is safe to decrease the delay value now, the boards using that driver have been dropped with commit commit ca9143501c30a2ce5886757961408488fac2bb4c ARM: EXYNOS: Remove unused board files As far as I am concerned you can do whatever you want with that delay call, remove it or decrease value, whatever helps to stop triggering warnings from the static analysis tools. -- Thanks, Sylwester -- 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
On Tue, Dec 13, 2016 at 03:53:47PM +0100, Sylwester Nawrocki wrote: > Hi Laurent, > > On 12/13/2016 03:10 PM, Laurent Pinchart wrote: > > As pointed out by Ian Arkver, the datasheet states the delay should be >50µs. > > Would it make sense to reduce the sleep duration to (3000, 4000) for instance > > (or possibly even lower), instead of increasing it ? > > Theoretically it would make sense, I believe the delay call should really > be part of the set_power callback. I think it is safe to decrease the > delay value now, the boards using that driver have been dropped with commit > > commit ca9143501c30a2ce5886757961408488fac2bb4c > ARM: EXYNOS: Remove unused board files > > As far as I am concerned you can do whatever you want with that delay > call, remove it or decrease value, whatever helps to stop triggering > warnings from the static analysis tools. > if its actually unused then it might be best to completely drop the code raher than fixing up dead-code. Is the EXYNOS the only system that had this device in use ? If it shold stay in then setting it to the above proposed 3000, 4000 would seem the most resonable to me as I asume this change would stay untested. thx! hofrat -- 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
On 12/15/2016 02:14 AM, Nicholas Mc Guire wrote: > if its actually unused then it might be best to completely drop the code > raher than fixing up dead-code. Is the EXYNOS the only system that had > this device in use ? If it shold stay in then setting it to the above > proposed 3000, 4000 would seem the most resonable to me as I asume this > change would stay untested. I agree, there little sense in modifying unused code which cannot be tested anyway. The whole driver is a candidate for removal as it has no users in mainline. AFAIK it had only been used on Exynos platforms. I'd suggest to just drop the delay call, there are already usleep_range() calls after the GPIO state change. IIRC the delay was needed to ensure proper I2C bus operation after enabling the voltage level translator, but I'm not 100% sure.
diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c index faee113..9fd254a 100644 --- a/drivers/media/i2c/s5k6aa.c +++ b/drivers/media/i2c/s5k6aa.c @@ -838,7 +838,7 @@ static int __s5k6aa_power_on(struct s5k6aa *s5k6aa) if (s5k6aa->s_power) ret = s5k6aa->s_power(1); - usleep_range(4000, 4000); + usleep_range(4000, 5000); if (s5k6aa_gpio_deassert(s5k6aa, RST)) msleep(20);