From nobody Tue Jan  7 06:18:10 2025
Delivered-To: importer@patchew.org
Received-SPF: pass (zohomail.com: domain of seabios.org designates
 78.46.105.101 as permitted sender) client-ip=78.46.105.101;
 envelope-from=seabios-bounces@seabios.org; helo=coreboot.org;
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as
 permitted sender)  smtp.mailfrom=seabios-bounces@seabios.org;
	dmarc=pass(p=reject dis=none)  header.from=seabios.org
ARC-Seal: i=1; a=rsa-sha256; t=1685454278; cv=none;
	d=zohomail.com; s=zohoarc;
	b=oC4AaVivVX7nhFyUCkzJKm84zrd2moDkgtOnl9/TjwpfXT8QCVxHzyhpnCtpnD9rcKyPSTkiwHzpz0V1NGifPueUjQ0fai3MSPV0SZFHVoo/D70DL5eiO7QAkS9D37mHEibtJwYf0FnODkkrGw0syytBzrEcd2DyXgL8FIZxE+Y=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1685454278;
 h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Subject:To;
	bh=J8YKZ83Iw5O2fubMODkdfd/B1lEGCsv/uigm/NuzkpA=;
	b=ThXrwRSvutGThD1Gi1H2oY/EgnViL90XVmE5H1O8zVqm4UW9LBATk4XwZ6lOhJFSyBGGkUgfPfVf4NHyBNP9ngHhL3o+OwbViXL20Kwe75Mg1J4CLAVM+4xUggka8P3Yie1ek1yOn30w6qGBI9NUF+bDN+mbqlcV2UDjDcH+DS4=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as
 permitted sender)  smtp.mailfrom=seabios-bounces@seabios.org;
	dmarc=pass header.from=<seabios@seabios.org> (p=reject dis=none)
Return-Path: <seabios-bounces@seabios.org>
Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com
	with SMTPS id 1685454278280205.69014270537843;
 Tue, 30 May 2023 06:44:38 -0700 (PDT)
Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP])
	by coreboot.org (Postfix) with ESMTPA id 71AD421EFB;
	Tue, 30 May 2023 13:44:33 +0000 (UTC)
Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP])
	by coreboot.org (Postfix) with ESMTP id 044D720305
	for <seabios@seabios.org>; Tue, 30 May 2023 13:44:16 +0000 (UTC)
Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP])
  by ob1.hgst.iphmx.com with ESMTP; 30 May 2023 21:44:15 +0800
Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP])
  by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256;
 30 May 2023 05:53:27 -0700
Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP])
  by uls-op-cesaip02.wdc.com with ESMTP; 30 May 2023 06:44:11 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seabios.org; s=dkim;
	t=1685454275; h=from:from:sender:reply-to:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:in-reply-to:
	 references:list-id:list-owner:list-unsubscribe:list-subscribe:list-post;
	bh=J8YKZ83Iw5O2fubMODkdfd/B1lEGCsv/uigm/NuzkpA=;
	b=hBzkSleFoiT2PwOYW3yuADfSeVJStSIa8Y836qHbKAD7B3Jviod0U6qVUJFQ8vAx3yEwBd
	YIU0P5PwxlMTtyXbLrujEkcUNVIJAIhJQlm5B8zo4kIF1rZaLcHCTGq71Njk3yq3LWMjEv
	KdoXNnzWvwS/wIhjKAr45jtipTtXN+Q=
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
  d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com;
  t=1685454257; x=1716990257;
  h=from:to:cc:subject:date:message-id:mime-version:
   content-transfer-encoding;
  bh=emoXCS6b59DNCDnPp6v7dg7Oci1linIuKxEjgWQyxjU=;
  b=oYHgFzhiSMTnT+7/3Di6toG6eVd9Yc3tdUYezTeNWkM6CgZRPeUDxav9
   0jPP+XL5mB+ddyfBOKuU5InQfs1q1qW83sz1f4orNtbxpyiyR0OtXmW/2
   SOI2wYt4IST1WUsi8Svdu7JeIhh2tF+oLd+CF12V7TfzeM9sDXIRW/oZd
   fCb3FtBYBbY96Vzih57gKA36cpFtf8F/WA0aNwSL/7Xml+g8LQVk19sAO
   ALVQlAAvQ8tRetzVOWCxK4dFInDt4Xzm5lkw1KDWWw6BhZKIGrrGLNDN5
   i11WyJ9bdrPrcIlIzT72RDlwQ3PZStwPeL+HzGldDNByOywNTd9vmTLZH
   Q==;
X-IronPort-AV: E=Sophos;i="6.00,204,1681142400";
   d="scan'208";a="231975540"
IronPort-SDR: 
 jKHmFsdCxTWpFmUG0OsIbHYiNTzIfM5/z/fhZYQS+4xX9W9UQFISrKVu/1NeQ0ULRbsM6SUL6L
 tFiVLvxYREoIn6I189ATlL5FYS4d31R6i0U21AmY/mKBfz4LGOk3fsd6pVP7DKpVvbUhEhKtLJ
 jE24iuJtU4wIZ/rBFerz6Wgb2l0aV6dOXCNbDYQ0Hn/O9PZoRafC/tyfikeD3Sh/p5mWIlsZpZ
 eUqi6G/zVA+w36rycn3PNBEa5vIoh531QvO1dhRHOXH6FREPjwZxvzVTdJMg17bF/SoEKd5oZr
 luo=
