Skip to contentSkip to conversation

Mod15Write quirk against v2.6.13

PATCH In review Tejun Heo 3 participants 15 messages Jul 28, 2005 – Aug 23, 2005 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Tejun Heo

author
#1 lore raw

PATCH 1/1 Mod15Write quirk against v2.6.13

Quoted 17 lines · Michael Madore

Hi,

I have been successfully using your mod15write quirk patch with 2.6.12- rc3. I recently applied the patch (with a minor reject) to 2.6.12.3. Reading seems to work fine, but writing to the disk results in the following output:

irq 169: nobody cared!

Call Trace: <IRQ> <ffffffff80161e15>{__report_bad_irq+53}
<ffffffff80161eec>{note_interrupt+92}
       <ffffffff80161730>{__do_IRQ+256} <ffffffff801116b8>{do_IRQ+72}
       <ffffffff8010f057>{ret_from_intr+0}  <EOI>
<ffffffff8010d390>{default_idle+0}
       <ffffffff8010d3b2>{default_idle+34} <ffffffff8010d407>{cpu_idle
+71}
       <ffffffff80515094>{start_secondary+564} 
Quoted 9 lines

handlers:
[<ffffffff88035490>] (ata_interrupt+0x0/0x180 [libata]) [<ffffffff88151440>] (snd_intel8x0_interrupt+0x0/0x240 [snd_intel8x0]) Disabling IRQ #169

Shortly thereafter, there is a kernel oops and the machine has to be rebooted. Do you have an updated driver for 2.6.12? I assume something has changed in libata.

Hello, Michael, again.
Hello, Jeff, Albert & ATA guys.

This is reply message to Michael's private mail reporting patch apply
failure and (after hand-fixing it) malfunction. I hope Michael wouldn't mind adding recipients to this reply.

sata_sil Mod15Write workaround was broken by the following commit by
Albert Lee.

Commit: 21b1ed74ee3667dcabcba92e486988ea9119a085
[PATCH] libata: Prevent the interrupt handler from completing a command twice

This commit clears ATA_QCFLAG_ACTIVE in ata_qc_complete() and doesn't
handle IRQ if ATA_QCFLAG_ACTIVE is cleared on entry to interrupt routine. As m15w workaround executes single command multiple times, the flag is cleared after the first chunk completion and the following interrupt gets ignored resulting in "nobody cared" interrupt error.

The following changes are made in m15w workaround to fix this.

* Moved clearing of ATA_QCFLAG_ACTIVE before invoking ->complete_fn, so that ->complete_fn can mangle with the flag. This doesn't affect any users.
* Added setting ATA_QCFLAG_ACTIVE in m15w chunk completion function.

One thing that bothers me is how Albert's commit and the original
ata_host_intr tell IRQ subsystem that an interrupt isn't ours when we know that we have generated a spurious interrupt. IMHO, we always should enter ata_host_intr and always tell IRQ subsystem that it's our interrupt if bmdma_status tells us so, regardless of ata status value. The current code is likely to cause "nobody cared" error which can be avoided.

Also, Jeff, I know you're very busy, but what do you think about
taking m15w workaround into ata tree? It's been around for a while now and I haven't received any complaints (except for this one) yet. The workaround is ugly but it surely helps and I'm willing to maintain it.

This patch is against v2.6.13-rc3 but also applies to v2.6.12 (with a
fuss).

Thanks.

