Skip to contentSkip to conversation

2.4.x kernels, big ide disks and old bios

DISCUSSION [email protected] 4 participants 4 messages Dec 25, 2001 – Dec 26, 2001

lore
Share & tools
lore
#0 lore raw

Josep Lladonosa i Capell:

Quoted 2 lines

Linux adopts the 'false' geometry (65530/16/63) ) to bypass the bios boot.

You can see that this is the wrong way around.
When you start your computer, first the BIOS boots, then Linux. But maybe you mean to say that you set a jumper on the disk so as to bypass the BIOS boot problem, and that as a result also Linux sees a smaller disk?

Quoted 2 lines

hdc: IC35L060AVER07-0, ATA DISK drive
hdc: 66055247 sectors (33820 MB) w/1916KiB Cache, CHS=119150/16/63,

Funny. Where did this CHS come from? Did you give boot parameters?

Quoted 2 lines

setmax.c does its job for my ide ibm - 60Gb, but kernel leaves bios parameters - 32Gb

Can you be more explicit? What precisely do you do? Call setmax in a boot script? And afterwards you can access the entire disk, but some proc files still mention the old geometry? Or are there any real problems?
What precisely do you mean by "kernel leaves bios parameters"?

Santiago Garcia Mantinan:

: What I'm using is change the geometry after the boot and before any : partition besides root is mounted, I do this at the beginning of : checkroot.sh by calling "/sbin/setmax -d 0 /dev/hda"
: This works ok for me, of course you can have other solutions.

Good to hear that it works OK. Sooner or later setmax or something similar must become part of the standard kernel, but so far I've gotten almost no feedback. Can you give the disk manufacturer and model (mail [email protected])?

Andries

#1 lore raw
Quoted 9 lines · On Tue, 25 Dec 2001 [email protected] wrote:

: What I'm using is change the geometry after the boot and before any : partition besides root is mounted, I do this at the beginning of : checkroot.sh by calling "/sbin/setmax -d 0 /dev/hda"
: This works ok for me, of course you can have other solutions.

Good to hear that it works OK. Sooner or later setmax or something similar must become part of the standard kernel, but so far I've gotten almost no feedback. Can you give the disk manufacturer and model (mail [email protected])?

The kernel part is already there in Andre Hedrick's IDE-patches for 2.2.x and 2.4.x. I don't know why it's not in standard 2.4.x.

Patch below is for 2.4.x, extracted from Andre's code. Works For Me(tm).

Eric

drivers/ide/ide-disk.c renamed from drivers/ide/ide-disk.c~ +133 -8
@@ -513,24 +513,149 @@
 			current_capacity(drive));
 }
 
