Re: CVS commit: src/sys/dev/ic

2020-06-25 Thread Christos Zoulas
In article <18083.1593053...@splode.eterna.com.au>,
matthew green   wrote:
>"Jaromir Dolecek" writes:
>> Module Name: src
>> Committed By:jdolecek
>> Date:Wed Jun 24 19:55:25 UTC 2020
>> 
>> Modified Files:
>>  src/sys/dev/ic: ibm561.c
>> 
>> Log Message:
>> avoid allocating almost 5k struct ibm561data on stack in ibm561_cninit();
>> it's too early for kmem_alloc(), so use static variable in BSS
>
>this seems particularly wasteful for a driver that won't
>be useful for most systems.
>
>seems like a candidate for allow-listing instead, and as
>it seems to only be relevant for alpha systems, that have
>a fairly large stack (16K), and this will be called with
>a fairly short call stack.

I agree; the BSS kludge is ugly in general and should only be
used sparingly.

christos



re: CVS commit: src/sys/dev/ic

2020-06-24 Thread matthew green
"Jaromir Dolecek" writes:
> Module Name:  src
> Committed By: jdolecek
> Date: Wed Jun 24 19:55:25 UTC 2020
> 
> Modified Files:
>   src/sys/dev/ic: ibm561.c
> 
> Log Message:
> avoid allocating almost 5k struct ibm561data on stack in ibm561_cninit();
> it's too early for kmem_alloc(), so use static variable in BSS

this seems particularly wasteful for a driver that won't
be useful for most systems.

seems like a candidate for allow-listing instead, and as
it seems to only be relevant for alpha systems, that have
a fairly large stack (16K), and this will be called with
a fairly short call stack.


.mrg.


Re: CVS commit: src/sys/dev/ic

2020-03-23 Thread SAITOH Masanobu
On 2020/03/24 12:45, SAITOH Masanobu wrote:
> Module Name:  src
> Committed By: msaitoh
> Date: Tue Mar 24 03:45:26 UTC 2020
> 
> Modified Files:
>   src/sys/dev/ic: spdmem.c spdmemvar.h
> 
> Log Message:
> - Define some new parameters of DDR3 SPD ROM.
> - Use fine timebase parameters for time calculation on DDR3. This change
>   makes PC3- value

+ and tAA-tRCD-tRP value

> more correctly on newer DD3.>
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.33 -r1.34 src/sys/dev/ic/spdmem.c
> cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/spdmemvar.h
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 


-- 
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


CVS commit: src/sys/dev/ic

2019-11-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Nov 28 05:07:27 UTC 2019

Modified Files:
src/sys/dev/ic: ac97.c am7990.c

Log Message:
Use NULL for pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/ic/ac97.c
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/ic/am7990.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/dev/ic/ac97.c
diff -u src/sys/dev/ic/ac97.c:1.98 src/sys/dev/ic/ac97.c:1.99
--- src/sys/dev/ic/ac97.c:1.98	Wed May  8 13:40:18 2019
+++ src/sys/dev/ic/ac97.c	Thu Nov 28 05:07:27 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: ac97.c,v 1.98 2019/05/08 13:40:18 isaki Exp $ */
+/*  $NetBSD: ac97.c,v 1.99 2019/11/28 05:07:27 isaki Exp $ */
 /*	$OpenBSD: ac97.c,v 1.8 2000/07/19 09:01:35 csapuntz Exp $	*/
 
 /*
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.98 2019/05/08 13:40:18 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.99 2019/11/28 05:07:27 isaki Exp $");
 
 #include 
 #include 
@@ -1691,7 +1691,7 @@ ac97_query_devinfo(struct ac97_codec_if 
 		else if (si->class)
 			name = si->class;
 		else
-			name = 0;
+			name = NULL;
 
 		if (name)
 			strcpy(dip->label.name, name);

Index: src/sys/dev/ic/am7990.c
diff -u src/sys/dev/ic/am7990.c:1.79 src/sys/dev/ic/am7990.c:1.80
--- src/sys/dev/ic/am7990.c:1.79	Tue Jun 26 06:48:00 2018
+++ src/sys/dev/ic/am7990.c	Thu Nov 28 05:07:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: am7990.c,v 1.79 2018/06/26 06:48:00 msaitoh Exp $	*/
+/*	$NetBSD: am7990.c,v 1.80 2019/11/28 05:07:27 isaki Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: am7990.c,v 1.79 2018/06/26 06:48:00 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am7990.c,v 1.80 2019/11/28 05:07:27 isaki Exp $");
 
 #include 
 #include 
@@ -483,7 +483,7 @@ am7990_start(struct ifnet *ifp)
 		}
 
 		IFQ_DEQUEUE(>if_snd, m);
-		if (m == 0)
+		if (m == NULL)
 			break;
 
 		/*



CVS commit: src/sys/dev/ic

2019-11-27 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Nov 28 05:07:27 UTC 2019

Modified Files:
src/sys/dev/ic: ac97.c am7990.c

Log Message:
Use NULL for pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/ic/ac97.c
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/ic/am7990.c

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



CVS commit: src/sys/dev/ic

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 20:27:39 UTC 2019

Modified Files:
src/sys/dev/ic: dw_hdmi.c

Log Message:
Use actual hw mode, not proposed mode.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/dw_hdmi.c

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



CVS commit: src/sys/dev/ic

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 20:27:39 UTC 2019

Modified Files:
src/sys/dev/ic: dw_hdmi.c

Log Message:
Use actual hw mode, not proposed mode.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/ic/dw_hdmi.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/dev/ic/dw_hdmi.c
diff -u src/sys/dev/ic/dw_hdmi.c:1.5 src/sys/dev/ic/dw_hdmi.c:1.6
--- src/sys/dev/ic/dw_hdmi.c:1.5	Sat Nov 23 12:28:44 2019
+++ src/sys/dev/ic/dw_hdmi.c	Sat Nov 23 20:27:39 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dw_hdmi.c,v 1.5 2019/11/23 12:28:44 jmcneill Exp $ */
+/* $NetBSD: dw_hdmi.c,v 1.6 2019/11/23 20:27:39 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.5 2019/11/23 12:28:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.6 2019/11/23 20:27:39 jmcneill Exp $");
 
 #include 
 #include 
@@ -429,14 +429,14 @@ dwhdmi_fc_init(struct dwhdmi_softc *sc, 
 	uint8_t val;
 
 	const uint8_t vic = drm_match_cea_mode(mode);
-	const uint16_t inhactiv = mode->hdisplay;
-	const uint16_t inhblank = mode->htotal - mode->hdisplay;
-	const uint16_t invactiv = mode->vdisplay;
-	const uint8_t invblank = mode->vtotal - mode->vdisplay;
-	const uint16_t hsyncindelay = mode->hsync_start - mode->hdisplay;
-	const uint16_t hsyncinwidth = mode->hsync_end - mode->hsync_start;
-	const uint8_t vsyncindelay = mode->vsync_start - mode->vdisplay;
-	const uint8_t vsyncinwidth = mode->vsync_end - mode->vsync_start;
+	const uint16_t inhactiv = mode->crtc_hdisplay;
+	const uint16_t inhblank = mode->crtc_htotal - mode->crtc_hdisplay;
+	const uint16_t invactiv = mode->crtc_vdisplay;
+	const uint8_t invblank = mode->crtc_vtotal - mode->crtc_vdisplay;
+	const uint16_t hsyncindelay = mode->crtc_hsync_start - mode->crtc_hdisplay;
+	const uint16_t hsyncinwidth = mode->crtc_hsync_end - mode->crtc_hsync_start;
+	const uint8_t vsyncindelay = mode->crtc_vsync_start - mode->crtc_vdisplay;
+	const uint8_t vsyncinwidth = mode->crtc_vsync_end - mode->crtc_vsync_start;
 
 	/* Input video configuration for frame composer */
 	val = HDMI_FC_INVIDCONF_DE_IN_POLARITY;



CVS commit: src/sys/dev/ic

2019-11-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 23 12:28:44 UTC 2019

Modified Files:
src/sys/dev/ic: dw_hdmi.c dw_hdmi.h

Log Message:
Allow bus glue to setup DDC clocks


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.h

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



CVS commit: src/sys/dev/ic

2019-11-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 16 13:10:07 UTC 2019

Modified Files:
src/sys/dev/ic: dw_hdmi.c dw_hdmi.h

Log Message:
Add software volume controls.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.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/dev/ic/dw_hdmi.c
diff -u src/sys/dev/ic/dw_hdmi.c:1.3 src/sys/dev/ic/dw_hdmi.c:1.4
--- src/sys/dev/ic/dw_hdmi.c:1.3	Sat Nov 16 12:50:08 2019
+++ src/sys/dev/ic/dw_hdmi.c	Sat Nov 16 13:10:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dw_hdmi.c,v 1.3 2019/11/16 12:50:08 jmcneill Exp $ */
+/* $NetBSD: dw_hdmi.c,v 1.4 2019/11/16 13:10:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.3 2019/11/16 12:50:08 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.4 2019/11/16 13:10:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -752,12 +752,47 @@ dwhdmi_dai_add_device(audio_dai_tag_t da
 	return 0;
 }
 
+static void
+dwhdmi_audio_swvol_codec(audio_filter_arg_t *arg)
+{
+	struct dwhdmi_softc * const sc = arg->context;
+	const aint_t *src;
+	aint_t *dst;
+	u_int sample_count;
+	u_int i;
+
+	src = arg->src;
+	dst = arg->dst;
+	sample_count = arg->count * arg->srcfmt->channels;
+	for (i = 0; i < sample_count; i++) {
+		aint2_t v = (aint2_t)(*src++);
+		v = v * sc->sc_swvol / 255;
+		*dst++ = (aint_t)v;
+	}
+}
+
+static int
+dwhdmi_audio_set_format(void *priv, int setmode,
+const audio_params_t *play, const audio_params_t *rec,
+audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
+{
+	struct dwhdmi_softc * const sc = priv;
+
+	pfil->codec = dwhdmi_audio_swvol_codec;
+	pfil->context = sc;
+
+	return 0;
+}
+
 static int
-dwhdmi_dai_set_port(void *priv, mixer_ctrl_t *mc)
+dwhdmi_audio_set_port(void *priv, mixer_ctrl_t *mc)
 {
+	struct dwhdmi_softc * const sc = priv;
+
 	switch (mc->dev) {
 	case DWHDMI_DAI_OUTPUT_MASTER_VOLUME:
 	case DWHDMI_DAI_INPUT_DAC_VOLUME:
+		sc->sc_swvol = mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT];
 		return 0;
 	default:
 		return ENXIO;
@@ -765,13 +800,15 @@ dwhdmi_dai_set_port(void *priv, mixer_ct
 }
 
 static int
-dwhdmi_dai_get_port(void *priv, mixer_ctrl_t *mc)
+dwhdmi_audio_get_port(void *priv, mixer_ctrl_t *mc)
 {
+	struct dwhdmi_softc * const sc = priv;
+
 	switch (mc->dev) {
 	case DWHDMI_DAI_OUTPUT_MASTER_VOLUME:
 	case DWHDMI_DAI_INPUT_DAC_VOLUME:
-		mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = 255;
-		mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = 255;
+		mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->sc_swvol;
+		mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->sc_swvol;
 		return 0;
 	default:
 		return ENXIO;
@@ -779,7 +816,7 @@ dwhdmi_dai_get_port(void *priv, mixer_ct
 }
 
 static int
-dwhdmi_dai_query_devinfo(void *priv, mixer_devinfo_t *di)
+dwhdmi_audio_query_devinfo(void *priv, mixer_devinfo_t *di)
 {
 	switch (di->index) {
 	case DWHDMI_DAI_OUTPUT_CLASS:
@@ -822,9 +859,10 @@ dwhdmi_dai_query_devinfo(void *priv, mix
 }
 
 static const struct audio_hw_if dwhdmi_dai_hw_if = {
-	.set_port = dwhdmi_dai_set_port,
-	.get_port = dwhdmi_dai_get_port,
-	.query_devinfo = dwhdmi_dai_query_devinfo,
+	.set_format = dwhdmi_audio_set_format,
+	.set_port = dwhdmi_audio_set_port,
+	.get_port = dwhdmi_audio_get_port,
+	.query_devinfo = dwhdmi_audio_query_devinfo,
 };
 
 int
@@ -849,6 +887,8 @@ dwhdmi_attach(struct dwhdmi_softc *sc)
 	sc->sc_version >> 12, sc->sc_version & 0xfff,
 	sc->sc_phytype);
 
+	sc->sc_swvol = 255;
+
 	/*
 	 * If a DDC i2c bus tag is provided by the caller, use it. Otherwise,
 	 * use the I2C master built-in to DWC HDMI.
Index: src/sys/dev/ic/dw_hdmi.h
diff -u src/sys/dev/ic/dw_hdmi.h:1.3 src/sys/dev/ic/dw_hdmi.h:1.4
--- src/sys/dev/ic/dw_hdmi.h:1.3	Sat Nov 16 12:50:08 2019
+++ src/sys/dev/ic/dw_hdmi.h	Sat Nov 16 13:10:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dw_hdmi.h,v 1.3 2019/11/16 12:50:08 jmcneill Exp $ */
+/* $NetBSD: dw_hdmi.h,v 1.4 2019/11/16 13:10:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -76,6 +76,7 @@ struct dwhdmi_softc {
 	struct i2c_controller	sc_ic_builtin;
 
 	struct audio_dai_device	sc_dai;
+	uint8_t			sc_swvol;
 
 	struct dwhdmi_connector	sc_connector;
 	struct drm_bridge	sc_bridge;



CVS commit: src/sys/dev/ic

2019-11-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 16 13:10:07 UTC 2019

Modified Files:
src/sys/dev/ic: dw_hdmi.c dw_hdmi.h

Log Message:
Add software volume controls.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.h

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



CVS commit: src/sys/dev/ic

2019-11-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 16 12:50:08 UTC 2019

Modified Files:
src/sys/dev/ic: dw_hdmi.c dw_hdmi.h

Log Message:
Add I2S audio input support.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.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/dev/ic/dw_hdmi.c
diff -u src/sys/dev/ic/dw_hdmi.c:1.2 src/sys/dev/ic/dw_hdmi.c:1.3
--- src/sys/dev/ic/dw_hdmi.c:1.2	Sat Nov  9 23:27:50 2019
+++ src/sys/dev/ic/dw_hdmi.c	Sat Nov 16 12:50:08 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dw_hdmi.c,v 1.2 2019/11/09 23:27:50 jmcneill Exp $ */
+/* $NetBSD: dw_hdmi.c,v 1.3 2019/11/16 12:50:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.2 2019/11/09 23:27:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 1.3 2019/11/16 12:50:08 jmcneill Exp $");
 
 #include 
 #include 
@@ -45,6 +45,8 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -52,6 +54,8 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 
 
 #define	HDMI_DESIGN_ID		0x
 #define	HDMI_REVISION_ID	0x0001
+#define	HDMI_CONFIG0_ID		0x0004
+#define	 HDMI_CONFIG0_ID_AUDI2S			__BIT(4)
 #define	HDMI_CONFIG2_ID		0x0006
 
 #define	HDMI_IH_I2CM_STAT0	0x0105
@@ -131,6 +135,10 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 
 #define	 HDMI_FC_CH1PREAM_DEFAULT		0x16
 #define	HDMI_FC_CH2PREAM	0x1016
 #define	 HDMI_FC_CH2PREAM_DEFAULT		0x21
+#define	HDMI_FC_AUDCONF0	0x1025
+#define	HDMI_FC_AUDCONF1	0x1026
+#define	HDMI_FC_AUDCONF2	0x1027
+#define	HDMI_FC_AUDCONF3	0x1028
 
 #define	HDMI_PHY_CONF0		0x3000
 #define	 HDMI_PHY_CONF0_PDZ			__BIT(7)
@@ -149,6 +157,28 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 
 #define	 HDMI_PHY_STAT0_HPD			__BIT(1)
 #define	 HDMI_PHY_STAT0_TX_PHY_LOCK		__BIT(0)
 
+#define	HDMI_AUD_CONF0		0x3100
+#define	 HDMI_AUD_CONF0_SW_AUDIO_FIFO_RST	__BIT(7)
+#define	 HDMI_AUD_CONF0_I2S_SELECT		__BIT(5)
+#define	 HDMI_AUD_CONF0_I2S_IN_EN		__BITS(3,0)
+#define	HDMI_AUD_CONF1		0x3101
+#define	 HDMI_AUD_CONF1_I2S_WIDTH		__BITS(4,0)
+#define	HDMI_AUD_INT		0x3102
+#define	HDMI_AUD_CONF2		0x3103
+#define	 HDMI_AUD_CONF2_INSERT_PCUV		__BIT(2)
+#define	 HDMI_AUD_CONF2_NLPCM			__BIT(1)
+#define	 HDMI_AUD_CONF2_HBR			__BIT(0)
+#define	HDMI_AUD_INT1		0x3104
+
+#define	HDMI_AUD_N1		0x3200
+#define	HDMI_AUD_N2		0x3201
+#define	HDMI_AUD_N3		0x3202
+#define	HDMI_AUD_CTS1		0x3203
+#define	HDMI_AUD_CTS2		0x3204
+#define	HDMI_AUD_CTS3		0x3205
+#define	HDMI_AUD_INPUTCLKFS	0x3206
+#define	 HDMI_AUD_INPUTCLKFS_IFSFACTOR		__BITS(2,0)
+
 #define	HDMI_MC_CLKDIS		0x4001
 #define	 HDMI_MC_CLKDIS_HDCPCLK_DISABLE		__BIT(6)
 #define	 HDMI_MC_CLKDIS_CECCLK_DISABLE		__BIT(5)
@@ -210,6 +240,16 @@ __KERNEL_RCSID(0, "$NetBSD: dw_hdmi.c,v 
 #define	 HDMI_I2CM_SOFTRSTZ_I2C_SOFTRST		__BIT(0)
 #define	HDMI_I2CM_SEGPTR	0x7e0a
 
+enum dwhdmi_dai_mixer_ctrl {
+	DWHDMI_DAI_OUTPUT_CLASS,
+	DWHDMI_DAI_INPUT_CLASS,
+
+	DWHDMI_DAI_OUTPUT_MASTER_VOLUME,
+	DWHDMI_DAI_INPUT_DAC_VOLUME,
+
+	DWHDMI_DAI_MIXER_CTRL_LAST
+};
+
 static int
 dwhdmi_ddc_acquire_bus(void *priv, int flags)
 {
@@ -433,7 +473,6 @@ dwhdmi_fc_init(struct dwhdmi_softc *sc, 
 static void
 dwhdmi_mc_init(struct dwhdmi_softc *sc)
 {
-	struct dwhdmi_connector *dwhdmi_connector = >sc_connector;
 	uint8_t val;
 	u_int n, iter;
 
@@ -445,8 +484,6 @@ dwhdmi_mc_init(struct dwhdmi_softc *sc)
 	  HDMI_MC_CLKDIS_CECCLK_DISABLE |
 	  HDMI_MC_CLKDIS_CSCCLK_DISABLE |
 	  HDMI_MC_CLKDIS_PREPCLK_DISABLE;
-	if (!dwhdmi_connector->monitor_audio)
-		val |= HDMI_MC_CLKDIS_AUDCLK_DISABLE;
 	dwhdmi_write(sc, HDMI_MC_CLKDIS, val);
 
 	/* Soft reset TMDS */
@@ -467,6 +504,59 @@ dwhdmi_mc_disable(struct dwhdmi_softc *s
 	dwhdmi_write(sc, HDMI_MC_CLKDIS, 0xff);
 }
 
