Archive-only list for patches
 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.19 03/91] ata: libahci: clear pending interrupt status
Date: Mon,  9 Oct 2023 15:05:35 +0200	[thread overview]
Message-ID: <20231009130111.652564497@linuxfoundation.org> (raw)
In-Reply-To: <20231009130111.518916887@linuxfoundation.org>

4.19-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 00eef92e91e57..b93fad6939dac 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1210,6 +1210,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)
@@ -1224,18 +1244,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);
@@ -1565,6 +1574,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:50 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 13:05 [PATCH 4.19 00/91] 4.19.296-rc1 review Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 01/91] NFS/pNFS: Report EINVAL errors from connect() to the server Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 02/91] ata: ahci: Drop pointless VPRINTK() calls and convert the remaining ones Greg Kroah-Hartman
2023-10-09 13:05 ` Greg Kroah-Hartman [this message]
2023-10-09 13:05 ` [PATCH 4.19 04/91] netfilter: nf_tables: disallow element removal on anonymous sets Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 05/91] selftests/tls: Add {} to avoid static checker warning Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 06/91] selftests: tls: swap the TX and RX sockets in some tests Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 07/91] ipv4: fix null-deref in ipv4_link_failure Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 08/91] powerpc/perf/hv-24x7: Update domain value check Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 09/91] net: hns3: add 5ms delay before clear firmware reset irq source Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 10/91] net: add atomic_long_t to net_device_stats fields Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 11/91] net: bridge: use DEV_STATS_INC() Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 12/91] team: fix null-ptr-deref when team device type is changed Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 13/91] gpio: tb10x: Fix an error handling path in tb10x_gpio_probe() Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 14/91] i2c: mux: demux-pinctrl: check the return value of devm_kstrdup() Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 15/91] Input: i8042 - add quirk for TUXEDO Gemini 17 Gen1/Clevo PD70PN Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 16/91] scsi: qla2xxx: Add protection mask module parameters Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 17/91] scsi: qla2xxx: Remove unsupported ql2xenabledif option Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 18/91] scsi: megaraid_sas: Load balance completions across all MSI-X Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 19/91] scsi: megaraid_sas: Fix deadlock on firmware crashdump Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 20/91] ext4: remove the group parameter of ext4_trim_extent Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 21/91] ext4: add new helper interface ext4_try_to_trim_range() Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 22/91] ext4: scope ret locally in ext4_try_to_trim_range() Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 23/91] ext4: change s_last_trim_minblks type to unsigned long Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 24/91] ext4: mark group as trimmed only if it was fully scanned Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 25/91] ext4: replace the traditional ternary conditional operator with with max()/min() Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 26/91] ext4: move setting of trimmed bit into ext4_try_to_trim_range() Greg Kroah-Hartman
2023-10-09 13:05 ` [PATCH 4.19 27/91] ext4: do not let fstrim block system suspend Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 28/91] MIPS: Alchemy: only build mmc support helpers if au1xmmc is enabled Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 29/91] clk: tegra: fix error return case for recalc_rate Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 30/91] ARM: dts: ti: omap: motorola-mapphone: Fix abe_clkctrl warning on boot Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 31/91] gpio: pmic-eic-sprd: Add can_sleep flag for PMIC EIC chip Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 32/91] parisc: sba: Fix compile warning wrt list of SBA devices Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 33/91] parisc: iosapic.c: Fix sparse warnings Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 34/91] parisc: drivers: Fix sparse warning Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 35/91] parisc: irq: Make irq_stack_union static to avoid " Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 36/91] selftests/ftrace: Correctly enable event in instance-event.tc Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 37/91] ring-buffer: Avoid softlockup in ring_buffer_resize() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 38/91] ata: libata-eh: do not clear ATA_PFLAG_EH_PENDING in ata_eh_reset() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 39/91] bpf: Clarify error expectations from bpf_clone_redirect Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 40/91] fbdev/sh7760fb: Depend on FB=y Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 41/91] nvme-pci: do not set the NUMA node of device if it has none Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 42/91] watchdog: iTCO_wdt: No need to stop the timer in probe Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 43/91] watchdog: iTCO_wdt: Set NO_REBOOT if the watchdog is not already running Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 44/91] net: Fix unwanted sign extension in netdev_stats_to_stats64() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 45/91] scsi: megaraid_sas: Enable msix_load_balance for Invader and later controllers Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 46/91] Smack:- Use overlay inode label in smack_inode_copy_up() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 47/91] smack: Retrieve transmuting information in smack_inode_getsecurity() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 48/91] smack: Record transmuting in smk_transmuted Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 49/91] serial: 8250_port: Check IRQ data before use Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 50/91] nilfs2: fix potential use after free in nilfs_gccache_submit_read_data() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 51/91] ALSA: hda: Disable power save for solving pop issue on Lenovo ThinkCentre M70q Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 52/91] ata: libata-scsi: ignore reserved bits for REPORT SUPPORTED OPERATION CODES Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 53/91] i2c: i801: unregister tco_pdev in i801_probe() error path Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 54/91] btrfs: properly report 0 avail for very full file systems Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 55/91] net: thunderbolt: Fix TCPv6 GSO checksum calculation Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 56/91] ata: libata-core: Fix ata_port_request_pm() locking Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 57/91] ata: libata-core: Fix port and device removal Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 58/91] ata: libata-core: Do not register PM operations for SAS ports Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 59/91] ata: libata-sata: increase PMP SRST timeout to 10s Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 60/91] fs: binfmt_elf_efpic: fix personality for ELF-FDPIC Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 61/91] ext4: fix rec_len verify error Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 62/91] ata: libata: disallow dev-initiated LPM transitions to unsupported states Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 63/91] Revert "drivers core: Use sysfs_emit and sysfs_emit_at for show(device *...) functions" Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 64/91] media: dvb: symbol fixup for dvb_attach() - again Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 65/91] Revert "PCI: qcom: Disable write access to read only registers for IP v2.3.3" Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 66/91] scsi: zfcp: Fix a double put in zfcp_port_enqueue() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 67/91] qed/red_ll2: Fix undefined behavior bug in struct qed_ll2_info Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 68/91] wifi: mwifiex: Fix tlv_buf_left calculation Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 69/91] net: replace calls to sock->ops->connect() with kernel_connect() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 70/91] btrfs: reject unknown mount options early Greg Kroah-Hartman
2023-10-10  8:53   ` Qu Wenruo
2023-10-10 11:27     ` Greg Kroah-Hartman
2023-10-10 12:59       ` David Sterba
2023-10-10 15:25         ` Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 71/91] ubi: Refuse attaching if mtds erasesize is 0 Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 72/91] wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 73/91] 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.19 74/91] regmap: rbtree: Fix wrong register marked as in-cache when creating new node Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 75/91] scsi: target: core: Fix deadlock due to recursive locking Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 76/91] modpost: add missing else to the "of" check Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 77/91] ipv4, ipv6: Fix handling of transhdrlen in __ip{,6}_append_data() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 78/91] net: usb: smsc75xx: Fix uninit-value access in __smsc75xx_read_reg Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 79/91] net: stmmac: dwmac-stm32: fix resume on STM32 MCU Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 80/91] tcp: fix quick-ack counting to count actual ACKs of new data Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 81/91] tcp: fix delayed ACKs for MSS boundary condition Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 82/91] sctp: update transport state when processing a dupcook packet Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 83/91] sctp: update hb timer immediately after users change hb_interval Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 84/91] cpupower: add Makefile dependencies for install targets Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 85/91] IB/mlx4: Fix the size of a buffer in add_port_entries() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 86/91] gpio: aspeed: fix the GPIO number passed to pinctrl_gpio_set_config() Greg Kroah-Hartman
2023-10-09 13:06 ` [PATCH 4.19 87/91] gpio: pxa: disable pinctrl calls for MMP_GPIO Greg Kroah-Hartman
2023-10-09 13:07 ` [PATCH 4.19 88/91] RDMA/cma: Fix truncation compilation warning in make_cma_ports Greg Kroah-Hartman
2023-10-09 13:07 ` [PATCH 4.19 89/91] RDMA/mlx5: Fix NULL string error Greg Kroah-Hartman
2023-10-09 13:07 ` [PATCH 4.19 90/91] parisc: Restore __ldcw_align for PA-RISC 2.0 processors Greg Kroah-Hartman
2023-10-09 13:07 ` [PATCH 4.19 91/91] dccp: fix dccp_v4_err()/dccp_v6_err() again Greg Kroah-Hartman
2023-10-09 23:03 ` [PATCH 4.19 00/91] 4.19.296-rc1 review Shuah Khan
2023-10-10  9:57 ` Jon Hunter
2023-10-10  9:57 ` Jon Hunter
2023-10-10 18:17 ` Guenter Roeck
2023-10-11  1:30 ` 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=20231009130111.652564497@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