Skip to contentSkip to conversation

dvd-r detection problem with port multiplier

DISCUSSION Trent George 2 participants 3 messages Sep 27, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Tejun,

Well after 2 days and nights of trying to hack into the driver to figure what is my problem....

I have a fix for me, and an explanation
The problem seemed related to a pioneer drive and bridgeboard

I modified sata_sil24.c with the following addition

in the sil24_do_softreset funtion:

+ void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;

	/* put the port into known state */
	if (sil24_init_port(ap)) {
		reason ="port not ready";
		goto err;
	}

+ ata_wait_register(port + PORT_CTRL_STAT, 0x1f0000,
+ x1f0000, 10, 2000);
+

	/* do SRST */
	ata_tf_init(link->device, &tf);	/* doesn't really matter */

this will wait until the "active slot" of the "port status" field changes from the port mulitpler pmp id of 0x1f (still executing previous command)

it seemed there was a delay from 12 to 84 jiffies for this to clear.

everything works perfect for me now.

sorry I dont know how to post a patch using the correct method.

and I know this is not the "correct" fix, but it is the essence of what needs to be done. This will probablly fix the issue of mixing ATAPI and ATA devices, slow devices or bridgeboards causing reset cycling, and using or not the pmp port 0

Trent

ps: I used this ugly code to see what was happening:
------------

	tmp0 = ata_wait_register(port + PORT_CTRL_STAT,	PORT_CS_RDY,
		0, 10, 10);
	tmp1 = jiffies;
	tmp = ata_wait_register(port + PORT_CTRL_STAT,	0x1f0000,
		0x1f0000, 10, 1000);
	ata_link_printk(link, KERN_ERR, "wait for ready on pmp %d %x %x %d\n ", pmp, tmp0, tmp, jiffies-tmp1);

--------------

Quoted 72 lines

Hello, Trent.

Trent George wrote:
[--snip--]

Quoted 2 lines

I should have mentioned that they have sata to pata bridgeboards on the drives.

That shouldn't change much.

Quoted 4 lines

I tried rebooting, with discs in and not in the drives. I can send you a physical bridgeboard, or drive if it helps you... the samsung hard drive is on the motherboard sata controller. the dvd drives are on pmp on the sata_sil24 board

I have plenty of SATA and PMP hardware these days, so thanks but that wouldn't be necessary.

[--snip--]

Quoted 16 lines

sata_sil24 0000:01:00.0: version 0.3
ACPI: PCI Interrupt 0000:01:00.0[A] -> GSI 16 (level, low) -> IRQ 169
PCI: Setting latency timer of device 0000:01:00.0 to 64
ata3: SATA max UDMA/100 cmd 0xFFFFC20000020000 ctl 0x0 bmdma 0x0 irq 169
ata4: SATA max UDMA/100 cmd 0xFFFFC20000022000 ctl 0x0 bmdma 0x0 irq 169 scsi2 : sata_sil24
sd 0:0:0:0: Attached scsi generic sg0 type 0
ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300) ata3.15: Port Multiplier 1.1, 0x1095:0x3726 r23, 5 ports, feat 0x9/0x9 ata3.00: hard resetting port
ata3.00: softreset failed (timeout)
ata3.00: follow-up softreset failed, retrying in 5 secs ata3.00: hard resetting port
ata3.00: COMRESET failed (errno=3D-16)
ata3.00: reset failed, giving up
ata3.15: hard resetting port

Quoted 8 lines

ata3.15: SATA link up 3.0 Gbps (SStatus 123 SControl 300) ata3.00: hard resetting port
ata3.00: softreset failed (timeout)
ata3.00: follow-up softreset failed, retrying in 5 secs ata3.00: hard resetting port
ata3.00: COMRESET failed (errno=3D-16)
ata3.00: reset failed, giving up
ata3.00: failed to recover link after 2 tries, disabling

Is the first port occupied? 3726 seems to fail initialization if the first port is not occupied. At the moment, I'm not very sure whether the hardware or the driver is responsible for this. When this happens, all other ports fail too which is consistent with your result.

[--snip--]

Quoted 7 lines

sata_sil24 0000:01:00.0: version 0.3
ACPI: PCI Interrupt 0000:01:00.0[A] -> GSI 16 (level, low) -> IRQ 169
PCI: Setting latency timer of device 0000:01:00.0 to 64
ata3: SATA max UDMA/100 cmd 0xFFFFC20000020000 ctl 0x0 bmdma 0x0 irq 169 Losing some ticks... checking if CPU frequency changed.
sd 0:0:0:0: Attached scsi generic sg0 type 0
ata4: SATA max UDMA/100 cmd 0xFFFFC20000022000 ctl 0x0 bmdma 0x0 irq 169

Quoted 8 lines

