From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8BC217A31E for ; Thu, 23 Jul 2026 00:12:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784765535; cv=none; b=b+wKtMtrNp55NWpnMrGvg7pQZ8zNsNsg4ntEmkpmwnCT4EuT0XQJOiqxx2zDQQFr+LXQIBEX5foC5ldvgFltnyCnxBwuOXk/PvIhUzpKBLuXJZhY93zHf9QUlkEgqmetdFB+hU6FrRF+WDrM8YdPPhiUZ4bKPFN6mTPS77qUd8w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784765535; c=relaxed/simple; bh=zxRUk15QyHPFIW7BYoJeqVqYzLOlUGbNStHDtvvRUCY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SZ62FOJ/JMNG8Q1zCxu0hnXOSwGrSt0VpSlQnwff9qf5Qs7eEEEedOXHdirjEfSP7aUFopjuvCHMDJECzrxDQnY67syuFHdO5d7sxZO0xmSXW0vHNbqTOnbA3FtzKQBrQKvgZZmRunlHjmDHs1gZ8f1PsgSi7YarmjGd0yW0/ts= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YzsRurnk; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YzsRurnk" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-8423f236418so31526b3a.1 for ; Wed, 22 Jul 2026 17:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784765534; x=1785370334; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oAzbfKn4mKCc6pS6016P2/PNkoC0SU+3zIwIGVc8iJo=; b=YzsRurnkln2k3NoKl7Ct7kpqM6+bdz/bwyfvgy5yu3U35CBmpVW6L8MIc/ByK0UN9x RNpj6INYRUtZ6vh2rFCR9BFbbCwkXxKNq4ktQzQlE3arp6k6SW9y/afNAiI9txhNw9oV bLidmaNkItyxuZzh5ezMDKH8LqCqanSLF9b2lLhsUrv+Pri9WjdcPC0EXTi5Xjajx4GC nDi5/cHrYXt87vTKTfBpdjcTBNmU7cuYfwJGAptw200eSwwf8KqObrYJVyXeFgBvR3b9 2EEQh6E/aCdob1++R2Tddc4+BDwAN2OUXtjFA1Z7EX2PXVgNQGciTRYIMT9a0F5SFrVQ lYrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784765534; x=1785370334; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=oAzbfKn4mKCc6pS6016P2/PNkoC0SU+3zIwIGVc8iJo=; b=DF2dmT5JJ8K0FMvVwXWS8YSXV9RG6WQUwIDmEMICo7tqpH1eiJUmSnHNT+1+zxl10e HPqxjquvF/0bi4+H9OXDS4HvQ8ca+63IPCcdqU4jLr4IPYOp+C6/Rdjb5hxSV2VK9Ppn AdS6oTFoJHQal9+XVAqFiJREYX3HYsVkZSK86dgFn45sqgWJRFu768df1tSw2VBzvGOh YLjXv2YqgDllTJ/Q2KHbFvAEy+NjVag4Gu0PNWzOc4xoAKv7z1hqB9p3lC+usWs1e70p cCH7Xlm2mCgsLlP6eV3LAQjKfRnZ74pl9N3DDFb4RKZfKPuG5+WbZKeQ4RGwSytKAi9D Dpiw== X-Forwarded-Encrypted: i=1; AHgh+Rq5ZsvBJeyVX4AmP66L1D/WJNeTq0kGG1NavKkcjRjGMbTdtij/tulmsHmjLVCWuOJNv88xaMYUJZTut8o=@vger.kernel.org X-Gm-Message-State: AOJu0YwOamiGiOV2t0hbv6TBl9Iw0LR6AIRL9UWyYl5MUhmi9M4LkplL 7XR2uj7fGpUcRjzb3a9hLVK2dK1iogT0GEMELh1VUHqlMR8I4tRKYhdwwGiaTQ== X-Gm-Gg: AR+sD13JgT0YL7rZNViPMJGOvjMDJrzTqFtFUtESQHnS031ErvVWoLyuIcyPKE+2553 admesc3eLoG0pdlu0qEp2f4uwozpmj7T2h6dCy5gBjGv8GTMCT5BrnTleS/VgBQOeymzuphrPIj 6MMagwfMzEZGmAR4O63AT6pyPEJ7Bk7t+dJbCpneNeK9bsJnmHe1eNMMA7B//bP2dyCFQPDuW5l Cvy07nvuSlvxq0ibSG+mANWKKGkHlInO08Qaz7mwWoKaASPFqdvxogWtDkcL+wCeUVwvIsG9dze fZfIrnbQQ2qMVdhx4P2Fvb4IuvfEc+YgpYO9+0NRjpNH5sKLQzLO3za3RuOERT95Kl3xsfwwR6v HuJEFMMXk5BG12+y71TM4ISd0uBBDRraUs6G1fEAHDVGZdbjnVIojj5Qv+Fy7B63QSuoLff/ARq Lc4yXHTW8YphPrimATmJsVyKW6tcZoBPTza3oByBS2PMqsHrtb3cBThoCDOQ0XhdE3uJiSacnZx g3diOB0U6ERWDJNPH31yWt+9/DPPskyX14VasQMAz4Sy/bjG2jVSQH+8JwGRc2XuQ== X-Received: by 2002:a05:6a00:1884:b0:845:c694:5c3d with SMTP id d2e1a72fcca58-84e2b82f716mr1169441b3a.1.1784765534135; Wed, 22 Jul 2026 17:12:14 -0700 (PDT) Received: from ryzen.lan ([2601:644:8000:7a86::e35]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84e1760025esm2037253b3a.57.2026.07.22.17.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 17:12:13 -0700 (PDT) From: Rosen Penev To: linux-ide@vger.kernel.org Cc: Damien Le Moal , Niklas Cassel , Tejun Heo , Mans Rullgard , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/3] ata: sata_dwc_460ex: preserve sactive_issued state across ISR invocations Date: Wed, 22 Jul 2026 17:12:08 -0700 Message-ID: <20260723001208.1469323-4-rosenp@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260723001208.1469323-1-rosenp@gmail.com> References: <20260723001208.1469323-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Zeroing hsdev->sactive_issued on every ISR entry destroys the NCQ tag tracking that must persist across interrupts. This field is populated in the NEWFP (DMA Setup FIS) handler and used in subsequent DMAT (DMA Transfer Complete) interrupts to determine which tags have completed via the formula tag_mask = (sactive_issued | sactive) ^ sactive. With the zeroing in place, sactive_issued is always cleared before a DMAT interrupt can read it, so the NCQ completion path never identifies completed tags correctly. The command completion then falls back to the non-NCQ path using ap->link.active_tag, which works for a single outstanding command but produces wrong results when multiple NCQ tags are in flight. Remove the spurious zeroing and fix the NCQ/non-NCQ discrimination: when tag_mask is zero but the active command is NCQ, all tracked tags are still in SCR_ACTIVE and no completion processing is needed. Fixes: 2d20da00c324b ("ata: sata_dwc_460ex: get rid of global data") Assisted-by: opencode:big-pickle Signed-off-by: Rosen Penev --- drivers/ata/sata_dwc_460ex.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c index 73bacdfd0bd3..025b5d968c78 100644 --- a/drivers/ata/sata_dwc_460ex.c +++ b/drivers/ata/sata_dwc_460ex.c @@ -467,7 +467,6 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance) struct sata_dwc_device_port *hsdevp; spin_lock_irqsave(&host->lock, flags); - hsdev->sactive_issued = 0; /* Read the interrupt register */ intpr = sata_dwc_readl(&hsdev->sata_dwc_regs->intpr); @@ -517,8 +516,11 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance) sata_dwc_scr_read(&ap->link, SCR_ACTIVE, &sactive); tag_mask = (hsdev->sactive_issued | sactive) ^ sactive; - /* If no sactive issued and tag_mask is zero then this is not NCQ */ - if (hsdev->sactive_issued == 0 && tag_mask == 0) { + /* + * If tag_mask is zero and the active command is not NCQ this is a + * non-NCQ completion. + */ + if (tag_mask == 0) { if (ap->link.active_tag == ATA_TAG_POISON) tag = 0; else @@ -534,6 +536,12 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance) handled = 1; goto DONE; } + if (ata_is_ncq(qc->tf.protocol)) { + /* NCQ commands still in flight; no tag completed. */ + ap->ops->sff_check_status(ap); + handled = 1; + goto DONE; + } status = ap->ops->sff_check_status(ap); qc->ap->link.active_tag = tag; -- 2.55.0