svn commit: r348774 - head/sys/sys

2019-06-07 Thread Andrey V. Elsukov
Author: ae
Date: Fri Jun  7 08:30:35 2019
New Revision: 348774
URL: https://svnweb.freebsd.org/changeset/base/348774

Log:
  Use underscores for internal variable name to avoid conflicts.
  
  MFC after:1 week

Modified:
  head/sys/sys/counter.h

Modified: head/sys/sys/counter.h
==
--- head/sys/sys/counter.h  Fri Jun  7 08:21:01 2019(r348773)
+++ head/sys/sys/counter.h  Fri Jun  7 08:30:35 2019(r348774)
@@ -43,23 +43,23 @@ voidcounter_u64_zero(counter_u64_t);
 uint64_t   counter_u64_fetch(counter_u64_t);
 
 #defineCOUNTER_ARRAY_ALLOC(a, n, wait) do {\
-   for (int i = 0; i < (n); i++)   \
-   (a)[i] = counter_u64_alloc(wait);   \
+   for (int _i = 0; _i < (n); _i++)\
+   (a)[_i] = counter_u64_alloc(wait);  \
 } while (0)
 
 #defineCOUNTER_ARRAY_FREE(a, n)do {\
-   for (int i = 0; i < (n); i++)   \
-   counter_u64_free((a)[i]);   \
+   for (int _i = 0; _i < (n); _i++)\
+   counter_u64_free((a)[_i]);  \
 } while (0)
 
 #defineCOUNTER_ARRAY_COPY(a, dstp, n)  do {\
-   for (int i = 0; i < (n); i++)   \
-   ((uint64_t *)(dstp))[i] = counter_u64_fetch((a)[i]);\
+   for (int _i = 0; _i < (n); _i++)\
+   ((uint64_t *)(dstp))[_i] = counter_u64_fetch((a)[_i]);\
 } while (0)
 
 #defineCOUNTER_ARRAY_ZERO(a, n)do {\
-   for (int i = 0; i < (n); i++)   \
-   counter_u64_zero((a)[i]);   \
+   for (int _i = 0; _i < (n); _i++)\
+   counter_u64_zero((a)[_i]);  \
 } while (0)
 
 /*
___
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: r348772 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-06-07 Thread Slawa Olhovchenkov
On Fri, Jun 07, 2019 at 06:35:42AM +, Andriy Gapon wrote:

> Author: avg
> Date: Fri Jun  7 06:35:42 2019
> New Revision: 348772
> URL: https://svnweb.freebsd.org/changeset/base/348772
> 
> Log:
>   Restore ARC MFU/MRU pressure
>   
>   Before r305323 (MFV r302991: 6950 ARC should cache compressed data)
>   arc_read() code did this for access to a ghost buffer:
>arc_adapt() (from arc_get_data_buf())
>arc_access(hdr, hash_lock)
>   I.e., we first checked access to the MFU ghost/MRU ghost buffer and
>   adapt MFU/MRU sizes (in arc_adapt()) and next move buffer from the ghost
>   state to regular.
>   
>   After r305323 the sequence is different:
>arc_access(hdr, hash_lock);
>arc_hdr_alloc_pabd(hdr);
>   I.e., we first move the buffer from the ghost state in arc_access() and
>   then we check access to buffer in ghost state (in arc_hdr_alloc_pabd()
>   -> arc_get_data_abd() -> arc_get_data_impl() -> arc_adapt()).  This is
>   incorrect: arc_adapt() never see access to the ghost buffer because
>   arc_access() already migrated the buffer from the ghost state to
>   regular.
>   
>   So, the fix is to restore a call to arc_adapt() before arc_access() and
>   to suppress the call to arc_adapt() after arc_access().
>   
>   Submitted by:   Slawa Olhovchenkov 
>   MFC after:  2 weeks
>   Sponsored by:   Integros [integros.com]
>   Differential Revision: https://reviews.freebsd.org/D19094

Include in 11.3-RELEASE planed?
___
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: r348776 - in head: contrib/elftoolchain/elfdump contrib/elftoolchain/readelf sys/sys

2019-06-07 Thread Christian S.J. Peron
Author: csjp
Date: Fri Jun  7 14:51:55 2019
New Revision: 348776
URL: https://svnweb.freebsd.org/changeset/base/348776

Log:
  Teach readelf about some OpenBSD ELF program headers
  
  - Add constants for OpenBSD wxneeded, bootdata and randomize to the
FreeBSD elf_common.h file. This is the file that gets used by the
elftoolchain library.
  - Update readelf and elfdump utilities to decode these program headers
if they are encountered.
  
  Note: FreeBSD has it's own version of elfdump(1), which will be updated
  in a subsequent commit. I am adding it here anyway because this diff is
  going to be submitted upstream.
  
  Discussed with:   emaste
  Reviewed by:  imp
  MFC afer: 2 weeks
  Differential Revision:https://reviews.freebsd.org/D20548
  
  Mcontrib/elftoolchain/elfdump/elfdump.c
  Mcontrib/elftoolchain/readelf/readelf.c
  Msys/sys/elf_common.h

Modified:
  head/contrib/elftoolchain/elfdump/elfdump.c
  head/contrib/elftoolchain/readelf/readelf.c
  head/sys/sys/elf_common.h

Modified: head/contrib/elftoolchain/elfdump/elfdump.c
==
--- head/contrib/elftoolchain/elfdump/elfdump.c Fri Jun  7 10:09:43 2019
(r348775)
+++ head/contrib/elftoolchain/elfdump/elfdump.c Fri Jun  7 14:51:55 2019
(r348776)
@@ -343,17 +343,20 @@ elf_phdr_type_str(unsigned int type)
static char s_type[32];
 
switch (type) {
-   case PT_NULL:   return "PT_NULL";
-   case PT_LOAD:   return "PT_LOAD";
-   case PT_DYNAMIC:return "PT_DYNAMIC";
-   case PT_INTERP: return "PT_INTERP";
-   case PT_NOTE:   return "PT_NOTE";
-   case PT_SHLIB:  return "PT_SHLIB";
-   case PT_PHDR:   return "PT_PHDR";
-   case PT_TLS:return "PT_TLS";
-   case PT_GNU_EH_FRAME:   return "PT_GNU_EH_FRAME";
-   case PT_GNU_STACK:  return "PT_GNU_STACK";
-   case PT_GNU_RELRO:  return "PT_GNU_RELRO";
+   case PT_NULL:   return "PT_NULL";
+   case PT_LOAD:   return "PT_LOAD";
+   case PT_DYNAMIC:return "PT_DYNAMIC";
+   case PT_INTERP: return "PT_INTERP";
+   case PT_NOTE:   return "PT_NOTE";
+   case PT_SHLIB:  return "PT_SHLIB";
+   case PT_PHDR:   return "PT_PHDR";
+   case PT_TLS:return "PT_TLS";
+   case PT_GNU_EH_FRAME:   return "PT_GNU_EH_FRAME";
+   case PT_GNU_STACK:  return "PT_GNU_STACK";
+   case PT_GNU_RELRO:  return "PT_GNU_RELRO";
+   case PT_OPENBSD_RANDOMIZE:  return "PT_OPENBSD_RANDOMIZE";
+   case PT_OPENBSD_WXNEEDED:   return "PT_OPENBSD_WXNEEDED";
+   case PT_OPENBSD_BOOTDATA:   return "PT_OPENBSD_BOOTDATA";
}
snprintf(s_type, sizeof(s_type), "", type);
return (s_type);

Modified: head/contrib/elftoolchain/readelf/readelf.c
==
--- head/contrib/elftoolchain/readelf/readelf.c Fri Jun  7 10:09:43 2019
(r348775)
+++ head/contrib/elftoolchain/readelf/readelf.c Fri Jun  7 14:51:55 2019
(r348776)
@@ -674,6 +674,9 @@ phdr_type(unsigned int mach, unsigned int ptype)
case PT_GNU_EH_FRAME: return "GNU_EH_FRAME";
case PT_GNU_STACK: return "GNU_STACK";
case PT_GNU_RELRO: return "GNU_RELRO";
+   case PT_OPENBSD_RANDOMIZE: return "OPENBSD_RANDOMIZE";
+   case PT_OPENBSD_WXNEEDED: return "OPENBSD_WXNEEDED";
+   case PT_OPENBSD_BOOTDATA: return "OPENBSD_BOOTDATA";
default:
if (ptype >= PT_LOOS && ptype <= PT_HIOS)
snprintf(s_ptype, sizeof(s_ptype), "LOOS+%#x",

Modified: head/sys/sys/elf_common.h
==
--- head/sys/sys/elf_common.h   Fri Jun  7 10:09:43 2019(r348775)
+++ head/sys/sys/elf_common.h   Fri Jun  7 14:51:55 2019(r348776)
@@ -535,6 +535,10 @@ typedef struct {
 #definePT_ARM_EXIDX0x7001  /* ARM exception unwind tables. 
*/
 #definePT_HIPROC   0x7fff  /* Last processor-specific 