drivers/scsi/libata-core.c +1 -1
@@ -3087,8 +3087,8 @@ void ata_qc_complete(struct ata_queued_c
 		ata_sg_clean(qc);
 
 	/* call completion callback */
-	rc = qc->complete_fn(qc, drv_stat);
 	qc->flags &= ~ATA_QCFLAG_ACTIVE;
+	rc = qc->complete_fn(qc, drv_stat);
 
 	/* if callback indicates not to complete command (non-zero),
 	 * return immediately
drivers/scsi/sata_sil.c +320 -19

437 lines not on this page · raw message

#2 lore raw
Quoted 5 lines · Tejun Heo

Also, Jeff, I know you're very busy, but what do you think about taking m15w workaround into ata tree? It's been around for a while now and I haven't received any complaints (except for this one) yet. The workaround is ugly but it surely helps and I'm willing to maintain it.

I think your mod15write solution is too messy to deal with long-term. Maintenance burden is much lower on us without it. It's not too difficult to simply avoid certain combinations of hardware.

Note! As Carlos @ Silicon Image points out, the blacklist should only apply to SiI 3112, not 3512/3114/etc. That's an open FIXME that would benefit users.

Quoted 7 lines

One thing that bothers me is how Albert's commit and the original
ata_host_intr tell IRQ subsystem that an interrupt isn't ours when we know that we have generated a spurious interrupt. IMHO, we always should enter ata_host_intr and always tell IRQ subsystem that it's our interrupt if bmdma_status tells us so, regardless of ata status value. The current code is likely to cause "nobody cared" error which can be avoided.

If there is a mismatch between BMDMA's IRQ bit and ATA device indicating an interrupt, that's a host state machine[1] violation that should be addressed elsewhere.

I wouldn't mind using BMDMA IRQ bit as an indicator of the ATA intrq status, though.

(for others) As linked on

	http://www.t13.org/project/d1510r1-Host-Adapter.pdf
		via
	http://linux.yyz.us/sata/devel.html

you can find documentation on the BMDMA IRQ bit.

The main problem with using BMDMA IRQ bit is that it is likely never set unless the commands are READ/WRITE DMA commands, which means we must have separate host state machine tracking for PIO and non-data commands, increasing complexity.

Jeff

[1] "host state machine" These are illustrated by the state machine diagrams in ATA/ATAPI-7 Volume 3, under the chapter headings "Bus idle protocol", "Non-data command protocol", "DMA command protocol", "Ultra DMA data-{in,out} command protocol". STUDY THESE.

author
#3 lore raw

Hello, Jeff.

Quoted 11 lines · Jeff Garzik
Quoted 5 lines · Tejun Heo

Also, Jeff, I know you're very busy, but what do you think about taking m15w workaround into ata tree? It's been around for a while now and I haven't received any complaints (except for this one) yet. The workaround is ugly but it surely helps and I'm willing to maintain it.

I think your mod15write solution is too messy to deal with long-term. Maintenance burden is much lower on us without it. It's not too difficult to simply avoid certain combinations of hardware.

No problem, I'll maintain it out of tree.

Quoted 2 lines

Note! As Carlos @ Silicon Image points out, the blacklist should only apply to SiI 3112, not 3512/3114/etc. That's an open FIXME that would benefit users.

Cool, I'll submit a patch right away.

Quoted 22 lines
Quoted 8 lines

One thing that bothers me is how Albert's commit and the original
ata_host_intr tell IRQ subsystem that an interrupt isn't ours when we know that we have generated a spurious interrupt. IMHO, we always should enter ata_host_intr and always tell IRQ subsystem that it's our interrupt if bmdma_status tells us so, regardless of ata status value. The current code is likely to cause "nobody cared" error which can be avoided.

If there is a mismatch between BMDMA's IRQ bit and ATA device indicating an interrupt, that's a host state machine[1] violation that should be addressed elsewhere.

I wouldn't mind using BMDMA IRQ bit as an indicator of the ATA intrq status, though.

(for others) As linked on

    http://www.t13.org/project/d1510r1-Host-Adapter.pdf
        via
    http://linux.yyz.us/sata/devel.html

you can find documentation on the BMDMA IRQ bit.

Quoted 7 lines

The main problem with using BMDMA IRQ bit is that it is likely never set unless the commands are READ/WRITE DMA commands, which means we must have separate host state machine tracking for PIO and non-data commands, increasing complexity.

Jeff

[1] "host state machine" These are illustrated by the state machine diagrams in ATA/ATAPI-7 Volume 3, under the chapter headings "Bus idle protocol", "Non-data command protocol", "DMA command protocol", "Ultra DMA data-{in,out} command protocol". STUDY THESE.

Yeap, I'll.

Signature · 1 line
tejun
#4 lore raw
Quoted 11 lines · Tejun Heo
Quoted 8 lines · Jeff Garzik
Quoted 5 lines · Tejun Heo

Also, Jeff, I know you're very busy, but what do you think about taking m15w workaround into ata tree? It's been around for a while now and I haven't received any complaints (except for this one) yet. The workaround is ugly but it surely helps and I'm willing to maintain it.

I think your mod15write solution is too messy to deal with long-term. Maintenance burden is much lower on us without it. It's not too difficult to simply avoid certain combinations of hardware.

No problem, I'll maintain it out of tree.

You're welcome to maintain it as an independent branch of libata-dev.git, if you would prefer.

Quoted 3 lines
Quoted 1 line

Note! As Carlos @ Silicon Image points out, the blacklist should only apply to SiI 3112, not 3512/3114/etc. That's an open FIXME that would benefit users.

Cool, I'll submit a patch right away.

Thanks,

Jeff

author
#5 lore raw

Hello, Jeff.

Quoted 13 lines · Jeff Garzik
Quoted 9 lines · Tejun Heo
Quoted 7 lines · Jeff Garzik
Quoted 5 lines · Tejun Heo

Also, Jeff, I know you're very busy, but what do you think about taking m15w workaround into ata tree? It's been around for a while now and I haven't received any complaints (except for this one) yet. The workaround is ugly but it surely helps and I'm willing to maintain it.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I think your mod15write solution is too messy to deal with long-term. Maintenance burden is much lower on us without it. It's not too difficult to simply avoid certain combinations of hardware.

No problem, I'll maintain it out of tree.

You're welcome to maintain it as an independent branch of libata-dev.git, if you would prefer.

I think I'll just keep it out of tree. I don't think many libata
developers would be interested in m15w workaround.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Note! As Carlos @ Silicon Image points out, the blacklist should only apply to SiI 3112, not 3512/3114/etc. That's an open FIXME that would benefit users.

Cool, I'll submit a patch right away.

Can you please tell me which are affected and which are not?

	{ 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
	{ 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
	{ 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
	{ 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
	{ 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
	{ 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
	{ 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },

Thanks.

Signature · 1 line
tejun
#6 lore raw
Quoted 25 lines · Tejun Heo

Hello, Jeff.

Quoted 21 lines · Jeff Garzik
Quoted 17 lines · Tejun Heo
Quoted 9 lines · Jeff Garzik
Quoted 5 lines · Tejun Heo

Also, Jeff, I know you're very busy, but what do you think about taking m15w workaround into ata tree? It's been around for a while now and I haven't received any complaints (except for this one) yet. The workaround is ugly but it surely helps and I'm willing to maintain it.

Quoted 3 lines

I think your mod15write solution is too messy to deal with long-term. Maintenance burden is much lower on us without it. It's not too difficult to simply avoid certain combinations of hardware.

No problem, I'll maintain it out of tree.

Quoted 11 lines
Quoted 3 lines

You're welcome to maintain it as an independent branch of libata-dev.git, if you would prefer.

I think I'll just keep it out of tree. I don't think many libata
developers would be interested in m15w workaround.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Note! As Carlos @ Silicon Image points out, the blacklist should only apply to SiI 3112, not 3512/3114/etc. That's an open FIXME that would benefit users.

Weird, Windows drivers (at least *.INF files) seem to apply workarounds to both 3112 and 3512 while 3114 is OK.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Cool, I'll submit a patch right away.

Can you please tell me which are affected and which are not?

What about fixing 3114 for a start? :-)

Quoted 9 lines
        { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
        { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
        { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
        { 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
        { 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
        { 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
        { 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },

Thanks.

Bartlomiej

author
#7 lore raw

PATCH 1/1 sil: apply M15W quirk selectively

Hello, Jeff & Bartlomiej & all.

Quoted 1 line

What about fixing 3114 for a start? :-)

Yeap, why not? Here it is.
--

This patch adds chipset mask to sil_blacklist such that quirks can be
applied selectively depending on chipset. And add sil_3112_m15w chipset which is identical to sil_3112 except that mod15write quirk is applied. As we don't know which PCI IDs are affected yet, I've changed all 3112's to sil_3112_m15w. Later when we know which PCI IDs are affected, we can just change them to sil_3112 later.

drivers/scsi/sata_sil.c +45 -30
@@ -41,8 +41,10 @@
 #define DRV_VERSION	"0.9"
 
 enum {
-	sil_3112		= 0,
-	sil_3114		= 1,
+	sil_3112_m15w		= (1 << 0),
+	sil_3112		= (1 << 1),
+	sil_3114		= (1 << 2),
+	sil_all			= 0xffffffff,
 
 	SIL_FIFO_R0		= 0x40,
 	SIL_FIFO_W0		= 0x41,
@@ -76,38 +78,39 @@ static void sil_scr_write (struct ata_po
 static void sil_post_set_mode (struct ata_port *ap);
 
 static struct pci_device_id sil_pci_tbl[] = {
-	{ 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
-	{ 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
-	{ 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
+	{ 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
+	{ 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
+	{ 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
 	{ 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
-	{ 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
-	{ 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
-	{ 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
+	{ 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
+	{ 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
+	{ 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
 	{ }	/* terminate list */
 };
 
 
 /* TODO firmware versions should be added - eric */
