All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] sata_mv: Prevent PIO commands to be defered too long if traffic in progress.
@ 2009-10-12 22:43 Gwendal Grignou
  2009-10-12 22:44 ` [PATCH 1/1] " Gwendal Grignou
  0 siblings, 1 reply; 6+ messages in thread
From: Gwendal Grignou @ 2009-10-12 22:43 UTC (permalink / raw)
  To: mlord; +Cc: linux-ide

Hello,

I found a bug in the sata_mv driver, that defers PIO commands indefinitely
while there is a traffic on other ports of a sata port multiplier [PMP]:

without traffic:
time smartctl --all /dev/sdc > /dev/null
real    0m0.243s

with fio running and blasting read IOs on 5 drives behind the same port multiplier for 5 minutes:
real    4m59.353s

Obviously the PIO commands are defer while traffic is in progress.

With the patch following, smart_ctl return before fio complete. It still takes 4s, time for all NCQ commands to be flushed out.
real    0m4.074s

Gwendal.

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

* [PATCH 1/1] sata_mv: Prevent PIO commands to be defered too long if traffic in progress.
  2009-10-12 22:43 [PATCH 0/1] sata_mv: Prevent PIO commands to be defered too long if traffic in progress Gwendal Grignou
@ 2009-10-12 22:44 ` Gwendal Grignou
  2009-10-13  1:44   ` Grant Grundler
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Gwendal Grignou @ 2009-10-12 22:44 UTC (permalink / raw)
  To: mlord; +Cc: linux-ide, Gwendal Grignou

Use excl_link when non NCQ commands are defered, to be sure they are processed
as soon as outstanding commands are completed. It prevents some commands to be
defered indifinitely when using a port multiplier.

Signed-off-by: Gwendal Grignou <gwendal@google.com>
---
 drivers/ata/sata_mv.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 17f9ff9..6f5093b 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -1382,6 +1382,25 @@ static int mv_qc_defer(struct ata_queued_cmd *qc)
 	 */
 	if (pp->pp_flags & MV_PP_FLAG_DELAYED_EH)
 		return ATA_DEFER_PORT;
+
+	/* PIO commands need exclusive link: no other commands [DMA or PIO]
+	 * can run concurrently.
+	 * set excl_link when we want to send a PIO command in DMA mode
+	 * or a non-NCQ command in NCQ mode.
+	 * When we receive a command from that link, and there are no
+	 * outstanding commands, mark a flag to clear excl_link and let
+	 * the command go through.
+	 */
+	if (unlikely(ap->excl_link)) {
+		if (link == ap->excl_link) {
+			if (ap->nr_active_links)
+				return ATA_DEFER_PORT;
+			qc->flags |= ATA_QCFLAG_CLEAR_EXCL;
+			return 0;
+		} else
+			return ATA_DEFER_PORT;
+	}
+
 	/*
 	 * If the port is completely idle, then allow the new qc.
 	 */
@@ -1395,8 +1414,14 @@ static int mv_qc_defer(struct ata_queued_cmd *qc)
 	 * doesn't allow it.
 	 */
 	if ((pp->pp_flags & MV_PP_FLAG_EDMA_EN) &&
-	    (pp->pp_flags & MV_PP_FLAG_NCQ_EN) && ata_is_ncq(qc->tf.protocol))
-		return 0;
+	    (pp->pp_flags & MV_PP_FLAG_NCQ_EN)) {
+		if (ata_is_ncq(qc->tf.protocol))
+			return 0;
+		else {
+			ap->excl_link = link;
+			return ATA_DEFER_PORT;
+		}
+	}
 
 	return ATA_DEFER_PORT;
 }
-- 
1.5.4.3


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

* Re: [PATCH 1/1] sata_mv: Prevent PIO commands to be defered too long if traffic in progress.
  2009-10-12 22:44 ` [PATCH 1/1] " Gwendal Grignou
@ 2009-10-13  1:44   ` Grant Grundler
  2009-10-14 12:35   ` Mark Lord
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Grant Grundler @ 2009-10-13  1:44 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: mlord, linux-ide

On Mon, Oct 12, 2009 at 3:44 PM, Gwendal Grignou <gwendal@google.com> wrote:
> Use excl_link when non NCQ commands are defered, to be sure they are processed
> as soon as outstanding commands are completed. It prevents some commands to be
> defered indifinitely when using a port multiplier.
>
> Signed-off-by: Gwendal Grignou <gwendal@google.com>

Reviewed-by: Grant Grundler <grundler@google.com>

thanks,
grant

