svn commit: r316380 - in head/sys: conf powerpc/conf powerpc/mpc85xx

2017-04-01 Thread Justin Hibbits
Author: jhibbits
Date: Sun Apr  2 01:21:35 2017
New Revision: 316380
URL: https://svnweb.freebsd.org/changeset/base/316380

Log:
  Add Freescale eSPI driver found on QorIQ SoCs

Added:
  head/sys/powerpc/mpc85xx/fsl_espi.c   (contents, props changed)
Modified:
  head/sys/conf/files.powerpc
  head/sys/powerpc/conf/MPC85XX
  head/sys/powerpc/conf/MPC85XXSPE

Modified: head/sys/conf/files.powerpc
==
--- head/sys/conf/files.powerpc Sat Apr  1 22:35:03 2017(r316379)
+++ head/sys/conf/files.powerpc Sun Apr  2 01:21:35 2017(r316380)
@@ -139,6 +139,7 @@ powerpc/mpc85xx/atpic.c optionalmpc85x
 powerpc/mpc85xx/ds1553_bus_fdt.c   optionalds1553 fdt
 powerpc/mpc85xx/ds1553_core.c  optionalds1553
 powerpc/mpc85xx/fsl_diu.c  optionalmpc85xx diu
+powerpc/mpc85xx/fsl_espi.c optionalmpc85xx spibus
 powerpc/mpc85xx/i2c.c  optionaliicbus fdt
 powerpc/mpc85xx/isa.c  optionalmpc85xx isa
 powerpc/mpc85xx/lbc.c  optionalmpc85xx

Modified: head/sys/powerpc/conf/MPC85XX
==
--- head/sys/powerpc/conf/MPC85XX   Sat Apr  1 22:35:03 2017
(r316379)
+++ head/sys/powerpc/conf/MPC85XX   Sun Apr  2 01:21:35 2017
(r316380)
@@ -93,6 +93,8 @@ devicerandom
 device scbus
 device scc
 device sec
+device spibus
+device spigen
 device tsec
 device dpaa
 device tun

Modified: head/sys/powerpc/conf/MPC85XXSPE
==
--- head/sys/powerpc/conf/MPC85XXSPESat Apr  1 22:35:03 2017
(r316379)
+++ head/sys/powerpc/conf/MPC85XXSPESun Apr  2 01:21:35 2017
(r316380)
@@ -94,6 +94,8 @@ devicescbus
 device scc
 device sdhci
 device sec
+device spibus
+device spigen
 device tsec
 device dpaa
 device tun

Added: head/sys/powerpc/mpc85xx/fsl_espi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/powerpc/mpc85xx/fsl_espi.c Sun Apr  2 01:21:35 2017
(r316380)
@@ -0,0 +1,434 @@
+/*-
+ * Copyright (c) 2017 Justin Hibbits 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include "spibus_if.h"
+
+/* TODO:
+ *
+ * Optimize FIFO reads and writes to do word-at-a-time instead of 
byte-at-a-time
+ */
+#defineESPI_SPMODE 0x0
+#define  ESPI_SPMODE_EN  0x8000
+#define  ESPI_SPMODE_LOOP0x4000
+#define  ESPI_SPMODE_HO_ADJ_M0x0007
+#define  ESPI_SPMODE_TXTHR_M 0x3f00
+#define  ESPI_SPMODE_TXTHR_S 8
+#define  ESPI_SPMODE_RXTHR_M 0x001f
+#define  ESPI_SPMODE_RXTHR_S 0
+#defineESPI_SPIE   0x4
+#define  ESPI_SPIE_RXCNT_M   0x3f00
+#define  ESPI_SPIE_RXCNT_S   24
+#define  ESPI_SPIE_TXCNT_M   0x003f
+#define  ESPI_SPIE_TXCNT_S   16
+#define  ESPI_SPIE_TXE   0x8000
+#define  ESPI_SPIE_DON   0x4000
+#define  ESPI_SPIE_RXT   0x2000
+#define  ESPI_SPIE_RXF   0x1000

svn commit: r316379 - head/sys/dev/sdhci

2017-04-01 Thread Justin Hibbits
Author: jhibbits
Date: Sat Apr  1 22:35:03 2017
New Revision: 316379
URL: https://svnweb.freebsd.org/changeset/base/316379

Log:
  Use the newly added mpc85xx_get_system_clock()
  
  Simplify the platform clock acquisition by using the new helper function.

Modified:
  head/sys/dev/sdhci/fsl_sdhci.c

Modified: head/sys/dev/sdhci/fsl_sdhci.c
==
--- head/sys/dev/sdhci/fsl_sdhci.c  Sat Apr  1 22:29:11 2017
(r316378)
+++ head/sys/dev/sdhci/fsl_sdhci.c  Sat Apr  1 22:35:03 2017
(r316379)
@@ -58,6 +58,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
+#ifdef __powerpc__
+#include 
+#endif
+
 #include 
 
 #include 
