diff mbox

[1/4] drm/i915: add msecs_to_jiffies_timeout to guarantee minimum duration

Message ID 1369155800-19654-1-git-send-email-imre.deak@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Imre Deak May 21, 2013, 5:03 p.m. UTC
We need this to avoid premature timeouts whenever scheduling a timeout
based on the current jiffies value. For an explanation see [1].
The following patches will take the helper into use.

Once the more generic solution proposed in the thread at [1] is accepted
this patch can be reverted while keeping the follow-up patches.

[1] http://marc.info/?l=linux-kernel&m=136854294730957&w=2

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Jani Nikula May 22, 2013, 7:48 a.m. UTC | #1
On Tue, 21 May 2013, Imre Deak <imre.deak@intel.com> wrote:
> We need this to avoid premature timeouts whenever scheduling a timeout
> based on the current jiffies value. For an explanation see [1].
> The following patches will take the helper into use.
>
> Once the more generic solution proposed in the thread at [1] is accepted
> this patch can be reverted while keeping the follow-up patches.
>
> [1] http://marc.info/?l=linux-kernel&m=136854294730957&w=2

With the name clashes, what happens when the generic solution is merged?
Blows up the build? To avoid confusion with merging upstream and
potential stable backports, should we err on the safe side and rename
these? Or add suitable trickery to use the generic version when
available?

BR,
Jani.


>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 639ec0b..78b6c56 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1981,4 +1981,19 @@ static inline void __user *to_user_ptr(u64 address)
>  	return (void __user *)(uintptr_t)address;
>  }
>  
> +static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m)
> +{
> +	unsigned long j = msecs_to_jiffies(m);
> +
> +	return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1);
> +}
> +
> +static inline unsigned long
> +timespec_to_jiffies_timeout(const struct timespec *value)
> +{
> +	unsigned long j = timespec_to_jiffies(value);
> +
> +	return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1);
> +}
> +
>  #endif
> -- 
> 1.8.1.2
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter May 22, 2013, 9:46 a.m. UTC | #2
On Wed, May 22, 2013 at 9:48 AM, Jani Nikula
<jani.nikula@linux.intel.com> wrote:
> On Tue, 21 May 2013, Imre Deak <imre.deak@intel.com> wrote:
>> We need this to avoid premature timeouts whenever scheduling a timeout
>> based on the current jiffies value. For an explanation see [1].
>> The following patches will take the helper into use.
>>
>> Once the more generic solution proposed in the thread at [1] is accepted
>> this patch can be reverted while keeping the follow-up patches.
>>
>> [1] http://marc.info/?l=linux-kernel&m=136854294730957&w=2
>
> With the name clashes, what happens when the generic solution is merged?
> Blows up the build? To avoid confusion with merging upstream and
> potential stable backports, should we err on the safe side and rename
> these? Or add suitable trickery to use the generic version when
> available?

linux-next should catch such fallout and we can fix up things in the
merge. And since Linus has intel graphics I expect that he'll catch it
if it fails to compile ;-)
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Imre Deak May 22, 2013, 9:57 a.m. UTC | #3
On Wed, 2013-05-22 at 11:46 +0200, Daniel Vetter wrote:
> On Wed, May 22, 2013 at 9:48 AM, Jani Nikula
> <jani.nikula@linux.intel.com> wrote:
> > On Tue, 21 May 2013, Imre Deak <imre.deak@intel.com> wrote:
> >> We need this to avoid premature timeouts whenever scheduling a timeout
> >> based on the current jiffies value. For an explanation see [1].
> >> The following patches will take the helper into use.
> >>
> >> Once the more generic solution proposed in the thread at [1] is accepted
> >> this patch can be reverted while keeping the follow-up patches.
> >>
> >> [1] http://marc.info/?l=linux-kernel&m=136854294730957&w=2
> >
> > With the name clashes, what happens when the generic solution is merged?
> > Blows up the build? To avoid confusion with merging upstream and
> > potential stable backports, should we err on the safe side and rename
> > these? Or add suitable trickery to use the generic version when
> > available?
> 
> linux-next should catch such fallout and we can fix up things in the
> merge. And since Linus has intel graphics I expect that he'll catch it
> if it fails to compile ;-)

Yea, I haven't thought this through properly. But after discussing with
Jani, this seems to be doable. I only hope Linus won't have to resolve
anything :)

--Imre
Daniel Vetter May 22, 2013, 11:51 a.m. UTC | #4
On Wed, May 22, 2013 at 12:57:01PM +0300, Imre Deak wrote:
> On Wed, 2013-05-22 at 11:46 +0200, Daniel Vetter wrote:
> > On Wed, May 22, 2013 at 9:48 AM, Jani Nikula
> > <jani.nikula@linux.intel.com> wrote:
> > > On Tue, 21 May 2013, Imre Deak <imre.deak@intel.com> wrote:
> > >> We need this to avoid premature timeouts whenever scheduling a timeout
> > >> based on the current jiffies value. For an explanation see [1].
> > >> The following patches will take the helper into use.
> > >>
> > >> Once the more generic solution proposed in the thread at [1] is accepted
> > >> this patch can be reverted while keeping the follow-up patches.
> > >>
> > >> [1] http://marc.info/?l=linux-kernel&m=136854294730957&w=2
> > >
> > > With the name clashes, what happens when the generic solution is merged?
> > > Blows up the build? To avoid confusion with merging upstream and
> > > potential stable backports, should we err on the safe side and rename
> > > these? Or add suitable trickery to use the generic version when
> > > available?
> > 
> > linux-next should catch such fallout and we can fix up things in the
> > merge. And since Linus has intel graphics I expect that he'll catch it
> > if it fails to compile ;-)
> 
> Yea, I haven't thought this through properly. But after discussing with
> Jani, this seems to be doable. I only hope Linus won't have to resolve
> anything :)

Ok, I've picked up the entire pile for -fixes, thanks for the patches.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 639ec0b..78b6c56 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1981,4 +1981,19 @@  static inline void __user *to_user_ptr(u64 address)
 	return (void __user *)(uintptr_t)address;
 }
 
+static inline unsigned long msecs_to_jiffies_timeout(const unsigned int m)
+{
+	unsigned long j = msecs_to_jiffies(m);
+
+	return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1);
+}
+
+static inline unsigned long
+timespec_to_jiffies_timeout(const struct timespec *value)
+{
+	unsigned long j = timespec_to_jiffies(value);
+
+	return min_t(unsigned long, MAX_JIFFY_OFFSET, j + 1);
+}
+
 #endif