linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]: pcmcia - spot slave decode flaws (for testing)
@ 2007-02-20 18:18 Alan
  2007-02-23 10:44 ` Jeff Garzik
  0 siblings, 1 reply; 4+ messages in thread
From: Alan @ 2007-02-20 18:18 UTC (permalink / raw)
  To: jgarzik, linux-kernel, linux-ide

If you've got a CF adapter or PCMCIA disc which shows up twice in libata
pata_pcmcia can you try this patch on top of the updates posted. It tries
to spot when the slave is a mirror of the master and to fix up problems
that causes.

Signed-off-by: Alan Cox <alan@redhat.com>

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.20-mm2/drivers/ata/pata_pcmcia.c linux-2.6.20-mm2/drivers/ata/pata_pcmcia.c
--- linux.vanilla-2.6.20-mm2/drivers/ata/pata_pcmcia.c	2007-02-20 13:37:58.000000000 +0000
+++ linux-2.6.20-mm2/drivers/ata/pata_pcmcia.c	2007-02-20 14:28:13.000000000 +0000
@@ -54,6 +54,39 @@
 	dev_node_t	node;
 };
 
+/**
+ *	pcmcia_set_mode	-	PCMCIA specific mode setup
+ *	@ap: Port
+ *	@r_failed_dev: Return pointer for failed device
+ *
+ *	Perform the tuning and setup of the devices and timings, which
+ *	for PCMCIA is the same as any other controller. We wrap it however
+ *	as we need to spot hardware with incorrect or missing master/slave
+ *	decode, which alas is embarrassingly common in the PC world
+ */
+ 
+static int pcmcia_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
+{
+	struct ata_device *master = &ap->device[0];
+	struct ata_device *slave = &ap->device[1];
+	
+	if (!ata_dev_enabled(master) || !ata_dev_enabled(slave))
+		return ata_do_set_mode(ap, r_failed_dev);
+		
+	if (memcmp(master->id + ATA_ID_FW_REV,  slave->id + ATA_ID_FW_REV,
+			   ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0)
+	{
+		/* Suspicious match, but could be two cards from
+		   the same vendor - check serial */
+		if (memcmp(master->id + ATA_ID_SERNO, slave->id + ATA_ID_SERNO,
+			   ATA_ID_SERNO_LEN) == 0 && master->id[ATA_ID_SERNO] >> 8) {
+			ata_dev_printk(slave, KERN_WARNING, "is a ghost device, ignoring.\n");
+			ata_dev_disable(slave);
+		}	 
+	}
+	return ata_do_set_mode(ap, r_failed_dev);
+}
+
 static struct scsi_host_template pcmcia_sht = {
 	.module			= THIS_MODULE,
 	.name			= DRV_NAME,
@@ -73,6 +106,7 @@
 };
 
 static struct ata_port_operations pcmcia_port_ops = {
+	.set_mode	= pcmcia_set_mode,
 	.port_disable	= ata_port_disable,
 	.tf_load	= ata_tf_load,
 	.tf_read	= ata_tf_read,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: pcmcia - spot slave decode flaws (for testing)
  2007-02-20 18:18 [PATCH]: pcmcia - spot slave decode flaws (for testing) Alan
@ 2007-02-23 10:44 ` Jeff Garzik
  2007-02-23 12:08   ` Alan
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2007-02-23 10:44 UTC (permalink / raw)
  To: Alan; +Cc: linux-kernel, linux-ide

Alan wrote:
> If you've got a CF adapter or PCMCIA disc which shows up twice in libata
> pata_pcmcia can you try this patch on top of the updates posted. It tries
> to spot when the slave is a mirror of the master and to fix up problems
> that causes.
> 
> Signed-off-by: Alan Cox <alan@redhat.com>
> 
> diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.20-mm2/drivers/ata/pata_pcmcia.c linux-2.6.20-mm2/drivers/ata/pata_pcmcia.c
> --- linux.vanilla-2.6.20-mm2/drivers/ata/pata_pcmcia.c	2007-02-20 13:37:58.000000000 +0000
> +++ linux-2.6.20-mm2/drivers/ata/pata_pcmcia.c	2007-02-20 14:28:13.000000000 +0000
> @@ -54,6 +54,39 @@
>  	dev_node_t	node;
>  };
>  
> +/**
> + *	pcmcia_set_mode	-	PCMCIA specific mode setup
> + *	@ap: Port
> + *	@r_failed_dev: Return pointer for failed device
> + *
> + *	Perform the tuning and setup of the devices and timings, which
> + *	for PCMCIA is the same as any other controller. We wrap it however
> + *	as we need to spot hardware with incorrect or missing master/slave
> + *	decode, which alas is embarrassingly common in the PC world
> + */
> + 
> +static int pcmcia_set_mode(struct ata_port *ap, struct ata_device **r_failed_dev)
> +{
> +	struct ata_device *master = &ap->device[0];
> +	struct ata_device *slave = &ap->device[1];
> +	
> +	if (!ata_dev_enabled(master) || !ata_dev_enabled(slave))
> +		return ata_do_set_mode(ap, r_failed_dev);
> +		
> +	if (memcmp(master->id + ATA_ID_FW_REV,  slave->id + ATA_ID_FW_REV,
> +			   ATA_ID_FW_REV_LEN + ATA_ID_PROD_LEN) == 0)
> +	{
> +		/* Suspicious match, but could be two cards from
> +		   the same vendor - check serial */
> +		if (memcmp(master->id + ATA_ID_SERNO, slave->id + ATA_ID_SERNO,
> +			   ATA_ID_SERNO_LEN) == 0 && master->id[ATA_ID_SERNO] >> 8) {
> +			ata_dev_printk(slave, KERN_WARNING, "is a ghost device, ignoring.\n");
> +			ata_dev_disable(slave);
> +		}	 
> +	}
> +	return ata_do_set_mode(ap, r_failed_dev);

Code looks OK. Not applied due to "for testing" note.

General comment:  it might be nice to do this in the core, just as a 
sanity check for a variety of problems, past, present and future.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: pcmcia - spot slave decode flaws (for testing)
  2007-02-23 10:44 ` Jeff Garzik
