Re: Seagate ST340824A and (un)clipping max LBA: 2.2.19+ide04092001 patch

2001-04-30 Thread Alexander Stavitsky


On Sat, Apr 28, 2001 at 12:22:07AM +0200, [EMAIL PROTECTED] wrote:

> No. Maybe someone can tell us about its origin, but in your case
> of course this just works because 0xa intersects 0x306b. You might
> comment out this entire test.

If I comment out the entire test, it would try to unclip the capacity of all
drives. Is it safe? For my situation I would prefer to use "setmax"
or disk specific "seagate" (see later), but I do not know how to change
the kernel idea of drive geometry and capacity. I use 2.2.19 + ide patch.
Neither fdisk nor dd would not read past the clipped capacity before or after
software unclipping.

> 
> In the case of this particular disk the manufacturer says:
> Use the Set Features command (EF) with subfunction F1.
> That tells the disk to report full capacity.
> (ATA-6 says that F1 is reserved for use by the Compact Flash Association)
> 
> [Could you try that and report identify output before and after?]

Yes, I tried that and it does report unclipped capacity.
seagate.c is attached for reference.

stalex@eagle:~$ sudo hdparm -I /dev/hdb
/dev/hdb:

 Model=TS438042 A  , FwRev=.350, SerialNo=H30E0186 
   
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=2048kB, MaxMultSect=16, MultSect=?16?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=66055248
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes: pio0 pio1 pio2 pio3 pio4 
 DMA modes: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4 udma5 
stalex@eagle:~$ sudo /usr/src/seagate /dev/hdb
Using device /dev/hdb
Sending Set Features F1 subcommand
Done.
stalex@eagle:~$ sudo hdparm -I /dev/hdb

/dev/hdb:

 Model=TS438042 A  , FwRev=.350, SerialNo=H30E0186 
   
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=2048kB, MaxMultSect=16, MultSect=?16?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=78165360
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes: pio0 pio1 pio2 pio3 pio4 
 DMA modes: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4 udma5 


-- 
  = mailto:[EMAIL PROTECTED]
 ===http://www.geocities.com/astavitsky
=   GPG Key 0xF7343C8B: 68DD 1E1B 2C98 D336 E31F  C87B 91B9 5244 F734 3C8B
  |_Alexander Stavitsky 


#include 
#include 
//#include 
#include 

#define SEAGATE_REPORT_FULL_CAPACITY	0xF1

int
get_identity(int fd) {
	unsigned char args[4+512] = {WIN_IDENTIFY,0,0,1,};
	struct hd_driveid *id = (struct hd_driveid *)[4];

	if (ioctl(fd, HDIO_DRIVE_CMD, )) {
		perror("HDIO_DRIVE_CMD");
		fprintf(stderr,
			"WIN_IDENTIFY failed - trying WIN_PIDENTIFY\n");
		args[0] = WIN_PIDENTIFY;
		if (ioctl(fd, HDIO_DRIVE_CMD, )) {
			perror("HDIO_DRIVE_CMD");
			fprintf(stderr,
			   "WIN_PIDENTIFY also failed - giving up\n");
			exit(1);
		}
	}

	printf("id->command_set_1: 0x%X\n", id->command_set_1);
	printf("id->lba_capacity: %lu\n", id->lba_capacity);
}

/*
 * result: in LBA mode precisely what is expected
 * in CHS mode the correct H and S, and C mod 65536.
 */

int
set_feature(int fd) {
unsigned char args[4] = {WIN_SETFEATURES,0,0xf1,0};
int i;

if (ioctl(fd, HDIO_DRIVE_CMD, )) {
	perror("HDIO_DRIVE_CMD failed WIN_SETFEATURES");
	for (i=0; i<4; i++)
	printf("%d = 0x%X\n", args[i], args[i]);
	exit(1);
}

return 0;
}

main(int argc, char **argv){
	int fd, c;

	char *device = NULL;	/* e.g. "/dev/hda" */
	int slave = 0;

	device = argv[1];
	if (!device) {
		fprintf(stderr, "no device specified - "
			"use e.g. \"seagate /dev/hdb\"\n");
		exit(1);
	}
	printf("Using device %s\n", device);

	fd = open(device, O_RDONLY);
	if (fd == -1) {
		perror("open");
		exit(1);
	}
	printf("Sending Set Features F1 subcommand\n");
	set_feature(fd);
	printf("Done.\n");

	return 0;
}

 PGP signature


Re: Seagate ST340824A and (un)clipping max LBA: 2.2.19+ide04092001 patch

2001-04-30 Thread Alexander Stavitsky


On Sat, Apr 28, 2001 at 12:22:07AM +0200, [EMAIL PROTECTED] wrote:

 No. Maybe someone can tell us about its origin, but in your case
 of course this just works because 0xa intersects 0x306b. You might
 comment out this entire test.