@@ -767,7 +771,6 @@ fsl_sdhci_get_card_present(device_t dev,
 static uint32_t
 fsl_sdhci_get_platform_clock(device_t dev)
 {
-   device_t parent;
phandle_t node;
uint32_t clock;
 
@@ -777,23 +780,14 @@ fsl_sdhci_get_platform_clock(device_t de
if((OF_getprop(node, "clock-frequency", (void *),
sizeof(clock)) <= 0) || (clock == 0)) {
 
-   /*
-* Trying to get clock from parent device (soc) if correct
-* clock cannot be acquired from sdhci node.
-*/
-   parent = device_get_parent(dev);
-   node = ofw_bus_get_node(parent);
+   clock = mpc85xx_get_system_clock();
 
-   /* Get soc properties */
-   if ((OF_getprop(node, "bus-frequency", (void *),
-   sizeof(clock)) <= 0) || (clock == 0)) {
+   if (clock == 0) {
device_printf(dev,"Cannot acquire correct sdhci "
"frequency from DTS.\n");
 
return (0);
}
-   /* eSDHC clock is 1/2 platform clock. */
-   clock /= 2;
}
 
if (bootverbose)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316378 - head/sys/powerpc/mpc85xx

2017-04-01 Thread Justin Hibbits
Author: jhibbits
Date: Sat Apr  1 22:29:11 2017
New Revision: 316378
URL: https://svnweb.freebsd.org/changeset/base/316378

Log:
  Add a helper function to get system reference clock
  
  Many devices are clocked from the SoC's platform clock / 2.  Some device nodes
  include their own clock-frequency property, while others are dependent on the
  SoC's bus-frequency property instead.  To simplify, add a helper function to 
get
  this clock.

Modified:
  head/sys/powerpc/mpc85xx/mpc85xx.c
  head/sys/powerpc/mpc85xx/mpc85xx.h

Modified: head/sys/powerpc/mpc85xx/mpc85xx.c
==
--- head/sys/powerpc/mpc85xx/mpc85xx.c  Sat Apr  1 22:03:00 2017
(r316377)
+++ head/sys/powerpc/mpc85xx/mpc85xx.c  Sat Apr  1 22:29:11 2017
(r316378)
@@ -436,3 +436,18 @@ mpc85xx_fix_errata(vm_offset_t va_ccsr)
 err:
return;
 }
+
+uint32_t
+mpc85xx_get_system_clock(void)
+{
+   phandle_t soc;
+   uint32_t freq;
+
+   soc = OF_finddevice("/soc");
+   freq = 0;
+
+   /* freq isn't modified on error. */
+   OF_getencprop(soc, "bus-frequency", (void *), sizeof(freq));
+
+   return (freq / 2);
+}

Modified: head/sys/powerpc/mpc85xx/mpc85xx.h
==
--- head/sys/powerpc/mpc85xx/mpc85xx.h  Sat Apr  1 22:03:00 2017
(r316377)
+++ head/sys/powerpc/mpc85xx/mpc85xx.h  Sat Apr  1 22:29:11 2017
(r316378)
@@ -171,5 +171,6 @@ void mpc85xx_enable_l3_cache(void);
 void mpc85xx_fix_errata(vm_offset_t);
 void dataloss_erratum_access(vm_offset_t, uint32_t);
 int mpc85xx_is_qoriq(void);
+uint32_t mpc85xx_get_system_clock(void);
 
 #endif /* _MPC85XX_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r316376 - head/sys/boot/fdt/dts/arm

2017-04-01 Thread Emmanuel Vadot
On Sat, 1 Apr 2017 15:02:11 -0700
Oleksandr Tymoshenko  wrote:

> Emmanuel Vadot (m...@freebsd.org) wrote:
> > Author: manu
> > Date: Sat Apr  1 21:55:09 2017
> > New Revision: 316376
> > URL: https://svnweb.freebsd.org/changeset/base/316376
> > 
> > Log:
> >   Reduce the diff on beaglebone-black DTS.
> >   
> >   The HDMI TX (tda19988) is already enabled in upstream DTS so use it 
> > directly
> >   instead.
> > 
> > Modified:
> >   head/sys/boot/fdt/dts/arm/beaglebone-black.dts
> 
> BBB switched to using upstream DTS. I don't think
> sys/boot/fdt/dts/arm/beaglebone* files are used anywhere.
> 
> -- 
> gonzo

 True, this was just in case people still uses this dts but I guess
that it will be better to remove it just to be sure.

-- 
Emmanuel Vadot  
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316377 - head/sys/boot/uboot/common

2017-04-01 Thread Ian Lepore
Author: ian
Date: Sat Apr  1 22:03:00 2017
New Revision: 316377
URL: https://svnweb.freebsd.org/changeset/base/316377

Log:
  Correct a comment... the stack used by ubldr is the same stack u-boot was
  running on when it jumped to the ubldr entry point.  None of the arches
  that use this code set up a different stack in their start.S routines.

Modified:
  head/sys/boot/uboot/common/main.c

Modified: head/sys/boot/uboot/common/main.c
==
--- head/sys/boot/uboot/common/main.c   Sat Apr  1 21:55:09 2017
(r316376)
+++ head/sys/boot/uboot/common/main.c   Sat Apr  1 22:03:00 2017
(r316377)
@@ -416,7 +416,9 @@ main(int argc, char **argv)
 
/*
 * Initialise the heap as early as possible.  Once this is done,
-* alloc() is usable. The stack is buried inside us, so this is safe.
+* alloc() is usable.  We are using the stack u-boot set up near the top
+* of physical ram; hopefully there is sufficient space between the end
+* of our bss and the bottom of the u-boot stack to avoid overlap.
 */
uboot_heap_start = round_page((uintptr_t)end);
uboot_heap_end   = uboot_heap_start + 512 * 1024;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r316376 - head/sys/boot/fdt/dts/arm

2017-04-01 Thread Oleksandr Tymoshenko
Emmanuel Vadot (m...@freebsd.org) wrote:
> Author: manu
> Date: Sat Apr  1 21:55:09 2017
> New Revision: 316376
> URL: https://svnweb.freebsd.org/changeset/base/316376
> 
> Log:
>   Reduce the diff on beaglebone-black DTS.
>   
>   The HDMI TX (tda19988) is already enabled in upstream DTS so use it directly
>   instead.
> 
> Modified:
>   head/sys/boot/fdt/dts/arm/beaglebone-black.dts

BBB switched to using upstream DTS. I don't think
sys/boot/fdt/dts/arm/beaglebone* files are used anywhere.

-- 
gonzo
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316376 - head/sys/boot/fdt/dts/arm

2017-04-01 Thread Emmanuel Vadot
Author: manu
Date: Sat Apr  1 21:55:09 2017
New Revision: 316376
URL: https://svnweb.freebsd.org/changeset/base/316376

Log:
  Reduce the diff on beaglebone-black DTS.
  
  The HDMI TX (tda19988) is already enabled in upstream DTS so use it directly
  instead.

Modified:
  head/sys/boot/fdt/dts/arm/beaglebone-black.dts

Modified: head/sys/boot/fdt/dts/arm/beaglebone-black.dts
==
--- head/sys/boot/fdt/dts/arm/beaglebone-black.dts  Sat Apr  1 21:53:58 
2017(r316375)
+++ head/sys/boot/fdt/dts/arm/beaglebone-black.dts  Sat Apr  1 21:55:09 
2017(r316376)
@@ -49,12 +49,6 @@
};
 };
 
- {
-   tda998x: tda19988 {
-   status = "okay";
-   };
-};
-
  {
pinctrl-names = "default";
pinctrl-0 = <_pins>;
@@ -77,11 +71,5 @@
 };
 
  {
-   hdmi = <>;
-};
-
-/ {
-   hdmi {
-   status = "disabled";
-   };
+   hdmi = <>;
 };
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316374 - head/sys/boot/arm/uboot

2017-04-01 Thread Ian Lepore
Author: ian
Date: Sat Apr  1 21:51:34 2017
New Revision: 316374
URL: https://svnweb.freebsd.org/changeset/base/316374

Log:
  Preserve the registers containing argc, argv, and return address values
  passed in from u-boot across the call to self_reloc and any other early-init
  code, and restore them before calling main().
  
  The self_reloc() routine uses r0 and r1 (and calling it uses lr), and
  depending on what values get left in them, main() would intermittantly lock
  up trying to interpret them as argc and argv values.  This problem affected
  the self-relocatable ubldr.bin but not ubldr (the elf version).

Modified:
  head/sys/boot/arm/uboot/start.S

Modified: head/sys/boot/arm/uboot/start.S
==
--- head/sys/boot/arm/uboot/start.S Sat Apr  1 21:06:22 2017
(r316373)
+++ head/sys/boot/arm/uboot/start.S Sat Apr  1 21:51:34 2017
(r316374)
@@ -45,6 +45,13 @@ _start:
orr ip, ip, #(CPU_CONTROL_AFLT_ENABLE)
mcr p15, 0, ip, c1, c0, 0
 #endif
+
+   /*
+* Save r0 and r1 (argc and argv passed from u-boot), and lr (trashed
+* by the call to self_reloc below) until we're ready to call main().
+*/
+   push{r0, r1, lr}
+
/* 
 * Do self-relocation when the weak external symbol _DYNAMIC is 
non-NULL.
 * When linked as a dynamic relocatable file, the linker automatically
@@ -71,9 +78,11 @@ _start:
str r9, [ip, #4]
 
/* 
+* First restore argc, argv, and the u-boot return address, then
 * Start loader.  This is basically a tail-recursion call; if main()
 * returns, it returns to u-boot (which reports the value returned r0).
 */
+   pop {r0, r1, lr}
b   main
 
/* 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316371 - head/sys/arm/versatile

2017-04-01 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Apr  1 20:38:12 2017
New Revision: 316371
URL: https://svnweb.freebsd.org/changeset/base/316371

Log:
  [versatilepb] Fix keyboard driver after switching to upstream DTS
  
  FreeBSD's DTS contained only one PL050 node and driver considered it to
  be PS/2 keyboard. In reality PL050 is a PS/2 port that pushes bytes to/from
  the periphers connected to it. New DTS contains two nodes and QEMU emulates
  keyboard connected to port #0 and mouse connected to port #1. Since there
  is no way to say what's connected to port by checking DTS we hardcode
  this knowledge in the driver: it assumes keyboard on port #0 and ignores
  port #1 altogether.
  
  Also QEMU defaults emulated keyboard to scan code set 2 while driver used
  to work with scan code set 1 so when initializing driver make sure keyboard
  is switched to scan code set 1

Modified:
  head/sys/arm/versatile/pl050.c

Modified: head/sys/arm/versatile/pl050.c
==
--- head/sys/arm/versatile/pl050.c  Sat Apr  1 20:10:08 2017
(r316370)
+++ head/sys/arm/versatile/pl050.c  Sat Apr  1 20:38:12 2017
(r316371)
@@ -106,7 +106,10 @@ __FBSDID("$FreeBSD$");
 #defineKMI_DRIVER_NAME  "kmi"
 #defineKMI_NFKEY(sizeof(fkey_tab)/sizeof(fkey_tab[0])) /* 
units */
 
+#defineSET_SCANCODE_SET0xf0
+
 struct kmi_softc {
+   device_t sc_dev;
keyboard_t sc_kbd;
keymap_t sc_keymap;
accentmap_t sc_accmap;
@@ -142,6 +145,8 @@ static int  kmi_ioctl(keyboard_t *, u_lon
 static int kmi_enable(keyboard_t *);
 static int kmi_disable(keyboard_t *);
 
+static int kmi_attached = 0;
+
 /* early keyboard probe, not supported */
 static int
 kmi_configure(int flags)
@@ -480,7 +485,6 @@ kmi_ioctl(keyboard_t *kbd, u_long cmd, c
}
 }
 
-
 /* clear the internal state of the keyboard */
 static void
 kmi_clear_state(keyboard_t *kbd)
@@ -610,6 +614,17 @@ pl050_kmi_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
 
+   /*
+* PL050 is plain PS2 port that pushes bytes to/from computer
+* VersatilePB has two such ports and QEMU simulates keyboard
+* connected to port #0 and mouse connected to port #1. This
+* information can't be obtained from device tree so we just
+* hardcode this knowledge here. We attach keyboard driver to
+* port #0 and ignore port #1
+*/
+   if (kmi_attached)
+   return (ENXIO);
+
if (ofw_bus_is_compatible(dev, "arm,pl050")) {
device_set_desc(dev, "PL050 Keyboard/Mouse Interface");
return (BUS_PROBE_DEFAULT);
@@ -625,7 +640,9 @@ pl050_kmi_attach(device_t dev)
keyboard_t *kbd;
int rid;
int i;
+   uint32_t ack;
 
+   sc->sc_dev = dev;
kbd = >sc_kbd;
rid = 0;
 
@@ -654,6 +671,16 @@ pl050_kmi_attach(device_t dev)
 
/* TODO: clock & divisor */
 
+   pl050_kmi_write_4(sc, KMICR, KMICR_EN);
+
+   pl050_kmi_write_4(sc, KMIDATA, SET_SCANCODE_SET);
+   /* read out ACK */
+   ack = pl050_kmi_read_4(sc, KMIDATA);
+   /* Set Scan Code set 1 (XT) */
+   pl050_kmi_write_4(sc, KMIDATA, 1);
+   /* read out ACK */
+   ack = pl050_kmi_read_4(sc, KMIDATA);
+
pl050_kmi_write_4(sc, KMICR, KMICR_EN | KMICR_RXINTREN);
 
kbd_init_struct(kbd, KMI_DRIVER_NAME, KB_OTHER, 
@@ -689,6 +716,7 @@ pl050_kmi_attach(device_t dev)
if (bootverbose) {
genkbd_diag(kbd, bootverbose);
}
+   kmi_attached = 1;
return (0);
 
 detach:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316370 - in head/sys/arm: arm conf versatile

2017-04-01 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Apr  1 20:10:08 2017
New Revision: 316370
URL: https://svnweb.freebsd.org/changeset/base/316370

Log:
  [versatilepb] Convert VERSATILEPB kernel to INTRNG and switch to upstream DTB
  
  Scope of this change is somewhat larger than just converting to INTRNG.
  The reason for this is that INTRNG support required switching from custom
  to upstream DTS because custom DTS didn't have interrup routing information.
  This switch caused rewrite of PCI and CLCD drivers and adding SCM module.
  List of changes in this commit:
  
  - Enable INTRNG and switch to versatile-pb.dts
  
  - Add SCM driver that controls various peripheral devices like LCD or
PCI controller. Previously registers required for power-up and
configuring peripherals were part of their respective nodes. Upstream
DTS has dedicated node for SCM
  
  - Convert PL190 driver to INTRNG
  
  - Convert Versatile SIC (secondary interrupt controller) to INTRNG
  
  - Refactor CLCD driver to use SCM API to power up and configuration
  
  - Refactor PCI driver to use SCM API to enable controller
  
  - Refactor PCI driver to use interrupt map provided in DTS for
interrupt routing. As a result it fixes broken IRQ routing and
it's no longer required to run QEMU with "-global 
versatile_pci.broken-irq-mapping=1"
command-line arguments

Added:
  head/sys/arm/versatile/versatile_scm.c   (contents, props changed)
  head/sys/arm/versatile/versatile_scm.h   (contents, props changed)
Modified:
  head/sys/arm/arm/pl190.c
  head/sys/arm/conf/VERSATILEPB
  head/sys/arm/versatile/files.versatile
  head/sys/arm/versatile/versatile_clcd.c
  head/sys/arm/versatile/versatile_pci.c
  head/sys/arm/versatile/versatile_sic.c

Modified: head/sys/arm/arm/pl190.c
==
--- head/sys/arm/arm/pl190.cSat Apr  1 19:27:06 2017(r316369)
+++ head/sys/arm/arm/pl190.cSat Apr  1 20:10:08 2017(r316370)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2012 Oleksandr Tymoshenko 
+ * Copyright (c) 2012-2017 Oleksandr Tymoshenko 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,6 @@
  * SUCH DAMAGE.
  */
 
-
 #include 
 __FBSDID("$FreeBSD$");
 
@@ -34,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include "pic_if.h"
+
 #ifdef  DEBUG
 #define dprintf(fmt, args...) printf(fmt, ##args)
 #else
@@ -62,17 +64,139 @@ __FBSDID("$FreeBSD$");
 
 #defineVIC_NIRQS   32
 
+struct pl190_intc_irqsrc {
+   struct intr_irqsrc  isrc;
+   u_int   irq;
+};
+
 struct pl190_intc_softc {
-   device_tsc_dev;
+   device_tdev;
+   struct mtx  mtx;
struct resource *   intc_res;
+   struct pl190_intc_irqsrcisrcs[VIC_NIRQS];
 };
 
-static struct pl190_intc_softc *pl190_intc_sc = NULL;
+#defineINTC_VIC_READ_4(sc, reg)\
+bus_read_4(sc->intc_res, (reg))
+#defineINTC_VIC_WRITE_4(sc, reg, val)  \
+bus_write_4(sc->intc_res, (reg), (val))
+
+#defineVIC_LOCK(_sc) mtx_lock_spin(&(_sc)->mtx)
+#defineVIC_UNLOCK(_sc) mtx_unlock_spin(&(_sc)->mtx)
+
+static inline void
+pl190_intc_irq_dispatch(struct pl190_intc_softc *sc, u_int irq,
+struct trapframe *tf)
+{
+   struct pl190_intc_irqsrc *src;
+
+   src = >isrcs[irq];
+   if (intr_isrc_dispatch(>isrc, tf) != 0)
+   device_printf(sc->dev, "Stray irq %u detected\n", irq);
+}
+
+static int
+pl190_intc_intr(void *arg)
+{
+   struct pl190_intc_softc *sc;
+   u_int cpu;
+   uint32_t num, pending;
+   struct trapframe *tf;
+
+   sc = arg;
+   cpu = PCPU_GET(cpuid);
+   tf = curthread->td_intr_frame;
+
+   VIC_LOCK(sc);
+   pending = INTC_VIC_READ_4(sc, VICIRQSTATUS);
+   VIC_UNLOCK(sc);
+   for (num = 0 ; num < VIC_NIRQS; num++) {
+   if (pending & (1 << num))
+   pl190_intc_irq_dispatch(sc, num, tf);
+   }
+
+   return (FILTER_HANDLED);
+}
+
+static void
+pl190_intc_disable_intr(device_t dev, struct intr_irqsrc *isrc)
+{
+   struct pl190_intc_softc *sc;
+   struct pl190_intc_irqsrc *src;
+
+   sc = device_get_softc(dev);
+   src = (struct pl190_intc_irqsrc *)isrc;
+
+   VIC_LOCK(sc);
+   INTC_VIC_WRITE_4(sc, VICINTENCLEAR, (1 << src->irq));
+   VIC_UNLOCK(sc);
+}
+
+static void
+pl190_intc_enable_intr(device_t dev, struct intr_irqsrc *isrc)
+{
+   struct pl190_intc_softc *sc;
+   struct pl190_intc_irqsrc *src;
 
-#defineintc_vic_read_4(reg)\
-bus_read_4(pl190_intc_sc->intc_res, (reg))
-#defineintc_vic_write_4(reg, val)  \
-

svn commit: r316368 - head

2017-04-01 Thread Jung-uk Kim
Author: jkim
Date: Sat Apr  1 19:08:22 2017
New Revision: 316368
URL: https://svnweb.freebsd.org/changeset/base/316368

Log:
  Fix typos to stop removing new files.

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Sat Apr  1 18:52:48 2017(r316367)
+++ head/ObsoleteFiles.inc  Sat Apr  1 19:08:22 2017(r316368)
@@ -45,16 +45,16 @@ OLD_FILES+=usr/tests/usr.bin/ident/ident
 OLD_FILES+=usr/tests/usr.bin/mkimg/mkimg
 OLD_FILES+=usr/tests/usr.bin/sdiff/sdiff
 OLD_FILES+=usr/tests/usr.bin/soelim/soelim
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_config_test
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_etcdir_test
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_lock_test
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupadd_test
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupdel_test
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupmod_test
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_useradd_test
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_userdel_test
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_usermod_test
-OLD_FILES+=usr/tests/usr.sbin/pw/pw_usernext_test
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_config
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_etcdir
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupadd
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupdel
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupmod
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_lock
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_useradd
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_userdel
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_usermod
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_usernext
 # 20170322: garbage collect old references to igb(4)
 OLD_FILES+=usr/share/man/man4/if_igb.4.gz
 OLD_FILES+=usr/share/man/man4/igb.4.gz
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316358 - head/share/man/man5

2017-04-01 Thread Alan Somers
Author: asomers
Date: Sat Apr  1 15:04:37 2017
New Revision: 316358
URL: https://svnweb.freebsd.org/changeset/base/316358

Log:
  Fix man page typo from r316342
  
  Reported by:  rgrimes
  MFC after:20 days
  X-MFC-With:   316342

Modified:
  head/share/man/man5/periodic.conf.5

Modified: head/share/man/man5/periodic.conf.5
==
--- head/share/man/man5/periodic.conf.5 Sat Apr  1 15:01:10 2017
(r316357)
+++ head/share/man/man5/periodic.conf.5 Sat Apr  1 15:04:37 2017
(r316358)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 31, 2015
+.Dd March 31, 2017
 .Dt PERIODIC.CONF 5
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316357 - head/usr.sbin/bhyve

2017-04-01 Thread Roman Bogorodskiy
Author: novel (ports committer)
Date: Sat Apr  1 15:01:10 2017
New Revision: 316357
URL: https://svnweb.freebsd.org/changeset/base/316357

Log:
  Minor style improvements in bhyve.8
  
  Replace "as of now" with "at present". As the change is a really minor one,
  don't bump .Dd.
  
  Suggested by: wblock
  Approved by:  wblock (implicit)

Modified:
  head/usr.sbin/bhyve/bhyve.8

Modified: head/usr.sbin/bhyve/bhyve.8
==
--- head/usr.sbin/bhyve/bhyve.8 Sat Apr  1 12:27:02 2017(r316356)
+++ head/usr.sbin/bhyve/bhyve.8 Sat Apr  1 15:01:10 2017(r316357)
@@ -294,9 +294,9 @@ sockets on the filesystem must be cleane
 exits.
 .It
 There is no way to use the "console port" feature, nor the console port
-resize as of now.
+resize at present.
 .It
-Emergency write is advertised, but no-op as of now.
+Emergency write is advertised, but no-op at present.
 .El
 .El
 .El
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r316355 - head/sys/netpfil/pf

2017-04-01 Thread Kristof Provost
Author: kp
Date: Sat Apr  1 12:22:34 2017
New Revision: 316355
URL: https://svnweb.freebsd.org/changeset/base/316355

Log:
  pf: Fix leak of pf_state_keys
  
  If we hit the state limit we returned from pf_create_state() without cleaning
  up.
  
  PR:   217997
  Submitted by: Max 
  MFC after:1 week

Modified:
  head/sys/netpfil/pf/pf.c

Modified: head/sys/netpfil/pf/pf.c
==
--- head/sys/netpfil/pf/pf.cSat Apr  1 11:24:34 2017(r316354)
+++ head/sys/netpfil/pf/pf.cSat Apr  1 12:22:34 2017(r316355)
@@ -3559,7 +3559,7 @@ pf_create_state(struct pf_rule *r, struc
(counter_u64_fetch(r->states_cur) >= r->max_states)) {
counter_u64_add(V_pf_status.lcounters[LCNT_STATES], 1);
REASON_SET(, PFRES_MAXSTATES);
-   return (PF_DROP);
+   goto csfailed;
}
/* src node for filter rule */
if ((r->rule_flag & PFRULE_SRCTRACK ||
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r316309 - head/sys/dev/qlxgbe

2017-04-01 Thread Sepherosa Ziehau
Maybe it's time to add an IFCAP for HWLRO.

On Fri, Mar 31, 2017 at 7:39 AM, Somayajulu, David
 wrote:
>>> > I know this is not a new topic but a little more descriptive commit-log 
>>> > would have been nicer. Also, you should update the manpage reflecting 
>>> > this change. i.e. now it also supports software LRO when h/w LRO is 
>>> > disabled.
>>> Will do. Sorry about that.
> Minor correction. Please note that the driver provides the ability to choose 
> between SoftwareLRO and HW LRO, when LRO is enabled - it is HW LRO by 
> default. If LRO is turned off via ifconfig, neither Software nor HW LRO is 
> enabled.
>
> Cheers
> David S.
>
> -Original Message-
> From: hiren panchasara [mailto:hi...@strugglingcoder.info]
> Sent: Thursday, March 30, 2017 4:12 PM
> To: Somayajulu, David 
> Cc: David C Somayajulu ; src-committ...@freebsd.org; 
> svn-src-...@freebsd.org; svn-src-head@freebsd.org
> Subject: Re: svn commit: r316309 - head/sys/dev/qlxgbe
>
> On 03/30/17 at 11:07P, Somayajulu, David wrote:
>> Hi Hiren,
>> > I know this is not a new topic but a little more descriptive commit-log 
>> > would have been nicer. Also, you should update the manpage reflecting this 
>> > change. i.e. now it also supports software LRO when h/w LRO is disabled.
>> Will do. Sorry about that.
>
> Thanks!
>>
>> > Do you know of a case where one would want to disable h/w lro and enable 
>> > s/w lro? I guess where you want to free up nic and make cpu do more work?
>> I was under the impression as well, that s/w lro is moot, if h/w lro was 
>> available, till one costumer asked for it. Not sure what the use case is.
>
> I thought this idea (like gro in linux) was popular when lro in h/w was 
> considered buggy and couldn't correctly do batching (i.e. hide useful flags). 
> Not sure if that's still the case.
>
> cheers,
> Hiren
> ___
> svn-src-...@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"



-- 
Tomorrow Will Never Die
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r316311 - in head: lib/libstand sys/boot/geli sys/boot/i386/gptboot sys/boot/i386/loader sys/boot/i386/zfsboot

2017-04-01 Thread Bruce Evans

On Fri, 31 Mar 2017, Brooks Davis wrote:


On Fri, Mar 31, 2017 at 11:29:20AM -0700, John Baldwin wrote:

On Friday, March 31, 2017 09:04:51 AM Peter Grehan wrote:

So... can anyone provide a clue what's "explicit" (or different in any
way) between explicit_bzero() and normal bzero()?



https://www.freebsd.org/cgi/man.cgi?query=explicit_bzero=3=FreeBSD+12-current


It should be called 'bzero_now_I_mean_it()'

(but then we would need some other function called anybody_want_a_peanut())


It's sole purpose is to prevent the compiler from observing a pattern
like:

char a_secret_key[len];
...
bzero(a_secret_key, len);
return;

or

char *a_secret_key = malloc(len);
...
bzero(a_secret_key, len);
free(a_secret_key);

And optimizing away bzero() because it knows what bzero() does and that
nothing will ever access it as far as the C language is concerned..


Only broken compilers know what bzero() does.  It is not a Standard C
function, and libstand doesn't implement Standard C.

Most boot code is compiled with -ffreestanding to prevent similar but
valid optimizations of Standard C functions, but geli isn't.

Some versions of POSIX have bzero() under certain feature test macros,
and a compiler for such versions of POSIX could optimize bzero() if
it also understands the feature test macros.  I doubt that any compiler
understands this.  In FreeBSD, the feature test macro condition for
bzero() in  is __BSD_VISIBLE__ || POSIX_VISIBLE <= 200112.
The compiler could reasonably optimize calls to bzero() if this condition
is satisfied in the caller's compilation unit.

bzero() (and most other functions) is not properly declared in .
 just includes  and many other standard headers and
gets massive namespace pollution for unimplemented things and bogus
visibility ifdefs for things like bzero() that it does implement.
bzero() is standard in libstand, but it is not obviously the standard
one.

 handles some functions better.  It declares getchar() and doesn't
include .
  (All of its function declararions have style bugs.  Functions are
  declared as extern, as was necessary to support versions of K older
  than the one that BSD pretended to support 25 years ago.  Many of
  its declarations have bugs.  Many have named parameters in the
  application namespace.  Some have a style bug instead of this bug
  -- they don't name the parameters.  None use the technically correct
  method of naming parameters with underscores.)
It only has the malloc() family of functions as macros which expand to
private functions like Malloc().


The moment you enable LTO all bets are off because it can pattern match
the code for explicit_bzero(), realize that it is that same as bzero()
and combine them.  Declaring a_secret_key volatile likely makes things
work, but the C language is deficient in not providing a way to express
something like explicit_bzero() sanely and reliable.


That is an invalid optimization even for bzero().  I doubt that LTO is
"smart" enough to even read the code of bzero() and reverse engineer this
to get its implementation in C.  bzero() is nonstandard so nothing can
be inferred from its name.  It might be a private version that takes
pointers to volatiles.  Then C semantics don't allow removing the memory
accesses.  LTO can determine if the pointers are volatiles given sufficient
annotations.  Debugging annotations would give some volatile types, but
I think it is insuccient to attach the types to variables.  But determining
the absence of volatile types is not enough for the optimization.  The
compiler has merely reverse-engineered the current implmentation, and
needs more annotations to determine that the absense of volatile types is
not just an implementation detail.

The compiler could read the documentation of libstand.  Unfortately, if
it does that it can know that its optimization of bzero() is valid
subject to the complications with the feature tests.  libstand(3) just
says that "String functions are available as documented in string(3)".
So the functions must be the standard ones for the applicable standard.
The compiler next has to read and understand string(3) better than its
authors.  Of course, it doesn't document the feature test macros.

bzero() is actually documented in bzero(3).  Of course, the feature test
macros aren't documented there either.  It is documented that POSIX
removed bzero() in 2008 and it is implicit that FreeBSD still has it.

explicit_bzero() is much the same as bzero(), except if the compiler
follows the chain of optimization down to bzero(3), and understand it,
then it will see that explicit_bzero() is a little different.
explicit_bzero()'s API is broken as designed, since it doesn't have
volatiles in it.  The memory accesses are magic, and volatile is
the only way to express this.  The difference between explicit_bzero()
and bzero() comes down to the clause in bzero() that disallows
compilers running their dead store 

Re: svn commit: r316342 - in head: etc/defaults etc/periodic/daily share/man/man5 usr.sbin/periodic

2017-04-01 Thread Rodney W. Grimes
Small error in date below

> Author: asomers
> Date: Sat Apr  1 04:42:35 2017
> New Revision: 316342
> URL: https://svnweb.freebsd.org/changeset/base/316342
> 
> Log:
>   Consolidate random sleeps in periodic scripts
>   
>   Multiple periodic scripts sleep for a random amount of time in order to
>   mitigate the thundering herd problem. This is bad, because the sum of
>   multiple uniformly distributed random variables approaches a normal
>   distribution, so the problem isn't mitigated as effectively as it would be
>   with a single sleep.
>   
>   This change creates a single configurable anticongestion sleep. periodic
>   will only sleep if at least one script requires it, and it will never sleep
>   more than once per invocation. It also won't sleep if periodic was run
>   interactively, fixing an unrelated longstanding bug.
>   
>   PR: 217055
>   PR: 210188
>   Reviewed by:cy
>   MFC after:  3 weeks
>   Differential Revision:  https://reviews.freebsd.org/D10211
> 
> Modified:
>   head/etc/defaults/periodic.conf
>   head/etc/periodic/daily/480.leapfile-ntpd
>   head/share/man/man5/periodic.conf.5
>   head/usr.sbin/periodic/periodic.sh
> 
> Modified: head/etc/defaults/periodic.conf
> ==
> --- head/etc/defaults/periodic.conf   Sat Apr  1 01:00:36 2017
> (r316341)
> +++ head/etc/defaults/periodic.conf   Sat Apr  1 04:42:35 2017
> (r316342)
> @@ -22,6 +22,8 @@ periodic_conf_files="/etc/periodic.conf 
>  # periodic script dirs
>  local_periodic="/usr/local/etc/periodic"
>  
> +# Max time to sleep to avoid causing congestion on download servers
> +anticongestion_sleeptime=3600
>  
>  # Daily options
>  
> @@ -136,8 +138,6 @@ daily_status_mail_rejects_shorten="NO"
>  
>  # 480.leapfile-ntpd
>  daily_ntpd_leapfile_enable="YES" # Fetch NTP leapfile
> -daily_ntpd_avoid_congestion="YES"# Avoid congesting
> - # leapfile sources
>  
>  # 480.status-ntpd
>  daily_status_ntpd_enable="NO"# Check NTP 
> status
> @@ -307,6 +307,18 @@ security_status_tcpwrap_period="daily"
>  if [ -z "${source_periodic_confs_defined}" ]; then
>  source_periodic_confs_defined=yes
>  
> + # Sleep for a random amount of time in order to mitigate the thundering
> + # herd problem of multiple hosts running periodic simultaneously.
> + # Will not sleep when used interactively.
> + # Will sleep at most once per invocation of periodic
> + anticongestion() {
> + [ -n "$PERIODIC_IS_INTERACTIVE" ] && return
> + if [ -f "$PERIODIC_ANTICONGESTION_FILE" ]; then
> + rm -f $PERIODIC_ANTICONGESTION_FILE
> + sleep `jot -r 1 0 ${anticongestion_sleeptime}`
> + fi
> + }
> +
>   # Compatibility with old daily variable names.
>   # They can be removed in stable/11.
>   security_daily_compat_var() {
> 
> Modified: head/etc/periodic/daily/480.leapfile-ntpd
> ==
> --- head/etc/periodic/daily/480.leapfile-ntpd Sat Apr  1 01:00:36 2017
> (r316341)
> +++ head/etc/periodic/daily/480.leapfile-ntpd Sat Apr  1 04:42:35 2017
> (r316342)
> @@ -13,16 +13,9 @@ fi
>  
>  case "$daily_ntpd_leapfile_enable" in
>  [Yy][Ee][Ss])
> - case "$daily_ntpd_avoid_congestion" in
> - [Yy][Ee][Ss])
> - # Avoid dogpiling
> - (sleep $(jot -r 1 0 3600); service ntpd onefetch) &
> - ;;
> - *)
> - service ntpd onefetch
> - ;;
> - esac
> - ;;
> +anticongestion
> +service ntpd onefetch
> +;;
>  esac
>  
>  exit $rc
> 
> Modified: head/share/man/man5/periodic.conf.5
> ==
> --- head/share/man/man5/periodic.conf.5   Sat Apr  1 01:00:36 2017
> (r316341)
> +++ head/share/man/man5/periodic.conf.5   Sat Apr  1 04:42:35 2017
> (r316342)
> @@ -25,7 +25,7 @@
>  .\"
>  .\" $FreeBSD$
>  .\"
> -.Dd March 26, 2015
> +.Dd March 31, 2015
  2017?


>  .Dt PERIODIC.CONF 5
>  .Os
>  .Sh NAME
> @@ -133,6 +133,10 @@ respectively.
>  Refer to the
>  .Xr periodic 8
>  manual page for how script return codes are interpreted.
> +.It Va anticongestion_sleeptime
> +.Pq Vt int
> +The maximum number of seconds to randomly sleep in order to smooth bursty 
> loads
> +on a shared resource, such as a download mirror.
>  .El
>  .Pp
>  The following variables are used by the standard scripts that reside in
> 
> Modified: head/usr.sbin/periodic/periodic.sh
> ==
> --- head/usr.sbin/periodic/periodic.shSat Apr  1 01:00:36 2017
> (r316341)
> +++