svn commit: r259218 - in head/sys/dev/usb: . controller template

2013-12-11 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Dec 11 13:20:32 2013
New Revision: 259218
URL: http://svnweb.freebsd.org/changeset/base/259218

Log:
  USB method structures for USB controllers and USB pipes should be
  constant and does not need to be modified. This also saves a small
  amount of RAM.

Modified:
  head/sys/dev/usb/controller/at91dci.c
  head/sys/dev/usb/controller/atmegadci.c
  head/sys/dev/usb/controller/avr32dci.c
  head/sys/dev/usb/controller/dwc_otg.c
  head/sys/dev/usb/controller/ehci.c
  head/sys/dev/usb/controller/musb_otg.c
  head/sys/dev/usb/controller/ohci.c
  head/sys/dev/usb/controller/uhci.c
  head/sys/dev/usb/controller/uss820dci.c
  head/sys/dev/usb/controller/xhci.c
  head/sys/dev/usb/template/usb_template.c
  head/sys/dev/usb/usb_bus.h
  head/sys/dev/usb/usb_device.c
  head/sys/dev/usb/usb_device.h
  head/sys/dev/usb/usb_hub.c
  head/sys/dev/usb/usb_transfer.c
  head/sys/dev/usb/usbdi.h

Modified: head/sys/dev/usb/controller/at91dci.c
==
--- head/sys/dev/usb/controller/at91dci.c   Wed Dec 11 08:46:18 2013
(r259217)
+++ head/sys/dev/usb/controller/at91dci.c   Wed Dec 11 13:20:32 2013
(r259218)
@@ -103,11 +103,11 @@ SYSCTL_INT(_hw_usb_at91dci, OID_AUTO, de
 
 /* prototypes */
 
-struct usb_bus_methods at91dci_bus_methods;
-struct usb_pipe_methods at91dci_device_bulk_methods;
-struct usb_pipe_methods at91dci_device_ctrl_methods;
-struct usb_pipe_methods at91dci_device_intr_methods;
-struct usb_pipe_methods at91dci_device_isoc_fs_methods;
+static const struct usb_bus_methods at91dci_bus_methods;
+static const struct usb_pipe_methods at91dci_device_bulk_methods;
+static const struct usb_pipe_methods at91dci_device_ctrl_methods;
+static const struct usb_pipe_methods at91dci_device_intr_methods;
+static const struct usb_pipe_methods at91dci_device_isoc_fs_methods;
 
 static at91dci_cmd_t at91dci_setup_rx;
 static at91dci_cmd_t at91dci_data_rx;
@@ -1515,7 +1515,7 @@ at91dci_device_bulk_start(struct usb_xfe
at91dci_start_standard_chain(xfer);
 }
 
-struct usb_pipe_methods at91dci_device_bulk_methods =
+static const struct usb_pipe_methods at91dci_device_bulk_methods =
 {
.open = at91dci_device_bulk_open,
.close = at91dci_device_bulk_close,
@@ -1552,7 +1552,7 @@ at91dci_device_ctrl_start(struct usb_xfe
at91dci_start_standard_chain(xfer);
 }
 
-struct usb_pipe_methods at91dci_device_ctrl_methods =
+static const struct usb_pipe_methods at91dci_device_ctrl_methods =
 {
.open = at91dci_device_ctrl_open,
.close = at91dci_device_ctrl_close,
@@ -1589,7 +1589,7 @@ at91dci_device_intr_start(struct usb_xfe
at91dci_start_standard_chain(xfer);
 }
 
-struct usb_pipe_methods at91dci_device_intr_methods =
+static const struct usb_pipe_methods at91dci_device_intr_methods =
 {
.open = at91dci_device_intr_open,
.close = at91dci_device_intr_close,
@@ -1671,7 +1671,7 @@ at91dci_device_isoc_fs_start(struct usb_
at91dci_start_standard_chain(xfer);
 }
 
-struct usb_pipe_methods at91dci_device_isoc_fs_methods =
+static const struct usb_pipe_methods at91dci_device_isoc_fs_methods =
 {
.open = at91dci_device_isoc_fs_open,
.close = at91dci_device_isoc_fs_close,
@@ -2318,7 +2318,7 @@ at91dci_set_hw_power_sleep(struct usb_bu
}
 }
 
-struct usb_bus_methods at91dci_bus_methods =
+static const struct usb_bus_methods at91dci_bus_methods =
 {
.endpoint_init = at91dci_ep_init,
.xfer_setup = at91dci_xfer_setup,

Modified: head/sys/dev/usb/controller/atmegadci.c
==
--- head/sys/dev/usb/controller/atmegadci.c Wed Dec 11 08:46:18 2013
(r259217)
+++ head/sys/dev/usb/controller/atmegadci.c Wed Dec 11 13:20:32 2013
(r259218)
@@ -96,9 +96,9 @@ SYSCTL_INT(_hw_usb_atmegadci, OID_AUTO, 
 
 /* prototypes */
 
-struct usb_bus_methods atmegadci_bus_methods;
-struct usb_pipe_methods atmegadci_device_non_isoc_methods;
-struct usb_pipe_methods atmegadci_device_isoc_fs_methods;
+static const struct usb_bus_methods atmegadci_bus_methods;
+static const struct usb_pipe_methods atmegadci_device_non_isoc_methods;
+static const struct usb_pipe_methods atmegadci_device_isoc_fs_methods;
 
 static atmegadci_cmd_t atmegadci_setup_rx;
 static atmegadci_cmd_t atmegadci_data_rx;
@@ -1410,7 +1410,7 @@ atmegadci_device_non_isoc_start(struct u
atmegadci_start_standard_chain(xfer);
 }
 
-struct usb_pipe_methods atmegadci_device_non_isoc_methods =
+static const struct usb_pipe_methods atmegadci_device_non_isoc_methods =
 {
.open = atmegadci_device_non_isoc_open,
.close = atmegadci_device_non_isoc_close,
@@ -1496,7 +1496,7 @@ atmegadci_device_isoc_fs_start(struct us
atmegadci_start_standard_chain(xfer);
 }
 
-struct usb_pipe_methods atmegadci_device_isoc_fs_methods =
+static const struct usb_pipe_methods 

svn commit: r259219 - head/usr.bin/calendar

2013-12-11 Thread Eitan Adler
Author: eadler
Date: Wed Dec 11 14:54:58 2013
New Revision: 259219
URL: http://svnweb.freebsd.org/changeset/base/259219

Log:
  calendar(1): use strlcpy instead of strncpy
  
  use strlcpy instead of strncpy which avoids non-null-termination if the 
string is MAXPATHLEN bytes or longer.

Modified:
  head/usr.bin/calendar/calcpp.c

Modified: head/usr.bin/calendar/calcpp.c
==
--- head/usr.bin/calendar/calcpp.c  Wed Dec 11 13:20:32 2013
(r259218)
+++ head/usr.bin/calendar/calcpp.c  Wed Dec 11 14:54:58 2013
(r259219)
@@ -133,7 +133,7 @@ tokenscpp(char *buf, char *string)
s = p;
while(!isspace((unsigned char)*p))
p++;
-   strncpy(string, s, MAXPATHLEN);
+   strlcpy(string, s, MAXPATHLEN);
return(T_DEFINE);
} else if ((p = strstr(buf, #ifndef)) != NULL) {
p += 8;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r259220 - head/sys/arm/at91

2013-12-11 Thread Warner Losh
Author: imp
Date: Wed Dec 11 15:32:28 2013
New Revision: 259220
URL: http://svnweb.freebsd.org/changeset/base/259220

Log:
  Loose - Lose so this sentence makes sense.
  
  MFC after:3 days

Modified:
  head/sys/arm/at91/if_ate.c

Modified: head/sys/arm/at91/if_ate.c
==
--- head/sys/arm/at91/if_ate.c  Wed Dec 11 14:54:58 2013(r259219)
+++ head/sys/arm/at91/if_ate.c  Wed Dec 11 15:32:28 2013(r259220)
@@ -1144,7 +1144,7 @@ atestart_locked(struct ifnet *ifp)
/*
 * There's a small race between the loop in ate_intr finishing
 * and the check above to see if the packet was finished, as 
well
-* as when atestart gets called via other paths. Loose the race
+* as when atestart gets called via other paths. Lose the race
 * gracefully and free the mbuf...
 */
if (sc-sent_mbuf[sc-txhead] != NULL) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r259221 - head/sys/dev/vt

2013-12-11 Thread George V. Neville-Neil
Author: gnn
Date: Wed Dec 11 17:18:10 2013
New Revision: 259221
URL: http://svnweb.freebsd.org/changeset/base/259221

Log:
  Fix a panic when booting with kernels that have FREEBBSD_COMPAT
  4, 5, 6 or 43 by only thunking the data parameter for old ioctls
  compatability ioctls instead of doing it for all of them.
  
  Submitted by: jhb@

Modified:
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/vt_core.c
==
--- head/sys/dev/vt/vt_core.c   Wed Dec 11 15:32:28 2013(r259220)
+++ head/sys/dev/vt/vt_core.c   Wed Dec 11 17:18:10 2013(r259221)
@@ -1321,9 +1321,12 @@ vtterm_ioctl(struct terminal *tm, u_long
case _IO('c', 110):
cmd = CONS_SETKBD;
break;
+   default:
+   goto skip_thunk;
}
ival = IOCPARM_IVAL(data);
data = (caddr_t)ival;
+skip_thunk:
 #endif
 
switch (cmd) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r259222 - head/sys/dev/ahci

2013-12-11 Thread Alexander Motin
Author: mav
Date: Wed Dec 11 17:40:35 2013
New Revision: 259222
URL: http://svnweb.freebsd.org/changeset/base/259222

Log:
  Destroy mtx lock when failed to allocate memory during attach.
  
  Submitted by: Dmitry Luhtionov dmitryluhtio...@gmail.com
  MFC after:2 weeks

Modified:
  head/sys/dev/ahci/ahciem.c

Modified: head/sys/dev/ahci/ahciem.c
==
--- head/sys/dev/ahci/ahciem.c  Wed Dec 11 17:18:10 2013(r259221)
+++ head/sys/dev/ahci/ahciem.c  Wed Dec 11 17:40:35 2013(r259222)
@@ -85,8 +85,10 @@ ahci_em_attach(device_t dev)
mtx_init(enc-mtx, AHCI enclosure lock, NULL, MTX_DEF);
rid = 0;
if (!(enc-r_memc = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
-   rid, RF_ACTIVE)))
+   rid, RF_ACTIVE))) {
+   mtx_destroy(enc-mtx);
return (ENXIO);
+   }
enc-capsem = ATA_INL(enc-r_memc, 0);
rid = 1;
if (!(enc-r_memt = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r259228 - in head/sys/x86: include x86

2013-12-11 Thread John Baldwin
Author: jhb
Date: Wed Dec 11 21:19:04 2013
New Revision: 259228
URL: http://svnweb.freebsd.org/changeset/base/259228

Log:
  Use fixed-width types for all fields in MP Table structures and pack
  all the structures.  While here, move a helper struct only used in
  the kernel parser out of this header since it is not part of the MP
  specification itself.

Modified:
  head/sys/x86/include/mptable.h
  head/sys/x86/x86/mptable.c

Modified: head/sys/x86/include/mptable.h
==
--- head/sys/x86/include/mptable.h  Wed Dec 11 20:56:23 2013
(r259227)
+++ head/sys/x86/include/mptable.h  Wed Dec 11 21:19:04 2013
(r259228)
@@ -30,47 +30,50 @@
 
 enum busTypes {
 NOBUS = 0,
+CBUS = 1,
+CBUSII = 2,
 EISA = 3,
 ISA = 6,
 MCA = 9,
 PCI = 13,
+XPRESS = 18,
 MAX_BUSTYPE = 18,
 UNKNOWN_BUSTYPE = 0xff
 };
 
 /* MP Floating Pointer Structure */
 typedef struct MPFPS {
-   charsignature[4];
-   u_int32_t pap;
-   u_char  length;
-   u_char  spec_rev;
-   u_char  checksum;
-   u_char  config_type;
-   u_char  mpfb2;
-   u_char  mpfb3;
-   u_char  mpfb4;
-   u_char  mpfb5;
-}  *mpfps_t;
+   uint8_t signature[4];
+   uint32_t pap;
+   uint8_t length;
+   uint8_t spec_rev;
+   uint8_t checksum;
+   uint8_t config_type;
+   uint8_t mpfb2;
+   uint8_t mpfb3;
+   uint8_t mpfb4;
+   uint8_t mpfb5;
+} __packed *mpfps_t;
 
 #defineMPFB2_IMCR_PRESENT  0x80
 #defineMPFB2_MUL_CLK_SRCS  0x40
 
 /* MP Configuration Table Header */
 typedef struct MPCTH {
-   charsignature[4];
-   u_short base_table_length;
-   u_char  spec_rev;
-   u_char  checksum;
-   u_char  oem_id[8];
-   u_char  product_id[12];
-   u_int32_t oem_table_pointer;
-   u_short oem_table_size;
-   u_short entry_count;
-   u_int32_t apic_address;
-   u_short extended_table_length;
-   u_char  extended_table_checksum;
-   u_char  reserved;
-}  *mpcth_t;
+   uint8_t signature[4];
+   uint16_t base_table_length;
+   uint8_t spec_rev;
+   uint8_t checksum;
+   uint8_t oem_id[8];
+   uint8_t product_id[12];
+   uint32_t oem_table_pointer;
+   uint16_t oem_table_size;
+   uint16_t entry_count;
+   uint32_t apic_address;
+   uint16_t extended_table_length;
+   uint8_t extended_table_checksum;
+   uint8_t reserved;
+} __packed *mpcth_t;
 
 /* Base table entries */
 
@@ -81,44 +84,44 @@ typedef struct MPCTH {
 #defineMPCT_ENTRY_LOCAL_INT4
 
 typedef struct PROCENTRY {
-   u_char  type;
-   u_char  apic_id;
-   u_char  apic_version;
-   u_char  cpu_flags;
-   u_int32_t cpu_signature;
-   u_int32_t feature_flags;
-   u_int32_t reserved1;
-   u_int32_t reserved2;
-}  *proc_entry_ptr;
+   uint8_t type;
+   uint8_t apic_id;
+   uint8_t apic_version;
+   uint8_t cpu_flags;
+   uint32_t cpu_signature;
+   uint32_t feature_flags;
+   uint32_t reserved1;
+   uint32_t reserved2;
+} __packed *proc_entry_ptr;
 
 #define PROCENTRY_FLAG_EN  0x01
 #define PROCENTRY_FLAG_BP  0x02
 
 typedef struct BUSENTRY {
-   u_char  type;
-   u_char  bus_id;
-   charbus_type[6];
-}  *bus_entry_ptr;
+   uint8_t type;
+   uint8_t bus_id;
+   uint8_t bus_type[6];
+} __packed *bus_entry_ptr;
 
 typedef struct IOAPICENTRY {
-   u_char  type;
-   u_char  apic_id;
-   u_char  apic_version;
-   u_char  apic_flags;
-   u_int32_t apic_address;
-}  *io_apic_entry_ptr;
+   uint8_t type;
+   uint8_t apic_id;
+   uint8_t apic_version;
+   uint8_t apic_flags;
+   uint32_t apic_address;
+} __packed *io_apic_entry_ptr;
 
 #define IOAPICENTRY_FLAG_EN0x01
 
 typedef struct INTENTRY {
-   u_char  type;
-   u_char  int_type;
-   u_short int_flags;
-   u_char  src_bus_id;
-   u_char  src_bus_irq;
-   u_char  dst_apic_id;
-   u_char  dst_apic_int;
-}  *int_entry_ptr;
+   uint8_t type;
+   uint8_t int_type;
+   uint16_t int_flags;
+   uint8_t src_bus_id;
+   uint8_t src_bus_irq;
+   uint8_t dst_apic_id;
+   uint8_t dst_apic_int;
+} __packed *int_entry_ptr;
 
 #defineINTENTRY_TYPE_INT   0
 #defineINTENTRY_TYPE_NMI   1
@@ -137,45 +140,45 @@ typedef struct INTENTRY {
 /* Extended table entries */
 
 typedefstruct EXTENTRY {
-   u_char  type;
-   u_char  length;
-}  *ext_entry_ptr;
+   uint8_t type;
+   uint8_t length;
+} __packed *ext_entry_ptr;
 
 #defineMPCT_EXTENTRY_SAS   0x80
 #defineMPCT_EXTENTRY_BHD   0x81
 #defineMPCT_EXTENTRY_CBASM 0x82
 
 typedef struct SASENTRY {
-   u_char  type;
-   u_char  length;
-   u_char  bus_id;
-   u_char  address_type;
+

svn commit: r259229 - head/usr.sbin/mptable

2013-12-11 Thread John Baldwin
Author: jhb
Date: Wed Dec 11 21:21:03 2013
New Revision: 259229
URL: http://svnweb.freebsd.org/changeset/base/259229

Log:
  - Use x86/mptable.h instead of duplicating its definitions.
  - Switch to mmaping the table from RAM instead of reading it out of
/dev/mem via read(2).

Modified:
  head/usr.sbin/mptable/mptable.c

Modified: head/usr.sbin/mptable/mptable.c
==
--- head/usr.sbin/mptable/mptable.c Wed Dec 11 21:19:04 2013
(r259228)
+++ head/usr.sbin/mptable/mptable.c Wed Dec 11 21:21:03 2013
(r259229)
@@ -43,9 +43,12 @@ static const char rcsid[] =
 #define OEM_PROCESSING_READY_NOT
 
 #include sys/param.h
+#include sys/mman.h
+#include x86/mptable.h
 #include err.h
 #include fcntl.h
 #include paths.h
+#include stdint.h
 #include stdio.h
 #include stdlib.h
 #include string.h
@@ -74,23 +77,8 @@ static const char rcsid[] =
 #define GROPE_AREA20x9
 #define GROPE_SIZE 0x1
 
-#define PROCENTRY_FLAG_EN  0x01
-#define PROCENTRY_FLAG_BP  0x02
-#define IOAPICENTRY_FLAG_EN0x01
-
 #define MAXPNSTR   132
 
-enum busTypes {
-CBUS = 1,
-CBUSII = 2,
-EISA = 3,
-ISA = 6,
-PCI = 13,
-XPRESS = 18,
-MAX_BUSTYPE = 18,
-UNKNOWN_BUSTYPE = 0xff
-};
-
 typedef struct BUSTYPENAME {
 u_char type;
 char   name[ 7 ];
@@ -129,140 +117,25 @@ static const char *whereStrings[] = {
 GROPE AREA #2
 };
 
-typedef struct TABLE_ENTRY {
-u_char type;
-u_char length;
-char   name[ 32 ];
-} tableEntry;
-
-static const tableEntry extendedtableEntryTypes[] =
-{
-{ 128, 20, System Address Space },
-{ 129,  8, Bus Hierarchy },
-{ 130,  8, Compatibility Bus Address }
-};
-
-/* MP Floating Pointer Structure */
-typedef struct MPFPS {
-char   signature[ 4 ];
-u_int32_t  pap;
-u_char length;
-u_char spec_rev;
-u_char checksum;
-u_char mpfb1;
-u_char mpfb2;
-u_char mpfb3;
-u_char mpfb4;
-u_char mpfb5;
-} mpfps_t;
-
-/* MP Configuration Table Header */
-typedef struct MPCTH {
-char   signature[ 4 ];
-u_shortbase_table_length;
-u_char spec_rev;
-u_char checksum;
-u_char oem_id[ 8 ];
-u_char product_id[ 12 ];
-u_int32_t  oem_table_pointer;
-u_shortoem_table_size;
-u_shortentry_count;
-u_int32_t  apic_address;
-u_shortextended_table_length;
-u_char extended_table_checksum;
-u_char reserved;
-} mpcth_t;
-
-
-typedef struct PROCENTRY {
-u_char type;
-u_char apicID;
-u_char apicVersion;
-u_char cpuFlags;
-u_int32_t  cpuSignature;
-u_int32_t  featureFlags;
-u_int32_t  reserved1;
-u_int32_t  reserved2;
-} ProcEntry;
-
-typedef struct BUSENTRY {
-u_char type;
-u_char busID;
-char   busType[ 6 ];
-} BusEntry;
-
-typedef struct IOAPICENTRY {
-u_char type;
-u_char apicID;
-u_char apicVersion;
-u_char apicFlags;
-u_int32_t  apicAddress;
-} IOApicEntry;
-
-typedef struct INTENTRY {
-u_char type;
-u_char intType;
-u_shortintFlags;
-u_char srcBusID;
-u_char srcBusIRQ;
-u_char dstApicID;
-u_char dstApicINT;
-} IntEntry;
-
-
-/*
- * extended entry type structures
- */
-
-typedef struct SASENTRY {
-u_char type;
-u_char length;
-u_char busID;
-u_char addressType;
-u_int64_t  addressBase;
-u_int64_t  addressLength;
-} __attribute__((__packed__)) SasEntry;
-
-
-typedef struct BHDENTRY {
-u_char type;
-u_char length;
-u_char busID;
-u_char busInfo;
-u_char busParent;
-u_char reserved[ 3 ];
-} BhdEntry;
-
-
-typedef struct CBASMENTRY {
-u_char type;
-u_char length;
-u_char busID;
-u_char addressMod;
-u_int  predefinedRange;
-} CbasmEntry;
-
-
-
 static void apic_probe( u_int32_t* paddr, int* where );
 
 static void MPConfigDefault( int featureByte );
 
-static void MPFloatingPointer( u_int32_t paddr, int where, mpfps_t* mpfps );
+static void MPFloatingPointer( u_int32_t paddr, int where, mpfps_t* mpfpsp );
 static void MPConfigTableHeader( u_int32_t pap );
 
-static int readType( void );
 static void seekEntry( u_int32_t addr );
 static void readEntry( void* entry, int size );
+static void *mapEntry( u_int32_t addr, int size );
 
-static void processorEntry( void );
-static void busEntry( void );
-static void ioApicEntry( void );
-static void intEntry( void );
-
-static void sasEntry( void );
-static void bhdEntry( void );
-static void cbasmEntry( void );
+static void processorEntry( proc_entry_ptr entry );
+static void busEntry( bus_entry_ptr entry );
+static void ioApicEntry( io_apic_entry_ptr entry );
+static void intEntry( int_entry_ptr entry );
+
+static void sasEntry( 

svn commit: r259232 - head/sys/kern

2013-12-11 Thread Alexander Motin
Author: mav
Date: Wed Dec 11 21:48:04 2013
New Revision: 259232
URL: http://svnweb.freebsd.org/changeset/base/259232

Log:
  Create own free list for each of the first 32 possible allocation sizes.
  In case of 4K allocation quantum that means for allocations up to 128K.
  
  With growth of memory fragmentation these lists may grow to quite a large
  sizes (tenths and hundreds of thousands items).  Having in one list items
  of different sizes in worst case may require full linear list traversal,
  that may be very expensive.  Having lists for items of single size means
  that unless user specify some alignment or border requirements (that are
  very rare cases) first item found on the list should satisfy the request.
  
  While running SPEC NFS benchmark on top of ZFS on 24-core machine with
  84GB RAM this change reduces CPU time spent in vmem_xalloc() from 8%
  and lock congestion spinning around it from 20% to invisible levels.
  And that all is by the cost of just 26 more pointers per vmem instance.
  
  If at some point our kernel will start to actively use KVA allocations
  with odd sizes above 128K, something may need to be done to bigger lists
  also.

Modified:
  head/sys/kern/subr_vmem.c

Modified: head/sys/kern/subr_vmem.c
==
--- head/sys/kern/subr_vmem.c   Wed Dec 11 21:41:21 2013(r259231)
+++ head/sys/kern/subr_vmem.c   Wed Dec 11 21:48:04 2013(r259232)
@@ -70,7 +70,10 @@ __FBSDID($FreeBSD$);
 #include vm/vm_param.h
 #include vm/vm_pageout.h
 
-#defineVMEM_MAXORDER   (sizeof(vmem_size_t) * NBBY)
+#defineVMEM_OPTORDER   5
+#defineVMEM_OPTVALUE   (1  VMEM_OPTORDER)
+#defineVMEM_MAXORDER   \
+(VMEM_OPTVALUE - 1 + sizeof(vmem_size_t) * NBBY - VMEM_OPTORDER)
 
 #defineVMEM_HASHSIZE_MIN   16
 #defineVMEM_HASHSIZE_MAX   131072
@@ -200,8 +203,10 @@ static LIST_HEAD(, vmem) vmem_list = LIS
 #defineVMEM_CROSS_P(addr1, addr2, boundary) \
addr1) ^ (addr2))  -(boundary)) != 0)
 
-#defineORDER2SIZE(order)   ((vmem_size_t)1  (order))
-#defineSIZE2ORDER(size)((int)flsl(size) - 1)
+#defineORDER2SIZE(order)   ((order)  VMEM_OPTVALUE ? ((order) + 
1) : \
+(vmem_size_t)1  ((order) - (VMEM_OPTVALUE - VMEM_OPTORDER - 1)))
+#defineSIZE2ORDER(size)((size) = VMEM_OPTVALUE ? ((size) - 1) 
: \
+(flsl(size) + (VMEM_OPTVALUE - VMEM_OPTORDER - 2)))
 
 /*
  * Maximum number of boundary tags that may be required to satisfy an
@@ -334,11 +339,14 @@ bt_free(vmem_t *vm, bt_t *bt)
 
 /*
  * freelist[0] ... [1, 1]
- * freelist[1] ... [2, 3]
- * freelist[2] ... [4, 7]
- * freelist[3] ... [8, 15]
+ * freelist[1] ... [2, 2]
  *  :
- * freelist[n] ... [(1  n), (1  (n + 1)) - 1]
+ * freelist[29] ... [30, 30]
+ * freelist[30] ... [31, 31]
+ * freelist[31] ... [32, 63]
+ * freelist[33] ... [64, 127]
+ *  :
+ * freelist[n] ... [(1  (n - 26)), (1  (n - 25)) - 1]
  *  :
  */
 