If I comment out the entire test, it would try to unclip the capacity of all
drives. Is it safe? For my situation I would prefer to use setmax
or disk specific seagate (see later), but I do not know how to change
the kernel idea of drive geometry and capacity. I use 2.2.19 + ide patch.
Neither fdisk nor dd would not read past the clipped capacity before or after
software unclipping.

 
 In the case of this particular disk the manufacturer says:
 Use the Set Features command (EF) with subfunction F1.
 That tells the disk to report full capacity.
 (ATA-6 says that F1 is reserved for use by the Compact Flash Association)
 
 [Could you try that and report identify output before and after?]

Yes, I tried that and it does report unclipped capacity.
seagate.c is attached for reference.

stalex@eagle:~$ sudo hdparm -I /dev/hdb
/dev/hdb:

 Model=TS438042 A  , FwRev=.350, SerialNo=H30E0186 
   
 Config={ HardSect NotMFM HdSw15uSec Fixed DTR10Mbs RotSpdTol.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=2048kB, MaxMultSect=16, MultSect=?16?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=66055248
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes: pio0 pio1 pio2 pio3 pio4 
 DMA modes: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4 udma5 
stalex@eagle:~$ sudo /usr/src/seagate /dev/hdb
Using device /dev/hdb
Sending Set Features F1 subcommand
Done.
stalex@eagle:~$ sudo hdparm -I /dev/hdb

/dev/hdb:

 Model=TS438042 A  , FwRev=.350, SerialNo=H30E0186 
   
 Config={ HardSect NotMFM HdSw15uSec Fixed DTR10Mbs RotSpdTol.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=2048kB, MaxMultSect=16, MultSect=?16?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=78165360
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes: pio0 pio1 pio2 pio3 pio4 
 DMA modes: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4 udma5 


-- 
  = mailto:[EMAIL PROTECTED]
 ===http://www.geocities.com/astavitsky
=   GPG Key 0xF7343C8B: 68DD 1E1B 2C98 D336 E31F  C87B 91B9 5244 F734 3C8B
  |_Alexander Stavitsky 


#include stdio.h
#include fcntl.h
//#include linux/ide.h
#include linux/hdreg.h

#define SEAGATE_REPORT_FULL_CAPACITY	0xF1

int
get_identity(int fd) {
	unsigned char args[4+512] = {WIN_IDENTIFY,0,0,1,};
	struct hd_driveid *id = (struct hd_driveid *)args[4];

	if (ioctl(fd, HDIO_DRIVE_CMD, args)) {
		perror(HDIO_DRIVE_CMD);
		fprintf(stderr,
			WIN_IDENTIFY failed - trying WIN_PIDENTIFY\n);
		args[0] = WIN_PIDENTIFY;
		if (ioctl(fd, HDIO_DRIVE_CMD, args)) {
			perror(HDIO_DRIVE_CMD);
			fprintf(stderr,
			   WIN_PIDENTIFY also failed - giving up\n);
			exit(1);
		}
	}

	printf(id-command_set_1: 0x%X\n, id-command_set_1);
	printf(id-lba_capacity: %lu\n, id-lba_capacity);
}

/*
 * result: in LBA mode precisely what is expected
 * in CHS mode the correct H and S, and C mod 65536.
 */

int
set_feature(int fd) {
unsigned char args[4] = {WIN_SETFEATURES,0,0xf1,0};
int i;

if (ioctl(fd, HDIO_DRIVE_CMD, args)) {
	perror(HDIO_DRIVE_CMD failed WIN_SETFEATURES);
	for (i=0; i4; i++)
	printf(%d = 0x%X\n, args[i], args[i]);
	exit(1);
}

return 0;
}

main(int argc, char **argv){
	int fd, c;

	char *device = NULL;	/* e.g. /dev/hda */
	int slave = 0;

	device = argv[1];
	if (!device) {
		fprintf(stderr, no device specified - 
			use e.g. \seagate /dev/hdb\\n);
		exit(1);
	}
	printf(Using device %s\n, device);

	fd = open(device, O_RDONLY);
	if (fd == -1) {
		perror(open);
		exit(1);
	}
	printf(Sending Set Features F1 subcommand\n);
	set_feature(fd);
	printf(Done.\n);

	return 0;
}

 PGP signature


Seagate ST340824A and (un)clipping max LBA: 2.2.19+ide04092001 patch

2001-04-27 Thread Alexander Stavitsky


Disk capacity unclipping routines in ide.2.2.19.04092001.patch do not unclip
Seagate ST340824A.

I have to use the jumper on the drive to make system boot.
I tried "setmax" program and it is able to unclip the capacity,
kernel however does not.

I digged a little and I think the problem is that ST340824A does not follow
the ATA standard - it does support both READ NATIVE MAX ADDRESS
and SET MAX ADDRESS, but does not advertise support for
Host Protected Area feature set.

drive->id->command_set_1 = 0x306b for the this drive.

The unclipping routines compare
drive->id->command_set_1 and 0x0400 (Host Protected Feature set)
The earlier version of the patch compared
drive->id->command_set_1 and 0x000a (Security Mode & Power Managment ???)

When I changed it back to 0x000a, it unclipped the capacity just fine.
But 0x000a doesn't make any sense to me.
What is the correct solution?

Also the idedisk_supports_host_protected_area is there, but not used and
the printk's notifying of unclipping are commented out???

I attach the diff to show what I'm talking about.

Also a related question: when I use "setmax", the drive reports full
capacity through "hdparm -I /dev/hd*", but kernel still uses the old info.
How does one update the kernel info after using "setmax"?


--- ide-disk.c.orig Mon Apr 16 13:30:50 2001
+++ ide-disk.c  Fri Apr 27 11:16:38 2001
@@ -546,7 +546,7 @@
ide_task_t args;
unsigned long addr = 0;
 
-   if (!(drive->id->command_set_1 & 0x0400))
+   if (!(drive->id->command_set_1 & 0x000a))
 // if (!(drive->id->cfs_enable_1 & 0x0400))
return addr;
 
@@ -580,7 +580,7 @@
ide_task_t args;
unsigned long addr_set = 0;

-// printk("%s: (un)clipping max LBA...%lu\n", drive->name, addr_req);
+   printk("%s: (un)clipping max LBA...%lu\n", drive->name, addr_req);
 
addr_req--;
/* Create IDE/ATA command request structure */
@@ -603,7 +603,7 @@
 | ((args.tfRegister[IDE_SECTOR_OFFSET]   ));
}
addr_set++;
-// printk("%s: max LBA (un)clipped to %lu\n", drive->name, addr_set);
+   printk("%s: max LBA (un)clipped to %lu\n", drive->name, addr_set);
return addr_set;
 }
 


