src.conf: CFLAGS/COPTFLAGS inconsistency

2014-09-19 Thread O. Hartmann
man make.conf states, that COPTFLAGS is used for building/compiling the kernel
(exclusively). The question arises: are kernel modules NOT kernel or are they 
kernel?

The problem I face is that with optimization level -O3 loader.efi gets 
miscompiled and a
UEFI laptop stops/reject booting. To avoid other interference, I defined 
COPTFLAGS
in /etc/src.conf accordingly, but leave CFLAGS?=-O3 in /etc/make.conf for 
compilation of
regular ports and the rest of the OS.

I can observe that with CFLAGS set, either in make.conf, or src.conf or mutual 
exclusive,
the CFLAGS is ALWAYS incorporated when kernel stuff like modules and even the 
loader.efi
is built! I consider this inconsitent, since loader.efi is definitely kernel 
related
stuff as well as modules.

It seems to me that it s not possible to separate cleanly CFLAGS and COPTFLAGS 
for
userland/ports and kernel-only related compilations as described in the man 
page. 


signature.asc
Description: PGP signature


Re: CURRENT: EFI boot failure

2014-09-19 Thread O. Hartmann
Am Wed, 17 Sep 2014 01:25:07 +0300
Andriy Gapon a...@freebsd.org schrieb:

 On 17/09/2014 00:32, Ed Maste wrote:
  On 16 September 2014 17:03, O. Hartmann ohart...@zedat.fu-berlin.de wrote:
 
  In that case, is it still /boot/boot1.efifat or is it /boot/boot1.efi? 
  What is the
  difference? Is the efi partition FAT?
  
  An EFI system partition (ESP) is a FAT-formatted partition with a
  specific GPT or MBR identifier and file system hierarchy; EFI firmware
  will try to load /EFI/BOOT/BOOTX64.EFI from the ESP.
 
 A very useful read about how EFI boot process works and how different OSes 
 boot
 on top of it:
 http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/efi-boot-process.html
 
  boot1.efi is an EFI application - that is, a PECOFF format binary.  It
  searches for a UFS filesystem and loads loader.efi from that.  It is
  intended to simplify the UEFI boot process, so that loader.efi, the
  .4th files, loader.conf etc. do not all need to be installed in the
  ESP.
  
  boot1.efifat is a FAT filesystem image that contains a copy of
  boot1.efi as /EFI/BOOT/BOOTX64.EFI.  It exists so that the installer
  can treat it as opaque bootcode, like other boot schemes.  It's
  certainly possible to create a partition, use newfs_msdos to format
  it, and copy in boot1.efi instead.
  
  It is one disk, dedicated to FreeBSD (a laptop disk). Is there any 
  documentation
  readable for non-developer for that matter? I'm curious about how EFI 
  works on
  FreeBSD.
  
  Better user-facing documentation is in progress; for now the best
  source is probably the wik.
  ___
  freebsd-current@freebsd.org mailing list
  http://lists.freebsd.org/mailman/listinfo/freebsd-current
  To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
  
 
 

The problem I reported about in the first place is triggered by a faulty 
loader.efi that
arises, when optimisation level is -O3. -O2 works fine.

I also realized that there is a kind of inconsistency in how COPTFLAGS and 
CFLAGS are
handled in reality compared to that what the manpage of make.conf states. 
Setting
COPTFLAGS=-O2 for compiling kernel stuff only ALWAYS incorporates CFLAGS, which 
is set to
CFLAGS=-O3 in make.conf in my case. loader.efi is, in my opinion, kernel stuff 
only as
well as kernel modules, which also gets compiled with CFLAGS.


signature.asc
Description: PGP signature


Re: src.conf: CFLAGS/COPTFLAGS inconsistency

2014-09-19 Thread Benjamin Kaduk
On Fri, 19 Sep 2014, O. Hartmann wrote:

 man make.conf states, that COPTFLAGS is used for building/compiling the kernel
 (exclusively). The question arises: are kernel modules NOT kernel or are they 
 kernel?

 The problem I face is that with optimization level -O3 loader.efi gets 
 miscompiled and a
 UEFI laptop stops/reject booting. To avoid other interference, I defined 
 COPTFLAGS
 in /etc/src.conf accordingly, but leave CFLAGS?=-O3 in /etc/make.conf for 
 compilation of
 regular ports and the rest of the OS.

 I can observe that with CFLAGS set, either in make.conf, or src.conf or 
 mutual exclusive,
 the CFLAGS is ALWAYS incorporated when kernel stuff like modules and even the 
 loader.efi
 is built! I consider this inconsitent, since loader.efi is definitely kernel 
 related
 stuff as well as modules.

Sorry, I don't think I understand what you're trying to say in these two
pragraphs.  What does defined COPTFLAGS in /etc/src.conf accordingly
mean?

