Re: smu(4) fan speed

2016-04-16 Thread Marcus Glocker
On Sat, Apr 16, 2016 at 09:56:21PM +0200, Olivier Cherrier wrote:

> And what about trying this ?
> 
> http://marc.info/?t=14542807061=1=2
> 
> (It works well for the iMac G5).
> 
> Thanks,
> Best
> oc

Thanks for pointing this out.  But my issue here happens even one step
before, when the driver can't set the initial unmanage/safe/average
value because on my machine this property is called 'safe-value' instead
of 'unmanage-value'.  Could you send the eeprom -p of your machine as
well?  I wonder if the property there is called 'unmanage-value' or
'unmanaged-value'.

Anyway, taken in to account of the 'safe-value' property as well, the
below diff works perfectly fine in my case:

$ sysctl -a | grep smu
hw.sensors.smu0.temp0=33.87 degC (CPU T-Diode)
hw.sensors.smu0.fan0=999 RPM (Rear Fan 0)
hw.sensors.smu0.fan1=1002 RPM (Rear fan 1)
hw.sensors.smu0.fan2=1002 RPM (Front Fan)
hw.sensors.smu0.volt0=12.17 VDC (CPU Voltage)
hw.sensors.smu0.power0=11.31 W (Slots Power)
hw.sensors.smu0.current0=1.07 A (CPU Current)

This diff doesn't change the current behaviour but takes 'safe-value'
in to account.


Index: sys/arch/macppc/dev/smu.c
===
RCS file: /cvs/src/sys/arch/macppc/dev/smu.c,v
retrieving revision 1.27
diff -u -p -u -p -r1.27 smu.c
--- sys/arch/macppc/dev/smu.c   4 Jun 2015 18:01:44 -   1.27
+++ sys/arch/macppc/dev/smu.c   17 Apr 2016 05:08:16 -
@@ -43,7 +43,7 @@ struct smu_fan {
u_int8_treg;
u_int16_t   min_rpm;
u_int16_t   max_rpm;
-   u_int16_t   unmanaged_rpm;
+   u_int16_t   avg_rpm;
struct ksensor  sensor;
 };
 
