stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Szuying Chen <Chloe_Chen@asmedia.com.tw>,
	Niklas Cassel <niklas.cassel@wdc.com>,
	Damien Le Moal <dlemoal@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.14 19/55] ata: libahci: clear pending interrupt status
Date: Mon,  9 Oct 2023 15:06:18 +0200	[thread overview]
Message-ID: <20231009130108.451550433@linuxfoundation.org> (raw)
In-Reply-To: <20231009130107.717692466@linuxfoundation.org>

4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Szuying Chen <chensiying21@gmail.com>

[ Upstream commit 737dd811a3dbfd7edd4ad2ba5152e93d99074f83 ]

When a CRC error occurs, the HBA asserts an interrupt to indicate an
interface fatal error (PxIS.IFS). The ISR clears PxIE and PxIS, then
does error recovery. If the adapter receives another SDB FIS
with an error (PxIS.TFES) from the device before the start of the EH
recovery process, the interrupt signaling the new SDB cannot be
serviced as PxIE was cleared already. This in turn results in the HBA
inability to issue any command during the error recovery process after
setting PxCMD.ST to 1 because PxIS.TFES is still set.

According to AHCI 1.3.1 specifications section 6.2.2, fatal errors
notified by setting PxIS.HBFS, PxIS.HBDS, PxIS.IFS or PxIS.TFES will
cause the HBA to enter the ERR:Fatal state. In this state, the HBA
shall not issue any new commands.

To avoid this situation, introduce the function
ahci_port_clear_pending_irq() to clear pending interrupts before
executing a COMRESET. This follows the AHCI 1.3.1 - section 6.2.2.2
specification.

Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw>
Fixes: e0bfd149973d ("[PATCH] ahci: stop engine during hard reset")
Cc: stable@vger.kernel.org
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/ata/libahci.c | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 3111c649816a2..563fcef14b7cb 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1196,6 +1196,26 @@ static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
 	return sprintf(buf, "%d\n", emp->blink_policy);
 }
 
+static void ahci_port_clear_pending_irq(struct ata_port *ap)
+{
+	struct ahci_host_priv *hpriv = ap->host->private_data;
+	void __iomem *port_mmio = ahci_port_base(ap);
+	u32 tmp;
+
+	/* clear SError */
+	tmp = readl(port_mmio + PORT_SCR_ERR);
+	dev_dbg(ap->host->dev, "PORT_SCR_ERR 0x%x\n", tmp);
+	writel(tmp, port_mmio + PORT_SCR_ERR);
+
+	/* clear port IRQ */
+	tmp = readl(port_mmio + PORT_IRQ_STAT);
+	dev_dbg(ap->host->dev, "PORT_IRQ_STAT 0x%x\n", tmp);
+	if (tmp)
+		writel(tmp, port_mmio + PORT_IRQ_STAT);
+
+	writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT);
+}
+
 static void ahci_port_init(struct device *dev, struct ata_port *ap,
 			   int port_no, void __iomem *mmio,
 			   void __iomem *port_mmio)
@@ -1210,18 +1230,7 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
 	if (rc)
 		dev_warn(dev, "%s (%d)\n", emsg, rc);
 
-	/* clear SError */
-	tmp = readl(port_mmio + PORT_SCR_ERR);
-	dev_dbg(dev, "PORT_SCR_ERR 0x%x\n", tmp);
-	writel(tmp, port_mmio + PORT_SCR_ERR);
-
-	/* clear port IRQ */
-	tmp = readl(port_mmio + PORT_IRQ_STAT);
-	dev_dbg(dev, "PORT_IRQ_STAT 0x%x\n", tmp);
-	if (tmp)
-		writel(tmp, port_mmio + PORT_IRQ_STAT);
-
-	writel(1 << port_no, mmio + HOST_IRQ_STAT);
+	ahci_port_clear_pending_irq(ap);
 
 	/* mark esata ports */
 	tmp = readl(port_mmio + PORT_CMD);
