CVS commit: src/sys/dev/ata

2023-07-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 17 21:12:19 UTC 2023

Modified Files:
src/sys/dev/ata: files.ata

Log Message:
ata(4): Add ATA_DOWNGRADE_MODE to opt_ata.h.

This way adding it to kernel config will trigger recompilation.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/ata/files.ata

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/ata/files.ata
diff -u src/sys/dev/ata/files.ata:1.30 src/sys/dev/ata/files.ata:1.31
--- src/sys/dev/ata/files.ata:1.30	Wed Oct 24 07:42:12 2018
+++ src/sys/dev/ata/files.ata	Mon Jul 17 21:12:19 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ata,v 1.30 2018/10/24 07:42:12 jdolecek Exp $
+#	$NetBSD: files.ata,v 1.31 2023/07/17 21:12:19 riastradh Exp $
 #
 # Config file and device description for machine-independent devices
 # which attach to ATA busses.  Included by ports that need it.  Ports
@@ -14,6 +14,8 @@ file	dev/ata/ata_wdc.c		wd & atabus & wd
 defflag	opt_wd.h	WD_SOFTBADSECT
 defflag	opt_wd.h	WD_CHAOS_MONKEY
 
+defflag	opt_ata.h	ATA_DOWNGRADE_MODE
+
 file	dev/ata/ata.c			(ata_hl | atapi) & atabus
 file	dev/ata/ata_subr.c		(ata_hl | atapi) & atabus
 file	dev/ata/ata_recovery.c		(ata_hl | atapi) & atabus



CVS commit: src/sys/dev/ata

2023-07-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul 17 21:12:19 UTC 2023

Modified Files:
src/sys/dev/ata: files.ata

Log Message:
ata(4): Add ATA_DOWNGRADE_MODE to opt_ata.h.

This way adding it to kernel config will trigger recompilation.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/ata/files.ata

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



CVS commit: src/sys/dev/ata

2023-01-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Jan 24 08:34:18 UTC 2023

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Sanitize capacity values.


