From nobody@FreeBSD.org  Tue May 24 14:39:31 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7D90316A41C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 24 May 2005 14:39:31 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 5DC2743D4C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 24 May 2005 14:39:31 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j4OEdVj9093818
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 24 May 2005 14:39:31 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j4OEdVqS093817;
	Tue, 24 May 2005 14:39:31 GMT
	(envelope-from nobody)
Message-Id: <200505241439.j4OEdVqS093817@www.freebsd.org>
Date: Tue, 24 May 2005 14:39:31 GMT
From: Arnaud de Prelle <support@pnzone.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Ataidle seems broken + problem with ATA wakeup
X-Send-Pr-Version: www-2.3

>Number:         81438
>Category:       kern
>Synopsis:       [ata] Ataidle seems broken + problem with ATA wakeup
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 24 14:40:01 GMT 2005
>Closed-Date:    Wed Jan 04 21:43:58 GMT 2006
>Last-Modified:  Wed Jan 04 21:43:58 GMT 2006
>Originator:     Arnaud de Prelle
>Release:        6.0-Current
>Organization:
>Environment:
FreeBSD pnserver.pnzone.net 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Tue May 24 15:41:42 CEST 2005 i386
>Description:
First, there seems to be some problem with a PATA-133 Maxtor disk when trying to wake it up (it has been waked up before with 'ataidle -S'):
kernel log messages:
>How-To-Repeat:
Every times
>Fix:
Unknown
>Release-Note:
>Audit-Trail:

From: arnaud de prelle <arnaud@pnzone.net>
To: bug-followup@FreeBSD.org, support@pnzone.net
Cc:  
Subject: Re: i386/81438: Ataidle seems broken + problem with ATA wakeup
Date: Tue, 24 May 2005 18:28:52 +0200

 I made little c program for manually setting idle a disk but now there 
 appears errors in the /usr/include/sys/ata.h !
 
 root@pnserver# cat sleep.c
 #include <sys/ioctl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/ata.h>
 
 int main (int argc, char *argv[]) {
         int fd;
         char *dev = argv[argc-1];
 
         if (argc != 2) {
                 printf("Error with number of args, usage:\n");
                 printf("$ sleep /dev/device_node\n");
                 exit(EXIT_FAILURE);
         }
 
         if ( (fd = open(dev, O_RDONLY)) == -1) {
                 printf("Error while trying to open %s\n", dev);
                 exit(EXIT_FAILURE);
         }
         if ( ioctl (fd, ATA_IDLE_IMMEDIATE, sizeof(ATA_IDLE_IMMEDIATE)) 
 == -1 ) {
                 printf("Error while trying to idle the disk\n");
                 printf("-> ATA_IDLE_IMMEDIATE Code: %d\n", 
 ATA_IDLE_IMMEDIATE);
                 printf("-> Error Code: %s\n", strerror (errno));
                 exit(EXIT_FAILURE);
         }
         else
                 printf("Disk is now idle\n");
         exit(EXIT_SUCCESS);
 }
 root@pnserver# cc sleep.c
 In file included from sleep.c:6:
 /usr/include/sys/ata.h:38: error: syntax error before "u_int16_t"
 /usr/include/sys/ata.h:130: error: syntax error before "u_int16_t"
 /usr/include/sys/ata.h:164: error: syntax error before "u_int16_t"
 /usr/include/sys/ata.h:349: error: syntax error before "u_int8_t"
 /usr/include/sys/ata.h:358: error: syntax error before "caddr_t"
 
 And when I manually set up ATA_IDLE_IMMEDIATE as seen in sys/ata.h:
 #define ATA_IDLE_IMMEDIATE              0xe1
 
 Here is the result:
 root@pnserver# cc sleep.c -o sleep
 root@pnserver# ./sleep /dev/ad1
 Error while trying to idle the disk
 -> ATA_IDLE_IMMEDIATE Code: 225
 -> Error Code: Inappropriate ioctl for device
 root@pnserver# df -h
 Filesystem     Size    Used   Avail Capacity  Mounted on
 /dev/ad0s1a    9.7G    4.5G    4.4G    50%    /
 devfs          1.0K    1.0K      0B   100%    /dev
 /dev/ad0s1f     45G     13G     29G    31%    /home
 /dev/ad0s1e     15G    2.5G     11G    19%    /net
 /dev/ad0s1d    3.9G    212M    3.4G     6%    /var
 /dev/ad1s1a    5.9G    4.3G    1.1G    80%    /dd3
 /dev/ad1s1f    2.9G    1.8G    871M    68%    /dd3/home
 /dev/ad1s1e    989M    346M    564M    38%    /dd3/var
 /dev/ad1s1d    2.9G    2.1G    554M    80%    /dd3/net
 /dev/ad2s1d    184G    101G     68G    60%    /dd2
 procfs         4.0K    4.0K      0B   100%    /proc
 devfs          1.0K    1.0K      0B   100%    /var/named/de
 
 So it tells me that 0xe1 is an Inappropriate ioctl for device. I dont 
 understand anything of this !
 ps: When trying with ATA_STANDBY_IMMEDIATE it's the same problem.
 ps2: I cant open the device in O_WRONLY maybe it's there the problem, I 
 don't know well.
 
 Does ata.h and all stuffes related to ata still in development on the 
 6.0-Current ?
 Will ata idle be repaired on 5.4-Release in future (see first post) or 
 must I shift to another distribution (I hope not!!) ?
 
 -- 
 Arnaud de Prelle
 arnaud@pnzone.net
 
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: lofi 
Responsible-Changed-When: Thu Nov 10 14:47:52 GMT 2005 
Responsible-Changed-Why:  
Over to ata maintainer. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=81438 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Wed Jan 4 21:41:53 UTC 2006 
State-Changed-Why:  
Ataidle is not supported by the ATA driver. 
Real idleing/spindown should be integrated into ATA so it can keep 
track of the devices state. However this is not unproblematic as 
device behavior is very different. 
Its an item on my rather long TODO list.... 

