Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2235180/?format=api
{ "id": 2235180, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2235180/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ide/patch/20260508193240.176735-5-cassel@kernel.org/", "project": { "id": 13, "url": "http://patchwork.ozlabs.org/api/1.2/projects/13/?format=api", "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": "<20260508193240.176735-5-cassel@kernel.org>", "list_archive_url": null, "date": "2026-05-08T19:32:41", "name": "[v2,1/2] 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": "2400e79eea8c014a546523aa08c24fd561014f34", "submitter": { "id": 87751, "url": "http://patchwork.ozlabs.org/api/1.2/people/87751/?format=api", "name": "Niklas Cassel", "email": "cassel@kernel.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-ide/patch/20260508193240.176735-5-cassel@kernel.org/mbox/", "series": [ { "id": 503436, "url": "http://patchwork.ozlabs.org/api/1.2/series/503436/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ide/list/?series=503436", "date": "2026-05-08T19:32:41", "name": "ata: fix deferred QC handling for port multipliers", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/503436/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2235180/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2235180/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-ide+bounces-5698-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=fzjP1WUY;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-ide+bounces-5698-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=\"fzjP1WUY\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201" ], "Received": [ "from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4gBzp16Rnrz1yK7\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 09 May 2026 05:34:17 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 972CA3019D3C\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 8 May 2026 19:33:06 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 09A32377ECF;\n\tFri, 8 May 2026 19:33:02 +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 DAA8E284662\n\tfor <linux-ide@vger.kernel.org>; Fri, 8 May 2026 19:33:01 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id 27C90C2BCB0;\n\tFri, 8 May 2026 19:32:59 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778268781; cv=none;\n b=beOXh7EHFtkWB11IKQQo2whXfn21rb1P9EBvOcewnzo9g6bKmrI5xam0fkZ7Wgh2gsQnkDMn10DnMbdt/Q3RLAjwZR1aX9gDfjYHa9jfV/1YgsGfwaa/xEHkcuV0eHPzki5g2UtojfKK4rfdFR5pAi2CvQyxsp9Ar44Z1xsBZso=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778268781; c=relaxed/simple;\n\tbh=fCzxSc3g8IQvtDPl7PPeMBpuyhUUgjzF0QyA34BWFs4=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=NK/AdkOW1Vn568bwkGhJEe4qslklqYmcS1+vLmc2bdDmG3GPgFjSlBT92qtXxaBfIYyB1ebnOFP4y7jj4DWUjkqTCBGfFthRyKI9qwNttcFJewAk7CUp+sbw9ghgR/WW+DMB0zgdQrXYVbFNekx1Fx1blTtRZUDGPlFMs7XPpGU=", "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=fzjP1WUY; 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=1778268781;\n\tbh=fCzxSc3g8IQvtDPl7PPeMBpuyhUUgjzF0QyA34BWFs4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=fzjP1WUY9lvAjvhbb/BPcApKxOJUE0yFh7JI5rvmpxlXTxf3v+8QPcV1dFKbLELvM\n\t yHjun/MdTTnRsF+GkUSIsCnaXhVSWONuRF2JLalI/o7NA6DDcuaAnN2N/80osVvjfL\n\t qR/OBxmS8xuVO7N3mgP3ersKd5LvUyE81bv5c6/JQ0Skc1BmrIlcVhxkasVHmzhzHv\n\t tKtZkjOKvj8k1Wfqw+bScXiFUiJ4AKul+ahvWL8VSru1z3ODd2pWhmOxT2DkKVG7/E\n\t chcaX6SaSDQIgnNhnkWSVgBWMb5o/pNLLJANLKdTyOSr14MGxrV4JG7mXmsrgZVlbw\n\t HERa0pzYGvvwQ==", "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\t\"Martin K. Petersen\" <martin.petersen@oracle.com>,\n\tJohn Garry <john.g.garry@oracle.com>", "Cc": "linux-ide@vger.kernel.org", "Subject": "[PATCH v2 1/2] ata: libata-scsi: do not use the deferred QC feature\n on PMPs with CBS", "Date": "Fri, 8 May 2026 21:32:41 +0200", "Message-ID": "<20260508193240.176735-5-cassel@kernel.org>", "X-Mailer": "git-send-email 2.54.0", "In-Reply-To": "<20260508193240.176735-4-cassel@kernel.org>", "References": "<20260508193240.176735-4-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=6310; i=cassel@kernel.org;\n h=from:subject; bh=fCzxSc3g8IQvtDPl7PPeMBpuyhUUgjzF0QyA34BWFs4=;\n b=owGbwMvMwCV2MsVw8cxjvkWMp9WSGDL/WSXm3Ll9YNr24j0fjveHGvk7v2dh2hRuENX5ZcYfI\n Wl180bOjlIWBjEuBlkxRRbfHy77i7vdpxxXvGMDM4eVCWQIAxenAEwkq4GRYZdt2cyna1NSDBfN\n ebz328oFK/jOm11gmngmNJuZxeSz1zGG/9WRrg6FE9ojuric79VkrEu3X6h2esbh/rVvtCLOFdz\n w5wQA", "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 sent to different links in\nsata_pmp_qc_defer_cmd_switch() using ap->excl_link.\n\nA user on the list reported that commit 0ea84089dbf6 (\"ata: libata-scsi:\navoid Non-NCQ command starvation\") broke PMPs with CBS. The commit\nintroduced code that stores a deferred qc in ap->deferred_qc, to later be\nissued via a workqueue. It turns out that this change is incompatible with\nthe existing ap->excl_link handling used by PMPs with CBS.\n\nThus, modify sata_pmp_qc_defer_cmd_switch() code to return\nATA_DEFER_PORT_PMP_CBS and ATA_DEFER_LINK_PMP_CBS, and make sure that the\ndeferred QC handling via workqueue is not used for these return values.\n\nThis way, PMPs with CBS will work once again. Note that the starvation\nreferenced in commit 0ea84089dbf6 (\"ata: libata-scsi: avoid Non-NCQ\ncommand starvation\") can only happen on libsas ports, and libsas does not\nsupport Port Multipliers, thus there is no harm of reverting back to the\nprevious way of deferring commands for PMPs with CBS.\n\nNon-libsas ports connected to anything but a PMP with CBS (e.g. a normal\ndrive or a PMP with FBS) will continue using the deferred workqueue, since\nit does result in lower completion latencies for non-NCQ commands, even\nthough the workqueue is not strictly needed to avoid starvation for\nnon-libsas ports.\n\nIf we want to modify the scope of the workqueue issuing to also handle\nPMPs with CBS, then we should ensure that we can save both NCQ and non-NCQ\ncommands in ap->deferred_qc, while also removing the existing PMP CBS\nhandling using ap->excl_link, such that we don't duplicate features.\n\nWhile at it, also add a comment explaining how the ap->excl_link mechanism\nworks.\n\nFixes: 0ea84089dbf6 (\"ata: libata-scsi: avoid Non-NCQ command starvation\")\nSigned-off-by: Niklas Cassel <cassel@kernel.org>\n---\n drivers/ata/libata-pmp.c | 24 ++++++++++++++--\n drivers/ata/libata-scsi.c | 58 ++++++++++++++++++++++++---------------\n include/linux/libata.h | 2 ++\n 3 files changed, 60 insertions(+), 24 deletions(-)", "diff": "diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c\nindex e3adc008fed1..d847bdff6d0a 100644\n--- a/drivers/ata/libata-pmp.c\n+++ b/drivers/ata/libata-pmp.c\n@@ -113,14 +113,34 @@ int sata_pmp_qc_defer_cmd_switch(struct ata_queued_cmd *qc)\n \n \tif (ap->excl_link == NULL || ap->excl_link == link) {\n \t\tif (ap->nr_active_links == 0 || ata_link_active(link)) {\n+\t\t\tint ret;\n+\n \t\t\tqc->flags |= ATA_QCFLAG_CLEAR_EXCL;\n-\t\t\treturn ata_std_qc_defer(qc);\n+\t\t\tret = ata_std_qc_defer(qc);\n+\t\t\tswitch (ret) {\n+\t\t\tcase 0:\n+\t\t\t\treturn ret;\n+\t\t\tcase ATA_DEFER_LINK:\n+\t\t\t\treturn ATA_DEFER_LINK_PMP_CBS;\n+\t\t\tcase ATA_DEFER_PORT:\n+\t\t\t\treturn ATA_DEFER_PORT_PMP_CBS;\n+\t\t\tdefault:\n+\t\t\t\tWARN_ON_ONCE(1);\n+\t\t\t\treturn ATA_DEFER_PORT_PMP_CBS;\n+\t\t\t}\n \t\t}\n \n+\t\t/*\n+\t\t * Note: ap->excl_link contains the link that is next in line,\n+\t\t * i.e. implicit round robin. If there is only one link\n+\t\t * dispatching, ap->excl_link will be left unclaimed, allowing\n+\t\t * other links to set ap->excl_link, ensuring that the currently\n+\t\t * active link cannot queue any more.\n+\t\t */\n \t\tap->excl_link = link;\n \t}\n \n-\treturn ATA_DEFER_PORT;\n+\treturn ATA_DEFER_PORT_PMP_CBS;\n }\n \n /**\ndiff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c\nindex f44612e269a4..6f273c5d0cd3 100644\n--- a/drivers/ata/libata-scsi.c\n+++ b/drivers/ata/libata-scsi.c\n@@ -1767,7 +1767,7 @@ static int ata_scsi_qc_issue(struct ata_port *ap, struct ata_queued_cmd *qc)\n \tint ret;\n \n \tif (!ap->ops->qc_defer)\n-\t\tgoto issue;\n+\t\tgoto issue_qc;\n \n \t/*\n \t * If we already have a deferred qc, then rely on the SCSI layer to\n@@ -1783,38 +1783,52 @@ static int ata_scsi_qc_issue(struct ata_port *ap, struct ata_queued_cmd *qc)\n \tret = ap->ops->qc_defer(qc);\n \tswitch (ret) {\n \tcase 0:\n-\t\tbreak;\n+\t\tgoto issue_qc;\n \tcase ATA_DEFER_LINK:\n \t\tret = SCSI_MLQUEUE_DEVICE_BUSY;\n-\t\tbreak;\n+\t\tgoto store_qc;\n \tcase ATA_DEFER_PORT:\n \t\tret = SCSI_MLQUEUE_HOST_BUSY;\n-\t\tbreak;\n+\t\tgoto store_qc;\n+\tcase ATA_DEFER_LINK_PMP_CBS:\n+\t\t/*\n+\t\t * PMP in CBS mode has independent handling using ap->excl_link\n+\t\t * that is incompatible with ap->deferred_qc workqueue handling.\n+\t\t */\n+\t\tret = SCSI_MLQUEUE_DEVICE_BUSY;\n+\t\tgoto free_qc;\n+\tcase ATA_DEFER_PORT_PMP_CBS:\n+\t\t/*\n+\t\t * PMP in CBS mode has independent handling using ap->excl_link\n+\t\t * that is incompatible with ap->deferred_qc workqueue handling.\n+\t\t */\n+\t\tret = SCSI_MLQUEUE_HOST_BUSY;\n+\t\tgoto free_qc;\n \tdefault:\n \t\tWARN_ON_ONCE(1);\n \t\tret = SCSI_MLQUEUE_HOST_BUSY;\n-\t\tbreak;\n+\t\tgoto free_qc;\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-\t\t * we issued it so that it is not requeued. The deferred qc will\n-\t\t * be issued with the port deferred_qc_work once all on-going\n-\t\t * commands complete.\n-\t\t */\n-\t\tif (!ata_is_ncq(qc->tf.protocol)) {\n-\t\t\tap->deferred_qc = qc;\n-\t\t\treturn 0;\n-\t\t}\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+store_qc:\n+\t/*\n+\t * We must defer this qc: if this is not an NCQ command, keep\n+\t * this qc as a deferred one and report to the SCSI layer that\n+\t * we issued it so that it is not requeued. The deferred qc will\n+\t * be issued with the port deferred_qc_work once all on-going\n+\t * commands complete.\n+\t */\n+\tif (!ata_is_ncq(qc->tf.protocol)) {\n+\t\tap->deferred_qc = qc;\n+\t\treturn 0;\n \t}\n \n-issue:\n+free_qc:\n+\t/* Force a requeue of the command to defer its execution. */\n+\tata_qc_free(qc);\n+\treturn ret;\n+\n+issue_qc:\n \tata_qc_issue(qc);\n \n \treturn 0;\ndiff --git a/include/linux/libata.h b/include/linux/libata.h\nindex 5c085ef4eda7..511cdf1a6650 100644\n--- a/include/linux/libata.h\n+++ b/include/linux/libata.h\n@@ -371,6 +371,8 @@ enum {\n \t/* return values for ->qc_defer */\n \tATA_DEFER_LINK\t\t= 1,\n \tATA_DEFER_PORT\t\t= 2,\n+\tATA_DEFER_LINK_PMP_CBS\t= 3,\n+\tATA_DEFER_PORT_PMP_CBS\t= 4,\n \n \t/* desc_len for ata_eh_info and context */\n \tATA_EH_DESC_LEN\t\t= 80,\n", "prefixes": [ "v2", "1/2" ] }