To generate a diff of this commit:
cvs rdiff -u -r1.467 -r1.468 src/sys/dev/ata/wd.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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.467 src/sys/dev/ata/wd.c:1.468
--- src/sys/dev/ata/wd.c:1.467	Mon Mar 28 12:39:37 2022
+++ src/sys/dev/ata/wd.c	Tue Jan 24 08:34:18 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.467 2022/03/28 12:39:37 riastradh Exp $ */
+/*	$NetBSD: wd.c,v 1.468 2023/01/24 08:34:18 mlelstv Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.467 2022/03/28 12:39:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.468 2023/01/24 08:34:18 mlelstv Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -412,17 +412,37 @@ wdattach(device_t parent, device_t self,
 		wd->sc_capacity28 =
 		(wd->sc_params.atap_capacity[1] << 16) |
 		wd->sc_params.atap_capacity[0];
+		/*
+		 * Force LBA48 addressing for invalid numbers.
+		 */
+		if (wd->sc_capacity28 > 0xfff)
+			wd->sc_capacity28 = 0xfff;
 	} else if ((wd->sc_flags & WDF_LBA) != 0) {
 		aprint_verbose(" LBA addressing\n");
-		wd->sc_capacity28 = wd->sc_capacity =
+		wd->sc_capacity28 =
 		(wd->sc_params.atap_capacity[1] << 16) |
 		wd->sc_params.atap_capacity[0];
+		/*
+		 * Limit capacity to LBA28 numbers to avoid overflow.
+		 */
+		if (wd->sc_capacity28 > 0xfff)
+			wd->sc_capacity28 = 0xfff;
+		wd->sc_capacity = wd->sc_capacity28;
 	} else {
 		aprint_verbose(" chs addressing\n");
-		wd->sc_capacity28 = wd->sc_capacity =
+		wd->sc_capacity =
 		wd->sc_params.atap_cylinders *
 		wd->sc_params.atap_heads *
 		wd->sc_params.atap_sectors;
+		/*
+		 * LBA28 size is ignored for CHS addressing. Use a reasonable
+		 * value for debugging. The CHS values may be artifical and
+		 * are mostly ignored.
+		 */
+		if (wd->sc_capacity < 0xfff)
+			wd->sc_capacity28 = wd->sc_capacity;
+		else
+			wd->sc_capacity28 = 0xfff;
 	}
 	if ((wd->sc_params.atap_secsz & ATA_SECSZ_VALID_MASK) == ATA_SECSZ_VALID
 	&& ((wd->sc_params.atap_secsz & ATA_SECSZ_LLS) != 0)) {



CVS commit: src/sys/dev/ata

2023-01-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Jan 24 08:34:18 UTC 2023

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Sanitize capacity values.


To generate a diff of this commit:
cvs rdiff -u -r1.467 -r1.468 src/sys/dev/ata/wd.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/ata

2022-03-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 28 12:39:37 UTC 2022

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
wd(4): Use d_cfdriver/devtounit to avoid open/detach races.


To generate a diff of this commit:
cvs rdiff -u -r1.466 -r1.467 src/sys/dev/ata/wd.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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.466 src/sys/dev/ata/wd.c:1.467
--- src/sys/dev/ata/wd.c:1.466	Tue Dec 28 13:27:32 2021
+++ src/sys/dev/ata/wd.c	Mon Mar 28 12:39:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.466 2021/12/28 13:27:32 riastradh Exp $ */
+/*	$NetBSD: wd.c,v 1.467 2022/03/28 12:39:37 riastradh Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.466 2021/12/28 13:27:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.467 2022/03/28 12:39:37 riastradh Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -152,6 +152,8 @@ const struct bdevsw wd_bdevsw = {
 	.d_dump = wddump,
 	.d_psize = wdsize,
 	.d_discard = wddiscard,
+	.d_cfdriver = _cd,
+	.d_devtounit = disklabel_dev_unit,
 	.d_flag = D_DISK
 };
 
@@ -167,6 +169,8 @@ const struct cdevsw wd_cdevsw = {
 	.d_mmap = nommap,
 	.d_kqfilter = nokqfilter,
 	.d_discard = wddiscard,
+	.d_cfdriver = _cd,
+	.d_devtounit = disklabel_dev_unit,
 	.d_flag = D_DISK
 };
 



CVS commit: src/sys/dev/ata

2022-03-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 28 12:39:37 UTC 2022

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
wd(4): Use d_cfdriver/devtounit to avoid open/detach races.


To generate a diff of this commit:
cvs rdiff -u -r1.466 -r1.467 src/sys/dev/ata/wd.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/ata

2022-03-19 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Mar 19 13:51:01 UTC 2022

Modified Files:
src/sys/dev/ata: ata_raid_adaptec.c ata_raid_intel.c ata_raid_jmicron.c
ata_raid_nvidia.c ata_raid_promise.c ata_raid_subr.c ata_raid_via.c

Log Message:
Lock vnode across VOP_OPEN.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ata/ata_raid_adaptec.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ata/ata_raid_intel.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ata/ata_raid_jmicron.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ata/ata_raid_nvidia.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ata/ata_raid_promise.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ata/ata_raid_subr.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/ata_raid_via.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/ata/ata_raid_adaptec.c
diff -u src/sys/dev/ata/ata_raid_adaptec.c:1.11 src/sys/dev/ata/ata_raid_adaptec.c:1.12
--- src/sys/dev/ata/ata_raid_adaptec.c:1.11	Mon Oct 22 19:38:06 2018
+++ src/sys/dev/ata/ata_raid_adaptec.c	Sat Mar 19 13:51:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid_adaptec.c,v 1.11 2018/10/22 19:38:06 jdolecek Exp $	*/
+/*	$NetBSD: ata_raid_adaptec.c,v 1.12 2022/03/19 13:51:01 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2000,2001,2002 Søren Schmidt 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.11 2018/10/22 19:38:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_adaptec.c,v 1.12 2022/03/19 13:51:01 hannken Exp $");
 
 #include 
 #include 
@@ -86,6 +86,7 @@ ata_raid_read_config_adaptec(struct wd_s
 	if (error)
 		goto out;
 
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	error = VOP_OPEN(vp, FREAD, NOCRED);
 	if (error) {
 		vput(vp);

Index: src/sys/dev/ata/ata_raid_intel.c
diff -u src/sys/dev/ata/ata_raid_intel.c:1.10 src/sys/dev/ata/ata_raid_intel.c:1.11
--- src/sys/dev/ata/ata_raid_intel.c:1.10	Fri Oct  4 12:24:32 2019
+++ src/sys/dev/ata/ata_raid_intel.c	Sat Mar 19 13:51:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid_intel.c,v 1.10 2019/10/04 12:24:32 mrg Exp $	*/
+/*	$NetBSD: ata_raid_intel.c,v 1.11 2022/03/19 13:51:01 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2000-2008 Søren Schmidt 
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.10 2019/10/04 12:24:32 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.11 2022/03/19 13:51:01 hannken Exp $");
 
 #include 
 #include 
@@ -158,6 +158,7 @@ ata_raid_read_config_intel(struct wd_sof
 	if (error)
 		goto out;
 
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	error = VOP_OPEN(vp, FREAD, NOCRED);
 	if (error) {
 		vput(vp);

Index: src/sys/dev/ata/ata_raid_jmicron.c
diff -u src/sys/dev/ata/ata_raid_jmicron.c:1.7 src/sys/dev/ata/ata_raid_jmicron.c:1.8
--- src/sys/dev/ata/ata_raid_jmicron.c:1.7	Mon Oct 22 19:38:06 2018
+++ src/sys/dev/ata/ata_raid_jmicron.c	Sat Mar 19 13:51:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid_jmicron.c,v 1.7 2018/10/22 19:38:06 jdolecek Exp $	*/
+/*	$NetBSD: ata_raid_jmicron.c,v 1.8 2022/03/19 13:51:01 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2000-2008 Søren Schmidt 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.7 2018/10/22 19:38:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.8 2022/03/19 13:51:01 hannken Exp $");
 
 #include 
 #include 
@@ -139,6 +139,7 @@ ata_raid_read_config_jmicron(struct wd_s
 	if (error)
 		goto out;
 
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	error = VOP_OPEN(vp, FREAD, NOCRED);
 	if (error) {
 		vput(vp);

Index: src/sys/dev/ata/ata_raid_nvidia.c
diff -u src/sys/dev/ata/ata_raid_nvidia.c:1.4 src/sys/dev/ata/ata_raid_nvidia.c:1.5
--- src/sys/dev/ata/ata_raid_nvidia.c:1.4	Mon Oct 22 19:38:06 2018
+++ src/sys/dev/ata/ata_raid_nvidia.c	Sat Mar 19 13:51:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid_nvidia.c,v 1.4 2018/10/22 19:38:06 jdolecek Exp $	*/
+/*	$NetBSD: ata_raid_nvidia.c,v 1.5 2022/03/19 13:51:01 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2000 - 2008 Søren Schmidt 
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.4 2018/10/22 19:38:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.5 2022/03/19 13:51:01 hannken Exp $");
 
 #include 
 #include 
@@ -145,6 +145,7 @@ ata_raid_read_config_nvidia(struct wd_so
 	if (error)
 		goto out;
 
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	error = VOP_OPEN(vp, FREAD, NOCRED);
 	if (error) {
 		vput(vp);

Index: src/sys/dev/ata/ata_raid_promise.c
diff -u src/sys/dev/ata/ata_raid_promise.c:1.13 src/sys/dev/ata/ata_raid_promise.c:1.14
--- src/sys/dev/ata/ata_raid_promise.c:1.13	Mon Oct 22 19:38:06 2018
+++ src/sys/dev/ata/ata_raid_promise.c	Sat Mar 19 13:51:01 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid_promise.c,v 1.13 2018/10/22 19:38:06 jdolecek Exp $	*/
+/*	$NetBSD: ata_raid_promise.c,v 1.14 2022/03/19 13:51:01 hannken Exp $	*/
 
 /*-
  * Copyright (c) 

CVS commit: src/sys/dev/ata

2022-03-19 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Mar 19 13:51:01 UTC 2022

Modified Files:
src/sys/dev/ata: ata_raid_adaptec.c ata_raid_intel.c ata_raid_jmicron.c
ata_raid_nvidia.c ata_raid_promise.c ata_raid_subr.c ata_raid_via.c

Log Message:
Lock vnode across VOP_OPEN.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ata/ata_raid_adaptec.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ata/ata_raid_intel.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ata/ata_raid_jmicron.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ata/ata_raid_nvidia.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ata/ata_raid_promise.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ata/ata_raid_subr.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/ata_raid_via.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/ata

2022-03-14 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Mar 14 22:15:51 UTC 2022

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Avoid an unaccounted extra channel freeze, if a reset is requested
more than once before the thread services the request.  Closes PR#56745.


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/dev/ata/ata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.166 src/sys/dev/ata/ata.c:1.167
--- src/sys/dev/ata/ata.c:1.166	Wed Feb 23 21:54:40 2022
+++ src/sys/dev/ata/ata.c	Mon Mar 14 22:15:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.166 2022/02/23 21:54:40 andvar Exp $	*/
+/*	$NetBSD: ata.c,v 1.167 2022/03/14 22:15:51 perseant Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.166 2022/02/23 21:54:40 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.167 2022/03/14 22:15:51 perseant Exp $");
 
 #include "opt_ata.h"
 
@@ -1600,12 +1600,14 @@ ata_thread_run(struct ata_channel *chp, 
 			/* NOTREACHED */
 		}
 
-		/*
-		 * Block execution of other commands while reset is scheduled
-		 * to a thread.
-		 */
-		ata_channel_freeze_locked(chp);
-		chp->ch_flags |= type;
+		if (!(chp->ch_flags & type)) {
+			/*
+			 * Block execution of other commands while
+			 * reset is scheduled to a thread.
+			 */
+			ata_channel_freeze_locked(chp);
+			chp->ch_flags |= type;
+		}
 
 		cv_signal(>ch_thr_idle);
 		return;



CVS commit: src/sys/dev/ata

2022-03-14 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Mon Mar 14 22:15:51 UTC 2022

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Avoid an unaccounted extra channel freeze, if a reset is requested
more than once before the thread services the request.  Closes PR#56745.


To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/sys/dev/ata/ata.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/ata

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 13:27:32 UTC 2021

Modified Files:
src/sys/dev/ata: wd.c wdvar.h

Log Message:
wd(4): Fix bugs in softbadsect handling.

- Don't copyout kernel virtual addresses (of SLIST entries) that
  userland won't use anyway.
  => The structure still has space for this pointer; it's just always
 null when userland gets it now.

- Don't copyout under a lock.

- Stop and return error if copyout fails (unless we've already copied
  some out).

- Don't kmem_free under a lock.

XXX Unclear whether anyone actually uses WD_SOFTBADSECT or why --
it's always been disabled by default.  Maybe we should just remove
it?


To generate a diff of this commit:
cvs rdiff -u -r1.465 -r1.466 src/sys/dev/ata/wd.c
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/ata/wdvar.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/ata

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 13:27:32 UTC 2021

Modified Files:
src/sys/dev/ata: wd.c wdvar.h

Log Message:
wd(4): Fix bugs in softbadsect handling.