http://www.freebsd.org/cgi/query-pr.cgi?pr=81438 
>Unformatted:
 >> ad2: TIMEOUT - READ_DMA retrying (2 retries left) LBA=12127
 >> ad2: WARNING - removed from configuration
 >> ata1-master: FAILURE - READ_DMA timed out
 And when I manually try to remove it from the mounting point in the tree 'unmount /mount_point' of this ad2 makes the server freezing.
 This brand-new disk has those properties:
 ad2: 194481MB <Maxtor 6B200P0/BAH41BY0> [395136/16/63] at ata1-master UDMA133
 
 So I tried to upgrade to 6.0-Current, successfully, but with this version, ataidle does simply not working:
 # ataidle -l
 error getting maximum channel: Operation not supported
 # ataidle -S 20 1 0
 error getting maximum channel: Operation not supported
 
 So I tought maybe the binary for 5.4 isn't compatible with 6.0 and I tried to recompile ataidle. And it seems to be broken:
 # pwd
 /usr/ports/sysutils/ataidle
 # cat distinfo
 MD5 (ataidle-0.8.tar.gz) = c7486da942c4fcd47a3724270ac4012d
 SIZE (ataidle-0.8.tar.gz) = 13618
 # make install clean
 ===>  Building for ataidle-0.8
 /bin/sh Make.sh clean all
 rm -f *.o ataidle
 cc -O -pipe -std=c99 -Wall -pedantic  -c freebsd/ataidle.c
 In file included from freebsd/ataidle.h:39,
                  from freebsd/ataidle.c:63:
 freebsd/../mi/atagen.h:81: error: field `atacmd' has incomplete type
 In file included from freebsd/ataidle.c:65:
 freebsd/../mi/atadefs.h:11: error: syntax error before numeric constant
 freebsd/../mi/atadefs.h:13: error: syntax error before numeric constant
 freebsd/ataidle.c: In function `ata_cmd':
 freebsd/ataidle.c:88: error: `ATAGMAXCHANNEL' undeclared (first use in this function)
 freebsd/ataidle.c:88: error: (Each undeclared identifier is reported only once
 freebsd/ataidle.c:88: error: for each function it appears in.)
 freebsd/ataidle.c:99: error: `ATAREQUEST' undeclared (first use in this function)
 freebsd/ataidle.c:103: error: `IOCATA' undeclared (first use in this function)
 freebsd/ataidle.c: In function `ata_setataparams':
 freebsd/ataidle.c:113: error: invalid application of `sizeof' to incomplete type `ata_cmd'
 freebsd/ataidle.c:114: error: `ATAREQUEST' undeclared (first use in this function)
 freebsd/ataidle.c: In function `ata_devpresent':
 freebsd/ataidle.c:153: error: `ATAGPARM' undeclared (first use in this function)
 freebsd/ataidle.c:155: error: `IOCATA' undeclared (first use in this function)
 freebsd/ataidle.c: In function `ata_getmaxchan':
 freebsd/ataidle.c:170: error: `ATAGMAXCHANNEL' undeclared (first use in this function)
 *** Error code 1
 
 Stop in /usr/ports/sysutils/ataidle/work/ataidle-0.8.
 *** Error code 1
 
 Stop in /usr/ports/sysutils/ataidle/work/ataidle-0.8.
 *** Error code 1
 
 Stop in /usr/ports/sysutils/ataidle.