@@ -1551,6 +1560,8 @@ int ahci_do_hardreset(struct ata_link *link, unsigned int *class,
 	tf.command = ATA_BUSY;
 	ata_tf_to_fis(&tf, 0, 0, d2h_fis);
 
+	ahci_port_clear_pending_irq(ap);
+
 	rc = sata_link_hardreset(link, timing, deadline, online,
 				 ahci_check_ready);
 
-- 
2.40.1




  parent reply	other threads:[~2023-10-09 13:49 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 13:05 [PATCH 4.14 00/55] 4.14.327-rc1 review Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 01/55] NFS/pNFS: Report EINVAL errors from connect() to the server Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 02/55] ipv4: fix null-deref in ipv4_link_failure Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 03/55] powerpc/perf/hv-24x7: Update domain value check Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 04/55] dccp: fix dccp_v4_err()/dccp_v6_err() again Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 05/55] team: fix null-ptr-deref when team device type is changed Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 06/55] gpio: tb10x: Fix an error handling path in tb10x_gpio_probe() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 07/55] i2c: mux: demux-pinctrl: check the return value of devm_kstrdup() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 08/55] clk: tegra: fix error return case for recalc_rate Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 09/55] xtensa: boot: dont add include-dirs Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 10/55] xtensa: boot/lib: fix function prototypes Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 11/55] parisc: sba: Fix compile warning wrt list of SBA devices Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 12/55] parisc: iosapic.c: Fix sparse warnings Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 13/55] parisc: irq: Make irq_stack_union static to avoid sparse warning Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 14/55] selftests/ftrace: Correctly enable event in instance-event.tc Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 15/55] ring-buffer: Avoid softlockup in ring_buffer_resize() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 16/55] ata: libata-eh: do not clear ATA_PFLAG_EH_PENDING in ata_eh_reset() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 17/55] fbdev/sh7760fb: Depend on FB=y Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 18/55] ata: ahci: Drop pointless VPRINTK() calls and convert the remaining ones Greg Kroah-Hartman
2023-10-09 13:06 ` Greg Kroah-Hartman [this message]
2023-10-09 13:06 ` [PATCH 4.14 20/55] watchdog: iTCO_wdt: No need to stop the timer in probe Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 21/55] watchdog: iTCO_wdt: Set NO_REBOOT if the watchdog is not already running Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 22/55] serial: 8250_port: Check IRQ data before use Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 23/55] nilfs2: fix potential use after free in nilfs_gccache_submit_read_data() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 24/55] ata: libata-scsi: ignore reserved bits for REPORT SUPPORTED OPERATION CODES Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 25/55] i2c: i801: unregister tco_pdev in i801_probe() error path Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 26/55] btrfs: properly report 0 avail for very full file systems Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 27/55] ata: libata-core: Fix ata_port_request_pm() locking Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 28/55] ata: libata-core: Fix port and device removal Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 29/55] ata: libata-sata: increase PMP SRST timeout to 10s Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 30/55] fs: binfmt_elf_efpic: fix personality for ELF-FDPIC Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 31/55] vc_screen: reload load of struct vc_data pointer in vcs_write() to avoid UAF Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 32/55] ext4: fix rec_len verify error Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 33/55] net/sched: sch_hfsc: Ensure inner classes have fsc curve Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 34/55] ata: libata: disallow dev-initiated LPM transitions to unsupported states Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 35/55] media: dvb: symbol fixup for dvb_attach() - again Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 36/55] scsi: zfcp: Fix a double put in zfcp_port_enqueue() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 37/55] wifi: mwifiex: Fix tlv_buf_left calculation Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 38/55] btrfs: reject unknown mount options early Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 39/55] ubi: Refuse attaching if mtds erasesize is 0 Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 40/55] wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 41/55] drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 42/55] regmap: rbtree: Fix wrong register marked as in-cache when creating new node Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 43/55] scsi: target: core: Fix deadlock due to recursive locking Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 44/55] modpost: add missing else to the "of" check Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 45/55] ipv4, ipv6: Fix handling of transhdrlen in __ip{,6}_append_data() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 46/55] net: usb: smsc75xx: Fix uninit-value access in __smsc75xx_read_reg Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 47/55] tcp: fix delayed ACKs for MSS boundary condition Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 48/55] sctp: update transport state when processing a dupcook packet Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 49/55] sctp: update hb timer immediately after users change hb_interval Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 50/55] cpupower: add Makefile dependencies for install targets Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 51/55] IB/mlx4: Fix the size of a buffer in add_port_entries() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 52/55] gpio: aspeed: fix the GPIO number passed to pinctrl_gpio_set_config() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 53/55] RDMA/cma: Fix truncation compilation warning in make_cma_ports Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 54/55] RDMA/mlx5: Fix NULL string error Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.14 55/55] parisc: Restore __ldcw_align for PA-RISC 2.0 processors Greg Kroah-Hartman
2023-10-10  9:57 ` [PATCH 4.14 00/55] 4.14.327-rc1 review Jon Hunter
2023-10-10 14:49 ` Harshit Mogalapalli
2023-10-10 18:17 ` Guenter Roeck
2023-10-11  1:18 ` Naresh Kamboju

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=20231009130108.451550433@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=Chloe_Chen@asmedia.com.tw \
    --cc=dlemoal@kernel.org \
    --cc=niklas.cassel@wdc.com \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@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).