- Don't copyout kernel virtual addresses (of SLIST entries) that
  userland won't use anyway.
  => The structure still has space for this pointer; it's just always
 null when userland gets it now.

- Don't copyout under a lock.

- Stop and return error if copyout fails (unless we've already copied
  some out).

- Don't kmem_free under a lock.

XXX Unclear whether anyone actually uses WD_SOFTBADSECT or why --
it's always been disabled by default.  Maybe we should just remove
it?


To generate a diff of this commit:
cvs rdiff -u -r1.465 -r1.466 src/sys/dev/ata/wd.c
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/ata/wdvar.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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.465 src/sys/dev/ata/wd.c:1.466
--- src/sys/dev/ata/wd.c:1.465	Mon Sep 28 12:47:49 2020
+++ src/sys/dev/ata/wd.c	Tue Dec 28 13:27:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.465 2020/09/28 12:47:49 jakllsch Exp $ */
+/*	$NetBSD: wd.c,v 1.466 2021/12/28 13:27:32 riastradh Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.465 2020/09/28 12:47:49 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.466 2021/12/28 13:27:32 riastradh Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -316,6 +316,7 @@ wdattach(device_t parent, device_t self,
 	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_BIO);
 #ifdef WD_SOFTBADSECT
 	SLIST_INIT(>sc_bslist);
+	cv_init(>sc_bslist_cv, "wdbadsect");
 #endif
 	wd->atabus = adev->adev_bustype;
 	wd->inflight = 0;
@@ -587,6 +588,11 @@ wddetach(device_t self, int flags)
 
 	wd_sysctl_detach(wd);
 
+#ifdef WD_SOFTBADSECT
+	KASSERT(SLIST_EMPTY(>sc_bslist));
+	cv_destroy(>sc_bslist_cv);
+#endif
+
 	mutex_destroy(>sc_lock);
 
 	wd->drvp->drive_type = ATA_DRIVET_NONE; /* no drive any more here */
