From xdivac02@stud.fit.vutbr.cz  Mon Jan  5 00:50:46 2004
Return-Path: <xdivac02@stud.fit.vutbr.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5F44116A4CF
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  5 Jan 2004 00:50:46 -0800 (PST)
Received: from eva.fit.vutbr.cz (eva.fit.vutbr.cz [147.229.10.14])
	by mx1.FreeBSD.org (Postfix) with ESMTP id EACDC43D2F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  5 Jan 2004 00:50:43 -0800 (PST)
	(envelope-from xdivac02@stud.fit.vutbr.cz)
Received: from eva.fit.vutbr.cz (localhost [127.0.0.1])
	by eva.fit.vutbr.cz (8.12.10/8.12.9) with ESMTP id i058oeYH044073
	(version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 5 Jan 2004 09:50:40 +0100 (CET)
Received: (from xdivac02@localhost)
	by eva.fit.vutbr.cz (8.12.10/8.12.5/Submit) id i058odRl044071;
	Mon, 5 Jan 2004 09:50:39 +0100 (CET)
Message-Id: <200401050850.i058odRl044071@eva.fit.vutbr.cz>
Date: Mon, 5 Jan 2004 09:50:39 +0100 (CET)
From: Divacky Roman <xdivac02@stud.fit.vutbr.cz>
Reply-To: Divacky Roman <xdivac02@stud.fit.vutbr.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: implementation of ata sleeping
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         60917
>Category:       kern
>Synopsis:       implementation of ata sleeping
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 05 01:00:38 PST 2004
>Closed-Date:    Mon Jan 12 11:32:46 PST 2004
>Last-Modified:  Mon Jan 12 11:32:46 PST 2004
>Originator:     Divacky Roman
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
>Environment:
System: FreeBSD eva.fit.vutbr.cz 4.9-STABLE FreeBSD 4.9-STABLE #2: Thu Nov 20 11:20:53 CET 2003 root@tereza.fit.vutbr.cz:/home/src/sys/sys-49/compile/EVA i386


	
>Description:

implementation of ata devices sleeping/standbying
>How-To-Repeat:
atacontrol sleep channel device
atacontrol standby channel device

>Fix:

--- ata-all.c.orig	Mon Dec 29 13:13:25 2003
+++ ata-all.c	Wed Dec 31 14:38:52 2003
@@ -509,6 +509,31 @@
 	error = ata_detach(device);
 	/* SOS should disable channel HW on controller XXX */
 	break;
+    case ATASTANDBY:
+    case ATASLEEP:
+	if (!device || !(ch = device_get_softc(device))) {
+	   error = ENXIO;
+	   break;
+	}
+        if (ch->device[iocmd->device].param &&
+            ch->device[iocmd->device].param->support.command2 
+	    & ATA_SUPPORT_FLUSHCACHE)
+	   ata_controlcmd(&ch->device[iocmd->device], ATA_FLUSHCACHE, 0, 0, 0);
+	if (iocmd->cmd == ATASLEEP)
+   	   ata_controlcmd(&ch->device[iocmd->device], ATA_SLEEP, 0, 0, 0);
+	else 
+	   ata_controlcmd(&ch->device[iocmd->device], ATA_STANDBY, 0, 0, 0);
+	error = 0;
+	break;
+    case ATACHECK:
+	if (!device || !(ch = device_get_softc(device))) {
+	   error = ENXIO;
+	   break;
+	}
+   	iocmd->u.mode.mode[iocmd->device] = 
+	   ata_controlcmd(&ch->device[iocmd->device], ATA_CHECKMODE, 0, 0, 0);
+	error = 0;
+	break;
 	
 
 #ifdef DEV_ATARAID
--- ata.h.orig	Mon Dec 29 13:14:27 2003
+++ /sys/sys/ata.h	Wed Dec 31 14:13:27 2003
@@ -227,6 +227,8 @@
 #define	ATA_READ_DMA			0xc8	/* read w/DMA command */
 #define	ATA_WRITE_DMA			0xca	/* write w/DMA command */
 #define	ATA_WRITE_DMA_QUEUED		0xcc	/* write w/DMA QUEUED command */
+#define	ATA_STANDBY			0xe0	/* standby command */
+#define ATA_CHECKMODE                   0xe5    /* check power mode */
 #define	ATA_SLEEP			0xe6	/* sleep command */
 #define	ATA_FLUSHCACHE			0xe7	/* flush cache to disk */
 #define	ATA_FLUSHCACHE48		0xea	/* flush cache to disk */
@@ -318,6 +320,9 @@
 #define ATARAIDADDSPARE		0x0123
 #define ATARAIDREBUILD		0x0124
 #define ATAENCSTAT		0x0130
+#define ATASLEEP		0x0131
+#define ATASTANDBY		0x0132
+#define ATACHECK                0x0133   
 
     union {
 	int			maxchan;
--- atacontrol.c.orig	Mon Dec 29 13:25:41 2003
+++ atacontrol.c	Wed Dec 31 14:27:38 2003
@@ -493,7 +493,18 @@
 				mode2str(iocmd.u.mode.mode[1]));
 		}
 	}
-	else
+	else if (!strcmp(argv[1], "sleep") && argc == 4) {
+	   iocmd.cmd = ATASLEEP;
+	   iocmd.device = atoi(argv[3]);
+	   if (ioctl(fd, IOCATA, &iocmd) < 0)
+	      err(1, "ioctl(ATASLEEP)");	    	   
+	}
+	else if (!strcmp(argv[1], "standby") && argc == 4) {
+	   iocmd.cmd = ATASTANDBY;
+	   iocmd.device = atoi(argv[3]);
+	   if (ioctl(fd, IOCATA, &iocmd) < 0)
+	      err(1, "ioctl(ATASTANDBY)");	    	   
+	}	else
 	    	usage();
 	exit(EX_OK);
 }

>Release-Note:
>Audit-Trail:

From: xdivac02@stud.fit.vutbr.cz
To: freebsd-gnats-submit@FreeBSD.org, xdivac02@stud.fit.vutbr.cz
Cc:  
Subject: Re: kern/60917: implementation of ata sleeping
Date: Mon, 5 Jan 2004 12:29:34 +0100 (CET)

 you hae to copy /sys/sys/ata.h to /usr/include/sys/ata.h (not included in this patch)
 
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: simon 
Responsible-Changed-When: Mon Jan 5 06:06:23 PST 2004 
Responsible-Changed-Why:  
Over to ATA maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60917 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Mon Jan 12 11:31:50 PST 2004 
State-Changed-Why:  
THere is no need for ioctl for this now, in 5.2 forward ATA/ATAPI 
commands can be issued from userland. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60917 
>Unformatted:
