All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <nks@flawful.org>
To: John Snow <jsnow@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
	Damien Le Moal <dlemoal@kernel.org>,
	Niklas Cassel <niklas.cassel@wdc.com>
Subject: [PATCH 8/9] hw/ide/ahci: fix ahci_write_fis_sdb()
Date: Fri, 28 Apr 2023 15:21:23 +0200	[thread overview]
Message-ID: <20230428132124.670840-9-nks@flawful.org> (raw)
In-Reply-To: <20230428132124.670840-1-nks@flawful.org>

From: Niklas Cassel <niklas.cassel@wdc.com>

When there is an error, we need to raise a TFES error irq, see AHCI 1.3.1,
5.3.13.1 SDB:Entry.

If ERR_STAT is set, we jump to state ERR:FatalTaskfile, which will raise
a TFES IRQ unconditionally, regardless if the I bit is set in the FIS or
not.

Thus, we should never raise a normal IRQ after having sent an error IRQ.

It is valid to signal successfully completed commands as finished in the
same SDB FIS that generates the error IRQ. The important thing is that
commands that did not complete successfully (e.g. commands that were
aborted, do not get the finished bit set).

Before this commit, there was never a TFES IRQ raised on NCQ error.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
---
 hw/ide/ahci.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index d88961b4c0..4950d3575e 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -806,8 +806,14 @@ static void ahci_write_fis_sdb(AHCIState *s, NCQTransferState *ncq_tfs)
     pr->scr_act &= ~ad->finished;
     ad->finished = 0;
 
-    /* Trigger IRQ if interrupt bit is set (which currently, it always is) */
-    if (sdb_fis->flags & 0x40) {
+    /*
+     * TFES IRQ is always raised if ERR_STAT is set, regardless of I bit.
+     * If ERR_STAT is not set, trigger SDBS IRQ if interrupt bit is set
+     * (which currently, it always is).
+     */
+    if (sdb_fis->status & ERR_STAT) {
+        ahci_trigger_irq(s, ad, AHCI_PORT_IRQ_BIT_TFES);
+    } else if (sdb_fis->flags & 0x40) {
         ahci_trigger_irq(s, ad, AHCI_PORT_IRQ_BIT_SDBS);
     }
 }
-- 
2.40.0



  parent reply	other threads:[~2023-04-28 13:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 13:21 [PATCH 0/9] misc AHCI cleanups Niklas Cassel
2023-04-28 13:21 ` [PATCH 1/9] hw/ide/ahci: remove stray backslash Niklas Cassel
2023-04-28 22:17   ` Philippe Mathieu-Daudé
2023-05-17 17:14   ` John Snow
2023-04-28 13:21 ` [PATCH 2/9] hw/ide/core: set ERR_STAT in unsupported command completion Niklas Cassel
2023-05-17 21:12   ` John Snow
2023-06-01 13:28     ` Niklas Cassel
2023-04-28 13:21 ` [PATCH 3/9] hw/ide/ahci: write D2H FIS on when processing NCQ command Niklas Cassel
2023-05-17 21:18   ` John Snow
2023-04-28 13:21 ` [PATCH 4/9] hw/ide/ahci: simplify and document PxCI handling Niklas Cassel
2023-04-28 13:21 ` [PATCH 5/9] hw/ide/ahci: PxCI should not get cleared when ERR_STAT is set Niklas Cassel
2023-04-28 13:21 ` [PATCH 6/9] hw/ide/ahci: PxSACT and PxCI is cleared when PxCMD.ST is cleared Niklas Cassel
2023-05-17 21:21   ` John Snow
2023-04-28 13:21 ` [PATCH 7/9] hw/ide/ahci: trigger either error IRQ or regular IRQ, not both Niklas Cassel
2023-05-17 21:22   ` John Snow
2023-04-28 13:21 ` Niklas Cassel [this message]
2023-04-28 13:21 ` [PATCH 9/9] hw/ide/ahci: fix broken SError handling Niklas Cassel
2023-05-17 21:26   ` John Snow
2023-05-17 17:06 ` [PATCH 0/9] misc AHCI cleanups John Snow
2023-06-01 13:56   ` Niklas Cassel

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=20230428132124.670840-9-nks@flawful.org \
    --to=nks@flawful.org \
    --cc=dlemoal@kernel.org \
    --cc=jsnow@redhat.com \
    --cc=niklas.cassel@wdc.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.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 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.