+static void
+dwhdmi_audio_init(struct dwhdmi_softc *sc)
+{
+	uint8_t val;
+	u_int n;
+
+	/* The following values are for 48 kHz */
+	switch (sc->sc_curmode.clock) {
+	case 25170:
+		n = 6864;
+		break;
+	case 74170:
+		n = 11648;
+		break;
+	case 148350:
+		n = 5824;
+		break;
+	default:
+		n = 6144;
+		break;
+	}
+
+	/* Use automatic CTS generation */
+	dwhdmi_write(sc, HDMI_AUD_CTS1, 0);
+	dwhdmi_write(sc, HDMI_AUD_CTS2, 0);
+	dwhdmi_write(sc, HDMI_AUD_CTS3, 0);
+
+	/* Set N factor for audio clock regeneration */
+	dwhdmi_write(sc, HDMI_AUD_N1, n & 0xff);
+	dwhdmi_write(sc, HDMI_AUD_N2, (n >> 8) & 0xff);
+	dwhdmi_write(sc, HDMI_AUD_N3, (n >> 16) & 0xff);
+
+	val = dwhdmi_read(sc, HDMI_AUD_CONF0);
+	val |= HDMI_AUD_CONF0_I2S_SELECT;		/* XXX i2s mode */
+	val &= ~HDMI_AUD_CONF0_I2S_IN_EN;
+	val |= __SHIFTIN(1, HDMI_AUD_CONF0_I2S_IN_EN);	/* XXX 2ch */
+	dwhdmi_write(sc, HDMI_AUD_CONF0, val);
+	
+	val = __SHIFTIN(16, HDMI_AUD_CONF1_I2S_WIDTH);
+	dwhdmi_write(sc, HDMI_AUD_CONF1, val);
+
+	dwhdmi_write(sc, HDMI_AUD_INPUTCLKFS, 4);	/* XXX 64 FS 

CVS commit: src/sys/dev/ic

2019-11-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 16 12:50:08 UTC 2019

Modified Files:
src/sys/dev/ic: dw_hdmi.c dw_hdmi.h

Log Message:
Add I2S audio input support.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/dw_hdmi.c src/sys/dev/ic/dw_hdmi.h

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



CVS commit: src/sys/dev/ic

2019-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 15 13:25:53 UTC 2019

Modified Files:
src/sys/dev/ic: rtl81x9reg.h

Log Message:
 Sort RTK_HWREV_* by value.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/ic/rtl81x9reg.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/dev/ic/rtl81x9reg.h
diff -u src/sys/dev/ic/rtl81x9reg.h:1.50 src/sys/dev/ic/rtl81x9reg.h:1.51
--- src/sys/dev/ic/rtl81x9reg.h:1.50	Fri Apr  5 23:46:04 2019
+++ src/sys/dev/ic/rtl81x9reg.h	Fri Nov 15 13:25:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9reg.h,v 1.50 2019/04/05 23:46:04 uwe Exp $	*/
+/*	$NetBSD: rtl81x9reg.h,v 1.51 2019/11/15 13:25:53 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -149,7 +149,7 @@
 #define RTK_TXCFG_IFG		0x0300	/* interframe gap */
 #define RTK_TXCFG_HWREV		0x7CC0
 
-#define RTK_LOOPTEST_OFF		0x
+#define RTK_LOOPTEST_OFF	0x
 #define RTK_LOOPTEST_ON		0x0002
 #define RTK_LOOPTEST_ON_CPLUS	0x0006
 
@@ -166,11 +166,6 @@
 #define RTK_HWREV_8168E		0x2C00
 #define RTK_HWREV_8168E_VL	0x2C80
 #define RTK_HWREV_8168_SPIN1	0x3000
-#define RTK_HWREV_8168G		0x4c00
-#define RTK_HWREV_8168G_SPIN1	0x4c10
-#define RTK_HWREV_8168G_SPIN2	0x5090
-#define RTK_HWREV_8168G_SPIN4	0x5c80
-#define RTK_HWREV_8168GU	0x5080
 #define RTK_HWREV_8100E		0x3080
 #define RTK_HWREV_8101E		0x3400
 #define RTK_HWREV_8102E		0x3480
@@ -181,18 +176,23 @@
 #define RTK_HWREV_8168C_SPIN2	0x3C40
 #define RTK_HWREV_8168CP	0x3C80
 #define RTK_HWREV_8168F		0x4800
+#define RTK_HWREV_8168G		0x4c00
+#define RTK_HWREV_8168G_SPIN1	0x4c10
+#define RTK_HWREV_8168GU	0x5080
+#define RTK_HWREV_8168G_SPIN2	0x5090
 #define RTK_HWREV_8168H		0x5400
 #define RTK_HWREV_8168H_SPIN1	0x5410
+#define RTK_HWREV_8168G_SPIN4	0x5c80
 #define RTK_HWREV_8139		0x6000
 #define RTK_HWREV_8139A		0x7000
 #define RTK_HWREV_8139AG	0x7080
-#define RTK_HWREV_8139B		0x7800
-#define RTK_HWREV_8130		0x7C00
 #define RTK_HWREV_8139C		0x7400
 #define RTK_HWREV_8139D		0x7440
 #define RTK_HWREV_8139CPLUS	0x7480
 #define RTK_HWREV_8101		0x74c0
+#define RTK_HWREV_8139B		0x7800
 #define RTK_HWREV_8100		0x7880
+#define RTK_HWREV_8130		0x7C00
 #define RTK_HWREV_8169_8110SBL	0x7cc0
 
 #define RTK_TXDMA_16BYTES	0x



CVS commit: src/sys/dev/ic

2019-11-15 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Nov 15 13:25:53 UTC 2019

Modified Files:
src/sys/dev/ic: rtl81x9reg.h

Log Message:
 Sort RTK_HWREV_* by value.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/ic/rtl81x9reg.h

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



CVS commit: src/sys/dev/ic

2019-11-10 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Nov 11 07:27:49 UTC 2019

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): Use the SET_FEATURES command to get the number of allocated queues.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/ic/nvme.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/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.46 src/sys/dev/ic/nvme.c:1.47
--- src/sys/dev/ic/nvme.c:1.46	Thu Sep 26 11:50:32 2019
+++ src/sys/dev/ic/nvme.c	Mon Nov 11 07:27:48 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.46 2019/09/26 11:50:32 nonaka Exp $	*/
+/*	$NetBSD: nvme.c,v 1.47 2019/11/11 07:27:48 nonaka Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.46 2019/09/26 11:50:32 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.47 2019/11/11 07:27:48 nonaka Exp $");
 
 #include 
 #include 
@@ -116,7 +116,8 @@ static void	nvme_pt_done(struct nvme_que
 static int	nvme_command_passthrough(struct nvme_softc *,
 		struct nvme_pt_command *, uint16_t, struct lwp *, bool);
 
-static int	nvme_get_number_of_queues(struct nvme_softc *, u_int *);
+static int	nvme_set_number_of_queues(struct nvme_softc *, u_int, u_int *,
+		u_int *);
 
 #define NVME_TIMO_QOP		5	/* queue create and delete timeout */
 #define NVME_TIMO_IDENT		10	/* probe identify timeout */
@@ -339,7 +340,7 @@ nvme_attach(struct nvme_softc *sc)
 	uint32_t reg;
 	u_int dstrd;
 	u_int mps = PAGE_SHIFT;
-	u_int ioq_allocated;
+	u_int ncq, nsq;
 	uint16_t adminq_entries = nvme_adminq_size;
 	uint16_t ioq_entries = nvme_ioq_size;
 	int i;
