CVS commit: src/sys/arch/x86/pci

2021-06-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 21 03:01:23 UTC 2021

Modified Files:
src/sys/arch/x86/pci: pci_ranges.c

Log Message:
prop_dictionary_set_cstring_nocopy -> prop_dictionary_set_string_nocopy


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/pci_ranges.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_ranges.c
diff -u src/sys/arch/x86/pci/pci_ranges.c:1.8 src/sys/arch/x86/pci/pci_ranges.c:1.9
--- src/sys/arch/x86/pci/pci_ranges.c:1.8	Fri Mar  1 04:25:59 2019
+++ src/sys/arch/x86/pci/pci_ranges.c	Sun Jun 20 23:01:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_ranges.c,v 1.8 2019/03/01 09:25:59 msaitoh Exp $	*/
+/*	$NetBSD: pci_ranges.c,v 1.9 2021/06/21 03:01:23 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_ranges.c,v 1.8 2019/03/01 09:25:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_ranges.c,v 1.9 2021/06/21 03:01:23 christos Exp $");
 
 #include 
 #include 
@@ -784,7 +784,7 @@ pci_range_record(pci_chipset_tag_t pc, p
 		pci_decompose_tag(pc, pal->pal_tag, , , );
 
 		ok = ok &&
-		prop_dictionary_set_cstring_nocopy(rsvn, "type",
+		prop_dictionary_set_string_nocopy(rsvn, "type",
 		pci_alloc_regtype_string(pal->pal_type)) &&
 		prop_dictionary_set_uint64(rsvn, "address",
 		pal->pal_addr) &&



CVS commit: src/sys/arch/x86/pci

2021-06-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun Jun  6 11:35:22 UTC 2021

Modified Files:
src/sys/arch/x86/pci: amdzentemp.c

Log Message:
Fix build failure on i386.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.13 src/sys/arch/x86/pci/amdzentemp.c:1.14
--- src/sys/arch/x86/pci/amdzentemp.c:1.13	Sun Jun  6 08:45:18 2021
+++ src/sys/arch/x86/pci/amdzentemp.c	Sun Jun  6 11:35:22 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.14 2021/06/06 11:35:22 nonaka Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.14 2021/06/06 11:35:22 nonaka Exp $ ");
 
 #include 
 #include 
@@ -431,8 +431,9 @@ static void
 amdzentemp_setup_ccd_sensors(struct amdzentemp_softc *sc)
 {
 	envsys_data_t *edata;
+	size_t i;
 	uint32_t temp;
-	int i, error;
+	int error;
 
 	for (i = 0; i < sc->sc_numsensors - 1; i++) {
 		error = amdsmn_read(sc->sc_smn,
@@ -446,7 +447,7 @@ amdzentemp_setup_ccd_sensors(struct amdz
 		edata->flags = ENVSYS_FHAS_ENTROPY;
 		edata->private = CCD_BASE + i;
 		snprintf(edata->desc, sizeof(edata->desc),
-		"cpu%u ccd%u temperature", device_unit(sc->sc_dev), i);
+		"cpu%u ccd%zu temperature", device_unit(sc->sc_dev), i);
 	}
 }
 



CVS commit: src/sys/arch/x86/pci

2021-06-06 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun Jun  6 08:45:18 UTC 2021

Modified Files:
src/sys/arch/x86/pci: amdzentemp.c

Log Message:
amdzentemp(4): Add support for per CCD temperature sensor from FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.12 src/sys/arch/x86/pci/amdzentemp.c:1.13
--- src/sys/arch/x86/pci/amdzentemp.c:1.12	Sat Jun  5 01:38:22 2021
+++ src/sys/arch/x86/pci/amdzentemp.c	Sun Jun  6 08:45:18 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.13 2021/06/06 08:45:18 nonaka Exp $ ");
 
 #include 
 #include 
@@ -76,6 +76,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c
 #define	AMD_CURTMP_RANGE_ADJUST	4900	/* in microKelvins (ie, 49C) */
 #define	AMD_CURTMP_RANGE_CHECK	__BIT(19)
 #define	F10_TEMP_CURTMP		__BITS(31,21)	/* XXX same as amdtemp.c */
+#define	F10_TEMP_CURTMP_MASK	0x7ff
 #define	F15M60_CURTMP_TJSEL	__BITS(17,16)
 
 /*
@@ -96,7 +97,17 @@ __KERNEL_RCSID(0, "$NetBSD: amdzentemp.c
  */
 #define	AMD_17H_CUR_TMP			0x59800
 
