linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Lord <liml@rtr.ca>
To: Jeff Garzik <jgarzik@pobox.com>, Tejun Heo <htejun@gmail.com>,
	IDE/ATA development list <linux-ide@vger.kernel.org>
Subject: [PATCH 04/12] sata_mv new mv_qc_defer method
Date: Fri, 02 May 2008 02:10:02 -0400	[thread overview]
Message-ID: <481AB03A.60808@rtr.ca> (raw)
In-Reply-To: <481AB00A.3000206@rtr.ca>

The EDMA engine cannot tolerate a mix of NCQ/non-NCQ commands,
and cannot be used for PIO at all.  So we need to prevent libata
from trying to feed us such mixtures.

Introduce mv_qc_defer() for this purpose, and use it for all chip versions.

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

--- old/drivers/ata/sata_mv.c	2008-05-01 17:56:54.000000000 -0400
+++ linux/drivers/ata/sata_mv.c	2008-05-01 18:01:04.000000000 -0400
@@ -492,6 +492,7 @@
 static int mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
 static int mv_port_start(struct ata_port *ap);
 static void mv_port_stop(struct ata_port *ap);
+static int mv_qc_defer(struct ata_queued_cmd *qc);
 static void mv_qc_prep(struct ata_queued_cmd *qc);
 static void mv_qc_prep_iie(struct ata_queued_cmd *qc);
 static unsigned int mv_qc_issue(struct ata_queued_cmd *qc);
@@ -561,6 +562,7 @@
 static struct ata_port_operations mv5_ops = {
 	.inherits		= &ata_sff_port_ops,
 
+	.qc_defer		= mv_qc_defer,
 	.qc_prep		= mv_qc_prep,
 	.qc_issue		= mv_qc_issue,
 
@@ -579,7 +581,6 @@
 
 static struct ata_port_operations mv6_ops = {
 	.inherits		= &mv5_ops,
-	.qc_defer		= sata_pmp_qc_defer_cmd_switch,
 	.dev_config             = mv6_dev_config,
 	.scr_read		= mv_scr_read,
 	.scr_write		= mv_scr_write,
@@ -592,7 +593,6 @@
 
 static struct ata_port_operations mv_iie_ops = {
 	.inherits		= &mv6_ops,
-	.qc_defer		= ata_std_qc_defer, /* FIS-based switching */
 	.dev_config		= ATA_OP_NULL,
 	.qc_prep		= mv_qc_prep_iie,
 };
@@ -1090,6 +1090,45 @@
 	}
 }
 
+static int mv_qc_defer(struct ata_queued_cmd *qc)
+{
+	struct ata_link *link = qc->dev->link;
+	struct ata_port *ap = link->ap;
+	struct mv_port_priv *pp = ap->private_data;
+
+	/*
+	 * If the port is completely idle, then allow the new qc.
+	 */
+	if (ap->nr_active_links == 0)
+		return 0;
+
+	if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) {
+		/*
+		 * The port is operating in host queuing mode (EDMA).
+		 * It can accomodate a new qc if the qc protocol
+		 * is compatible with the current host queue mode.
+		 */
+		if (pp->pp_flags & MV_PP_FLAG_NCQ_EN) {
+			/*
+			 * The host queue (EDMA) is in NCQ mode.
+			 * If the new qc is also an NCQ command,
+			 * then allow the new qc.
+			 */
+			if (qc->tf.protocol == ATA_PROT_NCQ)
+				return 0;
+		} else {
+			/*
+			 * The host queue (EDMA) is in non-NCQ, DMA mode.
+			 * If the new qc is also a non-NCQ, DMA command,
+			 * then allow the new qc.
+			 */
+			if (qc->tf.protocol == ATA_PROT_DMA)
+				return 0;
+		}
+	}
+	return ATA_DEFER_PORT;
+}
+
 static void mv_config_fbs(void __iomem *port_mmio, int enable_fbs)
 {
 	u32 old_fiscfg, new_fiscfg, old_ltmode, new_ltmode;

  reply	other threads:[~2008-05-02  6:10 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-02  6:07 [PATCH 00/12] sata_mv: The last big set for 2.6.26 Mark Lord
2008-05-02  6:07 ` [PATCH 01/12] sata_mv more cosmetic changes Mark Lord
2008-05-02  6:08   ` [PATCH 02/12] sata_mv pci features Mark Lord
2008-05-02  6:09     ` [PATCH 03/12] sata_mv wait for empty+idle Mark Lord
2008-05-02  6:10       ` Mark Lord [this message]
2008-05-02  6:10         ` [PATCH 05/12] sata_mv errata workaround for sata25 part 1 Mark Lord
2008-05-02  6:11           ` [PATCH 06/12] sata_mv rearrange mv_config_fbs Mark Lord
2008-05-02  6:12             ` [PATCH 07/12] sata_mv NCQ and SError fixes for mv_err_intr Mark Lord
2008-05-02  6:13               ` [PATCH 08/12] sata_mv fix mv_host_intr bug for hc_irq_cause Mark Lord
2008-05-02  6:14                 ` [PATCH 09/12] sata_mv new mv_port_intr function Mark Lord
2008-05-02  6:14                   ` [PATCH 10/12] sata_mv libata: export ata_eh_analyze_ncq_error Mark Lord
2008-05-02  6:15                     ` [PATCH 11/12] sata_mv delayed eh handling Mark Lord
2008-05-02  6:16                       ` [PATCH 12/12] sata_mv NCQ-EH for FIS-based switching Mark Lord
2008-05-02 12:44                         ` Mark Lord
2008-05-02 16:52                           ` Grant Grundler
2008-05-02 16:54                             ` Grant Grundler
2008-05-02 17:46                               ` Mark Lord
2008-05-02 17:52                                 ` Alan Cox
2008-05-02 17:56                         ` [PATCH 13/13] sata_mv use hweight16() for bit counting Mark Lord
2008-05-02 18:02                           ` Mark Lord
2008-05-02 18:02                           ` [PATCH 13/13] sata_mv use hweight16() for bit counting (V2) Mark Lord
2008-05-02 18:31                             ` Grant Grundler
2008-05-02 16:42       ` [PATCH 03/12] sata_mv wait for empty+idle Grant Grundler
2008-05-02 17:45         ` Mark Lord
2008-05-02 18:39           ` Grant Grundler
2008-05-02 20:09             ` Mark Lord
2008-05-02 16:06     ` [PATCH 02/12] sata_mv pci features Grant Grundler
2008-05-02 17:41       ` Mark Lord
2008-05-02 18:28         ` Grant Grundler
2008-05-06 14:10   ` [PATCH 01/12] sata_mv more cosmetic changes Jeff Garzik
2008-05-06 17:57     ` Mark Lord
2008-05-06 14:17   ` Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=481AB03A.60808@rtr.ca \
    --to=liml@rtr.ca \
    --cc=htejun@gmail.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).