RE: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-10-14 Thread Kuan Luo
Jeff wrote:
> Kuan Luo wrote:
> > One idea,  only simply adding 
> > if (!swncq_enabled) 
> > nv_port_info[SWNCQ].flags &= ~ATA_FLAG_NCQ;
> > 
> > ppi[0] = &nv_port_info[type];
> > rc = ata_pci_prepare_sff_host(pdev, ppi, &host);
> > 
> > I don't know if this is appropriate
> 
> 
> As long as the structure is not read-only ('const'), that is OK.
> 
> And just for future reference, make sure you're aware of the 
> implications of this applying to all sata_nv-aware PCI IDs.  If you 
> present multiple SATA devices on a PCI bus, or have multiple 
> PCI cards 
> (rare in NV's case, I guess) the probe function will be 
> called multiple 
> times.  You might even want to put that code into the module init 
> function, rather than the probe function.
> 
>   Jeff
> 
> 
My idea is not comprehensive.
Your analysis are reasonable.
Then you may apply either method in previous mail.

Jeff wrote
>   if (type == SWNCQ && !swncq_enabled)
>   type = GENERIC;
>
>Or, if you prefer, we could take the opposite route, _not_ set SWNCQ in

>the pci_device_id table, and instead do something like
>
>   if (type >= MCP65 && swncq_enabled)
>   type = SWNCQ;
>
>(MCP65 is just a pulled-out-of-thin-air example)
>
>Regards,
>
>   Jeff
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-10-12 Thread Jeff Garzik

Kuan Luo wrote:
One idea,  only simply adding 
	if (!swncq_enabled) 
		nv_port_info[SWNCQ].flags &= ~ATA_FLAG_NCQ;


ppi[0] = &nv_port_info[type];
rc = ata_pci_prepare_sff_host(pdev, ppi, &host);

I don't know if this is appropriate



As long as the structure is not read-only ('const'), that is OK.

And just for future reference, make sure you're aware of the 
implications of this applying to all sata_nv-aware PCI IDs.  If you 
present multiple SATA devices on a PCI bus, or have multiple PCI cards 
(rare in NV's case, I guess) the probe function will be called multiple 
times.  You might even want to put that code into the module init 
function, rather than the probe function.


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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-10-03 Thread Peer Chen
Jeff,
Is it possible this patch appear in mainline kernel 2.6.24? 


BRs
Peer Chen

-Original Message-
From: Kuan Luo 
Sent: Thursday, September 27, 2007 4:55 PM
To: 'Jeff Garzik'
Cc: Zoltan Boszormenyi; [EMAIL PROTECTED]; Peer Chen; Robert
Hancock; linux-ide@vger.kernel.org
Subject: RE: [patch 05/25] ata: add the SW NCQ support to sata_nv for
MCP51/MCP55/MCP61

 Jeff Garzik wrote:
> Kuan Luo wrote:
> > Jeff Garzik wrote:
> >> Kuan Luo wrote:
> >>> hi,
> >>> i saw the below changes  from
> >>>
> >> http://git.kernel.org/?p=linux/kernel/git/jgarzik/libata-dev.g
> >> it;a=commi
> >>> tdiff;h=5a5a9e1890b8260686218a68862d880daee1a817
> >>>
> >>> [libata] sata_nv: Clean up ATA_FLAG_NCQ usage; bit test micro-opt
> >>>
> >>>  @@ -622,7 +622,9 @@ static const struct ata_port_info
> >> nv_port_info[] =
> >>> {
> >>> /* SWNCQ */
> >>> {
> >>> .sht= &nv_swncq_sht,
> >>> -   .flags  = ATA_FLAG_SATA | 
> >> ATA_FLAG_NO_LEGACY,
> >>> +   .flags  = ATA_FLAG_SATA | 
> >> ATA_FLAG_NO_LEGACY |
> >>> + ATA_FLAG_NCQ,
> >>> +   .link_flags = ATA_LFLAG_HRST_TO_RESUME,
> >>> .pio_mask   = NV_PIO_MASK,
> >>> .mwdma_mask = NV_MWDMA_MASK,
> >>> .udma_mask  = NV_UDMA_MASK,
> >>>
> >>> If swncq_enabled is set zero by user, nv_swncq_host_init
> >> would not be
> >>> called .
> >>>  Then ncq should be disabled and the libata shouldn't
> send ncq cmd. 
> >>>  I am not sure whether the  ATA_FLAG_NCQ flag which is in
> >> default set
> >>> makes libata send ncq cmd even when swncq_enable is 0?
> >>>
> >>> nv_init_one
> >>>   } else if (type == SWNCQ && swncq_enabled) {
> >>>   dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ
mode\n");
> >>>   nv_swncq_host_init(host);
> >> Thanks for watching!  Yes, that looks like a problem.
> >>
> >> I still feel the flags usage I removed was problematic.  A better 
> >> solution, I think, would be to do follow the ADMA example of 
> >> switching the port_info type during early initialization:
> >>
> >>if (type >= CK804 && adma_enabled) {
> >>type = ADMA;
> >>
> >> which in our case would result in
> >>
> >>if (type == SWNCQ && !swncq_enabled)
> >>type = GENERIC;
> >>
> >> Or, if you prefer, we could take the opposite route, _not_ set 
> >> SWNCQ in the pci_device_id table, and instead do something like
> >>
> >>if (type >= MCP65 && swncq_enabled)
> >>type = SWNCQ;
> >>
> >> (MCP65 is just a pulled-out-of-thin-air example)
> >>
> >> Regards,
> >>
> >>Jeff
> >>
> > 1.The former method "type =GENERIC" cann't support hotplug in 
> > mcp51-55-61.
> 
> 'GENERIC' just an example; my apologies for the confusion.
> 
> 
> > 2.As to the latter mehthod, do you mean we may set MCP65 in 
> > pci_device_id table and add the extra variable static const struct 
> > ata_port_operations nv_MCP65_ops ={...}.
> 
> Correct.
> 
> The main point was to fall back from SWNCQ to , if 
> !swncq_enabled, to avoid changing the ap->flags value after the port 
> has been allocated and initialized internally.  And that switch must 
> occur prior to ata_pci_prepare_sff_host() call in nv_init_one().
> 
> Regards,
> 
>   Jeff
> 
One idea,  only simply adding 
if (!swncq_enabled) 
nv_port_info[SWNCQ].flags &= ~ATA_FLAG_NCQ;

ppi[0] = &nv_port_info[type];
rc = ata_pci_prepare_sff_host(pdev, ppi, &host);

I don't know if this is appropriate
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-27 Thread Kuan Luo
 Jeff Garzik wrote:
> Kuan Luo wrote:
> > Jeff Garzik wrote:
> >> Kuan Luo wrote:
> >>> hi,
> >>> i saw the below changes  from
> >>>
> >> http://git.kernel.org/?p=linux/kernel/git/jgarzik/libata-dev.g
> >> it;a=commi
> >>> tdiff;h=5a5a9e1890b8260686218a68862d880daee1a817
> >>>
> >>> [libata] sata_nv: Clean up ATA_FLAG_NCQ usage; bit test micro-opt
> >>>
> >>>  @@ -622,7 +622,9 @@ static const struct ata_port_info 
> >> nv_port_info[] =
> >>> {
> >>> /* SWNCQ */
> >>> {
> >>> .sht= &nv_swncq_sht,
> >>> -   .flags  = ATA_FLAG_SATA | 
> >> ATA_FLAG_NO_LEGACY,
> >>> +   .flags  = ATA_FLAG_SATA | 
> >> ATA_FLAG_NO_LEGACY |
> >>> + ATA_FLAG_NCQ,
> >>> +   .link_flags = ATA_LFLAG_HRST_TO_RESUME,
> >>> .pio_mask   = NV_PIO_MASK,
> >>> .mwdma_mask = NV_MWDMA_MASK,
> >>> .udma_mask  = NV_UDMA_MASK,
> >>>
> >>> If swncq_enabled is set zero by user, nv_swncq_host_init 
> >> would not be
> >>> called .
> >>>  Then ncq should be disabled and the libata shouldn't 
> send ncq cmd. 
> >>>  I am not sure whether the  ATA_FLAG_NCQ flag which is in 
> >> default set
> >>> makes libata send ncq cmd even when swncq_enable is 0?
> >>>
> >>> nv_init_one
> >>>   } else if (type == SWNCQ && swncq_enabled) {
> >>>   dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ
> >>> mode\n");
> >>>   nv_swncq_host_init(host);
> >> Thanks for watching!  Yes, that looks like a problem.
> >>
> >> I still feel the flags usage I removed was problematic.  A better 
> >> solution, I think, would be to do follow the ADMA example of 
> >> switching 
> >> the port_info type during early initialization:
> >>
> >>if (type >= CK804 && adma_enabled) {
> >>type = ADMA;
> >>
> >> which in our case would result in
> >>
> >>if (type == SWNCQ && !swncq_enabled)
> >>type = GENERIC;
> >>
> >> Or, if you prefer, we could take the opposite route, _not_ 
> >> set SWNCQ in 
> >> the pci_device_id table, and instead do something like
> >>
> >>if (type >= MCP65 && swncq_enabled)
> >>type = SWNCQ;
> >>
> >> (MCP65 is just a pulled-out-of-thin-air example)
> >>
> >> Regards,
> >>
> >>Jeff
> >>
> > 1.The former method "type =GENERIC" cann't support hotplug in
> > mcp51-55-61.
> 
> 'GENERIC' just an example; my apologies for the confusion.
> 
> 
> > 2.As to the latter mehthod, do you mean we may set MCP65 in
> > pci_device_id table and add the extra variable
> > static const struct ata_port_operations nv_MCP65_ops ={...}.
> 
> Correct.
> 
> The main point was to fall back from SWNCQ to , if 
> !swncq_enabled, to avoid changing the ap->flags value after 
> the port has 
> been allocated and initialized internally.  And that switch 
> must occur 
> prior to ata_pci_prepare_sff_host() call in nv_init_one().
> 
> Regards,
> 
>   Jeff
> 
One idea,  only simply adding 
if (!swncq_enabled) 
nv_port_info[SWNCQ].flags &= ~ATA_FLAG_NCQ;

ppi[0] = &nv_port_info[type];
rc = ata_pci_prepare_sff_host(pdev, ppi, &host);

I don't know if this is appropriate
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-27 Thread Kuan Luo
 Jeff Garzik wrote:
> Kuan Luo wrote:
> > Jeff Garzik wrote:
> >> Kuan Luo wrote:
> >>> hi,
> >>> i saw the below changes  from
> >>>
> >> http://git.kernel.org/?p=linux/kernel/git/jgarzik/libata-dev.g
> >> it;a=commi
> >>> tdiff;h=5a5a9e1890b8260686218a68862d880daee1a817
> >>>
> >>> [libata] sata_nv: Clean up ATA_FLAG_NCQ usage; bit test micro-opt
> >>>
> >>>  @@ -622,7 +622,9 @@ static const struct ata_port_info 
> >> nv_port_info[] =
> >>> {
> >>> /* SWNCQ */
> >>> {
> >>> .sht= &nv_swncq_sht,
> >>> -   .flags  = ATA_FLAG_SATA | 
> >> ATA_FLAG_NO_LEGACY,
> >>> +   .flags  = ATA_FLAG_SATA | 
> >> ATA_FLAG_NO_LEGACY |
> >>> + ATA_FLAG_NCQ,
> >>> +   .link_flags = ATA_LFLAG_HRST_TO_RESUME,
> >>> .pio_mask   = NV_PIO_MASK,
> >>> .mwdma_mask = NV_MWDMA_MASK,
> >>> .udma_mask  = NV_UDMA_MASK,
> >>>
> >>> If swncq_enabled is set zero by user, nv_swncq_host_init 
> >> would not be
> >>> called .
> >>>  Then ncq should be disabled and the libata shouldn't 
> send ncq cmd. 
> >>>  I am not sure whether the  ATA_FLAG_NCQ flag which is in 
> >> default set
> >>> makes libata send ncq cmd even when swncq_enable is 0?
> >>>
> >>> nv_init_one
> >>>   } else if (type == SWNCQ && swncq_enabled) {
> >>>   dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ
> >>> mode\n");
> >>>   nv_swncq_host_init(host);
> >> Thanks for watching!  Yes, that looks like a problem.
> >>
> >> I still feel the flags usage I removed was problematic.  A better 
> >> solution, I think, would be to do follow the ADMA example of 
> >> switching 
> >> the port_info type during early initialization:
> >>
> >>if (type >= CK804 && adma_enabled) {
> >>type = ADMA;
> >>
> >> which in our case would result in
> >>
> >>if (type == SWNCQ && !swncq_enabled)
> >>type = GENERIC;
> >>
> >> Or, if you prefer, we could take the opposite route, _not_ 
> >> set SWNCQ in 
> >> the pci_device_id table, and instead do something like
> >>
> >>if (type >= MCP65 && swncq_enabled)
> >>type = SWNCQ;
> >>
> >> (MCP65 is just a pulled-out-of-thin-air example)
> >>
> >> Regards,
> >>
> >>Jeff
> >>
> > 1.The former method "type =GENERIC" cann't support hotplug in
> > mcp51-55-61.
> 
> 'GENERIC' just an example; my apologies for the confusion.
> 
> 
> > 2.As to the latter mehthod, do you mean we may set MCP65 in
> > pci_device_id table and add the extra variable
> > static const struct ata_port_operations nv_MCP65_ops ={...}.
> 
> Correct.
> 
> The main point was to fall back from SWNCQ to , if 
> !swncq_enabled, to avoid changing the ap->flags value after 
> the port has 
> been allocated and initialized internally.  And that switch 
> must occur 
> prior to ata_pci_prepare_sff_host() call in nv_init_one().
> 
> Regards,
> 
>   Jeff
> 
 I see. Both your methods are perfect.
Because the nv_swncq_ops and nv_swncq_interrupt can be also used when
sending non ncq cmd,
It seems like:
/* MCP65 */
{
.sht= &nv_sht,
.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,
.udma_mask  = NV_UDMA_MASK,
.port_ops   = &nv_swncq_ops,
.irq_handler= nv_swncq_interrupt,
},

Is it right?

Best regards,
Kuan Luo

---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-27 Thread Jeff Garzik

Kuan Luo wrote:

Jeff Garzik wrote:

Kuan Luo wrote:

hi,
i saw the below changes  from


http://git.kernel.org/?p=linux/kernel/git/jgarzik/libata-dev.g
it;a=commi

tdiff;h=5a5a9e1890b8260686218a68862d880daee1a817

[libata] sata_nv: Clean up ATA_FLAG_NCQ usage; bit test micro-opt

 @@ -622,7 +622,9 @@ static const struct ata_port_info 

nv_port_info[] =

{
/* SWNCQ */
{
.sht= &nv_swncq_sht,
-   .flags  = ATA_FLAG_SATA | 

ATA_FLAG_NO_LEGACY,
+   .flags  = ATA_FLAG_SATA | 

ATA_FLAG_NO_LEGACY |

+ ATA_FLAG_NCQ,
+   .link_flags = ATA_LFLAG_HRST_TO_RESUME,
.pio_mask   = NV_PIO_MASK,
.mwdma_mask = NV_MWDMA_MASK,
.udma_mask  = NV_UDMA_MASK,

If swncq_enabled is set zero by user, nv_swncq_host_init 

would not be

called .
 Then ncq should be disabled and the libata shouldn't send ncq cmd. 
 I am not sure whether the  ATA_FLAG_NCQ flag which is in 

default set

makes libata send ncq cmd even when swncq_enable is 0?

nv_init_one
} else if (type == SWNCQ && swncq_enabled) {
dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ
mode\n");
nv_swncq_host_init(host);

Thanks for watching!  Yes, that looks like a problem.

I still feel the flags usage I removed was problematic.  A better 
solution, I think, would be to do follow the ADMA example of 
switching 
the port_info type during early initialization:


if (type >= CK804 && adma_enabled) {
type = ADMA;

which in our case would result in

if (type == SWNCQ && !swncq_enabled)
type = GENERIC;

Or, if you prefer, we could take the opposite route, _not_ 
set SWNCQ in 
the pci_device_id table, and instead do something like


if (type >= MCP65 && swncq_enabled)
type = SWNCQ;

(MCP65 is just a pulled-out-of-thin-air example)

Regards,

Jeff


1.The former method "type =GENERIC" cann't support hotplug in
mcp51-55-61.


'GENERIC' just an example; my apologies for the confusion.



2.As to the latter mehthod, do you mean we may set MCP65 in
pci_device_id table and add the extra variable
static const struct ata_port_operations nv_MCP65_ops ={...}.


Correct.

The main point was to fall back from SWNCQ to , if 
!swncq_enabled, to avoid changing the ap->flags value after the port has 
been allocated and initialized internally.  And that switch must occur 
prior to ata_pci_prepare_sff_host() call in nv_init_one().


Regards,

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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-26 Thread Kuan Luo
Jeff Garzik wrote:
> Kuan Luo wrote:
> > hi,
> > i saw the below changes  from
> > 
> http://git.kernel.org/?p=linux/kernel/git/jgarzik/libata-dev.g
> it;a=commi
> > tdiff;h=5a5a9e1890b8260686218a68862d880daee1a817
> > 
> > [libata] sata_nv: Clean up ATA_FLAG_NCQ usage; bit test micro-opt
> > 
> >  @@ -622,7 +622,9 @@ static const struct ata_port_info 
> nv_port_info[] =
> > {
> > /* SWNCQ */
> > {
> > .sht= &nv_swncq_sht,
> > -   .flags  = ATA_FLAG_SATA | 
> ATA_FLAG_NO_LEGACY,
> > +   .flags  = ATA_FLAG_SATA | 
> ATA_FLAG_NO_LEGACY |
> > + ATA_FLAG_NCQ,
> > +   .link_flags = ATA_LFLAG_HRST_TO_RESUME,
> > .pio_mask   = NV_PIO_MASK,
> > .mwdma_mask = NV_MWDMA_MASK,
> > .udma_mask  = NV_UDMA_MASK,
> > 
> > If swncq_enabled is set zero by user, nv_swncq_host_init 
> would not be
> > called .
> >  Then ncq should be disabled and the libata shouldn't send ncq cmd. 
> >  I am not sure whether the  ATA_FLAG_NCQ flag which is in 
> default set
> > makes libata send ncq cmd even when swncq_enable is 0?
> > 
> > nv_init_one
> > } else if (type == SWNCQ && swncq_enabled) {
> > dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ
> > mode\n");
> > nv_swncq_host_init(host);
> 
> Thanks for watching!  Yes, that looks like a problem.
> 
> I still feel the flags usage I removed was problematic.  A better 
> solution, I think, would be to do follow the ADMA example of 
> switching 
> the port_info type during early initialization:
> 
>   if (type >= CK804 && adma_enabled) {
>   type = ADMA;
> 
> which in our case would result in
> 
>   if (type == SWNCQ && !swncq_enabled)
>   type = GENERIC;
> 
> Or, if you prefer, we could take the opposite route, _not_ 
> set SWNCQ in 
> the pci_device_id table, and instead do something like
> 
>   if (type >= MCP65 && swncq_enabled)
>   type = SWNCQ;
> 
> (MCP65 is just a pulled-out-of-thin-air example)
> 
> Regards,
> 
>   Jeff
> 
1.The former method "type =GENERIC" cann't support hotplug in
mcp51-55-61.

2.As to the latter mehthod, do you mean we may set MCP65 in
pci_device_id table and add the extra variable
static const struct ata_port_operations nv_MCP65_ops ={...}.
 If setting GENERIC in pci_device_id table, It also doen't support
hotplug.
 
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-26 Thread Jeff Garzik

Kuan Luo wrote:

hi,
i saw the below changes  from
http://git.kernel.org/?p=linux/kernel/git/jgarzik/libata-dev.git;a=commi
tdiff;h=5a5a9e1890b8260686218a68862d880daee1a817

[libata] sata_nv: Clean up ATA_FLAG_NCQ usage; bit test micro-opt

 @@ -622,7 +622,9 @@ static const struct ata_port_info nv_port_info[] =
{
/* SWNCQ */
{
.sht= &nv_swncq_sht,
-   .flags  = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
+   .flags  = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+ ATA_FLAG_NCQ,
+   .link_flags = ATA_LFLAG_HRST_TO_RESUME,
.pio_mask   = NV_PIO_MASK,
.mwdma_mask = NV_MWDMA_MASK,
.udma_mask  = NV_UDMA_MASK,

If swncq_enabled is set zero by user, nv_swncq_host_init would not be
called .
 Then ncq should be disabled and the libata shouldn't send ncq cmd. 
 I am not sure whether the  ATA_FLAG_NCQ flag which is in default set

makes libata send ncq cmd even when swncq_enable is 0?

nv_init_one
} else if (type == SWNCQ && swncq_enabled) {
dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ
mode\n");
nv_swncq_host_init(host);


Thanks for watching!  Yes, that looks like a problem.

I still feel the flags usage I removed was problematic.  A better 
solution, I think, would be to do follow the ADMA example of switching 
the port_info type during early initialization:


if (type >= CK804 && adma_enabled) {
type = ADMA;

which in our case would result in

if (type == SWNCQ && !swncq_enabled)
type = GENERIC;

Or, if you prefer, we could take the opposite route, _not_ set SWNCQ in 
the pci_device_id table, and instead do something like


if (type >= MCP65 && swncq_enabled)
type = SWNCQ;

(MCP65 is just a pulled-out-of-thin-air example)

Regards,

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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-26 Thread Kuan Luo
hi,
i saw the below changes  from
http://git.kernel.org/?p=linux/kernel/git/jgarzik/libata-dev.git;a=commi
tdiff;h=5a5a9e1890b8260686218a68862d880daee1a817

[libata] sata_nv: Clean up ATA_FLAG_NCQ usage; bit test micro-opt

 @@ -622,7 +622,9 @@ static const struct ata_port_info nv_port_info[] =
{
/* SWNCQ */
{
.sht= &nv_swncq_sht,
-   .flags  = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY,
+   .flags  = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
+ ATA_FLAG_NCQ,
+   .link_flags = ATA_LFLAG_HRST_TO_RESUME,
.pio_mask   = NV_PIO_MASK,
.mwdma_mask = NV_MWDMA_MASK,
.udma_mask  = NV_UDMA_MASK,

If swncq_enabled is set zero by user, nv_swncq_host_init would not be
called .
 Then ncq should be disabled and the libata shouldn't send ncq cmd. 
 I am not sure whether the  ATA_FLAG_NCQ flag which is in default set
makes libata send ncq cmd even when swncq_enable is 0?

nv_init_one
} else if (type == SWNCQ && swncq_enabled) {
dev_printk(KERN_NOTICE, &pdev->dev, "Using SWNCQ
mode\n");
nv_swncq_host_init(host);
}
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-25 Thread Zoltan Boszormenyi

Jeff Garzik írta:

Zoltan Boszormenyi wrote:

Jeff Garzik írta:

Zoltan Boszormenyi wrote:

Hi,

Jeff Garzik írta:

[EMAIL PROTECTED] wrote:

From: Kuan Luo <[EMAIL PROTECTED]>

Add the Software NCQ support to sata_nv.c for MCP51/MCP55/MCP61 SATA
controller.  NCQ function is disable by default, you can enable 
it with
'swncq=1'.  NCQ will be turned off if the drive is Maxtor on 
MCP51 or MCP55

rev 0xa2 platform.

[EMAIL PROTECTED]: build fix]
Signed-off-by: Kuan Luo <[EMAIL PROTECTED]>
Signed-off-by: Peer Chen <[EMAIL PROTECTED]>
Cc: Zoltan Boszormenyi <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/ata/sata_nv.c |  860 
+++-

 1 files changed, 851 insertions(+), 9 deletions(-)


I finally gave this a thorough review.

Overall, good work.  The state transitions all seem solid.  I made 
several minor changes and cleanups, and checked it into the 
'nv-swncq' branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git


Two hurdles before I'm ready to push upstream:

* someone please verify my minor changes did not break anything; I 
don't have real hardware


After reading the diff between the original and your cleaned up 
version
it seems both the change from 4 individual flags to a single 
integer and the
nv_swncq_bmdma_stop() -> __ata_bmdma_stop() transition are 
obviously correct.
I attached a small cleanup patch which may make one check a bit 
more readable.


However, can you explain this chunk below? Why isn't it needed?

@@ -615,7 +622,6 @@ static const struct ata_port_info nv_por
   {
   .sht= &nv_swncq_sht,
   .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,
   .udma_mask  = NV_UDMA_MASK,


that's a bug.  fixed.

I also applied your cleanup.


Thanks, but you took the wrong cleanup patch.
My original, i.e. this chunk below is wrong.

@@ -2291,8 
 
+2283,7 
 
@@ static void nv_swncq_host_interrupt(struct ata_port *ap, u16 fis)

*/
   pp->dhfis_bits |= (0x1 << pp->last_issue_tag);
   pp->ncq_flags |= ncq_saw_d2h;
-   if ((pp->ncq_flags & ncq_saw_sdb) ||
-   (pp->ncq_flags & ncq_saw_backout)) {
+   if (pp->ncq_flags & (ncq_saw_sdb || ncq_saw_backout)) {
   ata_ehi_push_desc(ehi, "illegal fis 
transaction");

   ehi->err_mask |= AC_ERR_HSM;
   ehi->action |= ATA_EH_HARDRESET;

It should be a binary OR between the flags. This caused immediate
NCQ errors upon boot and lead to disabling NCQ.
My second patch has it corrected.


fixed


Thanks. And would you please also enable swncq by default? :-)
It's very stable.

Best regards,
Zoltán Böszörményi


-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-25 Thread Jeff Garzik

Zoltan Boszormenyi wrote:

Jeff Garzik írta:

Zoltan Boszormenyi wrote:

Hi,

Jeff Garzik írta:

[EMAIL PROTECTED] wrote:

From: Kuan Luo <[EMAIL PROTECTED]>

Add the Software NCQ support to sata_nv.c for MCP51/MCP55/MCP61 SATA
controller.  NCQ function is disable by default, you can enable it 
with
'swncq=1'.  NCQ will be turned off if the drive is Maxtor on MCP51 
or MCP55

rev 0xa2 platform.

[EMAIL PROTECTED]: build fix]
Signed-off-by: Kuan Luo <[EMAIL PROTECTED]>
Signed-off-by: Peer Chen <[EMAIL PROTECTED]>
Cc: Zoltan Boszormenyi <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/ata/sata_nv.c |  860 +++-
 1 files changed, 851 insertions(+), 9 deletions(-)


I finally gave this a thorough review.

Overall, good work.  The state transitions all seem solid.  I made 
several minor changes and cleanups, and checked it into the 
'nv-swncq' branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git


Two hurdles before I'm ready to push upstream:

* someone please verify my minor changes did not break anything; I 
don't have real hardware


After reading the diff between the original and your cleaned up version
it seems both the change from 4 individual flags to a single integer 
and the
nv_swncq_bmdma_stop() -> __ata_bmdma_stop() transition are obviously 
correct.
I attached a small cleanup patch which may make one check a bit more 
readable.


However, can you explain this chunk below? Why isn't it needed?

@@ -615,7 +622,6 @@ static const struct ata_port_info nv_por
   {
   .sht= &nv_swncq_sht,
   .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,
   .udma_mask  = NV_UDMA_MASK,


that's a bug.  fixed.

I also applied your cleanup.


Thanks, but you took the wrong cleanup patch.
My original, i.e. this chunk below is wrong.

@@ -2291,8 
 
+2283,7 
 
@@ static void nv_swncq_host_interrupt(struct ata_port *ap, u16 fis)

*/
   pp->dhfis_bits |= (0x1 << pp->last_issue_tag);
   pp->ncq_flags |= ncq_saw_d2h;
-   if ((pp->ncq_flags & ncq_saw_sdb) ||
-   (pp->ncq_flags & ncq_saw_backout)) {
+   if (pp->ncq_flags & (ncq_saw_sdb || ncq_saw_backout)) {
   ata_ehi_push_desc(ehi, "illegal fis transaction");
   ehi->err_mask |= AC_ERR_HSM;
   ehi->action |= ATA_EH_HARDRESET;

It should be a binary OR between the flags. This caused immediate
NCQ errors upon boot and lead to disabling NCQ.
My second patch has it corrected.


fixed

-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-25 Thread Zoltan Boszormenyi

Jeff Garzik írta:

Zoltan Boszormenyi wrote:

Hi,

Jeff Garzik írta:

[EMAIL PROTECTED] wrote:

From: Kuan Luo <[EMAIL PROTECTED]>

Add the Software NCQ support to sata_nv.c for MCP51/MCP55/MCP61 SATA
controller.  NCQ function is disable by default, you can enable it 
with
'swncq=1'.  NCQ will be turned off if the drive is Maxtor on MCP51 
or MCP55

rev 0xa2 platform.

[EMAIL PROTECTED]: build fix]
Signed-off-by: Kuan Luo <[EMAIL PROTECTED]>
Signed-off-by: Peer Chen <[EMAIL PROTECTED]>
Cc: Zoltan Boszormenyi <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/ata/sata_nv.c |  860 +++-
 1 files changed, 851 insertions(+), 9 deletions(-)


I finally gave this a thorough review.

Overall, good work.  The state transitions all seem solid.  I made 
several minor changes and cleanups, and checked it into the 
'nv-swncq' branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git


Two hurdles before I'm ready to push upstream:

* someone please verify my minor changes did not break anything; I 
don't have real hardware


After reading the diff between the original and your cleaned up version
it seems both the change from 4 individual flags to a single integer 
and the
nv_swncq_bmdma_stop() -> __ata_bmdma_stop() transition are obviously 
correct.
I attached a small cleanup patch which may make one check a bit more 
readable.


However, can you explain this chunk below? Why isn't it needed?

@@ -615,7 +622,6 @@ static const struct ata_port_info nv_por
   {
   .sht= &nv_swncq_sht,
   .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,
   .udma_mask  = NV_UDMA_MASK,


that's a bug.  fixed.

I also applied your cleanup.


Thanks, but you took the wrong cleanup patch.
My original, i.e. this chunk below is wrong.

@@ -2291,8 
 
+2283,7 
 
@@ static void nv_swncq_host_interrupt(struct ata_port *ap, u16 fis)

*/
   pp->dhfis_bits |= (0x1 << pp->last_issue_tag);
   pp->ncq_flags |= ncq_saw_d2h;
-   if ((pp->ncq_flags & ncq_saw_sdb) ||
-   (pp->ncq_flags & ncq_saw_backout)) {
+   if (pp->ncq_flags & (ncq_saw_sdb || ncq_saw_backout)) {
   ata_ehi_push_desc(ehi, "illegal fis transaction");
   ehi->err_mask |= AC_ERR_HSM;
   ehi->action |= ATA_EH_HARDRESET;

It should be a binary OR between the flags. This caused immediate
NCQ errors upon boot and lead to disabling NCQ.
My second patch has it corrected.

Best regards,
Zoltán Böszörményi


-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-25 Thread Jeff Garzik

Zoltan Boszormenyi wrote:

Hi,

Jeff Garzik írta:

[EMAIL PROTECTED] wrote:

From: Kuan Luo <[EMAIL PROTECTED]>

Add the Software NCQ support to sata_nv.c for MCP51/MCP55/MCP61 SATA
controller.  NCQ function is disable by default, you can enable it with
'swncq=1'.  NCQ will be turned off if the drive is Maxtor on MCP51 or 
MCP55

rev 0xa2 platform.

[EMAIL PROTECTED]: build fix]
Signed-off-by: Kuan Luo <[EMAIL PROTECTED]>
Signed-off-by: Peer Chen <[EMAIL PROTECTED]>
Cc: Zoltan Boszormenyi <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/ata/sata_nv.c |  860 +++-
 1 files changed, 851 insertions(+), 9 deletions(-)


I finally gave this a thorough review.

Overall, good work.  The state transitions all seem solid.  I made 
several minor changes and cleanups, and checked it into the 'nv-swncq' 
branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git


Two hurdles before I'm ready to push upstream:

* someone please verify my minor changes did not break anything; I 
don't have real hardware


After reading the diff between the original and your cleaned up version
it seems both the change from 4 individual flags to a single integer and 
the
nv_swncq_bmdma_stop() -> __ata_bmdma_stop() transition are obviously 
correct.
I attached a small cleanup patch which may make one check a bit more 
readable.


However, can you explain this chunk below? Why isn't it needed?

@@ -615,7 +622,6 @@ static const struct ata_port_info nv_por
   {
   .sht= &nv_swncq_sht,
   .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,
   .udma_mask  = NV_UDMA_MASK,


that's a bug.  fixed.

I also applied your cleanup.


-
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: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-21 Thread Zoltan Boszormenyi

Hi,

Zoltan Boszormenyi írta:

I will test the code without this locking. Can you give me a better idea
besides beating both my disks with separate requests? Say, bonnie++
and simultaneous hdparm -tT on both?


I tested the driver without locking with the above test, it survived nicely.
Patch is attached which deletes locking, enables swncq by default and
a correction to my previous readability cleanup.

Best regards,
Zoltán Böszörményi

--- linux-2.6.23-rc3-mm1/drivers/ata/sata_nv.c.committed	2007-09-21 08:32:04.0 +0200
+++ linux-2.6.23-rc3-mm1/drivers/ata/sata_nv.c	2007-09-21 09:27:49.0 +0200
@@ -279,7 +279,6 @@
 
 	unsigned int	last_issue_tag;
 
-	spinlock_t	lock;
 	/* fifo circular queue to store deferral command */
 	struct defer_queue defer_queue;
 
@@ -637,7 +636,7 @@
 MODULE_VERSION(DRV_VERSION);
 
 static int adma_enabled = 1;
-static int swncq_enabled;
+static int swncq_enabled = 1;
 
 static void nv_adma_register_mode(struct ata_port *ap)
 {
@@ -1965,7 +1964,6 @@
 	pp->sactive_block = ap->ioaddr.scr_addr + 4 * SCR_ACTIVE;
 	pp->irq_block = mmio + NV_INT_STATUS_MCP55 + ap->port_no * 2;
 	pp->tag_block = mmio + NV_NCQ_REG_MCP55 + ap->port_no * 2;
-	spin_lock_init(&pp->lock);
 
 	return 0;
 }
@@ -2051,18 +2049,15 @@
 {
 	struct ata_port *ap = qc->ap;
 	struct nv_swncq_port_priv *pp = ap->private_data;
-	unsigned long flags;
 
 	if (qc->tf.protocol != ATA_PROT_NCQ)
 		return ata_qc_issue_prot(qc);
 
 	DPRINTK("Enter\n");
-	spin_lock_irqsave(&pp->lock, flags);
 	if (!pp->qc_active)
 		nv_swncq_issue_atacmd(ap, qc);
 	else
 		nv_swncq_qc_to_dq(ap, qc);	/* add qc to defer queue */
-	spin_unlock_irqrestore(&pp->lock, flags);
 	return 0;
 }
 
@@ -2265,7 +2260,6 @@
 		return;
 	}
 
-	spin_lock(&pp->lock);
 	if (fis & NV_SWNCQ_IRQ_BACKOUT) {
 		/* If the IRQ is backout, driver must issue
 		 * the new command again some time later.
@@ -2290,8 +2284,7 @@
 		 */
 		pp->dhfis_bits |= (0x1 << pp->last_issue_tag);
 		pp->ncq_flags |= ncq_saw_d2h;
-		if ((pp->ncq_flags & ncq_saw_sdb) ||
-		(pp->ncq_flags & ncq_saw_backout)) {
+		if (pp->ncq_flags & (ncq_saw_sdb | ncq_saw_backout)) {
 			ata_ehi_push_desc(ehi, "illegal fis transaction");
 			ehi->err_mask |= AC_ERR_HSM;
 			ehi->action |= ATA_EH_HARDRESET;
@@ -2302,7 +2295,7 @@
 		!(pp->ncq_flags & ncq_saw_dmas)) {
 			ata_stat = ap->ops->check_status(ap);
 			if (ata_stat & ATA_BUSY)
-goto irq_exit;
+return;
 
 			if (pp->defer_queue.defer_bits) {
 DPRINTK("send next command\n");
@@ -2321,13 +2314,11 @@
 		rc = nv_swncq_dmafis(ap);
 	}
 
-irq_exit:
-	spin_unlock(&pp->lock);
 	return;
+
 irq_error:
 	ata_ehi_push_desc(ehi, "fis:0x%x", fis);
 	ata_port_freeze(ap);
-	spin_unlock(&pp->lock);
 	return;
 }
 



Re: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-20 Thread Zoltan Boszormenyi

Hi,

Jeff Garzik írta:

[EMAIL PROTECTED] wrote:

From: Kuan Luo <[EMAIL PROTECTED]>

Add the Software NCQ support to sata_nv.c for MCP51/MCP55/MCP61 SATA
controller.  NCQ function is disable by default, you can enable it with
'swncq=1'.  NCQ will be turned off if the drive is Maxtor on MCP51 or 
MCP55

rev 0xa2 platform.

[EMAIL PROTECTED]: build fix]
Signed-off-by: Kuan Luo <[EMAIL PROTECTED]>
Signed-off-by: Peer Chen <[EMAIL PROTECTED]>
Cc: Zoltan Boszormenyi <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/ata/sata_nv.c |  860 +++-
 1 files changed, 851 insertions(+), 9 deletions(-)


I finally gave this a thorough review.

Overall, good work.  The state transitions all seem solid.  I made 
several minor changes and cleanups, and checked it into the 'nv-swncq' 
branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git


Two hurdles before I'm ready to push upstream:

* someone please verify my minor changes did not break anything; I 
don't have real hardware


After reading the diff between the original and your cleaned up version
it seems both the change from 4 individual flags to a single integer and the
nv_swncq_bmdma_stop() -> __ata_bmdma_stop() transition are obviously 
correct.
I attached a small cleanup patch which may make one check a bit more 
readable.


However, can you explain this chunk below? Why isn't it needed?

@@ -615,7 +622,6 @@ static const struct ata_port_info nv_por
   {
   .sht= &nv_swncq_sht,
   .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,
   .udma_mask  = NV_UDMA_MASK,


* the pp->lock appears unnecessary at best, wrong at worst.  needs 
additional analysis.


I will test the code without this locking. Can you give me a better idea
besides beating both my disks with separate requests? Say, bonnie++
and simultaneous hdparm -tT on both?

Best regards,
Zoltán Böszörményi

--- sata_nv.c.committed	2007-09-21 06:49:23.0 +0200
+++ sata_nv.c.cleanup-swncq	2007-09-21 07:47:24.0 +0200
@@ -2290,8 +2290,7 @@
 		 */
 		pp->dhfis_bits |= (0x1 << pp->last_issue_tag);
 		pp->ncq_flags |= ncq_saw_d2h;
-		if ((pp->ncq_flags & ncq_saw_sdb) ||
-		(pp->ncq_flags & ncq_saw_backout)) {
+		if (pp->ncq_flags & (ncq_saw_sdb || ncq_saw_backout)) {
 			ata_ehi_push_desc(ehi, "illegal fis transaction");
 			ehi->err_mask |= AC_ERR_HSM;
 			ehi->action |= ATA_EH_HARDRESET;



Re: [patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-09-20 Thread Jeff Garzik

[EMAIL PROTECTED] wrote:

From: Kuan Luo <[EMAIL PROTECTED]>

Add the Software NCQ support to sata_nv.c for MCP51/MCP55/MCP61 SATA
controller.  NCQ function is disable by default, you can enable it with
'swncq=1'.  NCQ will be turned off if the drive is Maxtor on MCP51 or MCP55
rev 0xa2 platform.

[EMAIL PROTECTED]: build fix]
Signed-off-by: Kuan Luo <[EMAIL PROTECTED]>
Signed-off-by: Peer Chen <[EMAIL PROTECTED]>
Cc: Zoltan Boszormenyi <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/ata/sata_nv.c |  860 +++-
 1 files changed, 851 insertions(+), 9 deletions(-)


I finally gave this a thorough review.

Overall, good work.  The state transitions all seem solid.  I made 
several minor changes and cleanups, and checked it into the 'nv-swncq' 
branch of 
git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev.git


Two hurdles before I'm ready to push upstream:

* someone please verify my minor changes did not break anything; I don't 
have real hardware


* the pp->lock appears unnecessary at best, wrong at worst.  needs 
additional analysis.


-
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


[patch 05/25] ata: add the SW NCQ support to sata_nv for MCP51/MCP55/MCP61

2007-08-10 Thread akpm
From: Kuan Luo <[EMAIL PROTECTED]>

Add the Software NCQ support to sata_nv.c for MCP51/MCP55/MCP61 SATA
controller.  NCQ function is disable by default, you can enable it with
'swncq=1'.  NCQ will be turned off if the drive is Maxtor on MCP51 or MCP55
rev 0xa2 platform.

[EMAIL PROTECTED]: build fix]
Signed-off-by: Kuan Luo <[EMAIL PROTECTED]>
Signed-off-by: Peer Chen <[EMAIL PROTECTED]>
Cc: Zoltan Boszormenyi <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 drivers/ata/sata_nv.c |  860 +++-
 1 files changed, 851 insertions(+), 9 deletions(-)

diff -puN 
drivers/ata/sata_nv.c~ata-add-the-sw-ncq-support-to-sata_nv-for-mcp51-mcp55-mcp61
 drivers/ata/sata_nv.c
--- 
a/drivers/ata/sata_nv.c~ata-add-the-sw-ncq-support-to-sata_nv-for-mcp51-mcp55-mcp61
+++ a/drivers/ata/sata_nv.c
@@ -169,6 +169,35 @@ enum {
NV_ADMA_PORT_REGISTER_MODE  = (1 << 0),
NV_ADMA_ATAPI_SETUP_COMPLETE= (1 << 1),
 
+   /* MCP55 reg offset */
+   NV_CTL_MCP55= 0x400,
+   NV_INT_STATUS_MCP55 = 0x440,
+   NV_INT_ENABLE_MCP55 = 0x444,
+   NV_NCQ_REG_MCP55= 0x448,
+
+   /* MCP55 */
+   NV_INT_ALL_MCP55= 0x,
+   NV_INT_PORT_SHIFT_MCP55 = 16,   /* each port occupies 16 bits */
+   NV_INT_MASK_MCP55   = NV_INT_ALL_MCP55 & 0xfffd,
+
+   /* SWNCQ ENABLE BITS*/
+   NV_CTL_PRI_SWNCQ= 0x02,
+   NV_CTL_SEC_SWNCQ= 0x04,
+
+   /* SW NCQ status bits*/
+   NV_SWNCQ_IRQ_DEV= (1 << 0),
+   NV_SWNCQ_IRQ_PM = (1 << 1),
+   NV_SWNCQ_IRQ_ADDED  = (1 << 2),
+   NV_SWNCQ_IRQ_REMOVED= (1 << 3),
+
+   NV_SWNCQ_IRQ_BACKOUT= (1 << 4),
+   NV_SWNCQ_IRQ_SDBFIS = (1 << 5),
+   NV_SWNCQ_IRQ_DHREGFIS   = (1 << 6),
+   NV_SWNCQ_IRQ_DMASETUP   = (1 << 7),
+
+   NV_SWNCQ_IRQ_HOTPLUG= NV_SWNCQ_IRQ_ADDED |
+ NV_SWNCQ_IRQ_REMOVED,
+
 };
 
 /* ADMA Physical Region Descriptor - one SG segment */
@@ -226,6 +255,37 @@ struct nv_host_priv {
unsigned long   type;
 };
 
+struct defer_queue {
+   u32 defer_bits;
+   unsigned inthead;
+   unsigned inttail;
+   unsigned inttag[ATA_MAX_QUEUE];
+};
+
+struct nv_swncq_port_priv {
+   struct ata_prd  *prd;/* our SG list */
+   dma_addr_t  prd_dma; /* and its DMA mapping */
+   void __iomem*sactive_block;
+   void __iomem*irq_block;
+   void __iomem*tag_block;
+   u32 qc_active;
+   unsigned intlast_issue_tag;
+   spinlock_t  lock;
+   /* fifo circular queue to store deferral command */
+   struct defer_queue defer_queue;
+
+   /* for NCQ interrupt analysis */
+   u32 dhfis_bits;
+   u32 dmafis_bits;
+   u32 sdbfis_bits;
+
+   unsigned intncq_saw_d2h:1;
+   unsigned intncq_saw_dmas:1;
+   unsigned intncq_saw_sdb:1;
+   unsigned intncq_saw_backout:1;
+};
+
+
 #define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & ( 1 << (19 + (12 * (PORT)
 
 static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
@@ -263,13 +323,29 @@ static void nv_adma_host_stop(struct ata
 static void nv_adma_post_internal_cmd(struct ata_queued_cmd *qc);
 static void nv_adma_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
 
+static void nv_mcp55_thaw(struct ata_port *ap);
+static void nv_mcp55_freeze(struct ata_port *ap);
+static void nv_swncq_error_handler(struct ata_port *ap);
+static int nv_swncq_slave_config(struct scsi_device *sdev);
+static int nv_swncq_port_start(struct ata_port *ap);
+static void nv_swncq_qc_prep(struct ata_queued_cmd *qc);
+static void nv_swncq_fill_sg(struct ata_queued_cmd *qc);
+static unsigned int nv_swncq_qc_issue(struct ata_queued_cmd *qc);
+static void nv_swncq_irq_clear(struct ata_port *ap, u16 fis);
+static irqreturn_t nv_swncq_interrupt(int irq, void *dev_instance);
+#ifdef CONFIG_PM
+static int nv_swncq_port_suspend(struct ata_port *ap, pm_message_t mesg);
+static int nv_swncq_port_resume(struct ata_port *ap);
+#endif
+
 enum nv_host_type
 {
GENERIC,
NFORCE2,
NFORCE3 = NFORCE2,  /* NF2 == NF3 as far as sata_nv is concerned */
CK804,
-   ADMA
+   ADMA,
+   SWNCQ
 };
 
 static const struct pci_device_id nv_pci_tbl[] = {
@@ -280,13 +356,13 @@ static const struct pci_device_id nv_pci
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_SATA2), CK804 },
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA), CK804 },
{ PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA2), CK804 },
-   { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_SATA), GENERIC 
},
-