@@ -413,13 +414,15 @@ nvme_attach(struct nvme_softc *sc)
 
 	if (sc->sc_use_mq) {
 		/* Limit the number of queues to the number allocated in HW */
-		if (nvme_get_number_of_queues(sc, _allocated) != 0) {
+		if (nvme_set_number_of_queues(sc, sc->sc_nq, , ) != 0) {
 			aprint_error_dev(sc->sc_dev,
 			"unable to get number of queues\n");
 			goto disable;
 		}
-		if (sc->sc_nq > ioq_allocated)
-			sc->sc_nq = ioq_allocated;
+		if (sc->sc_nq > ncq)
+			sc->sc_nq = ncq;
+		if (sc->sc_nq > nsq)
+			sc->sc_nq = nsq;
 	}
 
 	sc->sc_q = kmem_zalloc(sizeof(*sc->sc_q) * sc->sc_nq, KM_SLEEP);
@@ -1579,20 +1582,21 @@ nvme_fill_identify(struct nvme_queue *q,
 }
 
 static int
-nvme_get_number_of_queues(struct nvme_softc *sc, u_int *nqap)
+nvme_set_number_of_queues(struct nvme_softc *sc, u_int nq, u_int *ncqa,
+u_int *nsqa)
 {
 	struct nvme_pt_state state;
 	struct nvme_pt_command pt;
 	struct nvme_ccb *ccb;
-	uint16_t ncqa, nsqa;
 	int rv;
 
 	ccb = nvme_ccb_get(sc->sc_admin_q, false);
 	KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */
 
 	memset(, 0, sizeof(pt));
-	pt.cmd.opcode = NVM_ADMIN_GET_FEATURES;
-	pt.cmd.cdw10 = NVM_FEATURE_NUMBER_OF_QUEUES;
+	pt.cmd.opcode = NVM_ADMIN_SET_FEATURES;
+	htolem32(, NVM_FEATURE_NUMBER_OF_QUEUES);
+	htolem32(, ((nq - 1) << 16) | (nq - 1));
 
 	memset(, 0, sizeof(state));
 	state.pt = 
@@ -1604,13 +1608,12 @@ nvme_get_number_of_queues(struct nvme_so
 	rv = nvme_poll(sc, sc->sc_admin_q, ccb, nvme_pt_fill, NVME_TIMO_QOP);
 
 	if (rv != 0) {
-		*nqap = 0;
+		*ncqa = *nsqa = 0;
 		return EIO;
 	}
 
-	ncqa = pt.cpl.cdw0 >> 16;
-	nsqa = pt.cpl.cdw0 & 0x;
-	*nqap = MIN(ncqa, nsqa) + 1;
+	*ncqa = (pt.cpl.cdw0 >> 16) + 1;
+	*nsqa = (pt.cpl.cdw0 & 0x) + 1;
 
 	return 0;
 }



CVS commit: src/sys/dev/ic

2019-11-10 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon Nov 11 07:27:49 UTC 2019

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): Use the SET_FEATURES command to get the number of allocated queues.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/ic/nvme.c

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



CVS commit: src/sys/dev/ic

2019-11-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 10 10:36:01 UTC 2019

Modified Files:
src/sys/dev/ic: dw_hdmi_phy.c

Log Message:
Select the correct MPLL and PHY settings for the requested pixel clock


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/dw_hdmi_phy.c

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



CVS commit: src/sys/dev/ic

2019-11-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 10 10:36:01 UTC 2019

Modified Files:
src/sys/dev/ic: dw_hdmi_phy.c

Log Message:
Select the correct MPLL and PHY settings for the requested pixel clock


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/dw_hdmi_phy.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/dev/ic/dw_hdmi_phy.c
diff -u src/sys/dev/ic/dw_hdmi_phy.c:1.1 src/sys/dev/ic/dw_hdmi_phy.c:1.2
--- src/sys/dev/ic/dw_hdmi_phy.c:1.1	Sat Nov  9 23:27:50 2019
+++ src/sys/dev/ic/dw_hdmi_phy.c	Sun Nov 10 10:36:01 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dw_hdmi_phy.c,v 1.1 2019/11/09 23:27:50 jmcneill Exp $ */
+/* $NetBSD: dw_hdmi_phy.c,v 1.2 2019/11/10 10:36:01 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Oleksandr Tymoshenko 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dw_hdmi_phy.c,v 1.1 2019/11/09 23:27:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dw_hdmi_phy.c,v 1.2 2019/11/10 10:36:01 jmcneill Exp $");
 
 #include 
 
@@ -300,7 +300,7 @@ dwhdmi_phy_configure(struct dwhdmi_softc
 	 * PLL/MPLL config
 	 */
 	for (mpll_conf = >sc_mpll_config[0]; mpll_conf->pixel_clock != 0; mpll_conf++)
-		if (mpll_conf->pixel_clock <= mode->clock)
+		if (mode->clock <= mpll_conf->pixel_clock)
 			break;
 
 	dwhdmi_phy_i2c_write(sc, mpll_conf->cpce, HDMI_PHY_I2C_CPCE_CTRL);
@@ -308,7 +308,7 @@ dwhdmi_phy_configure(struct dwhdmi_softc
 	dwhdmi_phy_i2c_write(sc, mpll_conf->curr, HDMI_PHY_I2C_CURRCTRL);
 
 	for (phy_conf = >sc_phy_config[0]; phy_conf->pixel_clock != 0; phy_conf++)
-		if (phy_conf->pixel_clock <= mode->clock)
+		if (mode->clock <= phy_conf->pixel_clock)
 			break;
 
 	dwhdmi_phy_i2c_write(sc, 0x, HDMI_PHY_I2C_PLLPHBYCTRL);



CVS commit: src/sys/dev/ic

2019-11-04 Thread Patrick Welche
Module Name:src
Committed By:   prlw1
Date:   Mon Nov  4 15:12:10 UTC 2019

Modified Files:
src/sys/dev/ic: wdc.c

Log Message:
Fix locking bug seen when using WDCNDELAY_DEBUG in PR kern/52126
(Observed
  piixide0:0:0: warning: busy-wait took 200us
with no panic)


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/sys/dev/ic/wdc.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/dev/ic/wdc.c
diff -u src/sys/dev/ic/wdc.c:1.294 src/sys/dev/ic/wdc.c:1.295
--- src/sys/dev/ic/wdc.c:1.294	Wed Oct 23 14:44:41 2019
+++ src/sys/dev/ic/wdc.c	Mon Nov  4 15:12:10 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc.c,v 1.294 2019/10/23 14:44:41 christos Exp $ */
+/*	$NetBSD: wdc.c,v 1.295 2019/11/04 15:12:10 prlw1 Exp $ */
 
 /*
  * Copyright (c) 1998, 2001, 2003 Manuel Bouyer.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.294 2019/10/23 14:44:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.295 2019/11/04 15:12:10 prlw1 Exp $");
 
 #include "opt_ata.h"
 #include "opt_wdc.h"
@@ -1240,7 +1240,7 @@ __wdcwait(struct ata_channel *chp, int m
 	if (!cold && xtime > WDCNDELAY_DEBUG) {
 		struct ata_xfer *xfer;
 
-		xfer = ata_queue_get_active_xfer(chp);
+		xfer = ata_queue_get_active_xfer_locked(chp);
 		if (xfer == NULL)
 			printf("%s channel %d: warning: busy-wait took %dus\n",
 			device_xname(chp->ch_atac->atac_dev),



CVS commit: src/sys/dev/ic

2019-11-04 Thread Patrick Welche
Module Name:src
Committed By:   prlw1
Date:   Mon Nov  4 15:12:10 UTC 2019

Modified Files:
src/sys/dev/ic: wdc.c

Log Message:
Fix locking bug seen when using WDCNDELAY_DEBUG in PR kern/52126
(Observed
  piixide0:0:0: warning: busy-wait took 200us
with no panic)


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 src/sys/dev/ic/wdc.c

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



CVS commit: src/sys/dev/ic

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:18:36 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c ssdfbvar.h

Log Message:
ssdfb: add support for SSD1322


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/ssdfbvar.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/dev/ic/ssdfb.c
diff -u src/sys/dev/ic/ssdfb.c:1.8 src/sys/dev/ic/ssdfb.c:1.9
--- src/sys/dev/ic/ssdfb.c:1.8	Tue Oct 22 22:03:27 2019
+++ src/sys/dev/ic/ssdfb.c	Sat Nov  2 14:18:36 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 tnn Exp $ */
+/* $NetBSD: ssdfb.c,v 1.9 2019/11/02 14:18:36 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.9 2019/11/02 14:18:36 tnn Exp $");
 
 #include "opt_ddb.h"
 
@@ -73,6 +73,7 @@ static void	ssdfb_cursor(void *, int, in
 
 /* hardware interface */
 static int	ssdfb_init_ssd1306(struct ssdfb_softc *);
+static int	ssdfb_init_ssd1322(struct ssdfb_softc *);
 static int	ssdfb_set_contrast(struct ssdfb_softc *, uint8_t, bool);
 static int	ssdfb_set_display_on(struct ssdfb_softc *, bool, bool);
 static int	ssdfb_set_mode(struct ssdfb_softc *, u_int);
@@ -85,8 +86,9 @@ static void	ssdfb_damage(struct ssdfb_so
 static void	ssdfb_thread(void *);
 static void	ssdfb_set_usepoll(struct ssdfb_softc *, bool);
 static int	ssdfb_sync(struct ssdfb_softc *, bool);
-static uint64_t	ssdfb_transpose_block_1bpp(uint8_t *, size_t);
-static uint64_t	ssdfb_transpose_block_8bpp(uint8_t *, size_t);
+static int	ssdfb_sync_ssd1306(struct ssdfb_softc *, bool);
+static int	ssdfb_sync_ssd1322(struct ssdfb_softc *, bool);
+static uint64_t	ssdfb_transpose_block(uint8_t *, size_t);
 
 /* misc helpers */
 static const struct ssdfb_product *
@@ -114,6 +116,7 @@ static const struct ssdfb_product ssdfb_
 		.p_name =		"generic",
 		.p_width =		128,
 		.p_height =		64,
+		.p_bits_per_pixel =	1,
 		.p_panel_shift =	0,
 		.p_fosc =		0x8,
 		.p_fosc_div =		0,
@@ -124,9 +127,8 @@ static const struct ssdfb_product ssdfb_
 		.p_vcomh_deselect_level = SSD1306_VCOMH_DESELECT_LEVEL_0_77_VCC,
 		.p_default_contrast =	0x7f,
 		.p_multiplex_ratio =	0x3f,
-		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
-		.p_init =		ssdfb_init_ssd1306
+		.p_init =		ssdfb_init_ssd1306,
+		.p_sync =		ssdfb_sync_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_SH1106_GENERIC,
@@ -134,6 +136,7 @@ static const struct ssdfb_product ssdfb_
 		.p_name =		"generic",
 		.p_width =		128,
 		.p_height =		64,
+		.p_bits_per_pixel =	1,
 		.p_panel_shift =	2,
 		.p_fosc =		0x5,
 		.p_fosc_div =		0,
@@ -144,9 +147,8 @@ static const struct ssdfb_product ssdfb_
 		.p_vcomh_deselect_level = SH1106_VCOMH_DESELECT_LEVEL_DEFAULT,
 		.p_default_contrast =	0x80,
 		.p_multiplex_ratio =	0x3f,
-		.p_chargepump_cmd =	SH1106_CMD_SET_CHARGE_PUMP_7V4,
-		.p_chargepump_arg =	SSDFB_CMD_NOP,
-		.p_init =		ssdfb_init_ssd1306
+		.p_init =		ssdfb_init_ssd1306,
+		.p_sync =		ssdfb_sync_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_ADAFRUIT_938,
@@ -154,6 +156,7 @@ static const struct ssdfb_product ssdfb_
 		.p_name =		"Adafruit Industries, LLC product 938",
 		.p_width =		128,
 		.p_height =		64,
+		.p_bits_per_pixel =	1,
 		.p_panel_shift =	0,
 		.p_fosc =		0x8,
 		.p_fosc_div =		0,
@@ -163,9 +166,8 @@ static const struct ssdfb_product ssdfb_
 		.p_vcomh_deselect_level = 0x40,
 		.p_default_contrast =	0x8f,
 		.p_multiplex_ratio =	0x3f,
-		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
-		.p_init =		ssdfb_init_ssd1306
+		.p_init =		ssdfb_init_ssd1306,
+		.p_sync =		ssdfb_sync_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_ADAFRUIT_931,
@@ -173,6 +175,7 @@ static const struct ssdfb_product ssdfb_
 		.p_name =		"Adafruit Industries, LLC product 931",
 		.p_width =		128,
 		.p_height =		32,
+		.p_bits_per_pixel =	1,
 		.p_panel_shift =	0,
 		.p_fosc =		0x8,
 		.p_fosc_div =		0,
@@ -182,9 +185,24 @@ static const struct ssdfb_product ssdfb_
 		.p_vcomh_deselect_level = 0x40,
 		.p_default_contrast =	0x8f,
 		.p_multiplex_ratio =	0x1f,
-		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
-		.p_init =		ssdfb_init_ssd1306
+		.p_init =		ssdfb_init_ssd1306,
+		.p_sync =		ssdfb_sync_ssd1306
+	},
+	{
+		.p_product_id =		SSDFB_PRODUCT_SSD1322_GENERIC,
+		.p_controller_id =	SSDFB_CONTROLLER_SSD1322,
+		.p_name =		"generic",
+		.p_width =		256,
+		.p_height =		64,
+		.p_bits_per_pixel =	4,
+		.p_panel_shift =	28,
+		.p_vcomh_deselect_level = SSD1322_DEFAULT_VCOMH,
+		.p_fosc =		SSD1322_DEFAULT_FREQUENCY,
+		.p_fosc_div =		SSD1322_DEFAULT_DIVIDER,
+		.p_default_contrast =	

CVS commit: src/sys/dev/ic

2019-11-02 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Nov  2 14:18:36 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c ssdfbvar.h

Log Message:
ssdfb: add support for SSD1322


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/ssdfbvar.h

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



CVS commit: src/sys/dev/ic

2019-10-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 23 14:44:41 UTC 2019

Modified Files:
src/sys/dev/ic: wdc.c

Log Message:
Missing ata_channel_unlock(chp). Noted by mjg@freebsd.


To generate a diff of this commit:
cvs rdiff -u -r1.293 -r1.294 src/sys/dev/ic/wdc.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/dev/ic/wdc.c
diff -u src/sys/dev/ic/wdc.c:1.293 src/sys/dev/ic/wdc.c:1.294
--- src/sys/dev/ic/wdc.c:1.293	Tue Oct 22 08:09:11 2019
+++ src/sys/dev/ic/wdc.c	Wed Oct 23 10:44:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc.c,v 1.293 2019/10/22 12:09:11 martin Exp $ */
+/*	$NetBSD: wdc.c,v 1.294 2019/10/23 14:44:41 christos Exp $ */
 
 /*
  * Copyright (c) 1998, 2001, 2003 Manuel Bouyer.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.293 2019/10/22 12:09:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.294 2019/10/23 14:44:41 christos Exp $");
 
 #include "opt_ata.h"
 #include "opt_wdc.h"
@@ -296,8 +296,10 @@ wdc_drvprobe(struct ata_channel *chp)
 	int i, j, error, tfd;
 
 	ata_channel_lock(chp);
-	if (atabus_alloc_drives(chp, wdc->wdc_maxdrives) != 0)
+	if (atabus_alloc_drives(chp, wdc->wdc_maxdrives) != 0) {
+		ata_channel_unlock(chp);
 		return;
+	}
 	if (wdcprobe1(chp, 0) == 0) {
 		/* No drives, abort the attach here. */
 		atabus_free_drives(chp);



CVS commit: src/sys/dev/ic

2019-10-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 23 14:44:41 UTC 2019

Modified Files:
src/sys/dev/ic: wdc.c

Log Message:
Missing ata_channel_unlock(chp). Noted by mjg@freebsd.


To generate a diff of this commit:
cvs rdiff -u -r1.293 -r1.294 src/sys/dev/ic/wdc.c

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



Re: CVS commit: src/sys/dev/ic

2019-10-23 Thread Kamil Rytarowski
On 22.10.2019 14:09, Martin Husemann wrote:
> Module Name:  src
> Committed By: martin
> Date: Tue Oct 22 12:09:11 UTC 2019
> 
> Modified Files:
>   src/sys/dev/ic: wdc.c
> 
> Log Message:
> Fix channel locking - patch from Christos.
> 
> 

>  #include 
> -__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.292 2019/09/14 17:11:39 tsutsui Exp 
> $");
> +__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.293 2019/10/22 12:09:11 martin Exp $");
>  
>  #include "opt_ata.h"
>  #include "opt_wdc.h"
> @@ -295,15 +295,16 @@ wdc_drvprobe(struct ata_channel *chp)
>   u_int8_t st0 = 0, st1 = 0;
>   int i, j, error, tfd;
>  
> + ata_channel_lock(chp);
>   if (atabus_alloc_drives(chp, wdc->wdc_maxdrives) != 0)

Missing ata_channel_unlock(chp)?

Noted by mjg@freebsd.

>   return;
>   if (wdcprobe1(chp, 0) == 0) {
>   /* No drives, abort the attach here. */
>   atabus_free_drives(chp);
> + ata_channel_unlock(chp);
>   return;
>   }
>  




signature.asc
Description: OpenPGP digital signature


CVS commit: src/sys/dev/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 22:03:27 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c ssdfbvar.h

Log Message:
allow to have a per-product init function


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/ssdfbvar.h

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



CVS commit: src/sys/dev/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 22:03:27 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c ssdfbvar.h

Log Message:
allow to have a per-product init function


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/ssdfb.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/ssdfbvar.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/dev/ic/ssdfb.c
diff -u src/sys/dev/ic/ssdfb.c:1.7 src/sys/dev/ic/ssdfb.c:1.8
--- src/sys/dev/ic/ssdfb.c:1.7	Tue Oct 22 21:41:01 2019
+++ src/sys/dev/ic/ssdfb.c	Tue Oct 22 22:03:27 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.7 2019/10/22 21:41:01 tnn Exp $ */
+/* $NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.7 2019/10/22 21:41:01 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.8 2019/10/22 22:03:27 tnn Exp $");
 
 #include "opt_ddb.h"
 
@@ -72,7 +72,7 @@ static void	ssdfb_eraserows(void *, int,
 static void	ssdfb_cursor(void *, int, int, int);
 
 /* hardware interface */
-static int	ssdfb_init(struct ssdfb_softc *);
+static int	ssdfb_init_ssd1306(struct ssdfb_softc *);
 static int	ssdfb_set_contrast(struct ssdfb_softc *, uint8_t, bool);
 static int	ssdfb_set_display_on(struct ssdfb_softc *, bool, bool);
 static int	ssdfb_set_mode(struct ssdfb_softc *, u_int);
@@ -100,7 +100,8 @@ static void	ssdfb_ddb_trap_callback(int)
 static const char *ssdfb_controller_names[] = {
 	[SSDFB_CONTROLLER_UNKNOWN] =	"unknown",
 	[SSDFB_CONTROLLER_SSD1306] =	"Solomon Systech SSD1306",
-	[SSDFB_CONTROLLER_SH1106] =	"Sino Wealth SH1106"
+	[SSDFB_CONTROLLER_SH1106] =	"Sino Wealth SH1106",
+	[SSDFB_CONTROLLER_SSD1322] =	"Solomon Systech SSD1322"
 };
 
 /*
@@ -124,7 +125,8 @@ static const struct ssdfb_product ssdfb_
 		.p_default_contrast =	0x7f,
 		.p_multiplex_ratio =	0x3f,
 		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE
+		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
+		.p_init =		ssdfb_init_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_SH1106_GENERIC,
@@ -143,7 +145,8 @@ static const struct ssdfb_product ssdfb_
 		.p_default_contrast =	0x80,
 		.p_multiplex_ratio =	0x3f,
 		.p_chargepump_cmd =	SH1106_CMD_SET_CHARGE_PUMP_7V4,
-		.p_chargepump_arg =	SSDFB_CMD_NOP
+		.p_chargepump_arg =	SSDFB_CMD_NOP,
+		.p_init =		ssdfb_init_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_ADAFRUIT_938,
@@ -161,7 +164,8 @@ static const struct ssdfb_product ssdfb_
 		.p_default_contrast =	0x8f,
 		.p_multiplex_ratio =	0x3f,
 		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE
+		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
+		.p_init =		ssdfb_init_ssd1306
 	},
 	{
 		.p_product_id =		SSDFB_PRODUCT_ADAFRUIT_931,
@@ -179,7 +183,8 @@ static const struct ssdfb_product ssdfb_
 		.p_default_contrast =	0x8f,
 		.p_multiplex_ratio =	0x1f,
 		.p_chargepump_cmd =	SSD1306_CMD_SET_CHARGE_PUMP,
-		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE
+		.p_chargepump_arg =	SSD1306_CHARGE_PUMP_ENABLE,
+		.p_init =		ssdfb_init_ssd1306
 	}
 };
 
@@ -294,7 +299,7 @@ ssdfb_attach(struct ssdfb_softc *sc, int
 	/*
 	 * Initialize hardware.
 	 */
-	error = ssdfb_init(sc);
+	error = p->p_init(sc);
 	if (error)
 		goto out;
 
@@ -581,7 +586,7 @@ ssdfb_cursor(void *cookie, int on, int r
 }
 
 static int
-ssdfb_init(struct ssdfb_softc *sc)
+ssdfb_init_ssd1306(struct ssdfb_softc *sc)
 {
 	int error;
 	uint8_t cmd[2];

Index: src/sys/dev/ic/ssdfbvar.h
diff -u src/sys/dev/ic/ssdfbvar.h:1.3 src/sys/dev/ic/ssdfbvar.h:1.4
--- src/sys/dev/ic/ssdfbvar.h:1.3	Tue Oct 22 21:40:10 2019
+++ src/sys/dev/ic/ssdfbvar.h	Tue Oct 22 22:03:27 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfbvar.h,v 1.3 2019/10/22 21:40:10 tnn Exp $ */
+/* $NetBSD: ssdfbvar.h,v 1.4 2019/10/22 22:03:27 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -209,6 +209,8 @@
 	#define SSD1322_COMMAND_UNLOCK_MAGIC		0x12
 	#define SSD1322_COMMAND_LOCK_MAGIC		0x16
 
+struct ssdfb_softc;
+
 typedef enum {
 	SSDFB_CONTROLLER_UNKNOWN=0,
 	SSDFB_CONTROLLER_SSD1306=1,
@@ -254,6 +256,7 @@ struct ssdfb_product {
 	uint8_tp_multiplex_ratio;
 	uint8_tp_chargepump_cmd;
 	uint8_tp_chargepump_arg;
+	int(*p_init)(struct ssdfb_softc *);
 };
 
 struct ssdfb_softc {



CVS commit: src/sys/dev/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 21:41:01 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c

Log Message:
use __SHIFTIN


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/ssdfb.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/dev/ic/ssdfb.c
diff -u src/sys/dev/ic/ssdfb.c:1.6 src/sys/dev/ic/ssdfb.c:1.7
--- src/sys/dev/ic/ssdfb.c:1.6	Wed Jun  5 20:32:28 2019
+++ src/sys/dev/ic/ssdfb.c	Tue Oct 22 21:41:01 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb.c,v 1.6 2019/06/05 20:32:28 tnn Exp $ */
+/* $NetBSD: ssdfb.c,v 1.7 2019/10/22 21:41:01 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.6 2019/06/05 20:32:28 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb.c,v 1.7 2019/10/22 21:41:01 tnn Exp $");
 
 #include "opt_ddb.h"
 
@@ -638,20 +638,16 @@ ssdfb_init(struct ssdfb_softc *sc)
 	 * Configure timing characteristics.
 	 */
 	SSDFB_CMD2(SSDFB_CMD_SET_DISPLAY_CLOCK_RATIO,
-	((sc->sc_p->p_fosc << SSDFB_DISPLAY_CLOCK_OSCILLATOR_SHIFT) &
-	 SSDFB_DISPLAY_CLOCK_OSCILLATOR_MASK) |
-	((sc->sc_p->p_fosc_div << SSDFB_DISPLAY_CLOCK_DIVIDER_SHIFT) &
-	 SSDFB_DISPLAY_CLOCK_DIVIDER_MASK));
+	__SHIFTIN(sc->sc_p->p_fosc, SSDFB_DISPLAY_CLOCK_OSCILLATOR_MASK) |
+	__SHIFTIN(sc->sc_p->p_fosc_div, SSDFB_DISPLAY_CLOCK_DIVIDER_MASK));
 	if (error)
 		return error;
 	SSDFB_CMD2(SSDFB_CMD_SET_CONTRAST_CONTROL, sc->sc_contrast);
 	if (error)
 		return error;
 	SSDFB_CMD2(SSDFB_CMD_SET_PRECHARGE_PERIOD,
-	((sc->sc_p->p_precharge << SSDFB_PRECHARGE_SHIFT) &
-	 SSDFB_PRECHARGE_MASK) |
-	((sc->sc_p->p_discharge << SSDFB_DISCHARGE_SHIFT) &
-	 SSDFB_DISCHARGE_MASK));
+	__SHIFTIN(sc->sc_p->p_precharge, SSDFB_PRECHARGE_MASK) |
+	__SHIFTIN(sc->sc_p->p_discharge, SSDFB_DISCHARGE_MASK));
 	if (error)
 		return error;
 	SSDFB_CMD2(SSDFB_CMD_SET_VCOMH_DESELECT_LEVEL,



CVS commit: src/sys/dev/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 21:41:01 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfb.c

Log Message:
use __SHIFTIN


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/ssdfb.c

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



CVS commit: src/sys/dev/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 21:40:10 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfbvar.h

Log Message:
define SSD1322 command set


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/ssdfbvar.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/dev/ic/ssdfbvar.h
diff -u src/sys/dev/ic/ssdfbvar.h:1.2 src/sys/dev/ic/ssdfbvar.h:1.3
--- src/sys/dev/ic/ssdfbvar.h:1.2	Sun Mar 17 04:03:17 2019
+++ src/sys/dev/ic/ssdfbvar.h	Tue Oct 22 21:40:10 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfbvar.h,v 1.2 2019/03/17 04:03:17 tnn Exp $ */
+/* $NetBSD: ssdfbvar.h,v 1.3 2019/10/22 21:40:10 tnn Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -101,15 +101,11 @@
  * SH1106 Rev 0.1 p.24,25,26
  */
 #define SSDFB_CMD_SET_DISPLAY_CLOCK_RATIO		0xd5
-	#define SSDFB_DISPLAY_CLOCK_DIVIDER_MASK	0x0f
-	#define SSDFB_DISPLAY_CLOCK_DIVIDER_SHIFT	0
-	#define SSDFB_DISPLAY_CLOCK_OSCILLATOR_MASK	0xf0
-	#define SSDFB_DISPLAY_CLOCK_OSCILLATOR_SHIFT	4
+	#define SSDFB_DISPLAY_CLOCK_DIVIDER_MASK	__BITS(3, 0)
+	#define SSDFB_DISPLAY_CLOCK_OSCILLATOR_MASK	__BITS(7, 4)
 #define SSDFB_CMD_SET_PRECHARGE_PERIOD			0xd9
-	#define SSDFB_PRECHARGE_MASK			0x0f
-	#define SSDFB_PRECHARGE_SHIFT			0
-	#define SSDFB_DISCHARGE_MASK			0xf0
-	#define SSDFB_DISCHARGE_SHIFT			4
+	#define SSDFB_PRECHARGE_MASK			__BITS(3, 0)
+	#define SSDFB_DISCHARGE_MASK			__BITS(7, 4)
 #define SSDFB_CMD_SET_VCOMH_DESELECT_LEVEL		0xdb
 	#define SSD1306_VCOMH_DESELECT_LEVEL_0_65_VCC	0x00
 	#define SSD1306_VCOMH_DESELECT_LEVEL_0_77_VCC	0x20
@@ -146,10 +142,78 @@
 	#define SH1106_DC_DC_OFF			0x8a
 	#define SH1106_DC_DC_ON0x8b
 
+/*
+ * SSD1322 command set
+ */
+#define SSD1322_CMD_ENABLE_GRAY_SCALE_TABLE		0x00
+#define SSD1322_CMD_SET_COLUMN_ADDRESS			0x15
+#define SSD1322_CMD_WRITE_RAM0x5c
+#define SSD1322_CMD_READ_RAM0x5d
+#define SSD1322_CMD_SET_ROW_ADDRESS			0x75
+#define SSD1322_CMD_SET_REMAP_AND_DUAL_COM_LINE_MODE	0xa0
+#define SSD1322_CMD_SET_DISPLAY_START_LINE		0xa1
+#define SSD1322_CMD_SET_DISPLAY_OFFSET			0xa2
+
+/* These are the same as SSDFB generic commands */
+#define SSD1322_CMD_ENTIRE_DISPLAY_OFF			0xa4
+#define SSD1322_CMD_ENTIRE_DISPLAY_ON			0xa5
+#define SSD1322_CMD_NORMAL_DISPLAY			0xa6
+#define SSD1322_CMD_INVERSE_DISPLAY			0xa7
+
+#define SSD1322_CMD_ENABLE_PARTIAL_DISPLAY		0xa8
+#define SSD1322_CMD_EXIT_PARTIAL_DISPLAY		0xa9
+#define SSD1322_CMD_FUNCTION_SELECTION			0xab
+	#define SSD1322_FUNCTION_SELECTION_EXTERNAL_VDD	0
+	#define SSD1322_FUNCTION_SELECTION_INTERNAL_VDD	__BIT(0)
+#define SSD1322_CMD_SET_SLEEP_MODE_ON			0xae
+#define SSD1322_CMD_SET_SLEEP_MODE_OFF			0xaf
+#define SSD1322_CMD_SET_PHASE_LENGTH			0xb1
+	#define SSD1322_PHASE_LENGTH_PHASE_2_MASK	__BITS(7, 4)
+	#define SSD1322_DEFAULT_PHASE_2			7
+	#define SSD1322_PHASE_LENGTH_PHASE_1_MASK	__BITS(3, 0)
+	#define SSD1322_DEFAULT_PHASE_1			4
+#define SSD1322_CMD_SET_FRONT_CLOCK_DIVIDER		0xb3
+	#define SSD1322_FREQUENCY_MASK			__BITS(7, 4)
+	#define SSD1322_DEFAULT_FREQUENCY		5
+	#define SSD1322_DIVIDER_MASK			__BITS(3, 0)
+	#define SSD1322_DEFAULT_DIVIDER			0
+#define SSD1322_CMD_DISPLAY_ENHANCEMENT_A		0xb4
+	#define SSD1322_DISPLAY_ENHANCEMENT_A_MAGIC1	0xa2
+	#define SSD1322_DISPLAY_ENHANCEMENT_A_MAGIC2	0xb5
+#define SSD1322_CMD_SET_GPIO0xb5
+	#define SSD1322_GPIO0_DISABLED			0
+	#define SSD1322_GPIO0_TRISTATE			__BIT(0)
+	#define SSD1322_GPIO0_LOW			__BIT(1)
+	#define SSD1322_GPIO0_HIGH			__BITS(1, 0)
+	#define SSD1322_GPIO1_DISABLED			0
+	#define SSD1322_GPIO1_TRISTATE			__BIT(2)
+	#define SSD1322_GPIO1_LOW			__BIT(3)
+	#define SSD1322_GPIO1_HIGH			__BITS(3, 2)
+#define SSD1322_CMD_SET_SECOND_PRECHARGE_PERIOD		0xb6
+	#define SSD1322_DEFAULT_SECOND_PRECHARGE	8
+#define SSD1322_CMD_SET_GRAY_SCALE_TABLE		0xb8
+#define SSD1322_CMD_SET_DEFAULT_GRAY_SCALE_TABLE	0xb9
+#define SSD1322_CMD_SET_PRE_CHARGE_VOLTAGE_LEVEL	0xbb
+	#define SSD1322_DEFAULT_PRE_CHARGE_VOLTAGE_LEVEL	0x17
+#define SSD1322_CMD_SET_VCOMH0xbe
+	#define SSD1322_DEFAULT_VCOMH			0x04
+#define SSD1322_CMD_SET_CONTRAST_CURRENT		0xc1
+	#define SSD1322_DEFAULT_CONTRAST_CURRENT	0x7f
+#define SSD1322_CMD_MASTER_CONTRAST_CURRENT_CONTROL	0xc7
+	#define SSD1322_DEFAULT_MASTER_CONTRAST_CURRENT_CONTROL	0xf
+#define SSD1322_CMD_SET_MUX_RATIO			0xca
+#define SSD1322_CMD_DISPLAY_ENHANCEMENT_B		0xd1
+	#define SSD1322_DISPLAY_ENHANCEMENT_B_MAGIC1	0xa2
+	#define SSD1322_DISPLAY_ENHANCEMENT_B_MAGIC2	0x20
+#define SSD1322_CMD_SET_COMMAND_LOCK			0xfd
+	#define SSD1322_COMMAND_UNLOCK_MAGIC		0x12
+	#define SSD1322_COMMAND_LOCK_MAGIC		0x16
+
 typedef enum {
 	SSDFB_CONTROLLER_UNKNOWN=0,
 	SSDFB_CONTROLLER_SSD1306=1,
 	SSDFB_CONTROLLER_SH1106=2,
+	SSDFB_CONTROLLER_SSD1322=3,
 } ssdfb_controller_id_t;
 
 typedef enum {
@@ -158,6 +222,7 @@ typedef enum {
 	SSDFB_PRODUCT_SH1106_GENERIC=2,
 	SSDFB_PRODUCT_ADAFRUIT_931=3,
 	SSDFB_PRODUCT_ADAFRUIT_938=4,
+	

CVS commit: src/sys/dev/ic

2019-10-22 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 22 21:40:10 UTC 2019

Modified Files:
src/sys/dev/ic: ssdfbvar.h

Log Message:
define SSD1322 command set


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/ssdfbvar.h

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



CVS commit: src/sys/dev/ic

2019-10-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 22 12:09:11 UTC 2019

Modified Files:
src/sys/dev/ic: wdc.c

Log Message:
Fix channel locking - patch from Christos.


To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 src/sys/dev/ic/wdc.c

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



CVS commit: src/sys/dev/ic

2019-10-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct 22 12:09:11 UTC 2019

Modified Files:
src/sys/dev/ic: wdc.c

Log Message:
Fix channel locking - patch from Christos.


To generate a diff of this commit:
cvs rdiff -u -r1.292 -r1.293 src/sys/dev/ic/wdc.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/dev/ic/wdc.c
diff -u src/sys/dev/ic/wdc.c:1.292 src/sys/dev/ic/wdc.c:1.293
--- src/sys/dev/ic/wdc.c:1.292	Sat Sep 14 17:11:39 2019
+++ src/sys/dev/ic/wdc.c	Tue Oct 22 12:09:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdc.c,v 1.292 2019/09/14 17:11:39 tsutsui Exp $ */
+/*	$NetBSD: wdc.c,v 1.293 2019/10/22 12:09:11 martin Exp $ */
 
 /*
  * Copyright (c) 1998, 2001, 2003 Manuel Bouyer.  All rights reserved.
@@ -58,7 +58,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.292 2019/09/14 17:11:39 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.293 2019/10/22 12:09:11 martin Exp $");
 
 #include "opt_ata.h"
 #include "opt_wdc.h"
@@ -295,15 +295,16 @@ wdc_drvprobe(struct ata_channel *chp)
 	u_int8_t st0 = 0, st1 = 0;
 	int i, j, error, tfd;
 
+	ata_channel_lock(chp);
 	if (atabus_alloc_drives(chp, wdc->wdc_maxdrives) != 0)
 		return;
 	if (wdcprobe1(chp, 0) == 0) {
 		/* No drives, abort the attach here. */
 		atabus_free_drives(chp);
+		ata_channel_unlock(chp);
 		return;
 	}
 
-	ata_channel_lock(chp);
 	/* for ATA/OLD drives, wait for DRDY, 3s timeout */
 	for (i = 0; i < mstohz(3000); i++) {
 		/*
@@ -498,7 +499,9 @@ wdcprobe_with_reset(struct wdc_regs *wdr
 	/* check the MD reset method */
 	wdc.reset = (do_reset != NULL) ? do_reset : wdc_do_reset;
 
+	ata_channel_lock();
 	rv = wdcprobe1(, 1);
+	ata_channel_unlock();
 
 	ata_channel_destroy();
 
@@ -522,7 +525,6 @@ wdcprobe1(struct ata_channel *chp, int p
 	 * Sanity check to see if the wdc channel responds at all.
 	 */
 
-	ata_channel_lock(chp);
 	if ((wdc->cap & WDC_CAPABILITY_NO_EXTRA_RESETS) == 0) {
 		while (wdc_probe_count-- > 0) {
 			if (wdc->select)
@@ -675,7 +677,6 @@ wdcprobe1(struct ata_channel *chp, int p
 		}
 
 		if (ret_value == 0) {
-			ata_channel_unlock(chp);
 			return 0;
 		}
 	}
@@ -723,7 +724,6 @@ wdcprobe1(struct ata_channel *chp, int p
 
 	/* if reset failed, there's nothing here */
 	if (ret_value == 0) {
-		ata_channel_unlock(chp);
 		return 0;
 	}
 
@@ -776,7 +776,6 @@ wdcprobe1(struct ata_channel *chp, int p
 		(void)bus_space_read_1(wdr->cmd_iot,
 		wdr->cmd_iohs[wd_status], 0);
 	}
-	ata_channel_unlock(chp);
 	return (ret_value);
 }
 



CVS commit: src/sys/dev/ic

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 06:40:20 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
awge: drop redundant m_adj(). Handled via uipc_mbuf.c r1.235 instead.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/ic/dwc_gmac.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/dev/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.67 src/sys/dev/ic/dwc_gmac.c:1.68
--- src/sys/dev/ic/dwc_gmac.c:1.67	Tue Oct 15 17:19:05 2019
+++ src/sys/dev/ic/dwc_gmac.c	Sat Oct 19 06:40:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.67 2019/10/15 17:19:05 tnn Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.68 2019/10/19 06:40:20 tnn Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.67 2019/10/15 17:19:05 tnn Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.68 2019/10/19 06:40:20 tnn Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -501,7 +501,6 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 		}
 		data->rd_m->m_len = data->rd_m->m_pkthdr.len
 		= data->rd_m->m_ext.ext_size;
-		m_adj(data->rd_m, (-(uintptr_t)data->rd_m->m_data) & 0x3f);
 		if (data->rd_m->m_len > AWGE_MAX_PACKET) {
 			data->rd_m->m_len = data->rd_m->m_pkthdr.len
 			= AWGE_MAX_PACKET;
@@ -1275,7 +1274,6 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 			goto skip;
 		}
 		mnew->m_len = mnew->m_pkthdr.len = mnew->m_ext.ext_size;
-		m_adj(mnew, (-(uintptr_t)mnew->m_data) & 0x3f);
 		if (mnew->m_len > AWGE_MAX_PACKET) {
 			mnew->m_len = mnew->m_pkthdr.len = AWGE_MAX_PACKET;
 		}



CVS commit: src/sys/dev/ic

2019-10-19 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Oct 19 06:40:20 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
awge: drop redundant m_adj(). Handled via uipc_mbuf.c r1.235 instead.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/ic/dwc_gmac.c

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



CVS commit: src/sys/dev/ic

2019-10-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 15 17:19:05 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
correct pointer arithmetics


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/ic/dwc_gmac.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/dev/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.66 src/sys/dev/ic/dwc_gmac.c:1.67
--- src/sys/dev/ic/dwc_gmac.c:1.66	Tue Oct 15 16:30:49 2019
+++ src/sys/dev/ic/dwc_gmac.c	Tue Oct 15 17:19:05 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.66 2019/10/15 16:30:49 tnn Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.67 2019/10/15 17:19:05 tnn Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.66 2019/10/15 16:30:49 tnn Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.67 2019/10/15 17:19:05 tnn Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -501,8 +501,7 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 		}
 		data->rd_m->m_len = data->rd_m->m_pkthdr.len
 		= data->rd_m->m_ext.ext_size;
-		m_adj(data->rd_m,
-		roundup((uintptr_t)data->rd_m->m_data & 0x3f, 0x40));
+		m_adj(data->rd_m, (-(uintptr_t)data->rd_m->m_data) & 0x3f);
 		if (data->rd_m->m_len > AWGE_MAX_PACKET) {
 			data->rd_m->m_len = data->rd_m->m_pkthdr.len
 			= AWGE_MAX_PACKET;
@@ -1276,7 +1275,7 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 			goto skip;
 		}
 		mnew->m_len = mnew->m_pkthdr.len = mnew->m_ext.ext_size;
-		m_adj(mnew, roundup((uintptr_t)mnew->m_data & 0x3f, 0x40));
+		m_adj(mnew, (-(uintptr_t)mnew->m_data) & 0x3f);
 		if (mnew->m_len > AWGE_MAX_PACKET) {
 			mnew->m_len = mnew->m_pkthdr.len = AWGE_MAX_PACKET;
 		}



CVS commit: src/sys/dev/ic

2019-10-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 15 17:19:05 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
correct pointer arithmetics


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/ic/dwc_gmac.c

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



CVS commit: src/sys/dev/ic

2019-10-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 15 16:30:49 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
awge: fix issue that caused rx packets to be corrupt with DIAGNOSTIC kernel

It seems the hardware can only reliably do rx DMA to addresses that are
dcache size aligned. This is hinted at by some GMAC data sheets but hard to
find an authoritative source.

on non-DIAGNOSTIC kernels we always implicitly get MCLBYTES-aligned mbuf
data pointers, but with the reintroduction of POOL_REDZONE for DIAGNOSTIC
we can get 8-byte alignment due to redzone padding. So align rx pointers to
64 bytes which should be good for both arm32 and aarch64.

While here change some bus_dmamap_load() to bus_dmamap_load_mbuf() and add
one missing bus_dmamap_sync(). Also fixes the code to not assume that
MCLBYTES == AWGE_MAX_PACKET. User may override MCLSHIFT in kernel config.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/ic/dwc_gmac.c

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



CVS commit: src/sys/dev/ic

2019-10-15 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Oct 15 16:30:49 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
awge: fix issue that caused rx packets to be corrupt with DIAGNOSTIC kernel

It seems the hardware can only reliably do rx DMA to addresses that are
dcache size aligned. This is hinted at by some GMAC data sheets but hard to
find an authoritative source.

on non-DIAGNOSTIC kernels we always implicitly get MCLBYTES-aligned mbuf
data pointers, but with the reintroduction of POOL_REDZONE for DIAGNOSTIC
we can get 8-byte alignment due to redzone padding. So align rx pointers to
64 bytes which should be good for both arm32 and aarch64.

While here change some bus_dmamap_load() to bus_dmamap_load_mbuf() and add
one missing bus_dmamap_sync(). Also fixes the code to not assume that
MCLBYTES == AWGE_MAX_PACKET. User may override MCLSHIFT in kernel config.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/dev/ic/dwc_gmac.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/dev/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.65 src/sys/dev/ic/dwc_gmac.c:1.66
--- src/sys/dev/ic/dwc_gmac.c:1.65	Fri Sep 13 07:55:06 2019
+++ src/sys/dev/ic/dwc_gmac.c	Tue Oct 15 16:30:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.65 2019/09/13 07:55:06 msaitoh Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.66 2019/10/15 16:30:49 tnn Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.65 2019/09/13 07:55:06 msaitoh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.66 2019/10/15 16:30:49 tnn Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -499,15 +499,24 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 			error = ENOMEM;
 			goto fail;
 		}
+		data->rd_m->m_len = data->rd_m->m_pkthdr.len
+		= data->rd_m->m_ext.ext_size;
+		m_adj(data->rd_m,
+		roundup((uintptr_t)data->rd_m->m_data & 0x3f, 0x40));
+		if (data->rd_m->m_len > AWGE_MAX_PACKET) {
+			data->rd_m->m_len = data->rd_m->m_pkthdr.len
+			= AWGE_MAX_PACKET;
+		}
 
-		error = bus_dmamap_load(sc->sc_dmat, data->rd_map,
-		mtod(data->rd_m, void *), MCLBYTES, NULL,
-		BUS_DMA_READ | BUS_DMA_NOWAIT);
+		error = bus_dmamap_load_mbuf(sc->sc_dmat, data->rd_map,
+		data->rd_m, BUS_DMA_READ | BUS_DMA_NOWAIT);
 		if (error != 0) {
 			aprint_error_dev(sc->sc_dev,
 			"could not load rx buf DMA map #%d", i);
 			goto fail;
 		}
+		bus_dmamap_sync(sc->sc_dmat, data->rd_map, 0,
+		data->rd_map->dm_mapsize, BUS_DMASYNC_PREREAD);
 		physaddr = data->rd_map->dm_segs[0].ds_addr;
 
 		desc = >sc_rxq.r_desc[i];
@@ -516,7 +525,7 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 		desc->ddesc_next = htole32(ring->r_physaddr
 		+ next * sizeof(*desc));
 		sc->sc_descm->rx_init_flags(desc);
-		sc->sc_descm->rx_set_len(desc, AWGE_MAX_PACKET);
+		sc->sc_descm->rx_set_len(desc, data->rd_m->m_len);
 		sc->sc_descm->rx_set_owned_by_dev(desc);
 	}
 
@@ -538,13 +547,15 @@ dwc_gmac_reset_rx_ring(struct dwc_gmac_s
 	struct dwc_gmac_rx_ring *ring)
 {
 	struct dwc_gmac_dev_dmadesc *desc;
+	struct dwc_gmac_rx_data *data;
 	int i;
 
 	mutex_enter(>r_mtx);
 	for (i = 0; i < AWGE_RX_RING_COUNT; i++) {
 		desc = >sc_rxq.r_desc[i];
+		data = >sc_rxq.r_data[i];
 		sc->sc_descm->rx_init_flags(desc);
-		sc->sc_descm->rx_set_len(desc, AWGE_MAX_PACKET);
+		sc->sc_descm->rx_set_len(desc, data->rd_m->m_len);
 		sc->sc_descm->rx_set_owned_by_dev(desc);
 	}
 
@@ -1264,6 +1275,11 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 			ifp->if_ierrors++;
 			goto skip;
 		}
+		mnew->m_len = mnew->m_pkthdr.len = mnew->m_ext.ext_size;
+		m_adj(mnew, roundup((uintptr_t)mnew->m_data & 0x3f, 0x40));
+		if (mnew->m_len > AWGE_MAX_PACKET) {
+			mnew->m_len = mnew->m_pkthdr.len = AWGE_MAX_PACKET;
+		}
 
 		/* unload old DMA map */
 		bus_dmamap_sync(sc->sc_dmat, data->rd_map, 0,
@@ -1271,15 +1287,13 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 		bus_dmamap_unload(sc->sc_dmat, data->rd_map);
 
 		/* and reload with new mbuf */
-		error = bus_dmamap_load(sc->sc_dmat, data->rd_map,
-		mtod(mnew, void*), MCLBYTES, NULL,
-		BUS_DMA_READ | BUS_DMA_NOWAIT);
+		error = bus_dmamap_load_mbuf(sc->sc_dmat, data->rd_map,
+		mnew, BUS_DMA_READ | BUS_DMA_NOWAIT);
 		if (error != 0) {
 			m_freem(mnew);
 			/* try to reload old mbuf */
-			error = bus_dmamap_load(sc->sc_dmat, data->rd_map,
-			mtod(data->rd_m, void*), MCLBYTES, NULL,
-			BUS_DMA_READ | BUS_DMA_NOWAIT);
+			error = bus_dmamap_load_mbuf(sc->sc_dmat, data->rd_map,
+			data->rd_m, BUS_DMA_READ | BUS_DMA_NOWAIT);
 			if (error != 0) {
 panic("%s: could not load old rx mbuf",
 device_xname(sc->sc_dev));
@@ -1308,7 +1322,7 @@ skip:
 		data->rd_map->dm_mapsize, BUS_DMASYNC_PREREAD);
 
 		sc->sc_descm->rx_init_flags(desc);
-		sc->sc_descm->rx_set_len(desc, AWGE_MAX_PACKET);
+		

CVS commit: src/sys/dev/ic

2019-10-05 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Oct  6 01:04:49 UTC 2019

Modified Files:
src/sys/dev/ic: adw.c adwlib.c adwlib.h

Log Message:
Get rid of bogus ADW_CALLBACK typedef.  Use the real callback types
directly.  Since we no longer need the casting dance we can get rid of
ADW_ISR_CALLBACK and ADW_ASYNC_CALLBACK typedefs too.  The diff for
adwlib.h looks larger than it is b/c we need to reorder structure
definitions for the proper callback declaration.  Found by gcc8
-Wcast-function-type.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/ic/adw.c
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/ic/adwlib.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/ic/adwlib.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/dev/ic/adw.c
diff -u src/sys/dev/ic/adw.c:1.54 src/sys/dev/ic/adw.c:1.55
--- src/sys/dev/ic/adw.c:1.54	Thu Jul 14 04:19:26 2016
+++ src/sys/dev/ic/adw.c	Sun Oct  6 01:04:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: adw.c,v 1.54 2016/07/14 04:19:26 msaitoh Exp $	 */
+/* $NetBSD: adw.c,v 1.55 2019/10/06 01:04:49 uwe Exp $	 */
 
 /*
  * Generic driver for the Advanced Systems Inc. SCSI controllers
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adw.c,v 1.54 2016/07/14 04:19:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adw.c,v 1.55 2019/10/06 01:04:49 uwe Exp $");
 
 #include 
 #include 
@@ -398,8 +398,8 @@ adw_init(ADW_SOFTC *sc)
 			"setting. Using automatic termination.\n");
 	}
 
-	sc->isr_callback = (ADW_CALLBACK) adw_isr_callback;
-	sc->async_callback = (ADW_CALLBACK) adw_async_callback;
+	sc->isr_callback = adw_isr_callback;
+	sc->async_callback = adw_async_callback;
 
 	return 0;
 }

Index: src/sys/dev/ic/adwlib.c
diff -u src/sys/dev/ic/adwlib.c:1.42 src/sys/dev/ic/adwlib.c:1.43
--- src/sys/dev/ic/adwlib.c:1.42	Sun Feb  3 03:19:27 2019
+++ src/sys/dev/ic/adwlib.c	Sun Oct  6 01:04:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: adwlib.c,v 1.42 2019/02/03 03:19:27 mrg Exp $*/
+/* $NetBSD: adwlib.c,v 1.43 2019/10/06 01:04:49 uwe Exp $*/
 
 /*
  * Low level routines for the Advanced Systems Inc. SCSI controllers chips
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adwlib.c,v 1.42 2019/02/03 03:19:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adwlib.c,v 1.43 2019/10/06 01:04:49 uwe Exp $");
 
 #include 
 #include 
@@ -2021,7 +2021,7 @@ AdwISR(ADW_SOFTC *sc)
 		}
 
 		if (sc->async_callback != 0) {
-		(*(ADW_ASYNC_CALLBACK)sc->async_callback)(sc, intrb_code);
+			(*sc->async_callback)(sc, intrb_code);
 		}
 	}
 
@@ -2098,7 +2098,7 @@ AdwISR(ADW_SOFTC *sc)
 		 * Notify the driver of the completed request by passing
 		 * the ADW_SCSI_REQ_Q pointer to its callback function.
 		 */
-		(*(ADW_ISR_CALLBACK)sc->isr_callback)(sc, scsiq);
+		(*sc->isr_callback)(sc, scsiq);
 		/*
 		 * Note: After the driver callback function is called, 'scsiq'
 		 * can no longer be referenced.

Index: src/sys/dev/ic/adwlib.h
diff -u src/sys/dev/ic/adwlib.h:1.21 src/sys/dev/ic/adwlib.h:1.22
--- src/sys/dev/ic/adwlib.h:1.21	Sat Oct 27 17:18:18 2012
+++ src/sys/dev/ic/adwlib.h	Sun Oct  6 01:04:49 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: adwlib.h,v 1.21 2012/10/27 17:18:18 chs Exp $*/
+/*  $NetBSD: adwlib.h,v 1.22 2019/10/06 01:04:49 uwe Exp $*/
 
 /*
  * Definitions for low level routines and data structures
@@ -717,80 +717,6 @@ typedef struct adw_sg_block {
 
 
 /*
- * Adapter operation variable structure.
- *
- * One structure is required per host adapter.
- *
- * Field naming convention:
- *
- *  *_able indicates both whether a feature should be enabled or disabled
- *  and whether a device is capable of the feature. At initialization
- *  this field may be set, but later if a device is found to be incapable
- *  of the feature, the field is cleared.
- */
-#define	CCB_HASH_SIZE	32	/* hash table size for phystokv */
-#define	CCB_HASH_SHIFT	9
-#define CCB_HASH(x)	x)) >> CCB_HASH_SHIFT) & (CCB_HASH_SIZE - 1))
-
-typedef int (* ADW_CALLBACK) (int);
-
-typedef struct adw_softc {
-
-	device_t		sc_dev;
-
-	bus_space_tag_t		sc_iot;
-	bus_space_handle_t	sc_ioh;
-	bus_dma_tag_t		sc_dmat;
-	bus_dmamap_t		sc_dmamap_control; /* maps the control structures */
-	bus_dmamap_t		sc_dmamap_carrier; /* maps the carrier structures */
-	void			*sc_ih;
-
-	struct adw_control	*sc_control; /* control structures */
-
-	struct adw_ccb		*sc_ccbhash[CCB_HASH_SIZE];
-	TAILQ_HEAD(, adw_ccb)	sc_free_ccb, sc_waiting_ccb;
-	TAILQ_HEAD(adw_pending_ccb, adw_ccb)	sc_pending_ccb;
-	struct scsipi_adapter   sc_adapter;
-	struct scsipi_channel   sc_channel;
-
-	int			sc_freeze_dev[ADW_MAX_TID+1];
-
-	ADW_CALLBACK	isr_callback;	/* pointer to function, called in AdwISR() */
-	ADW_CALLBACK	async_callback;	/* pointer to function, called in AdwISR() */
-	u_int16_t	bios_ctrl;	/* BIOS control word, EEPROM word 12 */
-	u_int16_t	wdtr_able;	/* try WDTR for a device */
-	

CVS commit: src/sys/dev/ic

2019-10-05 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Oct  6 01:04:49 UTC 2019

Modified Files:
src/sys/dev/ic: adw.c adwlib.c adwlib.h

Log Message:
Get rid of bogus ADW_CALLBACK typedef.  Use the real callback types
directly.  Since we no longer need the casting dance we can get rid of
ADW_ISR_CALLBACK and ADW_ASYNC_CALLBACK typedefs too.  The diff for
adwlib.h looks larger than it is b/c we need to reorder structure
definitions for the proper callback declaration.  Found by gcc8
-Wcast-function-type.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/ic/adw.c
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/ic/adwlib.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/ic/adwlib.h

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



CVS commit: src/sys/dev/ic

2019-10-05 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Oct  6 00:48:19 UTC 2019

Modified Files:
src/sys/dev/ic: adv.c adv.h advlib.c advlib.h

Log Message:
Get rid of bogus ASC_CALLBACK typedef.  Use the real callback type
(which is almost ASC_ISR_CALLBACK).  Since we no longer need the
casting dance we can get rid of the temporary variables, and since we
don't need the temporary variables we don't need the ASC_ISR_CALLBACK
typedef either.  Found by gcc8 -Wcast-function-type.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/ic/adv.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/adv.h
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/ic/advlib.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/advlib.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/dev/ic/adv.c
diff -u src/sys/dev/ic/adv.c:1.48 src/sys/dev/ic/adv.c:1.49
--- src/sys/dev/ic/adv.c:1.48	Wed Aug 29 16:51:51 2018
+++ src/sys/dev/ic/adv.c	Sun Oct  6 00:48:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: adv.c,v 1.48 2018/08/29 16:51:51 rin Exp $	*/
+/*	$NetBSD: adv.c,v 1.49 2019/10/06 00:48:19 uwe Exp $	*/
 
 /*
  * Generic driver for the Advanced Systems Inc. Narrow SCSI controllers
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: adv.c,v 1.48 2018/08/29 16:51:51 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adv.c,v 1.49 2019/10/06 00:48:19 uwe Exp $");
 
 #include 
 #include 
@@ -405,7 +405,7 @@ adv_init(ASC_SOFTC *sc)
 			aprint_normal("unknown warning %d\n", warn);
 		}
 	}
-	sc->isr_callback = (ASC_CALLBACK) adv_narrow_isr_callback;
+	sc->isr_callback = adv_narrow_isr_callback;
 
 	return (0);
 }

Index: src/sys/dev/ic/adv.h
diff -u src/sys/dev/ic/adv.h:1.13 src/sys/dev/ic/adv.h:1.14
--- src/sys/dev/ic/adv.h:1.13	Sun Dec 11 12:21:25 2005
+++ src/sys/dev/ic/adv.h	Sun Oct  6 00:48:19 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: adv.h,v 1.13 2005/12/11 12:21:25 christos Exp $*/
+/*  $NetBSD: adv.h,v 1.14 2019/10/06 00:48:19 uwe Exp $*/
 
 /*
  * Generic driver definitions and exported functions for the Advanced
@@ -43,9 +43,6 @@
 
 /**/
 
-/* second level interrupt callback type definition */
-typedef int (* ASC_ISR_CALLBACK) (ASC_SOFTC *, ASC_QDONE_INFO *);
-
 struct adv_ccb
 {
 	ASC_SG_HEAD	sghead;

Index: src/sys/dev/ic/advlib.c
diff -u src/sys/dev/ic/advlib.c:1.27 src/sys/dev/ic/advlib.c:1.28
--- src/sys/dev/ic/advlib.c:1.27	Sat Nov 13 13:52:00 2010
+++ src/sys/dev/ic/advlib.c	Sun Oct  6 00:48:19 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: advlib.c,v 1.27 2010/11/13 13:52:00 uebayasi Exp $*/
+/*  $NetBSD: advlib.c,v 1.28 2019/10/06 00:48:19 uwe Exp $*/
 
 /*
  * Low level routines for the Advanced Systems Inc. SCSI controllers chips
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: advlib.c,v 1.27 2010/11/13 13:52:00 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: advlib.c,v 1.28 2019/10/06 00:48:19 uwe Exp $");
 
 #include 
 #include 
@@ -1549,10 +1549,7 @@ AscIsrQDone(ASC_SOFTC *sc)
 	u_int8_tcur_target_qng;
 	ASC_QDONE_INFO  scsiq_buf;
 	ASC_QDONE_INFO *scsiq;
-	ASC_ISR_CALLBACK asc_isr_callback;
 
-
-	asc_isr_callback = (ASC_ISR_CALLBACK) sc->isr_callback;
 	n_q_used = 1;
 	scsiq = (ASC_QDONE_INFO *) & scsiq_buf;
 	done_q_tail = ASC_GET_VAR_DONE_QTAIL(iot, ioh);
@@ -1631,7 +1628,7 @@ AscIsrQDone(ASC_SOFTC *sc)
 	ASC_SET_CHIP_CONTROL(iot, ioh, 0);
 }
 			}
-			(*asc_isr_callback) (sc, scsiq);
+			(*sc->isr_callback)(sc, scsiq);
 
 			return (1);
 		} else {
@@ -2818,11 +2815,8 @@ AscRiscHaltedAbortCCB(ASC_SOFTC *sc, ADV
 	u_int8_tq_no;
 	ASC_QDONE_INFO  scsiq_buf;
 	ASC_QDONE_INFO *scsiq;
-	ASC_ISR_CALLBACK asc_isr_callback;
 	int last_int_level;
 
-
-	asc_isr_callback = (ASC_ISR_CALLBACK) sc->isr_callback;
 	last_int_level = DvcEnterCritical();
 	scsiq = (ASC_QDONE_INFO *) & scsiq_buf;
 
@@ -2840,7 +2834,7 @@ AscRiscHaltedAbortCCB(ASC_SOFTC *sc, ADV
 AscWriteLramDWord(iot, ioh, q_addr + ASC_SCSIQ_D_CCBPTR, 0L);
 AscWriteLramByte(iot, ioh, q_addr + ASC_SCSIQ_B_STATUS,
 		 scsiq->q_status);
-(*asc_isr_callback) (sc, scsiq);
+(*sc->isr_callback)(sc, scsiq);
 return (1);
 			}
 		}
@@ -2860,11 +2854,8 @@ AscRiscHaltedAbortTIX(ASC_SOFTC *sc, u_i
 	u_int8_tq_no;
 	ASC_QDONE_INFO  scsiq_buf;
 	ASC_QDONE_INFO *scsiq;
-	ASC_ISR_CALLBACK asc_isr_callback;
 	int last_int_level;
 
-
-	asc_isr_callback = (ASC_ISR_CALLBACK) sc->isr_callback;
 	last_int_level = DvcEnterCritical();
 	scsiq = (ASC_QDONE_INFO *) & scsiq_buf;
 	for (q_no = ASC_MIN_ACTIVE_QNO; q_no <= sc->max_total_qng; q_no++) {
@@ -2879,7 +2870,7 @@ AscRiscHaltedAbortTIX(ASC_SOFTC *sc, u_i
 AscWriteLramDWord(iot, ioh, q_addr + ASC_SCSIQ_D_CCBPTR, 0L);
 AscWriteLramByte(iot, ioh, q_addr + ASC_SCSIQ_B_STATUS,
 		 scsiq->q_status);
-(*asc_isr_callback) (sc, scsiq);

CVS commit: src/sys/dev/ic

2019-10-05 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sun Oct  6 00:48:19 UTC 2019

Modified Files:
src/sys/dev/ic: adv.c adv.h advlib.c advlib.h

Log Message:
Get rid of bogus ASC_CALLBACK typedef.  Use the real callback type
(which is almost ASC_ISR_CALLBACK).  Since we no longer need the
casting dance we can get rid of the temporary variables, and since we
don't need the temporary variables we don't need the ASC_ISR_CALLBACK
typedef either.  Found by gcc8 -Wcast-function-type.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/dev/ic/adv.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/adv.h
cvs rdiff -u -r1.27 -r1.28 src/sys/dev/ic/advlib.c
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/advlib.h

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



CVS commit: src/sys/dev/ic

2019-10-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct  5 12:27:14 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_mmc.c dwc_mmc_var.h

Log Message:
Add support for SDIO interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/dwc_mmc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/dwc_mmc_var.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/dev/ic/dwc_mmc.c
diff -u src/sys/dev/ic/dwc_mmc.c:1.17 src/sys/dev/ic/dwc_mmc.c:1.18
--- src/sys/dev/ic/dwc_mmc.c:1.17	Sun Jul 28 10:30:44 2019
+++ src/sys/dev/ic/dwc_mmc.c	Sat Oct  5 12:27:14 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_mmc.c,v 1.17 2019/07/28 10:30:44 jmcneill Exp $ */
+/* $NetBSD: dwc_mmc.c,v 1.18 2019/10/05 12:27:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwc_mmc.c,v 1.17 2019/07/28 10:30:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc_mmc.c,v 1.18 2019/10/05 12:27:14 jmcneill Exp $");
 
 #include 
 #include 
@@ -79,16 +79,40 @@ static struct sdmmc_chip_functions dwc_m
 #define MMC_READ(sc, reg) \
 	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
 
-static void
-dwc_mmc_dump_regs(struct dwc_mmc_softc *sc)
+static int
+dwc_mmc_dmabounce_setup(struct dwc_mmc_softc *sc)
 {
-	device_printf(sc->sc_dev, "device registers:\n");
-	for (u_int off = 0x00; off < 0x100; off += 16) {
-		device_printf(sc->sc_dev, "xx%02x: %08x %08x %08x %08x\n",
-		off,
-		MMC_READ(sc, off + 0), MMC_READ(sc, off + 4),
-		MMC_READ(sc, off + 8), MMC_READ(sc, off + 12));
-	}
+	bus_dma_segment_t ds[1];
+	int error, rseg;
+
+	sc->sc_dmabounce_buflen = dwc_mmc_host_maxblklen(sc);
+	error = bus_dmamem_alloc(sc->sc_dmat, sc->sc_dmabounce_buflen, 0,
+	sc->sc_dmabounce_buflen, ds, 1, , BUS_DMA_WAITOK);
+	if (error)
+		return error;
+	error = bus_dmamem_map(sc->sc_dmat, ds, 1, sc->sc_dmabounce_buflen,
+	>sc_dmabounce_buf, BUS_DMA_WAITOK);
+	if (error)
+		goto free;
+	error = bus_dmamap_create(sc->sc_dmat, sc->sc_dmabounce_buflen, 1,
+	sc->sc_dmabounce_buflen, 0, BUS_DMA_WAITOK, >sc_dmabounce_map);
+	if (error)
+		goto unmap;
+	error = bus_dmamap_load(sc->sc_dmat, sc->sc_dmabounce_map,
+	sc->sc_dmabounce_buf, sc->sc_dmabounce_buflen, NULL,
+	BUS_DMA_WAITOK);
+	if (error)
+		goto destroy;
+	return 0;
+
+destroy:
+	bus_dmamap_destroy(sc->sc_dmat, sc->sc_dmabounce_map);
+unmap:
+	bus_dmamem_unmap(sc->sc_dmat, sc->sc_dmabounce_buf,
+	sc->sc_dmabounce_buflen);
+free:
+	bus_dmamem_free(sc->sc_dmat, ds, rseg);
+	return error;
 }
 
 static int
@@ -145,55 +169,20 @@ dwc_mmc_attach_i(device_t self)
 	saa.saa_sch = sc;
 	saa.saa_clkmin = 400;
 	saa.saa_clkmax = sc->sc_clock_freq / 1000;
+	saa.saa_dmat = sc->sc_dmat;
 	saa.saa_caps = SMC_CAPS_4BIT_MODE|
 		   SMC_CAPS_8BIT_MODE|
 		   SMC_CAPS_SD_HIGHSPEED|
 		   SMC_CAPS_MMC_HIGHSPEED|
-		   SMC_CAPS_AUTO_STOP;
-	if (ISSET(sc->sc_flags, DWC_MMC_F_DMA)) {
-		saa.saa_dmat = sc->sc_dmat;
-		saa.saa_caps |= SMC_CAPS_DMA |
-SMC_CAPS_MULTI_SEG_DMA;
-	}
+		   SMC_CAPS_AUTO_STOP |
+		   SMC_CAPS_DMA |
+		   SMC_CAPS_MULTI_SEG_DMA;
 	if (sc->sc_card_detect)
 		saa.saa_caps |= SMC_CAPS_POLL_CARD_DET;
 
 	sc->sc_sdmmc_dev = config_found(self, , NULL);
 }
 
-static int
-dwc_mmc_wait_rint(struct dwc_mmc_softc *sc, uint32_t mask, int timeout)
-{
-	const bool use_dma = ISSET(sc->sc_flags, DWC_MMC_F_DMA);
-	int retry, error;
-
-	KASSERT(mutex_owned(>sc_intr_lock));
-
-	if (sc->sc_intr_rint & mask)
-		return 0;
-
-	retry = timeout / hz;
-
-	while (retry > 0) {
-		if (use_dma) {
-			error = cv_timedwait(>sc_intr_cv,
-			>sc_intr_lock, hz);
-			if (error && error != EWOULDBLOCK)
-return error;
-			if (sc->sc_intr_rint & mask)
-return 0;
-		} else {
-			sc->sc_intr_rint |= MMC_READ(sc, DWC_MMC_RINT);
-			if (sc->sc_intr_rint & mask)
-return 0;
-			delay(1000);
-		}
-		--retry;
-	}
-
-	return ETIMEDOUT;
-}
-
 static void
 dwc_mmc_led(struct dwc_mmc_softc *sc, int on)
 {
@@ -226,9 +215,9 @@ dwc_mmc_host_reset(sdmmc_chipset_handle_
 
 	MMC_WRITE(sc, DWC_MMC_TIMEOUT, 0x);
 
-	MMC_WRITE(sc, DWC_MMC_IMASK,
-	DWC_MMC_INT_CMD_DONE | DWC_MMC_INT_ERROR |
-	DWC_MMC_INT_DATA_OVER | DWC_MMC_INT_AUTO_CMD_DONE);
+	MMC_WRITE(sc, DWC_MMC_IMASK, 0);
+
+	MMC_WRITE(sc, DWC_MMC_RINT, 0x);
 
 	const uint32_t rx_wmark = (sc->sc_fifo_depth / 2) - 1;
 	const uint32_t tx_wmark = sc->sc_fifo_depth / 2;
@@ -421,56 +410,43 @@ dwc_mmc_bus_rod(sdmmc_chipset_handle_t s
 	return -1;
 }
 
-
-static int
-dwc_mmc_pio_wait(struct dwc_mmc_softc *sc, struct sdmmc_command *cmd)
-{
-	int retry = 0xf;
-	uint32_t bit = (cmd->c_flags & SCF_CMD_READ) ?
-	DWC_MMC_STATUS_FIFO_EMPTY : DWC_MMC_STATUS_FIFO_FULL;
-
-	while (--retry > 0) {
-		uint32_t status = MMC_READ(sc, DWC_MMC_STATUS);
-		if (!(status & bit))
-			return 0;
-		delay(10);
-	}
-
-	return ETIMEDOUT;

CVS commit: src/sys/dev/ic

2019-10-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct  5 12:27:14 UTC 2019

Modified Files:
src/sys/dev/ic: dwc_mmc.c dwc_mmc_var.h

Log Message:
Add support for SDIO interrupts.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/dwc_mmc.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/dwc_mmc_var.h

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



CVS commit: src/sys/dev/ic

2019-10-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct  3 14:42:20 UTC 2019

Modified Files:
src/sys/dev/ic: bwfm.c bwfmreg.h

Log Message:
If firmware is connected in HT or VHT mode, report it to SIOCGIFMEDIA


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/bwfm.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/bwfmreg.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/dev/ic/bwfm.c
diff -u src/sys/dev/ic/bwfm.c:1.16 src/sys/dev/ic/bwfm.c:1.17
--- src/sys/dev/ic/bwfm.c:1.16	Mon Sep  2 07:25:48 2019
+++ src/sys/dev/ic/bwfm.c	Thu Oct  3 14:42:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.16 2019/09/02 07:25:48 mlelstv Exp $ */
+/* $NetBSD: bwfm.c,v 1.17 2019/10/03 14:42:20 jmcneill Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -112,6 +112,7 @@ int	 bwfm_fwvar_var_set_int(struct bwfm_
 struct ieee80211_channel *bwfm_bss2chan(struct bwfm_softc *, struct bwfm_bss_info *);
 void	 bwfm_scan(struct bwfm_softc *);
 void	 bwfm_connect(struct bwfm_softc *);
+void	 bwfm_get_sta_info(struct bwfm_softc *, struct ifmediareq *);
 
 void	 bwfm_rx(struct bwfm_softc *, struct mbuf *);
 void	 bwfm_rx_event(struct bwfm_softc *, struct mbuf *);
@@ -512,6 +513,12 @@ bwfm_ioctl(struct ifnet *ifp, u_long cmd
 		}
 		break;
 
+	case SIOCGIFMEDIA:
+		error = ieee80211_ioctl(ic, cmd, data);
+		if (error == 0 && ic->ic_state == IEEE80211_S_RUN)
+			bwfm_get_sta_info(sc, (struct ifmediareq *)data);
+		break;
+
 	default:
 		error = ieee80211_ioctl(ic, cmd, data);
 	}
@@ -1789,6 +1796,50 @@ bwfm_connect(struct bwfm_softc *sc)
 }
 
 void
+bwfm_get_sta_info(struct bwfm_softc *sc, struct ifmediareq *ifmr)
+{
+	struct ieee80211com *ic = >sc_ic;
+	struct ieee80211_node *ni = ic->ic_bss;
+	struct bwfm_sta_info sta;
+	uint32_t flags, txrate;
+
+	memset(, 0, sizeof(sta));
+	memcpy(, ni->ni_macaddr, sizeof(ni->ni_macaddr));
+
+	if (bwfm_fwvar_var_get_data(sc, "sta_info", , sizeof(sta)))
+		return;
+
+	if (!IEEE80211_ADDR_EQ(ni->ni_macaddr, sta.ea))
+		return;
+
+	if (le16toh(sta.ver) < 4)
+		return;
+
+	flags = le32toh(sta.flags);
+	if ((flags & BWFM_STA_SCBSTATS) == 0)
+		return;
+
+	txrate = le32toh(sta.tx_rate);
+	if (txrate == 0x)
+		return;
+
+	if ((flags & BWFM_STA_VHT_CAP) != 0) {
+		ifmr->ifm_active &= ~IFM_TMASK;
+		ifmr->ifm_active |= IFM_IEEE80211_VHT;
+		ifmr->ifm_active &= ~IFM_MMASK;
+		ifmr->ifm_active |= IFM_IEEE80211_11AC;
+	} else if ((flags & BWFM_STA_N_CAP) != 0) {
+		ifmr->ifm_active &= ~IFM_TMASK;
+		ifmr->ifm_active |= IFM_IEEE80211_MCS;
+		ifmr->ifm_active &= ~IFM_MMASK;
+		if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan))
+			ifmr->ifm_active |= IFM_IEEE80211_11NG;
+		else
+			ifmr->ifm_active |= IFM_IEEE80211_11NA;
+	}
+}
+
+void
 bwfm_rx(struct bwfm_softc *sc, struct mbuf *m)
 {
 	struct ieee80211com *ic = >sc_ic;

Index: src/sys/dev/ic/bwfmreg.h
diff -u src/sys/dev/ic/bwfmreg.h:1.4 src/sys/dev/ic/bwfmreg.h:1.5
--- src/sys/dev/ic/bwfmreg.h:1.4	Sun Sep  1 05:40:39 2019
+++ src/sys/dev/ic/bwfmreg.h	Thu Oct  3 14:42:20 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfmreg.h,v 1.4 2019/09/01 05:40:39 mlelstv Exp $ */
+/* $NetBSD: bwfmreg.h,v 1.5 2019/10/03 14:42:20 jmcneill Exp $ */
 /* $OpenBSD: bwfmreg.h,v 1.16 2018/02/07 21:44:09 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -391,6 +391,137 @@ struct bwfm_bss_info {
 	uint16_t snr;
 };
 
+#define BWFM_MAXRATES_IN_SET		BWFM_MCSSET_LEN
+#define BWFM_ANT_MAX			4
+#define BWFM_VHT_CAP_MCS_MAP_NSS_MAX	8
+#define BWFM_HE_CAP_MCS_MAP_NSS_MAX	BWFM_VHT_CAP_MCS_MAP_NSS_MAX
+
+struct bwfm_sta_rateset_v5 {
+	uint32_t count;
+	/* rates in 500kbps units w/hi bit set if basic */
+	uint8_t rates[BWFM_MAXRATES_IN_SET];
+	uint8_t mcs[BWFM_MCSSET_LEN];
+	uint16_t vht_mcs[BWFM_VHT_CAP_MCS_MAP_NSS_MAX];
+};
+
+struct bwfm_sta_rateset_v7 {
+	uint16_t version;
+	uint16_t len;
+	uint32_t count;
+	/* rates in 500kbps units w/hi bit set if basic */
+	uint8_t rates[BWFM_MAXRATES_IN_SET];
+	uint8_t mcs[BWFM_MCSSET_LEN];
+	uint16_t vht_mcs[BWFM_VHT_CAP_MCS_MAP_NSS_MAX];
+	uint16_t he_mcs[BWFM_HE_CAP_MCS_MAP_NSS_MAX];
+};
+
+struct bwfm_sta_info {
+	uint16_t ver;
+	uint16_t len;
+	uint16_t cap;		/* sta's advertised capabilities */
+
+	uint32_t flags;
+#define BWFM_STA_BRCM		0x0001 /* Running a Broadcom driver */
+#define BWFM_STA_WME		0x0002 /* WMM association */
+#define BWFM_STA_NONERP		0x0004 /* No ERP */
+#define BWFM_STA_AUTHE		0x0008 /* Authenticated */
+#define BWFM_STA_ASSOC		0x0010 /* Associated */
+#define BWFM_STA_AUTHO		0x0020 /* Authorized */
+#define BWFM_STA_WDS		0x0040 /* Wireless Distribution System */
+#define BWFM_STA_WDS_LINKUP	0x0080 /* WDS traffic/probes flowing */
+#define BWFM_STA_PS		0x0100 /* STA in power save mode, says AP */
+#define BWFM_STA_APSD_BE	0x0200 /* APSD for AC_BE default enabled */

CVS commit: src/sys/dev/ic

2019-10-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct  3 14:42:20 UTC 2019

Modified Files:
src/sys/dev/ic: bwfm.c bwfmreg.h

Log Message:
If firmware is connected in HT or VHT mode, report it to SIOCGIFMEDIA


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/bwfm.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/bwfmreg.h

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



Re: CVS commit: src/sys/dev/ic

2019-10-02 Thread Michael van Elst
On Wed, Oct 02, 2019 at 03:44:21AM +, Constantine A. Murenin wrote:
> I'm getting a page fault trap after this patch, at netbsd:dk_open(), in
> VirtualBox 6.0.12 r133076 with an empty NVME controller.


There is a bug in dk_open when attachment didn't complete yet or failed.
I'm about to fix that.

I expect that is the same, but please provide the details.


-- 
Michael van Elst
Internet: mlel...@serpens.de
"A potential Snark may lurk in every tree."


Re: CVS commit: src/sys/dev/ic

2019-10-01 Thread Constantine A. Murenin
I'm getting a page fault trap after this patch, at netbsd:dk_open(), 
in VirtualBox 6.0.12 r133076 with an empty NVME controller.


C.

On 2019-W40-2 10:59 +, Michael van Elst wrote:

Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  1 10:59:50 UTC 2019

Modified Files:
src/sys/dev/ic: ld_nvme.c

Log Message:
Don't attach an ld device if the format descriptor is unsupported/unused.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/ld_nvme.c

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



CVS commit: src/sys/dev/ic

2019-10-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  1 10:59:50 UTC 2019

Modified Files:
src/sys/dev/ic: ld_nvme.c

Log Message:
Don't attach an ld device if the format descriptor is unsupported/unused.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/ld_nvme.c

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



CVS commit: src/sys/dev/ic

2019-10-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Oct  1 10:59:50 UTC 2019

Modified Files:
src/sys/dev/ic: ld_nvme.c

Log Message:
Don't attach an ld device if the format descriptor is unsupported/unused.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/ld_nvme.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/dev/ic/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.22 src/sys/dev/ic/ld_nvme.c:1.23
--- src/sys/dev/ic/ld_nvme.c:1.22	Fri Apr 26 14:28:40 2019
+++ src/sys/dev/ic/ld_nvme.c	Tue Oct  1 10:59:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.22 2019/04/26 14:28:40 mlelstv Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.23 2019/10/01 10:59:49 mlelstv Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22 2019/04/26 14:28:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.23 2019/10/01 10:59:49 mlelstv Exp $");
 
 #include 
 #include 
@@ -105,6 +105,19 @@ ld_nvme_attach(device_t parent, device_t
 	KASSERT(ns);
 	f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
 
+	/*
+	 * NVME1.0e 6.11 Identify command
+	 *
+	 * LBADS values smaller than 9 are not supported, a value
+	 * of zero means that the format is not used.
+	 */
+	if (f->lbads < 9) {
+		if (f->lbads > 0)
+			aprint_error_dev(self,
+			"unsupported logical data size %u\n", f->lbads);
+		return;
+	}
+
 	ld->sc_secsize = 1 << f->lbads;
 	ld->sc_secperunit = ns->ident->nsze;
 	ld->sc_maxxfer = naa->naa_maxphys;



CVS commit: src/sys/dev/ic

2019-09-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Sep 29 21:28:20 UTC 2019

Modified Files:
src/sys/dev/ic: ahcisata_core.c

Log Message:
Use AHCI_RFIS_SYNC in ahci_cmd_complete() AT_READREG case.

Ensures CPU sees the current device to host FIS before parsing.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/ic/ahcisata_core.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/dev/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.77 src/sys/dev/ic/ahcisata_core.c:1.78
--- src/sys/dev/ic/ahcisata_core.c:1.77	Sun Sep 29 21:25:08 2019
+++ src/sys/dev/ic/ahcisata_core.c	Sun Sep 29 21:28:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.77 2019/09/29 21:25:08 jakllsch Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.78 2019/09/29 21:28:20 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.77 2019/09/29 21:25:08 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.78 2019/09/29 21:28:20 jakllsch Exp $");
 
 #include 
 #include 
@@ -1265,6 +1265,7 @@ ahci_cmd_complete(struct ata_channel *ch
 {
 	struct ata_command *ata_c = >c_ata_c;
 	struct ahci_channel *achp = (struct ahci_channel *)chp;
+	struct ahci_softc *sc = AHCI_CH2SC(chp);
 
 	AHCIDEBUG_PRINT(("ahci_cmd_complete port %d CMD 0x%x CI 0x%x\n",
 	chp->ch_channel,
@@ -1286,8 +1287,10 @@ ahci_cmd_complete(struct ata_channel *ch
 		ata_c->flags |= AT_ERROR;
 	}
 
-	if (ata_c->flags & AT_READREG)
+	if (ata_c->flags & AT_READREG) {
+		AHCI_RFIS_SYNC(sc, achp, BUS_DMASYNC_POSTREAD);
 		satafis_rdh_cmd_readreg(ata_c, achp->ahcic_rfis->rfis_rfis);
+	}
 
 	ahci_cmd_done(chp, xfer);
 



CVS commit: src/sys/dev/ic

2019-09-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Sep 29 21:28:20 UTC 2019

Modified Files:
src/sys/dev/ic: ahcisata_core.c

Log Message:
Use AHCI_RFIS_SYNC in ahci_cmd_complete() AT_READREG case.

Ensures CPU sees the current device to host FIS before parsing.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/ic/ahcisata_core.c

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



CVS commit: src/sys/dev/ic

2019-09-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Sep 29 21:25:08 UTC 2019

Modified Files:
src/sys/dev/ic: ahcisata_core.c

Log Message:
Use AHCI_CMDTBL_SYNC in ahci_exec_fis() to ensure hardware sees the
command FIS.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/ic/ahcisata_core.c

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



CVS commit: src/sys/dev/ic

2019-09-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Sep 29 21:25:08 UTC 2019

Modified Files:
src/sys/dev/ic: ahcisata_core.c

Log Message:
Use AHCI_CMDTBL_SYNC in ahci_exec_fis() to ensure hardware sees the
command FIS.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/ic/ahcisata_core.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/dev/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.76 src/sys/dev/ic/ahcisata_core.c:1.77
--- src/sys/dev/ic/ahcisata_core.c:1.76	Sun Sep 29 21:21:41 2019
+++ src/sys/dev/ic/ahcisata_core.c	Sun Sep 29 21:25:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.76 2019/09/29 21:21:41 jakllsch Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.77 2019/09/29 21:25:08 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.76 2019/09/29 21:21:41 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.77 2019/09/29 21:25:08 jakllsch Exp $");
 
 #include 
 #include 
@@ -765,6 +765,7 @@ ahci_exec_fis(struct ata_channel *chp, i
 	else
 		timeout = timeout / 10;
 
+	AHCI_CMDTBL_SYNC(sc, achp, slot, BUS_DMASYNC_PREWRITE);
 	AHCI_CMDH_SYNC(sc, achp, slot,
 	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 	/* start command */



CVS commit: src/sys/dev/ic

2019-09-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Sep 29 21:21:41 UTC 2019

Modified Files:
src/sys/dev/ic: ahcisata_core.c

Log Message:
Ensure cmdh_prdtl is 0 in ahci_do_reset_drive().

(I'm probably just being paranoid here.)


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/ic/ahcisata_core.c

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



CVS commit: src/sys/dev/ic

2019-09-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Sep 29 21:21:41 UTC 2019

Modified Files:
src/sys/dev/ic: ahcisata_core.c

Log Message:
Ensure cmdh_prdtl is 0 in ahci_do_reset_drive().

(I'm probably just being paranoid here.)


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/ic/ahcisata_core.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/dev/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.75 src/sys/dev/ic/ahcisata_core.c:1.76
--- src/sys/dev/ic/ahcisata_core.c:1.75	Sun Apr  7 17:46:49 2019
+++ src/sys/dev/ic/ahcisata_core.c	Sun Sep 29 21:21:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.75 2019/04/07 17:46:49 bouyer Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.76 2019/09/29 21:21:41 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.75 2019/04/07 17:46:49 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.76 2019/09/29 21:21:41 jakllsch Exp $");
 
 #include 
 #include 
@@ -842,6 +842,7 @@ again:
 	cmd_tbl = achp->ahcic_cmd_tbl[c_slot];
 	cmd_h->cmdh_flags = htole16(AHCI_CMDH_F_RST | AHCI_CMDH_F_CBSY |
 	RHD_FISLEN / 4 | (drive << AHCI_CMDH_F_PMP_SHIFT));
+	cmd_h->cmdh_prdtl = 0;
 	cmd_h->cmdh_prdbc = 0;
 	memset(cmd_tbl->cmdt_cfis, 0, 64);
 	cmd_tbl->cmdt_cfis[fis_type] = RHD_FISTYPE;



CVS commit: src/sys/dev/ic

2019-09-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Sep 29 21:16:14 UTC 2019

Modified Files:
src/sys/dev/ic: ahcisatavar.h

Log Message:
Make AHCI_RFIS_SYNC macro (currently unused) compile.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/ahcisatavar.h

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



CVS commit: src/sys/dev/ic

2019-09-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Sep 29 21:16:14 UTC 2019

Modified Files:
src/sys/dev/ic: ahcisatavar.h

Log Message:
Make AHCI_RFIS_SYNC macro (currently unused) compile.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/ahcisatavar.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/dev/ic/ahcisatavar.h
diff -u src/sys/dev/ic/ahcisatavar.h:1.22 src/sys/dev/ic/ahcisatavar.h:1.23
--- src/sys/dev/ic/ahcisatavar.h:1.22	Mon Jan 14 21:29:56 2019
+++ src/sys/dev/ic/ahcisatavar.h	Sun Sep 29 21:16:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisatavar.h,v 1.22 2019/01/14 21:29:56 jdolecek Exp $	*/
+/*	$NetBSD: ahcisatavar.h,v 1.23 2019/09/29 21:16:14 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -103,7 +103,8 @@ struct ahci_softc {
 (char *)(&(achp)->ahcic_cmdh[(cmd)]) - (char *)(sc)->sc_cmd_hdr, \
 sizeof(struct ahci_cmd_header), (op))
 #define AHCI_RFIS_SYNC(sc, achp, op) bus_dmamap_sync((sc)->sc_dmat, \
-(sc)->sc_cmd_hdrd, (void *)(achp)->ahcic_rfis - (sc)->sc_cmd_hdr, \
+(sc)->sc_cmd_hdrd, \
+(char *)(achp)->ahcic_rfis - (char *)(sc)->sc_cmd_hdr, \
 AHCI_RFIS_SIZE, (op))
 #define AHCI_CMDTBL_SYNC(sc, achp, cmd, op) bus_dmamap_sync((sc)->sc_dmat, \
 (achp)->ahcic_cmd_tbld, AHCI_CMDTBL_SIZE * (cmd), \



CVS commit: src/sys/dev/ic

2019-09-26 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Sep 26 11:50:32 UTC 2019

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): Don't attach the device, if namespace not found.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/ic/nvme.c

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



CVS commit: src/sys/dev/ic

2019-09-26 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Sep 26 11:50:32 UTC 2019

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): Don't attach the device, if namespace not found.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/dev/ic/nvme.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/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.45 src/sys/dev/ic/nvme.c:1.46
--- src/sys/dev/ic/nvme.c:1.45	Fri Sep 20 05:32:42 2019
+++ src/sys/dev/ic/nvme.c	Thu Sep 26 11:50:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.45 2019/09/20 05:32:42 nonaka Exp $	*/
+/*	$NetBSD: nvme.c,v 1.46 2019/09/26 11:50:32 nonaka Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.45 2019/09/20 05:32:42 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.46 2019/09/26 11:50:32 nonaka Exp $");
 
 #include 
 #include 
@@ -399,6 +399,10 @@ nvme_attach(struct nvme_softc *sc)
 		aprint_error_dev(sc->sc_dev, "unable to identify controller\n");
 		goto disable;
 	}
+	if (sc->sc_nn == 0) {
+		aprint_error_dev(sc->sc_dev, "namespace not found\n");
+		goto disable;
+	}
 
 	/* we know how big things are now */
 	sc->sc_max_sgl = sc->sc_mdts / sc->sc_mps;



CVS commit: src/sys/dev/ic

2019-09-25 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Sep 25 15:51:37 UTC 2019

Modified Files:
src/sys/dev/ic: isp_netbsd.c

Log Message:
Make clang -Wformat-security happier by not passing a (constant) variable
as the format string,
const string msg; printf(msg)
  -> printf("%s", msg);

the strings are all known and don't currently contain format variables.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/dev/ic/isp_netbsd.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/dev/ic/isp_netbsd.c
diff -u src/sys/dev/ic/isp_netbsd.c:1.94 src/sys/dev/ic/isp_netbsd.c:1.95
--- src/sys/dev/ic/isp_netbsd.c:1.94	Sat Sep 21 07:31:56 2019
+++ src/sys/dev/ic/isp_netbsd.c	Wed Sep 25 15:51:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_netbsd.c,v 1.94 2019/09/21 07:31:56 maxv Exp $ */
+/* $NetBSD: isp_netbsd.c,v 1.95 2019/09/25 15:51:37 maya Exp $ */
 /*
  * Platform (NetBSD) dependent common attachment code for Qlogic adapters.
  */
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.94 2019/09/21 07:31:56 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.95 2019/09/25 15:51:37 maya Exp $");
 
 #include 
 #include 
@@ -1261,7 +1261,7 @@ isp_async(struct ispsoftc *isp, ispasync
    "Starting Loop Down Timer");
 			}
 		}
-		isp_prt(isp, ISP_LOGINFO, msg);
+		isp_prt(isp, ISP_LOGINFO, "%s", msg);
 		break;
 case ISPASYNC_LOOP_UP:
 		/*
@@ -1457,7 +1457,7 @@ isp_async(struct ispsoftc *isp, ispasync
 			isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
 			   "Stopping Loop Down Timer");
 		}
-		isp_prt(isp, ISP_LOGINFO, msg);
+		isp_prt(isp, ISP_LOGINFO, "%s", msg);
 		/*
 		 * We can set blocked here because we know it's now okay
 		 * to try and run isp_fc_runstate (in order to build loop



CVS commit: src/sys/dev/ic

2019-09-25 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Sep 25 15:51:37 UTC 2019

Modified Files:
src/sys/dev/ic: isp_netbsd.c

Log Message:
Make clang -Wformat-security happier by not passing a (constant) variable
as the format string,
const string msg; printf(msg)
  -> printf("%s", msg);

the strings are all known and don't currently contain format variables.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/dev/ic/isp_netbsd.c

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



CVS commit: src/sys/dev/ic

2019-09-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Sep 23 17:37:04 UTC 2019

Modified Files:
src/sys/dev/ic: an.c

Log Message:
Move the timeout check out of the loop, otherwise it is never reached.
Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/ic/an.c

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



CVS commit: src/sys/dev/ic

2019-09-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Mon Sep 23 17:37:04 UTC 2019

Modified Files:
src/sys/dev/ic: an.c

Log Message:
Move the timeout check out of the loop, otherwise it is never reached.
Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/ic/an.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/dev/ic/an.c
diff -u src/sys/dev/ic/an.c:1.71 src/sys/dev/ic/an.c:1.72
--- src/sys/dev/ic/an.c:1.71	Fri Sep 20 11:29:47 2019
+++ src/sys/dev/ic/an.c	Mon Sep 23 17:37:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: an.c,v 1.71 2019/09/20 11:29:47 maxv Exp $	*/
+/*	$NetBSD: an.c,v 1.72 2019/09/23 17:37:04 maxv Exp $	*/
 /*
  * Copyright (c) 1997, 1998, 1999
  *	Bill Paul .  All rights reserved.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.71 2019/09/20 11:29:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.72 2019/09/23 17:37:04 maxv Exp $");
 
 
 #include 
@@ -1796,12 +1796,12 @@ an_alloc_fid(struct an_softc *sc, int le
 	for (i = 0; i < AN_TIMEOUT; i++) {
 		if (CSR_READ_2(sc, AN_EVENT_STAT) & AN_EV_ALLOC)
 			break;
-		if (i == AN_TIMEOUT) {
-			printf("%s: timeout in alloc\n", device_xname(sc->sc_dev));
-			return ETIMEDOUT;
-		}
 		DELAY(10);
 	}
+	if (i == AN_TIMEOUT) {
+		printf("%s: timeout in alloc\n", device_xname(sc->sc_dev));
+		return ETIMEDOUT;
+	}
 
 	*idp = CSR_READ_2(sc, AN_ALLOC_FID);
 	CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_ALLOC);



CVS commit: src/sys/dev/ic

2019-09-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Sep 23 16:19:33 UTC 2019

Modified Files:
src/sys/dev/ic: mpt.c

Log Message:
Use PRIxBUSADDR


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/ic/mpt.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/dev/ic/mpt.c
diff -u src/sys/dev/ic/mpt.c:1.20 src/sys/dev/ic/mpt.c:1.21
--- src/sys/dev/ic/mpt.c:1.20	Sat Sep 21 12:57:25 2019
+++ src/sys/dev/ic/mpt.c	Mon Sep 23 16:19:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpt.c,v 1.20 2019/09/21 12:57:25 kre Exp $	*/
+/*	$NetBSD: mpt.c,v 1.21 2019/09/23 16:19:33 skrll Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001 by Greg Ansley
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.20 2019/09/21 12:57:25 kre Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.21 2019/09/23 16:19:33 skrll Exp $");
 
 #include 
 
@@ -327,8 +327,8 @@ mpt_send_cmd(mpt_softc_t *mpt, request_t
 	if (mpt->verbose > 1) {
 		u_int32_t *pReq;
 		pReq = req->req_vbuf;
-		mpt_prt(mpt, "Send Request %d (%#jx):",
-		req->index, (intmax_t)req->req_pbuf);
+		mpt_prt(mpt, "Send Request %d (%#" PRIxBUSADDR "):",
+		req->index, req->req_pbuf);
 		mpt_prt(mpt, "%08x %08x %08x %08x",
 		pReq[0], pReq[1], pReq[2], pReq[3]);
 		mpt_prt(mpt, "%08x %08x %08x %08x",



CVS commit: src/sys/dev/ic

2019-09-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Sep 23 16:19:33 UTC 2019

Modified Files:
src/sys/dev/ic: mpt.c

Log Message:
Use PRIxBUSADDR


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/ic/mpt.c

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



CVS commit: src/sys/dev/ic

2019-09-22 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Sep 22 16:41:19 UTC 2019

Modified Files:
src/sys/dev/ic: rtl8169.c rtl81x9var.h

Log Message:
8168H model didn't link up well. some models seems to require to enable TX/RX 
after configuration.
RTKQ_TXRXEN_LATER quirk flag added. it may be able to unify with 
RTKQ_RXDV_GATED flag?


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/ic/rtl81x9var.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/dev/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.159 src/sys/dev/ic/rtl8169.c:1.160
--- src/sys/dev/ic/rtl8169.c:1.159	Thu May 30 02:32:18 2019
+++ src/sys/dev/ic/rtl8169.c	Sun Sep 22 16:41:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.160 2019/09/22 16:41:19 ryo Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.159 2019/05/30 02:32:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.160 2019/09/22 16:41:19 ryo Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -607,12 +607,16 @@ re_attach(struct rtk_softc *sc)
 			sc->sc_quirk |= RTKQ_NOJUMBO;
 			break;
 		case RTK_HWREV_8168E:
-		case RTK_HWREV_8168H:
 		case RTK_HWREV_8168H_SPIN1:
 			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
 			RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM |
 			RTKQ_NOJUMBO;
 			break;
+		case RTK_HWREV_8168H:
+			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
+			RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_PHYWAKE_PM |
+			RTKQ_NOJUMBO | RTKQ_RXDV_GATED | RTKQ_TXRXEN_LATER;
+			break;
 		case RTK_HWREV_8168E_VL:
 		case RTK_HWREV_8168F:
 			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
@@ -1873,7 +1877,8 @@ re_init(struct ifnet *ifp)
 	/*
 	 * Enable transmit and receive.
 	 */
-	CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB);
+	if ((sc->sc_quirk & RTKQ_TXRXEN_LATER) == 0)
+		CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB);
 
 	/*
 	 * Set the initial TX and RX configuration.
@@ -1915,6 +1920,12 @@ re_init(struct ifnet *ifp)
 	rtk_setmulti(sc);
 
 	/*
+	 * some chips require to enable TX/RX *AFTER* TX/RX configuration
+	 */
+	if ((sc->sc_quirk & RTKQ_TXRXEN_LATER) != 0)
+		CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB);
+
+	/*
 	 * Enable interrupts.
 	 */
 	if (sc->re_testmode)

Index: src/sys/dev/ic/rtl81x9var.h
diff -u src/sys/dev/ic/rtl81x9var.h:1.56 src/sys/dev/ic/rtl81x9var.h:1.57
--- src/sys/dev/ic/rtl81x9var.h:1.56	Wed Apr 19 00:20:02 2017
+++ src/sys/dev/ic/rtl81x9var.h	Sun Sep 22 16:41:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9var.h,v 1.56 2017/04/19 00:20:02 jmcneill Exp $	*/
+/*	$NetBSD: rtl81x9var.h,v 1.57 2019/09/22 16:41:19 ryo Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -194,6 +194,7 @@ struct rtk_softc {
 #define RTKQ_PHYWAKE_PM		0x0400	/* wake PHY from power down */
 #define RTKQ_RXDV_GATED		0x0800
 #define RTKQ_IM_HW		0x1000	/* HW interrupt mitigation */
+#define RTKQ_TXRXEN_LATER	0x2000	/* TX/RX enable timing */
 
 	bus_dma_tag_t		sc_dmat;
 



CVS commit: src/sys/dev/ic

2019-09-22 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Sun Sep 22 16:41:19 UTC 2019

Modified Files:
src/sys/dev/ic: rtl8169.c rtl81x9var.h

Log Message:
8168H model didn't link up well. some models seems to require to enable TX/RX 
after configuration.
RTKQ_TXRXEN_LATER quirk flag added. it may be able to unify with 
RTKQ_RXDV_GATED flag?


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/ic/rtl81x9var.h

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



Re: CVS commit: src/sys/dev/ic

2019-09-22 Thread Robert Elz
Date:Sun, 22 Sep 2019 07:23:00 +0100
From:Nick Hudson 
Message-ID:  <793d2380-8d1a-78ab-3682-0468aea0d...@gmx.co.uk>

  | I was merely pointing out that it exists already.

Understood, and thanks - at a minimum that will avoid adding
it with a different name.

  | I'm happy to help adding it to other ports.

There's certainly no harm in that, for future use, but for right
now there's no real need.

kre



CVS commit: src/sys/dev/ic

2019-09-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Sep 22 09:03:07 UTC 2019

Modified Files:
src/sys/dev/ic: malo.c

Log Message:
Reduce always true comparison in malo_cmd_set_txpower()

powerlevel is already checked for >=30 in the previous condition.

Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/malo.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/dev/ic/malo.c
diff -u src/sys/dev/ic/malo.c:1.15 src/sys/dev/ic/malo.c:1.16
--- src/sys/dev/ic/malo.c:1.15	Fri Dec 14 21:23:43 2018
+++ src/sys/dev/ic/malo.c	Sun Sep 22 09:03:07 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: malo.c,v 1.15 2018/12/14 21:23:43 jakllsch Exp $ */
+/*	$NetBSD: malo.c,v 1.16 2019/09/22 09:03:07 kamil Exp $ */
 /*	$OpenBSD: malo.c,v 1.92 2010/08/27 17:08:00 jsg Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.15 2018/12/14 21:23:43 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: malo.c,v 1.16 2019/09/22 09:03:07 kamil Exp $");
 
 #include 
 #include 
@@ -2156,7 +2156,7 @@ malo_cmd_set_txpower(struct malo_softc *
 	body->action = htole16(1);
 	if (powerlevel < 30)
 		body->supportpowerlvl = htole16(5);	/* LOW */
-	else if (powerlevel >= 30 && powerlevel < 60)
+	else if (powerlevel < 60)
 		body->supportpowerlvl = htole16(10);	/* MEDIUM */
 	else
 		body->supportpowerlvl = htole16(15);	/* HIGH */



CVS commit: src/sys/dev/ic

2019-09-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Sep 22 09:03:07 UTC 2019

Modified Files:
src/sys/dev/ic: malo.c

Log Message:
Reduce always true comparison in malo_cmd_set_txpower()

powerlevel is already checked for >=30 in the previous condition.

Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/malo.c

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



Re: CVS commit: src/sys/dev/ic

2019-09-22 Thread Nick Hudson

On 21/09/2019 20:19, Robert Elz wrote:

 Date:Sun, 22 Sep 2019 01:23:41 +0700
 From:Robert Elz 
 Message-ID:  <8235.1569090...@jinx.noi.kre.to>

   | we'd need it in all the other ports before it can be used in MD code.

I meant MI code of course...


Sure. I was merely pointing out that it exists already.

I'm happy to help adding it to other ports.

Nick


Re: CVS commit: src/sys/dev/ic

2019-09-21 Thread Robert Elz
Date:Sun, 22 Sep 2019 01:23:41 +0700
From:Robert Elz 
Message-ID:  <8235.1569090...@jinx.noi.kre.to>

  | we'd need it in all the other ports before it can be used in MD code.

I meant MI code of course...

kre



Re: CVS commit: src/sys/dev/ic

2019-09-21 Thread Robert Elz
Date:Sat, 21 Sep 2019 19:06:15 +0100
From:Nick Hudson 
Message-ID:  

  | 
http://src.illumos.org/source/search?q=PRIxBUSADDR=PRIxBUSADDRnetbsd-src

That shows that mips and arm have PRIxBUSADDR - we'd need it in all the
other ports before it can be used in MD code.

kre



Re: CVS commit: src/sys/dev/ic

2019-09-21 Thread Nick Hudson
On 21/09/2019 17:26, Jason Thorpe wrote:
> Should we make a PRIxxx macro for it?
>
> -- thorpej
> Sent from my iPhone.
>
>> On Sep 21, 2019, at 5:57 AM, Robert Elz  wrote:
>>
>> Module Name:src
>> Committed By:kre
>> Date:Sat Sep 21 12:57:25 UTC 2019
>>
>> Modified Files:
>> src/sys/dev/ic: mpt.c
>>
>> Log Message:
>> bus_addt_t is different widths on different archs, so there is no
>> one simple %?x format that will always work to print it.  Cast to
>> intmax_t and use %jx which should work everywhere.

http://src.illumos.org/source/search?q=PRIxBUSADDR=PRIxBUSADDRnetbsd-src




Re: CVS commit: src/sys/dev/ic

2019-09-21 Thread Robert Elz
Date:Sat, 21 Sep 2019 09:26:21 -0700
From:Jason Thorpe 
Message-ID:  

  | Should we make a PRIxxx macro for it?

[since I deleted the context: "it" is bus_addr_t]

Perhaps, for this particular case it doesn't really matter, but if
code is likely to be printing buss_addr_t type values often enough
that it might make a difference, that might be worthwhile.

kre



Re: CVS commit: src/sys/dev/ic

2019-09-21 Thread Jason Thorpe
Should we make a PRIxxx macro for it?

-- thorpej
Sent from my iPhone.

> On Sep 21, 2019, at 5:57 AM, Robert Elz  wrote:
> 
> Module Name:src
> Committed By:kre
> Date:Sat Sep 21 12:57:25 UTC 2019
> 
> Modified Files:
>src/sys/dev/ic: mpt.c
> 
> Log Message:
> bus_addt_t is different widths on different archs, so there is no
> one simple %?x format that will always work to print it.  Cast to
> intmax_t and use %jx which should work everywhere.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/mpt.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 


CVS commit: src/sys/dev/ic

2019-09-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Sep 21 12:57:25 UTC 2019

Modified Files:
src/sys/dev/ic: mpt.c

Log Message:
bus_addt_t is different widths on different archs, so there is no
one simple %?x format that will always work to print it.  Cast to
intmax_t and use %jx which should work everywhere.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/mpt.c

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



CVS commit: src/sys/dev/ic

2019-09-21 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Sep 21 12:57:25 UTC 2019

Modified Files:
src/sys/dev/ic: mpt.c

Log Message:
bus_addt_t is different widths on different archs, so there is no
one simple %?x format that will always work to print it.  Cast to
intmax_t and use %jx which should work everywhere.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/mpt.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/dev/ic/mpt.c
diff -u src/sys/dev/ic/mpt.c:1.19 src/sys/dev/ic/mpt.c:1.20
--- src/sys/dev/ic/mpt.c:1.19	Sat Sep 21 07:08:27 2019
+++ src/sys/dev/ic/mpt.c	Sat Sep 21 12:57:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpt.c,v 1.19 2019/09/21 07:08:27 maxv Exp $	*/
+/*	$NetBSD: mpt.c,v 1.20 2019/09/21 12:57:25 kre Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001 by Greg Ansley
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.19 2019/09/21 07:08:27 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.20 2019/09/21 12:57:25 kre Exp $");
 
 #include 
 
@@ -327,8 +327,8 @@ mpt_send_cmd(mpt_softc_t *mpt, request_t
 	if (mpt->verbose > 1) {
 		u_int32_t *pReq;
 		pReq = req->req_vbuf;
-		mpt_prt(mpt, "Send Request %d (%#lx):",
-		req->index, req->req_pbuf);
+		mpt_prt(mpt, "Send Request %d (%#jx):",
+		req->index, (intmax_t)req->req_pbuf);
 		mpt_prt(mpt, "%08x %08x %08x %08x",
 		pReq[0], pReq[1], pReq[2], pReq[3]);
 		mpt_prt(mpt, "%08x %08x %08x %08x",



CVS commit: src/sys/dev/ic

2019-09-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Sep 21 07:31:56 UTC 2019

Modified Files:
src/sys/dev/ic: isp_netbsd.c

Log Message:
Remove unused function prototype. Reported by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/ic/isp_netbsd.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/dev/ic/isp_netbsd.c
diff -u src/sys/dev/ic/isp_netbsd.c:1.93 src/sys/dev/ic/isp_netbsd.c:1.94
--- src/sys/dev/ic/isp_netbsd.c:1.93	Fri Sep 20 14:20:45 2019
+++ src/sys/dev/ic/isp_netbsd.c	Sat Sep 21 07:31:56 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_netbsd.c,v 1.93 2019/09/20 14:20:45 christos Exp $ */
+/* $NetBSD: isp_netbsd.c,v 1.94 2019/09/21 07:31:56 maxv Exp $ */
 /*
  * Platform (NetBSD) dependent common attachment code for Qlogic adapters.
  */
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.93 2019/09/20 14:20:45 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.94 2019/09/21 07:31:56 maxv Exp $");
 
 #include 
 #include 
@@ -1042,7 +1042,6 @@ isp_make_gone(ispsoftc_t *isp, int tgt)
 static void
 isp_fc_worker(void *arg)
 {
-	void scsipi_run_queue(struct scsipi_channel *);
 	ispsoftc_t *isp = arg;
 	int slp = 0;
 	int chan = 0;



CVS commit: src/sys/dev/ic

2019-09-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Sep 21 07:31:56 UTC 2019

Modified Files:
src/sys/dev/ic: isp_netbsd.c

Log Message:
Remove unused function prototype. Reported by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/ic/isp_netbsd.c

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



CVS commit: src/sys/dev/ic

2019-09-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Sep 21 07:08:27 UTC 2019

Modified Files:
src/sys/dev/ic: mpt.c mpt_netbsd.h

Log Message:
Add __printflike, and fix two incorrect fmts. Reported by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/mpt.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ic/mpt_netbsd.h

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



CVS commit: src/sys/dev/ic

2019-09-21 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Sep 21 07:08:27 UTC 2019

Modified Files:
src/sys/dev/ic: mpt.c mpt_netbsd.h

Log Message:
Add __printflike, and fix two incorrect fmts. Reported by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/mpt.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ic/mpt_netbsd.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/dev/ic/mpt.c
diff -u src/sys/dev/ic/mpt.c:1.18 src/sys/dev/ic/mpt.c:1.19
--- src/sys/dev/ic/mpt.c:1.18	Tue Jan 30 20:15:41 2018
+++ src/sys/dev/ic/mpt.c	Sat Sep 21 07:08:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpt.c,v 1.18 2018/01/30 20:15:41 jakllsch Exp $	*/
+/*	$NetBSD: mpt.c,v 1.19 2019/09/21 07:08:27 maxv Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001 by Greg Ansley
@@ -110,7 +110,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.18 2018/01/30 20:15:41 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.19 2019/09/21 07:08:27 maxv Exp $");
 
 #include 
 
@@ -327,7 +327,7 @@ mpt_send_cmd(mpt_softc_t *mpt, request_t
 	if (mpt->verbose > 1) {
 		u_int32_t *pReq;
 		pReq = req->req_vbuf;
-		mpt_prt(mpt, "Send Request %d (0x%x):",
+		mpt_prt(mpt, "Send Request %d (%#lx):",
 		req->index, req->req_pbuf);
 		mpt_prt(mpt, "%08x %08x %08x %08x",
 		pReq[0], pReq[1], pReq[2], pReq[3]);
@@ -460,7 +460,7 @@ mpt_recv_handshake_reply(mpt_softc_t *mp
 	/* With the second word, we can now look at the length */
 	if (mpt->verbose > 1 && ((reply_len >> 1) != hdr->MsgLength)) {
 		mpt_prt(mpt, "reply length does not match message length: "
-			"got 0x%02x, expected 0x%02x",
+			"got 0x%02x, expected %#02zx",
 			hdr->MsgLength << 2, reply_len << 1);
 	}
 

Index: src/sys/dev/ic/mpt_netbsd.h
diff -u src/sys/dev/ic/mpt_netbsd.h:1.12 src/sys/dev/ic/mpt_netbsd.h:1.13
--- src/sys/dev/ic/mpt_netbsd.h:1.12	Tue Jan 30 19:13:08 2018
+++ src/sys/dev/ic/mpt_netbsd.h	Sat Sep 21 07:08:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpt_netbsd.h,v 1.12 2018/01/30 19:13:08 jakllsch Exp $	*/
+/*	$NetBSD: mpt_netbsd.h,v 1.13 2019/09/21 07:08:27 maxv Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -253,7 +253,7 @@ typedef struct mpt_softc {
 void	mpt_scsipi_attach(mpt_softc_t *);
 int	mpt_dma_mem_alloc(mpt_softc_t *);
 int	mpt_intr(void *);
-void	mpt_prt(mpt_softc_t *, const char *, ...);
+void	mpt_prt(mpt_softc_t *, const char *, ...) __printflike(2, 3);
 
 #define	mpt_set_config_regs(mpt)\
 do {\



CVS commit: src/sys/dev/ic

2019-09-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 20 14:20:45 UTC 2019

Modified Files:
src/sys/dev/ic: isp_netbsd.c isp_netbsd.h

Log Message:
declare printflike functions and fix another printf format.
also change 0x%x -> %#x.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/ic/isp_netbsd.c
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/ic/isp_netbsd.h

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



CVS commit: src/sys/dev/ic

2019-09-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 20 14:20:45 UTC 2019

Modified Files:
src/sys/dev/ic: isp_netbsd.c isp_netbsd.h

Log Message:
declare printflike functions and fix another printf format.
also change 0x%x -> %#x.


To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/dev/ic/isp_netbsd.c
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/ic/isp_netbsd.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/dev/ic/isp_netbsd.c
diff -u src/sys/dev/ic/isp_netbsd.c:1.92 src/sys/dev/ic/isp_netbsd.c:1.93
--- src/sys/dev/ic/isp_netbsd.c:1.92	Fri Sep 20 05:07:35 2019
+++ src/sys/dev/ic/isp_netbsd.c	Fri Sep 20 10:20:45 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_netbsd.c,v 1.92 2019/09/20 09:07:35 maxv Exp $ */
+/* $NetBSD: isp_netbsd.c,v 1.93 2019/09/20 14:20:45 christos Exp $ */
 /*
  * Platform (NetBSD) dependent common attachment code for Qlogic adapters.
  */
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.92 2019/09/20 09:07:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.93 2019/09/20 14:20:45 christos Exp $");
 
 #include 
 #include 
@@ -79,7 +79,7 @@ static const char *roles[4] = {
 "(none)", "Target", "Initiator", "Target/Initiator"
 };
 static const char prom3[] =
-"PortID 0x%06x Departed from Target %u because of %s";
+"PortID %#06x Departed from Target %u because of %s";
 int isp_change_is_bad = 0;	/* "changed" devices are bad */
 int isp_quickboot_time = 15;	/* don't wait more than N secs for loop up */
 static int isp_fabric_hysteresis = 5;
@@ -730,7 +730,7 @@ isprequest(struct scsipi_channel *chan, 
 		sdp->update = 1;
 		ISP_UNLOCK(isp);
 		isp_prt(isp, ISP_LOGDEBUG1,
-		"isprequest: device flags 0x%x for %d.%d.X",
+		"isprequest: device flags %#x for %d.%d.X",
 		dflags, chan->chan_channel, xm->xm_target);
 		break;
 	}
@@ -809,7 +809,7 @@ isp_done(XS_T *xs)
 		}
 		if (xs->error == XS_DRIVER_STUFFUP) {
 			isp_prt(isp, ISP_LOGERR,
-			"BOTCHED cmd for %d.%d.%d cmd 0x%x datalen %ld",
+			"BOTCHED cmd for %d.%d.%d cmd %#x datalen %ld",
 			XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs),
 			XS_CDBP(xs)[0], (long) XS_XFRLEN(xs));
 		}
@@ -841,13 +841,13 @@ isp_dog(void *arg)
 
 		if (XS_CMD_DONE_P(xs)) {
 			isp_prt(isp, ISP_LOGDEBUG1,
-			"watchdog found done cmd (handle 0x%x)", handle);
+			"watchdog found done cmd (handle %#x)", handle);
 			goto out;
 		}
 
 		if (XS_CMD_WDOG_P(xs)) {
 			isp_prt(isp, ISP_LOGDEBUG1,
-			"recursive watchdog (handle 0x%x)", handle);
+			"recursive watchdog (handle %#x)", handle);
 			goto out;
 		}
 
@@ -859,12 +859,12 @@ isp_dog(void *arg)
 		}
 		if (XS_CMD_DONE_P(xs)) {
 			isp_prt(isp, ISP_LOGDEBUG1,
-			"watchdog cleanup for handle 0x%x", handle);
+			"watchdog cleanup for handle %#x", handle);
 			XS_CMD_C_WDOG(xs);
 			isp_done(xs);
 		} else if (XS_CMD_GRACE_P(xs)) {
 			isp_prt(isp, ISP_LOGDEBUG1,
-			"watchdog timeout for handle 0x%x", handle);
+			"watchdog timeout for handle %#x", handle);
 			/*
 			 * Make sure the command is *really* dead before we
 			 * release the handle (and DMA resources) for reuse.
@@ -1180,11 +1180,11 @@ isp_async(struct ispsoftc *isp, ispasync
 	int bus, tgt;
 	const char *msg = NULL;
 	static const char prom[] =
-	"PortID 0x%06x handle 0x%x role %s %s\n"
-	"  WWNN 0x%08x%08x WWPN 0x%08x%08x";
+	"PortID %#06x handle %#x role %s %s\n"
+	"  WWNN %#08x%08x WWPN %#08x%08x";
 	static const char prom2[] =
-	"PortID 0x%06x handle 0x%x role %s %s tgt %u\n"
-	"  WWNN 0x%08x%08x WWPN 0x%08x%08x";
+	"PortID %#06x handle %#x role %s %s tgt %u\n"
+	"  WWNN %#08x%08x WWPN %#08x%08x";
 	fcportdb_t *lp;
 	va_list ap;
 
@@ -1495,7 +1495,7 @@ isp_async(struct ispsoftc *isp, ispasync
 			bus = 0;
 		}
 isp_prt(isp, ISP_LOGERR,
-"Internal Firmware Error on bus %d @ RISC Address 0x%x",
+"Internal Firmware Error on bus %d @ RISC Address %#x",
 bus, mbox1);
 		if (IS_FC(isp)) {
 			if (isp->isp_osinfo.blocked == 0) {
@@ -1650,9 +1650,9 @@ isp_mbox_wait_complete(struct ispsoftc *
 		microtime();
 		timersub(, , );
 		isp_prt(isp, ISP_LOGWARN,
-		"%s Mailbox Command (0x%x) Timeout (%uus actual)",
+		"%s Mailbox Command (%#x) Timeout (%juus actual)",
 		isp->isp_osinfo.mbox_sleep_ok? "Interrupting" : "Polled",
-		isp->isp_lastmbxcmd, (elapsed.tv_sec * 100) +
+		isp->isp_lastmbxcmd, (intmax_t)(elapsed.tv_sec * 100) +
 		elapsed.tv_usec);
 		mbp->param[0] = MBOX_TIMEOUT;
 		isp->isp_osinfo.mboxcmd_done = 1;

Index: src/sys/dev/ic/isp_netbsd.h
diff -u src/sys/dev/ic/isp_netbsd.h:1.75 src/sys/dev/ic/isp_netbsd.h:1.76
--- src/sys/dev/ic/isp_netbsd.h:1.75	Fri Aug 28 09:03:36 2015
+++ src/sys/dev/ic/isp_netbsd.h	Fri Sep 20 10:20:45 2019
@@ -1,4 +1,4 @@
-/* 

CVS commit: src/sys/dev/ic

2019-09-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Sep 20 11:29:47 UTC 2019

Modified Files:
src/sys/dev/ic: an.c

Log Message:
Don't use the same iterator in a nested loop. (How could this work?)

Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/ic/an.c

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



CVS commit: src/sys/dev/ic

2019-09-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Sep 20 11:29:47 UTC 2019

Modified Files:
src/sys/dev/ic: an.c

Log Message:
Don't use the same iterator in a nested loop. (How could this work?)

Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/ic/an.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/dev/ic/an.c
diff -u src/sys/dev/ic/an.c:1.70 src/sys/dev/ic/an.c:1.71
--- src/sys/dev/ic/an.c:1.70	Tue Feb  5 06:17:02 2019
+++ src/sys/dev/ic/an.c	Fri Sep 20 11:29:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: an.c,v 1.70 2019/02/05 06:17:02 msaitoh Exp $	*/
+/*	$NetBSD: an.c,v 1.71 2019/09/20 11:29:47 maxv Exp $	*/
 /*
  * Copyright (c) 1997, 1998, 1999
  *	Bill Paul .  All rights reserved.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.70 2019/02/05 06:17:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.71 2019/09/20 11:29:47 maxv Exp $");
 
 
 #include 
@@ -1240,8 +1240,9 @@ an_set_nwkey_eap(struct an_softc *sc, st
 			 */
 			memset(unibuf, 0, sizeof(unibuf));
 			/* XXX: convert password to unicode */
-			for (i = 0; i < len; i++)
-unibuf[i] = key->an_key[i];
+			int j;
+			for (j = 0; j < len; j++)
+unibuf[j] = key->an_key[j];
 			/* set PasswordHash */
 			MD4Init();
 			MD4Update(, (u_int8_t *)unibuf, len * 2);



CVS commit: src/sys/dev/ic

2019-09-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Sep 20 09:07:35 UTC 2019

Modified Files:
src/sys/dev/ic: isp_netbsd.c

Log Message:
Fix argument.

Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/ic/isp_netbsd.c

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



CVS commit: src/sys/dev/ic

2019-09-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Sep 20 09:07:35 UTC 2019

Modified Files:
src/sys/dev/ic: isp_netbsd.c

Log Message:
Fix argument.

Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/ic/isp_netbsd.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/dev/ic/isp_netbsd.c
diff -u src/sys/dev/ic/isp_netbsd.c:1.91 src/sys/dev/ic/isp_netbsd.c:1.92
--- src/sys/dev/ic/isp_netbsd.c:1.91	Sun Feb  3 03:19:27 2019
+++ src/sys/dev/ic/isp_netbsd.c	Fri Sep 20 09:07:35 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_netbsd.c,v 1.91 2019/02/03 03:19:27 mrg Exp $ */
+/* $NetBSD: isp_netbsd.c,v 1.92 2019/09/20 09:07:35 maxv Exp $ */
 /*
  * Platform (NetBSD) dependent common attachment code for Qlogic adapters.
  */
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.91 2019/02/03 03:19:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.92 2019/09/20 09:07:35 maxv Exp $");
 
 #include 
 #include 
@@ -609,7 +609,7 @@ ispcmd(struct ispsoftc *isp, XS_T *xs)
 	}
 	if (isp->isp_osinfo.blocked) {
 		isp_prt(isp, ISP_LOGWARN,
-		"I/O while blocked with retries %d", xs, xs->xs_retries);
+		"I/O while blocked with retries %d", xs->xs_retries);
 		if (xs->xs_retries) {
 			xs->error = XS_REQUEUE;
 			xs->xs_retries--;



CVS commit: src/sys/dev/ic

2019-09-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Sep 20 09:00:50 UTC 2019

Modified Files:
src/sys/dev/ic: i82557.c

Log Message:
Fix direction of the loop.

Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/dev/ic/i82557.c

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



CVS commit: src/sys/dev/ic

2019-09-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Sep 20 09:00:50 UTC 2019

Modified Files:
src/sys/dev/ic: i82557.c

Log Message:
Fix direction of the loop.

Found by the lgtm bot.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/dev/ic/i82557.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/dev/ic/i82557.c
diff -u src/sys/dev/ic/i82557.c:1.154 src/sys/dev/ic/i82557.c:1.155
--- src/sys/dev/ic/i82557.c:1.154	Tue Jul  9 08:46:58 2019
+++ src/sys/dev/ic/i82557.c	Fri Sep 20 09:00:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82557.c,v 1.154 2019/07/09 08:46:58 msaitoh Exp $	*/
+/*	$NetBSD: i82557.c,v 1.155 2019/09/20 09:00:50 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.154 2019/07/09 08:46:58 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.155 2019/09/20 09:00:50 maxv Exp $");
 
 #include 
 #include 
@@ -1892,7 +1892,7 @@ fxp_init(struct ifnet *ifp)
 	CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->sc_cddma + FXP_CDIASOFF);
 	fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_START);
 	/* ...and wait for it to complete. */
-	for (i = 1000; i > 0; i++) {
+	for (i = 1000; i > 0; i--) {
 		FXP_CDIASSYNC(sc,
 		BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 		status = le16toh(cb_ias->cb_status);



CVS commit: src/sys/dev/ic

2019-09-19 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Sep 20 05:32:42 UTC 2019

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
Don't set Phase Tag bit of Completion Queue entry at nvme_poll_done().

A new completion queue entry check incorrectly determined that there was
a Completion Queue entry for a command that was not submitted.

Fix PR kern/54275, PR kern/54503, PR kern/54532.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/ic/nvme.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/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44 src/sys/dev/ic/nvme.c:1.45
--- src/sys/dev/ic/nvme.c:1.44	Fri Jun 28 15:08:47 2019
+++ src/sys/dev/ic/nvme.c	Fri Sep 20 05:32:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44 2019/06/28 15:08:47 jmcneill Exp $	*/
+/*	$NetBSD: nvme.c,v 1.45 2019/09/20 05:32:42 nonaka Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44 2019/06/28 15:08:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.45 2019/09/20 05:32:42 nonaka Exp $");
 
 #include 
 #include 
@@ -1302,8 +1302,8 @@ nvme_poll_done(struct nvme_queue *q, str
 {
 	struct nvme_poll_state *state = ccb->ccb_cookie;
 
-	SET(cqe->flags, htole16(NVME_CQE_PHASE));
 	state->c = *cqe;
+	SET(state->c.flags, htole16(NVME_CQE_PHASE));
 
 	ccb->ccb_cookie = state->cookie;
 	state->done(q, ccb, >c);



CVS commit: src/sys/dev/ic

2019-09-19 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Sep 20 05:32:42 UTC 2019

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
Don't set Phase Tag bit of Completion Queue entry at nvme_poll_done().

A new completion queue entry check incorrectly determined that there was
a Completion Queue entry for a command that was not submitted.

Fix PR kern/54275, PR kern/54503, PR kern/54532.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/dev/ic/nvme.c

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



CVS commit: src/sys/dev/ic

2019-09-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep  3 14:26:55 UTC 2019

Modified Files:
src/sys/dev/ic: rt2860.c

Log Message:
 Use unsigned to avoid undefined behavior. Found by kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/ic/rt2860.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/dev/ic/rt2860.c
diff -u src/sys/dev/ic/rt2860.c:1.33 src/sys/dev/ic/rt2860.c:1.34
--- src/sys/dev/ic/rt2860.c:1.33	Mon Sep  3 16:29:31 2018
+++ src/sys/dev/ic/rt2860.c	Tue Sep  3 14:26:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rt2860.c,v 1.33 2018/09/03 16:29:31 riastradh Exp $	*/
+/*	$NetBSD: rt2860.c,v 1.34 2019/09/03 14:26:55 msaitoh Exp $	*/
 /*	$OpenBSD: rt2860.c,v 1.90 2016/04/13 10:49:26 mpi Exp $	*/
 /*	$FreeBSD: head/sys/dev/ral/rt2860.c 306591 2016-10-02 20:35:55Z avos $ */
 
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.33 2018/09/03 16:29:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.34 2019/09/03 14:26:55 msaitoh Exp $");
 
 #include 
 #include 
@@ -2233,7 +2233,7 @@ static void
 rt2860_enable_mrr(struct rt2860_softc *sc)
 {
 #define CCK(mcs)	(mcs)
-#define OFDM(mcs)	(1 << 3 | (mcs))
+#define OFDM(mcs)	(1U << 3 | (mcs))
 	RAL_WRITE(sc, RT2860_LG_FBK_CFG0,
 	OFDM(6) << 28 |	/* 54->48 */
 	OFDM(5) << 24 |	/* 48->36 */
@@ -3294,7 +3294,7 @@ b4inc(uint32_t b32, int8_t delta)
 			b4 = 0;
 		else if (b4 > 0xf)
 			b4 = 0xf;
-		b32 = b32 >> 4 | b4 << 28;
+		b32 = b32 >> 4 | (uint32_t)b4 << 28;
 	}
 	return b32;
 }



CVS commit: src/sys/dev/ic

2019-09-03 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Sep  3 14:26:55 UTC 2019

Modified Files:
src/sys/dev/ic: rt2860.c

Log Message:
 Use unsigned to avoid undefined behavior. Found by kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/ic/rt2860.c

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



CVS commit: src/sys/dev/ic

2019-09-02 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Sep  2 07:25:48 UTC 2019

Modified Files:
src/sys/dev/ic: bwfm.c

Log Message:
tagging work queue as MPSAFE was premature. Revert.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/bwfm.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/dev/ic/bwfm.c
diff -u src/sys/dev/ic/bwfm.c:1.15 src/sys/dev/ic/bwfm.c:1.16
--- src/sys/dev/ic/bwfm.c:1.15	Sun Sep  1 05:40:39 2019
+++ src/sys/dev/ic/bwfm.c	Mon Sep  2 07:25:48 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.15 2019/09/01 05:40:39 mlelstv Exp $ */
+/* $NetBSD: bwfm.c,v 1.16 2019/09/02 07:25:48 mlelstv Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -143,7 +143,7 @@ bwfm_attach(struct bwfm_softc *sc)
 	int i, j, error;
 
 	error = workqueue_create(>sc_taskq, DEVNAME(sc),
-	bwfm_task, sc, PRI_NONE, IPL_NET, WQ_MPSAFE);
+	bwfm_task, sc, PRI_NONE, IPL_NET, 0);
 	if (error != 0) {
 		printf("%s: could not create workqueue\n", DEVNAME(sc));
 		return;



CVS commit: src/sys/dev/ic

2019-09-02 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Sep  2 07:25:48 UTC 2019

Modified Files:
src/sys/dev/ic: bwfm.c

Log Message:
tagging work queue as MPSAFE was premature. Revert.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/bwfm.c

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



CVS commit: src/sys/dev/ic

2019-09-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 14:44:14 UTC 2019

Added Files:
src/sys/dev/ic: rng200.c rng200reg.h rng200var.h

Log Message:
Driver for Broadcom RNG200 hardware random generator


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/rng200.c src/sys/dev/ic/rng200reg.h \
src/sys/dev/ic/rng200var.h

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

Added files:

Index: src/sys/dev/ic/rng200.c
diff -u /dev/null src/sys/dev/ic/rng200.c:1.1
--- /dev/null	Sun Sep  1 14:44:14 2019
+++ src/sys/dev/ic/rng200.c	Sun Sep  1 14:44:14 2019
@@ -0,0 +1,125 @@
+/*	$NetBSD: rng200.c,v 1.1 2019/09/01 14:44:14 mlelstv Exp $	*/
+
+/*
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Michael van Elst
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Driver for the Broadcom iProc RNG200
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define READ4(sc, r) \
+	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (r))
+
+#define WRITE4(sc, r, v) \
+	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (r), (v))
+
+static void
+rng200_reset(struct rng200_softc *sc)
+{
+	uint32_t ctl, rng, rbg;
+
+	/* Disable RBG */
+	ctl = READ4(sc, RNG200_CONTROL);
+	ctl &= ~RNG200_RBG_MASK;
+	WRITE4(sc, RNG200_CONTROL, ctl);
+
+	/* Clear interrupts */
+	WRITE4(sc, RNG200_STATUS, 0x);
+
+	/* Reset RNG and RBG */
+	rbg = READ4(sc, RNG200_RBG_RESET);
+	rng = READ4(sc, RNG200_RNG_RESET);
+	WRITE4(sc, RNG200_RBG_RESET, rbg | RBG_RESET);
+	WRITE4(sc, RNG200_RNG_RESET, rng | RNG_RESET);
+	WRITE4(sc, RNG200_RNG_RESET, rng);
+	WRITE4(sc, RNG200_RBG_RESET, rbg);
+
+	/* Enable RBG */
+	WRITE4(sc, RNG200_CONTROL, ctl | RNG200_RBG_ENABLE);
+}
+
+static void
+rng200_get(size_t bytes_wanted, void *priv)
+{
+	struct rng200_softc * const sc = priv;
+	uint32_t w, data;
+	unsigned count;
+
+	mutex_spin_enter(>sc_lock);
+	while (bytes_wanted) {
+
+		w = READ4(sc, RNG200_STATUS);
+		if ((w & (RNG200_MASTER_FAIL | RNG200_NIST_FAIL)) != 0)
+			rng200_reset(sc);
+
+		w = READ4(sc, RNG200_COUNT);
+		count = __SHIFTOUT(w, RNG200_COUNT_MASK);
+
+		if (count == 0)
+			break;
+
+		data = READ4(sc, RNG200_DATA);
+		rnd_add_data_sync(>sc_rndsource, ,
+		sizeof(data), sizeof(data) * NBBY);
+		bytes_wanted -= MIN(bytes_wanted, sizeof(data));
+	}
+	explicit_memset(, 0, sizeof(data));
+	mutex_spin_exit(>sc_lock);
+}
+
+void
+rng200_attach(struct rng200_softc *sc)
+{
+
+	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM);
+
+	rndsource_setcb(>sc_rndsource, rng200_get, sc);
+	rnd_attach_source(>sc_rndsource, sc->sc_name,
+		RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
+
+	rng200_get(RND_POOLBITS / NBBY, sc);
+}
+
+void
+rng200_detach(struct rng200_softc *sc)
+{
+
+	rnd_detach_source(>sc_rndsource);
+	mutex_destroy(>sc_lock);
+}
+
Index: src/sys/dev/ic/rng200reg.h
diff -u /dev/null src/sys/dev/ic/rng200reg.h:1.1
--- /dev/null	Sun Sep  1 14:44:14 2019
+++ src/sys/dev/ic/rng200reg.h	Sun Sep  1 14:44:14 2019
@@ -0,0 +1,54 @@
+/*	$NetBSD: rng200reg.h,v 1.1 2019/09/01 14:44:14 mlelstv Exp $	*/
+
+/*
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Michael van Elst
+ *
+ * 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 

CVS commit: src/sys/dev/ic

2019-09-01 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Sep  1 14:44:14 UTC 2019

Added Files:
src/sys/dev/ic: rng200.c rng200reg.h rng200var.h

Log Message:
Driver for Broadcom RNG200 hardware random generator


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/rng200.c src/sys/dev/ic/rng200reg.h \
src/sys/dev/ic/rng200var.h

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



  1   2   3   >