Re: Early ATA devices

2007-08-15 Thread Erik Mouw
On Thu, Aug 02, 2007 at 09:47:06PM +0100, Alan Cox wrote:
   So in theory we can persuade libata to drive original MFM/RLL disks with
   relatively few changes
  
  Does anyone have a working device to test?
 
 I'm currently testing a 40MB pre-ATA IDE drive and with the LBA/non-LBA
 fix I sent to Andrew and the 'its ancient, its PIO  2 who cares if
 SETXFER isn't a known command' patch likewise it is running.
 
 That one has a pre-ATA version of identify however. Not yet found one
 without to play with

FWIW, I have a Seagate ST225 (still zero bad blocks) with controller.
If I can persuade the old 386 to do a netboot I can test it.


Erik
(sorry for the late reply, BTW)

-- 
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery


signature.asc
Description: Digital signature


Re: Early ATA devices

2007-08-15 Thread Alan Cox
 FWIW, I have a Seagate ST225 (still zero bad blocks) with controller.
 If I can persuade the old 386 to do a netboot I can test it.

Right now it'll fail on the identify (may fail earlier on the reset
signature test actually).

Alan

-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Early ATA devices

2007-08-02 Thread Alan Cox
  So in theory we can persuade libata to drive original MFM/RLL disks with
  relatively few changes
 
 Does anyone have a working device to test?

I'm currently testing a 40MB pre-ATA IDE drive and with the LBA/non-LBA
fix I sent to Andrew and the 'its ancient, its PIO  2 who cares if
SETXFER isn't a known command' patch likewise it is running.

That one has a pre-ATA version of identify however. Not yet found one
without to play with

Alan
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Early ATA devices

2007-08-01 Thread Tejun Heo
Alan Cox wrote:
 So I've been doing a scan of the code versus the early ATA specifications
 (English translation not the original Latin ;))
 
 I've found a couple of problem cases we don't deal with but I'm not sure
 matter, and an inconsistency
 
 #1We assume identify works. Early ATA actually lists this command
 as optional
 #2We don't allow for INIT_DEV_PARAMS failing which it may do on
 some early IDE pre ATA devices
 
 and the inconsistency
 
 We check ATA  4 || non-LBA capable when deciding whether to issue
 INIT_DEV_PARAMS. ATA 4+ however mandate LBA so the second case isn't
 theoretically at least possible.
 
 Aside from those cases the command issue (but not the detection paths)
 appear to be clean for everything from ST412 upwards providing a drive is
 being used in 16 head mode and does its own write precompensation
 selection.
 
 So in theory we can persuade libata to drive original MFM/RLL disks with
 relatively few changes

Does anyone have a working device to test?

-- 
tejun
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Early ATA devices

2007-08-01 Thread Jeff Garzik

Alan Cox wrote:

#1  We assume identify works. Early ATA actually lists this command
as optional


ITYM we assume identify command exists on the device?

We certainly do not assume IDENTIFY command, if exists, succeeds.

What is the proper probing method -- notice if command-aborted is 
returned and do something from there?




#2  We don't allow for INIT_DEV_PARAMS failing which it may do on
some early IDE pre ATA devices


Suggested handling?  Ignore device, since we don't know what state its 
in, if this fails?




We check ATA  4 || non-LBA capable when deciding whether to issue
INIT_DEV_PARAMS. ATA 4+ however mandate LBA so the second case isn't
theoretically at least possible.


I agree, though I figured that the current code was more robust, in case 
some weirdo device decided to forget its LBA-ness.


No strong opinions here, though.



So in theory we can persuade libata to drive original MFM/RLL disks with
relatively few changes


Crazy :)

Jeff



-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Early ATA devices

2007-08-01 Thread Alan Cox
On Wed, 01 Aug 2007 09:47:49 -0400
Jeff Garzik [EMAIL PROTECTED] wrote:

 Alan Cox wrote:
  #1  We assume identify works. Early ATA actually lists this command
  as optional
 
 ITYM we assume identify command exists on the device?
 
 We certainly do not assume IDENTIFY command, if exists, succeeds.

We assume that it exists and that it will succeed. In any other situation
we skip the device.
 
 What is the proper probing method -- notice if command-aborted is 
 returned and do something from there?

Yes. A good question is what as we then don't know geometry. I know
understand how PC BIOS geometry reporting works in detail so one option
is to write a drivers/firmware/pc_geometry.c library which knows how to
handle this crap for us. Thankfully any even prehistoric might still boot
Linux PC should have EDD2.0 and anything older we care about FDPT tables.

We'd end up with an API something like

int pcgeo_get_geometry_isa(ioport, devno, struct ...)
int pcgeo_get_geometry_pci(pci_dev, devno, )

which means we can also push user configuration of geometry into that
module and share it between hd, oldide, old scsi, whatever.

[and this stuff is more screwed up than IDE ...]

  #2  We don't allow for INIT_DEV_PARAMS failing which it may do on
  some early IDE pre ATA devices
 
 Suggested handling?  Ignore device, since we don't know what state its 
 in, if this fails?

I stuck a test patch in my tree and emulating this sequence it works to
just skip the aborted command. A drive which lacks this is fixed geometry
so the geometry we want to set is already set and a failure is
meaningless (which is different to an early ATA drive which may have
multiple emulated geometries).

Alan
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Early ATA devices

2007-08-01 Thread Alan Cox
  So in theory we can persuade libata to drive original MFM/RLL disks with
  relatively few changes
 
 Crazy :)