Likewise, what does  CFLAGS set, either in make.conf, or src.conf or
mutual exclusive mean?

It may be best to give concrete examples of make.conf/src.conf settings
pairs, and the observed behavior.

 It seems to me that it s not possible to separate cleanly CFLAGS and 
 COPTFLAGS for
 userland/ports and kernel-only related compilations as described in the man 
 page.

BTW,

 COPTFLAGS (str) Controls the compiler settings when building the ker-
   nel.  Optimization levels above [-O (-O2, ...)] are not
   guaranteed to work.

Note the last sentence.

-Ben
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] Patch to improve TSO limitation formula in general

2014-09-19 Thread Hans Petter Selasky

Hi,

Please find attached an updated TSO patch based on comments from Andrew, 
Rick and John-Mark Gurney. Review is appreciated.


--HPS
=== sys/dev/oce/oce_if.c
==
--- sys/dev/oce/oce_if.c	(revision 271555)
+++ sys/dev/oce/oce_if.c	(local)
@@ -1731,7 +1731,9 @@
 	sc-ifp-if_baudrate = IF_Gbps(10);
 
 #if __FreeBSD_version = 100
-	sc-ifp-if_hw_tsomax = OCE_MAX_TSO_SIZE;
+	sc-ifp-if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
+	sc-ifp-if_hw_tsomaxsegcount = OCE_MAX_TX_ELEMENTS;
+	sc-ifp-if_hw_tsomaxsegsize = 4096;
 #endif
 
 	ether_ifattach(sc-ifp, sc-macaddr.mac_addr);
=== sys/dev/oce/oce_if.h
==
--- sys/dev/oce/oce_if.h	(revision 271555)
+++ sys/dev/oce/oce_if.h	(local)
@@ -152,7 +152,6 @@
 #define OCE_MAX_TX_ELEMENTS		29
 #define OCE_MAX_TX_DESC			1024
 #define OCE_MAX_TX_SIZE			65535
-#define OCE_MAX_TSO_SIZE		(65535 - ETHER_HDR_LEN)
 #define OCE_MAX_RX_SIZE			4096
 #define OCE_MAX_RQ_POSTS		255
 #define OCE_DEFAULT_PROMISCUOUS		0
=== sys/dev/vmware/vmxnet3/if_vmx.c
==
--- sys/dev/vmware/vmxnet3/if_vmx.c	(revision 271555)
+++ sys/dev/vmware/vmxnet3/if_vmx.c	(local)
@@ -1722,7 +1722,9 @@
 	ifp-if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp-if_init = vmxnet3_init;
 	ifp-if_ioctl = vmxnet3_ioctl;
-	ifp-if_hw_tsomax = VMXNET3_TSO_MAXSIZE;
+	ifp-if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
+	ifp-if_hw_tsomaxsegcount = VMXNET3_TX_MAXSEGS;
+	ifp-if_hw_tsomaxsegsize = VMXNET3_TX_MAXSEGSIZE;
 
 #ifdef VMXNET3_LEGACY_TX
 	ifp-if_start = vmxnet3_start;
=== sys/dev/vmware/vmxnet3/if_vmxvar.h
==
--- sys/dev/vmware/vmxnet3/if_vmxvar.h	(revision 271555)
+++ sys/dev/vmware/vmxnet3/if_vmxvar.h	(local)
@@ -277,8 +277,6 @@
  */
 #define VMXNET3_TX_MAXSEGS		32
 #define VMXNET3_TX_MAXSIZE		(VMXNET3_TX_MAXSEGS * MCLBYTES)
-#define VMXNET3_TSO_MAXSIZE \
-(VMXNET3_TX_MAXSIZE - sizeof(struct ether_vlan_header))
 
 /*
  * Maximum support Tx segments size. The length field in the
=== sys/dev/xen/netfront/netfront.c
==
--- sys/dev/xen/netfront/netfront.c	(revision 271555)
+++ sys/dev/xen/netfront/netfront.c	(local)
@@ -134,7 +134,6 @@
  * to mirror the Linux MAX_SKB_FRAGS constant.
  */
 #define	MAX_TX_REQ_FRAGS (65536 / PAGE_SIZE + 2)
-#define	NF_TSO_MAXBURST ((IP_MAXPACKET / PAGE_SIZE) * MCLBYTES)
 
 #define RX_COPY_THRESHOLD 256
 
@@ -2102,7 +2101,9 @@
 	
 	ifp-if_hwassist = XN_CSUM_FEATURES;
 	ifp-if_capabilities = IFCAP_HWCSUM;
-	ifp-if_hw_tsomax = NF_TSO_MAXBURST;
+	ifp-if_hw_tsomax = 65536 - (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
+	ifp-if_hw_tsomaxsegcount = MAX_TX_REQ_FRAGS;
+	ifp-if_hw_tsomaxsegsize = PAGE_SIZE;
 	
 	ether_ifattach(ifp, np-mac);
 	callout_init(np-xn_stat_ch, CALLOUT_MPSAFE);
=== sys/kern/uipc_sockbuf.c
==
--- sys/kern/uipc_sockbuf.c	(revision 271555)
+++ sys/kern/uipc_sockbuf.c	(local)
@@ -1015,6 +1015,37 @@
 }
 
 /*
+ * Return the first mbuf and the mbuf data offset for the provided
+ * send offset without changing the sb_sndptroff field.
+ */
+struct mbuf *
+sbsndmbuf(struct sockbuf *sb, u_int off, u_int *moff)
+{
+	struct mbuf *m;
+
+	KASSERT(sb-sb_mb != NULL, (%s: sb_mb is NULL, __func__));
+
+	/*
+	 * If the off is below the stored offset, which happens on
+	 * retransmits, just use sb_mb:
+	 */
+	if (sb-sb_sndptr == NULL || sb-sb_sndptroff  off) {
+		m = sb-sb_mb;
+	} else {
+		m = sb-sb_sndptr;
+		off -= sb-sb_sndptroff;
+	}
+	while (off  0  m != NULL) {
+		if (off  m-m_len)
+			break;
+		off -= m-m_len;
+		m = m-m_next;
+	}
+	*moff = off;
+	return (m);
+}
+
+/*
  * Drop a record off the front of a sockbuf and move the next record to the
  * front.
  */
=== sys/net/if.c
==
--- sys/net/if.c	(revision 271555)
+++ sys/net/if.c	(local)
@@ -584,6 +584,57 @@
 	if_attach_internal(ifp, 0);
 }
 