@@ -1279,13 +1285,13 @@ wdioctl(dev_t dev, u_long cmd, void *add
 		return 0;
 #endif
 #ifdef WD_SOFTBADSECT
-	case DIOCBSLIST :
-	{
+	case DIOCBSLIST: {
 		uint32_t count, missing, skip;
 		struct disk_badsecinfo dbsi;
-		struct disk_badsectors *dbs;
+		struct disk_badsectors *dbs, dbsbuf;
 		size_t available;
 		uint8_t *laddr;
+		int error;
 
 		dbsi = *(struct disk_badsecinfo *)addr;
 		missing = wd->sc_bscount;
@@ -1303,7 +1309,9 @@ wdioctl(dev_t dev, u_long cmd, void *add
 		 * back to user space whilst the summary is returned via
 		 * the struct passed in via the ioctl.
 		 */
+		error = 0;
 		mutex_enter(>sc_lock);
+		wd->sc_bslist_inuse++;
 		SLIST_FOREACH(dbs, >sc_bslist, dbs_next) {
 			if (skip > 0) {
 missing--;
@@ -1313,30 +1321,57 @@ wdioctl(dev_t dev, u_long cmd, void *add
 			if (available < sizeof(*dbs))
 break;
 			available -= sizeof(*dbs);
-			copyout(dbs, laddr, sizeof(*dbs));
+			memset(, 0, sizeof(dbsbuf));
+			dbsbuf.dbs_min = dbs->dbs_min;
+			dbsbuf.dbs_max = dbs->dbs_max;
+			dbsbuf.dbs_failedat = dbs->dbs_failedat;
+			mutex_exit(>sc_lock);
+			error = copyout(, laddr, sizeof(dbsbuf));
+			mutex_enter(>sc_lock);
+			if (error)
+break;
 			laddr += sizeof(*dbs);
 			missing--;
 			count++;
 		}
+		if (--wd->sc_bslist_inuse == 0)
+			cv_broadcast(>sc_bslist_cv);
 		mutex_exit(>sc_lock);
 		dbsi.dbsi_left = missing;
 		dbsi.dbsi_copied = count;
 		*(struct disk_badsecinfo *)addr = dbsi;
-		return 0;
+
+		/*
+		 * If we copied anything out, ignore error and return
+		 * success -- can't back it out.
+		 */
+		return count ? 0 : error;
 	}
 
-	case DIOCBSFLUSH :
+	case DIOCBSFLUSH: {
+		int error;
+
 		/* Clean out the bad sector list */
 		mutex_enter(>sc_lock);
+		while (wd->sc_bslist_inuse) {
+			error = cv_wait_sig(>sc_bslist_cv, >sc_lock);
+			if (error) {
+mutex_exit(>sc_lock);
+return error;
+			}
+		}
 		while (!SLIST_EMPTY(>sc_bslist)) {
 			struct disk_badsectors *dbs =
 			SLIST_FIRST(>sc_bslist);
 			SLIST_REMOVE_HEAD(>sc_bslist, dbs_next);
+			mutex_exit(>sc_lock);
 			kmem_free(dbs, sizeof(*dbs));
+			mutex_enter(>sc_lock);
 		}
 		mutex_exit(>sc_lock);
 		wd->sc_bscount = 0;
 		return 0;
+	}
 #endif
 
 #ifdef notyet

Index: src/sys/dev/ata/wdvar.h
diff -u src/sys/dev/ata/wdvar.h:1.50 src/sys/dev/ata/wdvar.h:1.51
--- src/sys/dev/ata/wdvar.h:1.50	Mon Mar  2 16:01:56 2020
+++ src/sys/dev/ata/wdvar.h	Tue Dec 28 13:27:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdvar.h,v 1.50 2020/03/02 16:01:56 riastradh Exp $	*/
+/*	$NetBSD: wdvar.h,v 1.51 2021/12/28 13:27:32 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -31,8 +31,20 @@
 #include "opt_wd.h"
 #endif
 
-#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
+
+#include 
+#include 
+#include 
+
+struct sysctllog;
 
 struct wd_softc {
 

CVS commit: src/sys/dev/ata

2021-11-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Nov 12 06:53:49 UTC 2021

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/dev/ata/ata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.164 src/sys/dev/ata/ata.c:1.165
--- src/sys/dev/ata/ata.c:1.164	Tue Oct  5 08:01:05 2021
+++ src/sys/dev/ata/ata.c	Fri Nov 12 06:53:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.164 2021/10/05 08:01:05 rin Exp $	*/
+/*	$NetBSD: ata.c,v 1.165 2021/11/12 06:53:49 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.164 2021/10/05 08:01:05 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.165 2021/11/12 06:53:49 skrll Exp $");
 
 #include "opt_ata.h"
 
@@ -94,7 +94,7 @@ static struct pool ata_xfer_pool;
 /*
  * A queue of atabus instances, used to ensure the same bus probe order
  * for a given hardware configuration at each boot.  Kthread probing
- * devices on a atabus.  Only one probing at once. 
+ * devices on a atabus.  Only one probing at once.
  */
 static TAILQ_HEAD(, atabus_initq)	atabus_initq_head;
 static kmutex_tatabus_qlock;
@@ -1330,7 +1330,7 @@ ata_free_xfer(struct ata_channel *chp, s
 
 	if (__predict_false(chp->ch_atac->atac_free_hw))
 		chp->ch_atac->atac_free_hw(chp);
- 
+
 	ata_channel_unlock(chp);
 
 	if (__predict_true(!ISSET(xfer->c_flags, C_PRIVATE_ALLOC)))
@@ -1420,7 +1420,7 @@ ata_timo_xfer_check(struct ata_xfer *xfe
 
 			device_printf(drvp->drv_softc,
 			"xfer %"PRIxPTR" freed while invoking timeout\n",
-			(intptr_t)xfer & PAGE_MASK); 
+			(intptr_t)xfer & PAGE_MASK);
 
 			ata_free_xfer(chp, xfer);
 			return true;
@@ -1431,7 +1431,7 @@ ata_timo_xfer_check(struct ata_xfer *xfe
 
 		device_printf(drvp->drv_softc,
 		"xfer %"PRIxPTR" deactivated while invoking timeout\n",
-		(intptr_t)xfer & PAGE_MASK); 
+		(intptr_t)xfer & PAGE_MASK);
 		return true;
 	}
 
@@ -1503,7 +1503,7 @@ ata_kill_pending(struct ata_drive_datas 
 break;
 			}
 		}
-		
+
 		if (!drv_active) {
 			/* all finished */
 			break;
@@ -1614,7 +1614,7 @@ ata_thread_run(struct ata_channel *chp, 
 	/* Block execution of other commands during reset */
 	ata_channel_freeze_locked(chp);
 
-	/* 
+	/*
 	 * If reset has been scheduled to a thread, then clear
 	 * the flag now so that the thread won't try to execute it if
 	 * we happen to sleep, and thaw one more time after the reset.
@@ -1761,7 +1761,7 @@ ata_print_modes(struct ata_channel *chp)
 			? " w/PRIO" : "");
 		} else if (drvp->drive_flags & ATA_DRIVE_WFUA)
 			aprint_verbose(", WRITE DMA FUA EXT");
-			
+
 #endif	/* NATA_DMA || NATA_PIOBM */
 		aprint_verbose("\n");
 	}
@@ -2278,7 +2278,7 @@ atabus_rescan(device_t self, const char 
 
 	/*
 	 * we can rescan a port multiplier atabus, even if some devices are
-	 * still attached 
+	 * still attached
 	 */
 	if (chp->ch_satapmp_nports == 0) {
 		if (chp->atapibus != NULL) {



CVS commit: src/sys/dev/ata

2021-11-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Nov 12 06:53:49 UTC 2021

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/dev/ata/ata.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/ata

2021-08-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Aug 29 23:49:32 UTC 2021

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Output missing '\n' for capability list when DMA support is not compiled in.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/sys/dev/ata/ata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.162 src/sys/dev/ata/ata.c:1.163
--- src/sys/dev/ata/ata.c:1.162	Sat Aug  7 16:19:09 2021
+++ src/sys/dev/ata/ata.c	Sun Aug 29 23:49:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.162 2021/08/07 16:19:09 thorpej Exp $	*/
+/*	$NetBSD: ata.c,v 1.163 2021/08/29 23:49:32 rin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.162 2021/08/07 16:19:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.163 2021/08/29 23:49:32 rin Exp $");
 
 #include "opt_ata.h"
 
@@ -2044,9 +2044,7 @@ ata_probe_caps(struct ata_drive_datas *d
 #if NATA_DMA
 	if ((atac->atac_cap & ATAC_CAP_DMA) == 0) {
 		/* don't care about DMA modes */
-		if (*sep != '\0')
-			aprint_verbose("\n");
-		return;
+		goto out;
 	}
 	if (cf_flags & ATA_CONFIG_DMA_SET) {
 		ata_channel_lock(chp);
@@ -2092,13 +2090,10 @@ ata_probe_caps(struct ata_drive_datas *d
 	}
 	ata_channel_unlock(chp);
 
-	if (*sep != '\0')
-		aprint_verbose("\n");
-
 #if NATA_UDMA
 	if ((atac->atac_cap & ATAC_CAP_UDMA) == 0) {
 		/* don't care about UDMA modes */
-		return;
+		goto out;
 	}
 	if (cf_flags & ATA_CONFIG_UDMA_SET) {
 		ata_channel_lock(chp);
@@ -2113,7 +2108,10 @@ ata_probe_caps(struct ata_drive_datas *d
 		ata_channel_unlock(chp);
 	}
 #endif	/* NATA_UDMA */
+out:
 #endif	/* NATA_DMA */
+	if (*sep != '\0')
+		aprint_verbose("\n");
 }
 
 /* management of the /dev/atabus* devices */



CVS commit: src/sys/dev/ata

2021-08-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Aug 29 23:49:32 UTC 2021

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Output missing '\n' for capability list when DMA support is not compiled in.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/sys/dev/ata/ata.c

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



Re: Freeze or panic during boot was: Re: CVS commit: src/sys/dev/ata

2020-05-02 Thread David Brownlee
On Sat, 2 May 2020, 20:10 Jason Thorpe,  wrote:

>
> > On May 1, 2020, at 1:07 PM, Ryo ONODERA  wrote:
> >
> > Hi,
> >
> > Have you missed this thread?
> >
> > If the problem requires more time to investigate,
> > could you consider to revert ata change for a while?
> >
> > Thank you.
>
> I backed it out, but would appreciate some help tracking down the issue
> because no other problems were reported other than on these specific
> machines.
>

The T480 is my main machine but I'm happy to boot any test kernels (to
confirm, - current as of the 30th with just that one commit reverted runs
fine)

Thanks

David

>


Re: Freeze or panic during boot was: Re: CVS commit: src/sys/dev/ata

2020-05-02 Thread Jason Thorpe


> On May 1, 2020, at 1:07 PM, Ryo ONODERA  wrote:
> 
> Hi,
> 
> Have you missed this thread?
> 
> If the problem requires more time to investigate,
> could you consider to revert ata change for a while?
> 
> Thank you.

I backed it out, but would appreciate some help tracking down the issue because 
no other problems were reported other than on these specific machines.

-- thorpej



Freeze or panic during boot was: Re: CVS commit: src/sys/dev/ata

2020-05-01 Thread Ryo ONODERA
Hi,

Have you missed this thread?

If the problem requires more time to investigate,
could you consider to revert ata change for a while?

Thank you.

Alexander Nasonov  writes:

> David Brownlee wrote:
>> Just another data point - seeing this same panic on a T480 with the
>> latest kernel from nyftp
>
> Same problem on T470.
>
> -- 
> Alex

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


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

2020-05-01 Thread David Brownlee
Plus to confirm reverting just this commit from today's github copy of
current (d5b32e03eac8b05d38a143ee0ec615efb2233201) boots fine on the
T480

Thanks

On Thu, 30 Apr 2020 at 00:12, Alexander Nasonov  wrote:
>
> David Brownlee wrote:
> > Just another data point - seeing this same panic on a T480 with the
> > latest kernel from nyftp
>
> Same problem on T470.
>
> --
> Alex


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

2020-04-29 Thread Alexander Nasonov
David Brownlee wrote:
> Just another data point - seeing this same panic on a T480 with the
> latest kernel from nyftp

Same problem on T470.

-- 
Alex


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

2020-04-29 Thread David Brownlee
Just another data point - seeing this same panic on a T480 with the
latest kernel from nyftp


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

2020-04-27 Thread Ryo ONODERA
Ryo ONODERA  writes:

> Hi,
>
> After this commit, NetBSD/amd64-current on my HP Spectre x360
> freezes after acpiacad0 detection (before ld0 detection).
> Reverting this commit in latest tree fixes my freeze problem.
>
> Could you take a look at my problem?
>
> Thank you.
>
> === === ===
> cpu7: CPU max freq 40 Hz
> cpu7: TSC freq 199200 Hz
> timecounter: Timecounter "TSC" frequency 199200 Hz quality 3000
> uhub0 at usb0: NetBSD (0x) xHCI root hub (0x), class 9/0, rev 
> 3.00/1.00,
>  addr 0
> uhub0: 6 ports with 6 removable, self powered
> uhub1 at usb1: NetBSD (0x) xHCI root hub (0x), class 9/0, rev 
> 2.00/1.00,
>  addr 0
> uhub1: 12 ports with 12 removable, self powered
> acpiacad0: AC adapter online.
>
> (With this commit, freeze here)
>
> ld0: GPT GUID: 3fda58df-424f-4b48-9fb9-b4c5c037379e
> dk0 at ld0: "EFI", 262144 blocks at 2048, type: ntfs
> dk1 at ld0: "ROOT", 66955885 blocks at 266240, type: ffs
> === === ===

With LOCKDEBUG option,
I have gotten the following panic messages:

panic: TAILQ_INSERT_TAIL 0xd305ab82ae0 
/usr/src/sys/dev/pckbport/pckbport.c:531
cpu0: Begin traceback...
vpanic() at netbsd:vpanic+0x178
snprintf() at netbsd:snprintf
pckbport_enqueue_cmd() at netbsd:pckbport_enqueue_cmd+0x3c0
pms_reset_thread() at netbsd:pms_reset_thread+0x94
cpu0: End traceback...

Thank you.

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


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

2020-04-27 Thread Ryo ONODERA
Hi,

After this commit, NetBSD/amd64-current on my HP Spectre x360
freezes after acpiacad0 detection (before ld0 detection).
Reverting this commit in latest tree fixes my freeze problem.

Could you take a look at my problem?

Thank you.

=== === ===
cpu7: CPU max freq 40 Hz
cpu7: TSC freq 199200 Hz
timecounter: Timecounter "TSC" frequency 199200 Hz quality 3000
uhub0 at usb0: NetBSD (0x) xHCI root hub (0x), class 9/0, rev 3.00/1.00,
 addr 0
uhub0: 6 ports with 6 removable, self powered
uhub1 at usb1: NetBSD (0x) xHCI root hub (0x), class 9/0, rev 2.00/1.00,
 addr 0
uhub1: 12 ports with 12 removable, self powered
acpiacad0: AC adapter online.

(With this commit, freeze here)

ld0: GPT GUID: 3fda58df-424f-4b48-9fb9-b4c5c037379e
dk0 at ld0: "EFI", 262144 blocks at 2048, type: ntfs
dk1 at ld0: "ROOT", 66955885 blocks at 266240, type: ffs
=== === ===

"Jason R Thorpe"  writes:

> Module Name:  src
> Committed By: thorpej
> Date: Sat Apr 25 00:07:27 UTC 2020
>
> Modified Files:
>   src/sys/dev/ata: ata.c ata_subr.c atavar.h
>
> Log Message:
> Rather than creating a kthread-per-channel, use a threadpool and a
> threadpool-job-per-channel for the in-thread-context work that needs
> to be done (which is rare).
>
> On one of my test systems, this results in the total number of LWPs
> after multi-user boot dropping from 116 to 78.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.155 -r1.156 src/sys/dev/ata/ata.c
> cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/ata_subr.c
> cvs rdiff -u -r1.105 -r1.106 src/sys/dev/ata/atavar.h
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>

-- 
Ryo ONODERA // r...@tetera.org
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3


CVS commit: src/sys/dev/ata

2019-10-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Oct 21 18:58:57 UTC 2019

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
chuq does not like insomniac allocations so unlock-alloc-lock instead.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/dev/ata/ata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.152 src/sys/dev/ata/ata.c:1.153
--- src/sys/dev/ata/ata.c:1.152	Mon Oct 21 14:37:47 2019
+++ src/sys/dev/ata/ata.c	Mon Oct 21 14:58:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.152 2019/10/21 18:37:47 christos Exp $	*/
+/*	$NetBSD: ata.c,v 1.153 2019/10/21 18:58:57 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.152 2019/10/21 18:37:47 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.153 2019/10/21 18:58:57 christos Exp $");
 
 #include "opt_ata.h"
 
@@ -749,10 +749,18 @@ atabus_alloc_drives(struct ata_channel *
 	if (chp->ch_ndrives != ndrives)
 		atabus_free_drives(chp);
 	if (chp->ch_drive == NULL) {
-		chp->ch_drive = kmem_zalloc(
-		sizeof(struct ata_drive_datas) * ndrives, KM_NOSLEEP);
-		if (chp->ch_drive == NULL)
-			return ENOMEM;
+		void *drv;
+
+		ata_channel_unlock(chp);
+		drv = kmem_zalloc(sizeof(*chp->ch_drive) * ndrives, KM_SLEEP);
+		ata_channel_lock(chp);
+
+		if (chp->ch_drive != NULL) {
+			/* lost the race */
+			kmem_free(drv, sizeof(*chp->ch_drive) * ndrives);
+			return 0;
+		}
+		chp->ch_drive = drv;
 	}
 	for (i = 0; i < ndrives; i++) {
 		chp->ch_drive[i].chnl_softc = chp;



CVS commit: src/sys/dev/ata

2019-10-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Oct 21 18:58:57 UTC 2019

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
chuq does not like insomniac allocations so unlock-alloc-lock instead.


To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/sys/dev/ata/ata.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/ata

2019-10-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Oct 21 18:37:47 UTC 2019

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Fix assert_sleepable() panic by allocating with NOSLEEP. The alternative is
to unlock and relock the channel, but seems more dangerous to do so.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/dev/ata/ata.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/ata

2019-10-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Oct 21 18:37:47 UTC 2019

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Fix assert_sleepable() panic by allocating with NOSLEEP. The alternative is
to unlock and relock the channel, but seems more dangerous to do so.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/sys/dev/ata/ata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.151 src/sys/dev/ata/ata.c:1.152
--- src/sys/dev/ata/ata.c:1.151	Mon Oct 14 20:13:53 2019
+++ src/sys/dev/ata/ata.c	Mon Oct 21 14:37:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.151 2019/10/15 00:13:53 chs Exp $	*/
+/*	$NetBSD: ata.c,v 1.152 2019/10/21 18:37:47 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.151 2019/10/15 00:13:53 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.152 2019/10/21 18:37:47 christos Exp $");
 
 #include "opt_ata.h"
 
@@ -750,7 +750,9 @@ atabus_alloc_drives(struct ata_channel *
 		atabus_free_drives(chp);
 	if (chp->ch_drive == NULL) {
 		chp->ch_drive = kmem_zalloc(
-		sizeof(struct ata_drive_datas) * ndrives, KM_SLEEP);
+		sizeof(struct ata_drive_datas) * ndrives, KM_NOSLEEP);
+		if (chp->ch_drive == NULL)
+			return ENOMEM;
 	}
 	for (i = 0; i < ndrives; i++) {
 		chp->ch_drive[i].chnl_softc = chp;



CVS commit: src/sys/dev/ata

2019-10-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Oct  4 12:24:32 UTC 2019

Modified Files:
src/sys/dev/ata: ata_raid_intel.c

Log Message:
use memmove() not memcpy() for overlapping regions.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ata/ata_raid_intel.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/ata/ata_raid_intel.c
diff -u src/sys/dev/ata/ata_raid_intel.c:1.9 src/sys/dev/ata/ata_raid_intel.c:1.10
--- src/sys/dev/ata/ata_raid_intel.c:1.9	Mon Oct 22 19:38:06 2018
+++ src/sys/dev/ata/ata_raid_intel.c	Fri Oct  4 12:24:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_raid_intel.c,v 1.9 2018/10/22 19:38:06 jdolecek Exp $	*/
+/*	$NetBSD: ata_raid_intel.c,v 1.10 2019/10/04 12:24:32 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2000-2008 Søren Schmidt 
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.9 2018/10/22 19:38:06 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.10 2019/10/04 12:24:32 mrg Exp $");
 
 #include 
 #include 
@@ -176,7 +176,7 @@ ata_raid_read_config_intel(struct wd_sof
 
 	tmp = (char *)info;
 	(void)memcpy(tmp + 1024, tmp, 512);
-	(void)memcpy(tmp, tmp + 512, 1024);
+	(void)memmove(tmp, tmp + 512, 1024);
 	(void)memset(tmp + 1024, 0, 512);
 
 	/* Check if this is a Intel RAID struct */



CVS commit: src/sys/dev/ata

2019-08-15 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Thu Aug 15 09:00:23 UTC 2019

Modified Files:
src/sys/dev/ata: satafis_subr.c

Log Message:
Set the ATAPI "BYTE COUNT LIMIT" field in the SATA case like we
already do in the ATA case, to make NetBSD work with the virtual
SATA CD-ROM of "qemu-system-i386 -machine q35".  Fixes PR kern/54389.
OK mlelstv.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ata/satafis_subr.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/ata/satafis_subr.c
diff -u src/sys/dev/ata/satafis_subr.c:1.8 src/sys/dev/ata/satafis_subr.c:1.9
--- src/sys/dev/ata/satafis_subr.c:1.8	Sat Oct  7 16:05:32 2017
+++ src/sys/dev/ata/satafis_subr.c	Thu Aug 15 09:00:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: satafis_subr.c,v 1.8 2017/10/07 16:05:32 jdolecek Exp $ */
+/* $NetBSD: satafis_subr.c,v 1.9 2019/08/15 09:00:23 gson Exp $ */
 
 /*-
  * Copyright (c) 2009 Jonathan A. Kollasch.
@@ -51,7 +51,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.8 2017/10/07 16:05:32 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.9 2019/08/15 09:00:23 gson Exp $");
 
 #include 
 #include 
@@ -149,12 +149,16 @@ satafis_rhd_construct_bio(struct ata_xfe
 void
 satafis_rhd_construct_atapi(struct ata_xfer *xfer, uint8_t *fis)
 {
+	int bcount16;
 
 	memset(fis, 0, RHD_FISLEN);
 
 	fis[fis_type] = RHD_FISTYPE;
 	fis[rhd_c] = RHD_C;
 	fis[rhd_command] = ATAPI_PKT_CMD;
+	bcount16 = xfer->c_bcount <= 0x ? xfer->c_bcount : 0x;
+	fis[rhd_lba1] = (bcount16 >> 0) & 0xff;
+	fis[rhd_lba2] = (bcount16 >> 8) & 0xff;
 	fis[rhd_features0] = (xfer->c_flags & C_DMA) ?
 	ATAPI_PKT_CMD_FTRE_DMA : 0;
 }



CVS commit: src/sys/dev/ata

2019-08-15 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Thu Aug 15 09:00:23 UTC 2019

Modified Files:
src/sys/dev/ata: satafis_subr.c

Log Message:
Set the ATAPI "BYTE COUNT LIMIT" field in the SATA case like we
already do in the ATA case, to make NetBSD work with the virtual
SATA CD-ROM of "qemu-system-i386 -machine q35".  Fixes PR kern/54389.
OK mlelstv.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ata/satafis_subr.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/ata

2019-06-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jun  6 20:55:43 UTC 2019

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Take channel lock for calling reset_drive.
Should fix PR 54217.


To generate a diff of this commit:
cvs rdiff -u -r1.451 -r1.452 src/sys/dev/ata/wd.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/ata

2019-06-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jun  6 20:55:43 UTC 2019

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Take channel lock for calling reset_drive.
Should fix PR 54217.


To generate a diff of this commit:
cvs rdiff -u -r1.451 -r1.452 src/sys/dev/ata/wd.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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.451 src/sys/dev/ata/wd.c:1.452
--- src/sys/dev/ata/wd.c:1.451	Thu Jun  6 20:41:04 2019
+++ src/sys/dev/ata/wd.c	Thu Jun  6 20:55:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.451 2019/06/06 20:41:04 mlelstv Exp $ */
+/*	$NetBSD: wd.c,v 1.452 2019/06/06 20:55:43 mlelstv Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.451 2019/06/06 20:41:04 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.452 2019/06/06 20:55:43 mlelstv Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -1663,6 +1663,7 @@ int
 wd_get_params(struct wd_softc *wd, uint8_t flags, struct ataparams *params)
 {
 	int retry = 0;
+	struct ata_channel *chp = wd->drvp->chnl_softc;
 
 again:
 	switch (wd->atabus->ata_get_params(wd->drvp, flags, params)) {
@@ -1671,7 +1672,9 @@ again:
 	case CMD_ERR:
 		if (retry == 0) {
 			retry++;
+			ata_channel_lock(chp);
 			(*wd->atabus->ata_reset_drive)(wd->drvp, flags, NULL);
+			ata_channel_unlock(chp);
 			goto again;
 		}
 



CVS commit: src/sys/dev/ata

2019-06-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jun  6 20:41:04 UTC 2019

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Count only the initial start of a transfer, not the retries.
Should fix kern/54166.

Thanks to macallan@ for spotting the issue.


To generate a diff of this commit:
cvs rdiff -u -r1.450 -r1.451 src/sys/dev/ata/wd.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/ata

2019-06-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Jun  6 20:41:04 UTC 2019

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Count only the initial start of a transfer, not the retries.
Should fix kern/54166.

Thanks to macallan@ for spotting the issue.


To generate a diff of this commit:
cvs rdiff -u -r1.450 -r1.451 src/sys/dev/ata/wd.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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.450 src/sys/dev/ata/wd.c:1.451
--- src/sys/dev/ata/wd.c:1.450	Fri May 24 06:01:05 2019
+++ src/sys/dev/ata/wd.c	Thu Jun  6 20:41:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.450 2019/05/24 06:01:05 mlelstv Exp $ */
+/*	$NetBSD: wd.c,v 1.451 2019/06/06 20:41:04 mlelstv Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.450 2019/05/24 06:01:05 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.451 2019/06/06 20:41:04 mlelstv Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -734,7 +734,8 @@ wdstart1(struct wd_softc *wd, struct buf
 		xfer->c_bio.flags |= ATA_FUA;
 	}
 
-	wd->inflight++;
+	if (xfer->c_retries == 0)
+		wd->inflight++;
 	switch (wd->atabus->ata_bio(wd->drvp, xfer)) {
 	case ATACMD_TRY_AGAIN:
 		panic("wdstart1: try again");
@@ -989,7 +990,9 @@ noerror:	if ((xfer->c_bio.flags & ATA_CO
 
 	ata_free_xfer(wd->drvp->chnl_softc, xfer);
 
+	mutex_enter(>sc_lock);
 	wd->inflight--;
+	mutex_exit(>sc_lock);
 	dk_done(dksc, bp);
 	dk_start(dksc, NULL);
 }



CVS commit: src/sys/dev/ata

2019-05-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 25 16:30:18 UTC 2019

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
use PR_ZERO


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/dev/ata/ata.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/ata

2019-05-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 25 16:30:18 UTC 2019

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
use PR_ZERO


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/dev/ata/ata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.148 src/sys/dev/ata/ata.c:1.149
--- src/sys/dev/ata/ata.c:1.148	Fri Apr  5 20:35:25 2019
+++ src/sys/dev/ata/ata.c	Sat May 25 12:30:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.148 2019/04/06 00:35:25 uwe Exp $	*/
+/*	$NetBSD: ata.c,v 1.149 2019/05/25 16:30:18 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.148 2019/04/06 00:35:25 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.149 2019/05/25 16:30:18 christos Exp $");
 
 #include "opt_ata.h"
 
@@ -1278,17 +1278,8 @@ ata_activate_xfer_locked(struct ata_chan
 struct ata_xfer *
 ata_get_xfer(struct ata_channel *chp, bool waitok)
 {
-	struct ata_xfer *xfer;
-
-	xfer = pool_get(_xfer_pool, waitok ? PR_WAITOK : PR_NOWAIT);
-	KASSERT(!waitok || xfer != NULL);
-
-	if (xfer != NULL) {
-		/* zero everything */
-		memset(xfer, 0, sizeof(*xfer));
-	}
-
-	return xfer;
+	return pool_get(_xfer_pool,
+	PR_ZERO | (waitok ? PR_WAITOK : PR_NOWAIT));
 }
 
 /*



CVS commit: src/sys/dev/ata

2019-05-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri May 24 06:01:06 UTC 2019

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Also schedule timeouts when all openings are in use.


To generate a diff of this commit:
cvs rdiff -u -r1.449 -r1.450 src/sys/dev/ata/wd.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/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.449 src/sys/dev/ata/wd.c:1.450
--- src/sys/dev/ata/wd.c:1.449	Sun Apr  7 13:00:00 2019
+++ src/sys/dev/ata/wd.c	Fri May 24 06:01:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.449 2019/04/07 13:00:00 bouyer Exp $ */
+/*	$NetBSD: wd.c,v 1.450 2019/05/24 06:01:05 mlelstv Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.449 2019/04/07 13:00:00 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.450 2019/05/24 06:01:05 mlelstv Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -757,6 +757,7 @@ wd_diskstart(device_t dev, struct buf *b
 	struct ata_xfer *xfer;
 	struct ata_channel *chp;
 	unsigned openings;
+	int ticks;
 
 	mutex_enter(>sc_lock);
 
@@ -769,22 +770,37 @@ wd_diskstart(device_t dev, struct buf *b
 	openings = uimin(openings, wd->drvp->drv_openings);
 
 	if (wd->inflight >= openings) {
-		mutex_exit(>sc_lock);
-		return EAGAIN;
+		/*
+		 * pretend we run out of memory when the queue is full,
+		 * so that the operation is retried after a minimal
+		 * delay.
+		 */
+		xfer = NULL;
+		ticks = 1;
+	} else {
+		/*
+		 * If there is no available memory, retry later. This
+		 * happens very rarely and only under memory pressure,
+		 * so wait relatively long before retry.
+		 */
+		xfer = ata_get_xfer(chp, false);
+		ticks = hz/2;
 	}
 
-	xfer = ata_get_xfer(chp, false);
 	if (xfer == NULL) {
 		ATADEBUG_PRINT(("wd_diskstart %s no xfer\n",
 		dksc->sc_xname), DEBUG_XFERS);
 
 		/*
-		 * No available memory, retry later. This happens very rarely
-		 * and only under memory pressure, so wait relatively long
-		 * before retry.
+		 * The disk queue is pushed automatically when an I/O
+		 * operation finishes or another one is queued. We
+		 * need this extra timeout because an ATA channel
+		 * might be shared by more than one disk queue and
+		 * all queues need to be restarted when another slot
+		 * becomes available.
 		 */
 		if (!callout_pending(>sc_restart_diskqueue)) {
-			callout_reset(>sc_restart_diskqueue, hz / 2,
+			callout_reset(>sc_restart_diskqueue, ticks,
 			wdrestart, dev);
 		}
 



CVS commit: src/sys/dev/ata

2019-05-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri May 24 06:01:06 UTC 2019

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Also schedule timeouts when all openings are in use.


To generate a diff of this commit:
cvs rdiff -u -r1.449 -r1.450 src/sys/dev/ata/wd.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/ata

2014-07-25 Thread Alan Barrett

On Fri, 25 Jul 2014, David A. Holland wrote:

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Drop the old discard/trim ioctls from wd.c.



-   case DIOCGDISCARDPARAMS: {
-   case DIOCDISCARD: {


These never appeared in a release, so I suppose there's no need to
implement these ioctls in any compat code.

--apb (Alan Barrett)


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

2011-10-16 Thread John Nemeth
On Feb 25,  1:28pm, Wolfgang Solfrank wrote:
} Jonathan A. Kollasch schrieb:
}  On Wed, Oct 05, 2011 at 10:25:52AM +0200, Manuel Bouyer wrote:
}  On Wed, Oct 05, 2011 at 03:40:18AM +, Jonathan A. Kollasch wrote:
}  Module Name:  src
}  Committed By: jakllsch
}  Date: Wed Oct  5 03:40:18 UTC 2011
} 
}  Modified Files:
}src/sys/dev/ata: wd.c
} 
}  Log Message:
}  Limit wd(4) transfers to 128 (512-byte) logical sectors, as the 
traditional
}  MAXPHYS value has for at least the past decade.
} 
}  We should be able to go safely up to 256 sectors. Anything larger requires
}  LBA48, which is not supported by some controllers.
} 
}  Do we know how a real ST506 or similar ancient drive would respond
}  to such a command?
} 
} The ST506 was only a disk drive with no embedded controller logic.
} So it wouldn't respond to such a command at all, as it doesn't even see it.
} The command interface, after which the original ATA interface was modelled,
} was that of the WD1010 disk controller, to which this and similar drives
} would attach.  You would tell the controller the cylinder/head/sector

 And, I very much doubt there were any PCI versions of these
controllers since IDE came out well before the end of the ISA era.
Worrying about drives that old is pretty much pointless.  Even if you
could find one, it is very likely to be non-functional (these weren't
exactly high quality devices).

}-- End of excerpt from Wolfgang Solfrank



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

2011-10-16 Thread Warner Losh

On Oct 16, 2011, at 9:25 PM, John Nemeth wrote:

 On Feb 25,  1:28pm, Wolfgang Solfrank wrote:
 } Jonathan A. Kollasch schrieb:
 }  On Wed, Oct 05, 2011 at 10:25:52AM +0200, Manuel Bouyer wrote:
 }  On Wed, Oct 05, 2011 at 03:40:18AM +, Jonathan A. Kollasch wrote:
 }  Module Name:src
 }  Committed By:   jakllsch
 }  Date:   Wed Oct  5 03:40:18 UTC 2011
 } 
 }  Modified Files:
 }  src/sys/dev/ata: wd.c
 } 
 }  Log Message:
 }  Limit wd(4) transfers to 128 (512-byte) logical sectors, as the 
 traditional
 }  MAXPHYS value has for at least the past decade.
 } 
 }  We should be able to go safely up to 256 sectors. Anything larger 
 requires
 }  LBA48, which is not supported by some controllers.
 } 
 }  Do we know how a real ST506 or similar ancient drive would respond
 }  to such a command?
 } 
 } The ST506 was only a disk drive with no embedded controller logic.
 } So it wouldn't respond to such a command at all, as it doesn't even see it.
 } The command interface, after which the original ATA interface was modelled,
 } was that of the WD1010 disk controller, to which this and similar drives
 } would attach.  You would tell the controller the cylinder/head/sector
 
 And, I very much doubt there were any PCI versions of these
 controllers since IDE came out well before the end of the ISA era.
 Worrying about drives that old is pretty much pointless.  Even if you
 could find one, it is very likely to be non-functional (these weren't
 exactly high quality devices).