Would look something like this (but with geometry handling and some setup
work)

/**
 *  An original IDE/ST412/ST506 driver for libata
 *
 *  Information for hardware archeologists
 *  - IDE is the original pre ATA and 'EIDE' specification interface
 *emulating ST412 with some oddments nailed on
 *  - ST412 is the normal PC/AT attachment
 *  - ST506 is the prehistoric version
 *
 *  This driver will not (currently) handle ST506 unless you set the
 *  precomp value. Nor will it handle the original '8 head' protocol, nor
 *  drives not capable of the 35uS stepper rate. I might fix this for
 *  fun one day if I can find an old enough drive that still works 
 *
 *  How we work the compatibility ATA to ST412
 *  --
 *
 *  Mostly this works as pass through to libata as IDE and ATA were
 *  designed to be compatible in the IDE-ATA direction. The ST412
 *  interface ctrl register maps to the ATA ctl register (which is why it
 *  has lots of 'obsolete' bits). nIEN and SRST map to the IRQ mask
 *  bit on the controller and the controller soft reset.
 *
 *  Original IDE works on the same command set as ST412 as far as we
 *  care (we don't do formatting etc). Some later IDE drives insist
 *  that we tell them their geometry (Initialize Drive) and they also
 *  support better error handling (DIAGNOSE), but we can do that as
 *  it'll just get rejected by the MFM era controller.
 *
 *  The drive select is also cunning arranged so that '512 bytes with ECC'
 *  to the controller is in fact 0xA0 (aka the 'obsolete' bits in ATA)
 *
 *  The big limit on original IDE is that only the BIOS knows the c/h/s
 *  parameters for the drive. For MFM/RLL you can sneak a peek at the
 *  partition table and guess but not alas for early IDE as it requires
 *  you set the geometry before it'll let you look!
 *
 *  ST506
 *  -
 *
 *  ST506 requires we set 8 v 16 heads correctly and that we provide
 *  write precomp and a couple of other additional values. If you have
 *  a specific application involving rescuing such an ancient disk in
 *  a lab somewhere then let me know, although its probably easier and
 *  safer to read a disk that old in a data recovery lab
 */

#include linux/kernel.h
#include linux/module.h
#include linux/pci.h
#include linux/init.h
#include linux/blkdev.h
#include linux/delay.h
#include scsi/scsi_host.h
#include linux/libata.h
#include linux/platform_device.h

#define DRV_NAME pata_hd
#define DRV_VERSION 0.0.1

#define NR_HOST 2

struct platform_device *atahd_device[NR_HOST];
static struct ata_host *atahd_host[NR_HOST];

struct atahd_disk {
/* Geometry for faking IDENTIFY */
u16 cyls;
u8 heads;
u8 sectors;
/* Not currently supported - 35uS always used */
u8 seekrate;
/* Precompensation for older ST506 */
u8 wprecomp;
unsigned int legacy:1;  /* Drive is actually ATA-1+ */
unsigned int ide:1; /* Drive is original IDE */
unsigned int lba:1; /* Original IDE in LBA mode */
u8 bios_ident;  /* BIOS id of drive */
}

static struct atahd_param {
struct atahd_disk param[2]; /* Drive parameters */
int device; /* Tracking current device */
int present;/* Mask of present devices */
};

static struct atahd_param atahd_param[NR_HOST];
static int nr_atahd_host;
static int bios_ident = 0x80;

/**
 *  atahd_tf_load - send taskfile registers to host controller
 *  @ap: Port to which output is sent
 *  @tf: ATA taskfile register set
 *
 *  Outputs ATA taskfile to ST506/414 host controller.
 *
 *  LOCKING:
 *  Inherited from caller.
 */

void atahd_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
{
struct ata_ioports *ioaddr = ap-ioaddr;
unsigned int is_addr = tf-flags  ATA_TFLAG_ISADDR;

if (!p-param[p-device].legacy) {
ata_tf_load(ap, tf);
return;
}

if (tf-ctl != ap-last_ctl) {
iowrite8(tf-ctl, ioaddr-ctl_addr);
ap-last_ctl = tf-ctl;
ata_wait_idle(ap);
}
if (is_addr) {
/* ST-506 requires the precomp value is loaded, ST-412, IDE
   and later it is done by the drive. This causes no problem
   for ST-506 driving IDE but for IDE driving ST we need to
   fill in the blanks. Later ST-506 drives don't generally
   use the hardware precomp signal either */
if (p-param[p-device].wprecomp)
iowrite8(p-param[p.device].wprecomp, 
ioaddr-feature_addr);
else

Early ATA devices

2007-07-31 Thread Alan Cox
So I've been doing a scan of the code versus the early ATA specifications
(English translation not the original Latin ;))

I've found a couple of problem cases we don't deal with but I'm not sure
matter, and an inconsistency

#1  We assume identify works. Early ATA actually lists this command
as optional
#2  We don't allow for INIT_DEV_PARAMS failing which it may do on
some early IDE pre ATA devices

and the inconsistency

We check ATA  4 || non-LBA capable when deciding whether to issue
INIT_DEV_PARAMS. ATA 4+ however mandate LBA so the second case isn't
theoretically at least possible.

Aside from those cases the command issue (but not the detection paths)
appear to be clean for everything from ST412 upwards providing a drive is
being used in 16 head mode and does its own write precompensation
selection.

So in theory we can persuade libata to drive original MFM/RLL disks with
relatively few changes
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html