* [mm patch] i915: fix invalid opcode exception on cpus without clflush
@ 2008-01-17 23:52 Kyle McMartin
2008-01-18 2:03 ` H. Peter Anvin
0 siblings, 1 reply; 4+ messages in thread
From: Kyle McMartin @ 2008-01-17 23:52 UTC (permalink / raw)
To: akpm; +Cc: airlied, linux-kernel
i915_flush_ttm was unconditionally executing a clflush instruction
to (obviously) flush the cache. Instead, check if the cpu supports
clflush, and if not, fall back to calling wbinvd to flush the entire
cache.
Signed-off-by: Kyle McMartin <kmcmartin@redhat.com>
--- a/drivers/char/drm/i915_buffer.c
+++ b/drivers/char/drm/i915_buffer.c
@@ -286,7 +286,18 @@ void i915_flush_ttm(struct drm_ttm *ttm)
return;
DRM_MEMORYBARRIER();
+
+#ifdef CONFIG_X86_32
+ /* Hopefully nobody has built an x86-64 processor without clflush */
+ if (!cpu_has_clflush) {
+ wbinvd();
+ DRM_MEMORYBARRIER();
+ return;
+ }
+#endif
+
for (i = ttm->num_pages - 1; i >= 0; i--)
drm_cache_flush_page(drm_ttm_get_page(ttm, i));
+
DRM_MEMORYBARRIER();
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [mm patch] i915: fix invalid opcode exception on cpus without clflush
2008-01-17 23:52 [mm patch] i915: fix invalid opcode exception on cpus without clflush Kyle McMartin
@ 2008-01-18 2:03 ` H. Peter Anvin
2008-01-18 2:24 ` Harvey Harrison
2008-01-18 2:31 ` Kyle McMartin
0 siblings, 2 replies; 4+ messages in thread
From: H. Peter Anvin @ 2008-01-18 2:03 UTC (permalink / raw)
To: Kyle McMartin; +Cc: akpm, airlied, linux-kernel
Kyle McMartin wrote:
> i915_flush_ttm was unconditionally executing a clflush instruction
> to (obviously) flush the cache. Instead, check if the cpu supports
> clflush, and if not, fall back to calling wbinvd to flush the entire
> cache.
>
> Signed-off-by: Kyle McMartin <kmcmartin@redhat.com>
>
> --- a/drivers/char/drm/i915_buffer.c
> +++ b/drivers/char/drm/i915_buffer.c
> @@ -286,7 +286,18 @@ void i915_flush_ttm(struct drm_ttm *ttm)
> return;
>
> DRM_MEMORYBARRIER();
> +
> +#ifdef CONFIG_X86_32
> + /* Hopefully nobody has built an x86-64 processor without clflush */
> + if (!cpu_has_clflush) {
> + wbinvd();
> + DRM_MEMORYBARRIER();
> + return;
> + }
> +#endif
> +
> for (i = ttm->num_pages - 1; i >= 0; i--)
> drm_cache_flush_page(drm_ttm_get_page(ttm, i));
> +
> DRM_MEMORYBARRIER();
> }
The #ifdef is bogus. If it's required, it should go into
asm-x86/required_features.h and then cpu_has_clflush is static;
otherwise it's just plain wrong.
-hpa
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [mm patch] i915: fix invalid opcode exception on cpus without clflush
2008-01-18 2:03 ` H. Peter Anvin
@ 2008-01-18 2:24 ` Harvey Harrison
2008-01-18 2:31 ` Kyle McMartin
1 sibling, 0 replies; 4+ messages in thread
From: Harvey Harrison @ 2008-01-18 2:24 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Kyle McMartin, akpm, airlied, linux-kernel
On Thu, 2008-01-17 at 21:03 -0500, H. Peter Anvin wrote:
> Kyle McMartin wrote:
> > i915_flush_ttm was unconditionally executing a clflush instruction
> > to (obviously) flush the cache. Instead, check if the cpu supports
> > clflush, and if not, fall back to calling wbinvd to flush the entire
> > cache.
> >
> > Signed-off-by: Kyle McMartin <kmcmartin@redhat.com>
> >
> > --- a/drivers/char/drm/i915_buffer.c
> > +++ b/drivers/char/drm/i915_buffer.c
> > @@ -286,7 +286,18 @@ void i915_flush_ttm(struct drm_ttm *ttm)
> > return;
> >
> > DRM_MEMORYBARRIER();
> > +
> > +#ifdef CONFIG_X86_32
> > + /* Hopefully nobody has built an x86-64 processor without clflush */
> > + if (!cpu_has_clflush) {
> > + wbinvd();
> > + DRM_MEMORYBARRIER();
> > + return;
> > + }
> > +#endif
> > +
> > for (i = ttm->num_pages - 1; i >= 0; i--)
> > drm_cache_flush_page(drm_ttm_get_page(ttm, i));
> > +
> > DRM_MEMORYBARRIER();
> > }
>
> The #ifdef is bogus. If it's required, it should go into
> asm-x86/required_features.h and then cpu_has_clflush is static;
> otherwise it's just plain wrong.
I think Andi's CPA patches have some changes regarding wbinvd and
clflush handling, perhaps you can leverage some of his work?
Harvey
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [mm patch] i915: fix invalid opcode exception on cpus without clflush
2008-01-18 2:03 ` H. Peter Anvin
2008-01-18 2:24 ` Harvey Harrison
@ 2008-01-18 2:31 ` Kyle McMartin
1 sibling, 0 replies; 4+ messages in thread
From: Kyle McMartin @ 2008-01-18 2:31 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Kyle McMartin, akpm, airlied, linux-kernel
On Thu, Jan 17, 2008 at 09:03:17PM -0500, H. Peter Anvin wrote:
> The #ifdef is bogus. If it's required, it should go into
> asm-x86/required_features.h and then cpu_has_clflush is static; otherwise
> it's just plain wrong.
>
I have no objection to making cpu_has_clflush constant on x86_64. The
point was to get rid of a needless test & branch on 64-bit, and making
it constant will have the same effect.
cheers, Kyle
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-18 2:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-17 23:52 [mm patch] i915: fix invalid opcode exception on cpus without clflush Kyle McMartin
2008-01-18 2:03 ` H. Peter Anvin
2008-01-18 2:24 ` Harvey Harrison
2008-01-18 2:31 ` Kyle McMartin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox