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.