@@ -280,16 +280,17 @@ smu_attach(struct device *parent, struct
if (OF_getprop(node, "max-value", , sizeof val) <= 0)
val = 0x;
fan->max_rpm = val;
-   if (OF_getprop(node, "unmanage-value", , sizeof val) <= 0)
+   if (OF_getprop(node, "unmanage-value", , sizeof val) <= 0 &&
+   OF_getprop(node, "safe-value", , sizeof val) <= 0)
val = fan->max_rpm;
-   fan->unmanaged_rpm = val;
+   fan->avg_rpm = val;
 
if (OF_getprop(node, "location", loc, sizeof loc) <= 0)
strlcpy(loc, "Unknown", sizeof loc);
strlcpy(fan->sensor.desc, loc, sizeof sensor->sensor.desc);
 
-   /* Start running fans at their "unmanaged" speed. */
-   smu_fan_set_rpm(sc, fan, fan->unmanaged_rpm);
+   /* Start running fans at their "average" speed. */
+   smu_fan_set_rpm(sc, fan, fan->avg_rpm);
 
 #ifndef SMALL_KERNEL
sensor_attach(>sc_sensordev, >sensor);



libedit: delete vi-histedit editor command

2016-04-16 Thread Ingo Schwarze
Hi,

in vi command mode, libedit provides the editor command
vi-histedit (bound to the 'v' key by default) to fork and
exec vi(1) on the line being edited.  That is pretty much
pointless in the first place because the line can just as
well be edited with libedit itself, without any fork and exec.
Built-in libedit editing capabilities is already much more
bloated than we could reasonably wish for.

In a pledge(2)d world, such excessive functionality is harmful.
Nobody pledging a program will expect that it might need "proc exec"
just because it uses libedit, and then kittens^Wusers get killed
when hitting the "v" key at the wrong time.  Yikes.

OK to delete the misfeature?

Yours,
  Ingo


P.S.
For testing, don't forget to

  cd /usr/src/lib/libedit/
  make clean
  make depend
  make
  doas make install

to be sure that all generated files are properly regenerated.


Index: editrc.5
===
RCS file: /cvs/src/lib/libedit/editrc.5,v
retrieving revision 1.29
diff -u -p -r1.29 editrc.5
--- editrc.58 Jan 2016 20:26:54 -   1.29
+++ editrc.516 Apr 2016 23:20:04 -
@@ -388,8 +388,6 @@ Vi comment out current command.
 Vi include shell alias.
 .It Ic vi-to-history-line
 Vi go to specified history file line..
-.It Ic vi-histedit
-Vi edit history line with vi.
 .It Ic vi-history-word
 Vi append word from previous input line.
 .It Ic vi-redo
Index: map.c
===
RCS file: /cvs/src/lib/libedit/map.c,v
retrieving revision 1.24
diff -u -p -r1.24 map.c
--- map.c   12 Apr 2016 09:04:02 -  1.24
+++ map.c   16 Apr 2016 23:20:04 -
@@ -742,7 +742,7 @@ static const el_action_t el_map_vi_comma
/* 115 */   VI_SUBSTITUTE_CHAR, /* s */
/* 116 */   VI_TO_NEXT_CHAR,/* t */
/* 117 */   VI_UNDO,/* u */
-   /* 118 */   VI_HISTEDIT,/* v */
+   /* 118 */   ED_UNASSIGNED,  /* v */
/* 119 */   VI_NEXT_WORD,   /* w */
/* 120 */   ED_DELETE_NEXT_CHAR,/* x */
/* 121 */   VI_YANK,/* y */
Index: vi.c
===
RCS file: /cvs/src/lib/libedit/vi.c,v
retrieving revision 1.24
diff -u -p -r1.24 vi.c
--- vi.c11 Apr 2016 21:17:29 -  1.24
+++ vi.c16 Apr 2016 23:20:04 -
@@ -38,12 +38,10 @@
 /*
  * vi.c: Vi mode commands.
  */
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #include "el.h"
 #include "common.h"
@@ -991,93 +989,6 @@ vi_to_history_line(EditLine *el, wint_t 
if (rval == CC_ERROR)
el->el_history.eventno = sv_event_no;
return rval;
-}
-
-/* vi_histedit():
- * Vi edit history line with vi
- * [v]
- */
-protected el_action_t
-/*ARGSUSED*/
-vi_histedit(EditLine *el, wint_t c __attribute__((__unused__)))
-{
-   int fd;
-   pid_t pid;
-   ssize_t st;
-   int status;
-   char tempfile[] = "/tmp/histedit.XX";
-   char *cp;
-   size_t len;
-   wchar_t *line;
-
-   if (el->el_state.doingarg) {
-   if (vi_to_history_line(el, 0) == CC_ERROR)
-   return CC_ERROR;
-   }
-
-   fd = mkstemp(tempfile);
-   if (fd < 0)
-   return CC_ERROR;
-   len = (size_t)(el->el_line.lastchar - el->el_line.buffer);
-#define TMP_BUFSIZ (EL_BUFSIZ * MB_LEN_MAX)
-   cp = malloc(TMP_BUFSIZ);
-   if (cp == NULL) {
-   close(fd);
-   unlink(tempfile);
-   return CC_ERROR;
-   }
-   line = reallocarray(NULL, len, sizeof(*line));
-   if (line == NULL) {
-   close(fd);
-   unlink(tempfile);
-   free(cp);
-   return CC_ERROR;
-   }
-   wcsncpy(line, el->el_line.buffer, len);
-   line[len] = '\0';
-   wcstombs(cp, line, TMP_BUFSIZ - 1);
-   cp[TMP_BUFSIZ - 1] = '\0';
-   len = strlen(cp);
-   write(fd, cp, len);
-   write(fd, "\n", 1);
-   pid = fork();
-   switch (pid) {
-   case -1:
-   close(fd);
-   unlink(tempfile);
-   free(cp);
-free(line);
-   return CC_ERROR;
-   case 0:
-   close(fd);
-   execlp("vi", "vi", tempfile, (char *)NULL);
-   exit(0);
-   /*NOTREACHED*/
-   default:
-   while (waitpid(pid, , 0) != pid)
-   continue;
-   lseek(fd, (off_t)0, SEEK_SET);
-   st = read(fd, cp, TMP_BUFSIZ);
-   if (st > 0) {
-   len = (size_t)(el->el_line.lastchar -
-   el->el_line.buffer);
-   len = mbstowcs(el->el_line.buffer, cp, len);
-   if (len > 0 && el->el_line.buffer[len -1] == '\n')
- 

Re: smu(4) fan speed

2016-04-16 Thread Olivier Cherrier
On Sat, Apr 16, 2016 at 08:11:27PM +0200, mar...@nazgul.ch wrote:
> On Sat, Apr 16, 2016 at 07:34:59PM +0200, Mark Kettenis wrote:
> 
> > > Date: Fri, 15 Apr 2016 20:41:53 +0200
> > > From: Marcus Glocker 
> > > 
> > > Yesterday I've installed macppc -current on a G5.
> > > Since OF_getprop() for the 'unmanage-value' parameter fails on it,
> > > smu(4) sets the fan speed to 'max-value' instead, which is 3200RPM
> > > in my case.  This makes the G5 sound louder than my vacuum cleaner.
> > > 
> > > First I thought 'unmanage-value' is a typo and it should be
> > > 'unmanaged-value' like in the FreeBSD driver, but unfortunately it
> > > still did fail.  I saw that the FreeBSD driver doesn't set the fan
> > > speed at all initially in their driver.  When I do the same on the
> > > G5, the fan speed goes to a decent of ~1000RPM:
> > > 
> > >   hw.sensors.smu0.fan0=999 RPM (Rear Fan 0)
> > >   hw.sensors.smu0.fan1=999 RPM (Rear fan 1)
> > >   hw.sensors.smu0.fan2=999 RPM (Front Fan)
> > > 
> > > I don't know what the right way is to fix this, but skipping to set
> > > the fan speed when the 'unmanage-value' isn't available seems to work
> > > fine in this case.
> > 
> > On what hardware are you running this?
> 
> model: 'PowerMac9,1'
> compatible: 'PowerMac9,1' + 'MacRISC4' + 'Power Macintosh'
> 

And what about trying this ?

http://marc.info/?t=14542807061=1=2

(It works well for the iMac G5).

Thanks,
Best
oc



libkvm: Make _kvm_uread inspect proper amap slot to read userspace page

2016-04-16 Thread Stefan Kempf
_kvm_uread maps a userspace page to a slot in the amap, but
only checks whether the slot is indeed within the amap.
It must also use the slot to extract the correct vm_anon in order
to find the physical address to read from.

The attached program shows that kvm_uread otherwise attempts reads
from an incorrect userspace address.

ok?

Index: lib/libkvm/kvm_proc.c
===
RCS file: /cvs/src/lib/libkvm/kvm_proc.c,v
retrieving revision 1.52
diff -u -p -r1.52 kvm_proc.c
--- lib/libkvm/kvm_proc.c   22 Oct 2014 04:13:35 -  1.52
+++ lib/libkvm/kvm_proc.c   16 Apr 2016 18:23:32 -
@@ -163,7 +163,7 @@ _kvm_ureadm(kvm_t *kd, const struct kinf
if (slot > amap.am_nslot)
return (NULL);
 
-   addr = (u_long)amap.am_anon + (offset / kd->nbpg) * sizeof(anonp);
+   addr = (u_long)(amap.am_anon + slot);
if (KREAD(kd, addr, ))
return (NULL);
 
/*
 * Compile with: gcc -O2 libkvmtest.c -o libkvmtest -lkvm
 * Run as root.
 */

#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 

#define ARGSIZE (2 * 4096)

#define DO_MUNMAP   1

int
main(int argc, char **argv)
{
int cnt, i;
char *p, **pargv;
kvm_t *kd;
struct kinfo_proc *kp;

p = mmap(NULL, ARGSIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE,
-1, 0);
if (p == MAP_FAILED)
err(1, "mmap");

/*
 * Make sure that the kernel creates an amap the mapped range
 * by populating it with pages.
 */
memset(p, 0, ARGSIZE);

/*
 * Now unmap the first page. This causes the mapped
 * range to be split into two vm_map_entries. The
 * first entry is freed. The second vm_amp_entry represents
 * the second page in the range. The second map entry points
 * to the previously created amap. Since the amap still
 * contains two slots to represent the original range,
 * the second vm_map_entry must point into the amap with
 * an offset of 1 to refer to the slot representing the second
 * page.
 */
#if DO_MUNMAP
if (munmap(p, 4096) == -1)
err(1, "munmap");
#endif

p[4096] = 'A';
argv[0] = [4096];

kd = kvm_openfiles("./libkvmtest", "/dev/mem", NULL, O_RDONLY,
NULL);
if (kd == NULL)
errx(1, "kvm_open");
kp = kvm_getprocs(kd, KERN_PROC_PID, getpid(), sizeof *kp, );
if (kp == NULL || cnt != 1)
errx(1, "kvm_getprocs");

pargv = kvm_getargv(kd, kp, 8192);
if (pargv == NULL)
errx(1, "pargv");
for (i = 0; pargv[i] != NULL; i++)
printf("pargv[%d]: %s\n", i, pargv[i]);

return 0;

}


Re: smu(4) fan speed

2016-04-16 Thread Marcus Glocker
On Sat, Apr 16, 2016 at 07:34:59PM +0200, Mark Kettenis wrote:

> > Date: Fri, 15 Apr 2016 20:41:53 +0200
> > From: Marcus Glocker 
> > 
> > Yesterday I've installed macppc -current on a G5.
> > Since OF_getprop() for the 'unmanage-value' parameter fails on it,
> > smu(4) sets the fan speed to 'max-value' instead, which is 3200RPM
> > in my case.  This makes the G5 sound louder than my vacuum cleaner.
> > 
> > First I thought 'unmanage-value' is a typo and it should be
> > 'unmanaged-value' like in the FreeBSD driver, but unfortunately it
> > still did fail.  I saw that the FreeBSD driver doesn't set the fan
> > speed at all initially in their driver.  When I do the same on the
> > G5, the fan speed goes to a decent of ~1000RPM:
> > 
> > hw.sensors.smu0.fan0=999 RPM (Rear Fan 0)
> > hw.sensors.smu0.fan1=999 RPM (Rear fan 1)
> > hw.sensors.smu0.fan2=999 RPM (Front Fan)
> > 
> > I don't know what the right way is to fix this, but skipping to set
> > the fan speed when the 'unmanage-value' isn't available seems to work
> > fine in this case.
> 
> On what hardware are you running this?

model: 'PowerMac9,1'
compatible: 'PowerMac9,1' + 'MacRISC4' + 'Power Macintosh'

> Can you send us the output of eeprom -p for this machine?

Looks like the 'unmanage-value' is called 'safe-value' here:

Node 0xff97fc68
name: 'fan'
device_type: 'fan-rpm-control'
compatible: 'smu-rpm-fan' + 'smu-fan'
min-value: 0320
safe-value: 03e8
max-value: 0c80
reg: 
built-in: 
version: 0002
zone: 
control-id: 
location: 'Rear Fan 0'

Node 0xff97feb0
name: 'fan'
device_type: 'fan-rpm-control'
compatible: 'smu-rpm-fan' + 'smu-fan'
min-value: 0320
safe-value: 03e8
max-value: 0c80
reg: 0001
built-in: 
version: 0002
zone: 
control-id: 0001
location: 'Rear fan 1'

Node 0xff9800f8
name: 'fan'
device_type: 'fan-rpm-control'
compatible: 'smu-rpm-fan' + 'smu-fan'
min-value: 0320
safe-value: 0320
max-value: 0c80
reg: 0002
built-in: 
version: 0002
zone: 
control-id: 0002
location: 'Front Fan'

Here the full eeprom -p output:

Node 0xff88e0a0
model: 'PowerMac9,1'
compatible: 'PowerMac9,1' + 'MacRISC4' + 'Power Macintosh'
serial-number: 'QYU' + 'CK52400DQYU'
customer-sw-config: '   '
pid#: 2241
scb#: 0002
display-config-info: 0831.
name: 'device-tree'
copyright: 'Copyright 1983-2004 Apple Computer, Inc. All Rights Reserved'
device_type: 'bootrom'
system-id: '0'
#address-cells: 0002
#size-cells: 0001
clock-frequency: 23c34600
AAPL,add-fcode-file: ff867be0

Node 0xff8909e0
name: 'cpus'
#address-cells: 0001
#size-cells: 

Node 0xff890c48
name: 'PowerPC,G5'
device_type: 'cpu'
reg: 
cpu-version: 003c0300
cpu#: 
soft-reset: 0071
state: 'running'
clock-frequency: 6b49d200
bus-frequency: 23c34600
config-bus-frequency: 3b9aca00
timebase-frequency: 01fca055
reservation-granule-size: 0080
tlb-sets: 0100
tlb-size: 1000
d-cache-size: 8000
i-cache-size: 0001
d-cache-sets: 0080
i-cache-sets: 0200
i-cache-block-size: 0080
d-cache-block-size: 0080
graphics: 
performance-monitor: 
altivec: 
data-streams: 
dcbz: 0080
general-purpose: 
64-bit: 
32-64-bridge: 
existing: .8000.8000.8000
available: 3000.7fffd000.d000.2000
translations: 

Re: ix(4): enable checksum offload

2016-04-16 Thread mxb
Not sure what is wrong, if it is driver or chipset, but in freebsd I had to 
'-rxcsum6 -txcsum6 -tso -vlanhwtso’ in order to make it function.

> On 16 apr. 2016, at 18:23, Hrvoje Popovski  wrote:
> 
> On 9.9.2013. 22:07, Mike Belopuhov wrote:
>> On 9 September 2013 21:48, Brad Smith  wrote:
>>> Here is a diff to enable the checksum offload support for ix(4).
>>> 
>>> Looking for any testing.
>>> 
>> 
>> last time i checked this broke ospf traffic.  please make sure at least
>> ip/tcp, ip/udp, ip/icmp, ip/ip, ip/gre, ip/esp, ip/ah and ip/ospf work fine
>> with this.
>> 
> 
> Hi all,
> 
> is this still interesting topic? if it is, i have testbed to test csum
> for em i350 (i350v2 is on the way) and ix 82599 or x540. and week ago i
> ordered
> http://www.supermicro.com/products/system/1U/5018/SYS-5018D-FN8T.cfm
> with x552 or x557 not sure, i350-am4 and i210 ... lots of em's and ix's :)
> 



Re: uvm: remove am_maxslot from amap

2016-04-16 Thread Mark Kettenis
> Date: Sat, 16 Apr 2016 16:36:11 +0200
> From: Stefan Kempf 
> 
> am_maxslot represents the total number of slots an amap can be extended
> to. Since we do not extend amaps, this field as well as rounding the
> number of slots to the next malloc bucket is not useful.
> 
> This also removes the corresponding output from procmap(1).
> 
> ok?

ok kettenis@

> Index: sys/uvm/uvm_amap.c
> ===
> RCS file: /cvs/src/sys/uvm/uvm_amap.c,v
> retrieving revision 1.65
> diff -u -p -r1.65 uvm_amap.c
> --- sys/uvm/uvm_amap.c12 Apr 2016 16:47:33 -  1.65
> +++ sys/uvm/uvm_amap.c16 Apr 2016 14:29:55 -
> @@ -180,44 +180,37 @@ static inline struct vm_amap *
>  amap_alloc1(int slots, int waitf)
>  {
>   struct vm_amap *amap;
> - int totalslots;
>  
>   amap = pool_get(_amap_pool, (waitf == M_WAITOK) ? PR_WAITOK
>   : PR_NOWAIT);
>   if (amap == NULL)
>   return(NULL);
>  
> - totalslots = slots;
> - KASSERT(totalslots > 0);
> -
> - if (totalslots > UVM_AMAP_CHUNK)
> - totalslots = malloc_roundup(totalslots * MALLOC_SLOT_UNIT) /
> - MALLOC_SLOT_UNIT;
> + KASSERT(slots > 0);
>  
>   amap->am_ref = 1;
>   amap->am_flags = 0;
>  #ifdef UVM_AMAP_PPREF
>   amap->am_ppref = NULL;
>  #endif
> - amap->am_maxslot = totalslots;
>   amap->am_nslot = slots;
>   amap->am_nused = 0;
>  
> - if (totalslots > UVM_AMAP_CHUNK)
> - amap->am_slots = malloc(totalslots * MALLOC_SLOT_UNIT,
> + if (slots > UVM_AMAP_CHUNK)
> + amap->am_slots = malloc(slots * MALLOC_SLOT_UNIT,
>   M_UVMAMAP, waitf);
>   else
>   amap->am_slots = pool_get(
> - _amap_slot_pools[totalslots - 1],
> + _amap_slot_pools[slots - 1],
>   (waitf == M_WAITOK) ? PR_WAITOK : PR_NOWAIT);
>  
>   if (amap->am_slots == NULL)
>   goto fail1;
>  
> - amap->am_bckptr = (int *)(((char *)amap->am_slots) + totalslots *
> + amap->am_bckptr = (int *)(((char *)amap->am_slots) + slots *
>   sizeof(int));
>   amap->am_anon = (struct vm_anon **)(((char *)amap->am_bckptr) +
> - totalslots * sizeof(int));
> + slots * sizeof(int));
>  
>   return(amap);
>  
> @@ -243,7 +236,7 @@ amap_alloc(vaddr_t sz, int waitf)
>   amap = amap_alloc1(slots, waitf);
>   if (amap) {
>   memset(amap->am_anon, 0,
> - amap->am_maxslot * sizeof(struct vm_anon *));
> + amap->am_nslot * sizeof(struct vm_anon *));
>   amap_list_insert(amap);
>   }
>  
> @@ -263,10 +256,10 @@ amap_free(struct vm_amap *amap)
>   KASSERT(amap->am_ref == 0 && amap->am_nused == 0);
>   KASSERT((amap->am_flags & AMAP_SWAPOFF) == 0);
>  
> - if (amap->am_maxslot > UVM_AMAP_CHUNK)
> + if (amap->am_nslot > UVM_AMAP_CHUNK)
>   free(amap->am_slots, M_UVMAMAP, 0);
>   else
> - pool_put(_amap_slot_pools[amap->am_maxslot - 1],
> + pool_put(_amap_slot_pools[amap->am_nslot - 1],
>   amap->am_slots);
>  
>  #ifdef UVM_AMAP_PPREF
> @@ -409,8 +402,7 @@ amap_copy(struct vm_map *map, struct vm_
>   amap->am_slots[amap->am_nused] = lcv;
>   amap->am_nused++;
>   }
> - memset(>am_anon[lcv], 0,
> - (amap->am_maxslot - lcv) * sizeof(struct vm_anon *));
> + KASSERT(lcv == amap->am_nslot);
>  
>   /*
>* drop our reference to the old amap (srcamap).
> @@ -570,7 +562,7 @@ void
>  amap_pp_establish(struct vm_amap *amap)
>  {
>  
> - amap->am_ppref = mallocarray(amap->am_maxslot, sizeof(int),
> + amap->am_ppref = mallocarray(amap->am_nslot, sizeof(int),
>   M_UVMAMAP, M_NOWAIT|M_ZERO);
>  
>   /* if we fail then we just won't use ppref for this amap */
> Index: sys/uvm/uvm_amap.h
> ===
> RCS file: /cvs/src/sys/uvm/uvm_amap.h,v
> retrieving revision 1.23
> diff -u -p -r1.23 uvm_amap.h
> --- sys/uvm/uvm_amap.h4 Apr 2016 16:34:16 -   1.23
> +++ sys/uvm/uvm_amap.h16 Apr 2016 14:29:55 -
> @@ -124,8 +124,7 @@ boolean_t amap_swap_off(int, int);
>  struct vm_amap {
>   int am_ref; /* reference count */
>   int am_flags;   /* flags */
> - int am_maxslot; /* max # of slots allocated */
> - int am_nslot;   /* # of slots currently in map ( <= maxslot) */
> + int am_nslot;   /* # of slots currently in map */
>   int am_nused;   /* # of slots currently in use */
>   int *am_slots;  /* contig array of active slots */
>   int *am_bckptr; /* back pointer array to am_slots */
> Index: usr.sbin/procmap/procmap.c
> ===
> RCS file: 

Re: smu(4) fan speed

2016-04-16 Thread Mark Kettenis
> Date: Fri, 15 Apr 2016 20:41:53 +0200
> From: Marcus Glocker 
> 
> Yesterday I've installed macppc -current on a G5.
> Since OF_getprop() for the 'unmanage-value' parameter fails on it,
> smu(4) sets the fan speed to 'max-value' instead, which is 3200RPM
> in my case.  This makes the G5 sound louder than my vacuum cleaner.
> 
> First I thought 'unmanage-value' is a typo and it should be
> 'unmanaged-value' like in the FreeBSD driver, but unfortunately it
> still did fail.  I saw that the FreeBSD driver doesn't set the fan
> speed at all initially in their driver.  When I do the same on the
> G5, the fan speed goes to a decent of ~1000RPM:
> 
>   hw.sensors.smu0.fan0=999 RPM (Rear Fan 0)
>   hw.sensors.smu0.fan1=999 RPM (Rear fan 1)
>   hw.sensors.smu0.fan2=999 RPM (Front Fan)
> 
> I don't know what the right way is to fix this, but skipping to set
> the fan speed when the 'unmanage-value' isn't available seems to work
> fine in this case.

On what hardware are you running this?
Can you send us the output of eeprom -p for this machine?

> Index: sys/arch/macppc/dev/smu.c
> ===
> RCS file: /cvs/src/sys/arch/macppc/dev/smu.c,v
> retrieving revision 1.27
> diff -u -p -u -p -r1.27 smu.c
> --- sys/arch/macppc/dev/smu.c 4 Jun 2015 18:01:44 -   1.27
> +++ sys/arch/macppc/dev/smu.c 15 Apr 2016 18:17:12 -
> @@ -281,15 +281,17 @@ smu_attach(struct device *parent, struct
>   val = 0x;
>   fan->max_rpm = val;
>   if (OF_getprop(node, "unmanage-value", , sizeof val) <= 0)
> - val = fan->max_rpm;
> + val = 0;
>   fan->unmanaged_rpm = val;
>  
>   if (OF_getprop(node, "location", loc, sizeof loc) <= 0)
>   strlcpy(loc, "Unknown", sizeof loc);
>   strlcpy(fan->sensor.desc, loc, sizeof sensor->sensor.desc);
>  
> - /* Start running fans at their "unmanaged" speed. */
> - smu_fan_set_rpm(sc, fan, fan->unmanaged_rpm);
> + if (fan->unmanaged_rpm) {
> + /* Start running fans at their "unmanaged" speed. */
> + smu_fan_set_rpm(sc, fan, fan->unmanaged_rpm);
> + }
>  
>  #ifndef SMALL_KERNEL
>   sensor_attach(>sc_sensordev, >sensor);
> 
> 



ipsec/ipv6 refactor

2016-04-16 Thread Markus Friedl
Hi, this matches the IPsec/IPv4 change I committed back in December, but
since I don't have extensive IPv6 setups it's still not committed. Please test,
give feedback and it will finally go into the next release.
Thanks, -m



ipv6ipsec-refactor.diff
Description: Binary data


Re: ix(4): enable checksum offload

2016-04-16 Thread Hrvoje Popovski
On 9.9.2013. 22:07, Mike Belopuhov wrote:
> On 9 September 2013 21:48, Brad Smith  wrote:
>> Here is a diff to enable the checksum offload support for ix(4).
>>
>> Looking for any testing.
>>
> 
> last time i checked this broke ospf traffic.  please make sure at least
> ip/tcp, ip/udp, ip/icmp, ip/ip, ip/gre, ip/esp, ip/ah and ip/ospf work fine
> with this.
> 

Hi all,

is this still interesting topic? if it is, i have testbed to test csum
for em i350 (i350v2 is on the way) and ix 82599 or x540. and week ago i
ordered
http://www.supermicro.com/products/system/1U/5018/SYS-5018D-FN8T.cfm
with x552 or x557 not sure, i350-am4 and i210 ... lots of em's and ix's :)



Re: request for testing: rbootd timeout fix

2016-04-16 Thread Todd C. Miller
On Fri, 15 Apr 2016 23:07:47 -0700, Philip Guenther wrote:

> The current code is simply wrong: sizeof(struct timeval) >
> sizeof(struct bpf_timeval).  I think we should make this change (ok
> guenther@) and then work to update struct bpf_hdr or a replacement
> thereof to not be limited to 32bit time_t values.  Maybe it should be
> using a timespec instead too?  Have any other free OSes added timespec
> (or bintime) APIs?
> 
> (BPF has been around since 1990; the time from then to now is less
> than the time from now to 2038 when 32bit time_t fails...)

I agree that the change should be committed but since the values
in struct bpf_timeval are unsigned it doesn't have a year 2038
issue.

 - todd



synaptics: two-finger scrolling and coasting

2016-04-16 Thread Ulf Brosziewski
The changes I have introduced in wsconscomm.c recently can make the
transition from two-finger scrolling to coasting somewhat difficult.
Provided that you have scrolled quickly enough, coasting will start
if you finish the scroll gesture by lifting both fingers simultaneously,
but a short delay will prevent coasting. When the contact count drops
from 2 to 1 a RESET event will occur, and the handler clears the scroll
flag.

The diff below is a fix for this problem. The new version won't interrupt
or stop scrolling, rather it ensures that the current coordinate deltas
won't affect its speed or direction. I have tested it with my Elantech-v4
touchpad.

OK?


Index: src/wsconscomm.c
===
RCS file: /cvs/xenocara/driver/xf86-input-synaptics/src/wsconscomm.c,v
retrieving revision 1.14
diff -u -p -r1.14 wsconscomm.c
--- src/wsconscomm.c30 Mar 2016 23:33:34 -  1.14
+++ src/wsconscomm.c16 Apr 2016 15:15:46 -
@@ -150,6 +150,21 @@ WSConsQueryHardware(InputInfoPtr pInfo)
 return WSConsIsTouchpad(pInfo, NULL);
 }
 
+static void
+WSConsAdjustScrollCoords(SynapticsPrivate *priv, struct SynapticsHwState *hw)
+{
+int dx, dy, i;
+
+dx = hw->x - priv->scroll.last_x;
+dy = hw->y - priv->scroll.last_y;
+priv->scroll.last_x = hw->x;
+priv->scroll.last_y = hw->y;
+for (i = 0; i < SYNAPTICS_MOVE_HISTORY; i++) {
+priv->move_hist[i].x += dx;
+priv->move_hist[i].y += dy;
+}
+}
+
 static Bool
 WSConsReadHwState(InputInfoPtr pInfo,
 struct CommData *comm, struct SynapticsHwState *hwRet)
@@ -158,7 +173,7 @@ WSConsReadHwState(InputInfoPtr pInfo,
 struct wsconscomm_proto_data *proto_data = priv->proto_data;
 struct SynapticsHwState *hw = comm->hwState;
 struct wscons_event *event;
-Bool v;
+Bool v, reset = FALSE;
 
 while ((event = WSConsGetEvent(pInfo)) != NULL) {
 switch (event->type) {
@@ -229,15 +244,18 @@ WSConsReadHwState(InputInfoPtr pInfo,
 hw->fingerWidth = event->value;
 break;
 case WSCONS_EVENT_TOUCH_RESET:
-/*
- * The contact count or the active MT-slot has changed.
- * Suppress pointer motion and two-finger scrolling.
- */
-priv->count_packet_finger = 0;
-priv->vert_scroll_twofinger_on = FALSE;
-priv->horiz_scroll_twofinger_on = FALSE;
+/* The contact count or the active MT slot has changed. */
+reset = TRUE;
 break;
 case WSCONS_EVENT_SYNC:
+if (reset) {
+/* Ensure that pointer motion stops. */
+priv->count_packet_finger = 0;
+if (priv->vert_scroll_twofinger_on
+|| priv->horiz_scroll_twofinger_on) {
+WSConsAdjustScrollCoords(priv, hw);
+}
+}
 hw->millis = 1000 * event->time.tv_sec +
 event->time.tv_nsec / 100;
 SynapticsCopyHwState(hwRet, hw);



uvm: remove am_maxslot from amap

2016-04-16 Thread Stefan Kempf
am_maxslot represents the total number of slots an amap can be extended
to. Since we do not extend amaps, this field as well as rounding the
number of slots to the next malloc bucket is not useful.

This also removes the corresponding output from procmap(1).

ok?

Index: sys/uvm/uvm_amap.c
===
RCS file: /cvs/src/sys/uvm/uvm_amap.c,v
retrieving revision 1.65
diff -u -p -r1.65 uvm_amap.c
--- sys/uvm/uvm_amap.c  12 Apr 2016 16:47:33 -  1.65
+++ sys/uvm/uvm_amap.c  16 Apr 2016 14:29:55 -
@@ -180,44 +180,37 @@ static inline struct vm_amap *
 amap_alloc1(int slots, int waitf)
 {
struct vm_amap *amap;
-   int totalslots;
 
amap = pool_get(_amap_pool, (waitf == M_WAITOK) ? PR_WAITOK
: PR_NOWAIT);
if (amap == NULL)
return(NULL);
 
-   totalslots = slots;
-   KASSERT(totalslots > 0);
-
-   if (totalslots > UVM_AMAP_CHUNK)
-   totalslots = malloc_roundup(totalslots * MALLOC_SLOT_UNIT) /
-   MALLOC_SLOT_UNIT;
+   KASSERT(slots > 0);
 
amap->am_ref = 1;
amap->am_flags = 0;
 #ifdef UVM_AMAP_PPREF
amap->am_ppref = NULL;
 #endif
-   amap->am_maxslot = totalslots;
amap->am_nslot = slots;
amap->am_nused = 0;
 
-   if (totalslots > UVM_AMAP_CHUNK)
-   amap->am_slots = malloc(totalslots * MALLOC_SLOT_UNIT,
+   if (slots > UVM_AMAP_CHUNK)
+   amap->am_slots = malloc(slots * MALLOC_SLOT_UNIT,
M_UVMAMAP, waitf);
else
amap->am_slots = pool_get(
-   _amap_slot_pools[totalslots - 1],
+   _amap_slot_pools[slots - 1],
(waitf == M_WAITOK) ? PR_WAITOK : PR_NOWAIT);
 
if (amap->am_slots == NULL)
goto fail1;
 
-   amap->am_bckptr = (int *)(((char *)amap->am_slots) + totalslots *
+   amap->am_bckptr = (int *)(((char *)amap->am_slots) + slots *
sizeof(int));
amap->am_anon = (struct vm_anon **)(((char *)amap->am_bckptr) +
-   totalslots * sizeof(int));
+   slots * sizeof(int));
 
return(amap);
 
@@ -243,7 +236,7 @@ amap_alloc(vaddr_t sz, int waitf)
amap = amap_alloc1(slots, waitf);
if (amap) {
memset(amap->am_anon, 0,
-   amap->am_maxslot * sizeof(struct vm_anon *));
+   amap->am_nslot * sizeof(struct vm_anon *));
amap_list_insert(amap);
}
 
@@ -263,10 +256,10 @@ amap_free(struct vm_amap *amap)
KASSERT(amap->am_ref == 0 && amap->am_nused == 0);
KASSERT((amap->am_flags & AMAP_SWAPOFF) == 0);
 
-   if (amap->am_maxslot > UVM_AMAP_CHUNK)
+   if (amap->am_nslot > UVM_AMAP_CHUNK)
free(amap->am_slots, M_UVMAMAP, 0);
else
-   pool_put(_amap_slot_pools[amap->am_maxslot - 1],
+   pool_put(_amap_slot_pools[amap->am_nslot - 1],
amap->am_slots);
 
 #ifdef UVM_AMAP_PPREF
@@ -409,8 +402,7 @@ amap_copy(struct vm_map *map, struct vm_
amap->am_slots[amap->am_nused] = lcv;
amap->am_nused++;
}
-   memset(>am_anon[lcv], 0,
-   (amap->am_maxslot - lcv) * sizeof(struct vm_anon *));
+   KASSERT(lcv == amap->am_nslot);
 
/*
 * drop our reference to the old amap (srcamap).
@@ -570,7 +562,7 @@ void
 amap_pp_establish(struct vm_amap *amap)
 {
 
-   amap->am_ppref = mallocarray(amap->am_maxslot, sizeof(int),
+   amap->am_ppref = mallocarray(amap->am_nslot, sizeof(int),
M_UVMAMAP, M_NOWAIT|M_ZERO);
 
/* if we fail then we just won't use ppref for this amap */
Index: sys/uvm/uvm_amap.h
===
RCS file: /cvs/src/sys/uvm/uvm_amap.h,v
retrieving revision 1.23
diff -u -p -r1.23 uvm_amap.h
--- sys/uvm/uvm_amap.h  4 Apr 2016 16:34:16 -   1.23
+++ sys/uvm/uvm_amap.h  16 Apr 2016 14:29:55 -
@@ -124,8 +124,7 @@ boolean_t   amap_swap_off(int, int);
 struct vm_amap {
int am_ref; /* reference count */
int am_flags;   /* flags */
-   int am_maxslot; /* max # of slots allocated */
-   int am_nslot;   /* # of slots currently in map ( <= maxslot) */
+   int am_nslot;   /* # of slots currently in map */
int am_nused;   /* # of slots currently in use */
int *am_slots;  /* contig array of active slots */
int *am_bckptr; /* back pointer array to am_slots */
Index: usr.sbin/procmap/procmap.c
===
RCS file: /cvs/src/usr.sbin/procmap/procmap.c,v
retrieving revision 1.59
diff -u -p -r1.59 procmap.c
--- usr.sbin/procmap/procmap.c  19 Jan 2015 19:25:28 -  1.59
+++ usr.sbin/procmap/procmap.c  16 Apr 2016 14:29:56 -
@@ -97,7 +97,6 @@ rlim_t 

Re: request for testing: rbootd timeout fix

2016-04-16 Thread Stuart Henderson
On 2016/04/15 23:07, Philip Guenther wrote:
> On Thu, Apr 14, 2016 at 3:15 PM, Martin Natano  wrote:
> > In rbootd a struct bpf_timeval (with 32bit tv_sec) is copied to a struct
> > timeval (with 64 tv_sec) via bcopy(). This most likely causes
> > connections to not time out correctly in rbootd. I don't have an HP
> > machine to test this with. Who owns such a machine and is willing to
> > test this?
> 
> The current code is simply wrong: sizeof(struct timeval) >
> sizeof(struct bpf_timeval).  I think we should make this change (ok
> guenther@) and then work to update struct bpf_hdr or a replacement
> thereof to not be limited to 32bit time_t values.  Maybe it should be
> using a timespec instead too?  Have any other free OSes added timespec
> (or bintime) APIs?
> 
> (BPF has been around since 1990; the time from then to now is less
> than the time from now to 2038 when 32bit time_t fails...)

I'd like this for ports too; it is not sanely possible to patch some
programs to support bpf_timeval (in some programs it's common to
mix timevals from bpf with timevals on the system and want to
calculate time differences etc - patches to fix these cases are
often very intrusive).

I have a WIP diff to switch bpf to timevals, and convert in libpcap when
writing dump files - these need to be 32-bit unsigned in the current
format; there is a newer pcapng file format (draft-tuexen-opsawg-pcapng)
that has 64-bit timestamps but also has many other changes, libpcap
upstream only had partial support last time I checked.

It works fine on amd64 but last time I tried it on spar64 I was seeing
unaligned access with tcpdump, and dhclient didn't work, I haven't
managed to track that down yet (I have some ideas but my x1 died, my
other sparc64 is noisy and has no LOM so progress is slow!).

Index: lib/libpcap/pcap-int.h
===
RCS file: /cvs/src/lib/libpcap/pcap-int.h,v
retrieving revision 1.13
diff -u -p -r1.13 pcap-int.h
--- lib/libpcap/pcap-int.h  11 Apr 2014 04:08:58 -  1.13
+++ lib/libpcap/pcap-int.h  16 Apr 2016 10:05:57 -
@@ -120,11 +120,20 @@ struct pcap {
 };
 
 /*
+ * MI timeval structure as used in the dumpfile.
+ */
+
+struct pcap_timeval {
+   u_int32_t tv_sec;
+   u_int32_t tv_usec;
+};
+
+/*
  * How a `pcap_pkthdr' is actually stored in the dumpfile.
  */
 
 struct pcap_sf_pkthdr {
-struct bpf_timeval ts; /* time stamp */
+struct pcap_timeval ts;/* time stamp */
 bpf_u_int32 caplen;/* length of portion present */
 bpf_u_int32 len;   /* length this packet (off wire) */
 };
Index: lib/libpcap/pcap.h
===
RCS file: /cvs/src/lib/libpcap/pcap.h,v
retrieving revision 1.18
diff -u -p -r1.18 pcap.h
--- lib/libpcap/pcap.h  6 Apr 2016 08:02:56 -   1.18
+++ lib/libpcap/pcap.h  16 Apr 2016 10:05:57 -
@@ -90,7 +90,7 @@ typedef enum {
  * packet interfaces.
  */
 struct pcap_pkthdr {
-   struct bpf_timeval ts;  /* time stamp */
+   struct timeval ts;  /* time stamp */
bpf_u_int32 caplen; /* length of portion present */
bpf_u_int32 len;/* length this packet (off wire) */
 };
Index: lib/libpcap/savefile.c
===
RCS file: /cvs/src/lib/libpcap/savefile.c,v
retrieving revision 1.16
diff -u -p -r1.16 savefile.c
--- lib/libpcap/savefile.c  22 Dec 2015 19:51:04 -  1.16
+++ lib/libpcap/savefile.c  16 Apr 2016 10:05:57 -
@@ -211,20 +211,26 @@ pcap_fopen_offline(FILE *fp, char *errbu
 static int
 sf_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char *buf, int buflen)
 {
+   struct pcap_sf_pkthdr sf_hdr;
FILE *fp = p->sf.rfile;
 
/* read the stamp */
-   if (fread((char *)hdr, sizeof(struct pcap_pkthdr), 1, fp) != 1) {
+   if (fread(_hdr, sizeof(struct pcap_sf_pkthdr), 1, fp) != 1) {
/* probably an EOF, though could be a truncated packet */
return (1);
}
 
if (p->sf.swapped) {
/* these were written in opposite byte order */
-   hdr->caplen = SWAPLONG(hdr->caplen);
-   hdr->len = SWAPLONG(hdr->len);
-   hdr->ts.tv_sec = SWAPLONG(hdr->ts.tv_sec);
-   hdr->ts.tv_usec = SWAPLONG(hdr->ts.tv_usec);
+   hdr->caplen = SWAPLONG(sf_hdr.caplen);
+   hdr->len = SWAPLONG(sf_hdr.len);
+   hdr->ts.tv_sec = SWAPLONG(sf_hdr.ts.tv_sec);
+   hdr->ts.tv_usec = SWAPLONG(sf_hdr.ts.tv_usec);
+   } else {
+   hdr->caplen = sf_hdr.caplen;
+   hdr->len = sf_hdr.len;
+   hdr->ts.tv_sec = sf_hdr.ts.tv_sec;
+   hdr->ts.tv_usec = sf_hdr.ts.tv_usec;
}
/*
 * We interchanged the caplen and len fields at version 2.3,
@@ -332,10 +338,16 @@ void
 pcap_dump(u_char 

Re: request for testing: rbootd timeout fix

2016-04-16 Thread Philip Guenther
On Thu, Apr 14, 2016 at 3:15 PM, Martin Natano  wrote:
> In rbootd a struct bpf_timeval (with 32bit tv_sec) is copied to a struct
> timeval (with 64 tv_sec) via bcopy(). This most likely causes
> connections to not time out correctly in rbootd. I don't have an HP
> machine to test this with. Who owns such a machine and is willing to
> test this?

The current code is simply wrong: sizeof(struct timeval) >
sizeof(struct bpf_timeval).  I think we should make this change (ok
guenther@) and then work to update struct bpf_hdr or a replacement
thereof to not be limited to 32bit time_t values.  Maybe it should be
using a timespec instead too?  Have any other free OSes added timespec
(or bintime) APIs?

(BPF has been around since 1990; the time from then to now is less
than the time from now to 2038 when 32bit time_t fails...)


Philip Guenther