IronPort-SDR: 
 YgFRa/X1tc9v4giQlwRw6Ls+xD23zvHtHmfyBfPmso7mWZgZ0Ygp3nYupfHZD9f1wNM9pHzN4u
 br9DnLME8+BrlBw7ZzqxWK88wplDnvelOXRcStQ0/LMtXm0gbbwJOzaaQ74eXt0WFDDouIDSO0
 W/ffyTbPLE/4l8KNxVGtCn8gN9druZ9SFLGtDpGnJWnLHTl/O39pys9aNr8jSrks2YBpNUnmj4
 SD8de9HrXI5L0v46Iidfv4qV47StysFlotTM/ryCvU3KzZrzmd6OPzGBnSK/GaLrIeCwzKD8jg
 sh8=
WDCIronportException: Internal
To: seabios@seabios.org
Date: Tue, 30 May 2023 15:44:05 +0200
Message-Id: <20230530134405.320901-1-niklas.cassel@wdc.com>
MIME-Version: 1.0
X-Spam-Level: ***
Message-ID-Hash: RIHV3FZ4EVMAJA4TEDPASKNYV7V72O4C
X-Message-ID-Hash: RIHV3FZ4EVMAJA4TEDPASKNYV7V72O4C
X-MailFrom: prvs=507d5711c=niklas.cassel@wdc.com
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency;
 loop; banned-address; member-moderation; header-match-seabios.seabios.org-0;
 header-match-seabios.seabios.org-1; nonmember-moderation; administrivia;
 implicit-dest; max-recipients; max-size; news-moderation; no-subject;
 digests; suspicious-header
CC: Damien Le Moal <dlemoal@kernel.org>, John Snow <jsnow@redhat.com>,
 Niklas Cassel <niklas.cassel@wdc.com>
X-Mailman-Version: 3.3.6b1
Precedence: list
Subject: [SeaBIOS] [PATCH] ahci: handle TFES irq correctly
List-Id: SeaBIOS mailing list <seabios.seabios.org>
Archived-At: 
 <https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/message/RIHV3FZ4EVMAJA4TEDPASKNYV7V72O4C/>
List-Archive: <https://mail.coreboot.org/hyperkitty/list/seabios@seabios.org/>
List-Help: <mailto:seabios-request@seabios.org?subject=help>
List-Owner: <mailto:seabios-owner@seabios.org>
List-Post: <mailto:seabios@seabios.org>
List-Subscribe: <mailto:seabios-join@seabios.org>
List-Unsubscribe: <mailto:seabios-leave@seabios.org>
From: Niklas Cassel via SeaBIOS <seabios@seabios.org>
Reply-To: Niklas Cassel <niklas.cassel@wdc.com>
Content-Transfer-Encoding: quoted-printable
Authentication-Results: coreboot.org;
	auth=pass smtp.auth=mailman@coreboot.org
 smtp.mailfrom=seabios-bounces@seabios.org
X-Spamd-Bar: /
X-ZohoMail-DKIM: pass (identity @seabios.org)
X-ZM-MESSAGEID: 1685454280049100001
Content-Type: text/plain; charset="utf-8"

According to AHCI 1.3.1, 5.3.8.1 RegFIS:Entry, if ERR_STAT is set in the
received FIS, the HBA shall jump to state ERR:FatalTaskfile, which will
raise a TFES IRQ.

This means that if ERR_STAT is set in the recevied FIS, PxIS.TFES will
be set, without either PxIS.DHRS or PxIS.PSS being set.

SeaBIOS function ahci_port_setup() will try to identify an AHCI device
by sending an ATAPI identify device command. However, such a command
will be aborted with ERR_STAT set for a regular (non-ATAPI) device.

ahci_command() already performs the correct error recovery steps when
status is correctly set, so simply modify ahci_command() to read the
correct status when PxIS.TFES is set.

It is safe to read PxTFD when PxIS.TFES is set, even for systems with a
port multiplier, see AHCI 1.3.1, 9.3.7 PxTFD Register Information:
"When a taskfile error occurs (PxIS.TFES is set to '1'), the host may
refer to the values in PxTFD. The values in PxTFD at this time are
guaranteed to correspond to the device that reported the taskfile error
condition."

Without this, each boot will be delayed by 32 seconds, waiting for the
AHCI command to timeout.

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
---
 src/hw/ahci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/hw/ahci.c b/src/hw/ahci.c
index d45b430..3fa845a 100644
--- a/src/hw/ahci.c
+++ b/src/hw/ahci.c
@@ -138,6 +138,12 @@ static int ahci_command(struct ahci_port_s *port_gf, i=
nt iswrite, int isatapi,
             intbits =3D ahci_port_readl(ctrl, pnr, PORT_IRQ_STAT);
             if (intbits) {
                 ahci_port_writel(ctrl, pnr, PORT_IRQ_STAT, intbits);
+                if (intbits & 0x40000000) {
+                    u32 tf =3D ahci_port_readl(ctrl, pnr, PORT_TFDATA);
+                    status =3D tf & 0xff;
+                    error =3D (tf & 0xff00) >> 8;
+                    break;
+                }
                 if (intbits & 0x02) {
                     status =3D GET_LOWFLAT(fis->psfis[2]);
                     error  =3D GET_LOWFLAT(fis->psfis[3]);
--=20
2.40.1

_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-leave@seabios.org