You can still buy ESDI devices (that are compatible with the ST506 interface).  
Ebay has them from $35 to $535!  Sizes up to 750MB.

I was able to find ISA and Micro Channel ESDI cards.  I didn't see EISA or PCI 
ones either on Ebay or Google...

So I think you may be right about PCI.  IIRC, the only machines that had these 
were 386 boxes that weren't lucky enough to have IDE (the frankenstein machines 
of the time, since by then multi-function cards with IDE were the common 
solution) and some of the 68k early home machines (Atari and Amiga maybe) and 
sun 3's.

Warner

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

2011-10-05 Thread Jonathan A. Kollasch
On Wed, Oct 05, 2011 at 10:25:52AM +0200, Manuel Bouyer wrote:
 On Wed, Oct 05, 2011 at 03:40:18AM +, Jonathan A. Kollasch wrote:
  Module Name:src
  Committed By:   jakllsch
  Date:   Wed Oct  5 03:40:18 UTC 2011
  
  Modified Files:
  src/sys/dev/ata: wd.c
  
  Log Message:
  Limit wd(4) transfers to 128 (512-byte) logical sectors, as the traditional
  MAXPHYS value has for at least the past decade.
 
 We should be able to go safely up to 256 sectors. Anything larger requires
 LBA48, which is not supported by some controllers.