type. */
 
+#definePT_OPENBSD_RANDOMIZE0x65A3DBE6  /* OpenBSD random data 
segment */
+#definePT_OPENBSD_WXNEEDED 0x65A3DBE7  /* OpenBSD EXEC/WRITE 
pages needed */
+#definePT_OPENBSD_BOOTDATA 0x65A41BE6  /* OpenBSD section for 
boot args */
+
 /* Values for p_flags. */
 #definePF_X0x1 /* Executable. */
 #definePF_W0x2 /* Writable. */
___
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: r348772 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-06-07 Thread Andriy Gapon
On 07/06/2019 16:04, Slawa Olhovchenkov wrote:
> On Fri, Jun 07, 2019 at 06:35:42AM +, Andriy Gapon wrote:
> 
>> Author: avg
>> Date: Fri Jun  7 06:35:42 2019
>> New Revision: 348772
>> URL: https://svnweb.freebsd.org/changeset/base/348772
>>
>> Log:
>>   Restore ARC MFU/MRU pressure
>>   
>>   Before r305323 (MFV r302991: 6950 ARC should cache compressed data)
>>   arc_read() code did this for access to a ghost buffer:
>>arc_adapt() (from arc_get_data_buf())
>>arc_access(hdr, hash_lock)
>>   I.e., we first checked access to the MFU ghost/MRU ghost buffer and
>>   adapt MFU/MRU sizes (in arc_adapt()) and next move buffer from the ghost
>>   state to regular.
>>   
>>   After r305323 the sequence is different:
>>arc_access(hdr, hash_lock);
>>arc_hdr_alloc_pabd(hdr);
>>   I.e., we first move the buffer from the ghost state in arc_access() and
>>   then we check access to buffer in ghost state (in arc_hdr_alloc_pabd()
>>   -> arc_get_data_abd() -> arc_get_data_impl() -> arc_adapt()).  This is
>>   incorrect: arc_adapt() never see access to the ghost buffer because
>>   arc_access() already migrated the buffer from the ghost state to
>>   regular.
>>   
>>   So, the fix is to restore a call to arc_adapt() before arc_access() and
>>   to suppress the call to arc_adapt() after arc_access().
>>   
>>   Submitted by:  Slawa Olhovchenkov 
>>   MFC after: 2 weeks
>>   Sponsored by:  Integros [integros.com]
>>   Differential Revision: https://reviews.freebsd.org/D19094
> 
> Include in 11.3-RELEASE planed?


I didn't plan it, given the release schedule.
But I can be convinced that this is a really important fix.
So far, I am not :)

-- 
Andriy Gapon
___
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: r348777 - head

2019-06-07 Thread Alex Richardson
Author: arichardson
Date: Fri Jun  7 15:23:52 2019
New Revision: 348777
URL: https://svnweb.freebsd.org/changeset/base/348777

Log:
  Add a basic clang-format configuration file
  
  This gets reasonably close to the existing format in sys/kern but will
  probably require some changes to upstream clang-format before it can be
  used as the default formatting tool.
  
  I tried formatting a few files in sys/kern and the result is pretty close to
  the existing code. However, this configuration file is not ready to be used
  without manually checking the output.
  
  Reviewed By:  emaste
  Differential Revision: https://reviews.freebsd.org/D20533

Added:
  head/.clang-format   (contents, props changed)
Modified:
  head/.gitattributes

Added: head/.clang-format
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/.clang-format  Fri Jun  7 15:23:52 2019(r348777)
@@ -0,0 +1,77 @@
+# $FreeBSD$
+# Basic .clang-format
+---
+BasedOnStyle: WebKit
+AlignAfterOpenBracket: DontAlign
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Left
+AlignOperands: false
+AlignTrailingComments: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: InlineOnly
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterReturnType: TopLevelDefinitions
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: MultiLine
+BinPackArguments: true
+BinPackParameters: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: WebKit
+BreakBeforeTernaryOperators: false
+# TODO: BreakStringLiterals can cause very strange formatting so turn it off?
+BreakStringLiterals: false
+PenaltyBreakBeforeFirstCallParameter: 1000
+CompactNamespaces: true
+DerivePointerAlignment: false
+DisableFormat: false
+ForEachMacros:
+  - SLIST_FOREACH
+  - SLIST_FOREACH_SAFE
+  - LIST_FOREACH
+  - LIST_FOREACH_SAFE
+  - STAILQ_FOREACH
+  - STAILQ_FOREACH_SAFE
+  - TAILQ_FOREACH
+  - TAILQ_FOREACH_SAFE
+  - TAILQ_FOREACH_REVERSE
+  - TAILQ_FOREACH_REVERSE_SAFE
+  - RB_FOREACH
+  - RB_FOREACH_SAFE
+  - RB_FOREACH_FROM
+  - RB_FOREACH_REVERSE
+  - RB_FOREACH_REVERSE_FROM
+  - RB_FOREACH_REVERSE_SAFE
+  - FOREACH_THREAD_IN_PROC
+  - FOREACH_PROC_IN_SYSTEM
+  - FOREACH_PRISON_CHILD
+  - FOREACH_PRISON_DESCENDANT
+  - FOREACH_PRISON_DESCENDANT_LOCKED
+  - FOREACH_PRISON_DESCENDANT_LOCKED_LEVEL
+  - MNT_VNODE_FOREACH_ALL
+  - MNT_VNODE_FOREACH_ACTIVE
+IndentCaseLabels: false
+IndentPPDirectives: None
+Language: Cpp
+NamespaceIndentation: None
+PointerAlignment: Right
+ContinuationIndentWidth: 4
+IndentWidth: 8
+TabWidth: 8
+ColumnLimit: 80
+UseTab: Always
+SpaceAfterCStyleCast: false
+SortIncludes: false
+KeepEmptyLinesAtTheStartOfBlocks: true
+# The options below will only be supported starting with clang 9.0:
+# TODO-CLANG-9: TypenameMacros:
+# TODO-CLANG-9:   - SLIST_HEAD
+# TODO-CLANG-9:   - SLIST_ENTRY
+# TODO-CLANG-9:   - TAILQ_ENTRY
+# TODO-CLANG-9:   - TAILQ_HEAD
+# TODO-CLANG-9:   - STAILQ_ENTRY
+# TODO-CLANG-9:   - STAILQ_HEAD
+...