@ 2007-02-23 12:08   ` Alan
  2007-02-24 21:23     ` Eric D. Mudama
  0 siblings, 1 reply; 4+ messages in thread
From: Alan @ 2007-02-23 12:08 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-kernel, linux-ide

> Code looks OK. Not applied due to "for testing" note.
> 
> General comment:  it might be nice to do this in the core, just as a 
> sanity check for a variety of problems, past, present and future.

We tried that with old IDE and all hell broke loose. Lots of virtual disk
stuff and raid volumes have non-unique serial numbers. We even found a
case of identically serial numbered Maxtor drives.

It needs to stay in pcmcia, which is the only place we've seen the
duplication.



Alan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]: pcmcia - spot slave decode flaws (for testing)
  2007-02-23 12:08   ` Alan
@ 2007-02-24 21:23     ` Eric D. Mudama
  0 siblings, 0 replies; 4+ messages in thread
From: Eric D. Mudama @ 2007-02-24 21:23 UTC (permalink / raw)
  To: Alan; +Cc: Jeff Garzik, linux-kernel, linux-ide

On 2/23/07, Alan <alan@lxorguk.ukuu.org.uk> wrote:
> > Code looks OK. Not applied due to "for testing" note.
> >
> > General comment:  it might be nice to do this in the core, just as a
> > sanity check for a variety of problems, past, present and future.
>
> We tried that with old IDE and all hell broke loose. Lots of virtual disk
> stuff and raid volumes have non-unique serial numbers. We even found a
> case of identically serial numbered Maxtor drives.
>
> It needs to stay in pcmcia, which is the only place we've seen the
> duplication.

I don't think the maxtor drives actually had duplicate serial numbers.
 They were coming back as "M0000000000000000000" or something like
that to the limit of the strlen.  It looked more like buffer
corruption or something, and only happened with one or two people...

--eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-02-24 21:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-20 18:18 [PATCH]: pcmcia - spot slave decode flaws (for testing) Alan
2007-02-23 10:44 ` Jeff Garzik
2007-02-23 12:08   ` Alan
2007-02-24 21:23     ` Eric D. Mudama

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).