+/*
+ * Compute the least common TSO limit.
+ */
+void
+if_hw_tsomax_common(if_t ifp, struct ifnet_hw_tsomax *pmax)
+{
+	/*
+	 * 1) If there is no limit currently, take the limit from
+	 * the network adapter.
+	 *
+	 * 2) If the network adapter has a limit below the current
+	 * limit, apply it.
+	 */
+	if (pmax-tsomaxbytes == 0 || (ifp-if_hw_tsomax != 0 
+	ifp-if_hw_tsomax  pmax-tsomaxbytes)) {
+		pmax-tsomaxbytes = ifp-if_hw_tsomax;
+	}
+	if (pmax-tsomaxsegcount == 0 || (ifp-if_hw_tsomaxsegcount != 0 
+	ifp-if_hw_tsomaxsegcount  pmax-tsomaxsegcount)) {
+		pmax-tsomaxsegcount = ifp-if_hw_tsomaxsegcount;
+	}
+	if (pmax-tsomaxsegsize == 0 || (ifp-if_hw_tsomaxsegsize != 0 
+	ifp-if_hw_tsomaxsegsize  pmax-tsomaxsegsize)) {
+		pmax-tsomaxsegsize = ifp-if_hw_tsomaxsegsize;
+	}
+}
+
+/*
+ * 

x11/nvidia-driver (340.24/340.32/343.13): nvidia BLOB doesn't recognize any display socket on Lenovo E540/UEFI and FBSD CURRENT

2014-09-19 Thread O. Hartmann
nVidia's BLOB from port x11/nvidia-driver seems to have problems in FreeBSD 
11.0-CURRENT
#2 r271869: Fri Sep 19 13:28:03 CEST 2014 amd64, on Lenovo ThinkPad Edge E540 
laptop with
CPU i5-4200M (Haswell) with integrated HD4600 Intel iGPU and dedicated nVidia 
GT 740M
(Optimus) working correctly.

The systems boots FreeBSD off via UEFI.

First of all: I tried versions 340.24, 340.32 and Beta 343.13 all with the very 
same
results.

Symptoms:

a) Loading kernel module nvidia via /boot/load.conf freezes the system after 
the
UEFI/EFI loader message shows up. Loading the kernel module vi kld_load=
in /etc/rc.conf[.local] works so far regarding loading and booting the kernel.

b) No display socket is recognized by the nvidia driver resulting in a blank 
vt() screen
after X has been started. I tried many different configurations, but at the end 
I suspect
that nVidia's Optimus technology may be the culprit.

The documentation of nVidia's driver for FreeBSD states that after the Xserver 
has
started it logs in Xorg.0.log (or whatever display number is used) the 
available display
sockets like (taken from the documents):

(--) NVIDIA(0): Valid display device(s) on Quadro 6000 at PCI:10:0:0
(--) NVIDIA(0): CRT-0
(--) NVIDIA(0): CRT-1
(--) NVIDIA(0): DELL U2410 (DFP-0) (connected)
(--) NVIDIA(0): NEC LCD1980SXi (DFP-1) (connected)

Nothing that similar shows up in my environment, but this:

[...]
[58.656] (--) PCI:*(0:0:2:0) 8086:0416:17aa:502a rev 6, Mem @ 
0xf100/4194304,
0xe000/268435456, I/O @ 0x6000/64, BIOS @ 0x/65536
[58.659] (--) PCI: (0:1:0:0) 10de:1292:17aa:502a rev 161, Mem @ 
0xf000/16777216,
0xc000/268435456, 0xd000/33554432, I/O @ 0x5000/128
[58.662] (II) extmod will be loaded. This was enabled by default and also 
specified
in the config file.
[58.662] (II) dbe will be loaded. This was enabled by default and also 
specified in
the config file.
[...]
[60.055] (**) NVIDIA(0): Enabling 2D acceleration
[60.485] (II) NVIDIA(0): NVIDIA GPU GeForce GT 740M (GK208) at PCI:1:0:0 
(GPU-0)
[60.486] (--) NVIDIA(0): Memory: 2097152 kBytes
[60.486] (--) NVIDIA(0): VideoBIOS: 80.28.25.00.27
[60.486] (II) NVIDIA(0): Detected PCI Express Link width: 8X
[60.486] (--) NVIDIA(0): Valid display device(s) on GeForce GT 740M at 
PCI:1:0:0
[60.487] (--) NVIDIA(0): none
[60.487] (II) NVIDIA(0): Validated MetaModes:
[60.487] (II) NVIDIA(0): NULL
[60.487] (II) NVIDIA(0): Virtual screen size determined to be 640 x 480
[60.488] (WW) NVIDIA(0): Unable to get display device for DPI computation.
[60.488] (==) NVIDIA(0): DPI set to (75, 75); computed from built-in default
[60.488] (--) Depth 24 pixmap format is 32 bpp
[60.489] (II) NVIDIA: Reserving 3072.00 MB of virtual memory for indirect 
memory
[60.489] (II) NVIDIA: access.
[60.492] (II) NVIDIA(0): Setting mode NULL
[60.493] (EE) NVIDIA(0): Failed to initiate mode change.
[60.493] (EE) NVIDIA(0): Failed to complete mode change
[60.553] (II) NVIDIA(0): Built-in logo is bigger than the screen.
[60.573] (II) Loading extension NV-GLX
[...]

Confusing is that in the lines
[58.656] (--) PCI:*(0:0:2:0) 8086:0416:17aa:502a rev 6, Mem @ 
0xf100/4194304,
0xe000/268435456, I/O @ 0x6000/64, BIOS @ 0x/65536
[58.659] (--) PCI: (0:1:0:0) 10de:1292:17aa:502a rev 161, Mem @ 
0xf000/16777216,
0xc000/268435456, 0xd000/33554432, I/O @ 0x5000/128

both, the Intel iGPU HD4600 (PCI:*(0:0:2:0)) and the nVidia dedicated GPU GT 
740M (PCI: (0:1:0:0)) show up.

The more scaring part is then (--) NVIDIA(0): Valid display device(s):

No display device is shown although the notebook has a built-in display, a 
DisplayPort
port as well as a VGA port. On all nVidia dedicated graphics boards I use on 
diffrent
other machines with the very same driver EVERY possible connector/socket shows 
up.

The laptop has EFI/UEFI

EFI Version: 2.31
EFI Firmware: Lenovo (re. 05648)

The problem is present no matter whether the drm2 and i915kms kernel moules are 
loaded or
not.

What is wrong here? Any chance to get the nVidia GPU to work? I use at the 
moment
xf86-video-scfb which is a pain in the ass and absolutely not usable, even with 
a faster
CPU. Under average load the whole laptop screen is like a slide show.

Please CC me.

Thanks in advance,
O. Hartmann


signature.asc
Description: PGP signature


Re: x11/nvidia-driver (340.24/340.32/343.13): nvidia BLOB doesn't recognize any display socket on Lenovo E540/UEFI and FBSD CURRENT

2014-09-19 Thread Henry Hu
On Fri, Sep 19, 2014 at 2:12 PM, O. Hartmann ohart...@zedat.fu-berlin.de
wrote:

 nVidia's BLOB from port x11/nvidia-driver seems to have problems in
 FreeBSD 11.0-CURRENT
 #2 r271869: Fri Sep 19 13:28:03 CEST 2014 amd64, on Lenovo ThinkPad Edge
 E540 laptop with
 CPU i5-4200M (Haswell) with integrated HD4600 Intel iGPU and dedicated
 nVidia GT 740M
 (Optimus) working correctly.

 The systems boots FreeBSD off via UEFI.

 First of all: I tried versions 340.24, 340.32 and Beta 343.13 all with the
 very same
 results.

 Symptoms:

 a) Loading kernel module nvidia via /boot/load.conf freezes the system
 after the
 UEFI/EFI loader message shows up. Loading the kernel module vi kld_load=
 in /etc/rc.conf[.local] works so far regarding loading and booting the
 kernel.

 b) No display socket is recognized by the nvidia driver resulting in a
 blank vt() screen
 after X has been started. I tried many different configurations, but at
 the end I suspect
 that nVidia's Optimus technology may be the culprit.

 The documentation of nVidia's driver for FreeBSD states that after the
 Xserver has
 started it logs in Xorg.0.log (or whatever display number is used) the
 available display
 sockets like (taken from the documents):

 (--) NVIDIA(0): Valid display device(s) on Quadro 6000 at PCI:10:0:0
 (--) NVIDIA(0): CRT-0
 (--) NVIDIA(0): CRT-1
 (--) NVIDIA(0): DELL U2410 (DFP-0) (connected)
 (--) NVIDIA(0): NEC LCD1980SXi (DFP-1) (connected)

 Nothing that similar shows up in my environment, but this:

 [...]
 [58.656] (--) PCI:*(0:0:2:0) 8086:0416:17aa:502a rev 6, Mem @
 0xf100/4194304,
 0xe000/268435456, I/O @ 0x6000/64, BIOS @ 0x/65536
 [58.659] (--) PCI: (0:1:0:0) 10de:1292:17aa:502a rev 161, Mem @
 0xf000/16777216,
 0xc000/268435456, 0xd000/33554432, I/O @ 0x5000/128
 [58.662] (II) extmod will be loaded. This was enabled by default and
 also specified
 in the config file.
 [58.662] (II) dbe will be loaded. This was enabled by default and
 also specified in
 the config file.
 [...]
 [60.055] (**) NVIDIA(0): Enabling 2D acceleration
 [60.485] (II) NVIDIA(0): NVIDIA GPU GeForce GT 740M (GK208) at
 PCI:1:0:0 (GPU-0)
 [60.486] (--) NVIDIA(0): Memory: 2097152 kBytes
 [60.486] (--) NVIDIA(0): VideoBIOS: 80.28.25.00.27
 [60.486] (II) NVIDIA(0): Detected PCI Express Link width: 8X
 [60.486] (--) NVIDIA(0): Valid display device(s) on GeForce GT 740M at
 PCI:1:0:0
 [60.487] (--) NVIDIA(0): none
 [60.487] (II) NVIDIA(0): Validated MetaModes:
 [60.487] (II) NVIDIA(0): NULL
 [60.487] (II) NVIDIA(0): Virtual screen size determined to be 640 x 480
 [60.488] (WW) NVIDIA(0): Unable to get display device for DPI
 computation.
 [60.488] (==) NVIDIA(0): DPI set to (75, 75); computed from built-in
 default
 [60.488] (--) Depth 24 pixmap format is 32 bpp
 [60.489] (II) NVIDIA: Reserving 3072.00 MB of virtual memory for
 indirect memory
 [60.489] (II) NVIDIA: access.
 [60.492] (II) NVIDIA(0): Setting mode NULL
 [60.493] (EE) NVIDIA(0): Failed to initiate mode change.
 [60.493] (EE) NVIDIA(0): Failed to complete mode change
 [60.553] (II) NVIDIA(0): Built-in logo is bigger than the screen.
 [60.573] (II) Loading extension NV-GLX
 [...]

 Confusing is that in the lines
 [58.656] (--) PCI:*(0:0:2:0) 8086:0416:17aa:502a rev 6, Mem @
 0xf100/4194304,
 0xe000/268435456, I/O @ 0x6000/64, BIOS @ 0x/65536
 [58.659] (--) PCI: (0:1:0:0) 10de:1292:17aa:502a rev 161, Mem @
 0xf000/16777216,
 0xc000/268435456, 0xd000/33554432, I/O @ 0x5000/128

 both, the Intel iGPU HD4600 (PCI:*(0:0:2:0)) and the nVidia dedicated GPU
 GT
 740M (PCI: (0:1:0:0)) show up.

 The more scaring part is then (--) NVIDIA(0): Valid display device(s):

 No display device is shown although the notebook has a built-in display, a
 DisplayPort
 port as well as a VGA port. On all nVidia dedicated graphics boards I use
 on diffrent
 other machines with the very same driver EVERY possible connector/socket
 shows up.

 The laptop has EFI/UEFI

 EFI Version: 2.31
 EFI Firmware: Lenovo (re. 05648)

 The problem is present no matter whether the drm2 and i915kms kernel
 moules are loaded or
 not.

 What is wrong here? Any chance to get the nVidia GPU to work? I use at the
 moment
 xf86-video-scfb which is a pain in the ass and absolutely not usable, even
 with a faster
 CPU. Under average load the whole laptop screen is like a slide show.

 Please CC me.


My laptop has an integrated graphics (HD4000) and a nvidia GPU (GT650M). It
also has optimus.
 It has a VGA output, a HDMI output, and the internal LCD.

Using the intel driver, I can use the internal LCD and VGA. Using the
nvidia driver, I can use the HDMI.
To use the nvidia driver, I have to use acpi_call to turn on or initialize
the nvidia card first.

My guess is that my HDMI port is conencted to the nvidia card, and maybe
all the ports 

[PATCH] Lock spic(4)

2014-09-19 Thread John Baldwin
This patch adds locking to spic(4) and marks it MPSAFE.  The patch 
is against HEAD but probably applies to 9 and 10 as well.

http://people.freebsd.org/~jhb/patches/spic_locking.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[PATCH] Lock scsi_low, ct(4), ncv(4), nsp(4), stg(4)

2014-09-19 Thread John Baldwin
This patch adds locking to the scsi_low subsystem and the drivers that use it: 
ct(4), ncv(4), nsp(4), and stg(4).  The drivers are all marked MPSAFE.  The 
patch is against HEAD but probably applies to 9 and 10 as well.

http://people.freebsd.org/~jhb/patches/scsi_low_locking.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[PATCH] Various fixes to wl(4)

2014-09-19 Thread John Baldwin
This patch fixes various issues in wl(4) including:

 - Use bus_space instead of inb/outb.
 - Use device_printf() and if_printf()
 - Use callout(9) instead of timeout(9)
 - Don't hold the driver lock across sleeping actions like
   bus_teardown_intr(), subyte(), etc.
 - Don't recurse on the driver lock.

The patch is against HEAD but probably applies to 9 and 10 as well.

http://people.freebsd.org/~jhb/patches/wl_cleanup.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[PATCH] Convert bluetooth from timeout(9) to callout(9)

2014-09-19 Thread John Baldwin
This patch converts the netgraph bluetooth codee from timeout(9) to 
callout(9).  The patch is against HEAD but probably applies to 9 and 10 as 
well.

http://people.freebsd.org/~jhb/patches/bluetooth_callout.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[PATCH] Fix si(4) to use bus_space

2014-09-19 Thread John Baldwin
This patch fixes the si(4) driver to use the bus_space methods to access 
memory and I/O resources instead of directly calling inb()/outb() and using 
rman_get_virtual().  The patch is against HEAD but probably applies to 9 and 
10 as well.

http://people.freebsd.org/~jhb/patches/si_bus_space.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[PATCH] Lock scd(4)

2014-09-19 Thread John Baldwin
This patch adds locking to scd(4) and marks it MPSAFE.  It also uses bus_*() 
instead of bus_space_*().  The patch is against HEAD but probably applies to 9 
and 10 as well.

http://people.freebsd.org/~jhb/patches/scd_locking.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[PATCH] Convert tws(4) from timeout(9) to callout(9)

2014-09-19 Thread John Baldwin
This patch converts tws(4) from timeout(9) to callout(9).  It also fixes a few 
places that were tearing down and setting up in the interrupt handler where it 
was not safe to do so and adds some missing teardown actions.  The patch is 
against HEAD but probably applies to 9 and 10 as well.

http://people.freebsd.org/~jhb/patches/tws_callout.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[PATCH] Fix callouts in rp(4)

2014-09-19 Thread John Baldwin
This patch converts rp(4) from timeout(9) to callout(9).  To do this cleanly, 
it replaces a single, global timer that walks tables of controllers and ports 
to a per-controller timer.  This works much better with locking (since the 
locks are per-controller) and removes the need for various global lookup 
tables in the driver.  The patch is against HEAD but probably applies to 9 and 
10 as well.

http://people.freebsd.org/~jhb/patches/rp_callout.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[PATCH] Lock wds(4)

2014-09-19 Thread John Baldwin
This patch adds locking to wds(4) and marks it MPSAFE.  It also includes 
several other cleanups such as using bus_space instead of inb/outb.  The patch 
is against HEAD but probably applies to 9 and 10 as well.

http://people.freebsd.org/~jhb/patches/wds_locking.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: libthr and main thread stack size

2014-09-19 Thread John Baldwin
On Tuesday, September 16, 2014 11:13:24 AM Konstantin Belousov wrote:
 On Mon, Sep 15, 2014 at 03:47:41PM -0600, Justin T. Gibbs wrote:
  On Aug 8, 2014, at 5:22 AM, Konstantin Belousov kostik...@gmail.com
  wrote:
  
  ?
  
   Below is the patch which adds environment variable
   LIBPTHREAD_BIGSTACK_MAIN. Setting it to any value results in the
   main thread stack left as is, and other threads allocate stack
   below the area of RLIMIT_STACK. Try it. I do not want to set this
   behaviour as default.
  
  Is there a reason this should not be the default? Looking at the
  getrlimit() page on the OpenGroup?s site they say:
  
  RLIMIT_STACK This is the maximum size of the initial thread's stack,
  in bytes. The implementation does not automatically grow the stack
  beyond this limit. If this limit is exceeded, SIGSEGV shall be
  generated for the thread. If the thread is blocking SIGSEGV, or the
  process is ignoring or catching SIGSEGV and has not made arrangements
  to use an alternate stack, the disposition of SIGSEGV shall be set to
  SIG_DFL before it is generated.
  
  Does posix say something different?
  
  I ran into this issue when debugging a segfault on Postgres when
  running an (arguably quite bogus) query that should have fit within
  both the configured stack rlimit and Postgres? configured stack limit.
  The Postgres backend is really just single threaded, but happens
  to pull in libpthread due to the threading support in some of the
  libraries it uses. The segfault definitely violates POLA.
  
  ? Justin
 
 I am conservative to not disturb the address space layout in single go.
 If enough people test this setting, I can consider flipping the default
 to the reverse.
 
 I am still curious why the things were done in this way, but nobody
 replied.

I suspect it was done out of reasons of being overly conservative in 
interpreting RLIMIT_STACK.  I think it is quite surprising behavior though and 
would rather we make your option the default and implement what the Open Group 
says above.

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


[PATCH] Lock mse(4)

2014-09-19 Thread John Baldwin
This patch adds locking to mse(4) and marks it MPSAFE.  It also adds some 
other cleanups such as using bus_*() instead of bus_space_*() and 
consolidating duplicate copies of its detach routine.  The patch is against 
HEAD but probably applies to 9 and 10 as well.

http://people.freebsd.org/~jhb/patches/mse_locking.patch

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [PATCH] Convert bluetooth from timeout(9) to callout(9)

2014-09-19 Thread Maksim Yevmenkin
On Fri, Sep 19, 2014 at 1:18 PM, John Baldwin j...@freebsd.org wrote:
 This patch converts the netgraph bluetooth codee from timeout(9) to
 callout(9).  The patch is against HEAD but probably applies to 9 and 10 as
 well.

 http://people.freebsd.org/~jhb/patches/bluetooth_callout.patch

looks fine to me.

thanks,
max
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [PATCH] Various fixes to wl(4)

2014-09-19 Thread Warner Losh
I got rid of my pre-802.11 WaveLAN cards about 8 years go after not having them 
in a system at all for 8 years. And they were about 4 years obsolete when I 
took them out of service… I’m not even sure I have a machine with an ISA slot 
to test the card, even if I still had it.

Sorry I can’t help more :)

Warner

On Sep 19, 2014, at 2:07 PM, John Baldwin j...@freebsd.org wrote:

 This patch fixes various issues in wl(4) including:
 
 - Use bus_space instead of inb/outb.
 - Use device_printf() and if_printf()
 - Use callout(9) instead of timeout(9)
 - Don't hold the driver lock across sleeping actions like
   bus_teardown_intr(), subyte(), etc.
 - Don't recurse on the driver lock.
 
 The patch is against HEAD but probably applies to 9 and 10 as well.
 
 http://people.freebsd.org/~jhb/patches/wl_cleanup.patch
 
 -- 
 John Baldwin



signature.asc
Description: Message signed with OpenPGP using GPGMail


[PATCH] Fix integer overflow handling in dd(1)

2014-09-19 Thread William Orr

Hey,

I've submitted this patch before, and it's gotten comments and fixes, 
but still hasn't been merged. Any thoughts? Does it need more work?


Thanks,
William Orr

Index: args.c
===
--- args.c(revision 270645)
+++ args.c(working copy)
@@ -41,6 +41,7 @@

 #include sys/types.h

+#include ctype.h
 #include err.h
 #include errno.h
 #include inttypes.h
@@ -171,8 +172,7 @@
  */
 if (in.offset  OFF_MAX / (ssize_t)in.dbsz ||
 out.offset  OFF_MAX / (ssize_t)out.dbsz)
-errx(1, seek offsets cannot be larger than %jd,
-(intmax_t)OFF_MAX);
+errx(1, seek offsets cannot be larger than %jd, OFF_MAX);
 }

 static int
@@ -186,37 +186,28 @@
 static void
 f_bs(char *arg)
 {
-uintmax_t res;

-res = get_num(arg);
-if (res  1 || res  SSIZE_MAX)
-errx(1, bs must be between 1 and %jd, (intmax_t)SSIZE_MAX);
-in.dbsz = out.dbsz = (size_t)res;
+in.dbsz = out.dbsz = get_num(arg);
+if (out.dbsz  1 || out.dbsz  SSIZE_MAX)
+errx(1, bs must be between 1 and %jd, SSIZE_MAX);
 }

 static void
 f_cbs(char *arg)
 {
-uintmax_t res;

-res = get_num(arg);
-if (res  1 || res  SSIZE_MAX)
-errx(1, cbs must be between 1 and %jd, (intmax_t)SSIZE_MAX);
-cbsz = (size_t)res;
+cbsz = get_num(arg);
+if (cbsz  1 || cbsz  SSIZE_MAX)
+errx(1, cbs must be between 1 and %jd, SSIZE_MAX);
 }

 static void
 f_count(char *arg)
 {
-intmax_t res;

-res = (intmax_t)get_num(arg);
-if (res  0)
-errx(1, count cannot be negative);
-if (res == 0)
-cpy_cnt = (uintmax_t)-1;
-else
-cpy_cnt = (uintmax_t)res;
+cpy_cnt = get_num(arg);
+if (cpy_cnt == 0)
+cpy_cnt = -1;
 }

 static void