-static const struct sil_drivelist {
-	const char * product;
+static const struct sil_blacklist {
+	int chipmask;
+	const char * drive;
 	unsigned int quirk;
 } sil_blacklist [] = {
-	{ "ST320012AS",		SIL_QUIRK_MOD15WRITE },
-	{ "ST330013AS",		SIL_QUIRK_MOD15WRITE },
-	{ "ST340017AS",		SIL_QUIRK_MOD15WRITE },
-	{ "ST360015AS",		SIL_QUIRK_MOD15WRITE },
-	{ "ST380013AS",		SIL_QUIRK_MOD15WRITE },
-	{ "ST380023AS",		SIL_QUIRK_MOD15WRITE },
-	{ "ST3120023AS",	SIL_QUIRK_MOD15WRITE },
-	{ "ST3160023AS",	SIL_QUIRK_MOD15WRITE },
-	{ "ST3120026AS",	SIL_QUIRK_MOD15WRITE },
-	{ "ST3200822AS",	SIL_QUIRK_MOD15WRITE },
-	{ "ST340014ASL",	SIL_QUIRK_MOD15WRITE },
-	{ "ST360014ASL",	SIL_QUIRK_MOD15WRITE },
-	{ "ST380011ASL",	SIL_QUIRK_MOD15WRITE },
-	{ "ST3120022ASL",	SIL_QUIRK_MOD15WRITE },
-	{ "ST3160021ASL",	SIL_QUIRK_MOD15WRITE },
-	{ "Maxtor 4D060H3",	SIL_QUIRK_UDMA5MAX },
+	{ sil_3112_m15w, "ST320012AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST330013AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST340017AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST360015AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST380013AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST380023AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST3120023AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST3160023AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST3120026AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST3200822AS",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST340014ASL",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST360014ASL",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST380011ASL",		SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST3120022ASL",	SIL_QUIRK_MOD15WRITE },
+	{ sil_3112_m15w, "ST3160021ASL",	SIL_QUIRK_MOD15WRITE },
+	{ sil_all,	 "Maxtor 4D060H3",	SIL_QUIRK_UDMA5MAX },
 	{ }
 };
 
@@ -165,7 +168,16 @@ static struct ata_port_operations sil_op
 };
 
 static struct ata_port_info sil_port_info[] = {
-	/* sil_3112 */
+	/* sil_3112_m15w, keep it sync'd w/ sil_3112 */
+	{
+		.sht		= &sil_sht,
+		.host_flags	= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+				  ATA_FLAG_SRST | ATA_FLAG_MMIO,
+		.pio_mask	= 0x1f,			/* pio0-4 */
+		.mwdma_mask	= 0x07,			/* mwdma0-2 */
+		.udma_mask	= 0x3f,			/* udma0-5 */
+		.port_ops	= &sil_ops,
+	}, /* sil_3112 */
 	{
 		.sht		= &sil_sht,
 		.host_flags	= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
@@ -309,6 +321,7 @@ static void sil_scr_write (struct ata_po
  */
 static void sil_dev_config(struct ata_port *ap, struct ata_device *dev)
 {
+	int chip = (int)ap->host_set->private_data;
 	unsigned int n, quirks = 0;
 	unsigned char model_num[40];
 	const char *s;
@@ -323,9 +336,10 @@ static void sil_dev_config(struct ata_po
 	while ((len > 0) && (s[len - 1] == ' '))
 		len--;
 
-	for (n = 0; sil_blacklist[n].product; n++)
-		if (!memcmp(sil_blacklist[n].product, s,
-			    strlen(sil_blacklist[n].product))) {
+	for (n = 0; sil_blacklist[n].drive; n++)
+		if ((sil_blacklist[n].chipmask & chip) &&
+		    !memcmp(sil_blacklist[n].drive, s,
+			    strlen(sil_blacklist[n].drive))) {
 			quirks = sil_blacklist[n].quirk;
 			break;
 		}
@@ -403,6 +417,7 @@ static int sil_init_one (struct pci_dev 
        	probe_ent->irq = pdev->irq;
        	probe_ent->irq_flags = SA_SHIRQ;
 	probe_ent->host_flags = sil_port_info[ent->driver_data].host_flags;
+	probe_ent->private_data = (void *)ent->driver_data;
 
 	mmio_base = ioremap(pci_resource_start(pdev, 5),
 		            pci_resource_len(pdev, 5));
#8 lore raw

Re: [PATCH libata:upstream] sil: apply M15W quirk selectively

Quoted 17 lines · Tejun Heo

Hello, Jeff & Bartlomiej & all.

Quoted 1 line

What about fixing 3114 for a start? :-)

Yeap, why not? Here it is.
--

This patch adds chipset mask to sil_blacklist such that quirks can be
applied selectively depending on chipset. And add sil_3112_m15w chipset which is identical to sil_3112 except that mod15write quirk is applied. As we don't know which PCI IDs are affected yet, I've changed all 3112's to sil_3112_m15w. Later when we know which PCI IDs are affected, we can just change them to sil_3112 later.

Quoted 1 line

Thanks for tackling this. I would approach it in a different manner:

1) add to the enum at the top,
+ SIL_FLAG_M15W = (1 << 30),

2) do

        sil_3112                = 0,

- sil_3114 = 1,
+ sil_3112_m15w = 1,
+ sil_3114 = 2,

3) in sil_pci_tbl[], change all the sil_3112 entries to sil_3112_m15w, EXCEPT for PCI ID 0x1095, 0x3512, which should remain sil_3112.

4) in sil_port_info[], duplicate sil_3112 entry to new entry sil_3112_m15w. make sure order in sil_port_info[] array matches the values in step #2.

5) add SIL_FLAG_M15W to the list of host_flags in the new sil_3112_m15w entry created in step #4.

6) in sil_dev_config(), change

       if (quirks & SIL_QUIRK_MOD15WRITE) {

test to also test (ap->flags & SIL_FLAG_M15W)

Check over these steps to see if I missing anything... at the very least, I have illustrated the approach that should be taken.

Jeff

author
#9 lore raw

Re: [PATCH libata:upstream] sil: apply M15W quirk selectively

Hi, Jeff.

My posted patch is broken anyway. I was indexing sil_port_info w/
bit masks. :-(

Quoted 37 lines · Jeff Garzik
Quoted 17 lines · Tejun Heo

Hello, Jeff & Bartlomiej & all.

Quoted 1 line

What about fixing 3114 for a start? :-)

Yeap, why not? Here it is.
--

This patch adds chipset mask to sil_blacklist such that quirks can be applied selectively depending on chipset. And add sil_3112_m15w chipset which is identical to sil_3112 except that mod15write quirk is applied. As we don't know which PCI IDs are affected yet, I've changed all 3112's to sil_3112_m15w. Later when we know which PCI IDs are affected, we can just change them to sil_3112 later.

Quoted 1 line

Thanks for tackling this. I would approach it in a different manner:

1) add to the enum at the top,