> ---
>  drivers/ata/sata_mv.c |   29 +++++++++++++++++++++++++++--
>  1 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> index 17f9ff9..6f5093b 100644
> --- a/drivers/ata/sata_mv.c
> +++ b/drivers/ata/sata_mv.c
> @@ -1382,6 +1382,25 @@ static int mv_qc_defer(struct ata_queued_cmd *qc)
>         */
>        if (pp->pp_flags & MV_PP_FLAG_DELAYED_EH)
>                return ATA_DEFER_PORT;
> +
> +       /* PIO commands need exclusive link: no other commands [DMA or PIO]
> +        * can run concurrently.
> +        * set excl_link when we want to send a PIO command in DMA mode
> +        * or a non-NCQ command in NCQ mode.
> +        * When we receive a command from that link, and there are no
> +        * outstanding commands, mark a flag to clear excl_link and let
> +        * the command go through.
> +        */
> +       if (unlikely(ap->excl_link)) {
> +               if (link == ap->excl_link) {
> +                       if (ap->nr_active_links)
> +                               return ATA_DEFER_PORT;
> +                       qc->flags |= ATA_QCFLAG_CLEAR_EXCL;
> +                       return 0;
> +               } else
> +                       return ATA_DEFER_PORT;
> +       }
> +
>        /*
>         * If the port is completely idle, then allow the new qc.
>         */
> @@ -1395,8 +1414,14 @@ static int mv_qc_defer(struct ata_queued_cmd *qc)
>         * doesn't allow it.
>         */
>        if ((pp->pp_flags & MV_PP_FLAG_EDMA_EN) &&
> -           (pp->pp_flags & MV_PP_FLAG_NCQ_EN) && ata_is_ncq(qc->tf.protocol))
> -               return 0;
> +           (pp->pp_flags & MV_PP_FLAG_NCQ_EN)) {
> +               if (ata_is_ncq(qc->tf.protocol))
> +                       return 0;
> +               else {
> +                       ap->excl_link = link;
> +                       return ATA_DEFER_PORT;
> +               }
> +       }
>
>        return ATA_DEFER_PORT;
>  }
> --
> 1.5.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH 1/1] sata_mv: Prevent PIO commands to be defered too long if traffic in progress.
  2009-10-12 22:44 ` [PATCH 1/1] " Gwendal Grignou
  2009-10-13  1:44   ` Grant Grundler
@ 2009-10-14 12:35   ` Mark Lord
  2009-10-14 12:38   ` Jeff Garzik
  2009-10-16 10:26   ` Jeff Garzik
  3 siblings, 0 replies; 6+ messages in thread
From: Mark Lord @ 2009-10-14 12:35 UTC (permalink / raw)
  To: Gwendal Grignou, Jeff Garzik; +Cc: linux-ide, Grant Grundler

Gwendal Grignou wrote:
> Use excl_link when non NCQ commands are defered, to be sure they are processed
> as soon as outstanding commands are completed. It prevents some commands to be
> defered indifinitely when using a port multiplier.
> 
> Signed-off-by: Gwendal Grignou <gwendal@google.com>
..
> Reviewed-by: Grant Grundler <grundler@google.com>
..

Reviewed-by: Mark Lord <mlord@pobox.com>

Looks good to me.  Jeff, please feel free to accept sata_mv patches
directly from Gwendal and/or Grant -- they know the chips as well as I do.

Cheers

Mark

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

* Re: [PATCH 1/1] sata_mv: Prevent PIO commands to be defered too long if traffic in progress.
  2009-10-12 22:44 ` [PATCH 1/1] " Gwendal Grignou
  2009-10-13  1:44   ` Grant Grundler
  2009-10-14 12:35   ` Mark Lord
@ 2009-10-14 12:38   ` Jeff Garzik
  2009-10-16 10:26   ` Jeff Garzik
  3 siblings, 0 replies; 6+ messages in thread
From: Jeff Garzik @ 2009-10-14 12:38 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: mlord, linux-ide

On 10/12/2009 06:44 PM, Gwendal Grignou wrote:
> Use excl_link when non NCQ commands are defered, to be sure they are processed
> as soon as outstanding commands are completed. It prevents some commands to be
> defered indifinitely when using a port multiplier.
>
> Signed-off-by: Gwendal Grignou<gwendal@google.com>
> ---
>   drivers/ata/sata_mv.c |   29 +++++++++++++++++++++++++++--
>   1 files changed, 27 insertions(+), 2 deletions(-)

An ACK from Mark, too, I hope?

I'll give this a try on a Gen-IIE chip...

	Jeff





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

* Re: [PATCH 1/1] sata_mv: Prevent PIO commands to be defered too long if traffic in progress.
  2009-10-12 22:44 ` [PATCH 1/1] " Gwendal Grignou
                     ` (2 preceding siblings ...)
  2009-10-14 12:38   ` Jeff Garzik
@ 2009-10-16 10:26   ` Jeff Garzik
  3 siblings, 0 replies; 6+ messages in thread
From: Jeff Garzik @ 2009-10-16 10:26 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: mlord, linux-ide

On 10/12/2009 06:44 PM, Gwendal Grignou wrote:
> Use excl_link when non NCQ commands are defered, to be sure they are processed
> as soon as outstanding commands are completed. It prevents some commands to be
> defered indifinitely when using a port multiplier.
>
> Signed-off-by: Gwendal Grignou<gwendal@google.com>
> ---
>   drivers/ata/sata_mv.c |   29 +++++++++++++++++++++++++++--
>   1 files changed, 27 insertions(+), 2 deletions(-)

applied



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

end of thread, other threads:[~2009-10-16 10:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-12 22:43 [PATCH 0/1] sata_mv: Prevent PIO commands to be defered too long if traffic in progress Gwendal Grignou
2009-10-12 22:44 ` [PATCH 1/1] " Gwendal Grignou
2009-10-13  1:44   ` Grant Grundler
2009-10-14 12:35   ` Mark Lord
2009-10-14 12:38   ` Jeff Garzik
2009-10-16 10:26   ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.