+/*
+ * The following register set was discovered experimentally by Ondrej Čerman
+ * and collaborators, but is not (yet) documented in a PPR/OSRR (other than
+ * the M70H PPR SMN memory map showing [0x59800, +0x314] as allocated to
+ * SMU::THM).  It seems plausible and the Linux sensor folks have adopted it.
+ */
+#define	AMD_17H_CCD_TMP_BASE		0x59954
+#define	AMD_17H_CCD_TMP_VALID		__BIT(11)
+
 struct amdzentemp_softc {
+	device_t sc_dev;
 	struct sysmon_envsys *sc_sme;
 	device_t sc_smn;
 	envsys_data_t *sc_sensor;
@@ -105,15 +116,33 @@ struct amdzentemp_softc {
 	int32_t sc_offset;
 };
 
+enum {
+	NOSENSOR = 0,
+	CORE0_SENSOR0,
+	CCD_BASE,
+	CCD0 = CCD_BASE,
+	CCD1,
+	CCD2,
+	CCD3,
+	CCD4,
+	CCD5,
+	CCD6,
+	CCD7,
+	CCD_MAX,
+	NUM_CCDS = CCD_MAX - CCD_BASE
+};
+
 
 static int  amdzentemp_match(device_t, cfdata_t, void *);
 static void amdzentemp_attach(device_t, device_t, void *);
 static int  amdzentemp_detach(device_t, int);
 
-static void amdzentemp_init(struct amdzentemp_softc *);
-static void amdzentemp_setup_sensors(struct amdzentemp_softc *, int);
+static void amdzentemp_init(struct amdzentemp_softc *, int, int);
+static void amdzentemp_setup_sensors(struct amdzentemp_softc *);
 static void amdzentemp_family15_refresh(struct sysmon_envsys *, envsys_data_t *);
 static void amdzentemp_family17_refresh(struct sysmon_envsys *, envsys_data_t *);
+static int  amdzentemp_probe_ccd_sensors(struct amdzentemp_softc *, int, int);
+static void amdzentemp_setup_ccd_sensors(struct amdzentemp_softc *);
 
 CFATTACH_DECL_NEW(amdzentemp, sizeof(struct amdzentemp_softc),
 amdzentemp_match, amdzentemp_attach, amdzentemp_detach, NULL);
@@ -124,9 +153,9 @@ amdzentemp_match(device_t parent, cfdata
 	struct pci_attach_args *pa __diagused = aux;
 
 	KASSERT(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD);
- 
+
 	cfdata_t parent_cfdata = device_cfdata(parent);
- 
+
 	/* Got AMD family 17h system management network */
 	return parent_cfdata->cf_name &&
 	memcmp(parent_cfdata->cf_name, "amdsmn", 6) == 0;
@@ -137,18 +166,20 @@ amdzentemp_attach(device_t parent, devic
 {
 	struct amdzentemp_softc *sc = device_private(self);
 	struct cpu_info *ci = curcpu();
-	int family;
+	int family, model;
 	int error;
 	size_t i;
 
+	sc->sc_dev = self;
+
 	family = CPUID_TO_FAMILY(ci->ci_signature);
+	model = CPUID_TO_MODEL(ci->ci_signature);
 	aprint_naive("\n");
-	aprint_normal(": AMD CPU Temperature Sensors (Family%xh)",
-	family);
+	aprint_normal(": AMD CPU Temperature Sensors (Family%xh)", family);
 
 	sc->sc_smn = parent;
 
-	amdzentemp_init(sc);
+	amdzentemp_init(sc, family, model);
 
 	aprint_normal("\n");
 
@@ -156,12 +187,14 @@ amdzentemp_attach(device_t parent, devic
 	sc->sc_sensor_len = sizeof(envsys_data_t) * sc->sc_numsensors;
 	sc->sc_sensor = kmem_zalloc(sc->sc_sensor_len, KM_SLEEP);
 
-	amdzentemp_setup_sensors(sc, device_unit(self));
+	amdzentemp_setup_sensors(sc);
 
 	/*
 	 * Set properties in sensors.
 	 */
 	for (i = 0; i < sc->sc_numsensors; i++) {
+		if (sc->sc_sensor[i].private == NOSENSOR)
+			continue;
 		if (sysmon_envsys_sensor_attach(sc->sc_sme, >sc_sensor[i]))
 			goto bad;
 	}
@@ -223,10 +256,10 @@ amdzentemp_detach(device_t self, int fla
 
 
 static void
-amdzentemp_init(struct amdzentemp_softc *sc) 
+amdzentemp_init(struct amdzentemp_softc *sc, int family, int model)
 {
 
-	sc->sc_numsensors = 1;
+	

CVS commit: src/sys/arch/x86/pci

2021-06-04 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Jun  5 01:38:22 UTC 2021

Modified Files:
src/sys/arch/x86/pci: amdzentemp.c

Log Message:
amdzentemp(4): Add Zen 3 support.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.11 src/sys/arch/x86/pci/amdzentemp.c:1.12
--- src/sys/arch/x86/pci/amdzentemp.c:1.11	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/pci/amdzentemp.c	Sat Jun  5 01:38:22 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.11 2020/04/25 15:26:18 bouyer Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -53,7 +53,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.11 2020/04/25 15:26:18 bouyer Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.12 2021/06/05 01:38:22 nonaka Exp $ ");
 
 #include 
 #include 
@@ -177,6 +177,7 @@ amdzentemp_attach(device_t parent, devic
 		sc->sc_sme->sme_refresh = amdzentemp_family15_refresh;
 		break;
 	case 0x17:
+	case 0x19:
 		sc->sc_sme->sme_refresh = amdzentemp_family17_refresh;
 		break;
 	default:



CVS commit: src/sys/arch/x86/pci

2021-05-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat May 29 09:47:28 UTC 2021

Modified Files:
src/sys/arch/x86/pci: dwiic_pci.c

Log Message:
dwiic(4): Attribute output correctly and relegate to debug-level.

Tidy up a little while here.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/pci/dwiic_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/dwiic_pci.c
diff -u src/sys/arch/x86/pci/dwiic_pci.c:1.4 src/sys/arch/x86/pci/dwiic_pci.c:1.5
--- src/sys/arch/x86/pci/dwiic_pci.c:1.4	Sat Apr 24 23:36:51 2021
+++ src/sys/arch/x86/pci/dwiic_pci.c	Sat May 29 09:47:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dwiic_pci.c,v 1.4 2021/04/24 23:36:51 thorpej Exp $ */
+/* $NetBSD: dwiic_pci.c,v 1.5 2021/05/29 09:47:28 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.4 2021/04/24 23:36:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.5 2021/05/29 09:47:28 riastradh Exp $");
 
 #include 
 #include 
@@ -68,9 +68,8 @@ struct pci_dwiic_softc {
 static uint32_t
 lpss_read(struct pci_dwiic_softc *sc, int offset)
 {
-	u_int32_t b = bus_space_read_4(sc->sc_dwiic.sc_iot, sc->sc_dwiic.sc_ioh,
-	 offset);
-	return b;
+	return bus_space_read_4(sc->sc_dwiic.sc_iot, sc->sc_dwiic.sc_ioh,
+	offset);
 }
 
 static void
@@ -169,7 +168,7 @@ pci_dwiic_attach(device_t parent, device
 	pa->pa_bus, pa->pa_device, pa->pa_function);
 
 	if (sc->sc_acpinode) {
-		sc->sc_dwiic.sc_iba.iba_child_devices = 
+		sc->sc_dwiic.sc_iba.iba_child_devices =
 		acpi_enter_i2c_devs(NULL, sc->sc_acpinode);
 	} else {
 		aprint_verbose_dev(self, "no matching ACPI node\n");
@@ -188,13 +187,18 @@ out:
 static bool
 dwiic_pci_power(struct dwiic_softc *dwsc, bool power)
 {
-	struct pci_dwiic_softc *sc = (void *)dwsc;
-	pcireg_t pmreg;
-
-	printf("status 0x%x\n", pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_COMMAND_STATUS_REG));
-	printf("reset 0x%x\n", lpss_read(sc, LPSS_RESET));
-	printf("rlo 0x%x\n", lpss_read(sc, LPSS_REMAP_LO));
-	printf("rho 0x%x\n", lpss_read(sc, LPSS_REMAP_HI));
+	struct pci_dwiic_softc *sc = container_of(dwsc, struct pci_dwiic_softc,
+	sc_dwiic);
+	pcireg_t pmreg, csr;
+	uint32_t reset, rlo, rhi;
+
+	csr = pci_conf_read(sc->sc_pc, sc->sc_ptag, PCI_COMMAND_STATUS_REG);
+	reset = lpss_read(sc, LPSS_RESET);
+	rlo = lpss_read(sc, LPSS_REMAP_LO);
+	rhi = lpss_read(sc, LPSS_REMAP_HI);
+	aprint_debug_dev(dwsc->sc_dev,
+	"status 0x%x reset 0x%x rlo 0x%x rhi 0x%x\n",
+	csr, reset, rlo, rhi);
 
 	if (!power)
 		lpss_write(sc, LPSS_CLKGATE, LPSS_CLKGATE_CTRL_OFF);
@@ -205,7 +209,7 @@ dwiic_pci_power(struct dwiic_softc *dwsc
 		pci_conf_write(sc->sc_pc, sc->sc_ptag, pmreg + PCI_PMCSR,
 		power ? PCI_PMCSR_STATE_D0 : PCI_PMCSR_STATE_D3);
 		DELAY(1); /* 10 milliseconds */
-		DPRINTF((" -> 0x%x\n", 
+		DPRINTF((" -> 0x%x\n",
 		pci_conf_read(sc->sc_pc, sc->sc_ptag, pmreg + PCI_PMCSR)));
 	}
 	if (power) {



CVS commit: src/sys/arch/x86/pci

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 08:10:23 UTC 2021

Modified Files:
src/sys/arch/x86/pci: pci_msi_machdep.c

Log Message:
Remoave an extra space from a comment


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/pci/pci_msi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_msi_machdep.c
diff -u src/sys/arch/x86/pci/pci_msi_machdep.c:1.14 src/sys/arch/x86/pci/pci_msi_machdep.c:1.15
--- src/sys/arch/x86/pci/pci_msi_machdep.c:1.14	Sun Jul 19 14:27:07 2020
+++ src/sys/arch/x86/pci/pci_msi_machdep.c	Sun Mar 14 08:10:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_msi_machdep.c,v 1.14 2020/07/19 14:27:07 jdolecek Exp $	*/
+/*	$NetBSD: pci_msi_machdep.c,v 1.15 2021/03/14 08:10:23 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.14 2020/07/19 14:27:07 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.15 2021/03/14 08:10:23 skrll Exp $");
 
 #include "opt_intrdebug.h"
 #include "ioapic.h"
@@ -509,7 +509,7 @@ x86_pci_msix_disestablish(pci_chipset_ta
 /*
  * This function is used by device drivers like pci_intr_map().
  *
- * "ihps" is the array  of vector numbers which MSI used instead of IRQ number.
+ * "ihps" is the array of vector numbers which MSI used instead of IRQ number.
  * "count" must be power of 2.
  * "count" can decrease if struct intrsource cannot be allocated.
  * if count == 0, return non-zero value.



CVS commit: src/sys/arch/x86/pci

2020-12-11 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Dec 11 09:22:20 UTC 2020

Modified Files:
src/sys/arch/x86/pci: msipic.c

Log Message:
Fix build failure when XNEPV is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/x86/pci/msipic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.24 src/sys/arch/x86/pci/msipic.c:1.25
--- src/sys/arch/x86/pci/msipic.c:1.24	Fri Dec 11 07:49:39 2020
+++ src/sys/arch/x86/pci/msipic.c	Fri Dec 11 09:22:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.24 2020/12/11 07:49:39 knakahara Exp $	*/
+/*	$NetBSD: msipic.c,v 1.25 2020/12/11 09:22:20 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.24 2020/12/11 07:49:39 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.25 2020/12/11 09:22:20 knakahara Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -548,8 +548,8 @@ msix_addroute(struct pic *pic, struct cp
 	pcitag_t tag;
 	bus_space_tag_t bstag;
 	bus_space_handle_t bshandle;
-	uint64_t entry_base;
 #ifndef XENPV
+	uint64_t entry_base;
 	pcireg_t addr, data;
 #endif
 	pcireg_t ctl;
@@ -574,9 +574,9 @@ msix_addroute(struct pic *pic, struct cp
 
 	bstag = pic->pic_msipic->mp_bstag;
 	bshandle = pic->pic_msipic->mp_bshandle;
+#ifndef XENPV
 	entry_base = PCI_MSIX_TABLE_ENTRY_SIZE * msix_vec;
 
-#ifndef XENPV
 	/*
 	 * See Intel 64 and IA-32 Architectures Software Developer's Manual
 	 * Volume 3 10.11 Message Signalled Interrupts.



CVS commit: src/sys/arch/x86/pci

2020-12-10 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Dec 11 07:49:40 UTC 2020

Modified Files:
src/sys/arch/x86/pci: msipic.c

Log Message:
Not pic->pic_addroute but pic->pic_hwunmask should enable interrupts for MSI-X.

pic->pic_addroute should not enable interrupt, because callers expect
interrupts have been disabled until they call pic->pic_hwunmask.

By the way, the old implement writes zero to Vector Control for MSI-X Table
Entries, howerver it must be read and updated.  Because, there are not only
Mask Bit but also ST lower and ST upper.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/x86/pci/msipic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.23 src/sys/arch/x86/pci/msipic.c:1.24
--- src/sys/arch/x86/pci/msipic.c:1.23	Mon May  4 15:55:56 2020
+++ src/sys/arch/x86/pci/msipic.c	Fri Dec 11 07:49:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.23 2020/05/04 15:55:56 jdolecek Exp $	*/
+/*	$NetBSD: msipic.c,v 1.24 2020/12/11 07:49:39 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.23 2020/05/04 15:55:56 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.24 2020/12/11 07:49:39 knakahara Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -598,8 +598,6 @@ msix_addroute(struct pic *pic, struct cp
 	bus_space_write_4(bstag, bshandle,
 	entry_base + PCI_MSIX_TABLE_ENTRY_DATA, data);
 #endif /* !XENPV */
-	bus_space_write_4(bstag, bshandle,
-	entry_base + PCI_MSIX_TABLE_ENTRY_VECTCTL, 0);
 	BUS_SPACE_WRITE_FLUSH(bstag, bshandle);
 
 	ctl = pci_conf_read(pc, tag, off + PCI_MSIX_CTL);



CVS commit: src/sys/arch/x86/pci

2020-05-04 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Mon May  4 09:34:37 UTC 2020

Modified Files:
src/sys/arch/x86/pci: msipic.c

Log Message:
constify the pic templates


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/x86/pci/msipic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.21 src/sys/arch/x86/pci/msipic.c:1.22
--- src/sys/arch/x86/pci/msipic.c:1.21	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/pci/msipic.c	Mon May  4 09:34:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.21 2020/04/25 15:26:18 bouyer Exp $	*/
+/*	$NetBSD: msipic.c,v 1.22 2020/05/04 09:34:37 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.21 2020/04/25 15:26:18 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.22 2020/05/04 09:34:37 jdolecek Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -114,7 +114,7 @@ static void msipic_release_common_msi_de
 
 static struct pic *msipic_find_msi_pic_locked(int);
 static struct pic *msipic_construct_common_msi_pic(const struct pci_attach_args *,
-		   struct pic *);
+		   const struct pic *);
 static void msipic_destruct_common_msi_pic(struct pic *);
 
 static void msi_set_msictl_enablebit(struct pic *, int, int);
@@ -231,7 +231,7 @@ msipic_find_msi_pic(int devid)
  */
 static struct pic *
 msipic_construct_common_msi_pic(const struct pci_attach_args *pa,
-struct pic *pic_tmpl)
+const struct pic *pic_tmpl)
 {
 	struct pic *pic;
 	struct msipic *msipic;
@@ -427,7 +427,7 @@ msi_delroute(struct pic *pic, struct cpu
  * Template for MSI pic.
  * .pic_msipic is set later in construct_msi_pic().
  */
-static struct pic msi_pic_tmpl = {
+static const struct pic msi_pic_tmpl = {
 	.pic_type = PIC_MSI,
 	.pic_vecbase = 0,
 	.pic_apicid = 0,
@@ -605,7 +605,7 @@ msix_delroute(struct pic *pic, struct cp
  * Template for MSI-X pic.
  * .pic_msipic is set later in construct_msix_pic().
  */
-static struct pic msix_pic_tmpl = {
+static const struct pic msix_pic_tmpl = {
 	.pic_type = PIC_MSIX,
 	.pic_vecbase = 0,
 	.pic_apicid = 0,



CVS commit: src/sys/arch/x86/pci

2020-04-27 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Mon Apr 27 23:40:37 UTC 2020

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Fix the wrong logic about making the number of vmx(4) TX/RX queue
be power of two

reviewed by nonaka@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.59 src/sys/arch/x86/pci/if_vmx.c:1.60
--- src/sys/arch/x86/pci/if_vmx.c:1.59	Tue Mar 24 09:27:46 2020
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Apr 27 23:40:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.59 2020/03/24 09:27:46 knakahara Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.60 2020/04/27 23:40:37 yamaguchi Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,12 +19,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.59 2020/03/24 09:27:46 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.60 2020/04/27 23:40:37 yamaguchi Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -466,23 +467,11 @@ CFATTACH_DECL3_NEW(vmx, sizeof(struct vm
 static int
 vmxnet3_calc_queue_size(int n)
 {
-	int v, q;
 
-	v = n;
-	while (v != 0) {
-		if (powerof2(n) != 0)
-			break;
-		v /= 2;
-		q = rounddown2(n, v);
-		if (q != 0) {
-			n = q;
-			break;
-		}
-	}
-	if (n == 0)
-		n = 1;
+	if (__predict_false(n <= 0))
+		return 1;
 
-	return n;
+	return (1U << (fls32(n) - 1));
 }
 
 static inline void



CVS commit: src/sys/arch/x86/pci

2020-04-23 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr 23 13:40:36 UTC 2020

Modified Files:
src/sys/arch/x86/pci: amdsmn.c

Log Message:
Apply previous change ("Don't mix sign and unsigned operands. Just use
size_t for the loop.") to another loop variable.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/amdsmn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdsmn.c
diff -u src/sys/arch/x86/pci/amdsmn.c:1.8 src/sys/arch/x86/pci/amdsmn.c:1.9
--- src/sys/arch/x86/pci/amdsmn.c:1.8	Mon Apr 20 13:02:57 2020
+++ src/sys/arch/x86/pci/amdsmn.c	Thu Apr 23 13:40:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdsmn.c,v 1.8 2020/04/20 13:02:57 joerg Exp $	*/
+/*	$NetBSD: amdsmn.c,v 1.9 2020/04/23 13:40:36 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2017, 2019 Conrad Meyer 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.8 2020/04/20 13:02:57 joerg Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.9 2020/04/23 13:40:36 simonb Exp $ ");
 
 /*
  * Driver for the AMD Family 15h (model 60+) and 17h CPU
@@ -107,7 +107,7 @@ static int
 amdsmn_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct pci_attach_args *pa = aux;
-	unsigned int i;
+	size_t i;
 
 	if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_AMD)
 		return 0;



CVS commit: src/sys/arch/x86/pci

2020-04-20 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Apr 20 13:02:57 UTC 2020

Modified Files:
src/sys/arch/x86/pci: amdsmn.c

Log Message:
Don't mix sign and unsigned operands. Just use size_t for the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/pci/amdsmn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdsmn.c
diff -u src/sys/arch/x86/pci/amdsmn.c:1.7 src/sys/arch/x86/pci/amdsmn.c:1.8
--- src/sys/arch/x86/pci/amdsmn.c:1.7	Mon Apr 20 11:03:02 2020
+++ src/sys/arch/x86/pci/amdsmn.c	Mon Apr 20 13:02:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdsmn.c,v 1.7 2020/04/20 11:03:02 simonb Exp $	*/
+/*	$NetBSD: amdsmn.c,v 1.8 2020/04/20 13:02:57 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2017, 2019 Conrad Meyer 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.7 2020/04/20 11:03:02 simonb Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.8 2020/04/20 13:02:57 joerg Exp $ ");
 
 /*
  * Driver for the AMD Family 15h (model 60+) and 17h CPU
@@ -134,7 +134,7 @@ amdsmn_attach(device_t parent, device_t 
 	struct amdsmn_softc *sc = device_private(self);
 	struct pci_attach_args *pa = aux;
 	int flags = 0;
-	int i;
+	size_t i;
 
 	mutex_init(>smn_lock, MUTEX_DEFAULT, IPL_NONE);
 	sc->pa = *pa;



CVS commit: src/sys/arch/x86/pci

2020-04-20 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Apr 20 11:03:02 UTC 2020

Modified Files:
src/sys/arch/x86/pci: amdsmn.c amdzentemp.c

Log Message:
Update to support Family 15h Model 60 temperature sensors.

Changes based on FreeBSD amdtemp driver changes by Conrad Meyer.

XXX: Some code duplication between this driver and amdtemp as
 parts of the 15h refresh code share more in common with
 older CPUs while accessing the device more like 17h.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/pci/amdsmn.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdsmn.c
diff -u src/sys/arch/x86/pci/amdsmn.c:1.6 src/sys/arch/x86/pci/amdsmn.c:1.7
--- src/sys/arch/x86/pci/amdsmn.c:1.6	Tue Aug  6 05:32:44 2019
+++ src/sys/arch/x86/pci/amdsmn.c	Mon Apr 20 11:03:02 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: amdsmn.c,v 1.6 2019/08/06 05:32:44 msaitoh Exp $	*/
+/*	$NetBSD: amdsmn.c,v 1.7 2020/04/20 11:03:02 simonb Exp $	*/
 
 /*-
- * Copyright (c) 2017 Conrad Meyer 
+ * Copyright (c) 2017, 2019 Conrad Meyer 
  * All rights reserved.
  *
  * NetBSD port by Ian Clark 
@@ -29,10 +29,11 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.6 2019/08/06 05:32:44 msaitoh Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.7 2020/04/20 11:03:02 simonb Exp $ ");
 
 /*
- * Driver for the AMD Family 17h CPU System Management Network.
+ * Driver for the AMD Family 15h (model 60+) and 17h CPU
+ * System Management Network.
  */
 
 #include 
@@ -52,11 +53,15 @@ __KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1
 #include "amdsmn.h"
 #include "ioconf.h"
 
-#define	SMN_ADDR_REG	0x60
-#define	SMN_DATA_REG	0x64
+#define	F15H_SMN_ADDR_REG	0xb8
+#define	F15H_SMN_DATA_REG	0xbc
+#define	F17H_SMN_ADDR_REG	0x60
+#define	F17H_SMN_DATA_REG	0x64
 
 struct amdsmn_softc {
 	kmutex_t smn_lock;
+	uint8_t smn_addr_reg;
+	uint8_t smn_data_reg;
 	struct pci_attach_args pa;
 	pci_chipset_tag_t pc;
 	pcitag_t pcitag;
@@ -64,10 +69,29 @@ struct amdsmn_softc {
 
 static const struct pciid {
 	uint16_t	amdsmn_deviceid;
+	uint8_t		amdsmn_addr_reg;
+	uint8_t		amdsmn_data_reg;
 } amdsmn_ids[] = {
-	{ PCI_PRODUCT_AMD_F17_RC },
-	{ PCI_PRODUCT_AMD_F17_1X_RC },
-	{ PCI_PRODUCT_AMD_F17_7X_RC },
+	{
+		.amdsmn_deviceid = PCI_PRODUCT_AMD_F15_60_RC,
+		.amdsmn_addr_reg = F15H_SMN_ADDR_REG,
+		.amdsmn_data_reg = F15H_SMN_DATA_REG,
+	},
+	{
+		.amdsmn_deviceid = PCI_PRODUCT_AMD_F17_RC,
+		.amdsmn_addr_reg = F17H_SMN_ADDR_REG,
+		.amdsmn_data_reg = F17H_SMN_DATA_REG,
+	},
+	{
+		.amdsmn_deviceid = PCI_PRODUCT_AMD_F17_1X_RC,
+		.amdsmn_addr_reg = F17H_SMN_ADDR_REG,
+		.amdsmn_data_reg = F17H_SMN_DATA_REG,
+	},
+	{
+		.amdsmn_deviceid = PCI_PRODUCT_AMD_F17_7X_RC,
+		.amdsmn_addr_reg = F17H_SMN_ADDR_REG,
+		.amdsmn_data_reg = F17H_SMN_DATA_REG,
+	},
 };
 
 static int amdsmn_match(device_t, cfdata_t, void *);
@@ -110,12 +134,21 @@ amdsmn_attach(device_t parent, device_t 
 	struct amdsmn_softc *sc = device_private(self);
 	struct pci_attach_args *pa = aux;
 	int flags = 0;
+	int i;
 
 	mutex_init(>smn_lock, MUTEX_DEFAULT, IPL_NONE);
 	sc->pa = *pa;
 	sc->pc = pa->pa_pc;
 	sc->pcitag = pa->pa_tag;
-	aprint_normal(": AMD Family 17h System Management Network\n");
+
+	for (i = 0; i < __arraycount(amdsmn_ids); i++)
+		if (PCI_PRODUCT(pa->pa_id) == amdsmn_ids[i].amdsmn_deviceid) {
+			sc->smn_addr_reg = amdsmn_ids[i].amdsmn_addr_reg;
+			sc->smn_data_reg = amdsmn_ids[i].amdsmn_data_reg;
+		}
+
+	// aprint_normal(": AMD Family 17h System Management Network\n");
+	aprint_normal(": AMD System Management Network\n");
 	amdsmn_rescan(self, "amdsmnbus", );
 }
 
@@ -146,8 +179,8 @@ amdsmn_read(device_t dev, uint32_t addr,
 	struct amdsmn_softc *sc = device_private(dev);
 
 	mutex_enter(>smn_lock);
-	pci_conf_write(sc->pc, sc->pcitag, SMN_ADDR_REG, addr);
-	*value = pci_conf_read(sc->pc, sc->pcitag, SMN_DATA_REG);
+	pci_conf_write(sc->pc, sc->pcitag, sc->smn_addr_reg, addr);
+	*value = pci_conf_read(sc->pc, sc->pcitag, sc->smn_data_reg);
 	mutex_exit(>smn_lock);
 
 	return 0;
@@ -159,8 +192,8 @@ amdsmn_write(device_t dev, uint32_t addr
 	struct amdsmn_softc *sc = device_private(dev);
 
 	mutex_enter(>smn_lock);
-	pci_conf_write(sc->pc, sc->pcitag, SMN_ADDR_REG, addr);
-	pci_conf_write(sc->pc, sc->pcitag, SMN_DATA_REG, value);
+	pci_conf_write(sc->pc, sc->pcitag, sc->smn_addr_reg, addr);
+	pci_conf_write(sc->pc, sc->pcitag, sc->smn_data_reg, value);
 	mutex_exit(>smn_lock);
 
 	return 0;

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.9 src/sys/arch/x86/pci/amdzentemp.c:1.10
--- src/sys/arch/x86/pci/amdzentemp.c:1.9	Sun Jun 16 09:12:51 2019
+++ src/sys/arch/x86/pci/amdzentemp.c	Mon Apr 20 11:03:02 2020
@@ -1,8 +1,11 @@
-/*  $NetBSD: amdzentemp.c,v 1.9 2019/06/16 09:12:51 mlelstv Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.10 2020/04/20 

CVS commit: src/sys/arch/x86/pci

2020-04-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr  7 12:42:11 UTC 2020

Modified Files:
src/sys/arch/x86/pci: rdcpcib.c

Log Message:
Recognize more rdc devices (Andrius V.)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/pci/rdcpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/rdcpcib.c
diff -u src/sys/arch/x86/pci/rdcpcib.c:1.2 src/sys/arch/x86/pci/rdcpcib.c:1.3
--- src/sys/arch/x86/pci/rdcpcib.c:1.2	Fri Jul  1 14:22:08 2011
+++ src/sys/arch/x86/pci/rdcpcib.c	Tue Apr  7 08:42:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: rdcpcib.c,v 1.2 2011/07/01 18:22:08 dyoung Exp $	*/
+/*	$NetBSD: rdcpcib.c,v 1.3 2020/04/07 12:42:11 christos Exp $	*/
 
 /*
  * Copyright (c) 2011 Manuel Bouyer.
@@ -31,7 +31,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rdcpcib.c,v 1.2 2011/07/01 18:22:08 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rdcpcib.c,v 1.3 2020/04/07 12:42:11 christos Exp $");
 
 #include 
 #include 
@@ -88,6 +88,17 @@ CFATTACH_DECL2_NEW(rdcpcib, sizeof(struc
 rdcpcibmatch, rdcpcibattach, rdcpcibdetach, NULL,
 pcibrescan, pcibchilddet);
 
+
+static const struct rdcpcib_device {
+	pcireg_t vendor, product;
+} rdcpcib_devices[] = {
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6011_PCIB},
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6013_PCIB},
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6031_PCIB},
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6035_PCIB},
+	{ PCI_VENDOR_RDC, PCI_PRODUCT_RDC_R6036_PCIB},
+};
+
 static int
 rdcpcibmatch(device_t parent, cfdata_t match, void *aux)
 {
@@ -97,9 +108,11 @@ rdcpcibmatch(device_t parent, cfdata_t m
 	PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_ISA)
 		return 0;
 
-	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_RDC &&
-	PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_RDC_PCIB)
+	for (size_t i = 0; i < __arraycount(rdcpcib_devices); i++) {
+		if (PCI_VENDOR(pa->pa_id) == rdcpcib_devices[i].vendor &&
+		PCI_PRODUCT(pa->pa_id) == rdcpcib_devices[i].product)
 			return 10;
+	}
 
 	return 0;
 }



CVS commit: src/sys/arch/x86/pci

2020-03-24 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Mar 24 09:27:46 UTC 2020

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
fix vmx(4) cannot link up at boot time.  reviewed by msaitoh@n.o, thanks.

vmx(4) could call if_link_state_change(ifp, LINK_STATE_UP) from vmxnet3_init()
before ifp->if_link_cansched was set, because dp->dom_if_up() (in6_if_up() for
INET6) could call ifp->if_init().  And then, workqueue_enqueue() was not called
at that time.
As the result, the last LQ_ITEM was stuck LINK_STATE_UP, so
if_link_state_change_work_schedule() was never called until
if_link_state_change(ifp, LINK_STATE_DOWN) was called.

To fix this issue, vmx(4) avoid calling if_link_state_change() before
ifp->if_link_cansched is set.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.58 src/sys/arch/x86/pci/if_vmx.c:1.59
--- src/sys/arch/x86/pci/if_vmx.c:1.58	Sun Mar 15 23:04:50 2020
+++ src/sys/arch/x86/pci/if_vmx.c	Tue Mar 24 09:27:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.58 2020/03/15 23:04:50 thorpej Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.59 2020/03/24 09:27:46 knakahara Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.58 2020/03/15 23:04:50 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.59 2020/03/24 09:27:46 knakahara Exp $");
 
 #include 
 #include 
@@ -445,9 +445,10 @@ static int vmxnet3_ifflags_cb(struct eth
 static int vmxnet3_watchdog(struct vmxnet3_txqueue *);
 static void vmxnet3_refresh_host_stats(struct vmxnet3_softc *);
 static void vmxnet3_tick(void *);
-static void vmxnet3_link_status(struct vmxnet3_softc *);
-static void vmxnet3_media_status(struct ifnet *, struct ifmediareq *);
-static int vmxnet3_media_change(struct ifnet *);
+static void vmxnet3_if_link_status(struct vmxnet3_softc *);
+static bool vmxnet3_cmd_link_status(struct ifnet *);
+static void vmxnet3_ifmedia_status(struct ifnet *, struct ifmediareq *);
+static int vmxnet3_ifmedia_change(struct ifnet *);
 static void vmxnet3_set_lladdr(struct vmxnet3_softc *);
 static void vmxnet3_get_lladdr(struct vmxnet3_softc *);
 
@@ -1857,8 +1858,8 @@ vmxnet3_setup_interface(struct vmxnet3_s
 
 	/* Initialize ifmedia structures. */
 	sc->vmx_ethercom.ec_ifmedia = >vmx_media;
-	ifmedia_init_with_lock(>vmx_media, IFM_IMASK, vmxnet3_media_change,
-	vmxnet3_media_status, sc->vmx_mtx);
+	ifmedia_init_with_lock(>vmx_media, IFM_IMASK, vmxnet3_ifmedia_change,
+	vmxnet3_ifmedia_status, sc->vmx_mtx);
 	ifmedia_add(>vmx_media, IFM_ETHER | IFM_AUTO, 0, NULL);
 	ifmedia_add(>vmx_media, IFM_ETHER | IFM_10G_T | IFM_FDX, 0, NULL);
 	ifmedia_add(>vmx_media, IFM_ETHER | IFM_10G_T, 0, NULL);
@@ -1870,7 +1871,7 @@ vmxnet3_setup_interface(struct vmxnet3_s
 	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, sc->vmx_lladdr);
 	ether_set_ifflags_cb(>vmx_ethercom, vmxnet3_ifflags_cb);
-	vmxnet3_link_status(sc);
+	vmxnet3_cmd_link_status(ifp);
 
 	/* should set before setting interrupts */
 	sc->vmx_rx_intr_process_limit = VMXNET3_RX_INTR_PROCESS_LIMIT;
@@ -2069,7 +2070,7 @@ vmxnet3_evintr(struct vmxnet3_softc *sc)
 
 	if (event & VMXNET3_EVENT_LINK) {
 		sc->vmx_event_link.ev_count++;
-		vmxnet3_link_status(sc);
+		vmxnet3_if_link_status(sc);
 		if (sc->vmx_link_active != 0)
 			if_schedule_deferred_start(>vmx_ethercom.ec_if);
 	}
@@ -2909,7 +2910,7 @@ vmxnet3_init_locked(struct vmxnet3_softc
 	}
 
 	ifp->if_flags |= IFF_RUNNING;
-	vmxnet3_link_status(sc);
+	vmxnet3_cmd_link_status(ifp);
 
 	vmxnet3_enable_all_intrs(sc);
 	callout_reset(>vmx_tick, hz, vmxnet3_tick, sc);
@@ -3425,6 +3426,8 @@ vmxnet3_ifflags_cb(struct ethercom *ec)
 	vmxnet3_set_rxfilter(sc);
 	VMXNET3_CORE_UNLOCK(sc);
 
+	vmxnet3_if_link_status(sc);
+
 	return 0;
 }
 
@@ -3481,17 +3484,20 @@ vmxnet3_tick(void *xsc)
 	VMXNET3_CORE_UNLOCK(sc);
 }
 
+/*
+ * update link state of ifnet and softc
+ */
 static void
-vmxnet3_link_status(struct vmxnet3_softc *sc)
+vmxnet3_if_link_status(struct vmxnet3_softc *sc)
 {
 	struct ifnet *ifp = >vmx_ethercom.ec_if;
-	u_int x, link, speed;
+	u_int x, link;
+
+	vmxnet3_cmd_link_status(ifp);
 
 	x = vmxnet3_read_cmd(sc, VMXNET3_CMD_GET_LINK);
-	speed = x >> 16;
 	if (x & 1) {
 		sc->vmx_link_active = 1;
-		ifp->if_baudrate = IF_Mbps(speed);
 		link = LINK_STATE_UP;
 	} else {
 		sc->vmx_link_active = 0;
@@ -3501,17 +3507,37 @@ vmxnet3_link_status(struct vmxnet3_softc
 	if_link_state_change(ifp, link);
 }
 
-static void
-vmxnet3_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+/*
+ * check vmx(4) state by VMXNET3_CMD and update ifp->if_baudrate
+ *   returns
+ *   - true:  link up
+ *   - flase: link down
+ */
+static bool

CVS commit: src/sys/arch/x86/pci

2020-02-01 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Feb  2 05:27:21 UTC 2020

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
- Adopt .
- Use ifmedia_fini().


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.56 src/sys/arch/x86/pci/if_vmx.c:1.57
--- src/sys/arch/x86/pci/if_vmx.c:1.56	Wed Jan 29 08:43:30 2020
+++ src/sys/arch/x86/pci/if_vmx.c	Sun Feb  2 05:27:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.56 2020/01/29 08:43:30 knakahara Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.57 2020/02/02 05:27:21 thorpej Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.56 2020/01/29 08:43:30 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.57 2020/02/02 05:27:21 thorpej Exp $");
 
 #include 
 #include 
@@ -179,9 +179,11 @@ struct vmxnet3_comp_ring {
 };
 
 struct vmxnet3_txq_stats {
+#if 0
 	uint64_t vmtxs_opackets;	/* if_opackets */
 	uint64_t vmtxs_obytes;		/* if_obytes */
 	uint64_t vmtxs_omcasts;		/* if_omcasts */
+#endif
 	uint64_t vmtxs_csum;
 	uint64_t vmtxs_tso;
 	uint64_t vmtxs_full;
@@ -211,12 +213,14 @@ struct vmxnet3_txqueue {
 	struct evcnt vxtxq_defrag_failed;
 };
 
+#if 0
 struct vmxnet3_rxq_stats {
 	uint64_t vmrxs_ipackets;	/* if_ipackets */
 	uint64_t vmrxs_ibytes;		/* if_ibytes */
 	uint64_t vmrxs_iqdrops;		/* if_iqdrops */
 	uint64_t vmrxs_ierrors;		/* if_ierrors */
 };
+#endif
 
 struct vmxnet3_rxqueue {
 	kmutex_t *vxrxq_mtx;
@@ -225,7 +229,9 @@ struct vmxnet3_rxqueue {
 	struct mbuf *vxrxq_mtail;
 	struct vmxnet3_rxring vxrxq_cmd_ring[VMXNET3_RXRINGS_PERQ];
 	struct vmxnet3_comp_ring vxrxq_comp_ring;
+#if 0
 	struct vmxnet3_rxq_stats vxrxq_stats;
+#endif
 	struct vmxnet3_rxq_shared *vxrxq_rs;
 	char vxrxq_name[16];
 
@@ -670,10 +676,9 @@ vmxnet3_detach(device_t self, int flags)
 		callout_destroy(>vmx_tick);
 		VMXNET3_CORE_UNLOCK(sc);
 
-		ifmedia_delete_instance(>vmx_media, IFM_INST_ANY);
-
 		ether_ifdetach(ifp);
 		if_detach(ifp);
+		ifmedia_fini(>vmx_media);
 	}
 
 	vmxnet3_teardown_stats(sc);
@@ -2109,6 +2114,7 @@ vmxnet3_txq_eof(struct vmxnet3_txqueue *
 	struct vmxnet3_comp_ring *txc;
 	struct vmxnet3_txcompdesc *txcd;
 	struct vmxnet3_txbuf *txb;
+	struct ifnet *ifp;
 	struct mbuf *m;
 	u_int sop;
 	bool more = false;
@@ -2116,9 +2122,11 @@ vmxnet3_txq_eof(struct vmxnet3_txqueue *
 	sc = txq->vxtxq_sc;
 	txr = >vxtxq_cmd_ring;
 	txc = >vxtxq_comp_ring;
+	ifp = >vmx_ethercom.ec_if;
 
 	VMXNET3_TXQ_LOCK_ASSERT(txq);
 
+	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
 	for (;;) {
 		if (limit-- == 0) {
 			more = true;
@@ -2144,10 +2152,10 @@ vmxnet3_txq_eof(struct vmxnet3_txqueue *
 			BUS_DMASYNC_POSTWRITE);
 			bus_dmamap_unload(sc->vmx_dmat, txb->vtxb_dmamap);
 
-			txq->vxtxq_stats.vmtxs_opackets++;
-			txq->vxtxq_stats.vmtxs_obytes += m->m_pkthdr.len;
+			if_statinc_ref(nsr, if_opackets);
+			if_statadd_ref(nsr, if_obytes, m->m_pkthdr.len);
 			if (m->m_flags & M_MCAST)
-txq->vxtxq_stats.vmtxs_omcasts++;
+if_statinc_ref(nsr, if_omcasts);
 
 			m_freem(m);
 			txb->vtxb_m = NULL;
@@ -2155,6 +2163,7 @@ vmxnet3_txq_eof(struct vmxnet3_txqueue *
 
 		txr->vxtxr_next = (txcd->eop_idx + 1) % txr->vxtxr_ndesc;
 	}
+	IF_STAT_PUTREF(ifp);
 
 	if (txr->vxtxr_head == txr->vxtxr_next)
 		txq->vxtxq_watchdog = 0;
@@ -2310,7 +2319,7 @@ vmxnet3_rxq_input(struct vmxnet3_rxqueue
 	ifp = >vmx_ethercom.ec_if;
 
 	if (rxcd->error) {
-		rxq->vxrxq_stats.vmrxs_ierrors++;
+		if_statinc(ifp, if_ierrors);
 		m_freem(m);
 		return;
 	}
@@ -2320,8 +2329,10 @@ vmxnet3_rxq_input(struct vmxnet3_rxqueue
 	if (rxcd->vlan)
 		vlan_set_tag(m, rxcd->vtag);
 
-	rxq->vxrxq_stats.vmrxs_ipackets++;
-	rxq->vxrxq_stats.vmrxs_ibytes += m->m_pkthdr.len;
+	net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
+	if_statinc_ref(nsr, if_ipackets);
+	if_statadd_ref(nsr, if_ibytes, m->m_pkthdr.len);
+	IF_STAT_PUTREF(ifp);
 
 	if_percpuq_enqueue(ifp->if_percpuq, m);
 }
@@ -2412,7 +2423,7 @@ vmxnet3_rxq_eof(struct vmxnet3_rxqueue *
 			}
 
 			if (vmxnet3_newbuf(sc, rxq, rxr) != 0) {
-rxq->vxrxq_stats.vmrxs_iqdrops++;
+if_statinc(ifp, if_iqdrops);
 vmxnet3_rxq_eof_discard(rxq, rxr, idx);
 if (!rxcd->eop)
 	vmxnet3_rxq_discard_chain(rxq);
@@ -2431,7 +2442,7 @@ vmxnet3_rxq_eof(struct vmxnet3_rxqueue *
 			KASSERT(m_head != NULL);
 
 			if (vmxnet3_newbuf(sc, rxq, rxr) != 0) {
-rxq->vxrxq_stats.vmrxs_iqdrops++;
+if_statinc(ifp, if_iqdrops);
 vmxnet3_rxq_eof_discard(rxq, rxr, idx);
 if (!rxcd->eop)
 	vmxnet3_rxq_discard_chain(rxq);
@@ -3385,45 +3396,7 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 		}
 		break;
 	}
-	case SIOCGIFDATA:
-	case SIOCZIFDATA:
-		ifp->if_ipackets = 0;
-		ifp->if_ibytes = 0;
-		

CVS commit: src/sys/arch/x86/pci

2020-01-29 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Jan 29 08:43:30 UTC 2020

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Fix missing callout_destroy().  Pointed out by yamaguchi@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.55 src/sys/arch/x86/pci/if_vmx.c:1.56
--- src/sys/arch/x86/pci/if_vmx.c:1.55	Wed Jan 29 02:58:51 2020
+++ src/sys/arch/x86/pci/if_vmx.c	Wed Jan 29 08:43:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.55 2020/01/29 02:58:51 knakahara Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.56 2020/01/29 08:43:30 knakahara Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.55 2020/01/29 02:58:51 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.56 2020/01/29 08:43:30 knakahara Exp $");
 
 #include 
 #include 
@@ -667,6 +667,7 @@ vmxnet3_detach(device_t self, int flags)
 		VMXNET3_CORE_LOCK(sc);
 		vmxnet3_stop_locked(sc);
 		callout_halt(>vmx_tick, sc->vmx_mtx);
+		callout_destroy(>vmx_tick);
 		VMXNET3_CORE_UNLOCK(sc);
 
 		ifmedia_delete_instance(>vmx_media, IFM_INST_ANY);



CVS commit: src/sys/arch/x86/pci

2020-01-28 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Jan 29 02:58:51 UTC 2020

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Fix typo in evcnt description.  Pointed out by yamaguchi@n.o.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.54 src/sys/arch/x86/pci/if_vmx.c:1.55
--- src/sys/arch/x86/pci/if_vmx.c:1.54	Mon Jan  6 07:15:03 2020
+++ src/sys/arch/x86/pci/if_vmx.c	Wed Jan 29 02:58:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.54 2020/01/06 07:15:03 msaitoh Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.55 2020/01/29 02:58:51 knakahara Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.54 2020/01/06 07:15:03 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.55 2020/01/29 02:58:51 knakahara Exp $");
 
 #include 
 #include 
@@ -1966,9 +1966,9 @@ vmxnet3_setup_stats(struct vmxnet3_softc
 		evcnt_attach_dynamic(>vxtxq_transmitdef, EVCNT_TYPE_MISC,
 		NULL, txq->vxtxq_name, "Deferred transmit");
 		evcnt_attach_dynamic(>vxtxq_watchdogto, EVCNT_TYPE_MISC,
-		NULL, txq->vxtxq_name, "Watchdog timeount");
+		NULL, txq->vxtxq_name, "Watchdog timeout");
 		evcnt_attach_dynamic(>vxtxq_defragged, EVCNT_TYPE_MISC,
-		NULL, txq->vxtxq_name, "m_defrag sucessed");
+		NULL, txq->vxtxq_name, "m_defrag successed");
 		evcnt_attach_dynamic(>vxtxq_defrag_failed, EVCNT_TYPE_MISC,
 		NULL, txq->vxtxq_name, "m_defrag failed");
 	}



CVS commit: src/sys/arch/x86/pci

2019-12-24 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Dec 24 10:21:08 UTC 2019

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Fix missing splnet() for ether_ioctl() caused by if_vmx.c:r1.32.

pointed out by nonaka@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.52 src/sys/arch/x86/pci/if_vmx.c:1.53
--- src/sys/arch/x86/pci/if_vmx.c:1.52	Wed Nov 27 19:21:36 2019
+++ src/sys/arch/x86/pci/if_vmx.c	Tue Dec 24 10:21:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.52 2019/11/27 19:21:36 maxv Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.53 2019/12/24 10:21:08 knakahara Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.52 2019/11/27 19:21:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.53 2019/12/24 10:21:08 knakahara Exp $");
 
 #include 
 #include 
@@ -3378,7 +3378,9 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 			break;
 		}
 		if (ifp->if_mtu != nmtu) {
+			s = splnet();
 			error = ether_ioctl(ifp, cmd, data);
+			splx(s);
 			if (error == ENETRESET)
 error = vmxnet3_init(ifp);
 		}



CVS commit: src/sys/arch/x86/pci

2019-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Mar 20 13:34:51 UTC 2019

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
PR/54058: vmx(4): Fix device enable command failure when the number of vCPUs
is not a power of two.

Make the size of the vmx(4) TX/RX queue a power of two not exceeding
the number of vCPUs.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.26 src/sys/arch/x86/pci/if_vmx.c:1.27
--- src/sys/arch/x86/pci/if_vmx.c:1.26	Tue Jun 26 06:48:00 2018
+++ src/sys/arch/x86/pci/if_vmx.c	Wed Mar 20 13:34:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.26 2018/06/26 06:48:00 msaitoh Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.27 2019/03/20 13:34:51 nonaka Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.26 2018/06/26 06:48:00 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.27 2019/03/20 13:34:51 nonaka Exp $");
 
 #include 
 #include 
@@ -395,6 +395,29 @@ void vmxnet3_dma_free(struct vmxnet3_sof
 CFATTACH_DECL3_NEW(vmx, sizeof(struct vmxnet3_softc),
 vmxnet3_match, vmxnet3_attach, vmxnet3_detach, NULL, NULL, NULL, 0);
 
+/* round down to the nearest power of 2 */
+static int
+vmxnet3_calc_queue_size(int n)
+{
+	int v, q;
+
+	v = n;
+	while (v != 0) {
+		if (powerof2(n) != 0)
+			break;
+		v /= 2;
+		q = rounddown2(n, v);
+		if (q != 0) {
+			n = q;
+			break;
+		}
+	}
+	if (n == 0)
+		n = 1;
+
+	return n;
+}
+
 static inline void
 vmxnet3_write_bar0(struct vmxnet3_softc *sc, bus_size_t r, uint32_t v)
 {
@@ -520,8 +543,10 @@ vmxnet3_attach(device_t parent, device_t
 	sc->vmx_mtx = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
 	callout_init(>vmx_tick, CALLOUT_MPSAFE);
 
-	sc->vmx_max_ntxqueues = ncpu;
-	sc->vmx_max_nrxqueues = ncpu;
+	sc->vmx_max_ntxqueues =
+	vmxnet3_calc_queue_size(MIN(VMXNET3_MAX_TX_QUEUES, ncpu));
+	sc->vmx_max_nrxqueues =
+	vmxnet3_calc_queue_size(MIN(VMXNET3_MAX_RX_QUEUES, ncpu));
 	sc->vmx_ntxdescs = 512;
 	sc->vmx_nrxdescs = 256;
 	sc->vmx_max_rxsegs = VMXNET3_MAX_RX_SEGS;



CVS commit: src/sys/arch/x86/pci

2018-12-30 Thread Ignatios Souvatzis
Module Name:src
Committed By:   is
Date:   Sun Dec 30 15:43:43 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdtemp.c

Log Message:
Document bobcat/puma family nicknames.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/x86/pci/amdtemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdtemp.c
diff -u src/sys/arch/x86/pci/amdtemp.c:1.22 src/sys/arch/x86/pci/amdtemp.c:1.23
--- src/sys/arch/x86/pci/amdtemp.c:1.22	Wed Dec 12 23:35:04 2018
+++ src/sys/arch/x86/pci/amdtemp.c	Sun Dec 30 15:43:43 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdtemp.c,v 1.22 2018/12/12 23:35:04 is Exp $ */
+/*  $NetBSD: amdtemp.c,v 1.23 2018/12/30 15:43:43 is Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.22 2018/12/12 23:35:04 is Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.23 2018/12/30 15:43:43 is Exp $ ");
 
 #include 
 #include 
@@ -250,8 +250,8 @@ amdtemp_attach(device_t parent, device_t
 	case 0x11: /* AMD Griffin */
 	case 0x12: /* AMD Lynx/Sabine (Llano) */
 	case 0x14: /* AMD Brazos (Ontario/Zacate/Desna) */
-	case 0x15:
-	case 0x16:
+	case 0x15: /* AMD Bobcat */
+	case 0x16: /* AMD Puma/Jaguar */
 		amdtemp_family10_init(sc);
 		break;
 



CVS commit: src/sys/arch/x86/pci

2018-12-12 Thread Ignatios Souvatzis
Module Name:src
Committed By:   is
Date:   Wed Dec 12 23:35:04 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdnb_misc.c amdtemp.c

Log Message:
Added support for AMD family 16h cpu sensors - (just like 10h-14h).
(Tested on netbsd-8.0 release.)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/pci/amdnb_misc.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/x86/pci/amdtemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdnb_misc.c
diff -u src/sys/arch/x86/pci/amdnb_misc.c:1.2 src/sys/arch/x86/pci/amdnb_misc.c:1.3
--- src/sys/arch/x86/pci/amdnb_misc.c:1.2	Mon Apr 16 16:07:24 2012
+++ src/sys/arch/x86/pci/amdnb_misc.c	Wed Dec 12 23:35:04 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdnb_misc.c,v 1.2 2012/04/16 16:07:24 cegger Exp $ */
+/*	$NetBSD: amdnb_misc.c,v 1.3 2018/12/12 23:35:04 is Exp $ */
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdnb_misc.c,v 1.2 2012/04/16 16:07:24 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdnb_misc.c,v 1.3 2018/12/12 23:35:04 is Exp $");
 
 #include 
 #include 
@@ -67,6 +67,8 @@ amdnb_misc_match(device_t parent, cfdata
 	case PCI_PRODUCT_AMD_AMD64_F11_MISC:
 	case PCI_PRODUCT_AMD_F14_NB:		/* Family 12h, too */
 	case PCI_PRODUCT_AMD_F15_MISC:
+	case PCI_PRODUCT_AMD_F16_NB:
+	case PCI_PRODUCT_AMD_F16_30_NB:
 		break;
 	default:
 		return 0;

Index: src/sys/arch/x86/pci/amdtemp.c
diff -u src/sys/arch/x86/pci/amdtemp.c:1.21 src/sys/arch/x86/pci/amdtemp.c:1.22
--- src/sys/arch/x86/pci/amdtemp.c:1.21	Thu Sep 27 14:59:43 2018
+++ src/sys/arch/x86/pci/amdtemp.c	Wed Dec 12 23:35:04 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdtemp.c,v 1.21 2018/09/27 14:59:43 maxv Exp $ */
+/*  $NetBSD: amdtemp.c,v 1.22 2018/12/12 23:35:04 is Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.21 2018/09/27 14:59:43 maxv Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.22 2018/12/12 23:35:04 is Exp $ ");
 
 #include 
 #include 
@@ -206,7 +206,7 @@ amdtemp_match(device_t parent, cfdata_t 
 	}
 
 	/* Not yet supported CPUs. */
-	if (family > 0x15)
+	if (family > 0x16)
 		return 0;
 
 	return 1;
@@ -251,6 +251,7 @@ amdtemp_attach(device_t parent, device_t
 	case 0x12: /* AMD Lynx/Sabine (Llano) */
 	case 0x14: /* AMD Brazos (Ontario/Zacate/Desna) */
 	case 0x15:
+	case 0x16:
 		amdtemp_family10_init(sc);
 		break;
 
@@ -278,6 +279,7 @@ amdtemp_attach(device_t parent, device_t
 	case 0x12:
 	case 0x14:
 	case 0x15:
+	case 0x16:
 		amdtemp_family10_setup_sensors(sc, device_unit(self));
 		break;
 	}
@@ -305,6 +307,7 @@ amdtemp_attach(device_t parent, device_t
 	case 0x12:
 	case 0x14:
 	case 0x15:
+	case 0x16:
 		sc->sc_sme->sme_refresh = amdtemp_family10_refresh;
 		break;
 	}



CVS commit: src/sys/arch/x86/pci

2018-11-27 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue Nov 27 21:03:50 UTC 2018

Modified Files:
src/sys/arch/x86/pci: pci_intr_machdep.c

Log Message:
actually allow pci_intr_alloc() with NULL count with MSI-X


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/x86/pci/pci_intr_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.46 src/sys/arch/x86/pci/pci_intr_machdep.c:1.47
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.46	Tue Nov 27 20:08:05 2018
+++ src/sys/arch/x86/pci/pci_intr_machdep.c	Tue Nov 27 21:03:50 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_intr_machdep.c,v 1.46 2018/11/27 20:08:05 jdolecek Exp $	*/
+/*	$NetBSD: pci_intr_machdep.c,v 1.47 2018/11/27 21:03:50 jdolecek Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.46 2018/11/27 20:08:05 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.47 2018/11/27 21:03:50 jdolecek Exp $");
 
 #include 
 #include 
@@ -543,9 +543,8 @@ pci_intr_alloc(const struct pci_attach_a
 	if (msix_count > 0) {
 		error = pci_msix_alloc_exact(pa, ihps, msix_count);
 		if (error == 0) {
-			KASSERTMSG(counts != NULL,
-			"If MSI-X is used, counts must not be NULL.");
-			counts[PCI_INTR_TYPE_MSIX] = msix_count;
+			if (counts != NULL)
+counts[PCI_INTR_TYPE_MSIX] = msix_count;
 			goto out;
 		}
 	}



CVS commit: src/sys/arch/x86/pci

2018-09-27 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Sep 27 14:59:43 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdtemp.c

Log Message:
Improve a bit, no real functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/x86/pci/amdtemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdtemp.c
diff -u src/sys/arch/x86/pci/amdtemp.c:1.20 src/sys/arch/x86/pci/amdtemp.c:1.21
--- src/sys/arch/x86/pci/amdtemp.c:1.20	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/pci/amdtemp.c	Thu Sep 27 14:59:43 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdtemp.c,v 1.20 2017/06/01 02:45:08 chs Exp $ */
+/*  $NetBSD: amdtemp.c,v 1.21 2018/09/27 14:59:43 maxv Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -46,9 +46,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.20 2017/06/01 02:45:08 chs Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.21 2018/09/27 14:59:43 maxv Exp $ ");
 
 #include 
 #include 
@@ -103,17 +102,13 @@ __KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 
 #define K8_T_SEL_S0(v)   (v &= ~(K8_THERM_SENSE_SEL))
 #define K8_T_SEL_S1(v)   (v |= K8_THERM_SENSE_SEL)
 
-
-
 /*
  * AMD Family 10h Processors, Function 3 -- Miscellaneous Control
  */
 
 /* Function 3 Registers */
 #define F10_TEMPERATURE_CTL_R	0xa4
-
-/* Bits within Reported Temperature Control Register */
-#define F10_TEMP_CURTEMP	(1 << 21)
+#define 	F10_TEMP_CURTMP		__BITS(31,21)
 
 /*
  * Revision Guide for AMD NPT Family 0Fh Processors,
@@ -124,10 +119,10 @@ __KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 
 #define K8_SOCKET_S1	3	/* Laptop */
 
 static const struct {
-	const char  rev[5];
+	const char rev[5];
 	const struct {
-		const pcireg_t  cpuid;
-		const uint8_t   socket;
+		const pcireg_t cpuid;
+		const uint8_t socket;
 	} cpu[5];
 } amdtemp_core[] = {
 	{ "BH-F", { { 0x00040FB0, K8_SOCKET_AM2 },	/* F2 */
@@ -151,22 +146,20 @@ static const struct {
 		  { 0, 0 } } }
 };
 
-
 struct amdtemp_softc {
-pci_chipset_tag_t sc_pc;
-pcitag_t sc_pcitag;
+	pci_chipset_tag_t sc_pc;
+	pcitag_t sc_pcitag;
 
 	struct sysmon_envsys *sc_sme;
 	envsys_data_t *sc_sensor;
 	size_t sc_sensor_len;
 
-char sc_rev;
-int8_t sc_numsensors;
+	char sc_rev;
+	int8_t sc_numsensors;
 	uint32_t sc_family;
 	int32_t sc_adjustment;
 };
 
-
 static int  amdtemp_match(device_t, cfdata_t, void *);
 static void amdtemp_attach(device_t, device_t, void *);
 static int  amdtemp_detach(device_t, int);
@@ -180,7 +173,7 @@ static void amdtemp_family10_setup_senso
 static void amdtemp_family10_refresh(struct sysmon_envsys *, envsys_data_t *);
 
 CFATTACH_DECL_NEW(amdtemp, sizeof(struct amdtemp_softc),
-	amdtemp_match, amdtemp_attach, amdtemp_detach, NULL);
+amdtemp_match, amdtemp_attach, amdtemp_detach, NULL);
 
 static int
 amdtemp_match(device_t parent, cfdata_t match, void *aux)
@@ -194,8 +187,10 @@ amdtemp_match(device_t parent, cfdata_t 
 	cpu_signature = pci_conf_read(pa->pa_pc,
 	pa->pa_tag, CPUID_FAMILY_MODEL_R);
 
-	/* This CPUID northbridge register has been introduced
-	 * in Revision F */
+	/*
+	 * This CPUID northbridge register has been introduced in
+	 * Revision F.
+	 */
 	if (cpu_signature == 0x0)
 		return 0;
 
@@ -205,13 +200,12 @@ amdtemp_match(device_t parent, cfdata_t 
 	if (family == 0x10) {
 		if (CPUID_TO_BASEMODEL(cpu_signature) < 4)
 			return 0;
-		if (CPUID_TO_BASEMODEL(cpu_signature) == 4
-		&& CPUID_TO_STEPPING(cpu_signature) < 2)
+		if (CPUID_TO_BASEMODEL(cpu_signature) == 4 &&
+		CPUID_TO_STEPPING(cpu_signature) < 2)
 			return 0;
 	}
 
-
-	/* Not yet supported CPUs */
+	/* Not yet supported CPUs. */
 	if (family > 0x15)
 		return 0;
 
@@ -262,7 +256,7 @@ amdtemp_attach(device_t parent, device_t
 
 	default:
 		aprint_normal(", family 0x%x not supported\n",
-			 sc->sc_family);
+		sc->sc_family);
 		return;
 	}
 
@@ -292,8 +286,7 @@ amdtemp_attach(device_t parent, device_t
 	 * Set properties in sensors.
 	 */
 	for (i = 0; i < sc->sc_numsensors; i++) {
-		if (sysmon_envsys_sensor_attach(sc->sc_sme,
-		>sc_sensor[i]))
+		if (sysmon_envsys_sensor_attach(sc->sc_sme, >sc_sensor[i]))
 			goto bad;
 	}
 
@@ -371,8 +364,8 @@ amdtemp_k8_init(struct amdtemp_softc *sc
 
 			sc->sc_rev = amdtemp_core[i].rev[3];
 			aprint_normal(": core rev %.4s%.1x",
-amdtemp_core[i].rev,
-CPUID_TO_STEPPING(cpu_signature));
+			amdtemp_core[i].rev,
+			CPUID_TO_STEPPING(cpu_signature));
 
 			switch (amdtemp_core[i].cpu[j].socket) {
 			case K8_SOCKET_AM2:
@@ -391,9 +384,11 @@ amdtemp_k8_init(struct amdtemp_softc *sc
 	}
 
 	if (sc->sc_rev == '\0') {
-		/* CPUID Family Model Register was introduced in
-		 * Revision F */
-		sc->sc_rev = 'G';   /* newer than E, assume G */
+		/*
+		 * CPUID Family Model Register 

CVS commit: src/sys/arch/x86/pci

2018-09-22 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Sun Sep 23 02:51:06 UTC 2018

Modified Files:
src/sys/arch/x86/pci: pci_intr_machdep.c

Log Message:
Revert:
http://mail-index.netbsd.org/source-changes/2018/09/10/msg098995.html

It is incorrect to infer semantics from usage.

the problem for which the original commit was intended should be fixed
within the callee intr_establish_xname() and not the caller:
pci_intr_find_intx_irq()

This was accomplished via:
http://mail-index.netbsd.org/source-changes/2018/09/20/msg099286.html


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/x86/pci/pci_intr_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.44 src/sys/arch/x86/pci/pci_intr_machdep.c:1.45
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.44	Mon Sep 10 02:49:23 2018
+++ src/sys/arch/x86/pci/pci_intr_machdep.c	Sun Sep 23 02:51:06 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_intr_machdep.c,v 1.44 2018/09/10 02:49:23 cherry Exp $	*/
+/*	$NetBSD: pci_intr_machdep.c,v 1.45 2018/09/23 02:51:06 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.44 2018/09/10 02:49:23 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.45 2018/09/23 02:51:06 cherry Exp $");
 
 #include 
 #include 
@@ -294,7 +294,9 @@ pci_intr_find_intx_irq(pci_intr_handle_t
 			return ENOENT;
 		*pic = >sc_pic;
 		*pin = APIC_IRQ_PIN(ih);
-		*irq = -1; /* PCI doesn't use legacy irq */
+		*irq = APIC_IRQ_LEGACY_IRQ(ih);
+		if (*irq < 0 || *irq >= NUM_LEGACY_IRQS)
+			*irq = -1;
 	}
 #endif
 



CVS commit: src/sys/arch/x86/pci

2018-09-09 Thread Cherry G. Mathew
Module Name:src
Committed By:   cherry
Date:   Mon Sep 10 02:49:23 UTC 2018

Modified Files:
src/sys/arch/x86/pci: pci_intr_machdep.c

Log Message:
In the NIOAPIC case, we do not need to support "legacy" irqs,
ie; We don't need to simultaneously pass back the irq in the
range 0 < irq < 16 (which are sometimes described as "legacy"
in src

This was non-obvious, until the semantics of "legacy" were
used in inconsistent ways in Xen (to also mean interrupts in
the 0 < irq < 256 range) which causes problems with attempting
to unify the sys/arch/x86/isa/isa_machdep.c:isa_intr_establish_xname()
function between XEN and !XEN

This commit should not affect current functionality on any
either native or Xen. It is needed for future code reorg, and
published now as a preview.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x86/pci/pci_intr_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.43 src/sys/arch/x86/pci/pci_intr_machdep.c:1.44
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.43	Sun Jun 24 11:51:15 2018
+++ src/sys/arch/x86/pci/pci_intr_machdep.c	Mon Sep 10 02:49:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_intr_machdep.c,v 1.43 2018/06/24 11:51:15 jdolecek Exp $	*/
+/*	$NetBSD: pci_intr_machdep.c,v 1.44 2018/09/10 02:49:23 cherry Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.43 2018/06/24 11:51:15 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.44 2018/09/10 02:49:23 cherry Exp $");
 
 #include 
 #include 
@@ -294,9 +294,7 @@ pci_intr_find_intx_irq(pci_intr_handle_t
 			return ENOENT;
 		*pic = >sc_pic;
 		*pin = APIC_IRQ_PIN(ih);
-		*irq = APIC_IRQ_LEGACY_IRQ(ih);
-		if (*irq < 0 || *irq >= NUM_LEGACY_IRQS)
-			*irq = -1;
+		*irq = -1; /* PCI doesn't use legacy irq */
 	}
 #endif
 



CVS commit: src/sys/arch/x86/pci

2018-07-25 Thread Lars Reichardt
Module Name:src
Committed By:   para
Date:   Wed Jul 25 19:10:41 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdzentemp.c

Log Message:
adjust for possible 49K offset

presence of this offset is indicated by a set 19th bit which is shifted away
this brings the temperature to "normal" levels on my ryzen 2700
(I assumed the same 49K offset as the k10temp project)


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.7 src/sys/arch/x86/pci/amdzentemp.c:1.8
--- src/sys/arch/x86/pci/amdzentemp.c:1.7	Fri Jan 26 23:01:44 2018
+++ src/sys/arch/x86/pci/amdzentemp.c	Wed Jul 25 19:10:41 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.7 2018/01/26 23:01:44 pgoyette Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.8 2018/07/25 19:10:41 para Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -50,7 +50,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.7 2018/01/26 23:01:44 pgoyette Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.8 2018/07/25 19:10:41 para Exp $ ");
 
 #include 
 #include 
@@ -219,6 +219,9 @@ amdzentemp_family17_refresh(struct sysmo
 	edata->state = ENVSYS_SVALID;
 	/* From C to uK. */  
 	edata->value_cur = ((temp >> 21) * 125000) + 27315;
+	/* adjust for possible offset of 49K */
+	if (temp & 0x8) 
+		edata->value_cur -= 4900;
 }
 
 MODULE(MODULE_CLASS_DRIVER, amdzentemp, "sysmon_envsys,amdsmn");



CVS commit: src/sys/arch/x86/pci

2018-07-10 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Jul 10 06:44:49 UTC 2018

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
Fix bug, SPINOUT() is not supposed to take the value given to BACKOFF().
Here the exponential backoff is wrecked.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.82 src/sys/arch/x86/pci/pci_machdep.c:1.83
--- src/sys/arch/x86/pci/pci_machdep.c:1.82	Sat Jun 23 16:09:53 2018
+++ src/sys/arch/x86/pci/pci_machdep.c	Tue Jul 10 06:44:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.82 2018/06/23 16:09:53 jakllsch Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.83 2018/07/10 06:44:49 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.82 2018/06/23 16:09:53 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.83 2018/07/10 06:44:49 maxv Exp $");
 
 #include 
 #include 
@@ -340,20 +340,23 @@ pci_conf_lock(struct pci_conf_lock *ocl,
 	if (cpuno == cl->cl_cpuno) {
 		ocl->cl_cpuno = cpuno;
 	} else {
-		u_int spins;
+#ifdef LOCKDEBUG
+		u_int spins = 0;
+#endif
+		u_int count;
+		count = SPINLOCK_BACKOFF_MIN;
 
 		ocl->cl_cpuno = 0;
 
-		spins = SPINLOCK_BACKOFF_MIN;
 		while (atomic_cas_32(>cl_cpuno, 0, cpuno) != 0) {
-			SPINLOCK_BACKOFF(spins);
+			SPINLOCK_BACKOFF(count);
 #ifdef LOCKDEBUG
 			if (SPINLOCK_SPINOUT(spins)) {
 panic("%s: cpu %" PRId32
 " spun out waiting for cpu %" PRId32,
 __func__, cpuno, cl->cl_cpuno);
 			}
-#endif	/* LOCKDEBUG */
+#endif
 		}
 	}
 



CVS commit: src/sys/arch/x86/pci

2018-06-23 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Jun 23 16:09:53 UTC 2018

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
Disable all contemporary mode 1 quirks.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.81 src/sys/arch/x86/pci/pci_machdep.c:1.82
--- src/sys/arch/x86/pci/pci_machdep.c:1.81	Sat Jun 23 16:05:05 2018
+++ src/sys/arch/x86/pci/pci_machdep.c	Sat Jun 23 16:09:53 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.81 2018/06/23 16:05:05 jakllsch Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.82 2018/06/23 16:09:53 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.81 2018/06/23 16:05:05 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.82 2018/06/23 16:09:53 jakllsch Exp $");
 
 #include 
 #include 
@@ -204,6 +204,7 @@ const struct {
 	/* XXX Triflex2 not tested */
 	_qe(0, 0, 0, PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX2),
 	_qe(0, 0, 0, PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX4),
+#if 0
 	/* Triton needed for Connectix Virtual PC */
 	_qe(0, 0, 0, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82437FX),
 	/* Connectix Virtual PC 5 has a 440BX */
@@ -217,6 +218,7 @@ const struct {
 	_qe(0, 0, 0, PCI_VENDOR_SIS, PCI_PRODUCT_SIS_741),
 	/* VIA Technologies VX900 */
 	_qe(0, 0, 0, PCI_VENDOR_VIATECH, PCI_PRODUCT_VIATECH_VX900_HB)
+#endif
 };
 #undef _tag
 #undef _qe
@@ -730,7 +732,6 @@ pci_mode_detect(void)
 	uint32_t sav, val;
 	int i;
 	pcireg_t idreg;
-	extern char cpu_brand_string[];
 
 	if (pci_mode != -1)
 		return pci_mode;
@@ -761,6 +762,8 @@ pci_mode_detect(void)
 		}
 	}
 
+#if 0
+	extern char cpu_brand_string[];
 	const char *reason, *system_vendor, *system_product;
 	if (memcmp(cpu_brand_string, "QEMU", 4) == 0)
 		/* PR 45671, https://bugs.launchpad.net/qemu/+bug/897771 */
@@ -779,7 +782,7 @@ pci_mode_detect(void)
 #endif
 		return (pci_mode);
 	}
-
+#endif
 	/*
 	 * Strong check for standard compliant mode 1:
 	 * 1. bit 31 ("enable") can be set



CVS commit: src/sys/arch/x86/pci

2018-06-23 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Jun 23 16:05:05 UTC 2018

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
If mode 1 enable check fails, give mode 1 a second chance by trying to
use it to locate a PCI Host Bridge or device from vendor that produced
a chipset lacking a Host Bridge class device.

Should allow us to remove most all the mode 1 quirks added in the last
two decades.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.80 src/sys/arch/x86/pci/pci_machdep.c:1.81
--- src/sys/arch/x86/pci/pci_machdep.c:1.80	Wed Apr 11 10:34:19 2018
+++ src/sys/arch/x86/pci/pci_machdep.c	Sat Jun 23 16:05:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.80 2018/04/11 10:34:19 nonaka Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.81 2018/06/23 16:05:05 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.80 2018/04/11 10:34:19 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.81 2018/06/23 16:05:05 jakllsch Exp $");
 
 #include 
 #include 
@@ -433,6 +433,30 @@ pci_conf_select(uint32_t sel)
 	}
 }
 
+static int
+pci_mode_check(void)
+{
+	pcireg_t x;
+	pcitag_t t;
+	int device;
+	const int maxdev = pci_bus_maxdevs(NULL, 0);
+
+	for (device = 0; device < maxdev; device++) {
+		t = pci_make_tag(NULL, 0, device, 0);
+		x = pci_conf_read(NULL, t, PCI_CLASS_REG);
+		if (PCI_CLASS(x) == PCI_CLASS_BRIDGE &&
+		PCI_SUBCLASS(x) == PCI_SUBCLASS_BRIDGE_HOST)
+			return 0;
+		x = pci_conf_read(NULL, t, PCI_ID_REG);
+		switch (PCI_VENDOR(x)) {
+		case PCI_VENDOR_COMPAQ:
+		case PCI_VENDOR_INTEL:
+		case PCI_VENDOR_VIATECH:
+			return 0;
+		}
+	}
+	return -1;
+}
 #ifdef __HAVE_PCI_MSI_MSIX
 static int
 pci_has_msi_quirk(pcireg_t id, int type)
@@ -769,6 +793,13 @@ pci_mode_detect(void)
 #ifdef DEBUG
 		printf("%s: mode 1 enable failed (%x)\n", __func__, val);
 #endif
+		/* Try out mode 1 to see if we can find a host bridge. */
+		if (pci_mode_check() == 0) {
+#ifdef DEBUG
+			printf("%s: mode 1 functional, using\n", __func__);
+#endif
+			return (pci_mode);
+		}
 		goto not1;
 	}
 	outl(PCI_MODE1_ADDRESS_REG, 0);



CVS commit: src/sys/arch/x86/pci

2018-06-03 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun  3 10:13:54 UTC 2018

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
Constify lpcib_devices[] so that it lands in .rodata (1584 bytes).


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.51 src/sys/arch/x86/pci/ichlpcib.c:1.52
--- src/sys/arch/x86/pci/ichlpcib.c:1.51	Sat Aug  6 21:57:04 2016
+++ src/sys/arch/x86/pci/ichlpcib.c	Sun Jun  3 10:13:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.51 2016/08/06 21:57:04 jakllsch Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.52 2018/06/03 10:13:54 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.51 2016/08/06 21:57:04 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.52 2018/06/03 10:13:54 maxv Exp $");
 
 #include 
 #include 
@@ -163,7 +163,7 @@ struct lpcib_softc *speedstep_cookie;	/*
 CFATTACH_DECL2_NEW(ichlpcib, sizeof(struct lpcib_softc),
 lpcibmatch, lpcibattach, lpcibdetach, NULL, lpcibrescan, lpcibchilddet);
 
-static struct lpcib_device {
+static const struct lpcib_device {
 	pcireg_t vendor, product;
 	int has_rcba;
 	int has_ich5_hpet;
@@ -291,7 +291,7 @@ static int
 lpcibmatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct pci_attach_args *pa = aux;
-	struct lpcib_device *lpcib_dev;
+	const struct lpcib_device *lpcib_dev;
 
 	/* We are ISA bridge, of course */
 	if (PCI_CLASS(pa->pa_class) != PCI_CLASS_BRIDGE ||
@@ -312,7 +312,7 @@ lpcibattach(device_t parent, device_t se
 {
 	struct pci_attach_args *pa = aux;
 	struct lpcib_softc *sc = device_private(self);
-	struct lpcib_device *lpcib_dev;
+	const struct lpcib_device *lpcib_dev;
 	pcireg_t pmbase;
 
 	sc->sc_pa = *pa;



CVS commit: src/sys/arch/x86/pci

2018-04-16 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Apr 16 09:12:52 UTC 2018

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
vmx(4): compute if_ibytes using rxq->vxrxq_stats.vmrxs_ibytes.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.23 src/sys/arch/x86/pci/if_vmx.c:1.24
--- src/sys/arch/x86/pci/if_vmx.c:1.23	Mon Apr 16 09:10:42 2018
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Apr 16 09:12:52 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.23 2018/04/16 09:10:42 nonaka Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.24 2018/04/16 09:12:52 nonaka Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.23 2018/04/16 09:10:42 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.24 2018/04/16 09:12:52 nonaka Exp $");
 
 #include 
 #include 
@@ -2894,6 +2894,7 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 	case SIOCGIFDATA:
 	case SIOCZIFDATA:
 		ifp->if_ipackets = 0;
+		ifp->if_ibytes = 0;
 		ifp->if_iqdrops = 0;
 		ifp->if_ierrors = 0;
 		for (int i = 0; i < sc->vmx_nrxqueues; i++) {
@@ -2901,6 +2902,7 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 
 			VMXNET3_RXQ_LOCK(rxq);
 			ifp->if_ipackets += rxq->vxrxq_stats.vmrxs_ipackets;
+			ifp->if_ibytes += rxq->vxrxq_stats.vmrxs_ibytes;
 			ifp->if_iqdrops += rxq->vxrxq_stats.vmrxs_iqdrops;
 			ifp->if_ierrors += rxq->vxrxq_stats.vmrxs_ierrors;
 			if (cmd == SIOCZIFDATA) {



CVS commit: src/sys/arch/x86/pci

2018-04-16 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Apr 16 09:10:42 UTC 2018

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
vmx(4): handled SIOCZIFDATA.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.22 src/sys/arch/x86/pci/if_vmx.c:1.23
--- src/sys/arch/x86/pci/if_vmx.c:1.22	Mon Apr 16 03:21:43 2018
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Apr 16 09:10:42 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.22 2018/04/16 03:21:43 nonaka Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.23 2018/04/16 09:10:42 nonaka Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.22 2018/04/16 03:21:43 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.23 2018/04/16 09:10:42 nonaka Exp $");
 
 #include 
 #include 
@@ -2892,27 +2892,38 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 		splx(s);
 		break;
 	case SIOCGIFDATA:
+	case SIOCZIFDATA:
 		ifp->if_ipackets = 0;
 		ifp->if_iqdrops = 0;
 		ifp->if_ierrors = 0;
 		for (int i = 0; i < sc->vmx_nrxqueues; i++) {
-			ifp->if_ipackets +=
-			sc->vmx_rxq[i].vxrxq_stats.vmrxs_ipackets;
-			ifp->if_iqdrops +=
-			sc->vmx_rxq[i].vxrxq_stats.vmrxs_iqdrops;
-			ifp->if_ierrors +=
-			sc->vmx_rxq[i].vxrxq_stats.vmrxs_ierrors;
+			struct vmxnet3_rxqueue *rxq = >vmx_rxq[i];
+
+			VMXNET3_RXQ_LOCK(rxq);
+			ifp->if_ipackets += rxq->vxrxq_stats.vmrxs_ipackets;
+			ifp->if_iqdrops += rxq->vxrxq_stats.vmrxs_iqdrops;
+			ifp->if_ierrors += rxq->vxrxq_stats.vmrxs_ierrors;
+			if (cmd == SIOCZIFDATA) {
+memset(>vxrxq_stats, 0,
+sizeof(rxq->vxrxq_stats));
+			}
+			VMXNET3_RXQ_UNLOCK(rxq);
 		}
 		ifp->if_opackets = 0;
 		ifp->if_obytes = 0;
 		ifp->if_omcasts = 0;
 		for (int i = 0; i < sc->vmx_ntxqueues; i++) {
-			ifp->if_opackets +=
-			sc->vmx_txq[i].vxtxq_stats.vmtxs_opackets;
-			ifp->if_obytes +=
-			sc->vmx_txq[i].vxtxq_stats.vmtxs_obytes;
-			ifp->if_omcasts +=
-			sc->vmx_txq[i].vxtxq_stats.vmtxs_omcasts;
+			struct vmxnet3_txqueue *txq = >vmx_txq[i];
+
+			VMXNET3_TXQ_LOCK(txq);
+			ifp->if_opackets += txq->vxtxq_stats.vmtxs_opackets;
+			ifp->if_obytes += txq->vxtxq_stats.vmtxs_obytes;
+			ifp->if_omcasts += txq->vxtxq_stats.vmtxs_omcasts;
+			if (cmd == SIOCZIFDATA) {
+memset(>vxtxq_stats, 0,
+sizeof(txq->vxtxq_stats));
+			}
+			VMXNET3_TXQ_UNLOCK(txq);
 		}
 		/* FALLTHROUGH */
 	default:



CVS commit: src/sys/arch/x86/pci

2018-04-15 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Apr 16 03:21:43 UTC 2018

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
vmx(4): Fix calculation of interface statistics counter.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.21 src/sys/arch/x86/pci/if_vmx.c:1.22
--- src/sys/arch/x86/pci/if_vmx.c:1.21	Mon Feb 12 17:01:22 2018
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Apr 16 03:21:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.21 2018/02/12 17:01:22 maxv Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.22 2018/04/16 03:21:43 nonaka Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.21 2018/02/12 17:01:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.22 2018/04/16 03:21:43 nonaka Exp $");
 
 #include 
 #include 
@@ -2892,20 +2892,26 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long 
 		splx(s);
 		break;
 	case SIOCGIFDATA:
+		ifp->if_ipackets = 0;
+		ifp->if_iqdrops = 0;
+		ifp->if_ierrors = 0;
 		for (int i = 0; i < sc->vmx_nrxqueues; i++) {
-			ifp->if_ipackets =
+			ifp->if_ipackets +=
 			sc->vmx_rxq[i].vxrxq_stats.vmrxs_ipackets;
-			ifp->if_iqdrops =
+			ifp->if_iqdrops +=
 			sc->vmx_rxq[i].vxrxq_stats.vmrxs_iqdrops;
-			ifp->if_ierrors =
+			ifp->if_ierrors +=
 			sc->vmx_rxq[i].vxrxq_stats.vmrxs_ierrors;
 		}
+		ifp->if_opackets = 0;
+		ifp->if_obytes = 0;
+		ifp->if_omcasts = 0;
 		for (int i = 0; i < sc->vmx_ntxqueues; i++) {
-			ifp->if_opackets =
+			ifp->if_opackets +=
 			sc->vmx_txq[i].vxtxq_stats.vmtxs_opackets;
-			ifp->if_obytes =
+			ifp->if_obytes +=
 			sc->vmx_txq[i].vxtxq_stats.vmtxs_obytes;
-			ifp->if_omcasts =
+			ifp->if_omcasts +=
 			sc->vmx_txq[i].vxtxq_stats.vmtxs_omcasts;
 		}
 		/* FALLTHROUGH */



CVS commit: src/sys/arch/x86/pci

2018-04-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 11 10:34:20 UTC 2018

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
efiboot reports parent ppb bus/device/function of booted network inteface.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.79 src/sys/arch/x86/pci/pci_machdep.c:1.80
--- src/sys/arch/x86/pci/pci_machdep.c:1.79	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed Apr 11 10:34:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.80 2018/04/11 10:34:19 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.79 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.80 2018/04/11 10:34:19 nonaka Exp $");
 
 #include 
 #include 
@@ -98,6 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -149,6 +150,10 @@ __KERNEL_RCSID(0, "$NetBSD: pci_machdep.
 #include 
 #endif
 
+#ifndef XEN
+#include 
+#endif
+
 #include "opt_pci_conf_mode.h"
 
 #ifdef PCI_CONF_MODE
@@ -1016,6 +1021,7 @@ device_t
 device_pci_register(device_t dev, void *aux)
 {
 	static bool found_console = false;
+	device_t parent = device_parent(dev);
 
 	device_pci_props_register(dev, aux);
 
@@ -1037,8 +1043,7 @@ device_pci_register(device_t dev, void *
 		 * information (checked below) must be sufficient to
 		 * identify the device.
 		 */
-		if (bin->bus == BI_BUS_PCI &&
-		device_is_a(device_parent(dev), "pci")) {
+		if (bin->bus == BI_BUS_PCI && device_is_a(parent, "pci")) {
 			struct pci_attach_args *paa = aux;
 			int b, d, f;
 
@@ -1052,9 +1057,23 @@ device_pci_register(device_t dev, void *
 			pci_decompose_tag(paa->pa_pc, paa->pa_tag, , , );
 			if (bin->addr.tag == ((b << 8) | (d << 3) | f))
 return dev;
+
+#ifndef XEN
+			/*
+			 * efiboot reports parent ppb bus/device/function.
+			 */
+			device_t grand = device_parent(parent);
+			if (efi_probe() && grand && device_is_a(grand, "ppb")) {
+struct ppb_softc *ppb_sc = device_private(grand);
+pci_decompose_tag(ppb_sc->sc_pc, ppb_sc->sc_tag,
+, , );
+if (bin->addr.tag == ((b << 8) | (d << 3) | f))
+	return dev;
+			}
+#endif
 		}
 	}
-	if (device_parent(dev) && device_is_a(device_parent(dev), "pci") &&
+	if (parent && device_is_a(parent, "pci") &&
 	found_console == false) {
 		struct btinfo_framebuffer *fbinfo;
 		struct pci_attach_args *pa = aux;



CVS commit: src/sys/arch/x86/pci/imcsmb

2018-03-15 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Thu Mar 15 23:57:18 UTC 2018

Modified Files:
src/sys/arch/x86/pci/imcsmb: imc.c

Log Message:
Provide a default case also when building imc as builtin.

Fixes ALL kernel build. ok pgoyette.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/imcsmb/imc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/imcsmb/imc.c
diff -u src/sys/arch/x86/pci/imcsmb/imc.c:1.1 src/sys/arch/x86/pci/imcsmb/imc.c:1.2
--- src/sys/arch/x86/pci/imcsmb/imc.c:1.1	Thu Mar  1 04:45:06 2018
+++ src/sys/arch/x86/pci/imcsmb/imc.c	Thu Mar 15 23:57:17 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: imc.c,v 1.1 2018/03/01 04:45:06 pgoyette Exp $ */
+/* $NetBSD: imc.c,v 1.2 2018/03/15 23:57:17 maya Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imc.c,v 1.1 2018/03/01 04:45:06 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imc.c,v 1.2 2018/03/15 23:57:17 maya Exp $");
 
 #include 
 #include 
@@ -394,10 +394,8 @@ imc_modcmd(modcmd_t cmd, void *opaque)
 			mutex_destroy(_access_mutex);
 		break;
 	default:
-#ifdef _MODULE
 		error = ENOTTY;
 		break;
-#endif
 	}
 
 	return error;



CVS commit: src/sys/arch/x86/pci/imcsmb

2018-03-02 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Mar  3 05:27:02 UTC 2018

Modified Files:
src/sys/arch/x86/pci/imcsmb: imcsmb.c

Log Message:
Fix the attach message - needs a ": "


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/imcsmb/imcsmb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/imcsmb/imcsmb.c
diff -u src/sys/arch/x86/pci/imcsmb/imcsmb.c:1.1 src/sys/arch/x86/pci/imcsmb/imcsmb.c:1.2
--- src/sys/arch/x86/pci/imcsmb/imcsmb.c:1.1	Thu Mar  1 04:45:06 2018
+++ src/sys/arch/x86/pci/imcsmb/imcsmb.c	Sat Mar  3 05:27:02 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: imcsmb.c,v 1.1 2018/03/01 04:45:06 pgoyette Exp $ */
+/* $NetBSD: imcsmb.c,v 1.2 2018/03/03 05:27:02 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: imcsmb.c,v 1.1 2018/03/01 04:45:06 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imcsmb.c,v 1.2 2018/03/03 05:27:02 pgoyette Exp $");
 
 #include 
 #include 
@@ -123,7 +123,7 @@ imcsmb_attach(device_t parent, device_t 
 	struct imc_attach_args *imca = aux;
 
 	aprint_naive("\n");
-	aprint_normal("SMBus controller\n");
+	aprint_normal(": SMBus controller\n");
 
 	/* Initialize private state */
 	sc->sc_dev = self;



CVS commit: src/sys/arch/x86/pci

2018-02-12 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Feb 12 17:01:22 UTC 2018

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
m_free -> m_freem, otherwise leak


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.20 src/sys/arch/x86/pci/if_vmx.c:1.21
--- src/sys/arch/x86/pci/if_vmx.c:1.20	Tue Sep 26 07:42:05 2017
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Feb 12 17:01:22 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.20 2017/09/26 07:42:05 knakahara Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.21 2018/02/12 17:01:22 maxv Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.20 2017/09/26 07:42:05 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.21 2018/02/12 17:01:22 maxv Exp $");
 
 #include 
 #include 
@@ -2527,7 +2527,7 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
 		offset = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
 		break;
 	default:
-		m_free(m);
+		m_freem(m);
 		return (EINVAL);
 	}
 



CVS commit: src/sys/arch/x86/pci

2018-01-27 Thread Frank Kardel
Module Name:src
Committed By:   kardel
Date:   Sat Jan 27 21:24:30 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdsmn.c

Log Message:
rescan amdsmnbus instead of amdsmn (fixes panic)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/pci/amdsmn.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdsmn.c
diff -u src/sys/arch/x86/pci/amdsmn.c:1.2 src/sys/arch/x86/pci/amdsmn.c:1.3
--- src/sys/arch/x86/pci/amdsmn.c:1.2	Thu Jan 25 23:37:33 2018
+++ src/sys/arch/x86/pci/amdsmn.c	Sat Jan 27 21:24:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdsmn.c,v 1.2 2018/01/25 23:37:33 pgoyette Exp $	*/
+/*	$NetBSD: amdsmn.c,v 1.3 2018/01/27 21:24:30 kardel Exp $	*/
 
 /*-
  * Copyright (c) 2017 Conrad Meyer 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.2 2018/01/25 23:37:33 pgoyette Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.3 2018/01/27 21:24:30 kardel Exp $ ");
 
 /*
  * Driver for the AMD Family 17h CPU System Management Network.
@@ -101,7 +101,7 @@ amdsmn_attach(device_t parent, device_t 
 	sc->pc = pa->pa_pc;
 	sc->pcitag = pa->pa_tag;
 	aprint_normal(": AMD Family 17h System Management Network\n");
-	amdsmn_rescan(self, "amdsmn", );
+	amdsmn_rescan(self, "amdsmnbus", );
 }
 
 static int



CVS commit: src/sys/arch/x86/pci

2018-01-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 27 00:21:42 UTC 2018

Modified Files:
src/sys/arch/x86/pci: files.pci

Log Message:
provide an intermediate "bus" for the module and to be the same structure
like amdtemp


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/x86/pci/files.pci

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/files.pci
diff -u src/sys/arch/x86/pci/files.pci:1.22 src/sys/arch/x86/pci/files.pci:1.23
--- src/sys/arch/x86/pci/files.pci:1.22	Wed Jan 24 20:22:21 2018
+++ src/sys/arch/x86/pci/files.pci	Fri Jan 26 19:21:41 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.22 2018/01/25 01:22:21 christos Exp $
+#	$NetBSD: files.pci,v 1.23 2018/01/27 00:21:41 christos Exp $
 
 device 	aapic
 attach 	aapic at pci
@@ -10,6 +10,7 @@ define	agp_x86: agp_ali, agp_amd, agp_am
 defflag	AGP_X86
 
 define amdnb_miscbus {}
+define amdsmnbus {}
 
 # PCI-Host bridge chipsets
 device	pchb:	pcibus, agpbus, agp_x86
@@ -36,13 +37,13 @@ attach	amdnb_misc at pci
 file	arch/x86/pci/amdnb_misc.c	amdnb_misc
  
 # AMD Family 17h system management network
-device	amdsmn {}
+device	amdsmn: amdsmnbus
 attach	amdsmn at pci
 file arch/x86/pci/amdsmn.c		amdsmn
 
 # AMD Family 17h CPU temp sensor
 device	amdzentemp: sysmon_envsys
-attach	amdzentemp at amdsmn
+attach	amdzentemp at amdsmnbus
 file	arch/x86/pci/amdzentemp.c		amdzentemp
 
 device	amdtemp: sysmon_envsys



CVS commit: src/sys/arch/x86/pci

2018-01-26 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Jan 26 23:01:44 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdzentemp.c

Log Message:
sc->sc_sensor cannot be NULL since it was just allocated with KM_SLEEP
(which cannot fail).  So remove the NULL-check.  CID/1428644


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.6 src/sys/arch/x86/pci/amdzentemp.c:1.7
--- src/sys/arch/x86/pci/amdzentemp.c:1.6	Thu Jan 25 23:37:33 2018
+++ src/sys/arch/x86/pci/amdzentemp.c	Fri Jan 26 23:01:44 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.6 2018/01/25 23:37:33 pgoyette Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.7 2018/01/26 23:01:44 pgoyette Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -50,7 +50,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.6 2018/01/25 23:37:33 pgoyette Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.7 2018/01/26 23:01:44 pgoyette Exp $ ");
 
 #include 
 #include 
@@ -167,10 +167,8 @@ bad:
 		sc->sc_sme = NULL;
 	}
 
-	if (sc->sc_sensor != NULL) {
-		kmem_free(sc->sc_sensor, sc->sc_sensor_len);
-		sc->sc_sensor = NULL;
-	}
+	kmem_free(sc->sc_sensor, sc->sc_sensor_len);
+	sc->sc_sensor = NULL;
 }
 
 static int



CVS commit: src/sys/arch/x86/pci

2018-01-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jan 25 23:37:34 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdsmn.c amdzentemp.c

Log Message:
Modularize the amdsmn(4) driver, and update dependency for amdzentemp(4)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/amdsmn.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdsmn.c
diff -u src/sys/arch/x86/pci/amdsmn.c:1.1 src/sys/arch/x86/pci/amdsmn.c:1.2
--- src/sys/arch/x86/pci/amdsmn.c:1.1	Thu Jan 25 01:22:21 2018
+++ src/sys/arch/x86/pci/amdsmn.c	Thu Jan 25 23:37:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdsmn.c,v 1.1 2018/01/25 01:22:21 christos Exp $	*/
+/*	$NetBSD: amdsmn.c,v 1.2 2018/01/25 23:37:33 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2017 Conrad Meyer 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.1 2018/01/25 01:22:21 christos Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.2 2018/01/25 23:37:33 pgoyette Exp $ ");
 
 /*
  * Driver for the AMD Family 17h CPU System Management Network.
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -49,6 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1
 #include 
 
 #include "amdsmn.h"
+#include "ioconf.h"
 
 #define	SMN_ADDR_REG	0x60
 #define	SMN_DATA_REG	0x64
@@ -63,11 +65,12 @@ struct amdsmn_softc {
 
 static int amdsmn_match(device_t, cfdata_t, void *);
 static void amdsmn_attach(device_t, device_t, void *);
+static int amdsmn_rescan(device_t, const char *, const int *);
 static int amdsmn_detach(device_t, int);
 static int amdsmn_misc_search(device_t, cfdata_t, const int *, void *);
 
-CFATTACH_DECL_NEW(amdsmn, sizeof(struct amdsmn_softc), amdsmn_match,
-amdsmn_attach, amdsmn_detach, NULL);
+CFATTACH_DECL3_NEW(amdsmn, sizeof(struct amdsmn_softc), amdsmn_match,
+amdsmn_attach, amdsmn_detach, NULL, amdsmn_rescan, NULL, 0);
 
 static int
 amdsmn_match(device_t parent, cfdata_t match, void *aux) 
@@ -91,13 +94,24 @@ amdsmn_attach(device_t parent, device_t 
 {
 	struct amdsmn_softc *sc = device_private(self);
 	struct pci_attach_args *pa = aux;
+	int flags = 0;
 
 	mutex_init(>smn_lock, MUTEX_DEFAULT, IPL_NONE);
 	sc->pa = *pa;
 	sc->pc = pa->pa_pc;
 	sc->pcitag = pa->pa_tag;
 	aprint_normal(": AMD Family 17h System Management Network\n");
-	config_search_loc(amdsmn_misc_search, self, "amdsmn", NULL, >pa);
+	amdsmn_rescan(self, "amdsmn", );
+}
+
+static int
+amdsmn_rescan(device_t self, const char *ifattr, const int *flags)
+{
+	struct amdsmn_softc *sc = device_private(self);
+
+	config_search_loc(amdsmn_misc_search, self, ifattr, NULL, >pa);
+
+	return 0;
 }
 
 static int
@@ -136,3 +150,34 @@ amdsmn_write(device_t dev, uint32_t addr
 
 	return 0;
 }
+
+MODULE(MODULE_CLASS_DRIVER, amdsmn, "pci");
+
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
+
+static int
+amdsmn_modcmd(modcmd_t cmd, void *opaque)
+{
+	int error = 0;
+
+#ifdef _MODULE
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		error = config_init_component(cfdriver_ioconf_amdsmn,
+		cfattach_ioconf_amdsmn, cfdata_ioconf_amdsmn);
+		break;
+	case MODULE_CMD_FINI:
+		error = config_fini_component(cfdriver_ioconf_amdsmn,
+		cfattach_ioconf_amdsmn, cfdata_ioconf_amdsmn);
+		break;
+	default:
+		error = ENOTTY;
+		break;
+	}
+#endif
+
+	return error;
+}
+

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.5 src/sys/arch/x86/pci/amdzentemp.c:1.6
--- src/sys/arch/x86/pci/amdzentemp.c:1.5	Thu Jan 25 22:37:42 2018
+++ src/sys/arch/x86/pci/amdzentemp.c	Thu Jan 25 23:37:33 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.5 2018/01/25 22:37:42 pgoyette Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.6 2018/01/25 23:37:33 pgoyette Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -50,7 +50,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.5 2018/01/25 22:37:42 pgoyette Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.6 2018/01/25 23:37:33 pgoyette Exp $ ");
 
 #include 
 #include 
@@ -223,7 +223,7 @@ amdzentemp_family17_refresh(struct sysmo
 	edata->value_cur = ((temp >> 21) * 125000) + 27315;
 }
 
-MODULE(MODULE_CLASS_DRIVER, amdzentemp, "sysmon_envsys");
+MODULE(MODULE_CLASS_DRIVER, amdzentemp, "sysmon_envsys,amdsmn");
 
 #ifdef _MODULE
 #include "ioconf.c"



CVS commit: src/sys/arch/x86/pci

2018-01-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jan 25 22:37:42 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdzentemp.c

Log Message:
Correct placement of __diagused attribute


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.4 src/sys/arch/x86/pci/amdzentemp.c:1.5
--- src/sys/arch/x86/pci/amdzentemp.c:1.4	Thu Jan 25 22:14:01 2018
+++ src/sys/arch/x86/pci/amdzentemp.c	Thu Jan 25 22:37:42 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.4 2018/01/25 22:14:01 pgoyette Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.5 2018/01/25 22:37:42 pgoyette Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -50,7 +50,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.4 2018/01/25 22:14:01 pgoyette Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.5 2018/01/25 22:37:42 pgoyette Exp $ ");
 
 #include 
 #include 
@@ -98,7 +98,7 @@ CFATTACH_DECL_NEW(amdzentemp, sizeof(str
 static int
 amdzentemp_match(device_t parent, cfdata_t match, void *aux)
 {
-	struct pci_attach_args *pa = aux __diagused;
+	struct pci_attach_args *pa __diagused = aux;
 
 	KASSERT(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD);
  



CVS commit: src/sys/arch/x86/pci

2018-01-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jan 25 22:14:01 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdzentemp.c

Log Message:
Put back the variable declaration, too, and mark it __diagused

Otherwise a DIAGNOSTIC kernel will complain about the variable being
undeclared.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.3 src/sys/arch/x86/pci/amdzentemp.c:1.4
--- src/sys/arch/x86/pci/amdzentemp.c:1.3	Thu Jan 25 21:23:36 2018
+++ src/sys/arch/x86/pci/amdzentemp.c	Thu Jan 25 22:14:01 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.3 2018/01/25 21:23:36 pgoyette Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.4 2018/01/25 22:14:01 pgoyette Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -50,7 +50,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.3 2018/01/25 21:23:36 pgoyette Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.4 2018/01/25 22:14:01 pgoyette Exp $ ");
 
 #include 
 #include 
@@ -98,6 +98,7 @@ CFATTACH_DECL_NEW(amdzentemp, sizeof(str
 static int
 amdzentemp_match(device_t parent, cfdata_t match, void *aux)
 {
+	struct pci_attach_args *pa = aux __diagused;
 
 	KASSERT(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD);
  



CVS commit: src/sys/arch/x86/pci

2018-01-25 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jan 25 21:23:36 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdzentemp.c

Log Message:
KNF: Put back the blank line following the empty variable declarations


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.2 src/sys/arch/x86/pci/amdzentemp.c:1.3
--- src/sys/arch/x86/pci/amdzentemp.c:1.2	Thu Jan 25 15:01:05 2018
+++ src/sys/arch/x86/pci/amdzentemp.c	Thu Jan 25 21:23:36 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.2 2018/01/25 15:01:05 prlw1 Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.3 2018/01/25 21:23:36 pgoyette Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -50,7 +50,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.2 2018/01/25 15:01:05 prlw1 Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.3 2018/01/25 21:23:36 pgoyette Exp $ ");
 
 #include 
 #include 
@@ -98,6 +98,7 @@ CFATTACH_DECL_NEW(amdzentemp, sizeof(str
 static int
 amdzentemp_match(device_t parent, cfdata_t match, void *aux)
 {
+
 	KASSERT(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD);
  
 	cfdata_t parent_cfdata = device_cfdata(parent);



CVS commit: src/sys/arch/x86/pci

2018-01-25 Thread Patrick Welche
Module Name:src
Committed By:   prlw1
Date:   Thu Jan 25 15:01:05 UTC 2018

Modified Files:
src/sys/arch/x86/pci: amdzentemp.c

Log Message:
Unused variable build fix. (now void *aux is unused)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/amdzentemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdzentemp.c
diff -u src/sys/arch/x86/pci/amdzentemp.c:1.1 src/sys/arch/x86/pci/amdzentemp.c:1.2
--- src/sys/arch/x86/pci/amdzentemp.c:1.1	Thu Jan 25 01:22:21 2018
+++ src/sys/arch/x86/pci/amdzentemp.c	Thu Jan 25 15:01:05 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdzentemp.c,v 1.1 2018/01/25 01:22:21 christos Exp $ */
+/*  $NetBSD: amdzentemp.c,v 1.2 2018/01/25 15:01:05 prlw1 Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -50,7 +50,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.1 2018/01/25 01:22:21 christos Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdzentemp.c,v 1.2 2018/01/25 15:01:05 prlw1 Exp $ ");
 
 #include 
 #include 
@@ -98,8 +98,6 @@ CFATTACH_DECL_NEW(amdzentemp, sizeof(str
 static int
 amdzentemp_match(device_t parent, cfdata_t match, void *aux)
 {
-	struct pci_attach_args *pa = aux;
-
 	KASSERT(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD);
  
 	cfdata_t parent_cfdata = device_cfdata(parent);



CVS commit: src/sys/arch/x86/pci

2018-01-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 25 01:22:21 UTC 2018

Modified Files:
src/sys/arch/x86/pci: files.pci
Added Files:
src/sys/arch/x86/pci: amdsmn.c amdsmn.h amdzentemp.c

Log Message:
Add amdzentemp from FreeBSD via Ian Clark


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/pci/amdsmn.c \
src/sys/arch/x86/pci/amdsmn.h src/sys/arch/x86/pci/amdzentemp.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/x86/pci/files.pci

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/files.pci
diff -u src/sys/arch/x86/pci/files.pci:1.21 src/sys/arch/x86/pci/files.pci:1.22
--- src/sys/arch/x86/pci/files.pci:1.21	Sun Dec 10 12:12:54 2017
+++ src/sys/arch/x86/pci/files.pci	Wed Jan 24 20:22:21 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.21 2017/12/10 17:12:54 bouyer Exp $
+#	$NetBSD: files.pci,v 1.22 2018/01/25 01:22:21 christos Exp $
 
 device 	aapic
 attach 	aapic at pci
@@ -34,6 +34,16 @@ filearch/x86/pci/amdpcib_hpet.c		amd
 device	amdnb_misc: amdnb_miscbus
 attach	amdnb_misc at pci
 file	arch/x86/pci/amdnb_misc.c	amdnb_misc
+ 
+# AMD Family 17h system management network
+device	amdsmn {}
+attach	amdsmn at pci
+file arch/x86/pci/amdsmn.c		amdsmn
+
+# AMD Family 17h CPU temp sensor
+device	amdzentemp: sysmon_envsys
+attach	amdzentemp at amdsmn
+file	arch/x86/pci/amdzentemp.c		amdzentemp
 
 device	amdtemp: sysmon_envsys
 attach	amdtemp at amdnb_miscbus

Added files:

Index: src/sys/arch/x86/pci/amdsmn.c
diff -u /dev/null src/sys/arch/x86/pci/amdsmn.c:1.1
--- /dev/null	Wed Jan 24 20:22:21 2018
+++ src/sys/arch/x86/pci/amdsmn.c	Wed Jan 24 20:22:21 2018
@@ -0,0 +1,138 @@
+/*	$NetBSD: amdsmn.c,v 1.1 2018/01/25 01:22:21 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2017 Conrad Meyer 
+ * All rights reserved.
+ *
+ * NetBSD port by Ian Clark 
+ *
+ * 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 ``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 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 
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.1 2018/01/25 01:22:21 christos Exp $ ");
+
+/*
+ * Driver for the AMD Family 17h CPU System Management Network.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "amdsmn.h"
+
+#define	SMN_ADDR_REG	0x60
+#define	SMN_DATA_REG	0x64
+#define	AMD_17H_MANAGEMENT_NETWORK_PCI_ID	0x14501022
+
+struct amdsmn_softc {
+	kmutex_t smn_lock;
+	struct pci_attach_args pa;
+	pci_chipset_tag_t pc;
+	pcitag_t pcitag;
+};
+
+static int amdsmn_match(device_t, cfdata_t, void *);
+static void amdsmn_attach(device_t, device_t, void *);
+static int amdsmn_detach(device_t, int);
+static int amdsmn_misc_search(device_t, cfdata_t, const int *, void *);
+
+CFATTACH_DECL_NEW(amdsmn, sizeof(struct amdsmn_softc), amdsmn_match,
+amdsmn_attach, amdsmn_detach, NULL);
+
+static int
+amdsmn_match(device_t parent, cfdata_t match, void *aux) 
+{
+	struct pci_attach_args *pa = aux;
+	
+	return pa->pa_id == AMD_17H_MANAGEMENT_NETWORK_PCI_ID ? 2 : 0;
+}
+
+static int 
+amdsmn_misc_search(device_t parent, cfdata_t cf, const int *locs, void *aux) 
+{
+	if (config_match(parent, cf, aux))
+		config_attach_loc(parent, cf, locs, aux, NULL);
+
+	return 0;
+}
+
+static void 
+amdsmn_attach(device_t parent, device_t self, void *aux) 
+{
+	struct amdsmn_softc *sc = device_private(self);
+	struct pci_attach_args *pa = aux;
+
+	mutex_init(>smn_lock, MUTEX_DEFAULT, IPL_NONE);
+	sc->pa = *pa;
+	sc->pc = pa->pa_pc;
+	sc->pcitag = pa->pa_tag;
+	aprint_normal(": AMD Family 17h System Management Network\n");
+	config_search_loc(amdsmn_misc_search, self, "amdsmn", NULL, >pa);
+}
+
+static int
+amdsmn_detach(device_t self, int flags) 

CVS commit: src/sys/arch/x86/pci

2017-07-28 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Jul 28 14:26:51 UTC 2017

Modified Files:
src/sys/arch/x86/pci: msipic.c pci_addr_fixup.c pci_intr_machdep.c
pci_msi_machdep.c

Log Message:
Don't include malloc.h.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/pci/msipic.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/pci/pci_addr_fixup.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x86/pci/pci_intr_machdep.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/pci/pci_msi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.10 src/sys/arch/x86/pci/msipic.c:1.11
--- src/sys/arch/x86/pci/msipic.c:1.10	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/pci/msipic.c	Fri Jul 28 14:26:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.10 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: msipic.c,v 1.11 2017/07/28 14:26:50 maxv Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.10 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.11 2017/07/28 14:26:50 maxv Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -36,7 +36,6 @@ __KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 

Index: src/sys/arch/x86/pci/pci_addr_fixup.c
diff -u src/sys/arch/x86/pci/pci_addr_fixup.c:1.9 src/sys/arch/x86/pci/pci_addr_fixup.c:1.10
--- src/sys/arch/x86/pci/pci_addr_fixup.c:1.9	Fri Jan 27 18:53:06 2012
+++ src/sys/arch/x86/pci/pci_addr_fixup.c	Fri Jul 28 14:26:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_addr_fixup.c,v 1.9 2012/01/27 18:53:06 para Exp $	*/
+/*	$NetBSD: pci_addr_fixup.c,v 1.10 2017/07/28 14:26:50 maxv Exp $	*/
 
 /*-
  * Copyright (c) 2000 UCHIYAMA Yasushi.  All rights reserved.
@@ -27,11 +27,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_addr_fixup.c,v 1.9 2012/01/27 18:53:06 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_addr_fixup.c,v 1.10 2017/07/28 14:26:50 maxv Exp $");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Index: src/sys/arch/x86/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.40 src/sys/arch/x86/pci/pci_intr_machdep.c:1.41
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.40	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/pci/pci_intr_machdep.c	Fri Jul 28 14:26:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_intr_machdep.c,v 1.40 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: pci_intr_machdep.c,v 1.41 2017/07/28 14:26:50 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.40 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.41 2017/07/28 14:26:50 maxv Exp $");
 
 #include 
 #include 
@@ -84,7 +84,6 @@ __KERNEL_RCSID(0, "$NetBSD: pci_intr_mac
 #include 
 #include 
 #include 
-#include 
 
 #include 
 

Index: src/sys/arch/x86/pci/pci_msi_machdep.c
diff -u src/sys/arch/x86/pci/pci_msi_machdep.c:1.12 src/sys/arch/x86/pci/pci_msi_machdep.c:1.13
--- src/sys/arch/x86/pci/pci_msi_machdep.c:1.12	Thu Jun  1 02:45:08 2017
+++ src/sys/arch/x86/pci/pci_msi_machdep.c	Fri Jul 28 14:26:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_msi_machdep.c,v 1.12 2017/06/01 02:45:08 chs Exp $	*/
+/*	$NetBSD: pci_msi_machdep.c,v 1.13 2017/07/28 14:26:50 maxv Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.12 2017/06/01 02:45:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.13 2017/07/28 14:26:50 maxv Exp $");
 
 #include "opt_intrdebug.h"
 #include "ioapic.h"
@@ -48,7 +48,6 @@ __KERNEL_RCSID(0, "$NetBSD: pci_msi_mach
 #include 
 #include 
 #include 
-#include 
 
 #include 
 



CVS commit: src/sys/arch/x86/pci

2017-04-14 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Apr 14 09:34:46 UTC 2017

Modified Files:
src/sys/arch/x86/pci: pci_msi_machdep.c

Log Message:
disable msi/msix when the system doesn't detect ioapic. This would fix PR 
kern/52111.

Some system does not detect ioapic when "boot -1", disable acpi, and so on.
In such cases, msi/msix doesn't work, so disable them.

This patch is implemented by nonaka@n.o, I just commit by proxy, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/pci/pci_msi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_msi_machdep.c
diff -u src/sys/arch/x86/pci/pci_msi_machdep.c:1.10 src/sys/arch/x86/pci/pci_msi_machdep.c:1.11
--- src/sys/arch/x86/pci/pci_msi_machdep.c:1.10	Mon Nov 28 05:00:41 2016
+++ src/sys/arch/x86/pci/pci_msi_machdep.c	Fri Apr 14 09:34:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_msi_machdep.c,v 1.10 2016/11/28 05:00:41 knakahara Exp $	*/
+/*	$NetBSD: pci_msi_machdep.c,v 1.11 2017/04/14 09:34:46 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,9 +34,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.10 2016/11/28 05:00:41 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.11 2017/04/14 09:34:46 knakahara Exp $");
 
 #include "opt_intrdebug.h"
+#include "ioapic.h"
 
 #include 
 #include 
@@ -162,6 +163,13 @@ pci_msi_alloc_common(pci_intr_handle_t *
 	pci_intr_handle_t *vectors;
 	int error, i;
 
+#if NIOAPIC > 0
+	if (nioapics == 0) {
+		DPRINTF(("no IOAPIC.\n"));
+		return ENODEV;
+	}
+#endif
+
 	if ((pa->pa_flags & PCI_FLAGS_MSI_OKAY) == 0) {
 		DPRINTF(("PCI host bridge does not support MSI.\n"));
 		return ENODEV;
@@ -244,6 +252,13 @@ pci_msix_alloc_common(pci_intr_handle_t 
 	pci_intr_handle_t *vectors;
 	int error, i;
 
+#if NIOAPIC > 0
+	if (nioapics == 0) {
+		DPRINTF(("no IOAPIC.\n"));
+		return ENODEV;
+	}
+#endif
+
 	if ((pa->pa_flags & PCI_FLAGS_MSIX_OKAY) == 0) {
 		DPRINTF(("PCI host bridge does not support MSI-X.\n"));
 		return ENODEV;



CVS commit: src/sys/arch/x86/pci

2017-02-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Feb 20 09:02:01 UTC 2017

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Apply deferred if_start to vmx(4).


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.18 src/sys/arch/x86/pci/if_vmx.c:1.19
--- src/sys/arch/x86/pci/if_vmx.c:1.18	Wed Jan 11 00:55:57 2017
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Feb 20 09:02:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.18 2017/01/11 00:55:57 maya Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.19 2017/02/20 09:02:01 knakahara Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.18 2017/01/11 00:55:57 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.19 2017/02/20 09:02:01 knakahara Exp $");
 
 #include 
 #include 
@@ -2158,7 +2158,7 @@ vmxnet3_legacy_intr(void *xsc)
 
 	VMXNET3_TXQ_LOCK(txq);
 	vmxnet3_txq_eof(txq);
-	vmxnet3_start_locked(>vmx_ethercom.ec_if);
+	if_schedule_deferred_start(>vmx_ethercom.ec_if);
 	VMXNET3_TXQ_UNLOCK(txq);
 
 	vmxnet3_enable_all_intrs(sc);
@@ -2180,7 +2180,7 @@ vmxnet3_txq_intr(void *xtxq)
 
 	VMXNET3_TXQ_LOCK(txq);
 	vmxnet3_txq_eof(txq);
-	vmxnet3_start_locked(>vmx_ethercom.ec_if);
+	if_schedule_deferred_start(>vmx_ethercom.ec_if);
 	VMXNET3_TXQ_UNLOCK(txq);
 
 	vmxnet3_enable_intr(sc, txq->vxtxq_intr_idx);



CVS commit: src/sys/arch/x86/pci

2017-02-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Feb  9 03:38:01 UTC 2017

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
 Supress verbose message "This pci host supports neither MSI nor MSI-X."
on VMware and KVM. OK'd by k-nakahara.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.76 src/sys/arch/x86/pci/pci_machdep.c:1.77
--- src/sys/arch/x86/pci/pci_machdep.c:1.76	Thu Aug 25 12:21:21 2016
+++ src/sys/arch/x86/pci/pci_machdep.c	Thu Feb  9 03:38:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.76 2016/08/25 12:21:21 nonaka Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.77 2017/02/09 03:38:01 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.76 2016/08/25 12:21:21 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.77 2017/02/09 03:38:01 msaitoh Exp $");
 
 #include 
 #include 
@@ -483,7 +483,12 @@ pci_attach_hook(device_t parent, device_
 	PCI_SUBCLASS(class) != PCI_SUBCLASS_BRIDGE_HOST)
 		return;
 
-	if (pci_has_msi_quirk(id, PCI_QUIRK_DISABLE_MSI)) {
+	/* VMware and KVM use old chipset, but they can use MSI/MSI-X */
+	if ((cpu_feature[1] & CPUID2_RAZ)
+	&& (pci_has_msi_quirk(id, PCI_QUIRK_ENABLE_MSI_VM))) {
+			pba->pba_flags |= PCI_FLAGS_MSI_OKAY;
+			pba->pba_flags |= PCI_FLAGS_MSIX_OKAY;
+	} else if (pci_has_msi_quirk(id, PCI_QUIRK_DISABLE_MSI)) {
 		pba->pba_flags &= ~PCI_FLAGS_MSI_OKAY;
 		pba->pba_flags &= ~PCI_FLAGS_MSIX_OKAY;
 		aprint_verbose("\n");
@@ -500,14 +505,6 @@ pci_attach_hook(device_t parent, device_
 		pba->pba_flags |= PCI_FLAGS_MSIX_OKAY;
 	}
 
-	/* VMware and KVM use old chipset, but they can use MSI/MSI-X */
-	if (cpu_feature[1] & CPUID2_RAZ) {
-		if (pci_has_msi_quirk(id, PCI_QUIRK_ENABLE_MSI_VM)) {
-			pba->pba_flags |= PCI_FLAGS_MSI_OKAY;
-			pba->pba_flags |= PCI_FLAGS_MSIX_OKAY;
-		}
-	}
-
 	/*
 	 * Don't enable MSI on a HyperTransport bus.  In order to
 	 * determine that bus 0 is a HyperTransport bus, we look at



CVS commit: src/sys/arch/x86/pci

2017-01-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Jan 11 00:55:57 UTC 2017

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
we cannot guarantee that m_pulldown doesn't fail, as it may fail even
if temporarily out of memory, and it will free the mbuf in this scenario.

test for failure and return error if it happens.

CID 1396651

ok riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.17 src/sys/arch/x86/pci/if_vmx.c:1.18
--- src/sys/arch/x86/pci/if_vmx.c:1.17	Wed Jan 11 00:51:22 2017
+++ src/sys/arch/x86/pci/if_vmx.c	Wed Jan 11 00:55:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.17 2017/01/11 00:51:22 maya Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.18 2017/01/11 00:55:57 maya Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.17 2017/01/11 00:51:22 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.18 2017/01/11 00:55:57 maya Exp $");
 
 #include 
 #include 
@@ -2554,6 +2554,10 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
 
 	*csum_start = *start + csum_off;
 	mp = m_pulldown(m, 0, *csum_start + 2, );
+	if (!mp) {
+		/* m is already freed */
+		return ENOBUFS;
+	}
 
 	if (m->m_pkthdr.csum_flags & (M_CSUM_TSOv4 | M_CSUM_TSOv6)) {
 		struct tcphdr *tcp;



CVS commit: src/sys/arch/x86/pci

2017-01-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Jan 11 00:51:22 UTC 2017

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
on error, free the mbuf in vmxnet3_txq_offload_ctx, not in callers.

ok riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.16 src/sys/arch/x86/pci/if_vmx.c:1.17
--- src/sys/arch/x86/pci/if_vmx.c:1.16	Wed Jan 11 00:41:38 2017
+++ src/sys/arch/x86/pci/if_vmx.c	Wed Jan 11 00:51:22 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.16 2017/01/11 00:41:38 maya Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.17 2017/01/11 00:51:22 maya Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.16 2017/01/11 00:41:38 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.17 2017/01/11 00:51:22 maya Exp $");
 
 #include 
 #include 
@@ -2531,6 +2531,7 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
 		offset = ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN;
 		break;
 	default:
+		m_free(m);
 		return (EINVAL);
 	}
 
@@ -2660,9 +2661,9 @@ vmxnet3_txq_encap(struct vmxnet3_txqueue
 	} else if (m->m_pkthdr.csum_flags & VMXNET3_CSUM_ALL_OFFLOAD) {
 		error = vmxnet3_txq_offload_ctx(txq, m, , _start);
 		if (error) {
+			/* m is already freed */
 			txq->vxtxq_stats.vmtxs_offload_failed++;
 			vmxnet3_txq_unload_mbuf(txq, dmap);
-			m_freem(m);
 			*m0 = NULL;
 			return (error);
 		}



CVS commit: src/sys/arch/x86/pci

2017-01-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Jan 11 00:41:38 UTC 2017

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
GC unused macros.

Even if they were used (and actually asserted), asserting on !mutex_owned
is generally a bad idea, as it may be true in unexpected contexts.

suggested by riastradh, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.15 src/sys/arch/x86/pci/if_vmx.c:1.16
--- src/sys/arch/x86/pci/if_vmx.c:1.15	Wed Dec 28 07:32:16 2016
+++ src/sys/arch/x86/pci/if_vmx.c	Wed Jan 11 00:41:38 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.15 2016/12/28 07:32:16 ozaki-r Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.16 2017/01/11 00:41:38 maya Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.15 2016/12/28 07:32:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.16 2017/01/11 00:41:38 maya Exp $");
 
 #include 
 #include 
@@ -97,22 +97,16 @@ __KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1
 #define VMXNET3_CORE_LOCK(_sc)		mutex_enter((_sc)->vmx_mtx)
 #define VMXNET3_CORE_UNLOCK(_sc)	mutex_exit((_sc)->vmx_mtx)
 #define VMXNET3_CORE_LOCK_ASSERT(_sc)	mutex_owned((_sc)->vmx_mtx)
-#define VMXNET3_CORE_LOCK_ASSERT_NOTOWNED(_sc) \
-(!mutex_owned((_sc)->vmx_mtx))
 
 #define VMXNET3_RXQ_LOCK(_rxq)		mutex_enter((_rxq)->vxrxq_mtx)
 #define VMXNET3_RXQ_UNLOCK(_rxq)	mutex_exit((_rxq)->vxrxq_mtx)
 #define VMXNET3_RXQ_LOCK_ASSERT(_rxq)		\
 mutex_owned((_rxq)->vxrxq_mtx)
-#define VMXNET3_RXQ_LOCK_ASSERT_NOTOWNED(_rxq)	\
-(!mutex_owned((_rxq)->vxrxq_mtx))
 
 #define VMXNET3_TXQ_LOCK(_txq)		mutex_enter((_txq)->vxtxq_mtx)
 #define VMXNET3_TXQ_UNLOCK(_txq)	mutex_exit((_txq)->vxtxq_mtx)
 #define VMXNET3_TXQ_LOCK_ASSERT(_txq)		\
 mutex_owned((_txq)->vxtxq_mtx)
-#define VMXNET3_TXQ_LOCK_ASSERT_NOTOWNED(_txq)	\
-(!mutex_owned((_txq)->vxtxq_mtx))
 
 struct vmxnet3_dma_alloc {
 	bus_addr_t dma_paddr;



CVS commit: src/sys/arch/x86/pci

2016-11-29 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Nov 29 22:27:09 UTC 2016

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
PR 51672 David Binderman: M_CSUM_TCPv6, not 2x M_CSUM_TCPv4.
(from context it's quite clear that's what's supposed to be here)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.10 src/sys/arch/x86/pci/if_vmx.c:1.11
--- src/sys/arch/x86/pci/if_vmx.c:1.10	Mon Nov 28 20:12:41 2016
+++ src/sys/arch/x86/pci/if_vmx.c	Tue Nov 29 22:27:09 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.10 2016/11/28 20:12:41 martin Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.11 2016/11/29 22:27:09 dholland Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.10 2016/11/28 20:12:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.11 2016/11/29 22:27:09 dholland Exp $");
 
 #include 
 #include 
@@ -2552,7 +2552,7 @@ vmxnet3_txq_offload_ctx(struct vmxnet3_t
 	*start = offset + iphl;
 
 	if (m->m_pkthdr.csum_flags &
-	(M_CSUM_TCPv4 | M_CSUM_TCPv4 | M_CSUM_TSOv4 | M_CSUM_TSOv6)) {
+	(M_CSUM_TCPv4 | M_CSUM_TCPv6 | M_CSUM_TSOv4 | M_CSUM_TSOv6)) {
 		csum_off = offsetof(struct tcphdr, th_sum);
 	} else {
 		csum_off = offsetof(struct udphdr, uh_sum);



CVS commit: src/sys/arch/x86/pci

2016-11-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 28 20:12:42 UTC 2016

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Mark a variable __diagused as it is only ever used in a KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.9 src/sys/arch/x86/pci/if_vmx.c:1.10
--- src/sys/arch/x86/pci/if_vmx.c:1.9	Fri Nov 25 06:48:37 2016
+++ src/sys/arch/x86/pci/if_vmx.c	Mon Nov 28 20:12:41 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.9 2016/11/25 06:48:37 hikaru Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.10 2016/11/28 20:12:41 martin Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.9 2016/11/25 06:48:37 hikaru Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.10 2016/11/28 20:12:41 martin Exp $");
 
 #include 
 #include 
@@ -2006,7 +2006,7 @@ vmxnet3_rxq_eof(struct vmxnet3_rxqueue *
 	struct ifnet *ifp;
 	struct vmxnet3_rxring *rxr;
 	struct vmxnet3_comp_ring *rxc;
-	struct vmxnet3_rxdesc *rxd;
+	struct vmxnet3_rxdesc *rxd __diagused;
 	struct vmxnet3_rxcompdesc *rxcd;
 	struct mbuf *m, *m_head, *m_tail;
 	int idx, length;



CVS commit: src/sys/arch/x86/pci

2016-11-27 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Nov 28 05:00:41 UTC 2016

Modified Files:
src/sys/arch/x86/pci: pci_intr_machdep.c pci_msi_machdep.c

Log Message:
fix build of amd64/i386 with NO_PCI_MSI_MSIX option.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x86/pci/pci_intr_machdep.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/pci/pci_msi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.38 src/sys/arch/x86/pci/pci_intr_machdep.c:1.39
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.38	Mon Jul 11 06:14:51 2016
+++ src/sys/arch/x86/pci/pci_intr_machdep.c	Mon Nov 28 05:00:41 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_intr_machdep.c,v 1.38 2016/07/11 06:14:51 knakahara Exp $	*/
+/*	$NetBSD: pci_intr_machdep.c,v 1.39 2016/11/28 05:00:41 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.38 2016/07/11 06:14:51 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.39 2016/11/28 05:00:41 knakahara Exp $");
 
 #include 
 #include 
@@ -274,8 +274,8 @@ pci_intr_setattr(pci_chipset_tag_t pc, p
 	}
 }
 
-void *
-pci_intr_establish_xname(pci_chipset_tag_t pc, pci_intr_handle_t ih,
+static void *
+pci_intr_establish_xname_internal(pci_chipset_tag_t pc, pci_intr_handle_t ih,
 int level, int (*func)(void *), void *arg, const char *xname)
 {
 	int pin, irq;
@@ -331,8 +331,19 @@ pci_intr_establish(pci_chipset_tag_t pc,
 int level, int (*func)(void *), void *arg)
 {
 
-	return pci_intr_establish_xname(pc, ih, level, func, arg, "unknown");
+	return pci_intr_establish_xname_internal(pc, ih, level, func, arg, "unknown");
+}
+
+#ifdef __HAVE_PCI_MSI_MSIX
+void *
+pci_intr_establish_xname(pci_chipset_tag_t pc, pci_intr_handle_t ih,
+int level, int (*func)(void *), void *arg, const char *xname)
+{
+
+	return pci_intr_establish_xname_internal(pc, ih, level, func, arg, xname);
 }
+#endif
+
 
 void
 pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
@@ -351,6 +362,7 @@ pci_intr_disestablish(pci_chipset_tag_t 
 }
 
 #if NIOAPIC > 0
+#ifdef __HAVE_PCI_MSI_MSIX
 pci_intr_type_t
 pci_intr_type(pci_chipset_tag_t pc, pci_intr_handle_t ih)
 {
@@ -544,4 +556,5 @@ pci_intr_release(pci_chipset_tag_t pc, p
 	}
 
 }
-#endif
+#endif /* __HAVE_PCI_MSI_MSIX */
+#endif /*  NIOAPIC > 0 */

Index: src/sys/arch/x86/pci/pci_msi_machdep.c
diff -u src/sys/arch/x86/pci/pci_msi_machdep.c:1.9 src/sys/arch/x86/pci/pci_msi_machdep.c:1.10
--- src/sys/arch/x86/pci/pci_msi_machdep.c:1.9	Mon Aug 17 06:16:03 2015
+++ src/sys/arch/x86/pci/pci_msi_machdep.c	Mon Nov 28 05:00:41 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_msi_machdep.c,v 1.9 2015/08/17 06:16:03 knakahara Exp $	*/
+/*	$NetBSD: pci_msi_machdep.c,v 1.10 2016/11/28 05:00:41 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.9 2015/08/17 06:16:03 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.10 2016/11/28 05:00:41 knakahara Exp $");
 
 #include "opt_intrdebug.h"
 
@@ -88,6 +88,7 @@ pci_msi_calculate_handle(struct pic *msi
 	return pih;
 }
 
+#ifdef __HAVE_PCI_MSI_MSIX
 static pci_intr_handle_t *
 pci_msi_alloc_vectors(struct pic *msi_pic, uint *table_indexes, int *count)
 {
@@ -130,6 +131,7 @@ pci_msi_alloc_vectors(struct pic *msi_pi
 
 	return vectors;
 }
+#endif /* __HAVE_PCI_MSI_MSIX */
 
 static void
 pci_msi_free_vectors(struct pic *msi_pic, pci_intr_handle_t *pihs, int count)
@@ -151,6 +153,7 @@ pci_msi_free_vectors(struct pic *msi_pic
 	kmem_free(pihs, sizeof(pihs[0]) * count);
 }
 
+#ifdef __HAVE_PCI_MSI_MSIX
 static int
 pci_msi_alloc_common(pci_intr_handle_t **ihps, int *count,
 const struct pci_attach_args *pa, bool exact)
@@ -205,6 +208,7 @@ pci_msi_alloc_common(pci_intr_handle_t *
 	*ihps = vectors;
 	return 0;
 }
+#endif /* __HAVE_PCI_MSI_MSIX */
 
 static void *
 pci_msi_common_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
@@ -231,6 +235,7 @@ pci_msi_common_disestablish(pci_chipset_
 	intr_disestablish(cookie);
 }
 
+#ifdef __HAVE_PCI_MSI_MSIX
 static int
 pci_msix_alloc_common(pci_intr_handle_t **ihps, u_int *table_indexes,
 int *count, const struct pci_attach_args *pa, bool exact)
@@ -299,6 +304,7 @@ x86_pci_msi_alloc_exact(pci_intr_handle_
 
 	return pci_msi_alloc_common(ihps, , pa, true);
 }
+#endif /* __HAVE_PCI_MSI_MSIX */
 
 static void
 x86_pci_msi_release_internal(pci_intr_handle_t *pihs, int count)
@@ -313,6 +319,7 @@ x86_pci_msi_release_internal(pci_intr_ha
 	msipic_destruct_msi_pic(pic);
 }
 
+#ifdef __HAVE_PCI_MSI_MSIX
 static int
 x86_pci_msix_alloc(pci_intr_handle_t **ihps, int *count,
 const struct pci_attach_args *pa)
@@ -336,6 

CVS commit: src/sys/arch/x86/pci

2016-11-24 Thread Hikaru Abe
Module Name:src
Committed By:   hikaru
Date:   Fri Nov 25 06:48:37 UTC 2016

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Add missing bpf_mtap.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.8 src/sys/arch/x86/pci/if_vmx.c:1.9
--- src/sys/arch/x86/pci/if_vmx.c:1.8	Fri Nov 25 05:29:54 2016
+++ src/sys/arch/x86/pci/if_vmx.c	Fri Nov 25 06:48:37 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.8 2016/11/25 05:29:54 hikaru Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.9 2016/11/25 06:48:37 hikaru Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.8 2016/11/25 05:29:54 hikaru Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.9 2016/11/25 06:48:37 hikaru Exp $");
 
 #include 
 #include 
@@ -1994,6 +1994,8 @@ vmxnet3_rxq_input(struct vmxnet3_rxqueue
 	rxq->vxrxq_stats.vmrxs_ipackets++;
 	rxq->vxrxq_stats.vmrxs_ibytes += m->m_pkthdr.len;
 
+	bpf_mtap(ifp, m);
+
 	if_percpuq_enqueue(ifp->if_percpuq, m);
 }
 



CVS commit: src/sys/arch/x86/pci

2016-11-24 Thread Hikaru Abe
Module Name:src
Committed By:   hikaru
Date:   Fri Nov 25 05:29:55 UTC 2016

Modified Files:
src/sys/arch/x86/pci: if_vmx.c if_vmxreg.h

Log Message:
Sync code with FreeBSD to support RSS

- Use MSI/MSI-X if it is available.
- Support TSO.

co-authored by k-nakahara


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/x86/pci/if_vmx.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/if_vmxreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.7 src/sys/arch/x86/pci/if_vmx.c:1.8
--- src/sys/arch/x86/pci/if_vmx.c:1.7	Fri Jun 10 13:27:13 2016
+++ src/sys/arch/x86/pci/if_vmx.c	Fri Nov 25 05:29:54 2016
@@ -1,8 +1,9 @@
-/*	$NetBSD: if_vmx.c,v 1.7 2016/06/10 13:27:13 ozaki-r Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.8 2016/11/25 05:29:54 hikaru Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
  * Copyright (c) 2013 Tsubai Masanari
+ * Copyright (c) 2013 Bryan Venteicher 
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -18,9 +19,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.7 2016/06/10 13:27:13 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.8 2016/11/25 05:29:54 hikaru Exp $");
 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -35,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1
 #include 	/* for  */
 #include 		/* for  */
 #include 		/* for struct ip */
+#include 	/* for struct ip6_hdr */
 #include 	/* for struct tcphdr */
 #include 	/* for struct udphdr */
 
@@ -44,137 +49,446 @@ __KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1
 
 #include 
 
-#define NRXQUEUE 1
-#define NTXQUEUE 1
+#define VMXNET3_DRIVER_VERSION 0x0001
 
-#define NTXDESC 128 /* tx ring size */
-#define NTXSEGS 8 /* tx descriptors per packet */
-#define NRXDESC 128
-#define NTXCOMPDESC NTXDESC
-#define NRXCOMPDESC (NRXDESC * 2)	/* ring1 + ring2 */
+/*
+ * Max descriptors per Tx packet. We must limit the size of the
+ * any TSO packets based on the number of segments.
+ */
+#define VMXNET3_TX_MAXSEGS		32
+#define VMXNET3_TX_MAXSIZE		(VMXNET3_TX_MAXSEGS * MCLBYTES)
 
-#define VMXNET3_DRIVER_VERSION 0x0001
+/*
+ * Maximum support Tx segments size. The length field in the
+ * Tx descriptor is 14 bits.
+ */
+#define VMXNET3_TX_MAXSEGSIZE		(1 << 14)
+
+/*
+ * The maximum number of Rx segments we accept.
+ */
+#define VMXNET3_MAX_RX_SEGS		0	/* no segments */
+
+/*
+ * Predetermined size of the multicast MACs filter table. If the
+ * number of multicast addresses exceeds this size, then the
+ * ALL_MULTI mode is use instead.
+ */
+#define VMXNET3_MULTICAST_MAX		32
+
+/*
+ * Our Tx watchdog timeout.
+ */
+#define VMXNET3_WATCHDOG_TIMEOUT	5
+
+/*
+ * IP protocols that we can perform Tx checksum offloading of.
+ */
+#define VMXNET3_CSUM_OFFLOAD \
+(M_CSUM_TCPv4 | M_CSUM_UDPv4)
+#define VMXNET3_CSUM_OFFLOAD_IPV6 \
+(M_CSUM_TCPv6 | M_CSUM_UDPv6)
+
+#define VMXNET3_CSUM_ALL_OFFLOAD \
+(VMXNET3_CSUM_OFFLOAD | VMXNET3_CSUM_OFFLOAD_IPV6 | M_CSUM_TSOv4 | M_CSUM_TSOv6)
+
+#define VMXNET3_RXRINGS_PERQ 2
+
+#define VMXNET3_CORE_LOCK(_sc)		mutex_enter((_sc)->vmx_mtx)
+#define VMXNET3_CORE_UNLOCK(_sc)	mutex_exit((_sc)->vmx_mtx)
+#define VMXNET3_CORE_LOCK_ASSERT(_sc)	mutex_owned((_sc)->vmx_mtx)
+#define VMXNET3_CORE_LOCK_ASSERT_NOTOWNED(_sc) \
+(!mutex_owned((_sc)->vmx_mtx))
+
+#define VMXNET3_RXQ_LOCK(_rxq)		mutex_enter((_rxq)->vxrxq_mtx)
+#define VMXNET3_RXQ_UNLOCK(_rxq)	mutex_exit((_rxq)->vxrxq_mtx)
+#define VMXNET3_RXQ_LOCK_ASSERT(_rxq)		\
+mutex_owned((_rxq)->vxrxq_mtx)
+#define VMXNET3_RXQ_LOCK_ASSERT_NOTOWNED(_rxq)	\
+(!mutex_owned((_rxq)->vxrxq_mtx))
+
+#define VMXNET3_TXQ_LOCK(_txq)		mutex_enter((_txq)->vxtxq_mtx)
+#define VMXNET3_TXQ_UNLOCK(_txq)	mutex_exit((_txq)->vxtxq_mtx)
+#define VMXNET3_TXQ_LOCK_ASSERT(_txq)		\
+mutex_owned((_txq)->vxtxq_mtx)
+#define VMXNET3_TXQ_LOCK_ASSERT_NOTOWNED(_txq)	\
+(!mutex_owned((_txq)->vxtxq_mtx))
+
+struct vmxnet3_dma_alloc {
+	bus_addr_t dma_paddr;
+	void *dma_vaddr;
+	bus_dmamap_t dma_map;
+	bus_size_t dma_size;
+	bus_dma_segment_t dma_segs[1];
+};
+
+struct vmxnet3_txbuf {
+	bus_dmamap_t vtxb_dmamap;
+	struct mbuf *vtxb_m;
+};
 
 struct vmxnet3_txring {
-	struct mbuf *m[NTXDESC];
-	bus_dmamap_t dmap[NTXDESC];
-	struct vmxnet3_txdesc *txd;
-	u_int head;
-	u_int next;
-	uint8_t gen;
+	struct vmxnet3_txbuf *vxtxr_txbuf;
+	struct vmxnet3_txdesc *vxtxr_txd;
+	u_int vxtxr_head;
+	u_int vxtxr_next;
+	u_int vxtxr_ndesc;
+	int vxtxr_gen;
+	struct vmxnet3_dma_alloc vxtxr_dma;
+};
+
+struct vmxnet3_rxbuf {
+	bus_dmamap_t vrxb_dmamap;
+	struct mbuf *vrxb_m;
 };
 
 struct vmxnet3_rxring {
-	struct mbuf *m[NRXDESC];
-	bus_dmamap_t dmap[NRXDESC];
-	struct vmxnet3_rxdesc *rxd;
-	u_int fill;
-	

CVS commit: src/sys/arch/x86/pci

2016-10-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Oct  1 21:51:53 UTC 2016

Modified Files:
src/sys/arch/x86/pci: pchb.c

Log Message:
use 4-byte style accesses, should hopefully fix PR#37787.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/pci/pchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pchb.c
diff -u src/sys/arch/x86/pci/pchb.c:1.34 src/sys/arch/x86/pci/pchb.c:1.35
--- src/sys/arch/x86/pci/pchb.c:1.34	Mon Apr 16 04:57:42 2012
+++ src/sys/arch/x86/pci/pchb.c	Sat Oct  1 21:51:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pchb.c,v 1.34 2012/04/16 04:57:42 pgoyette Exp $ */
+/*	$NetBSD: pchb.c,v 1.35 2016/10/01 21:51:52 mrg Exp $ */
 
 /*-
  * Copyright (c) 1996, 1998, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.34 2012/04/16 04:57:42 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.35 2016/10/01 21:51:52 mrg Exp $");
 
 #include 
 #include 
@@ -61,13 +61,13 @@ __KERNEL_RCSID(0, "$NetBSD: pchb.c,v 1.3
 #define	I82443BX_SDRAMC_REG	0x74 /* upper 16 bits */
 
 /* XXX should be in dev/ic/i82424{reg.var}.h */
-#define I82424_CPU_BCTL_REG		0x53
+#define I82424_CPU_BCTL_REG		0x50 /* upper 8 bits */
 #define I82424_PCI_BCTL_REG		0x54
 
-#define I82424_BCTL_CPUMEM_POSTEN	0x01
-#define I82424_BCTL_CPUPCI_POSTEN	0x02
-#define I82424_BCTL_PCIMEM_BURSTEN	0x01
-#define I82424_BCTL_PCI_BURSTEN		0x02
+#define I82424_BCTL_CPUMEM_POSTEN	0x0100
+#define I82424_BCTL_CPUPCI_POSTEN	0x0200
+#define I82424_BCTL_PCIMEM_BURSTEN	0x0100
+#define I82424_BCTL_PCI_BURSTEN		0x0200
 
 static int	pchbmatch(device_t, cfdata_t, void *);
 static void	pchbattach(device_t, device_t, void *);



CVS commit: src/sys/arch/x86/pci

2016-08-25 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Aug 25 12:21:22 UTC 2016

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
more fix line break position in verbose message.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.75 src/sys/arch/x86/pci/pci_machdep.c:1.76
--- src/sys/arch/x86/pci/pci_machdep.c:1.75	Thu Aug 25 11:06:50 2016
+++ src/sys/arch/x86/pci/pci_machdep.c	Thu Aug 25 12:21:21 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.75 2016/08/25 11:06:50 knakahara Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.76 2016/08/25 12:21:21 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.75 2016/08/25 11:06:50 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.76 2016/08/25 12:21:21 nonaka Exp $");
 
 #include 
 #include 
@@ -486,11 +486,15 @@ pci_attach_hook(device_t parent, device_
 	if (pci_has_msi_quirk(id, PCI_QUIRK_DISABLE_MSI)) {
 		pba->pba_flags &= ~PCI_FLAGS_MSI_OKAY;
 		pba->pba_flags &= ~PCI_FLAGS_MSIX_OKAY;
-		aprint_verbose_dev(self, "\nThis pci host supports neither MSI nor MSI-X.");
+		aprint_verbose("\n");
+		aprint_verbose_dev(self,
+		"This pci host supports neither MSI nor MSI-X.");
 	} else if (pci_has_msi_quirk(id, PCI_QUIRK_DISABLE_MSIX)) {
 		pba->pba_flags |= PCI_FLAGS_MSI_OKAY;
 		pba->pba_flags &= ~PCI_FLAGS_MSIX_OKAY;
-		aprint_verbose_dev(self, "\nThis pci host does not support MSI-X.");
+		aprint_verbose("\n");
+		aprint_verbose_dev(self,
+		"This pci host does not support MSI-X.");
 	} else {
 		pba->pba_flags |= PCI_FLAGS_MSI_OKAY;
 		pba->pba_flags |= PCI_FLAGS_MSIX_OKAY;



CVS commit: src/sys/arch/x86/pci

2016-08-25 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Aug 25 11:06:50 UTC 2016

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
fix line break position in verbose message.

pointed out by nonaka@n.o, thanks.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.74 src/sys/arch/x86/pci/pci_machdep.c:1.75
--- src/sys/arch/x86/pci/pci_machdep.c:1.74	Fri Jun 10 23:07:52 2016
+++ src/sys/arch/x86/pci/pci_machdep.c	Thu Aug 25 11:06:50 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.74 2016/06/10 23:07:52 jakllsch Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.75 2016/08/25 11:06:50 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.74 2016/06/10 23:07:52 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.75 2016/08/25 11:06:50 knakahara Exp $");
 
 #include 
 #include 
@@ -486,11 +486,11 @@ pci_attach_hook(device_t parent, device_
 	if (pci_has_msi_quirk(id, PCI_QUIRK_DISABLE_MSI)) {
 		pba->pba_flags &= ~PCI_FLAGS_MSI_OKAY;
 		pba->pba_flags &= ~PCI_FLAGS_MSIX_OKAY;
-		aprint_verbose_dev(self, "This pci host supports neither MSI nor MSI-X.\n");
+		aprint_verbose_dev(self, "\nThis pci host supports neither MSI nor MSI-X.");
 	} else if (pci_has_msi_quirk(id, PCI_QUIRK_DISABLE_MSIX)) {
 		pba->pba_flags |= PCI_FLAGS_MSI_OKAY;
 		pba->pba_flags &= ~PCI_FLAGS_MSIX_OKAY;
-		aprint_verbose_dev(self, "This pci host does not support MSI-X.\n");
+		aprint_verbose_dev(self, "\nThis pci host does not support MSI-X.");
 	} else {
 		pba->pba_flags |= PCI_FLAGS_MSI_OKAY;
 		pba->pba_flags |= PCI_FLAGS_MSIX_OKAY;



CVS commit: src/sys/arch/x86/pci

2016-08-06 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Aug  6 21:57:04 UTC 2016

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
Disable gpio(4) attachment to ichlpcib(4) by default.

The GPIO lines on an ICH are usually connected to opaque platform-
defined functionality, and may be manipulated by the ACPI DSDT or other
mechanisms behind our backs.  In one instance, it was found this
in combiation with gpio_resume() sabotaged repeated suspend/resume cycles.

GPIO functionality can be enabled by setting ichlpcib_gpio_disable to 0,
for instance with `gdb -write`.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.50 src/sys/arch/x86/pci/ichlpcib.c:1.51
--- src/sys/arch/x86/pci/ichlpcib.c:1.50	Sun May 17 04:59:43 2015
+++ src/sys/arch/x86/pci/ichlpcib.c	Sat Aug  6 21:57:04 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.50 2015/05/17 04:59:43 msaitoh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.51 2016/08/06 21:57:04 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.50 2015/05/17 04:59:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.51 2016/08/06 21:57:04 jakllsch Exp $");
 
 #include 
 #include 
@@ -277,6 +277,14 @@ static struct lpcib_device {
 };
 
 /*
+ * Allow user to enable GPIO functionality if they really need it.  The
+ * vast majority of systems with an ICH should not expose GPIO to the
+ * kernel or user.  In at least one instance the gpio_resume() handler
+ * on ICH GPIO was found to sabotage S3 suspend/resume.
+ */
+int	ichlpcib_gpio_disable = 1;
+
+/*
  * Autoconf callbacks.
  */
 static int
@@ -888,6 +896,9 @@ lpcib_gpio_configure(device_t self)
 	int pin, shift, base_reg, cntl_reg, reg;
 	int rv;
 
+	if (ichlpcib_gpio_disable != 0)
+		return;
+
 	/* this implies ICH >= 6, and thus different mapreg */
 	if (sc->sc_has_rcba) {
 		base_reg = LPCIB_PCI_GPIO_BASE_ICH6;



CVS commit: src/sys/arch/x86/pci

2016-06-10 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Jun 10 23:07:52 UTC 2016

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
Avoid trying to create a tag for locating AMD HyperTransport bridge that will
panic a machine that uses Configuration Mechanism 2.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.73 src/sys/arch/x86/pci/pci_machdep.c:1.74
--- src/sys/arch/x86/pci/pci_machdep.c:1.73	Thu Nov 26 16:27:05 2015
+++ src/sys/arch/x86/pci/pci_machdep.c	Fri Jun 10 23:07:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.73 2015/11/26 16:27:05 jakllsch Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.74 2016/06/10 23:07:52 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.73 2015/11/26 16:27:05 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.74 2016/06/10 23:07:52 jakllsch Exp $");
 
 #include 
 #include 
@@ -512,10 +512,12 @@ pci_attach_hook(device_t parent, device_
 	 * If that device has a HyperTransport capability, bus 0 must
 	 * be a HyperTransport bus and we disable MSI.
 	 */
-	tag = pci_make_tag(pc, 0, 24, 0);
-	if (pci_get_capability(pc, tag, PCI_CAP_LDT, NULL, NULL)) {
-		pba->pba_flags &= ~PCI_FLAGS_MSI_OKAY;
-		pba->pba_flags &= ~PCI_FLAGS_MSIX_OKAY;
+	if (24 < pci_bus_maxdevs(pc, 0)) {
+		tag = pci_make_tag(pc, 0, 24, 0);
+		if (pci_get_capability(pc, tag, PCI_CAP_LDT, NULL, NULL)) {
+			pba->pba_flags &= ~PCI_FLAGS_MSI_OKAY;
+			pba->pba_flags &= ~PCI_FLAGS_MSIX_OKAY;
+		}
 	}
 #endif /* __HAVE_PCI_MSI_MSIX */
 }



CVS commit: src/sys/arch/x86/pci

2015-11-26 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Nov 26 16:27:05 UTC 2015

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
Move acpimcfg_map_bus() before no-MSI bailout in pci_attach_hook().


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.72 src/sys/arch/x86/pci/pci_machdep.c:1.73
--- src/sys/arch/x86/pci/pci_machdep.c:1.72	Mon Nov  2 09:29:08 2015
+++ src/sys/arch/x86/pci/pci_machdep.c	Thu Nov 26 16:27:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.72 2015/11/02 09:29:08 knakahara Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.73 2015/11/26 16:27:05 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.72 2015/11/02 09:29:08 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.73 2015/11/26 16:27:05 jakllsch Exp $");
 
 #include 
 #include 
@@ -461,6 +461,9 @@ pci_attach_hook(device_t parent, device_
 #if NACPICA > 0
 	mpacpi_pci_attach_hook(parent, self, pba);
 #endif
+#if NACPICA > 0 && !defined(NO_PCI_EXTENDED_CONFIG)
+	acpimcfg_map_bus(self, pba->pba_pc, pba->pba_bus);
+#endif
 
 #ifdef __HAVE_PCI_MSI_MSIX
 	/*
@@ -515,10 +518,6 @@ pci_attach_hook(device_t parent, device_
 		pba->pba_flags &= ~PCI_FLAGS_MSIX_OKAY;
 	}
 #endif /* __HAVE_PCI_MSI_MSIX */
-
-#if NACPICA > 0 && !defined(NO_PCI_EXTENDED_CONFIG)
-	acpimcfg_map_bus(self, pba->pba_pc, pba->pba_bus);
-#endif
 }
 
 int



CVS commit: src/sys/arch/x86/pci

2015-08-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 30 07:50:34 UTC 2015

Modified Files:
src/sys/arch/x86/pci: tco.c

Log Message:
print the configuration information early so that it does not get intermingled
with possible error prints.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/tco.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/tco.c
diff -u src/sys/arch/x86/pci/tco.c:1.1 src/sys/arch/x86/pci/tco.c:1.2
--- src/sys/arch/x86/pci/tco.c:1.1	Sat May  2 22:50:59 2015
+++ src/sys/arch/x86/pci/tco.c	Sun Aug 30 03:50:34 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: tco.c,v 1.1 2015/05/03 02:50:59 pgoyette Exp $	*/
+/*	$NetBSD: tco.c,v 1.2 2015/08/30 07:50:34 christos Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tco.c,v 1.1 2015/05/03 02:50:59 pgoyette Exp $);
+__KERNEL_RCSID(0, $NetBSD: tco.c,v 1.2 2015/08/30 07:50:34 christos Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -112,6 +112,9 @@ tco_attach(device_t parent, device_t sel
 	sc-sc_pcib = ta-ta_pcib;
 	sc-sc_has_rcba = ta-ta_has_rcba;
 
+	aprint_normal(: TCO (watchdog) timer configured.\n);
+	aprint_naive(\n);
+
 	/* Explicitly stop the TCO timer. */
 	tcotimer_stop(sc);
 
@@ -160,8 +163,6 @@ tco_attach(device_t parent, device_t sel
 	}
 	sc-sc_smw.smw_period = lpcib_tcotimer_tick_to_second(sc-sc_max_t);
 
-	aprint_normal(: TCO (watchdog) timer configured.\n);
-	aprint_naive(\n);
 	aprint_verbose_dev(self, Min/Max interval %u/%u seconds\n,
 		lpcib_tcotimer_tick_to_second(sc-sc_min_t),
 		lpcib_tcotimer_tick_to_second(sc-sc_max_t));



CVS commit: src/sys/arch/x86/pci

2015-08-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Aug 13 04:52:40 UTC 2015

Modified Files:
src/sys/arch/x86/pci: msipic.c

Log Message:
 Add workaround for PCI prefetchable bit in msipic_construct_msix_pic().
Some chips (e.g. Intel 82599) report SERR and MSI-X interrupt doesn't work.
This problem might not be the driver's bug but our PCI common part or VMs'
bug. See fxp(4), ixgbe(4) and ixgbe(4). All of them has the same workaround
related to prefetchable bit. For the MSI-X table area, it should not have side
effect by prefetching. Until we find a real reason, we ignore the prefetchable
bit.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/pci/msipic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.6 src/sys/arch/x86/pci/msipic.c:1.7
--- src/sys/arch/x86/pci/msipic.c:1.6	Thu Aug 13 04:39:33 2015
+++ src/sys/arch/x86/pci/msipic.c	Thu Aug 13 04:52:40 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.6 2015/08/13 04:39:33 msaitoh Exp $	*/
+/*	$NetBSD: msipic.c,v 1.7 2015/08/13 04:52:40 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msipic.c,v 1.6 2015/08/13 04:39:33 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: msipic.c,v 1.7 2015/08/13 04:52:40 msaitoh Exp $);
 
 #include opt_intrdebug.h
 
@@ -619,6 +619,8 @@ msipic_construct_msix_pic(const struct p
 	size_t table_size;
 	uint32_t table_offset;
 	u_int memtype;
+	bus_addr_t memaddr;
+	int flags;
 	int bir, bar, err, off, table_nentry;
 	char pic_name_buf[MSIPICNAMEBUF];
 
@@ -684,9 +686,32 @@ msipic_construct_msix_pic(const struct p
 	  * - Message Lower Address (32bit)
 	  */
 	table_size = table_nentry * PCI_MSIX_TABLE_ENTRY_SIZE;
+#if 0
 	err = pci_mapreg_submap(pa, bar, memtype, BUS_SPACE_MAP_LINEAR,
 	roundup(table_size, PAGE_SIZE), table_offset,
 	bstag, bshandle, NULL, bssize);
+#else
+	/*
+	 * Workaround for PCI prefetchable bit. Some chips (e.g. Intel 82599)
+	 * report SERR and MSI-X doesn't work. This problem might not be the
+	 * driver's bug but our PCI common part or VMs' bug. Until we find a
+	 * real reason, we ignore the prefetchable bit.
+	 */
+	if (pci_mapreg_info(pa-pa_pc, pa-pa_tag, bar, memtype,
+		memaddr, NULL, flags) != 0) {
+		DPRINTF((cannot get a map info.\n));
+		msipic_destruct_common_msi_pic(msix_pic);
+		return NULL;
+	}
+	if ((flags  BUS_SPACE_MAP_PREFETCHABLE) != 0) {
+		DPRINTF(( clear prefetchable bit\n));
+		flags = ~BUS_SPACE_MAP_PREFETCHABLE;
+	}
+	bssize = roundup(table_size, PAGE_SIZE);
+	err = bus_space_map(pa-pa_memt, memaddr + table_offset, bssize, flags,
+	bshandle);
+	bstag = pa-pa_memt;
+#endif
 	if (err) {
 		DPRINTF((cannot map msix table.\n));
 		msipic_destruct_common_msi_pic(msix_pic);



CVS commit: src/sys/arch/x86/pci

2015-08-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Aug 11 04:04:36 UTC 2015

Modified Files:
src/sys/arch/x86/pci: msipic.c pci_msi_machdep.c

Log Message:
 Add missing opt_intrdebug.h.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/pci/msipic.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/pci/pci_msi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.4 src/sys/arch/x86/pci/msipic.c:1.5
--- src/sys/arch/x86/pci/msipic.c:1.4	Fri May  8 04:27:48 2015
+++ src/sys/arch/x86/pci/msipic.c	Tue Aug 11 04:04:36 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.4 2015/05/08 04:27:48 knakahara Exp $	*/
+/*	$NetBSD: msipic.c,v 1.5 2015/08/11 04:04:36 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,9 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msipic.c,v 1.4 2015/05/08 04:27:48 knakahara Exp $);
+__KERNEL_RCSID(0, $NetBSD: msipic.c,v 1.5 2015/08/11 04:04:36 msaitoh Exp $);
+
+#include opt_intrdebug.h
 
 #include sys/types.h
 #include sys/param.h

Index: src/sys/arch/x86/pci/pci_msi_machdep.c
diff -u src/sys/arch/x86/pci/pci_msi_machdep.c:1.6 src/sys/arch/x86/pci/pci_msi_machdep.c:1.7
--- src/sys/arch/x86/pci/pci_msi_machdep.c:1.6	Mon Jun 22 03:57:01 2015
+++ src/sys/arch/x86/pci/pci_msi_machdep.c	Tue Aug 11 04:04:36 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_msi_machdep.c,v 1.6 2015/06/22 03:57:01 msaitoh Exp $	*/
+/*	$NetBSD: pci_msi_machdep.c,v 1.7 2015/08/11 04:04:36 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,9 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_msi_machdep.c,v 1.6 2015/06/22 03:57:01 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_msi_machdep.c,v 1.7 2015/08/11 04:04:36 msaitoh Exp $);
+
+#include opt_intrdebug.h
 
 #include sys/types.h
 #include sys/param.h



CVS commit: src/sys/arch/x86/pci

2015-07-24 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri Jul 24 06:49:58 UTC 2015

Modified Files:
src/sys/arch/x86/pci: pci_intr_machdep.c

Log Message:
fix pci_intr_alloc(..., NULL, 0). reported nonaka@n.o


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/pci/pci_intr_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.34 src/sys/arch/x86/pci/pci_intr_machdep.c:1.35
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.34	Tue Jul 21 03:10:42 2015
+++ src/sys/arch/x86/pci/pci_intr_machdep.c	Fri Jul 24 06:49:58 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_intr_machdep.c,v 1.34 2015/07/21 03:10:42 knakahara Exp $	*/
+/*	$NetBSD: pci_intr_machdep.c,v 1.35 2015/07/24 06:49:58 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_intr_machdep.c,v 1.34 2015/07/21 03:10:42 knakahara Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_intr_machdep.c,v 1.35 2015/07/24 06:49:58 knakahara Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -484,7 +484,8 @@ pci_intr_alloc(const struct pci_attach_a
 		}
 	}
 
-	memset(counts, 0, sizeof(counts[0]) * PCI_INTR_TYPE_SIZE);
+	if (counts != NULL)
+		memset(counts, 0, sizeof(counts[0]) * PCI_INTR_TYPE_SIZE);
 	error = EINVAL;
 
 	/* try MSI-X */
@@ -493,6 +494,8 @@ pci_intr_alloc(const struct pci_attach_a
 	if (msix_count  0) {
 		error = pci_msix_alloc_exact(pa, ihps, msix_count);
 		if (error == 0) {
+			KASSERTMSG(counts != NULL,
+			If MSI-X is used, counts must not be NULL.);
 			counts[PCI_INTR_TYPE_MSIX] = msix_count;
 			goto out;
 		}
@@ -504,10 +507,9 @@ pci_intr_alloc(const struct pci_attach_a
 	if (msi_count  0) {
 		error = pci_msi_alloc_exact(pa, ihps, msi_count);
 		if (error == 0) {
-			if (counts != NULL) {
+			if (counts != NULL)
 counts[PCI_INTR_TYPE_MSI] = msi_count;
-goto out;
-			}
+			goto out;
 		}
 	}
 



CVS commit: src/sys/arch/x86/pci

2015-06-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jun 22 03:57:01 UTC 2015

Modified Files:
src/sys/arch/x86/pci: pci_msi_machdep.c

Log Message:
Don't check PCI_FLAGS_MSI_OKAY in pci_msix_alloc_common().
OK'd by knakahara.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/pci/pci_msi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_msi_machdep.c
diff -u src/sys/arch/x86/pci/pci_msi_machdep.c:1.5 src/sys/arch/x86/pci/pci_msi_machdep.c:1.6
--- src/sys/arch/x86/pci/pci_msi_machdep.c:1.5	Fri May 15 08:36:41 2015
+++ src/sys/arch/x86/pci/pci_msi_machdep.c	Mon Jun 22 03:57:01 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_msi_machdep.c,v 1.5 2015/05/15 08:36:41 knakahara Exp $	*/
+/*	$NetBSD: pci_msi_machdep.c,v 1.6 2015/06/22 03:57:01 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_msi_machdep.c,v 1.5 2015/05/15 08:36:41 knakahara Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_msi_machdep.c,v 1.6 2015/06/22 03:57:01 msaitoh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -236,8 +236,7 @@ pci_msix_alloc_common(pci_intr_handle_t 
 	pci_intr_handle_t *vectors;
 	int error, i;
 
-	if (((pa-pa_flags  PCI_FLAGS_MSI_OKAY) == 0)
-	|| ((pa-pa_flags  PCI_FLAGS_MSIX_OKAY) == 0)) {
+	if ((pa-pa_flags  PCI_FLAGS_MSIX_OKAY) == 0) {
 		DPRINTF((PCI host bridge does not support MSI-X.\n));
 		return ENODEV;
 	}



CVS commit: src/sys/arch/x86/pci

2015-05-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sun May 17 04:59:43 UTC 2015

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
 Add Core 5G (mobile) LPC support.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.49 src/sys/arch/x86/pci/ichlpcib.c:1.50
--- src/sys/arch/x86/pci/ichlpcib.c:1.49	Sun May  3 02:50:59 2015
+++ src/sys/arch/x86/pci/ichlpcib.c	Sun May 17 04:59:43 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.49 2015/05/03 02:50:59 pgoyette Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.50 2015/05/17 04:59:43 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.49 2015/05/03 02:50:59 pgoyette Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.50 2015/05/17 04:59:43 msaitoh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -257,6 +257,8 @@ static struct lpcib_device {
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z97_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X99_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_X99_LPC_2, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_LPC_4, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_CORE5G_M_LPC_7, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C222_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C224_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C226_LPC, 1, 0 },



CVS commit: src/sys/arch/x86/pci

2015-05-15 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Fri May 15 08:29:33 UTC 2015

Modified Files:
src/sys/arch/x86/pci: pci_intr_machdep.c pci_msi_machdep.c

Log Message:
refactor: change function names and move them.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/x86/pci/pci_intr_machdep.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/pci/pci_msi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.31 src/sys/arch/x86/pci/pci_intr_machdep.c:1.32
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.31	Fri May 15 08:26:44 2015
+++ src/sys/arch/x86/pci/pci_intr_machdep.c	Fri May 15 08:29:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_intr_machdep.c,v 1.31 2015/05/15 08:26:44 knakahara Exp $	*/
+/*	$NetBSD: pci_intr_machdep.c,v 1.32 2015/05/15 08:29:33 knakahara Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_intr_machdep.c,v 1.31 2015/05/15 08:26:44 knakahara Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_intr_machdep.c,v 1.32 2015/05/15 08:29:33 knakahara Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -350,6 +350,20 @@ pci_intr_distribute(void *cookie, const 
 }
 
 #if NIOAPIC  0
+static void
+x86_pci_intx_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih)
+{
+	char intrstr_buf[INTRIDBUF];
+	const char *intrstr;
+
+	intrstr = pci_intr_string(NULL, *pih, intrstr_buf, sizeof(intrstr_buf));
+	mutex_enter(cpu_lock);
+	intr_free_io_intrsource(intrstr);
+	mutex_exit(cpu_lock);
+
+	kmem_free(pih, sizeof(*pih));
+}
+
 int
 pci_intx_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **pih)
 {
@@ -390,20 +404,6 @@ error:
 	return error;
 }
 
-static void
-x86_pci_intx_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih)
-{
-	char intrstr_buf[INTRIDBUF];
-	const char *intrstr;
-
-	intrstr = pci_intr_string(NULL, *pih, intrstr_buf, sizeof(intrstr_buf));
-	mutex_enter(cpu_lock);
-	intr_free_io_intrsource(intrstr);
-	mutex_exit(cpu_lock);
-
-	kmem_free(pih, sizeof(*pih));
-}
-
 void
 pci_intr_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih, int count)
 {

Index: src/sys/arch/x86/pci/pci_msi_machdep.c
diff -u src/sys/arch/x86/pci/pci_msi_machdep.c:1.3 src/sys/arch/x86/pci/pci_msi_machdep.c:1.4
--- src/sys/arch/x86/pci/pci_msi_machdep.c:1.3	Fri May 15 08:26:44 2015
+++ src/sys/arch/x86/pci/pci_msi_machdep.c	Fri May 15 08:29:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_msi_machdep.c,v 1.3 2015/05/15 08:26:44 knakahara Exp $	*/
+/*	$NetBSD: pci_msi_machdep.c,v 1.4 2015/05/15 08:29:33 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_msi_machdep.c,v 1.3 2015/05/15 08:26:44 knakahara Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_msi_machdep.c,v 1.4 2015/05/15 08:29:33 knakahara Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -172,7 +172,7 @@ pci_msi_free_vectors(struct pic *msi_pic
 }
 
 static int
-pci_msi_alloc_md_common(pci_intr_handle_t **ihps, int *count,
+pci_msi_alloc_common(pci_intr_handle_t **ihps, int *count,
 const struct pci_attach_args *pa, bool exact)
 {
 	struct pic *msi_pic;
@@ -226,35 +226,6 @@ pci_msi_alloc_md_common(pci_intr_handle_
 	return 0;
 }
 
-static int
-pci_msi_alloc_md(pci_intr_handle_t **ihps, int *count,
-const struct pci_attach_args *pa)
-{
-
-	return pci_msi_alloc_md_common(ihps, count, pa, false);
-}
-
-static int
-pci_msi_alloc_exact_md(pci_intr_handle_t **ihps, int count,
-const struct pci_attach_args *pa)
-{
-
-	return pci_msi_alloc_md_common(ihps, count, pa, true);
-}
-
-static void
-pci_msi_release_md(pci_intr_handle_t *pihs, int count)
-{
-	struct pic *pic;
-
-	pic = msipic_find_msi_pic(MSI_INT_DEV(pihs[0]));
-	if (pic == NULL)
-		return;
-
-	pci_msi_free_vectors(pic, pihs, count);
-	msipic_destruct_msi_pic(pic);
-}
-
 static void *
 pci_msi_common_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih,
 int level, int (*func)(void *), void *arg, struct pic *pic)
@@ -280,7 +251,7 @@ pci_msi_common_disestablish(pci_chipset_
 }
 
 static int
-pci_msix_alloc_md_common(pci_intr_handle_t **ihps, u_int *table_indexes,
+pci_msix_alloc_common(pci_intr_handle_t **ihps, u_int *table_indexes,
 int *count, const struct pci_attach_args *pa, bool exact)
 {
 	struct pic *msix_pic;
@@ -334,31 +305,60 @@ pci_msix_alloc_md_common(pci_intr_handle
 }
 
 static int
-pci_msix_alloc_md(pci_intr_handle_t **ihps, int *count,
+x86_pci_msi_alloc(pci_intr_handle_t **ihps, int *count,
 const struct pci_attach_args *pa)
 {
 
-	return pci_msix_alloc_md_common(ihps, NULL, count, pa, false);
+	return pci_msi_alloc_common(ihps, count, pa, false);
 }
 
 static int
-pci_msix_alloc_exact_md(pci_intr_handle_t **ihps, int count,

CVS commit: src/sys/arch/x86/pci

2015-05-02 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sun May  3 02:50:59 UTC 2015

Modified Files:
src/sys/arch/x86/pci: files.pci ichlpcib.c
Added Files:
src/sys/arch/x86/pci: tco.c tco.h

Log Message:
Separate the watchdog code from the pcib code, and make the watchdog
a loadable module.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/x86/pci/files.pci
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/x86/pci/ichlpcib.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/pci/tco.c src/sys/arch/x86/pci/tco.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/files.pci
diff -u src/sys/arch/x86/pci/files.pci:1.19 src/sys/arch/x86/pci/files.pci:1.20
--- src/sys/arch/x86/pci/files.pci:1.19	Tue Nov 11 02:31:55 2014
+++ src/sys/arch/x86/pci/files.pci	Sun May  3 02:50:59 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.19 2014/11/11 02:31:55 christos Exp $
+#	$NetBSD: files.pci,v 1.20 2015/05/03 02:50:59 pgoyette Exp $
 
 device 	aapic
 attach 	aapic at pci
@@ -46,13 +46,18 @@ file 	arch/x86/pci/rdcpcib.c 		rdcpcib
 
 define	fwhichbus {}
 define	hpetichbus {}
-device	ichlpcib: acpipmtimer, isabus, sysmon_wdog, fwhichbus, hpetichbus, gpiobus
+define	tcoichbus {}
+device	ichlpcib: acpipmtimer, isabus, fwhichbus, hpetichbus, gpiobus, tcoichbus
 attach	ichlpcib at pci
 file 	arch/x86/pci/ichlpcib.c 	ichlpcib
 
 attach	hpet at hpetichbus with ichlpcib_hpet
 filearch/x86/pci/ichlpcib_hpet.c	ichlpcib_hpet
 
+device	tco: sysmon_wdog
+attach	tco at tcoichbus
+file	arch/x86/pci/tco.c		tco
+
 device	tcpcib: isabus, sysmon_wdog, hpetichbus
 attach	tcpcib at pci
 file	arch/x86/pci/tcpcib.c		tcpcib

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.48 src/sys/arch/x86/pci/ichlpcib.c:1.49
--- src/sys/arch/x86/pci/ichlpcib.c:1.48	Fri Mar 20 12:01:32 2015
+++ src/sys/arch/x86/pci/ichlpcib.c	Sun May  3 02:50:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.48 2015/03/20 12:01:32 msaitoh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.49 2015/05/03 02:50:59 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -34,12 +34,13 @@
  *
  *  LPC Interface Bridge is basically a pcib (PCI-ISA Bridge), but has
  *  some power management and monitoring functions.
- *  Currently we support the watchdog timer, SpeedStep (on some systems)
+ *  Currently we support the watchdog timer, SpeedStep (on some systems),
+ *  the gpio interface, hpet timer, hardware random number generator,
  *  and the power management timer.
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.48 2015/03/20 12:01:32 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.49 2015/05/03 02:50:59 pgoyette Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -55,7 +56,6 @@ __KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v
 #include dev/pci/pcidevs.h
 
 #include dev/gpio/gpiovar.h
-#include dev/sysmon/sysmonvar.h
 
 #include dev/ic/acpipmtimer.h
 #include dev/ic/i82801lpcreg.h
@@ -63,6 +63,8 @@ __KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v
 #include dev/ic/hpetreg.h
 #include dev/ic/hpetvar.h
 
+#include arch/x86/pci/tco.h
+
 #include pcibvar.h
 #include gpio.h
 #include fwhrng.h
@@ -82,8 +84,7 @@ struct lpcib_softc {
 	bus_space_handle_t	sc_rcbah;
 	pcireg_t		sc_rcba_reg;
 
-	/* Watchdog variables. */
-	struct sysmon_wdog	sc_smw;
+	/* Power management variables. */
 	bus_space_tag_t		sc_iot;
 	bus_space_handle_t	sc_ioh;
 	bus_size_t		sc_iosize;
@@ -114,6 +115,7 @@ struct lpcib_softc {
 	pcireg_t		sc_fwhsel2;
 
 	/* Child devices */
+	device_t		sc_tco;
 	device_t		sc_hpetbus;
 	acpipmtimer_t		sc_pmtimer;
 	pcireg_t		sc_acpi_cntl;
@@ -135,12 +137,6 @@ static int pmtimer_unconfigure(device_t,
 
 static void tcotimer_configure(device_t);
 static int tcotimer_unconfigure(device_t, int);
-static int tcotimer_setmode(struct sysmon_wdog *);
-static int tcotimer_tickle(struct sysmon_wdog *);
-static void tcotimer_stop(struct lpcib_softc *);
-static void tcotimer_start(struct lpcib_softc *);
-static void tcotimer_status_reset(struct lpcib_softc *);
-static int  tcotimer_disable_noreboot(device_t);
 
 static void speedstep_configure(device_t);
 static void speedstep_unconfigure(device_t);
@@ -411,6 +407,11 @@ lpcibchilddet(device_t self, device_t ch
 		return;
 	}
 #endif
+	if (sc-sc_tco == child) {
+		sc-sc_tco = NULL;
+		return;
+	}
+
 	if (sc-sc_hpetbus != child) {
 		pcibchilddet(self, child);
 		return;
@@ -454,6 +455,9 @@ lpcibrescan(device_t self, const char *i
 {
 	struct lpcib_softc *sc = device_private(self);
 
+	if(ifattr_match(ifattr, tcoichbus)  sc-sc_tco == NULL)
+		tcotimer_configure(self);
+
 #if NFWHRNG  0
 	if (ifattr_match(ifattr, fwhichbus)  sc-sc_fwhbus == NULL)
 		lpcib_fwh_configure(self);
@@ -613,59 +617,22 @@ pmtimer_unconfigure(device_t self, int f
 }
 
 /*
- * Initialize the watchdog timer.
+ * Configure the watchdog timer.
  */
 static void
 

CVS commit: src/sys/arch/x86/pci

2015-04-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 28 06:23:57 UTC 2015

Modified Files:
src/sys/arch/x86/pci: msipic.c

Log Message:
Make this compilable in non-DIAGNOSTIC kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/pci/msipic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.2 src/sys/arch/x86/pci/msipic.c:1.3
--- src/sys/arch/x86/pci/msipic.c:1.2	Tue Apr 28 02:38:53 2015
+++ src/sys/arch/x86/pci/msipic.c	Tue Apr 28 06:23:57 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.2 2015/04/28 02:38:53 knakahara Exp $	*/
+/*	$NetBSD: msipic.c,v 1.3 2015/04/28 06:23:57 martin Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msipic.c,v 1.2 2015/04/28 02:38:53 knakahara Exp $);
+__KERNEL_RCSID(0, $NetBSD: msipic.c,v 1.3 2015/04/28 06:23:57 martin Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -322,12 +322,13 @@ msi_set_msictl_enablebit(struct pic *pic
 	struct pci_attach_args *pa;
 	pcitag_t tag;
 	pcireg_t ctl;
-	int off;
+	int off, err __diagused;
 
 	pc = NULL;
 	pa = pic-pic_msipic-mp_pa;
 	tag = pa-pa_tag;
-	KASSERT(pci_get_capability(pc, tag, PCI_CAP_MSI, off, NULL) != 0);
+	err = pci_get_capability(pc, tag, PCI_CAP_MSI, off, NULL);
+	KASSERT(err != 0);
 
 	/*
 	 * MSI can establish only one vector at once.
@@ -368,12 +369,13 @@ msi_addroute(struct pic *pic, struct cpu
 	struct pci_attach_args *pa;
 	pcitag_t tag;
 	pcireg_t addr, data, ctl;
-	int off;
+	int off, err __diagused;
 
 	pc = NULL;
 	pa = pic-pic_msipic-mp_pa;
 	tag = pa-pa_tag;
-	KASSERT(pci_get_capability(pc, tag, PCI_CAP_MSI, off, NULL) != 0);
+	err = pci_get_capability(pc, tag, PCI_CAP_MSI, off, NULL);
+	KASSERT(err != 0);
 
 	/*
 	 * See Intel 64 and IA-32 Architectures Software Developer's Manual
@@ -527,7 +529,7 @@ msix_addroute(struct pic *pic, struct cp
 	bus_space_handle_t bshandle;
 	uint64_t entry_base;
 	pcireg_t addr, data, ctl;
-	int off;
+	int off, err __diagused;
 
 	if (msix_vec  0) {
 		DPRINTF((%s: invalid MSI-X table index, devid=%d vecid=%d,
@@ -538,7 +540,8 @@ msix_addroute(struct pic *pic, struct cp
 	pa = pic-pic_msipic-mp_pa;
 	pc = pa-pa_pc;
 	tag = pa-pa_tag;
-	KASSERT(pci_get_capability(pc, tag, PCI_CAP_MSIX, off, NULL) != 0);
+	err = pci_get_capability(pc, tag, PCI_CAP_MSIX, off, NULL);
+	KASSERT(err != 0);
 
 	entry_base = PCI_MSIX_TABLE_ENTRY_SIZE * msix_vec;
 



CVS commit: src/sys/arch/x86/pci

2015-04-27 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Apr 28 02:38:53 UTC 2015

Modified Files:
src/sys/arch/x86/pci: msipic.c

Log Message:
fix debug message.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/msipic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/msipic.c
diff -u src/sys/arch/x86/pci/msipic.c:1.1 src/sys/arch/x86/pci/msipic.c:1.2
--- src/sys/arch/x86/pci/msipic.c:1.1	Mon Apr 27 07:03:58 2015
+++ src/sys/arch/x86/pci/msipic.c	Tue Apr 28 02:38:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: msipic.c,v 1.1 2015/04/27 07:03:58 knakahara Exp $	*/
+/*	$NetBSD: msipic.c,v 1.2 2015/04/28 02:38:53 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msipic.c,v 1.1 2015/04/27 07:03:58 knakahara Exp $);
+__KERNEL_RCSID(0, $NetBSD: msipic.c,v 1.2 2015/04/28 02:38:53 knakahara Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -478,7 +478,7 @@ msix_set_vecctl_mask(struct pic *pic, in
 
 	if (msix_vec  0) {
 		DPRINTF((%s: invalid MSI-X table index, devid=%d vecid=%d,
-			__func__, msi_get_devid(pic), msix_vec));
+			__func__, msipic_get_devid(pic), msix_vec));
 		return;
 	}
 
@@ -531,7 +531,7 @@ msix_addroute(struct pic *pic, struct cp
 
 	if (msix_vec  0) {
 		DPRINTF((%s: invalid MSI-X table index, devid=%d vecid=%d,
-			__func__, msi_get_devid(pic), msix_vec));
+			__func__, msipic_get_devid(pic), msix_vec));
 		return;
 	}
 



CVS commit: src/sys/arch/x86/pci

2015-01-13 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jan 13 08:57:02 UTC 2015

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
As I wrote in the last commit, The PMBASE and GPIOBASE registers are not
compltible with the PCI spec and the map sizes are fixed to 128bytes. The
pci_mapreg_submap() function has a code to check the range of the BAR. The
PCI_MAPREG_IO_SIZE() macro returns lower than 128bytes on some machines.
It makes impossible to use pci_mapreg_submap(). Use pci_conf_read() and
bus_space_map() directly. Observed and tested with my Thinkpad X61.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.45 src/sys/arch/x86/pci/ichlpcib.c:1.46
--- src/sys/arch/x86/pci/ichlpcib.c:1.45	Fri Dec 26 05:09:03 2014
+++ src/sys/arch/x86/pci/ichlpcib.c	Tue Jan 13 08:57:02 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.45 2014/12/26 05:09:03 msaitoh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.46 2015/01/13 08:57:02 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.45 2014/12/26 05:09:03 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.46 2015/01/13 08:57:02 msaitoh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -303,6 +303,7 @@ lpcibattach(device_t parent, device_t se
 	struct pci_attach_args *pa = aux;
 	struct lpcib_softc *sc = device_private(self);
 	struct lpcib_device *lpcib_dev;
+	pcireg_t pmbase;
 
 	sc-sc_pa = *pa;
 
@@ -324,12 +325,16 @@ lpcibattach(device_t parent, device_t se
 	 *
 	 * The PMBASE register is alike PCI BAR but not completely compatible
 	 * with it. The PMBASE define the base address and the type but
-	 * not describe the size.
+	 * not describe the size. The value of the register may be lower
+	 * than LPCIB_PCI_PM_SIZE. It makes impossible to use
+	 * pci_mapreg_submap() because the function does range check.
 	 */
-	if (pci_mapreg_submap(pa, LPCIB_PCI_PMBASE, PCI_MAPREG_TYPE_IO, 0,
-		LPCIB_PCI_PM_SIZE, 0, sc-sc_iot, sc-sc_ioh, NULL,
-		sc-sc_iosize)) {
-		aprint_error_dev(self, can't map power management i/o space\n);
+	sc-sc_iot = pa-pa_iot;
+	pmbase = pci_conf_read(pa-pa_pc, pa-pa_tag, LPCIB_PCI_PMBASE);
+	if (bus_space_map(sc-sc_iot, PCI_MAPREG_IO_ADDR(pmbase),
+	LPCIB_PCI_PM_SIZE, 0, sc-sc_ioh) != 0) {
+		aprint_error_dev(self,
+		can't map power management i/o space\n);
 		return;
 	}
 
@@ -1082,11 +1087,14 @@ lpcib_gpio_configure(device_t self)
 	/*
 	 * The GPIO_BASE register is alike PCI BAR but not completely
 	 * compatible with it. The PMBASE define the base address and the type
-	 * but not describe the size.
+	 * but not describe the size. The value of the register may be lower
+	 * than LPCIB_PCI_GPIO_SIZE. It makes impossible to use
+	 * pci_mapreg_submap() because the function does range check.
 	 */
-	rv = pci_mapreg_submap(sc-sc_pa, base_reg, PCI_MAPREG_TYPE_IO, 0,
-	LPCIB_PCI_GPIO_SIZE, 0, sc-sc_gpio_iot, sc-sc_gpio_ioh,
-	NULL, sc-sc_gpio_ios);
+	sc-sc_gpio_iot = sc-sc_pa.pa_iot;
+	reg = pci_conf_read(sc-sc_pa.pa_pc, sc-sc_pa.pa_tag, base_reg);
+	rv = bus_space_map(sc-sc_gpio_iot, PCI_MAPREG_IO_ADDR(reg),
+	LPCIB_PCI_GPIO_SIZE, 0, sc-sc_gpio_ioh);
 	if (rv != 0) {
 		aprint_error_dev(self, can't map general purpose i/o space(rv = %d)\n, rv);
 		return;



CVS commit: src/sys/arch/x86/pci

2014-12-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Dec 15 13:29:43 UTC 2014

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
Add DH89xxC[CL] LPC devices.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.43 src/sys/arch/x86/pci/ichlpcib.c:1.44
--- src/sys/arch/x86/pci/ichlpcib.c:1.43	Sat Jan  4 02:59:17 2014
+++ src/sys/arch/x86/pci/ichlpcib.c	Mon Dec 15 13:29:42 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.43 2014/01/04 02:59:17 msaitoh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.44 2014/12/15 13:29:42 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.43 2014/01/04 02:59:17 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.44 2014/12/15 13:29:42 msaitoh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -262,6 +262,8 @@ static struct lpcib_device {
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C226_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H81_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCC_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_DH89XXCL_LPC, 1, 0 },
 #if 0
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_1, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_2, 1, 0 },



CVS commit: src/sys/arch/x86/pci

2014-11-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov 11 02:31:55 UTC 2014

Modified Files:
src/sys/arch/x86/pci: files.pci

Log Message:
add an agp dependency so that the agp drivers get loaded.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/pci/files.pci

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/files.pci
diff -u src/sys/arch/x86/pci/files.pci:1.18 src/sys/arch/x86/pci/files.pci:1.19
--- src/sys/arch/x86/pci/files.pci:1.18	Sat Oct 18 12:56:51 2014
+++ src/sys/arch/x86/pci/files.pci	Mon Nov 10 21:31:55 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.18 2014/10/18 16:56:51 uebayasi Exp $
+#	$NetBSD: files.pci,v 1.19 2014/11/11 02:31:55 christos Exp $
 
 device 	aapic
 attach 	aapic at pci
@@ -12,7 +12,7 @@ defflag	AGP_X86
 define amdnb_miscbus {}
 
 # PCI-Host bridge chipsets
-device	pchb:	pcibus, agpbus
+device	pchb:	pcibus, agpbus, agp_x86
 attach	pchb at pci
 file	arch/x86/pci/pchb.c		pchb		needs-flag
 



CVS commit: src/sys/arch/x86/pci

2014-11-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov  7 12:48:21 UTC 2014

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
print the bad values in panic messages


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.68 src/sys/arch/x86/pci/pci_machdep.c:1.69
--- src/sys/arch/x86/pci/pci_machdep.c:1.68	Wed Nov  5 00:07:43 2014
+++ src/sys/arch/x86/pci/pci_machdep.c	Fri Nov  7 07:48:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.68 2014/11/05 05:07:43 christos Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.69 2014/11/07 12:48:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.68 2014/11/05 05:07:43 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.69 2014/11/07 12:48:21 christos Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -333,7 +333,7 @@ pci_conf_selector(pcitag_t tag, int reg)
 	case 2:
 		return tag.mode1  mode2_mask.mode1;
 	default:
-		panic(%s: mode not configured, __func__);
+		panic(%s: mode %d not configured, __func__, pci_mode);
 	}
 }
 
@@ -346,7 +346,7 @@ pci_conf_port(pcitag_t tag, int reg)
 	case 2:
 		return tag.mode2.port | reg;
 	default:
-		panic(%s: mode not configured, __func__);
+		panic(%s: mode %d not configured, __func__, pci_mode);
 	}
 }
 
@@ -366,7 +366,7 @@ pci_conf_select(uint32_t sel)
 			outb(PCI_MODE2_FORWARD_REG, tag.mode2.forward);
 		return;
 	default:
-		panic(%s: mode not configured, __func__);
+		panic(%s: mode %d not configured, __func__, pci_mode);
 	}
 }
 
@@ -415,21 +415,23 @@ pci_make_tag(pci_chipset_tag_t pc, int b
 	switch (pci_mode) {
 	case 1:
 		if (bus = 256 || device = 32 || function = 8)
-			panic(%s: bad request, __func__);
+			panic(%s: bad request(%d, %d, %d), __func__,
+			bus, device, function);
 
 		tag.mode1 = PCI_MODE1_ENABLE |
 			(bus  16) | (device  11) | (function  8);
 		return tag;
 	case 2:
 		if (bus = 256 || device = 16 || function = 8)
-			panic(%s: bad request, __func__);
+			panic(%s: bad request(%d, %d, %d), __func__,
+			bus, device, function);
 
 		tag.mode2.port = 0xc000 | (device  8);
 		tag.mode2.enable = 0xf0 | (function  1);
 		tag.mode2.forward = bus;
 		return tag;
 	default:
-		panic(%s: mode not configured, __func__);
+		panic(%s: mode %d not configured, __func__, pci_mode);
 	}
 }
 
@@ -465,7 +467,7 @@ pci_decompose_tag(pci_chipset_tag_t pc, 
 			*fp = (tag.mode2.enable  1)  0x7;
 		return;
 	default:
-		panic(%s: mode not configured, __func__);
+		panic(%s: mode %d not configured, __func__, pci_mode);
 	}
 }
 



CVS commit: src/sys/arch/x86/pci

2014-11-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov  5 05:07:43 UTC 2014

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
we don't need to keep track of curmode if not vga_post.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.67 src/sys/arch/x86/pci/pci_machdep.c:1.68
--- src/sys/arch/x86/pci/pci_machdep.c:1.67	Tue May  6 14:54:34 2014
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed Nov  5 00:07:43 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.67 2014/05/06 18:54:34 christos Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.68 2014/11/05 05:07:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.67 2014/05/06 18:54:34 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.68 2014/11/05 05:07:43 christos Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -789,24 +789,28 @@ static bool
 x86_genfb_setmode(struct genfb_softc *sc, int newmode)
 {
 #if NGENFB  0
+# if NACPICA  0  defined(VGA_POST)
 	static int curmode = WSDISPLAYIO_MODE_EMUL;
+# endif
 
 	switch (newmode) {
 	case WSDISPLAYIO_MODE_EMUL:
 		x86_genfb_mtrr_init(sc-sc_fboffset,
 		sc-sc_height * sc-sc_stride);
-#if NACPICA  0  defined(VGA_POST)
+# if NACPICA  0  defined(VGA_POST)
 		if (curmode != newmode) {
 			if (vga_posth != NULL  acpi_md_vesa_modenum != 0) {
 vga_post_set_vbe(vga_posth,
 acpi_md_vesa_modenum);
 			}
 		}
-#endif
+# endif
 		break;
 	}
 
+# if NACPICA  0  defined(VGA_POST)
 	curmode = newmode;
+# endif
 #endif
 	return true;
 }



CVS commit: src/sys/arch/x86/pci

2014-10-17 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Fri Oct 17 20:55:21 UTC 2014

Modified Files:
src/sys/arch/x86/pci: files.pci

Log Message:
Fix another indirect circular dependency (agp_* - (agpbus) - pchb - abp_*).
Fixes no agp* build.  Reported  build-tested by Kurt Schreiner.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/pci/files.pci

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/files.pci
diff -u src/sys/arch/x86/pci/files.pci:1.16 src/sys/arch/x86/pci/files.pci:1.17
--- src/sys/arch/x86/pci/files.pci:1.16	Tue Jun 10 01:42:39 2014
+++ src/sys/arch/x86/pci/files.pci	Fri Oct 17 20:55:21 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.16 2014/06/10 01:42:39 hikaru Exp $
+#	$NetBSD: files.pci,v 1.17 2014/10/17 20:55:21 uebayasi Exp $
 
 device 	aapic
 attach 	aapic at pci
@@ -9,9 +9,7 @@ file	arch/x86/pci/agp_machdep.c	agp
 define amdnb_miscbus {}
 
 # PCI-Host bridge chipsets
-device	pchb:	pcibus, agpbus,
-		agp_ali, agp_amd, agp_amd64, agp_i810,
-		agp_intel, agp_sis, agp_via
+device	pchb:	pcibus, agpbus
 attach	pchb at pci
 file	arch/x86/pci/pchb.c		pchb		needs-flag
 



CVS commit: src/sys/arch/x86/pci

2014-08-13 Thread Hikaru Abe
Module Name:src
Committed By:   hikaru
Date:   Thu Aug 14 05:42:16 UTC 2014

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Set ifflags callback so that the device can enter promiscuous mode.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.4 src/sys/arch/x86/pci/if_vmx.c:1.5
--- src/sys/arch/x86/pci/if_vmx.c:1.4	Sat Jul 19 06:12:24 2014
+++ src/sys/arch/x86/pci/if_vmx.c	Thu Aug 14 05:42:16 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.4 2014/07/19 06:12:24 hikaru Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.5 2014/08/14 05:42:16 hikaru Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_vmx.c,v 1.4 2014/07/19 06:12:24 hikaru Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_vmx.c,v 1.5 2014/08/14 05:42:16 hikaru Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -158,6 +158,7 @@ void vmxnet3_evintr(struct vmxnet3_softc
 void vmxnet3_txintr(struct vmxnet3_softc *, struct vmxnet3_txqueue *);
 void vmxnet3_rxintr(struct vmxnet3_softc *, struct vmxnet3_rxqueue *);
 void vmxnet3_iff(struct vmxnet3_softc *);
+int vmxnet3_ifflags_cb(struct ethercom *);
 void vmxnet3_rx_csum(struct vmxnet3_rxcompdesc *, struct mbuf *);
 int vmxnet3_getbuf(struct vmxnet3_softc *, struct vmxnet3_rxring *);
 void vmxnet3_stop(struct ifnet *, int disable);
@@ -308,6 +309,7 @@ vmxnet3_attach(device_t parent, device_t
 
 	if_attach(ifp);
 	ether_ifattach(ifp, enaddr);
+	ether_set_ifflags_cb(sc-sc_ethercom, vmxnet3_ifflags_cb);
 	vmxnet3_link_state(sc);
 }
 
@@ -859,6 +861,15 @@ setit:
 	WRITE_CMD(sc, VMXNET3_CMD_SET_RXMODE);
 }
 
+int
+vmxnet3_ifflags_cb(struct ethercom *ec)
+{
+
+	vmxnet3_iff((struct vmxnet3_softc *)ec-ec_if.if_softc);
+
+	return 0;
+}
+
 
 void
 vmxnet3_rx_csum(struct vmxnet3_rxcompdesc *rxcd, struct mbuf *m)



CVS commit: src/sys/arch/x86/pci

2014-07-19 Thread Hikaru Abe
Module Name:src
Committed By:   hikaru
Date:   Sat Jul 19 06:12:24 UTC 2014

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Correct return value handling.
m_defrag(9) is different from OpenBSD one,
it returns new mbuf pointer on success, not zero.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.3 src/sys/arch/x86/pci/if_vmx.c:1.4
--- src/sys/arch/x86/pci/if_vmx.c:1.3	Thu Jun 19 13:20:28 2014
+++ src/sys/arch/x86/pci/if_vmx.c	Sat Jul 19 06:12:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.3 2014/06/19 13:20:28 hikaru Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.4 2014/07/19 06:12:24 hikaru Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_vmx.c,v 1.3 2014/06/19 13:20:28 hikaru Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_vmx.c,v 1.4 2014/07/19 06:12:24 hikaru Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -1145,11 +1145,13 @@ vmxnet3_load_mbuf(struct vmxnet3_softc *
 	case 0:
 		break;
 	case EFBIG:
-		if (m_defrag(m, M_DONTWAIT) == 0 
-		bus_dmamap_load_mbuf(sc-sc_dmat, map, m,
-		 BUS_DMA_NOWAIT) == 0)
-			break;
-
+		mp = m_defrag(m, M_DONTWAIT);
+		if (mp != NULL) {
+			m = mp;
+			if (bus_dmamap_load_mbuf(sc-sc_dmat, map, m,
+			BUS_DMA_NOWAIT) == 0)
+break;
+		}
 		/* FALLTHROUGH */
 	default:
 		m_freem(m);



CVS commit: src/sys/arch/x86/pci

2014-06-19 Thread Hikaru Abe
Module Name:src
Committed By:   hikaru
Date:   Thu Jun 19 13:16:29 UTC 2014

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Make it be able to down I/F. This fixes panic when removing IFF_UP flag.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.1 src/sys/arch/x86/pci/if_vmx.c:1.2
--- src/sys/arch/x86/pci/if_vmx.c:1.1	Tue Jun 10 01:42:39 2014
+++ src/sys/arch/x86/pci/if_vmx.c	Thu Jun 19 13:16:29 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.1 2014/06/10 01:42:39 hikaru Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.2 2014/06/19 13:16:29 hikaru Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_vmx.c,v 1.1 2014/06/10 01:42:39 hikaru Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_vmx.c,v 1.2 2014/06/19 13:16:29 hikaru Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -160,7 +160,7 @@ void vmxnet3_rxintr(struct vmxnet3_softc
 void vmxnet3_iff(struct vmxnet3_softc *);
 void vmxnet3_rx_csum(struct vmxnet3_rxcompdesc *, struct mbuf *);
 int vmxnet3_getbuf(struct vmxnet3_softc *, struct vmxnet3_rxring *);
-void vmxnet3_stop(struct ifnet *);
+void vmxnet3_stop(struct ifnet *, int disable);
 void vmxnet3_reset(struct ifnet *);
 int vmxnet3_init(struct ifnet *);
 int vmxnet3_ioctl(struct ifnet *, u_long, void *);
@@ -281,6 +281,7 @@ vmxnet3_attach(device_t parent, device_t
 	ifp-if_start = vmxnet3_start;
 	ifp-if_watchdog = vmxnet3_watchdog;
 	ifp-if_init = vmxnet3_init;
+	ifp-if_stop = vmxnet3_stop;
 	sc-sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
 	if (sc-sc_ds-upt_features  UPT1_F_CSUM)
 		sc-sc_ethercom.ec_if.if_capabilities |=
@@ -599,7 +600,10 @@ int
 vmxnet3_intr(void *arg)
 {
 	struct vmxnet3_softc *sc = arg;
+	struct ifnet *ifp = sc-sc_ethercom.ec_if;
 
+	if ((ifp-if_flags  IFF_RUNNING) == 0)
+		return 0;
 	if (READ_BAR1(sc, VMXNET3_BAR1_INTR) == 0)
 		return 0;
 	if (sc-sc_ds-event)
@@ -939,7 +943,7 @@ vmxnet3_getbuf(struct vmxnet3_softc *sc,
 }
 
 void
-vmxnet3_stop(struct ifnet *ifp)
+vmxnet3_stop(struct ifnet *ifp, int disable)
 {
 	struct vmxnet3_softc *sc = ifp-if_softc;
 	int queue;
@@ -951,6 +955,9 @@ vmxnet3_stop(struct ifnet *ifp)
 	ifp-if_flags = ~(IFF_RUNNING | IFF_OACTIVE);
 	ifp-if_timer = 0;
 
+	if (!disable)
+		return;
+
 	WRITE_CMD(sc, VMXNET3_CMD_DISABLE);
 
 	for (queue = 0; queue  NTXQUEUE; queue++)
@@ -964,7 +971,7 @@ vmxnet3_reset(struct ifnet *ifp)
 {
 	struct vmxnet3_softc *sc = ifp-if_softc;
 
-	vmxnet3_stop(ifp);
+	vmxnet3_stop(ifp, 1);
 	WRITE_CMD(sc, VMXNET3_CMD_RESET);
 	vmxnet3_init(ifp);
 }
@@ -989,7 +996,7 @@ vmxnet3_init(struct ifnet *ifp)
 	WRITE_CMD(sc, VMXNET3_CMD_ENABLE);
 	if (READ_BAR1(sc, VMXNET3_BAR1_CMD)) {
 		printf(%s: failed to initialize\n, ifp-if_xname);
-		vmxnet3_stop(ifp);
+		vmxnet3_stop(ifp, 1);
 		return EIO;
 	}
 
@@ -1013,7 +1020,7 @@ vmxnet3_change_mtu(struct vmxnet3_softc 
 
 	if (mtu  VMXNET3_MIN_MTU || mtu  VMXNET3_MAX_MTU)
 		return EINVAL;
-	vmxnet3_stop(ifp);
+	vmxnet3_stop(ifp, 1);
 	ifp-if_mtu = ds-mtu = mtu;
 	error = vmxnet3_init(ifp);
 	return error;
@@ -1191,7 +1198,7 @@ vmxnet3_watchdog(struct ifnet *ifp)
 
 	printf(%s: device timeout\n, ifp-if_xname);
 	s = splnet();
-	vmxnet3_stop(ifp);
+	vmxnet3_stop(ifp, 1);
 	vmxnet3_init(ifp);
 	splx(s);
 }



CVS commit: src/sys/arch/x86/pci

2014-06-19 Thread Hikaru Abe
Module Name:src
Committed By:   hikaru
Date:   Thu Jun 19 13:20:28 UTC 2014

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
Use 64-bit DMA, if it is available.
This fixes null packet handling on guest which have memory over than 3GB.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/pci/if_vmx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.2 src/sys/arch/x86/pci/if_vmx.c:1.3
--- src/sys/arch/x86/pci/if_vmx.c:1.2	Thu Jun 19 13:16:29 2014
+++ src/sys/arch/x86/pci/if_vmx.c	Thu Jun 19 13:20:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.2 2014/06/19 13:16:29 hikaru Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.3 2014/06/19 13:20:28 hikaru Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: if_vmx.c,v 1.2 2014/06/19 13:16:29 hikaru Exp $);
+__KERNEL_RCSID(0, $NetBSD: if_vmx.c,v 1.3 2014/06/19 13:20:28 hikaru Exp $);
 
 #include sys/param.h
 #include sys/bus.h
@@ -238,7 +238,10 @@ vmxnet3_attach(device_t parent, device_t
 	preg |= PCI_COMMAND_MASTER_ENABLE;
 	pci_conf_write(pa-pa_pc, pa-pa_tag, PCI_COMMAND_STATUS_REG, preg);
 
-	sc-sc_dmat = pa-pa_dmat;
+	if (pci_dma64_available(pa))
+		sc-sc_dmat = pa-pa_dmat64;
+	else
+		sc-sc_dmat = pa-pa_dmat;
 	if (vmxnet3_dma_init(sc)) {
 		aprint_error_dev(sc-sc_dev, failed to setup DMA\n);
 		return;



CVS commit: src/sys/arch/x86/pci

2014-05-12 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon May 12 11:55:39 UTC 2014

Modified Files:
src/sys/arch/x86/pci: pciide_machdep.c

Log Message:
buf is only used in the ioapic case.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/pci/pciide_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pciide_machdep.c
diff -u src/sys/arch/x86/pci/pciide_machdep.c:1.12 src/sys/arch/x86/pci/pciide_machdep.c:1.13
--- src/sys/arch/x86/pci/pciide_machdep.c:1.12	Sat Mar 29 19:28:30 2014
+++ src/sys/arch/x86/pci/pciide_machdep.c	Mon May 12 11:55:39 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pciide_machdep.c,v 1.12 2014/03/29 19:28:30 christos Exp $	*/
+/*	$NetBSD: pciide_machdep.c,v 1.13 2014/05/12 11:55:39 joerg Exp $	*/
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -41,7 +41,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pciide_machdep.c,v 1.12 2014/03/29 19:28:30 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: pciide_machdep.c,v 1.13 2014/05/12 11:55:39 joerg Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -70,8 +70,8 @@ pciide_machdep_compat_intr_establish(dev
 	void *cookie;
 #if NIOAPIC  0
 	int mpih;
-#endif
 	char buf[PCI_INTRSTR_LEN];
+#endif
 
 	irq = PCIIDE_COMPAT_IRQ(chan);
 	cookie = isa_intr_establish(NULL, irq, IST_EDGE, IPL_BIO, func, arg);



CVS commit: src/sys/arch/x86/pci

2014-05-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue May  6 18:54:34 UTC 2014

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
tidy up.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.66 src/sys/arch/x86/pci/pci_machdep.c:1.67
--- src/sys/arch/x86/pci/pci_machdep.c:1.66	Tue May  6 05:01:26 2014
+++ src/sys/arch/x86/pci/pci_machdep.c	Tue May  6 14:54:34 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.66 2014/05/06 09:01:26 sborrill Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.67 2014/05/06 18:54:34 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.66 2014/05/06 09:01:26 sborrill Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.67 2014/05/06 18:54:34 christos Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -526,7 +526,6 @@ pci_mode_detect(void)
 	int i;
 	pcireg_t idreg;
 	extern char cpu_brand_string[];
-	const char *system_vendor, *system_product;
 
 	if (pci_mode != -1)
 		return pci_mode;
@@ -550,22 +549,28 @@ pci_mode_detect(void)
 		idreg = pci_conf_read(NULL, t, PCI_ID_REG); /* needs pci_mode */
 		if (idreg == pcim1_quirk_tbl[i].id) {
 #ifdef DEBUG
-			printf(known mode 1 PCI chipset (%08x)\n,
-			   idreg);
+			printf(%s: known mode 1 PCI chipset (%08x)\n,
+			__func__, idreg);
 #endif
 			return (pci_mode);
 		}
 	}
 
-	system_vendor = pmf_get_platform(system-vendor);
-	system_product = pmf_get_platform(system-product);
-if (memcmp(cpu_brand_string, QEMU, 4) == 0 ||
-	(system_vendor != NULL  system_product != NULL 
-	 !strcmp(system_vendor, Xen) 
-	 !strcmp(system_product, HVM domU))) {
+	const char *reason, *system_vendor, *system_product;
+	if (memcmp(cpu_brand_string, QEMU, 4) == 0)
 		/* PR 45671, https://bugs.launchpad.net/qemu/+bug/897771 */
+		reason = QEMU;
+	else if ((system_vendor = pmf_get_platform(system-vendor)) != NULL 
+	strcmp(system_vendor, Xen) == 0 
+	(system_product = pmf_get_platform(system-product)) != NULL 
+	strcmp(system_product, HVM domU) == 0)
+		reason = Xen;
+	else
+		reason = NULL;
+
+	if (reason) {
 #ifdef DEBUG
-		printf(forcing PCI mode 1 for QEMU\n);
+		printf(%s: forcing PCI mode 1 for %s\n, __func__, reason);
 #endif
 		return (pci_mode);
 	}
@@ -581,8 +586,7 @@ pci_mode_detect(void)
 	val = inl(PCI_MODE1_ADDRESS_REG);
 	if ((val  0x80fc) != PCI_MODE1_ENABLE) {
 #ifdef DEBUG
-		printf(pci_mode_detect: mode 1 enable failed (%x)\n,
-		   val);
+		printf(%s: mode 1 enable failed (%x)\n, __func__, val);
 #endif
 		goto not1;
 	}



CVS commit: src/sys/arch/x86/pci

2014-01-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Jan 27 23:11:50 UTC 2014

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
Stopgap to prevent genfb from stealing console.  Revisit later.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.64 src/sys/arch/x86/pci/pci_machdep.c:1.65
--- src/sys/arch/x86/pci/pci_machdep.c:1.64	Sun Jan 26 10:54:24 2014
+++ src/sys/arch/x86/pci/pci_machdep.c	Mon Jan 27 23:11:50 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.64 2014/01/26 10:54:24 msaitoh Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.65 2014/01/27 23:11:50 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.64 2014/01/26 10:54:24 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.65 2014/01/27 23:11:50 jakllsch Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -938,6 +938,13 @@ device_pci_register(device_t dev, void *
 }
 #endif
 			}
+#if 1  NWSDISPLAY  0  NGENFB  0
+			/* XXX */
+			if (device_is_a(dev, genfb)) {
+prop_dictionary_set_bool(dict, is_console,
+genfb_is_console());
+			} else
+#endif
 			prop_dictionary_set_bool(dict, is_console, true);
 
 			prop_dictionary_set_bool(dict, clear-screen, false);



CVS commit: src/sys/arch/x86/pci

2014-01-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jan  3 23:18:48 UTC 2014

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
Add C2000 Platform Controller Unit(PCU).


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.40 src/sys/arch/x86/pci/ichlpcib.c:1.41
--- src/sys/arch/x86/pci/ichlpcib.c:1.40	Tue Sep 17 01:16:45 2013
+++ src/sys/arch/x86/pci/ichlpcib.c	Fri Jan  3 23:18:48 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.40 2013/09/17 01:16:45 jakllsch Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.41 2014/01/03 23:18:48 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.40 2013/09/17 01:16:45 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.41 2014/01/03 23:18:48 msaitoh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -261,6 +261,10 @@ static struct lpcib_device {
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C226_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H81_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_1, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_2, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_3, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_4, 1, 0 },
 
 	{ 0, 0, 0, 0 },
 };



CVS commit: src/sys/arch/x86/pci

2014-01-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jan  4 02:09:12 UTC 2014

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
Temporary disable C2000 PCU because the behavior of the wdog is little strange.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.41 src/sys/arch/x86/pci/ichlpcib.c:1.42
--- src/sys/arch/x86/pci/ichlpcib.c:1.41	Fri Jan  3 23:18:48 2014
+++ src/sys/arch/x86/pci/ichlpcib.c	Sat Jan  4 02:09:12 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.41 2014/01/03 23:18:48 msaitoh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.42 2014/01/04 02:09:12 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.41 2014/01/03 23:18:48 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.42 2014/01/04 02:09:12 msaitoh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -261,10 +261,12 @@ static struct lpcib_device {
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C226_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H81_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_LPC, 1, 0 },
+#if 0
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_1, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_2, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_3, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C2000_PCU_4, 1, 0 },
+#endif
 
 	{ 0, 0, 0, 0 },
 };



CVS commit: src/sys/arch/x86/pci

2014-01-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jan  4 02:59:17 UTC 2014

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
Add Z68 LPC.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.42 src/sys/arch/x86/pci/ichlpcib.c:1.43
--- src/sys/arch/x86/pci/ichlpcib.c:1.42	Sat Jan  4 02:09:12 2014
+++ src/sys/arch/x86/pci/ichlpcib.c	Sat Jan  4 02:59:17 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.42 2014/01/04 02:09:12 msaitoh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.43 2014/01/04 02:59:17 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.42 2014/01/04 02:09:12 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.43 2014/01/04 02:59:17 msaitoh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -233,6 +233,7 @@ static struct lpcib_device {
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QM67_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QS67_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_UM67_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z68_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_B75_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H77_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_MOBILE_HM70_LPC, 1, 0 },



CVS commit: src/sys/arch/x86/pci

2013-12-25 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Dec 25 17:24:39 UTC 2013

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
Give cpu_comcnprobe a chance of working on Mode 2 PCI config space.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.62 src/sys/arch/x86/pci/pci_machdep.c:1.63
--- src/sys/arch/x86/pci/pci_machdep.c:1.62	Thu Oct 17 21:12:24 2013
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed Dec 25 17:24:39 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.62 2013/10/17 21:12:24 christos Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.63 2013/12/25 17:24:39 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.62 2013/10/17 21:12:24 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.63 2013/12/25 17:24:39 jakllsch Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -970,7 +970,7 @@ cpu_comcnprobe(struct consdev *cn, struc
 	pci_mode_detect();
 	pa-pa_iot = x86_bus_space_io;
 	pa-pa_pc = 0;
-	pa-pa_tag = pci_make_tag(0, 0, 31, 0);
+	pa-pa_tag = pci_make_tag(0, 0, pci_bus_maxdevs(NULL, 0) - 1, 0);
 	return 0;
 }
 #endif



CVS commit: src/sys/arch/x86/pci

2013-11-12 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Nov 12 15:08:01 UTC 2013

Modified Files:
src/sys/arch/x86/pci: amdtemp.c

Log Message:
 Calcurate the processor family correctly. The extended family bits
should be added only when the base family is 0xf.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/pci/amdtemp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/amdtemp.c
diff -u src/sys/arch/x86/pci/amdtemp.c:1.16 src/sys/arch/x86/pci/amdtemp.c:1.17
--- src/sys/arch/x86/pci/amdtemp.c:1.16	Mon Jul 16 01:52:37 2012
+++ src/sys/arch/x86/pci/amdtemp.c	Tue Nov 12 15:08:01 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: amdtemp.c,v 1.16 2012/07/16 01:52:37 pgoyette Exp $ */
+/*  $NetBSD: amdtemp.c,v 1.17 2013/11/12 15:08:01 msaitoh Exp $ */
 /*  $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $   */
 
 /*
@@ -48,7 +48,7 @@
 
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: amdtemp.c,v 1.16 2012/07/16 01:52:37 pgoyette Exp $ );
+__KERNEL_RCSID(0, $NetBSD: amdtemp.c,v 1.17 2013/11/12 15:08:01 msaitoh Exp $ );
 
 #include sys/param.h
 #include sys/bus.h
@@ -239,7 +239,8 @@ amdtemp_attach(device_t parent, device_t
 	KASSERT(cpu_signature != 0x0);
 
 	sc-sc_family = CPUID2FAMILY(cpu_signature);
-	sc-sc_family += CPUID2EXTFAMILY(cpu_signature);
+	if (sc-sc_family == 0xf)
+		sc-sc_family += CPUID2EXTFAMILY(cpu_signature);
 
 	KASSERT(sc-sc_family = 0xf);
 



CVS commit: src/sys/arch/x86/pci

2013-10-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct 17 21:12:24 UTC 2013

Modified Files:
src/sys/arch/x86/pci: fwhrng.c pci_machdep.c

Log Message:
remove set but unused variables


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/x86/pci/fwhrng.c
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/fwhrng.c
diff -u src/sys/arch/x86/pci/fwhrng.c:1.5 src/sys/arch/x86/pci/fwhrng.c:1.6
--- src/sys/arch/x86/pci/fwhrng.c:1.5	Thu Feb  2 14:43:01 2012
+++ src/sys/arch/x86/pci/fwhrng.c	Thu Oct 17 17:12:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fwhrng.c,v 1.5 2012/02/02 19:43:01 tls Exp $	*/
+/*	$NetBSD: fwhrng.c,v 1.6 2013/10/17 21:12:24 christos Exp $	*/
 
 /*
  * Copyright (c) 2000 Michael Shalayeff
@@ -29,7 +29,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: fwhrng.c,v 1.5 2012/02/02 19:43:01 tls Exp $);
+__KERNEL_RCSID(0, $NetBSD: fwhrng.c,v 1.6 2013/10/17 21:12:24 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -71,11 +71,8 @@ fwhrng_match(device_t parent, cfdata_t m
 {
 	bus_space_tag_t bst;
 	bus_space_handle_t bsh;
-	int ret;
 	uint8_t id0, id1, data0, data1;
 
-	ret = 0;
-
 	bst = x86_bus_space_mem;
 
 	/* read chip ID */

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.61 src/sys/arch/x86/pci/pci_machdep.c:1.62
--- src/sys/arch/x86/pci/pci_machdep.c:1.61	Sat Oct  5 07:20:34 2013
+++ src/sys/arch/x86/pci/pci_machdep.c	Thu Oct 17 17:12:24 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.61 2013/10/05 11:20:34 gson Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.62 2013/10/17 21:12:24 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.61 2013/10/05 11:20:34 gson Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.62 2013/10/17 21:12:24 christos Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -309,9 +309,7 @@ pci_conf_lock(struct pci_conf_lock *ocl,
 static void
 pci_conf_unlock(struct pci_conf_lock *ocl)
 {
-	uint32_t sel;
-
-	sel = atomic_cas_32_ni(cl-cl_sel, cl-cl_sel, ocl-cl_sel);
+	atomic_cas_32_ni(cl-cl_sel, cl-cl_sel, ocl-cl_sel);
 	pci_conf_select(ocl-cl_sel);
 	if (ocl-cl_cpuno != cl-cl_cpuno)
 		atomic_cas_32(cl-cl_cpuno, cl-cl_cpuno, ocl-cl_cpuno);



CVS commit: src/sys/arch/x86/pci

2013-10-05 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Oct  5 11:20:35 UTC 2013

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
Force PCI mode 1 when running under QEMU, to work around QEMU bug 897771.
This should also make it possible to boot NetBSD under versions of KVM
that have inherited said QEMU bug.  Fixes PR kern/45671.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.60 src/sys/arch/x86/pci/pci_machdep.c:1.61
--- src/sys/arch/x86/pci/pci_machdep.c:1.60	Wed Jul 31 19:27:51 2013
+++ src/sys/arch/x86/pci/pci_machdep.c	Sat Oct  5 11:20:34 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.60 2013/07/31 19:27:51 macallan Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.61 2013/10/05 11:20:34 gson Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.60 2013/07/31 19:27:51 macallan Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.61 2013/10/05 11:20:34 gson Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -526,6 +526,7 @@ pci_mode_detect(void)
 	uint32_t sav, val;
 	int i;
 	pcireg_t idreg;
+	extern char cpu_brand_string[];
 
 	if (pci_mode != -1)
 		return pci_mode;
@@ -555,6 +556,13 @@ pci_mode_detect(void)
 			return (pci_mode);
 		}
 	}
+if (memcmp(cpu_brand_string, QEMU, 4) == 0) {
+		/* PR 45671, https://bugs.launchpad.net/qemu/+bug/897771 */
+#ifdef DEBUG
+		printf(forcing PCI mode 1 for QEMU\n);
+#endif
+		return (pci_mode);
+	}
 
 	/*
 	 * Strong check for standard compliant mode 1:



CVS commit: src/sys/arch/x86/pci

2013-09-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Tue Sep 17 01:16:45 UTC 2013

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
Use '\n' at the end of all aprint_error_dev() format strings.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.39 src/sys/arch/x86/pci/ichlpcib.c:1.40
--- src/sys/arch/x86/pci/ichlpcib.c:1.39	Tue Jun  4 13:59:16 2013
+++ src/sys/arch/x86/pci/ichlpcib.c	Tue Sep 17 01:16:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.39 2013/06/04 13:59:16 msaitoh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.40 2013/09/17 01:16:45 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.39 2013/06/04 13:59:16 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.40 2013/09/17 01:16:45 jakllsch Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -315,7 +315,7 @@ lpcibattach(device_t parent, device_t se
 	 */
 	if (pci_mapreg_map(pa, LPCIB_PCI_PMBASE, PCI_MAPREG_TYPE_IO, 0,
 			   sc-sc_iot, sc-sc_ioh, NULL, sc-sc_iosize)) {
-		aprint_error_dev(self, can't map power management i/o space);
+		aprint_error_dev(self, can't map power management i/o space\n);
 		return;
 	}
 
@@ -331,14 +331,14 @@ lpcibattach(device_t parent, device_t se
 		rcba = pci_conf_read(sc-sc_pcib.sc_pc, sc-sc_pcib.sc_tag,
 		 LPCIB_RCBA);
 		if ((rcba  LPCIB_RCBA_EN) == 0) {
-			aprint_error_dev(self, RCBA is not enabled);
+			aprint_error_dev(self, RCBA is not enabled\n);
 			return;
 		}
 		rcba = ~LPCIB_RCBA_EN;
 
 		if (bus_space_map(sc-sc_rcbat, rcba, LPCIB_RCBA_SIZE, 0,
   sc-sc_rcbah)) {
-			aprint_error_dev(self, RCBA could not be mapped);
+			aprint_error_dev(self, RCBA could not be mapped\n);
 			return;
 		}
 	}



CVS commit: src/sys/arch/x86/pci

2013-07-31 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 31 19:27:52 UTC 2013

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
hand genfb the virtual address of the actual framebuffer, not the upper
left corner of the text area
now centering works and we don't scribble past the mapped VRAM when trying
to clear the screen in 32bit colour


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.59 src/sys/arch/x86/pci/pci_machdep.c:1.60
--- src/sys/arch/x86/pci/pci_machdep.c:1.59	Wed Jul 31 14:05:33 2013
+++ src/sys/arch/x86/pci/pci_machdep.c	Wed Jul 31 19:27:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.59 2013/07/31 14:05:33 soren Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.60 2013/07/31 19:27:51 macallan Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.59 2013/07/31 14:05:33 soren Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.60 2013/07/31 19:27:51 macallan Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -897,7 +897,7 @@ device_pci_register(device_t dev, void *
 if (ri-ri_bits != NULL) {
 	prop_dictionary_set_uint64(dict,
 	virtual_address,
-	(vaddr_t)ri-ri_bits);
+	(vaddr_t)ri-ri_origbits);
 }
 #endif
 }
@@ -932,6 +932,7 @@ device_pci_register(device_t dev, void *
 #endif
 			}
 			prop_dictionary_set_bool(dict, is_console, true);
+
 			prop_dictionary_set_bool(dict, clear-screen, false);
 #if NWSDISPLAY  0  NGENFB  0
 			prop_dictionary_set_uint16(dict, cursor-row,



CVS commit: src/sys/arch/x86/pci

2013-06-04 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Jun  4 13:59:17 UTC 2013

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
Add Intel 8 Series / C220 Series LPC devices.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.38 src/sys/arch/x86/pci/ichlpcib.c:1.39
--- src/sys/arch/x86/pci/ichlpcib.c:1.38	Sat Jan 12 20:33:59 2013
+++ src/sys/arch/x86/pci/ichlpcib.c	Tue Jun  4 13:59:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.38 2013/01/12 20:33:59 riastradh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.39 2013/06/04 13:59:16 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.38 2013/01/12 20:33:59 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.39 2013/06/04 13:59:16 msaitoh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -247,6 +247,19 @@ static struct lpcib_device {
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q77_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z75_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z77_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z87_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z85_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM86_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H87_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_HM87_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q85_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q87_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_QM87_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_B85_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C222_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C224_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C226_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_H81_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_LPC, 1, 0 },
 
 	{ 0, 0, 0, 0 },



CVS commit: src/sys/arch/x86/pci

2013-05-03 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri May  3 15:42:31 UTC 2013

Modified Files:
src/sys/arch/x86/pci: pci_machdep.c

Log Message:
use IO_VGA as symbolic constant for 0x3c0 in x86_genfb_set_mapreg()


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/x86/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/pci_machdep.c
diff -u src/sys/arch/x86/pci/pci_machdep.c:1.56 src/sys/arch/x86/pci/pci_machdep.c:1.57
--- src/sys/arch/x86/pci/pci_machdep.c:1.56	Thu Mar  1 20:16:27 2012
+++ src/sys/arch/x86/pci/pci_machdep.c	Fri May  3 15:42:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_machdep.c,v 1.56 2012/03/01 20:16:27 jakllsch Exp $	*/
+/*	$NetBSD: pci_machdep.c,v 1.57 2013/05/03 15:42:29 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.56 2012/03/01 20:16:27 jakllsch Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_machdep.c,v 1.57 2013/05/03 15:42:29 jakllsch Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -803,10 +803,10 @@ einval:
 static void
 x86_genfb_set_mapreg(void *opaque, int index, int r, int g, int b)
 {
-	outb(0x3c0 + VGA_DAC_ADDRW, index);
-	outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)r  2);
-	outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)g  2);
-	outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)b  2);
+	outb(IO_VGA + VGA_DAC_ADDRW, index);
+	outb(IO_VGA + VGA_DAC_PALETTE, (uint8_t)r  2);
+	outb(IO_VGA + VGA_DAC_PALETTE, (uint8_t)g  2);
+	outb(IO_VGA + VGA_DAC_PALETTE, (uint8_t)b  2);
 }
 
 static bool



CVS commit: src/sys/arch/x86/pci

2013-01-12 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Jan 12 20:34:00 UTC 2013

Modified Files:
src/sys/arch/x86/pci: ichlpcib.c

Log Message:
Match the C600's ichlpcib.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/x86/pci/ichlpcib.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.37 src/sys/arch/x86/pci/ichlpcib.c:1.38
--- src/sys/arch/x86/pci/ichlpcib.c:1.37	Wed Dec 19 05:52:00 2012
+++ src/sys/arch/x86/pci/ichlpcib.c	Sat Jan 12 20:33:59 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.37 2012/12/19 05:52:00 msaitoh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.38 2013/01/12 20:33:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.37 2012/12/19 05:52:00 msaitoh Exp $);
+__KERNEL_RCSID(0, $NetBSD: ichlpcib.c,v 1.38 2013/01/12 20:33:59 riastradh Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -247,6 +247,7 @@ static struct lpcib_device {
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Q77_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z75_LPC, 1, 0 },
 	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_Z77_LPC, 1, 0 },
+	{ PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_C600_LPC, 1, 0 },
 
 	{ 0, 0, 0, 0 },
 };



  1   2   >