-- 
  = mailto:[EMAIL PROTECTED]
 ===http://www.geocities.com/astavitsky
=   GPG Key 0xF7343C8B: 68DD 1E1B 2C98 D336 E31F  C87B 91B9 5244 F734 3C8B
  |_Alexander Stavitsky 

 PGP signature


Seagate ST340824A and (un)clipping max LBA: 2.2.19+ide04092001 patch

2001-04-27 Thread Alexander Stavitsky


Disk capacity unclipping routines in ide.2.2.19.04092001.patch do not unclip
Seagate ST340824A.

I have to use the jumper on the drive to make system boot.
I tried setmax program and it is able to unclip the capacity,
kernel however does not.

I digged a little and I think the problem is that ST340824A does not follow
the ATA standard - it does support both READ NATIVE MAX ADDRESS
and SET MAX ADDRESS, but does not advertise support for
Host Protected Area feature set.

drive-id-command_set_1 = 0x306b for the this drive.

The unclipping routines compare
drive-id-command_set_1 and 0x0400 (Host Protected Feature set)
The earlier version of the patch compared
drive-id-command_set_1 and 0x000a (Security Mode  Power Managment ???)

When I changed it back to 0x000a, it unclipped the capacity just fine.
But 0x000a doesn't make any sense to me.
What is the correct solution?

Also the idedisk_supports_host_protected_area is there, but not used and
the printk's notifying of unclipping are commented out???

I attach the diff to show what I'm talking about.

Also a related question: when I use setmax, the drive reports full
capacity through hdparm -I /dev/hd*, but kernel still uses the old info.
How does one update the kernel info after using setmax?


--- ide-disk.c.orig Mon Apr 16 13:30:50 2001
+++ ide-disk.c  Fri Apr 27 11:16:38 2001
@@ -546,7 +546,7 @@
ide_task_t args;
unsigned long addr = 0;
 
-   if (!(drive-id-command_set_1  0x0400))
+   if (!(drive-id-command_set_1  0x000a))
 // if (!(drive-id-cfs_enable_1  0x0400))
return addr;
 
@@ -580,7 +580,7 @@
ide_task_t args;
unsigned long addr_set = 0;

-// printk(%s: (un)clipping max LBA...%lu\n, drive-name, addr_req);
+   printk(%s: (un)clipping max LBA...%lu\n, drive-name, addr_req);
 
addr_req--;
/* Create IDE/ATA command request structure */
@@ -603,7 +603,7 @@
 | ((args.tfRegister[IDE_SECTOR_OFFSET]   ));
}
addr_set++;
-// printk(%s: max LBA (un)clipped to %lu\n, drive-name, addr_set);
+   printk(%s: max LBA (un)clipped to %lu\n, drive-name, addr_set);
return addr_set;
 }
 


-- 
  = mailto:[EMAIL PROTECTED]
 ===http://www.geocities.com/astavitsky
=   GPG Key 0xF7343C8B: 68DD 1E1B 2C98 D336 E31F  C87B 91B9 5244 F734 3C8B
  |_Alexander Stavitsky 

 PGP signature