Do we know how a real ST506 or similar ancient drive would respond
to such a command?  Then again, maybe we shouldn't care until someone
reports it doesn't work.  Currently we limit transfers to 255 sectors.
Presumably we're assuming that the register value of 0 used for 256
might be mishandled.

Jonathan Kollasch


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

2011-10-05 Thread Wolfgang Solfrank

Hi,

Jonathan A. Kollasch schrieb:

On Wed, Oct 05, 2011 at 10:25:52AM +0200, Manuel Bouyer wrote:

On Wed, Oct 05, 2011 at 03:40:18AM +, Jonathan A. Kollasch wrote:

Module Name:src
Committed By:   jakllsch
Date:   Wed Oct  5 03:40:18 UTC 2011

Modified Files:
src/sys/dev/ata: wd.c

Log Message:
Limit wd(4) transfers to 128 (512-byte) logical sectors, as the traditional
MAXPHYS value has for at least the past decade.


We should be able to go safely up to 256 sectors. Anything larger requires
LBA48, which is not supported by some controllers.


Do we know how a real ST506 or similar ancient drive would respond
to such a command?


The ST506 was only a disk drive with no embedded controller logic.
So it wouldn't respond to such a command at all, as it doesn't even see it.
The command interface, after which the original ATA interface was modelled,
was that of the WD1010 disk controller, to which this and similar drives
would attach.  You would tell the controller the cylinder/head/sector
of the first sector you wanted to read, and when multiple sectors were
requested, the controller would increment only the sector number.
Since the controller wouldn't even know the number of sectors on a track,
it wouldn't be able to cross a track boundary.

 Then again, maybe we shouldn't care until someone