+
+/*
+ * Tests if the drive supports Host Protected Area feature.
+ * Returns true if supported, false otherwise.
+ */
+static inline int idedisk_supports_host_protected_area(ide_drive_t *drive)
+{
+ int flag = (drive->id->command_set_1 & 0x0400) ? 1 : 0;
+ printk("%s: host protected area => %d\n", drive->name, flag);
+ return flag;
+}
+
+/*
+ * Queries for true maximum capacity of the drive.
+ * Returns maximum LBA address (> 0) of the drive, 0 if failed.
+ */
+static unsigned long idedisk_read_native_max_address(ide_drive_t *drive)
+{
+ byte args[7];
+ unsigned long addr = 0;
+
+ printk("%s: checking for max native LBA...\n", drive->name);
+
+ /* Create IDE/ATA command request structure
+ *
+ * NOTE: I'm not sure if I can safely use IDE_*_OFFSET macro
+ * here...For real ATA command structure, offset for IDE
+ * command is 7, but in IDE driver, it needs to be at 0th
+ * index (same goes for IDE status offset below). Hmm...
+ */
+ args[0] = 0xf8; /* READ_NATIVE_MAX - see ATA spec */
+ args[IDE_FEATURE_OFFSET] = 0x00;
+ args[IDE_NSECTOR_OFFSET] = 0x00;
+ args[IDE_SECTOR_OFFSET] = 0x00;
+ args[IDE_LCYL_OFFSET] = 0x00;
+ args[IDE_HCYL_OFFSET] = 0x00;
+ args[IDE_SELECT_OFFSET] = 0x40;
+
+ /* submit command request - if OK, read current max LBA value */
+ if (ide_wait_cmd_task(drive, args) == 0) {
+ if ((args[0] & 0x01) == 0) {
+ addr = ((args[IDE_SELECT_OFFSET] & 0x0f) << 24)
+ | ((args[IDE_HCYL_OFFSET] ) << 16)
+ | ((args[IDE_LCYL_OFFSET] ) << 8)
+ | ((args[IDE_SECTOR_OFFSET] ));
+ }
+ }
+
+ printk("%s: max native LBA is %lu\n", drive->name, addr);
+
+ return addr;
+}
+
+/*
+ * Sets maximum virtual LBA address of the drive.
+ * Returns new maximum virtual LBA address (> 0) or 0 on failure.
+ */
+static unsigned long idedisk_set_max_address(ide_drive_t *drive,
+ unsigned long addr_req)
+{
+ byte args[7];
+ unsigned long addr_set = 0;
+
+ printk("%s: (un)clipping max LBA...\n", drive->name);
+
+ /* Create IDE/ATA command request structure
+ *
+ * NOTE: I'm not sure if I can safely use IDE_*_OFFSET macro
+ * here...For real ATA command structure, offset for IDE
+ * command is 7, but in IDE driver, it needs to be at 0th
+ * index (same goes for IDE status offset below). Hmm...
+ */
+ args[0] = 0xf9; /* SET_MAX - see ATA spec */
+ args[IDE_FEATURE_OFFSET] = 0x00;
+ args[IDE_NSECTOR_OFFSET] = 0x00;
+ args[IDE_SECTOR_OFFSET] = ((addr_req ) & 0xff);
+ args[IDE_LCYL_OFFSET] = ((addr_req >> 8) & 0xff);
+ args[IDE_HCYL_OFFSET] = ((addr_req >> 16) & 0xff);
+ args[IDE_SELECT_OFFSET] = ((addr_req >> 24) & 0x0f) | 0x40;
+
+ /* submit command request - if OK, read new max LBA value */
+ if (ide_wait_cmd_task(drive, args) == 0) {
+ if ((args[0] & 0x01) == 0) {
+ addr_set = ((args[IDE_SELECT_OFFSET] & 0x0f) << 24)
+ | ((args[IDE_HCYL_OFFSET] ) << 16)
+ | ((args[IDE_LCYL_OFFSET] ) << 8)
+ | ((args[IDE_SECTOR_OFFSET] ));
+ }
+ }
+
+ printk("%s: max LBA (un)clipped to %lu\n", drive->name, addr_set);
+
+ return addr_set;
+}
+
 /*
  * Compute drive->capacity, the full capacity of the drive
  * Called with drive->id != NULL.
+ *
+ * To compute capacity, this uses either of
+ *
+ * 1. CHS value set by user (whatever user sets will be trusted)
+ * 2. LBA value from target drive (require new ATA feature)
+ * 3. LBA value from system BIOS (new one is OK, old one may break)
+ * 4. CHS value from system BIOS (traditional style)
+ *
+ * in above order (i.e., if value of higher priority is available,
+ * rest of the values are ignored).
  */
 static void init_idedisk_capacity (ide_drive_t  *drive)
 {
+ unsigned long hd_max;
+ unsigned long hd_cap = drive->cyl * drive->head * drive->sect;
+ int is_lba = 0;
+
 	struct hd_driveid *id = drive->id;
-	unsigned long capacity = drive->cyl * drive->head * drive->sect;
 
-	drive->select.b.lba = 0;
+ /* Unless geometry is given by user, use autodetected value */
+ if (! drive->forced_geom) {
+ /* If BIOS LBA geometry is available, use it */
+ if ((id->capability & 2) && lba_capacity_is_ok(id)) {
+ hd_cap = id->lba_capacity;
+ is_lba = 1;
+ }
 
-	/* Determine capacity, and use LBA if the drive properly supports it */
-	if ((id->capability & 2) && lba_capacity_is_ok(id)) {
-		capacity = id->lba_capacity;
-		drive->cyl = capacity / (drive->head * drive->sect);
-		drive->select.b.lba = 1;
+ /* If new ATA feature is supported, try using it */
+ if (idedisk_supports_host_protected_area(drive)) {
+ hd_max = idedisk_read_native_max_address(drive);
+ hd_max = idedisk_set_max_address(drive, hd_max);
+
+ if (hd_max > 0) {
+ hd_cap = hd_max+1;
+ is_lba = 1;
+ }
+ }
 	}
-	drive->capacity = capacity;
+
+ printk("%s: lba = %d, cap = %lu\n", drive->name, is_lba, hd_cap);
+
+ /* update parameters with fetched results */
+ drive->select.b.lba = is_lba;
+ drive->capacity = hd_cap;
+ drive->cyl = hd_cap / (drive->head * drive->sect);
 }
 
 static unsigned long idedisk_capacity (ide_drive_t  *drive)
#2 lore raw
Quoted 2 lines · Eric Lammerts

The kernel part is already there in Andre Hedrick's IDE-patches for 2.2.x and 2.4.x. I don't know why it's not in standard 2.4.x.

suppose first references are to 2.2.x and 2.3.x.

Quoted 2 lines

Patch below is for 2.4.x, extracted from Andre's code. Works For Me(tm).

patch rejected for 2.4.17 kernel. Not Working For Me :-(

--
Salutacions...Josep
http://www.geocities.com/SiliconValley/Horizon/1065/
--

#3 lore raw
In reply to [email protected]
Quoted 4 lines

Good to hear that it works OK. Sooner or later setmax or something similar must become part of the standard kernel, but so far I've gotten almost no feedback. Can you give the disk manufacturer and model (mail [email protected])?

Well, yes, as I had not said it on my previous mail, I'm not putting any geometry or anything like that on lilo, the disk I have now working like that is a 60Gigs Seagate Model=ST340823A which is recogniced by Linux as...

hda: 66055248 sectors (33820 MB) w/512KiB Cache, CHS=4111/255/63, UDMA(33)

Of course after using setmax I can access the hole disk.

I have also tried this on a 80 Gigs Seagate Model=ST380020A and it also works ok.

Regards...

Signature · 1 line
Manty/BestiaTester -> http://manty.net