Modified: head/.gitattributes
==
--- head/.gitattributes Fri Jun  7 14:51:55 2019(r348776)
+++ head/.gitattributes Fri Jun  7 15:23:52 2019(r348777)
@@ -4,3 +4,4 @@
 *.hpp  diff=cpp
 *.py   diff=python
 . svn-properties=svn:keywords=tools/build/options/WITHOUT_LOADER_ZFS
+.clang-format svn-properties=svn:keywords=FreeBSD=%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"


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

2019-06-07 Thread John Baldwin
Author: jhb
Date: Fri Jun  7 15:48:12 2019
New Revision: 348778
URL: https://svnweb.freebsd.org/changeset/base/348778

Log:
  Enable memory and I/O decoding in PCI devices on demand.
  
  Rather than uncoditionally setting the MEMEN and PORTEN bits in
  PCIR_COMMAND for PCI devices, set the respective bit when the first
  BAR of a given type is added to the device.  This more closely matches
  what firmware does on bare metal.
  
  BUSMASTEREN is still set unconditionally.  Eventually this bit should
  move into the device models as not all device models need this set.
  
  Reviewed by:  rgrimes
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D20530

Modified:
  head/usr.sbin/bhyve/pci_emul.c

Modified: head/usr.sbin/bhyve/pci_emul.c
==
--- head/usr.sbin/bhyve/pci_emul.c  Fri Jun  7 15:23:52 2019
(r348777)
+++ head/usr.sbin/bhyve/pci_emul.c  Fri Jun  7 15:48:12 2019
(r348778)
@@ -586,6 +586,7 @@ pci_emul_alloc_pbar(struct pci_devinst *pdi, int idx, 
 {
int error;
uint64_t *baseptr, limit, addr, mask, lobits, bar;
+   uint16_t cmd, enbit;
 
assert(idx >= 0 && idx <= PCI_BARMAX);
 
@@ -604,13 +605,14 @@ pci_emul_alloc_pbar(struct pci_devinst *pdi, int idx, 
switch (type) {
case PCIBAR_NONE:
baseptr = NULL;
-   addr = mask = lobits = 0;
+   addr = mask = lobits = enbit = 0;
break;
case PCIBAR_IO:
baseptr = &pci_emul_iobase;
limit = PCI_EMUL_IOLIMIT;
mask = PCIM_BAR_IO_BASE;
lobits = PCIM_BAR_IO_SPACE;
+   enbit = PCIM_CMD_PORTEN;
break;
case PCIBAR_MEM64:
/*
@@ -639,12 +641,14 @@ pci_emul_alloc_pbar(struct pci_devinst *pdi, int idx, 
mask = PCIM_BAR_MEM_BASE;
lobits = PCIM_BAR_MEM_SPACE | PCIM_BAR_MEM_64;
}
+   enbit = PCIM_CMD_MEMEN;
break;
case PCIBAR_MEM32:
baseptr = &pci_emul_membase32;
limit = PCI_EMUL_MEMLIMIT32;
mask = PCIM_BAR_MEM_BASE;
lobits = PCIM_BAR_MEM_SPACE | PCIM_BAR_MEM_32;
+   enbit = PCIM_CMD_MEMEN;
break;
default:
printf("pci_emul_alloc_base: invalid bar type %d\n", type);
@@ -671,6 +675,9 @@ pci_emul_alloc_pbar(struct pci_devinst *pdi, int idx, 
pci_set_cfgdata32(pdi, PCIR_BAR(idx + 1), bar >> 32);
}
 
+   cmd = pci_get_cfgdata16(pdi, PCIR_COMMAND);
+   if ((cmd & enbit) != enbit)
+   pci_set_cfgdata16(pdi, PCIR_COMMAND, cmd | enbit);
register_bar(pdi, idx);
 
return (0);
@@ -756,8 +763,7 @@ pci_emul_init(struct vmctx *ctx, struct pci_devemu *pd
pci_set_cfgdata8(pdi, PCIR_INTLINE, 255);
pci_set_cfgdata8(pdi, PCIR_INTPIN, 0);
 
-   pci_set_cfgdata8(pdi, PCIR_COMMAND,
-   PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
+   pci_set_cfgdata8(pdi, PCIR_COMMAND, PCIM_CMD_BUSMASTEREN);
 
err = (*pde->pe_init)(ctx, pdi, fi->fi_param);
if (err == 0)
___
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: r348779 - head/usr.sbin/bhyve

2019-06-07 Thread John Baldwin
Author: jhb
Date: Fri Jun  7 15:53:27 2019
New Revision: 348779
URL: https://svnweb.freebsd.org/changeset/base/348779

Log:
  Keep the shadow PCIR_COMMAND synced with the real one for pass through.
  
  This ensures that bhyve properly recognizes when decoding is disabled
  for BARs on passthru devices.  To properly handle writes to the
  register, export a pci_emul_cmd_changed function from pci_emul.c that
  the pass through device model invokes for config writes that change
  PCIR_COMMAND.
  
  Reviewed by:  rgrimes
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D20531

Modified:
  head/usr.sbin/bhyve/pci_emul.c
  head/usr.sbin/bhyve/pci_emul.h
  head/usr.sbin/bhyve/pci_passthru.c

Modified: head/usr.sbin/bhyve/pci_emul.c
==
--- head/usr.sbin/bhyve/pci_emul.c  Fri Jun  7 15:48:12 2019
(r348778)
+++ head/usr.sbin/bhyve/pci_emul.c  Fri Jun  7 15:53:27 2019
(r348779)
@@ -1679,33 +1679,20 @@ pci_emul_hdrtype_fixup(int bus, int slot, int off, int
}
 }
 
-static void
-pci_emul_cmdsts_write(struct pci_devinst *pi, int coff, uint32_t new, int 
bytes)
+/*
+ * Update device state in response to changes to the PCI command
+ * register.
+ */
+void
+pci_emul_cmd_changed(struct pci_devinst *pi, uint16_t old)
 {
-   int i, rshift;
-   uint32_t cmd, cmd2, changed, old, readonly;
+   int i;
+   uint16_t changed, new;
 
-   cmd = pci_get_cfgdata16(pi, PCIR_COMMAND);  /* stash old value */
+   new = pci_get_cfgdata16(pi, PCIR_COMMAND);
+   changed = old ^ new;
 
/*
-* From PCI Local Bus Specification 3.0 sections 6.2.2 and 6.2.3.
-*
-* XXX Bits 8, 11, 12, 13, 14 and 15 in the status register are
-* 'write 1 to clear'. However these bits are not set to '1' by
-* any device emulation so it is simpler to treat them as readonly.
-*/
-   rshift = (coff & 0x3) * 8;
-   readonly = 0xF880 >> rshift;
-
-   old = CFGREAD(pi, coff, bytes);
-   new &= ~readonly;
-   new |= (old & readonly);
-   CFGWRITE(pi, coff, new, bytes); /* update config */
-
-   cmd2 = pci_get_cfgdata16(pi, PCIR_COMMAND); /* get updated value */
-   changed = cmd ^ cmd2;
-
-   /*
 * If the MMIO or I/O address space decoding has changed then
 * register/unregister all BARs that decode that address space.
 */
@@ -1717,7 +1704,7 @@ pci_emul_cmdsts_write(struct pci_devinst *pi, int coff
case PCIBAR_IO:
/* I/O address space decoding changed? */
if (changed & PCIM_CMD_PORTEN) {
-   if (porten(pi))
+   if (new & PCIM_CMD_PORTEN)
register_bar(pi, i);
else
unregister_bar(pi, i);
@@ -1727,7 +1714,7 @@ pci_emul_cmdsts_write(struct pci_devinst *pi, int coff
case PCIBAR_MEM64:
/* MMIO address space decoding changed? */
if (changed & PCIM_CMD_MEMEN) {
-   if (memen(pi))
+   if (new & PCIM_CMD_MEMEN)
register_bar(pi, i);
else
unregister_bar(pi, i);
@@ -1743,6 +1730,32 @@ pci_emul_cmdsts_write(struct pci_devinst *pi, int coff
 * interrupt.
 */
pci_lintr_update(pi);
+}
+
+static void
+pci_emul_cmdsts_write(struct pci_devinst *pi, int coff, uint32_t new, int 
bytes)
+{
+   int rshift;
+   uint32_t cmd, old, readonly;
+
+   cmd = pci_get_cfgdata16(pi, PCIR_COMMAND);  /* stash old value */
+
+   /*
+* From PCI Local Bus Specification 3.0 sections 6.2.2 and 6.2.3.
+*
+* XXX Bits 8, 11, 12, 13, 14 and 15 in the status register are
+* 'write 1 to clear'. However these bits are not set to '1' by
+* any device emulation so it is simpler to treat them as readonly.
+*/
+   rshift = (coff & 0x3) * 8;
+   readonly = 0xF880 >> rshift;
+
+   old = CFGREAD(pi, coff, bytes);
+   new &= ~readonly;
+   new |= (old & readonly);
+   CFGWRITE(pi, coff, new, bytes); /* update config */
+
+   pci_emul_cmd_changed(pi, cmd);
 }
 
 static void

Modified: head/usr.sbin/bhyve/pci_emul.h
==
--- head/usr.sbin/bhyve/pci_emul.h  Fri Jun  7 15:48:12 2019
(r348778)
+++ head/usr.sbin/bhyve/pci_emul.h  Fri Jun  7 15:53:27 2019
(r348779)
@@ -223,6 +223,7 @@ int pci_emul_alloc_pbar(struct 

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

2019-06-07 Thread Chuck Tuffli
Author: chuck
Date: Fri Jun  7 17:09:49 2019
New Revision: 348781
URL: https://svnweb.freebsd.org/changeset/base/348781

Log:
  bhyve: Add PCIe Integrated Endpoint capability
  
  The NVMe CAM driver reports the PCIe Link Capability and Status for
  devices. For emulated bhyve NVMe devices, this looks like:
  
  nda0: nvme version 1.3 x63 (max x63) lanes PCIe Gen15 (max Gen15) link
  
  The driver outputs this because the emulated device doesn't include the
  PCIe Capability structure. The NVMe specification requires these
  registers, so the fix is to add this set of capability registers to the
  emulated device.
  
  Note that PCI Express devices that are integrated into the Root Complex
  (i.e. Bus 0x0) do not have to support the Link Capability or Status
  registers. Windows will fail to start (i.e. Code 10) devices that appear
  to be part of the Root Complex but report being a PCI Express Endpoint.
  So also add a check to pci_emul_add_pciecap() to check if the device is
  integrated and change the device type.
  
  Reviewed by:  imp, ken, araujo, jhb, rgrimes
  Approved by:  imp (mentor), ken (mentor), jhb (maintainer)
  MFC after:1 week
  Differential Revision: https://reviews.freebsd.org/D19904

Modified:
  head/usr.sbin/bhyve/pci_emul.c
  head/usr.sbin/bhyve/pci_nvme.c

Modified: head/usr.sbin/bhyve/pci_emul.c
==
--- head/usr.sbin/bhyve/pci_emul.c  Fri Jun  7 17:05:58 2019
(r348780)
+++ head/usr.sbin/bhyve/pci_emul.c  Fri Jun  7 17:09:49 2019
(r348781)
@@ -953,15 +953,23 @@ pci_emul_add_pciecap(struct pci_devinst *pi, int type)
int err;
struct pciecap pciecap;
 
-   if (type != PCIEM_TYPE_ROOT_PORT)
-   return (-1);
-
bzero(&pciecap, sizeof(pciecap));
 
+   /*
+* Use the integrated endpoint type for endpoints on a root complex bus.
+*
+* NB: bhyve currently only supports a single PCI bus that is the root
+* complex bus, so all endpoints are integrated.
+*/
+   if ((type == PCIEM_TYPE_ENDPOINT) && (pi->pi_bus == 0))
+   type = PCIEM_TYPE_ROOT_INT_EP;
+
pciecap.capid = PCIY_EXPRESS;
-   pciecap.pcie_capabilities = PCIECAP_VERSION | PCIEM_TYPE_ROOT_PORT;
-   pciecap.link_capabilities = 0x411;  /* gen1, x1 */
-   pciecap.link_status = 0x11; /* gen1, x1 */
+   pciecap.pcie_capabilities = PCIECAP_VERSION | type;
+   if (type != PCIEM_TYPE_ROOT_INT_EP) {
+   pciecap.link_capabilities = 0x411;  /* gen1, x1 */
+   pciecap.link_status = 0x11; /* gen1, x1 */
+   }
 
err = pci_emul_add_capability(pi, (u_char *)&pciecap, sizeof(pciecap));
return (err);

Modified: head/usr.sbin/bhyve/pci_nvme.c
==
--- head/usr.sbin/bhyve/pci_nvme.c  Fri Jun  7 17:05:58 2019
(r348780)
+++ head/usr.sbin/bhyve/pci_nvme.c  Fri Jun  7 17:09:49 2019
(r348781)
@@ -1925,6 +1925,12 @@ pci_nvme_init(struct vmctx *ctx, struct pci_devinst *p
goto done;
}
 
+   error = pci_emul_add_pciecap(pi, PCIEM_TYPE_ROOT_INT_EP);
+   if (error) {
+   WPRINTF(("%s pci add Express capability failed\r\n", __func__));
+   goto done;
+   }
+
pthread_mutex_init(&sc->mtx, NULL);
sem_init(&sc->iosemlock, 0, sc->ioslots);
 
___
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: r348782 - head/share/examples/bhyve

2019-06-07 Thread Mark Johnston
Author: markj
Date: Fri Jun  7 17:54:26 2019
New Revision: 348782
URL: https://svnweb.freebsd.org/changeset/base/348782

Log:
  vmrun: Add a missing close-paren to the usage message.
  
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/examples/bhyve/vmrun.sh

Modified: head/share/examples/bhyve/vmrun.sh
==
--- head/share/examples/bhyve/vmrun.sh  Fri Jun  7 17:09:49 2019
(r348781)
+++ head/share/examples/bhyve/vmrun.sh  Fri Jun  7 17:54:26 2019
(r348782)
@@ -75,7 +75,7 @@ usage() {
echo "   -E: Use UEFI mode"
echo "   -f: Use a specific UEFI firmware"
echo "   -F: Use a custom UEFI GOP framebuffer size" \
-   "(default: ${DEFAULT_VNCSIZE}"
+   "(default: ${DEFAULT_VNCSIZE})"
echo "   -g: listen for connection from kgdb at "
echo "   -H: host filesystem to export to the loader"
echo "   -i: force boot of the Installation CDROM image"
___
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: r348783 - in head/sys/powerpc: aim pseries

2019-06-07 Thread Leandro Lupori
Author: luporl
Date: Fri Jun  7 17:58:59 2019
New Revision: 348783
URL: https://svnweb.freebsd.org/changeset/base/348783

Log:
  [PPC64] Support QEMU/KVM pseries without hugepages
  
  This set of changes make it possible to run FreeBSD for PowerPC64/pseries,
  under QEMU/KVM, without requiring the host to make hugepages available to the
  guest.
  
  While there was already this possibility, by means of setting hw_direct_map to
  0, on PowerPC64 there were a couple of issues/wrong assumptions that prevented
  this from working, before this changelist.
  
  Reviewed by:  jhibbits
  Differential Revision:https://reviews.freebsd.org/D20522

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/mmu_oea64.h
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/pseries/mmu_phyp.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cFri Jun  7 17:54:26 2019
(r348782)
+++ head/sys/powerpc/aim/mmu_oea64.cFri Jun  7 17:58:59 2019
(r348783)
@@ -638,7 +638,7 @@ moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernel
 {
struct pvo_entry *pvo;
register_t msr;
-   vm_paddr_t pa;
+   vm_paddr_t pa, pkernelstart, pkernelend;
vm_offset_t size, off;
uint64_t pte_lo;
int i;
@@ -686,9 +686,11 @@ moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernel
 */
 
if (!hw_direct_map || kernelstart < DMAP_BASE_ADDRESS) {
-   for (pa = kernelstart & ~PAGE_MASK; pa < kernelend;
+   pkernelstart = kernelstart & ~DMAP_BASE_ADDRESS;
+   pkernelend = kernelend & ~DMAP_BASE_ADDRESS;
+   for (pa = pkernelstart & ~PAGE_MASK; pa < pkernelend;
pa += PAGE_SIZE)
-   moea64_kenter(mmup, pa, pa);
+   moea64_kenter(mmup, pa | DMAP_BASE_ADDRESS, pa);
}
 
if (!hw_direct_map) {
@@ -696,6 +698,10 @@ moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernel
off = (vm_offset_t)(moea64_bpvo_pool);
for (pa = off; pa < off + size; pa += PAGE_SIZE)
moea64_kenter(mmup, pa, pa);
+
+   /* Map exception vectors */
+   for (pa = EXC_RSVD; pa < EXC_LAST; pa += PAGE_SIZE)
+   moea64_kenter(mmup, pa | DMAP_BASE_ADDRESS, pa);
}
ENABLE_TRANS(msr);
 
@@ -875,7 +881,7 @@ moea64_mid_bootstrap(mmu_t mmup, vm_offset_t kernelsta
 * Initialise the bootstrap pvo pool.
 */
moea64_bpvo_pool = (struct pvo_entry *)moea64_bootstrap_alloc(
-   moea64_bpvo_pool_size*sizeof(struct pvo_entry), 0);
+   moea64_bpvo_pool_size*sizeof(struct pvo_entry), PAGE_SIZE);
moea64_bpvo_pool_index = 0;
 
/* Place at address usable through the direct map */
@@ -1169,15 +1175,19 @@ moea64_unwire(mmu_t mmu, pmap_t pm, vm_offset_t sva, v
  */
 
 static __inline
-void moea64_set_scratchpage_pa(mmu_t mmup, int which, vm_paddr_t pa) {
+void moea64_set_scratchpage_pa(mmu_t mmup, int which, vm_paddr_t pa)
+{
+   struct pvo_entry *pvo;
 
KASSERT(!hw_direct_map, ("Using OEA64 scratchpage with a direct map!"));
mtx_assert(&moea64_scratchpage_mtx, MA_OWNED);
 
-   moea64_scratchpage_pvo[which]->pvo_pte.pa =
+   pvo = moea64_scratchpage_pvo[which];
+   PMAP_LOCK(pvo->pvo_pmap);
+   pvo->pvo_pte.pa =
moea64_calc_wimg(pa, VM_MEMATTR_DEFAULT) | (uint64_t)pa;
-   MOEA64_PTE_REPLACE(mmup, moea64_scratchpage_pvo[which],
-   MOEA64_PTE_INVALIDATE);
+   MOEA64_PTE_REPLACE(mmup, pvo, MOEA64_PTE_INVALIDATE);
+   PMAP_UNLOCK(pvo->pvo_pmap);
isync();
 }
 

Modified: head/sys/powerpc/aim/mmu_oea64.h
==
--- head/sys/powerpc/aim/mmu_oea64.hFri Jun  7 17:54:26 2019
(r348782)
+++ head/sys/powerpc/aim/mmu_oea64.hFri Jun  7 17:58:59 2019
(r348783)
@@ -81,6 +81,7 @@ extern u_int  moea64_pte_overflow;
 
 extern int moea64_large_page_shift;
 extern uint64_tmoea64_large_page_size;
+extern uint64_tmoea64_large_page_mask;
 extern u_long  moea64_pteg_count;
 extern u_long  moea64_pteg_mask;
 extern int n_slbs;

Modified: head/sys/powerpc/aim/slb.c
==
--- head/sys/powerpc/aim/slb.c  Fri Jun  7 17:54:26 2019(r348782)
+++ head/sys/powerpc/aim/slb.c  Fri Jun  7 17:58:59 2019(r348783)
@@ -500,10 +500,12 @@ slb_uma_real_alloc(uma_zone_t zone, vm_size_t bytes, i
if (m == NULL)
return (NULL);
 
-   va = (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m));
-
-   if (!hw_direct_map)
+   if (hw_direct_map)
+   va = (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m));
+   else {
+  

svn commit: r348785 - in head/sys: amd64/amd64 arm/arm arm/nvidia/drm2 compat/linuxkpi/common/src dev/drm2/ttm dev/ti dev/xen/gntdev i386/i386 mips/mips riscv/riscv vm

2019-06-07 Thread Mark Johnston
Author: markj
Date: Fri Jun  7 18:23:29 2019
New Revision: 348785
URL: https://svnweb.freebsd.org/changeset/base/348785

Log:
  Replace uses of vm_page_unwire(m, PQ_NONE) with vm_page_unwire_noq(m).
  
  These calls are not the same in general: the former will dequeue the
  page if it is enqueued, while the latter will just leave it alone.  But,
  all existing uses of the former apply to unmanaged pages, which are
  never enqueued in the first place.  No functional change intended.
  
  Reviewed by:  kib
  MFC after:1 week
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D20470

Modified:
  head/sys/amd64/amd64/pmap.c
  head/sys/arm/arm/pmap-v6.c
  head/sys/arm/nvidia/drm2/tegra_bo.c
  head/sys/compat/linuxkpi/common/src/linux_page.c
  head/sys/dev/drm2/ttm/ttm_page_alloc.c
  head/sys/dev/ti/if_ti.c
  head/sys/dev/xen/gntdev/gntdev.c
  head/sys/i386/i386/pmap.c
  head/sys/mips/mips/pmap.c
  head/sys/riscv/riscv/pmap.c
  head/sys/vm/uma_core.c
  head/sys/vm/vm_glue.c
  head/sys/vm/vm_kern.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Fri Jun  7 18:01:29 2019(r348784)
+++ head/sys/amd64/amd64/pmap.c Fri Jun  7 18:23:29 2019(r348785)
@@ -4081,7 +4081,7 @@ free_pv_chunk(struct pv_chunk *pc)
/* entire chunk is free, return it */
m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc));
dump_drop_page(m->phys_addr);
-   vm_page_unwire(m, PQ_NONE);
+   vm_page_unwire_noq(m);
vm_page_free(m);
 }
 

Modified: head/sys/arm/arm/pmap-v6.c
==
--- head/sys/arm/arm/pmap-v6.c  Fri Jun  7 18:01:29 2019(r348784)
+++ head/sys/arm/arm/pmap-v6.c  Fri Jun  7 18:23:29 2019(r348785)
@@ -2973,7 +2973,7 @@ free_pv_chunk(struct pv_chunk *pc)
/* entire chunk is free, return it */
m = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)pc));
pmap_qremove((vm_offset_t)pc, 1);
-   vm_page_unwire(m, PQ_NONE);
+   vm_page_unwire_noq(m);
vm_page_free(m);
pmap_pte2list_free(&pv_vafree, (vm_offset_t)pc);
 }

Modified: head/sys/arm/nvidia/drm2/tegra_bo.c
==
--- head/sys/arm/nvidia/drm2/tegra_bo.c Fri Jun  7 18:01:29 2019
(r348784)
+++ head/sys/arm/nvidia/drm2/tegra_bo.c Fri Jun  7 18:23:29 2019
(r348785)
@@ -67,7 +67,7 @@ tegra_bo_destruct(struct tegra_bo *bo)
cdev_pager_free_page(bo->cdev_pager, m);
vm_page_lock(m);
m->flags &= ~PG_FICTITIOUS;
-   vm_page_unwire(m, PQ_NONE);
+   vm_page_unwire_noq(m);
vm_page_free(m);
vm_page_unlock(m);
}

Modified: head/sys/compat/linuxkpi/common/src/linux_page.c
==
--- head/sys/compat/linuxkpi/common/src/linux_page.cFri Jun  7 18:01:29 
2019(r348784)
+++ head/sys/compat/linuxkpi/common/src/linux_page.cFri Jun  7 18:23:29 
2019(r348785)
@@ -317,7 +317,7 @@ linux_shmem_read_mapping_page_gfp(vm_object_t obj, int
rv = vm_pager_get_pages(obj, &page, 1, NULL, NULL);
if (rv != VM_PAGER_OK) {
vm_page_lock(page);
-   vm_page_unwire(page, PQ_NONE);
+   vm_page_unwire_noq(page);
vm_page_free(page);
vm_page_unlock(page);
VM_OBJECT_WUNLOCK(obj);

Modified: head/sys/dev/drm2/ttm/ttm_page_alloc.c
==
--- head/sys/dev/drm2/ttm/ttm_page_alloc.c  Fri Jun  7 18:01:29 2019
(r348784)
+++ head/sys/dev/drm2/ttm/ttm_page_alloc.c  Fri Jun  7 18:23:29 2019
(r348785)
@@ -137,7 +137,7 @@ ttm_vm_page_free(vm_page_t m)
KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("ttm got unmanaged %p", m));
m->flags &= ~PG_FICTITIOUS;
m->oflags |= VPO_UNMANAGED;
-   vm_page_unwire(m, PQ_NONE);
+   vm_page_unwire_noq(m);
vm_page_free(m);
 }
 

Modified: head/sys/dev/ti/if_ti.c
==
--- head/sys/dev/ti/if_ti.c Fri Jun  7 18:01:29 2019(r348784)
+++ head/sys/dev/ti/if_ti.c Fri Jun  7 18:23:29 2019(r348785)
@@ -1623,7 +1623,7 @@ ti_newbuf_jumbo(struct ti_softc *sc, int idx, struct m
}
sf[i] = sf_buf_alloc(frame, SFB_NOWAIT);
if (sf[i] == NULL) {
-   vm_page_unwire(frame, PQ_NONE);
+   vm_page_unwire_noq(frame);
vm_page_free

svn commit: r348786 - in head/sys: cam/nvme dev/nvme

2019-06-07 Thread Chuck Tuffli
Author: chuck
Date: Fri Jun  7 18:34:48 2019
New Revision: 348786
URL: https://svnweb.freebsd.org/changeset/base/348786

Log:
  Fix nda(4) PCIe link status output
  
  Differentiate between PCI Express Endpoint devices and Root Complex
  Integrated Endpoints in the nda driver. The Link Status and Capability
  registers are not valid for Integrated Endpoints and should not be
  displayed. The bhyve emulated NVMe device will advertise as being an
  Integrated Endpoint.
  
  Reviewed by:  imp
  Approved byL  imp (mentor)
  Differential Revision: https://reviews.freebsd.org/D20282

Modified:
  head/sys/cam/nvme/nvme_xpt.c
  head/sys/dev/nvme/nvme_sim.c

Modified: head/sys/cam/nvme/nvme_xpt.c
==
--- head/sys/cam/nvme/nvme_xpt.cFri Jun  7 18:23:29 2019
(r348785)
+++ head/sys/cam/nvme/nvme_xpt.cFri Jun  7 18:34:48 2019
(r348786)
@@ -722,6 +722,8 @@ nvme_announce_periph(struct cam_periph *periph)
struct  ccb_trans_settings cts;
struct  cam_path *path = periph->path;
struct ccb_trans_settings_nvme  *nvmex;
+   struct sbuf sb;
+   charbuffer[120];
 
cam_periph_assert(periph, MA_OWNED);
 
@@ -736,13 +738,18 @@ nvme_announce_periph(struct cam_periph *periph)
 
/* Ask the SIM for its base transfer speed */
xpt_path_inq(&cpi, periph->path);
-   printf("%s%d: nvme version %d.%d x%d (max x%d) lanes PCIe Gen%d (max 
Gen%d) link",
+   sbuf_new(&sb, buffer, sizeof(buffer), SBUF_FIXEDLEN);
+   sbuf_printf(&sb, "%s%d: nvme version %d.%d",
periph->periph_name, periph->unit_number,
NVME_MAJOR(nvmex->spec),
-   NVME_MINOR(nvmex->spec),
-   nvmex->lanes, nvmex->max_lanes,
-   nvmex->speed, nvmex->max_speed);
-   printf("\n");
+   NVME_MINOR(nvmex->spec));
+   if (nvmex->valid & CTS_NVME_VALID_LINK)
+   sbuf_printf(&sb, " x%d (max x%d) lanes PCIe Gen%d (max Gen%d) 
link",
+   nvmex->lanes, nvmex->max_lanes,
+   nvmex->speed, nvmex->max_speed);
+   sbuf_printf(&sb, "\n");
+   sbuf_finish(&sb);
+   sbuf_putbuf(&sb);
 }
 
 static void

Modified: head/sys/dev/nvme/nvme_sim.c
==
--- head/sys/dev/nvme/nvme_sim.cFri Jun  7 18:23:29 2019
(r348785)
+++ head/sys/dev/nvme/nvme_sim.cFri Jun  7 18:34:48 2019
(r348786)
@@ -212,7 +212,7 @@ nvme_sim_action(struct cam_sim *sim, union ccb *ccb)
struct ccb_trans_settings_nvme  *nvmep;
struct ccb_trans_settings_nvme  *nvmex;
device_t dev;
-   uint32_t status, caps;
+   uint32_t status, caps, flags;
 
dev = ctrlr->dev;
cts = &ccb->cts;
@@ -221,12 +221,16 @@ nvme_sim_action(struct cam_sim *sim, union ccb *ccb)
 
status = pcie_read_config(dev, PCIER_LINK_STA, 2);
caps = pcie_read_config(dev, PCIER_LINK_CAP, 2);
-   nvmex->valid = CTS_NVME_VALID_SPEC | CTS_NVME_VALID_LINK;
+   flags = pcie_read_config(dev, PCIER_FLAGS, 2);
nvmex->spec = nvme_mmio_read_4(ctrlr, vs);
-   nvmex->speed = status & PCIEM_LINK_STA_SPEED;
-   nvmex->lanes = (status & PCIEM_LINK_STA_WIDTH) >> 4;
-   nvmex->max_speed = caps & PCIEM_LINK_CAP_MAX_SPEED;
-   nvmex->max_lanes = (caps & PCIEM_LINK_CAP_MAX_WIDTH) >> 4;
+   nvmex->valid = CTS_NVME_VALID_SPEC;
+   if ((flags & PCIEM_FLAGS_TYPE) == PCIEM_TYPE_ENDPOINT) {
+   nvmex->valid |= CTS_NVME_VALID_LINK;
+   nvmex->speed = status & PCIEM_LINK_STA_SPEED;
+   nvmex->lanes = (status & PCIEM_LINK_STA_WIDTH) >> 4;
+   nvmex->max_speed = caps & PCIEM_LINK_CAP_MAX_SPEED;
+   nvmex->max_lanes = (caps & PCIEM_LINK_CAP_MAX_WIDTH) >> 
4;
+   }
 
/* XXX these should be something else maybe ? */
nvmep->valid = 1;
___
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: r348788 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-06-07 Thread Alexander Motin
Author: mav
Date: Fri Jun  7 19:03:17 2019
New Revision: 348788
URL: https://svnweb.freebsd.org/changeset/base/348788

Log:
  Explicitly start ARC adjustment on limits change.
  
  While formally it is not necessary, but the sooner it start, the sooner it
  finish, and supposedly less disturbing for workload it will be.
  
  MFC after:2 weeks

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Fri Jun  7 
18:52:36 2019(r348787)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Fri Jun  7 
19:03:17 2019(r348788)
@@ -1233,6 +1233,12 @@ sysctl_vfs_zfs_arc_meta_limit(SYSCTL_HANDLER_ARGS)
return (EINVAL);
 
arc_meta_limit = val;
+
+   mutex_enter(&arc_adjust_lock);
+   arc_adjust_needed = B_TRUE;
+   mutex_exit(&arc_adjust_lock);
+   zthr_wakeup(arc_adjust_zthr);
+
return (0);
 }
 
@@ -1293,6 +1299,11 @@ sysctl_vfs_zfs_arc_max(SYSCTL_HANDLER_ARGS)
arc_c = arc_c / 2;
 
zfs_arc_max = arc_c;
+
+   mutex_enter(&arc_adjust_lock);
+   arc_adjust_needed = B_TRUE;
+   mutex_exit(&arc_adjust_lock);
+   zthr_wakeup(arc_adjust_zthr);
 
return (0);
 }
___
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: r348790 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-06-07 Thread Alexander Motin
Author: mav
Date: Fri Jun  7 20:59:24 2019
New Revision: 348790
URL: https://svnweb.freebsd.org/changeset/base/348790

Log:
  Fix comparison signedness in arc_is_overflowing().
  
  When ARC size is very small, aggsum_lower_bound(&arc_size) may return
  negative values, that due to unsigned comparison caused delays, waiting
  for arc_adjust() to "fix" it by calling aggsum_value(&arc_size).  Use
  of signed comparison there fixes the problem.
  
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Fri Jun  7 
20:43:34 2019(r348789)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Fri Jun  7 
20:59:24 2019(r348790)
@@ -5140,7 +5140,7 @@ static boolean_t
 arc_is_overflowing(void)
 {
/* Always allow at least one block of overflow */
-   uint64_t overflow = MAX(SPA_MAXBLOCKSIZE,
+   int64_t overflow = MAX(SPA_MAXBLOCKSIZE,
arc_c >> zfs_arc_overflow_shift);
 
/*
@@ -5152,7 +5152,7 @@ arc_is_overflowing(void)
 * in the ARC. In practice, that's in the tens of MB, which is low
 * enough to be safe.
 */
-   return (aggsum_lower_bound(&arc_size) >= arc_c + overflow);
+   return (aggsum_lower_bound(&arc_size) >= (int64_t)arc_c + overflow);
 }
 
 static abd_t *
___
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: r348791 - head/sys/dev/cxgbe/tom

2019-06-07 Thread John Baldwin
Author: jhb
Date: Fri Jun  7 21:30:11 2019
New Revision: 348791
URL: https://svnweb.freebsd.org/changeset/base/348791

Log:
  Fix debug trace after removal of pdu_overhead.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/tom/t4_tls.c

Modified: head/sys/dev/cxgbe/tom/t4_tls.c
==
--- head/sys/dev/cxgbe/tom/t4_tls.c Fri Jun  7 20:59:24 2019
(r348790)
+++ head/sys/dev/cxgbe/tom/t4_tls.c Fri Jun  7 21:30:11 2019
(r348791)
@@ -1585,8 +1585,8 @@ do_rx_tls_cmp(struct sge_iq *iq, const struct rss_head
sbappendstream_locked(sb, m, 0);
rx_credits = sbspace(sb) > tp->rcv_wnd ? sbspace(sb) - tp->rcv_wnd : 0;
 #ifdef VERBOSE_TRACES
-   CTR5(KTR_CXGBE, "%s: tid %u PDU overhead %d rx_credits %u rcv_wnd %u",
-   __func__, tid, pdu_overhead, rx_credits, tp->rcv_wnd);
+   CTR4(KTR_CXGBE, "%s: tid %u rx_credits %u rcv_wnd %u",
+   __func__, tid, rx_credits, tp->rcv_wnd);
 #endif
if (rx_credits > 0 && sbused(sb) + tp->rcv_wnd < sb->sb_lowat) {
rx_credits = send_rx_credits(sc, toep, rx_credits);
___
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: r348794 - head/sys/powerpc/aim

2019-06-07 Thread Justin Hibbits
Author: jhibbits
Date: Sat Jun  8 02:36:07 2019
New Revision: 348794
URL: https://svnweb.freebsd.org/changeset/base/348794

Log:
  powerpc/aim: Use nitems() for calculating size of phys_avail in AIM pmaps
  
  Same thing was already done in r347164 for Book-E pmap.

Modified:
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea.c
==
--- head/sys/powerpc/aim/mmu_oea.c  Sat Jun  8 02:30:16 2019
(r348793)
+++ head/sys/powerpc/aim/mmu_oea.c  Sat Jun  8 02:36:07 2019
(r348794)
@@ -749,7 +749,7 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm
} while (pa < end);
}
 
-   if (sizeof(phys_avail)/sizeof(phys_avail[0]) < regions_sz)
+   if (nitems(phys_avail) < regions_sz)
panic("moea_bootstrap: phys_avail too small");
 
phys_avail_count = 0;

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cSat Jun  8 02:30:16 2019
(r348793)
+++ head/sys/powerpc/aim/mmu_oea64.cSat Jun  8 02:36:07 2019
(r348794)
@@ -768,7 +768,7 @@ moea64_early_bootstrap(mmu_t mmup, vm_offset_t kernels
mem_regions(&pregions, &pregions_sz, ®ions, ®ions_sz);
CTR0(KTR_PMAP, "moea64_bootstrap: physical memory");
 
-   if (sizeof(phys_avail)/sizeof(phys_avail[0]) < regions_sz)
+   if (nitems(phys_avail) < regions_sz)
panic("moea64_bootstrap: phys_avail too small");
 
phys_avail_count = 0;
___
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: r348795 - in head/sys/powerpc: aim include powerpc

2019-06-07 Thread Justin Hibbits
Author: jhibbits
Date: Sat Jun  8 03:07:08 2019
New Revision: 348795
URL: https://svnweb.freebsd.org/changeset/base/348795

Log:
  powerpc/pmap: Move the SLB spill handlers to a better place
  
  The SLB spill handlers are AIM-specific, and belong better with the rest of
  the SLB code anyway.  No functional change.

Modified:
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/include/slb.h
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/aim/slb.c
==
--- head/sys/powerpc/aim/slb.c  Sat Jun  8 02:36:07 2019(r348794)
+++ head/sys/powerpc/aim/slb.c  Sat Jun  8 03:07:08 2019(r348795)
@@ -47,7 +47,10 @@
 #include 
 #include 
 #include 
+#include 
 
+#include "mmu_oea64.h"
+
 uintptr_t moea64_get_unique_vsid(void);
 void moea64_release_vsid(uint64_t vsid);
 static void slb_zone_init(void *);
@@ -540,3 +543,86 @@ slb_free_user_cache(struct slb **slb)
 {
uma_zfree(slb_cache_zone, slb);
 }
+
+#if defined(__powerpc64__)
+/* Handle kernel SLB faults -- runs in real mode, all seat belts off */
+void
+handle_kernel_slb_spill(int type, register_t dar, register_t srr0)
+{
+   struct slb *slbcache;
+   uint64_t slbe, slbv;
+   uint64_t esid, addr;
+   int i;
+
+   addr = (type == EXC_ISE) ? srr0 : dar;
+   slbcache = PCPU_GET(aim.slb);
+   esid = (uintptr_t)addr >> ADDR_SR_SHFT;
+   slbe = (esid << SLBE_ESID_SHIFT) | SLBE_VALID;
+   
+   /* See if the hardware flushed this somehow (can happen in LPARs) */
+   for (i = 0; i < n_slbs; i++)
+   if (slbcache[i].slbe == (slbe | (uint64_t)i))
+   return;
+
+   /* Not in the map, needs to actually be added */
+   slbv = kernel_va_to_slbv(addr);
+   if (slbcache[USER_SLB_SLOT].slbe == 0) {
+   for (i = 0; i < n_slbs; i++) {
+   if (i == USER_SLB_SLOT)
+   continue;
+   if (!(slbcache[i].slbe & SLBE_VALID))
+   goto fillkernslb;
+   }
+
+   if (i == n_slbs)
+   slbcache[USER_SLB_SLOT].slbe = 1;
+   }
+
+   /* Sacrifice a random SLB entry that is not the user entry */
+   i = mftb() % n_slbs;
+   if (i == USER_SLB_SLOT)
+   i = (i+1) % n_slbs;
+
+fillkernslb:
+   /* Write new entry */
+   slbcache[i].slbv = slbv;
+   slbcache[i].slbe = slbe | (uint64_t)i;
+
+   /* Trap handler will restore from cache on exit */
+}
+
+int 
+handle_user_slb_spill(pmap_t pm, vm_offset_t addr)
+{
+   struct slb *user_entry;
+   uint64_t esid;
+   int i;
+
+   if (pm->pm_slb == NULL)
+   return (-1);
+
+   esid = (uintptr_t)addr >> ADDR_SR_SHFT;
+
+   PMAP_LOCK(pm);
+   user_entry = user_va_to_slb_entry(pm, addr);
+
+   if (user_entry == NULL) {
+   /* allocate_vsid auto-spills it */
+   (void)allocate_user_vsid(pm, esid, 0);
+   } else {
+   /*
+* Check that another CPU has not already mapped this.
+* XXX: Per-thread SLB caches would be better.
+*/
+   for (i = 0; i < pm->pm_slb_len; i++)
+   if (pm->pm_slb[i] == user_entry)
+   break;
+
+   if (i == pm->pm_slb_len)
+   slb_insert_user(pm, user_entry);
+   }
+   PMAP_UNLOCK(pm);
+
+   return (0);
+}
+#endif

Modified: head/sys/powerpc/include/slb.h
==
--- head/sys/powerpc/include/slb.h  Sat Jun  8 02:36:07 2019
(r348794)
+++ head/sys/powerpc/include/slb.h  Sat Jun  8 03:07:08 2019
(r348795)
@@ -79,4 +79,8 @@ struct slb {
uint64_tslbe;
 };
 
+struct pmap;
+void   handle_kernel_slb_spill(int, register_t, register_t);
+inthandle_user_slb_spill(struct pmap *pm, vm_offset_t addr);
+
 #endif /* !_MACHINE_SLB_H_ */

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Sat Jun  8 02:36:07 2019
(r348794)
+++ head/sys/powerpc/powerpc/trap.c Sat Jun  8 03:07:08 2019
(r348795)
@@ -69,9 +69,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
+#include 
 
 /* Below matches setjmp.S */
 #defineFAULTBUF_LR 21
@@ -92,9 +93,6 @@ static inthandle_onfault(struct trapframe *frame);
 static voidsyscall(struct trapframe *frame);
 
 #if defined(__powerpc64__) && defined(AIM)
-   voidhandle_kernel_slb_spill(int, register_t, register_t);
-static int handle_user_slb_spill(pmap_t pm, vm_offset_t addr);
-extern int n_slbs;
 static voidnormalize_inputs(void);
 #endif
 
@@ -720,89 +718,6 @@ syscall(struct trapframe *frame)