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 09/12] sata_mv new mv_port_intr function
Date: Fri, 02 May 2008 02:14:02 -0400 [thread overview]
Message-ID: <481AB12A.3030102@rtr.ca> (raw)
In-Reply-To: <481AB107.701@rtr.ca>
Separate out the inner loop body of mv_host_intr()
into it's own function called mv_port_intr().
This should help maintainabilty.
Signed-off-by: Mark Lord <mlord@pobox.com>
---
Ignore the checkpatch.pl "braces {} are not necessary" warning for now.
A subsequent patch installs more code within them.
--- old/drivers/ata/sata_mv.c 2008-05-01 20:15:59.000000000 -0400
+++ linux/drivers/ata/sata_mv.c 2008-05-01 20:01:40.000000000 -0400
@@ -1591,25 +1591,22 @@
return qc;
}
-static void mv_unexpected_intr(struct ata_port *ap)
+static void mv_unexpected_intr(struct ata_port *ap, int edma_was_enabled)
{
- struct mv_port_priv *pp = ap->private_data;
struct ata_eh_info *ehi = &ap->link.eh_info;
- char *when = "";
+ char *when = "idle";
- /*
- * We got a device interrupt from something that
- * was supposed to be using EDMA or polling.
- */
ata_ehi_clear_desc(ehi);
- if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) {
- when = " while EDMA enabled";
+ if (!ap || (ap->flags & ATA_FLAG_DISABLED)) {
+ when = "disabled";
+ } else if (edma_was_enabled) {
+ when = "EDMA enabled";
} else {
struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->link.active_tag);
if (qc && (qc->tf.flags & ATA_TFLAG_POLLING))
- when = " while polling";
+ when = "polling";
}
- ata_ehi_push_desc(ehi, "unexpected device interrupt%s", when);
+ ata_ehi_push_desc(ehi, "unexpected device interrupt while %s", when);
ehi->err_mask |= AC_ERR_OTHER;
ehi->action |= ATA_EH_RESET;
ata_port_freeze(ap);
@@ -1807,6 +1804,42 @@
port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
}
+static void mv_port_intr(struct ata_port *ap, u32 port_cause)
+{
+ struct mv_port_priv *pp;
+ int edma_was_enabled;
+
+ if (!ap || (ap->flags & ATA_FLAG_DISABLED)) {
+ mv_unexpected_intr(ap, 0);
+ return;
+ }
+ /*
+ * Grab a snapshot of the EDMA_EN flag setting,
+ * so that we have a consistent view for this port,
+ * even if something we call of our routines changes it.
+ */
+ pp = ap->private_data;
+ edma_was_enabled = (pp->pp_flags & MV_PP_FLAG_EDMA_EN);
+ /*
+ * Process completed CRPB response(s) before other events.
+ */
+ if (edma_was_enabled && (port_cause & DONE_IRQ)) {
+ mv_process_crpb_entries(ap, pp);
+ }
+ /*
+ * Handle chip-reported errors, or continue on to handle PIO.
+ */
+ if (unlikely(port_cause & ERR_IRQ)) {
+ mv_err_intr(ap);
+ } else if (!edma_was_enabled) {
+ struct ata_queued_cmd *qc = mv_get_active_qc(ap);
+ if (qc)
+ ata_sff_host_intr(ap, qc);
+ else
+ mv_unexpected_intr(ap, edma_was_enabled);
+ }
+}
+
/**
* mv_host_intr - Handle all interrupts on the given host controller
* @host: host specific structure
@@ -1823,7 +1856,6 @@
for (port = 0; port < hpriv->n_ports; port++) {
struct ata_port *ap = host->ports[port];
- struct mv_port_priv *pp;
unsigned int p, shift, hardport, port_cause;
MV_PORT_TO_SHIFT_AND_HARDPORT(port, shift, hardport);
@@ -1865,32 +1897,12 @@
writelfl(~ack_irqs, hc_mmio + HC_IRQ_CAUSE_OFS);
handled = 1;
}
- port_cause = (main_irq_cause >> shift) & (DONE_IRQ | ERR_IRQ);
- if (!port_cause)
- continue;
/*
- * Process completed CRPB response(s) before other events.
+ * Handle interrupts signalled for this port:
*/
- pp = ap->private_data;
- if (port_cause & DONE_IRQ) {
- if (pp->pp_flags & MV_PP_FLAG_EDMA_EN)
- mv_process_crpb_entries(ap, pp);
- }
- /*
- * Handle chip-reported errors, or continue on to handle PIO.
- */
- if (unlikely(port_cause & ERR_IRQ)) {
- mv_err_intr(ap);
- } else {
- if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) {
- struct ata_queued_cmd *qc = mv_get_active_qc(ap);
- if (qc) {
- ata_sff_host_intr(ap, qc);
- continue;
- }
- mv_unexpected_intr(ap);
- }
- }
+ port_cause = (main_irq_cause >> shift) & (DONE_IRQ | ERR_IRQ);
+ if (port_cause)
+ mv_port_intr(ap, port_cause);
}
return handled;
}
next prev parent reply other threads:[~2008-05-02 6:14 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 ` [PATCH 04/12] sata_mv new mv_qc_defer method Mark Lord
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 ` Mark Lord [this message]
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=481AB12A.3030102@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).