{"id":2231875,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2231875/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ide/patch/20260501125410.1204490-7-cassel@kernel.org/","project":{"id":13,"url":"http://patchwork.ozlabs.org/api/1.2/projects/13/?format=json","name":"Linux IDE development","link_name":"linux-ide","list_id":"linux-ide.vger.kernel.org","list_email":"linux-ide@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260501125410.1204490-7-cassel@kernel.org>","list_archive_url":null,"date":"2026-05-01T12:54:12","name":"[2/3] ata: libata-scsi: do not use the deferred QC feature on PMPs with CBS","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6ab7caea6b15a75a7f78d0ff8fbd74466b958937","submitter":{"id":87751,"url":"http://patchwork.ozlabs.org/api/1.2/people/87751/?format=json","name":"Niklas Cassel","email":"cassel@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ide/patch/20260501125410.1204490-7-cassel@kernel.org/mbox/","series":[{"id":502457,"url":"http://patchwork.ozlabs.org/api/1.2/series/502457/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ide/list/?series=502457","date":"2026-05-01T12:54:13","name":"ata: fix deferred QC handling for port multipliers","version":1,"mbox":"http://patchwork.ozlabs.org/series/502457/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231875/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231875/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-ide+bounces-5618-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ide@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=gqzN7uJT;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ide+bounces-5618-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"gqzN7uJT\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g6WGC6YjVz1yKN\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 22:54:43 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 02C7D301A1C7\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  1 May 2026 12:54:24 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id B07013A5431;\n\tFri,  1 May 2026 12:54:22 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E3F53A5420\n\tfor <linux-ide@vger.kernel.org>; Fri,  1 May 2026 12:54:22 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id B540FC2BCB4;\n\tFri,  1 May 2026 12:54:20 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777640062; cv=none;\n b=E142g+s7Ugfd98WkoOoAfF2m0vK1DrPHLkickT+3A7I1h2ffN8MSTw9zA92T+zbJzlvcKSsbI2iv7eXLsXCMKz7ur9kKxnWzB7eaEU2WxRACdtTAWGV4H4sgJJYrouez1avDNU5W+3hhk0LYWcARRn7BtNmXq1dQqIrp++1BE38=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777640062; c=relaxed/simple;\n\tbh=Mhx8R7RfUXtSX09O8KpG01EuKahyvztstMi2Npfyq1g=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=s64OksS/35sEseKA0kG8lQ8bM1f39bARzO+OeMDgGPZ9neXeKdU+X4VFTFUKlBD/rZ40Rp+9WIWeJOUK6ARNoq86x3hE0j8Suo+aPxV+O3DYLcLYgeXphevwwydSe38H/aFFXiW3nvxltD1hRwvSth8tmVeTMk4YVDcR2Y4CryE=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=gqzN7uJT; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777640062;\n\tbh=Mhx8R7RfUXtSX09O8KpG01EuKahyvztstMi2Npfyq1g=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=gqzN7uJTGKjfc7alA9431lCE6pWnE/QyTN2oIGxVL8W6iKLJYHgrq5TdMgnWXb+yc\n\t sv+Uufek8IVXI9mg2AGkthk2OC/QNb1zFfsHKjFS2imbqKzgzlHAHA4KH71aUqbdgd\n\t 6J1HO5n/s9fYYz/2kZ+PFeoZTIZxnWjNBacyzfkO2McAIPMZYS5DNe/rHTK5+uY2kY\n\t jjUW1x6JdLFixK1pcsPagAQYznkAkjNdBT3udDpNeK71E4jIRN/nQ7xDUmMVDTfxjR\n\t hlDp/ilZ+Jq3rZYPr2DxjFpWR9mqZEIHxjq4Zl9k7bflpuhw5a7d2hJCM6ufKclptS\n\t 9Z7x3+ZiDz16A==","From":"Niklas Cassel <cassel@kernel.org>","To":"Tommy Kelly <linux@tkel.ly>,\n\tDamien Le Moal <dlemoal@kernel.org>,\n\tNiklas Cassel <cassel@kernel.org>,\n\tJohn Garry <john.g.garry@oracle.com>,\n\t\"Martin K. Petersen\" <martin.petersen@oracle.com>","Cc":"linux-ide@vger.kernel.org","Subject":"[PATCH 2/3] ata: libata-scsi: do not use the deferred QC feature on\n PMPs with CBS","Date":"Fri,  1 May 2026 14:54:12 +0200","Message-ID":"<20260501125410.1204490-7-cassel@kernel.org>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260501125410.1204490-5-cassel@kernel.org>","References":"<20260501125410.1204490-5-cassel@kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-ide@vger.kernel.org","List-Id":"<linux-ide.vger.kernel.org>","List-Subscribe":"<mailto:linux-ide+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ide+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","X-Developer-Signature":"v=1; a=openpgp-sha256; l=3422; i=cassel@kernel.org;\n h=from:subject; bh=Mhx8R7RfUXtSX09O8KpG01EuKahyvztstMi2Npfyq1g=;\n b=owGbwMvMwCV2MsVw8cxjvkWMp9WSGDK/LCpWZHhy+mLkrV8Zi5MPWZ2qflOhJr3jSfql8s+1K\n klTxO9Id5SyMIhxMciKKbL4/nDZX9ztPuW44h0bmDmsTCBDGLg4BWAiU84w/E93XcRf5SRTq776\n 7dwD7RfsD8iuUj8mwPR584/DuTv1L7xiZNh0fVeQo45WxKWjp5Zv6tyw93DsQot/1fVPZ3BeFnj\n ZxM8JAA==","X-Developer-Key":"i=cassel@kernel.org; a=openpgp;\n fpr=5ADE635C0E631CBBD5BE065A352FE6582ED9B5DA","Content-Transfer-Encoding":"8bit"},"content":"When using Port Multipliers (PMPs) with Command-Based Switching (CBS), you\ncan only issue commands to one link at a time. For PMPs with CBS, there is\nalready code to handle commands being send to different links in\nsata_pmp_qc_defer_cmd_switch(), which will return ATA_DEFER_PORT when\ntrying to send a command (NCQ or non-NCQ) to the non-active link.\n\nAfter commit 0ea84089dbf6 (\"ata: libata-scsi: avoid Non-NCQ command\nstarvation\"), in addition to the existing handling PMP CBS handling, we\nwould also, incorrectly, save a non-NCQ command to another link in\nap->deferred_qc. The deferred qc feature was only meant to defer QCs to\nthe same link, not to duplicate the existing PMP CBS deferal logic when\ndealing with separate links.\n\nNote that when deferring commands to the same link (i.e. because NCQ and\nnon-NCQ commands are mixed), even when using a PMP with CBS, we will use\nthe deferred_qc feature that issues the deferred qc via a workqueue\n(because sata_pmp_qc_defer_cmd_switch() in this case ATA_DEFER_LINK is\nreturned).\n\nSince the deferred_qc issuing via workqueue was only meant to deal with a\nsingle link, modify the code to feature to only set link->deferred_qc when\ndeferring a qc to the same link (ATA_DEFER_LINK), and not when deferring a\nqc because we are not issuing a qc to the active link (ATA_DEFER_PORT).\n\nIf we want to modify the scope of the workqueue issuing to also handle the\ncase where we issue commands to the link that is not the active link, then\nwe should ensure that it can save both NCQ and non-NCQ commands, while also\nremoving some of the existing PMP CBS handling, such that we don't\nduplicate features.\n\nThus, modify ata_scsi_qc_issue() to only use the deferred_qc workqueue for\nATA_DEFER_LINK and not for ATA_DEFER_PORT.\n\nFixes: 0ea84089dbf6 (\"ata: libata-scsi: avoid Non-NCQ command starvation\")\nSigned-off-by: Niklas Cassel <cassel@kernel.org>\n---\n drivers/ata/libata-scsi.c | 27 ++++++++++++++-------------\n 1 file changed, 14 insertions(+), 13 deletions(-)","diff":"diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c\nindex f44612e269a4..dca7ea7e6315 100644\n--- a/drivers/ata/libata-scsi.c\n+++ b/drivers/ata/libata-scsi.c\n@@ -1785,18 +1785,6 @@ static int ata_scsi_qc_issue(struct ata_port *ap, struct ata_queued_cmd *qc)\n \tcase 0:\n \t\tbreak;\n \tcase ATA_DEFER_LINK:\n-\t\tret = SCSI_MLQUEUE_DEVICE_BUSY;\n-\t\tbreak;\n-\tcase ATA_DEFER_PORT:\n-\t\tret = SCSI_MLQUEUE_HOST_BUSY;\n-\t\tbreak;\n-\tdefault:\n-\t\tWARN_ON_ONCE(1);\n-\t\tret = SCSI_MLQUEUE_HOST_BUSY;\n-\t\tbreak;\n-\t}\n-\n-\tif (ret) {\n \t\t/*\n \t\t * We must defer this qc: if this is not an NCQ command, keep\n \t\t * this qc as a deferred one and report to the SCSI layer that\n@@ -1811,7 +1799,20 @@ static int ata_scsi_qc_issue(struct ata_port *ap, struct ata_queued_cmd *qc)\n \n \t\t/* Force a requeue of the command to defer its execution. */\n \t\tata_qc_free(qc);\n-\t\treturn ret;\n+\t\treturn SCSI_MLQUEUE_DEVICE_BUSY;\n+\tcase ATA_DEFER_PORT:\n+\t\t/*\n+\t\t * ATA_DEFER_PORT is returned when the host is busy, e.g. when\n+\t\t * using a PMP with CBS and trying to issue a qc to a link that\n+\t\t * is not the currently active link. In this case, simply\n+\t\t * propagate the error back to the SCSI layer.\n+\t\t */\n+\t\tata_qc_free(qc);\n+\t\treturn SCSI_MLQUEUE_HOST_BUSY;\n+\tdefault:\n+\t\tWARN_ON_ONCE(1);\n+\t\tata_qc_free(qc);\n+\t\treturn SCSI_MLQUEUE_HOST_BUSY;\n \t}\n \n issue:\n","prefixes":["2/3"]}