BUG: sata_nv swncq cannot be disabled
Hi,
I stumbled over a bug in the sata_nv swncq code of the current 2.6.23-git kernel. ata_port_info.flags is always initialised with the ATA_FLAG_NCQ flag set, but nv_swncq_host_init(...) is only called if "swncq=1" is passed to the driver (default is swncq=0). I can can observe ata link resets under high load if I don't pass sata_nv.swncq=1 to my kernel.
Former versions of the SWNCQ patch didn't have this problem as ATA_FLAG_NCQ was set in nv_swncq_host_init(...). The appended patch restores this behaviour (or was it changed for a good reason?) We could also simply drop the option to enable/disable swncq.
I'm not subscribed to the list so please CC me on replies.
Gerhard
---
drivers/ata/sata_nv.c +11 -2
@@ -622,8 +622,7 @@ static const struct ata_port_info nv_por/* SWNCQ */ { .sht = &nv_swncq_sht, - .flags =ATA_FLAG_SATA |ATA_FLAG_NO_LEGACY | - ATA_FLAG_NCQ, + .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, .link_flags = ATA_LFLAG_HRST_TO_RESUME, .pio_mask = NV_PIO_MASK, .mwdma_mask = NV_MWDMA_MASK,
@@ -1831,6 +1830,9 @@ static int nv_swncq_port_suspend(struct/* clear irq */ writel (~0 , mmio +NV_INT_STATUS_MCP55 ); +if (!(ap->flags &ATA_FLAG_NCQ )) +return 0 ; +/* disable irq */ writel (0 , mmio +NV_INT_ENABLE_MCP55 );
@@ -1850,6 +1852,9 @@ static int nv_swncq_port_resume(struct a/* clear irq */ writel (~0 , mmio +NV_INT_STATUS_MCP55 ); +if (!(ap->flags &ATA_FLAG_NCQ )) +return 0 ; +/* enable irq */ writel (0x00fd00fd , mmio +NV_INT_ENABLE_MCP55 );
@@ -1867,6 +1872,7 @@ static void nv_swncq_host_init(struct atvoid __iomem *mmio = host->iomap[NV_MMIO_BAR ];struct pci_dev *pdev =to_pci_dev (host->dev);u8 regval; +int i;/* disable ECO 398 */ pci_read_config_byte (pdev,0x7f , ®val);
@@ -1878,6 +1884,9 @@ static void nv_swncq_host_init(struct atVPRINTK ("HOST_CTL:0x%X\n" , tmp);writel (tmp |NV_CTL_PRI_SWNCQ |NV_CTL_SEC_SWNCQ , mmio +NV_CTL_MCP55 ); +for (i =0 ; i < host->n_ports; i++) + host->ports[i]->flags |=ATA_FLAG_NCQ ; +/* enable irq intr */ tmp =readl (mmio +NV_INT_ENABLE_MCP55 );VPRINTK ("HOST_ENABLE:0x%X\n" , tmp);
Quoted 4 lines
Former versions of the SWNCQ patch didn't have this problem as
ATA_FLAG_NCQwas set innv_swncq_host_init(...). The appended patch restores this behaviour (or was it changed for a good reason?) We could also simply drop the option to enable/disable swncq.
Outch - sorry, just found the thread where you're already discussing the problem.
I'm not subscribed to the list so please CC me on replies.
Gerhard
Signature · 2 lines
Gerhard Dirschl PGP-Key-ID: 0x7B95AE94 Germany
Quoted 8 lines · Gerhard Dirschl
Hi,
I stumbled over a bug in the
sata_nvswncq code of the current 2.6.23-git kernel. ata_port_info.flags is always initialised with theATA_FLAG_NCQflag set, butnv_swncq_host_init(...)is only called if "swncq=1" is passed to the driver (default is swncq=0). I can can observe ata link resets under high load if I don't pass sata_nv.swncq=1 to my kernel.
Seeing this, are there any guarantees about SWNCQ and MSI compatibility?
I have sata_nv patched to use MSI, and since SWNCQ patch arrived to
the kernel (and I've enabled it to work around Gerhard's problem) my root filesystem remounts read-only or disk completely disappears every now and then :-(
drivers/ata/sata_nv.c static void nv_swncq_host_init(struct at · line 1892
Quoted 12 lines
drivers/ata/sata_nv.c +3
-0@@ -1878,6 +1884,9 @@ static void nv_swncq_host_init(struct atVPRINTK ("HOST_CTL:0x%X\n" , tmp);writel (tmp |NV_CTL_PRI_SWNCQ |NV_CTL_SEC_SWNCQ , mmio +NV_CTL_MCP55 ); +for (i =0 ; i < host->n_ports; i++) + host->ports[i]->flags |=ATA_FLAG_NCQ ; +/* enable irq intr */ tmp =readl (mmio +NV_INT_ENABLE_MCP55 );VPRINTK ("HOST_ENABLE:0x%X\n" , tmp);
I believe that ATA_FLAG_NCQ should be set before call to ata_pci_prepare_sff_host so you do not play with flags after host was created. I cannot find any other reason...
Petr