@@ -979,6 +987,7 @@ vmem_init(vmem_t *vm, const char *name, 
int i;
 
MPASS(quantum  0);
+   MPASS((quantum  (quantum - 1)) == 0);
 
bzero(vm, sizeof(*vm));
 
@@ -988,8 +997,7 @@ vmem_init(vmem_t *vm, const char *name, 
LIST_INIT(vm-vm_freetags);
strlcpy(vm-vm_name, name, sizeof(vm-vm_name));
vm-vm_quantum_mask = quantum - 1;
-   vm-vm_quantum_shift = SIZE2ORDER(quantum);
-   MPASS(ORDER2SIZE(vm-vm_quantum_shift) == quantum);
+   vm-vm_quantum_shift = flsl(quantum) - 1;
vm-vm_nbusytag = 0;
vm-vm_size = 0;
vm-vm_inuse = 0;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r259221 - head/sys/dev/vt

2013-12-11 Thread Aleksandr Rybalko
On Wed, 11 Dec 2013 17:18:10 + (UTC)
George V. Neville-Neil g...@freebsd.org wrote:

 Author: gnn
 Date: Wed Dec 11 17:18:10 2013
 New Revision: 259221
 URL: http://svnweb.freebsd.org/changeset/base/259221
 
 Log:
   Fix a panic when booting with kernels that have FREEBBSD_COMPAT
   4, 5, 6 or 43 by only thunking the data parameter for old ioctls
   compatability ioctls instead of doing it for all of them.
   
   Submitted by:   jhb@
 
 Modified:
   head/sys/dev/vt/vt_core.c
 
 Modified: head/sys/dev/vt/vt_core.c
 ==
 --- head/sys/dev/vt/vt_core.c Wed Dec 11 15:32:28 2013
 (r259220) +++ head/sys/dev/vt/vt_core.c   Wed Dec 11 17:18:10
 2013  (r259221) @@ -1321,9 +1321,12 @@ vtterm_ioctl(struct
 terminal *tm, u_long case _IO('c', 110):
   cmd = CONS_SETKBD;
   break;
 + default:
 + goto skip_thunk;
   }
   ival = IOCPARM_IVAL(data);
   data = (caddr_t)ival;
 +skip_thunk:
  #endif
  
   switch (cmd) {

Many thanks George and John!

Next time I will just copy old code instead of try to optimize it :-D

Thanks!

WBW
-- 
Aleksandr Rybalko r...@freebsd.org
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r259244 - head/sys/ia64/ia64

2013-12-11 Thread Marcel Moolenaar
Author: marcel
Date: Thu Dec 12 03:04:00 2013
New Revision: 259244
URL: http://svnweb.freebsd.org/changeset/base/259244

Log:
  Allow pmap_remove_pages() to be called for physical maps not
  associated with the current thread.
  
  Obtained from: alc@

Modified:
  head/sys/ia64/ia64/pmap.c

Modified: head/sys/ia64/ia64/pmap.c
==
--- head/sys/ia64/ia64/pmap.c   Thu Dec 12 02:04:59 2013(r259243)
+++ head/sys/ia64/ia64/pmap.c   Thu Dec 12 03:04:00 2013(r259244)
@@ -2103,19 +2103,16 @@ pmap_remove_pages(pmap_t pmap)
 {
struct pv_chunk *pc, *npc;
struct ia64_lpte *pte;
+   pmap_t oldpmap;
pv_entry_t pv;
vm_offset_t va;
vm_page_t m;
u_long inuse, bitmask;
int allfree, bit, field, idx;
 
-   if (pmap != vmspace_pmap(curthread-td_proc-p_vmspace)) {
-   printf(warning: %s called with non-current pmap\n,
-   __func__);
-   return;
-   }
rw_wlock(pvh_global_lock);
PMAP_LOCK(pmap);
+   oldpmap = pmap_switch(pmap);
TAILQ_FOREACH_SAFE(pc, pmap-pm_pvchunk, pc_list, npc) {
allfree = 1;
for (field = 0; field  _NPCM; field++) {
@@ -2155,8 +2152,9 @@ pmap_remove_pages(pmap_t pmap)
free_pv_chunk(pc);
}
}
-   rw_wunlock(pvh_global_lock);
+   pmap_switch(oldpmap);
PMAP_UNLOCK(pmap);
+   rw_wunlock(pvh_global_lock);
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r259245 - head/sys/powerpc/aim

2013-12-11 Thread Justin Hibbits
Author: jhibbits
Date: Thu Dec 12 04:12:19 2013
New Revision: 259245
URL: http://svnweb.freebsd.org/changeset/base/259245

Log:
  FBT now does work fully on PowerPC.
  
  MFC after:2 weeks

Modified:
  head/sys/powerpc/aim/trap.c
  head/sys/powerpc/aim/trap_subr32.S
  head/sys/powerpc/aim/trap_subr64.S

Modified: head/sys/powerpc/aim/trap.c
==
--- head/sys/powerpc/aim/trap.c Thu Dec 12 03:04:00 2013(r259244)
+++ head/sys/powerpc/aim/trap.c Thu Dec 12 04:12:19 2013(r259245)
@@ -297,7 +297,7 @@ trap(struct trapframe *frame)
 #ifdef KDTRACE_HOOKS
case EXC_PGM:
if (frame-srr1  EXC_PGM_TRAP) {
-   if (*(uintptr_t *)frame-srr0 == 0x7c810808) {
+   if (*(uint32_t *)frame-srr0 == 0x7c810808) {
if (dtrace_invop_jump_addr != NULL) {
dtrace_invop_jump_addr(frame);
return;

Modified: head/sys/powerpc/aim/trap_subr32.S
==
--- head/sys/powerpc/aim/trap_subr32.S  Thu Dec 12 03:04:00 2013
(r259244)
+++ head/sys/powerpc/aim/trap_subr32.S  Thu Dec 12 04:12:19 2013
(r259245)
@@ -883,8 +883,8 @@ CNAME(dblow):
mfcr%r29/* save CR in r29 */
mfsrr1  %r1
mtcr%r1
-   bf  17,1f   /* branch if privileged */
-
+   bf  17,2f   /* branch if privileged */
+1:
/* Unprivileged case */
mtcr%r29/* put the condition register back */
 mfsprg2%r29/* ... and r29 */
@@ -893,7 +893,17 @@ CNAME(dblow):
li  %r1, 0  /* How to get the vector from LR */
 
 bla generictrap/* and we look like a generic trap */
-1:
+2:
+#ifdef KDTRACE_HOOKS
+   /* Privileged, so drop to KDB */
+   mfsrr0  %r1
+   lwz %r4,0(%r1)
+   /* Check if it's a DTrace trap. */
+   li  %r3,0x0808
+   addis   %r3,%r3,0x7c81
+   cmplw   %cr0,%r3,%r4
+   beq %cr0,1b
+#endif
/* Privileged, so drop to KDB */
GET_CPUINFO(%r1)
stw %r28,(PC_DBSAVE+CPUSAVE_R28)(%r1)   /* free r28 */

Modified: head/sys/powerpc/aim/trap_subr64.S
==
--- head/sys/powerpc/aim/trap_subr64.S  Thu Dec 12 03:04:00 2013
(r259244)
+++ head/sys/powerpc/aim/trap_subr64.S  Thu Dec 12 04:12:19 2013
(r259245)
@@ -789,8 +789,9 @@ CNAME(dblow):
mfcr%r29/* save CR in r29 */
mfsrr1  %r1
mtcr%r1
-   bf  17,1f   /* branch if privileged */
+   bf  17,2f   /* branch if privileged */
 
+1:
/* Unprivileged case */
mtcr%r29/* put the condition register back */
 mfsprg2%r29/* ... and r29 */
@@ -799,8 +800,17 @@ CNAME(dblow):
li  %r1, 0  /* How to get the vector from LR */
 
 bla generictrap/* and we look like a generic trap */
-1:
+2:
+#ifdef KDTRACE_HOOKS
/* Privileged, so drop to KDB */
+   mfsrr0  %r1
+   lwz %r4,0(%r1)
+   /* Check if it's a DTrace trap. */
+   li  %r3,0x0808
+   addis   %r3,%r3,0x7c81
+   cmplw   %cr0,%r3,%r4
+   beq %cr0,1b
+#endif
GET_CPUINFO(%r1)
std %r27,(PC_DBSAVE+CPUSAVE_R27)(%r1)   /* free r27 */
std %r28,(PC_DBSAVE+CPUSAVE_R28)(%r1)   /* free r28 */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r259246 - head/release/scripts

2013-12-11 Thread Glen Barber
Author: gjb
Date: Thu Dec 12 05:49:27 2013
New Revision: 259246
URL: http://svnweb.freebsd.org/changeset/base/259246

Log:
  Prevent release build errors found during snapshot builds where if
  NOPORTS=1, pkg-stage.sh cannot build the ports-mgmt/pkg port if
  WITH_DVD=1.
  
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/release/scripts/pkg-stage.sh

Modified: head/release/scripts/pkg-stage.sh
==
--- head/release/scripts/pkg-stage.sh   Thu Dec 12 04:12:19 2013
(r259245)
+++ head/release/scripts/pkg-stage.sh   Thu Dec 12 05:49:27 2013
(r259246)
@@ -24,6 +24,11 @@ fi
 REVISION=${2}
 . ${1} || exit 1
 
+# If NOPORTS is set for the release, do not attempt to build pkg(8).
+if [ ! -f /usr/ports/Makefile ]; then
+   exit 0
+fi
+
 if [ ! -x /usr/local/sbin/pkg ]; then
/usr/bin/make -C /usr/ports/ports-mgmt/pkg install clean
 fi
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org