reports it doesn't work.


Given that the ST506 had a capacity of 5 MB (yes, megabytes!), this
is most likely reasonable.

 Currently we limit transfers to 255 sectors.

Presumably we're assuming that the register value of 0 used for 256
might be mishandled.


IIRC there were some early IDE drives that had this problem.

Ciao,
Wolfgang
--
wolfg...@solfrank.net   Wolfgang Solfrank


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

2011-10-05 Thread David Laight
On Wed, Oct 05, 2011 at 06:52:37PM +0200, Wolfgang Solfrank wrote:
 ...  You would tell the controller the cylinder/head/sector
 of the first sector you wanted to read, and when multiple sectors were
 requested, the controller would increment only the sector number.
 Since the controller wouldn't even know the number of sectors on a track,
 it wouldn't be able to cross a track boundary.

I suspect some PC BIOS/floppy have that 'feature'!
IIRC there is a bug booting from floppies with less than 8k/track
due to the way bootxx_xxxfs gets loaded.

There has been some confusion about the difference between reads for
multiple sectors and the 'multi-sector' read feature.
The latter changes the interface slightly - I think it means you
only get one data/dma request burst for multiple sectors.

With LBA reads the underlying (reported) geometry shouldn't matter.
But yes, avoiding requests for 256 sectors is probably a good idea!

David

-- 
David Laight: da...@l8s.co.uk


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

2011-05-05 Thread Paul Goyette

Module Name:src
Committed By:   jakllsch
Date:   Sat Apr 30 00:34:03 UTC 2011

Modified Files:
src/sys/dev/ata: ata.c atavar.h

Log Message:
Add simplistic atabus(4) rescan support.



Hmmm, not sure this is working:

{135} ident /netbsd | grep ' ata.c'
 $NetBSD: ata.c,v 1.115 2011/04/30 00:34:03 jakllsch Exp $
{136} drvctl -r atabus2
drvctl: DRVRESCANBUS: Invalid argument
{137} dmesg | grep atabus3
atabus3 at ahcisata0 channel 3
{138}


Am I missing something?  If this actually works, it should find the hard 
drive that I just inserted into this hot-swap dock.



-
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |  | pgoyette at netbsd.org  |
-


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

2011-05-05 Thread Jonathan A. Kollasch
On Thu, May 05, 2011 at 07:42:35AM -0700, Paul Goyette wrote:
 Module Name:src
 Committed By:   jakllsch
 Date:   Sat Apr 30 00:34:03 UTC 2011
 
 Modified Files:
 src/sys/dev/ata: ata.c atavar.h
 
 Log Message:
 Add simplistic atabus(4) rescan support.
 
 
 Hmmm, not sure this is working:
 
 {135} ident /netbsd | grep ' ata.c'
  $NetBSD: ata.c,v 1.115 2011/04/30 00:34:03 jakllsch Exp $
 {136} drvctl -r atabus2
 drvctl: DRVRESCANBUS: Invalid argument
 {137} dmesg | grep atabus3
 atabus3 at ahcisata0 channel 3
 {138}
 
 
 Am I missing something?

Yeah, you need to use something along the lines of:
drvctl -r -a ata_hl atabus2

Jonathan Kollasch


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

2011-05-05 Thread Paul Goyette

On Thu, 5 May 2011, Jonathan A. Kollasch wrote:


Hmmm, not sure this is working:

{135} ident /netbsd | grep ' ata.c'
 $NetBSD: ata.c,v 1.115 2011/04/30 00:34:03 jakllsch Exp $
{136} drvctl -r atabus2
drvctl: DRVRESCANBUS: Invalid argument
{137} dmesg | grep atabus3
atabus3 at ahcisata0 channel 3
{138}


Am I missing something?


Yeah, you need to use something along the lines of:
drvctl -r -a ata_hl atabus2


Kewl!

{141} drvctl -r -a ata_hl atabus3
{142} dmesg | grep atabus3
atabus3 at ahcisata0 channel 3
wd3 at atabus3 drive 0
{143}

Thanks for quick response!


-
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |  | pgoyette at netbsd.org  |
-


CVS commit: src/sys/dev/ata

2010-01-24 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Jan 25 00:39:52 UTC 2010

Modified Files:
src/sys/dev/ata: atareg.h

Log Message:
Add some more elements to struct ataparams.

These mostly concern the new Long Physical Sectors
and Long Logical Sectors feature sets.

Information from a draft of ACS-2, with some additional
in-between members and bits being borrowed from OpenBSD.

There's lots more in ACS-2 we could add, but for the most
part it would be superfluous.

XXX: Some elements marked as reserved no longer are,
and some elements we still reference are now obsolete.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ata/atareg.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/ata

2010-01-21 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Jan 21 23:26:58 UTC 2010

Modified Files:
src/sys/dev/ata: atareg.h

Log Message:
Convert to C99 types. Make whitespace more consistent.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/ata/atareg.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/ata

2010-01-20 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Thu Jan 21 02:53:51 UTC 2010

Modified Files:
src/sys/dev/ata: ata.c

Log Message:
Cosmetic: join some lines.  Get out early on errors, change

switch (...) {
...
error = ...;
break;
}
return error;

to

switch (...) {
...
return ...;
}


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/ata/ata.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/ata

2010-01-10 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jan 10 16:04:25 UTC 2010

Modified Files:
src/sys/dev/ata: atareg.h

Log Message:
Provide atacmd_to48() in case of #if defined(_STANDALONE) too
because standalone wdc driver in cobalt bootloader requires it
for LBA48 support.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/ata/atareg.h

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