@@ -225,7 +216,7 @@

 files_cnt = get_num(arg);
 if (files_cnt  1)
-errx(1, files must be between 1 and %jd, (uintmax_t)-1);
+errx(1, files must be between 1 and %ju, SIZE_MAX);
 }

 static void
@@ -241,14 +232,11 @@
 static void
 f_ibs(char *arg)
 {
-uintmax_t res;

 if (!(ddflags  C_BS)) {
-res = get_num(arg);
-if (res  1 || res  SSIZE_MAX)
-errx(1, ibs must be between 1 and %jd,
-(intmax_t)SSIZE_MAX);
-in.dbsz = (size_t)res;
+in.dbsz = get_num(arg);
+if (in.dbsz  1 || in.dbsz  SSIZE_MAX)
+errx(1, ibs must be between 1 and %ju, SSIZE_MAX);
 }
 }

@@ -262,14 +250,11 @@
 static void
 f_obs(char *arg)
 {
-uintmax_t res;

 if (!(ddflags  C_BS)) {
-res = get_num(arg);
-if (res  1 || res  SSIZE_MAX)
-errx(1, obs must be between 1 and %jd,
-(intmax_t)SSIZE_MAX);
-out.dbsz = (size_t)res;
+out.dbsz = get_num(arg);
+if (out.dbsz  1 || out.dbsz  SSIZE_MAX)
+errx(1, obs must be between 1 and %jd, SSIZE_MAX);
 }
 }