(quoted diff) +1 -0
+	SIL_FLAG_M15W		= (1 << 30),

2) do

        sil_3112                = 0,
(quoted diff) +2 -1
-       sil_3114                = 1,
+	sil_3112_m15w		= 1,
+	sil_3114		= 2,

3) in sil_pci_tbl[], change all the sil_3112 entries to sil_3112_m15w, EXCEPT for PCI ID 0x1095, 0x3512, which should remain sil_3112.

Quoted 7 lines

4) in sil_port_info[], duplicate sil_3112 entry to new entry sil_3112_m15w. make sure order in sil_port_info[] array matches the values in step #2.

5) add SIL_FLAG_M15W to the list of host_flags in the new sil_3112_m15w entry created in step #4.

Can we use host_flags for that? It seems that it's for ATA_FLAG_*
flags, and we currently don't explicitly reserve any bits from ATA_FLAG_*.

Quoted 12 lines

6) in sil_dev_config(), change

       if (quirks & SIL_QUIRK_MOD15WRITE) {

test to also test (ap->flags & SIL_FLAG_M15W)

Check over these steps to see if I missing anything... at the very least, I have illustrated the approach that should be taken.

Jeff

Thanks.

Signature · 1 line
tejun
#10 lore raw

Re: [PATCH libata:upstream] sil: apply M15W quirk selectively

Quoted 8 lines · Tejun Heo
Quoted 3 lines · Jeff Garzik

Tejun Heo wrote:

5) add SIL_FLAG_M15W to the list of host_flags in the new sil_3112_m15w entry created in step #4.

