linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Use of floating point in the kernel
@ 2004-01-07 23:59 Pekka Pietikainen
  2004-01-08  3:34 ` H. Peter Anvin
  0 siblings, 1 reply; 6+ messages in thread
From: Pekka Pietikainen @ 2004-01-07 23:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-dvb

Hi

There are a few instances of use of floating point in 2.6,

--- linux-2.6.0-1.30/drivers/media/dvb/ttpci/av7110.c~	2004-01-07 23:14:14.000000000 +0200
+++ linux-2.6.0-1.30/drivers/media/dvb/ttpci/av7110.c	2004-01-07 23:14:14.000000000 +0200
@@ -2673,9 +2673,9 @@
 	buf[1] = div & 0xff;
 	buf[2] = 0x8e;
 
-	if (freq < (u32) 16*168.25 )
+	if (freq < 2692 ) /* 16*168.25 */
 		config = 0xa0;
-	else if (freq < (u32) 16*447.25)
+	else if (freq < 7156) /* 16*447.25 */
 		config = 0x90;
 	else
 		config = 0x30;

(If I'm not mistaken a similar patch for this has already been sent to
Linus, just making sure the DVB people get this in their trees as well)
(u32) (16*168.25) would work too, I suppose.

The other case is a bit more widespread, patch below is mostly rhetoric :-)
http://www.winischhofer.net/linuxsisvga.shtml#download contains the latest version
of the sisfb that doesn't use floating point at all, so that is certainly the better
option.

--- linux-2.6.0-1.30/drivers/video/sis/sis_main.c~	2004-01-08 01:27:44.909006216 +0200
+++ linux-2.6.0-1.30/drivers/video/sis/sis_main.c	2004-01-08 01:28:19.111806600 +0200
@@ -616,6 +616,7 @@
 		var->left_margin + var->xres + var->right_margin +
 		var->hsync_len;
 	unsigned int vtotal = 0; 
+#error Use of floating point in the kernel is NOT safe!
 	double drate = 0, hrate = 0;
 	int found_mode = 0;
 	int old_mode;
--- linux-2.6.0-1.30/drivers/video/Kconfig~	2004-01-08 01:25:37.570364632 +0200
+++ linux-2.6.0-1.30/drivers/video/Kconfig	2004-01-08 01:25:37.571364480 +0200
@@ -704,7 +704,7 @@
 
 config FB_SIS
 	tristate "SIS acceleration"
-	depends on FB && PCI
+	depends on FB && PCI && BROKEN
 	help
 	  This is the frame buffer device driver for the SiS 630 and 640 Super
 	  Socket 7 UMA cards.  Specs available at <http://www.sis.com.tw/>.


-- 
Pekka Pietikainen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use of floating point in the kernel
  2004-01-07 23:59 Use of floating point in the kernel Pekka Pietikainen
@ 2004-01-08  3:34 ` H. Peter Anvin
  2004-01-08  3:48   ` Dave Jones
  2004-01-08  3:52   ` Linus Torvalds
  0 siblings, 2 replies; 6+ messages in thread
From: H. Peter Anvin @ 2004-01-08  3:34 UTC (permalink / raw)
  To: linux-kernel

Pekka Pietikainen wrote:
> Hi
> 
> There are a few instances of use of floating point in 2.6,
> 

Has anyone considered asking the gcc people to add an -fno-fpu (or 
-mno-fpu) option, throwing an error if any FP instructions are used?

	-hpa


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use of floating point in the kernel
  2004-01-08  3:34 ` H. Peter Anvin
@ 2004-01-08  3:48   ` Dave Jones
  2004-01-08  3:52   ` Linus Torvalds
  1 sibling, 0 replies; 6+ messages in thread
From: Dave Jones @ 2004-01-08  3:48 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel

On Wed, Jan 07, 2004 at 07:34:06PM -0800, H. Peter Anvin wrote:

 > Has anyone considered asking the gcc people to add an -fno-fpu (or 
 > -mno-fpu) option, throwing an error if any FP instructions are used?

building with -msoft-float gets you this.

		Dave


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use of floating point in the kernel
  2004-01-08  3:34 ` H. Peter Anvin
  2004-01-08  3:48   ` Dave Jones
@ 2004-01-08  3:52   ` Linus Torvalds
  2004-01-08  3:54     ` H. Peter Anvin
  1 sibling, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2004-01-08  3:52 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel



On Wed, 7 Jan 2004, H. Peter Anvin wrote:
>
> Pekka Pietikainen wrote:
> > 
> > There are a few instances of use of floating point in 2.6,
> 
> Has anyone considered asking the gcc people to add an -fno-fpu (or 
> -mno-fpu) option, throwing an error if any FP instructions are used?

We really should, but there really are some rare cases where it is 
actually ok.

In particular, you _can_ do math, if you just do the proper
"kernel_fpu_begin()"/"kernel_fpu_end()" around it, and you have reason to 
believe that you can assume a math processor exists. 

Is it needed? I dunno. I'd frown on it in general, but I don't see it 
being fundamentally wrong under the rigth circumstances.

		Linus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use of floating point in the kernel
  2004-01-08  3:52   ` Linus Torvalds
@ 2004-01-08  3:54     ` H. Peter Anvin
  0 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2004-01-08  3:54 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

Linus Torvalds wrote:
> 
> We really should, but there really are some rare cases where it is 
> actually ok.
> 
> In particular, you _can_ do math, if you just do the proper
> "kernel_fpu_begin()"/"kernel_fpu_end()" around it, and you have reason to 
> believe that you can assume a math processor exists. 
> 
> Is it needed? I dunno. I'd frown on it in general, but I don't see it 
> being fundamentally wrong under the rigth circumstances.
> 

Sure; however, perhaps those can be marked separately in the Makefile.

	-hpa


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Use of floating point in the kernel
       [not found]   ` <1bzv7-4Cw-3@gated-at.bofh.it>
@ 2004-01-08  4:12     ` Andi Kleen
  0 siblings, 0 replies; 6+ messages in thread
From: Andi Kleen @ 2004-01-08  4:12 UTC (permalink / raw)
  To: Dave Jones; +Cc: linux-kernel

Dave Jones <davej@redhat.com> writes:

> On Wed, Jan 07, 2004 at 07:34:06PM -0800, H. Peter Anvin wrote:
>
>  > Has anyone considered asking the gcc people to add an -fno-fpu (or 
>  > -mno-fpu) option, throwing an error if any FP instructions are used?
>
> building with -msoft-float gets you this.

I think they will need an -fno-fpu option for the kernel at some point
anyways. As soon as gcc starts using SSE2 registers for integer
operations on SSE2 targets. My impression is that this point isn't
that far away anymore.

-Andi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-01-08  4:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-07 23:59 Use of floating point in the kernel Pekka Pietikainen
2004-01-08  3:34 ` H. Peter Anvin
2004-01-08  3:48   ` Dave Jones
2004-01-08  3:52   ` Linus Torvalds
2004-01-08  3:54     ` H. Peter Anvin
     [not found] <1bvUw-7Ry-15@gated-at.bofh.it>
     [not found] ` <1bzbF-4cG-5@gated-at.bofh.it>
     [not found]   ` <1bzv7-4Cw-3@gated-at.bofh.it>
2004-01-08  4:12     ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).