@@ -378,11 +363,17 @@
 uintmax_t num, mult, prevnum;
 char *expr;

+while (isspace(val[0]))
+val++;
+
+if (val[0] == '-')
+errx(1, %s: cannot be negative, oper);
+
 errno = 0;
-num = strtouq(val, expr, 0);
+num = strtoull(val, expr, 0);
 if (errno != 0)/* Overflow or underflow. */
 err(1, %s, oper);
-
+
 if (expr == val)/* No valid digits. */
 errx(1, %s: illegal numeric value, oper);

Index: conv.c
===
--- conv.c(revision 270645)
+++ conv.c(working copy)
@@ -133,7 +133,7 @@
  */
 ch = 0;
 for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) {
-maxlen = MIN(cbsz, in.dbcnt);
+maxlen = MIN(cbsz, (size_t)in.dbcnt);
 if ((t = ctab) != NULL)
 for (cnt = 0; cnt  maxlen  (ch = *inp++) != '\n';
 ++cnt)
@@ -146,7 +146,7 @@
  * Check for short record without a newline.  Reassemble the
  * input block.
  */
-if (ch != '\n'  in.dbcnt  cbsz) {
+if (ch != '\n'  (size_t)in.dbcnt  cbsz) {
 (void)memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
 break;
 }
@@ -228,7 +228,7 @@
  * translation has to already be done or we might not recognize the
  * spaces.
  */
-for (inp = in.db; in.dbcnt = cbsz; inp += cbsz, in.dbcnt -= cbsz) {
+for (inp = in.db; (size_t)in.dbcnt = cbsz; inp += cbsz, in.dbcnt
-= cbsz) {
 for (t = inp + cbsz - 1; t = inp  *t == ' '; --t)
 ;
 if (t = inp) {
Index: dd.c
===
--- dd.c(revision 270645)
+++ dd.c(working copy)
@@ -168,10 +168,10 @@
  * record oriented I/O, only need a single buffer.
  */
 if (!(ddflags  (C_BLOCK | C_UNBLOCK))) {
-if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL)
+if ((in.db = malloc((size_t)out.dbsz + in.dbsz - 1)) == NULL)
 err(1, input buffer);