Can we use host_flags for that? It seems that it's for ATA_FLAG_*
flags, and we currently don't explicitly reserve any bits from ATA_FLAG_*.

The drivers are free to use the upper bits of ap->flags for their own purposes. ata_piix.c is an example of this, with PIIX_FLAG_xxx.

We can worry about bitspace collision when libata general flags and driver-specific flags get so numerous its a problem.

Jeff

author
#11 lore raw

Re: [PATCH libata:upstream] sil: apply M15W quirk selectively (take 2)

In reply to Tejun Heo

As SII reports that only original 3112's are affected by M15W quirk,
This patch adds SIL_FLAG_MOD15WRITE to selectively apply M15W quirk depending on chipsets. As of yet, we don't know exactly which PCI IDs are for original 3112, so M15W quirk is applied to all except for 3512 and 3124. Once more info is avaliable, we can change some of these sil_3112_m15w's to sil_3112.

drivers/scsi/sata_sil.c +20 -7
@@ -41,8 +41,11 @@
 #define DRV_VERSION	"0.9"
 
 enum {
+	SIL_FLAG_MOD15WRITE	= (1 << 30),
+
 	sil_3112		= 0,
-	sil_3114		= 1,
+	sil_3112_m15w		= 1,
+	sil_3114		= 2,
 
 	SIL_FIFO_R0		= 0x40,
 	SIL_FIFO_W0		= 0x41,
@@ -76,13 +79,13 @@ static void sil_scr_write (struct ata_po
 static void sil_post_set_mode (struct ata_port *ap);
 
 static struct pci_device_id sil_pci_tbl[] = {
-	{ 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
-	{ 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
+	{ 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
+	{ 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
 	{ 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
 	{ 0x1095, 0x3114, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3114 },
-	{ 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
-	{ 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
-	{ 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
+	{ 0x1002, 0x436e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
+	{ 0x1002, 0x4379, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
+	{ 0x1002, 0x437a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
 	{ }	/* terminate list */
 };
 
@@ -174,6 +177,16 @@ static struct ata_port_info sil_port_inf
 		.mwdma_mask	= 0x07,			/* mwdma0-2 */
 		.udma_mask	= 0x3f,			/* udma0-5 */
 		.port_ops	= &sil_ops,
+	}, /* sil_3112_15w - keep it sync'd w/ sil_3112 */
+	{
+		.sht		= &sil_sht,
+		.host_flags	= ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+				  ATA_FLAG_SRST | ATA_FLAG_MMIO |
+				  SIL_FLAG_MOD15WRITE,
+		.pio_mask	= 0x1f,			/* pio0-4 */
+		.mwdma_mask	= 0x07,			/* mwdma0-2 */
+		.udma_mask	= 0x3f,			/* udma0-5 */
+		.port_ops	= &sil_ops,
 	}, /* sil_3114 */
 	{
 		.sht		= &sil_sht,
@@ -331,7 +344,7 @@ static void sil_dev_config(struct ata_po
 		}
 
 	/* limit requests to 15 sectors */
-	if (quirks & SIL_QUIRK_MOD15WRITE) {
+	if (ap->flags & SIL_FLAG_MOD15WRITE && quirks & SIL_QUIRK_MOD15WRITE) {
 		printk(KERN_INFO "ata%u(%u): applying Seagate errata fix\n",
 		       ap->id, dev->devno);
 		ap->host->max_sectors = 15;
Applied
#12 lore raw

Re: [PATCH libata:upstream] sil: apply M15W quirk selectively (take 2)

applied

#13 lore raw
In reply to Tejun Heo
Quoted 23 lines · Tejun Heo

sata_sil Mod15Write workaround was broken by the following commit by
Albert Lee.

Commit: 21b1ed74ee3667dcabcba92e486988ea9119a085
[PATCH] libata: Prevent the interrupt handler from completing a command twice

This commit clears ATA_QCFLAG_ACTIVE in ata_qc_complete() and doesn't
handle IRQ if ATA_QCFLAG_ACTIVE is cleared on entry to interrupt routine. As m15w workaround executes single command multiple times, the flag is cleared after the first chunk completion and the following interrupt gets ignored resulting in "nobody cared" interrupt error.

The following changes are made in m15w workaround to fix this.

* Moved clearing of ATA_QCFLAG_ACTIVE before invoking ->complete_fn, so that ->complete_fn can mangle with the flag. This doesn't affect any users.
* Added setting ATA_QCFLAG_ACTIVE in m15w chunk completion function.

drivers/scsi/libata-core.c void ata_qc_complete(struct ata_queued_c · line 3094

Quoted 9 lines
drivers/scsi/libata-core.c +1 -1
@@ -3087,8 +3087,8 @@ void ata_qc_complete(struct ata_queued_c
 		ata_sg_clean(qc);
 
 	/* call completion callback */
-	rc = qc->complete_fn(qc, drv_stat);
 	qc->flags &= ~ATA_QCFLAG_ACTIVE;
+	rc = qc->complete_fn(qc, drv_stat);
 
 	/* if callback indicates not to complete command (non-zero),
 	 * return immediately

I'm leaning towards applying latest Albert's ATA_QCFLAG_ACTIVE fix, which does the same thing your patch did.

For various complex tasks in the SCSI translation layer (SAT), we may wish to issue multiple ATA commands, before signalling completion. As your mod15write patch is an example of this, it helps point out what parts of libata need work in order to accomplish this.

Any comments before I apply Albert's patch?

Jeff

author
#14 lore raw

Hi, Jeff.

Quoted 40 lines · Jeff Garzik
Quoted 24 lines · Tejun Heo

sata_sil Mod15Write workaround was broken by the following commit by
Albert Lee.

Commit: 21b1ed74ee3667dcabcba92e486988ea9119a085
[PATCH] libata: Prevent the interrupt handler from completing a command twice

This commit clears ATA_QCFLAG_ACTIVE in ata_qc_complete() and doesn't
handle IRQ if ATA_QCFLAG_ACTIVE is cleared on entry to interrupt routine. As m15w workaround executes single command multiple times, the flag is cleared after the first chunk completion and the following interrupt gets ignored resulting in "nobody cared" interrupt error.

The following changes are made in m15w workaround to fix this.

* Moved clearing of ATA_QCFLAG_ACTIVE before invoking ->complete_fn, so that ->complete_fn can mangle with the flag. This doesn't affect any users.
* Added setting ATA_QCFLAG_ACTIVE in m15w chunk completion function.

drivers/scsi/libata-core.c void ata_qc_complete(struct ata_queued_c · line 3094

Quoted 9 lines
drivers/scsi/libata-core.c +1 -1
@@ -3087,8 +3087,8 @@ void ata_qc_complete(struct ata_queued_c
         ata_sg_clean(qc);
 
     /* call completion callback */
-    rc = qc->complete_fn(qc, drv_stat);
     qc->flags &= ~ATA_QCFLAG_ACTIVE;
+    rc = qc->complete_fn(qc, drv_stat);
 
     /* if callback indicates not to complete command (non-zero),
      * return immediately

I'm leaning towards applying latest Albert's ATA_QCFLAG_ACTIVE fix, which does the same thing your patch did.

Quoted 4 lines

For various complex tasks in the SCSI translation layer (SAT), we may wish to issue multiple ATA commands, before signalling completion. As your mod15write patch is an example of this, it helps point out what parts of libata need work in order to accomplish this.

Any comments before I apply Albert's patch?

I think the following patch I've posted deal with the same problem.

http://marc.theaimsgroup.com/?l=linux-ide&m=112454734102242&w=2

Which, I think, is a better way to fix it. It's dependant on the
previous patchset you've just NAK'ed, so it cannot be applied but please take a look. The base of the problem is that we run both ata_qc_complete and EH concurrently.

Signature · 1 line
tejun
#15 lore raw
Quoted 47 lines · Tejun Heo

Hi, Jeff.

Quoted 42 lines · Jeff Garzik
Quoted 25 lines · Tejun Heo

sata_sil Mod15Write workaround was broken by the following commit by
Albert Lee.

Commit: 21b1ed74ee3667dcabcba92e486988ea9119a085
[PATCH] libata: Prevent the interrupt handler from completing a command twice

This commit clears ATA_QCFLAG_ACTIVE in ata_qc_complete() and doesn't
handle IRQ if ATA_QCFLAG_ACTIVE is cleared on entry to interrupt routine. As m15w workaround executes single command multiple times, the flag is cleared after the first chunk completion and the following interrupt gets ignored resulting in "nobody cared" interrupt error.

The following changes are made in m15w workaround to fix this.

* Moved clearing of ATA_QCFLAG_ACTIVE before invoking ->complete_fn, so that ->complete_fn can mangle with the flag. This doesn't affect any users.
* Added setting ATA_QCFLAG_ACTIVE in m15w chunk completion function.

drivers/scsi/libata-core.c void ata_qc_complete(struct ata_queued_c · line 3094

Quoted 9 lines
drivers/scsi/libata-core.c +1 -1
@@ -3087,8 +3087,8 @@ void ata_qc_complete(struct ata_queued_c
         ata_sg_clean(qc);
 
     /* call completion callback */
-    rc = qc->complete_fn(qc, drv_stat);
     qc->flags &= ~ATA_QCFLAG_ACTIVE;
+    rc = qc->complete_fn(qc, drv_stat);
 
     /* if callback indicates not to complete command (non-zero),
      * return immediately

I'm leaning towards applying latest Albert's ATA_QCFLAG_ACTIVE fix, which does the same thing your patch did.

Quoted 8 lines
Quoted 4 lines

For various complex tasks in the SCSI translation layer (SAT), we may wish to issue multiple ATA commands, before signalling completion. As your mod15write patch is an example of this, it helps point out what parts of libata need work in order to accomplish this.

Any comments before I apply Albert's patch?

I think the following patch I've posted deal with the same problem.

http://marc.theaimsgroup.com/?l=linux-ide&m=112454734102242&w=2

In the SCSI translation layer (SAT), some simulation may require issuing multiple ATA commands, before indicating a completion to the upper layers. That capability is something I definitely want libata to support. Your mod15write patch is an excellent example of this, even though I NAK'd it due to long term sata_sil maintenance burden.

That's why I think move ATA_QCFLAG_ACTIVE -anyway- may be a good idea.

Jeff