scsi2 : sata_sil24
ata3: SATA link up 3.0 Gbps (SStatus 123 SControl 300) ata3.00: ATAPI, max UDMA/66
ata3.00: configured for UDMA/66
scsi3 : sata_sil24
ata4: SATA link down (SStatus 0 SControl 300)
Vendor: _NEC Model: DVD_RW ND-3550A Rev: 1.G3
Type: CD-ROM ANSI SCSI revision: 05

Ah... So your ATAPI device is connected to the first port. Can you swap the two and see what happens? Does the same setup work okay on windows?

Thanks for testing.

Signature · 1 line
tejun
#1 lore raw

Hello, Trent.

Quoted 6 lines · Trent George

Hi Tejun,

Well after 2 days and nights of trying to hack into the driver to figure what is my problem....

I have a fix for me, and an explanation
The problem seemed related to a pioneer drive and bridgeboard

I have one px716-sa (embedded bridge board), several PATA odds and an external simg bridge board. All of them work okay with the current code.

Quoted 18 lines

I modified sata_sil24.c with the following addition

in the sil24_do_softreset funtion:

(quoted diff) +1 -0
+	void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
	/* put the port into known state */
	if (sil24_init_port(ap)) {
		reason ="port not ready";
		goto err;
	}
(quoted diff) +3 -0
+	ata_wait_register(port + PORT_CTRL_STAT, 0x1f0000,
+		x1f0000, 10, 2000);
+	
	/* do SRST */
	ata_tf_init(link->device, &tf);	/* doesn't really matter */
Quoted 3 lines

this will wait until the "active slot" of the "port status" field changes from the port mulitpler pmp id of 0x1f (still executing previous command) it seemed there was a delay from 12 to 84 jiffies for this to clear.
everything works perfect for me now.

That's interesting. I guess that's from sil24_clear_pmp(). Maybe that function needs to wait for active slot to change after clearing each port's error condition. Hmm.. wasn't in the spec though.

Quoted 2 lines

sorry I dont know how to post a patch using the correct method.
and I know this is not the "correct" fix, but it is the essence of what needs to be done. This will probablly fix the issue of mixing ATAPI and ATA devices, slow devices or bridgeboards causing reset cycling, and using or not the pmp port 0

So, you're saying that this is the same problem which causes reset failures if port 0 is unoccupied? That's great. Thanks a lot for tracking this problem down.

Quoted 9 lines

ps: I used this ugly code to see what was happening:
------------

	tmp0 = ata_wait_register(port + PORT_CTRL_STAT,	PORT_CS_RDY,
		0, 10, 10);
	tmp1 = jiffies;
	tmp = ata_wait_register(port + PORT_CTRL_STAT,	0x1f0000,
		0x1f0000, 10, 1000);
	ata_link_printk(link, KERN_ERR, "wait for ready on pmp %d %x %x %d\n ", pmp, tmp0, tmp, jiffies-tmp1);

--------------

Pretty enough. :-) I'll investigate into sil24_clear_pmp() and try to merge your fix.

Thanks.

Signature · 1 line
tejun
#2 lore raw

Can you please test the following patch? The spec says that clearing PMP status should be followed by port initialization and I missed that before.

drivers/scsi/sata_sil24.c +7 -5
Index: work1/drivers/scsi/sata_sil24.c
===================================================================
@@ -594,15 +594,17 @@ static int sil24_init_port(struct ata_po
 	struct sil24_port_priv *pp = ap->private_data;
 	u32 tmp;
 
+	if (ap->nr_pmp_links) {
+		/* clear PMP error status */
+		sil24_clear_pmp(ap);
+	}
+
 	writel(PORT_CS_INIT, port + PORT_CTRL_STAT);
 	ata_wait_register(port + PORT_CTRL_STAT,
 			  PORT_CS_INIT, PORT_CS_INIT, 10, 100);
 	tmp = ata_wait_register(port + PORT_CTRL_STAT,
 				PORT_CS_RDY, 0, 10, 100);
 
-	/* clear PMP error status */
-	sil24_clear_pmp(ap);
-
 	if ((tmp & (PORT_CS_INIT | PORT_CS_RDY)) != PORT_CS_RDY) {
 		pp->do_port_rst = 1;
 		ap->link.eh_context.i.action |= ATA_EH_HARDRESET;
@@ -916,12 +918,12 @@ static void sil24_irq_clear(struct ata_p
 static void sil24_pmp_attach(struct ata_port *ap)
 {
 	sil24_config_pmp(ap, 1);
-	sil24_clear_pmp(ap);
+	sil24_init_port(ap);
 }
 
 static void sil24_pmp_detach(struct ata_port *ap)
 {
-	sil24_clear_pmp(ap);
+	sil24_init_port(ap);
 	sil24_config_pmp(ap, 0);
 }