[{"id":3682672,"web_url":"http://patchwork.ozlabs.org/comment/3682672/","msgid":"<ae9TGoaQAi7dOVc0@ryzen>","list_archive_url":null,"date":"2026-04-27T12:14:18","subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","submitter":{"id":87751,"url":"http://patchwork.ozlabs.org/api/people/87751/","name":"Niklas Cassel","email":"cassel@kernel.org"},"content":"On Mon, Apr 27, 2026 at 02:05:46PM +0800, dayou5941@163.com wrote:\n> From: Youhong Li <liyouhong@kylinos.cn>\n> \n> When an AHCI controller is disabled in BIOS, its HOST_CAP register may\n> contain invalid values (e.g., 0xFFFFFFFF) indicating an impossibly large\n> number of ports. If CAP.NP claims more ports than can physically fit\n> within the mapped BAR region, accessing port registers beyond the BAR\n> boundary causes a kernel panic.\n> \n> Add validation in ahci_init_one() to check that the BAR size is\n> sufficient for the number of ports claimed in CAP.NP. The check\n> calculates the required MMIO size as:\n> \n>   required_size = 0x100 (global registers) + max_ports * 0x80\n> \n> If required_size exceeds the actual BAR size, the probe fails with\n> -ENODEV, preventing the panic and providing a clear error message.\n> \n> This solution follows the suggestion by Damien Le Moal and Niklas Cassel\n> to detect and reject obviously broken controller configurations early.\n> \n> Reported-by: liyouhong <liyouhong@kylinos.cn>\n> Suggested-by: Damien Le Moal <dlemoal@kernel.org>\n> Suggested-by: Niklas Cassel <cassel@kernel.org>\n> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>\n> Signed-off-by: liyouhong <liyouhong@kylinos.cn>\n> ---\n> v2:\n> - Complete rewrite based on community feedback\n> - Move check from libahci.c to ahci.c\n> - Fail probe early instead of attempting to work around invalid state\n> - Implement BAR size validation as suggested\n> \n> v3:\n> - Fix patch format: add \"---\" separator and move changelog to correct location\n> - Change dev_err to dev_warn as suggested\n> \n> v4:\n> - Break long lines as suggested by Damien\n> - Keep complete changelog history\n> \n> ---\n>  drivers/ata/ahci.c | 23 +++++++++++++++++++++++\n>  1 file changed, 23 insertions(+)\n> \n> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c\n> index 1d73a53370cf..c04bee682605 100644\n> --- a/drivers/ata/ahci.c\n> +++ b/drivers/ata/ahci.c\n> @@ -1888,6 +1888,25 @@ static ssize_t remapped_nvme_show(struct device *dev,\n>  \n>  static DEVICE_ATTR_RO(remapped_nvme);\n>  \n> +static int ahci_validate_bar_size(struct pci_dev *pdev, void __iomem *mmio)\n\nstatic int ahci_validate_bar_size(struct pci_dev *pdev, int bar, struct ahci_host_priv *hpriv)\n\n\n> +{\n> +\tu32 cap = readl(mmio + HOST_CAP);\n\nreadl(hpriv->mmio, HOST_CAP);\n\n\n> +\tunsigned int max_ports = ahci_nr_ports(cap);\n> +\tu32 last_port_end = 0x100 + (max_ports * 0x80);\n> +\tresource_size_t bar_size =\n> +\t\tpci_resource_len(pdev, AHCI_PCI_BAR_STANDARD);\n\npci_resource_len(pdev, bar);\n\n\n> +\n> +\tif (last_port_end > bar_size) {\n> +\t\tdev_warn(&pdev->dev,\n> +\t\t\t \"BAR5 too small for %u ports (last port ends at %u, BAR %llu)\\n\",\n\n\"BAR%d too small for %u ports (last port ends at %#x, BAR %pa)\\n\", bar,\n\n\n> +\t\t\t max_ports, last_port_end,\n> +\t\t\t (unsigned long long)bar_size);\n\nPrint resource_size_t as %pa instead of casting to unsigned long long\nand pass bar_size by reference (&bar_size):\nhttps://docs.kernel.org/core-api/printk-formats.html#physical-address-types-phys-addr-t\n\n\n> +\t\treturn -ENODEV;\n\nreturn -EIO;\n\n\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> +\n>  static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)\n>  {\n>  \tunsigned int board_id = ent->driver_data;\n> @@ -1988,6 +2007,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)\n>  \tif (!hpriv->mmio)\n>  \t\treturn -ENOMEM;\n>  \n> +\trc = ahci_validate_bar_size(pdev, hpriv->mmio);\n\nPlease let this function be called with the arguments:\n\nahci_validate_bar_size(pdev, ahci_pci_bar, hpriv);\n\nSuch that it takes the same arguments as ahci_remap_check().\n\n\nKind regards,\nNiklas\n\n\n> +\tif (rc)\n> +\t\treturn rc;\n> +\n>  \t/* detect remapped nvme devices */\n>  \tahci_remap_check(pdev, ahci_pci_bar, hpriv);\n>  \n> -- \n> 2.25.1\n>","headers":{"Return-Path":"\n <linux-ide+bounces-5564-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=h1zV+2Yp;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-ide+bounces-5564-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=\"h1zV+2Yp\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::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 4g42Yf3cz6z1yHv\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 22:14:30 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 4FA6C30157F1\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 12:14:23 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 774683B6BE3;\n\tMon, 27 Apr 2026 12:14: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 5420F3B6348\n\tfor <linux-ide@vger.kernel.org>; Mon, 27 Apr 2026 12:14:22 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id DFE63C19425;\n\tMon, 27 Apr 2026 12:14:20 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777292062; cv=none;\n b=Hjho2Dh7KnAOX5PZf8Fy1UDratuSWOVP6C7rHmCmb4B/bTwLJB9pB8Pp4++/WscZOHPKjy80Jte1R6PenNlICOYWvdHhqrNSF/QcAtxjvH5iGfPlhEHsHqFMSeEZj2yufFBgGRCy3OfUIUoJdg3VX0uKeFBkKOvvFx1IbCH50GI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777292062; c=relaxed/simple;\n\tbh=DY4KEJNZ+0pmsiXVAcMHRaYvbm7DX81+y4zKcnRGmEE=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=nSoi5VkuPHf2rIxFZN1Gr4EeLfym5fzfPRNl42s3iy1eqUtlwgFHoNjZ5zXfyA1viQo/dCkcP2EI1TlevZ1YCue/5y2UZDZszNIHK0ket2/AzgIxoiRHnWTs1fx0yT/zBgMn4C/CfZdh1MsHdCtV30x75zkRF+Hno+CK4ORIuOs=","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=h1zV+2Yp; 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=1777292062;\n\tbh=DY4KEJNZ+0pmsiXVAcMHRaYvbm7DX81+y4zKcnRGmEE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=h1zV+2Ypy2dGtx+/OlfWe9QGXI0tZteDzqn1Vz30Ht39hcEGHbPElRHuethgbSjSh\n\t 0FCEWqOkuTIbUDdR0PgYUg0Hnj4Ejjdpy4vAWLqebMW6t4V3aMLbnUHFvzCKz44dbT\n\t +HJeaaqs903N9IFjRyvlzapv62D5nOGii5Lv4etkXkWzR5oYaajnIYE6igBRxZvvBW\n\t SAIQ9pjDTWQykyrZzcOZhFqiS6t+GIdMTr6u9CUFLD3nBs5uioqRdextQ4c0/b8Txb\n\t GJYxmqJsuq4B1c7df4qptLJiu0knlOvCOs4uV/0rAUKbni2kfX3inGl1DKn5QFcI1t\n\t U8mjm+iFY7SVw==","Date":"Mon, 27 Apr 2026 14:14:18 +0200","From":"Niklas Cassel <cassel@kernel.org>","To":"dayou5941@163.com","Cc":"linux-ide@vger.kernel.org, dlemoal@kernel.org, liyouhong@kylinos.cn","Subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","Message-ID":"<ae9TGoaQAi7dOVc0@ryzen>","References":"<20260427060546.1407439-1-dayou5941@163.com>","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","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260427060546.1407439-1-dayou5941@163.com>"}},{"id":3682952,"web_url":"http://patchwork.ozlabs.org/comment/3682952/","msgid":"<a805fa86-0fe7-4803-ad2e-45719415f263@kernel.org>","list_archive_url":null,"date":"2026-04-27T20:23:12","subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","submitter":{"id":86188,"url":"http://patchwork.ozlabs.org/api/people/86188/","name":"Damien Le Moal","email":"dlemoal@kernel.org"},"content":"On 2026/04/27 21:14, Niklas Cassel wrote:\n>> +\t\t\t max_ports, last_port_end,\n>> +\t\t\t (unsigned long long)bar_size);\n> \n> Print resource_size_t as %pa instead of casting to unsigned long long\n> and pass bar_size by reference (&bar_size):\n> https://docs.kernel.org/core-api/printk-formats.html#physical-address-types-phys-addr-t\n> \n> \n>> +\t\treturn -ENODEV;\n> \n> return -EIO;\n\nI do not agree here. We did not do any I/O. If anything, this should be EINVAL.\nBut I think that ENODEV is safer since we are in the probe context here and we\ndo not want to see that device show up.","headers":{"Return-Path":"\n <linux-ide+bounces-5565-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=GW4vfUFX;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-ide+bounces-5565-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=\"GW4vfUFX\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\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 4g4FSF3DWsz1yHv\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 06:25:33 +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 DA3D230A9571\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 20:23:15 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 5D38436403C;\n\tMon, 27 Apr 2026 20:23:15 +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 014A0364EB1\n\tfor <linux-ide@vger.kernel.org>; Mon, 27 Apr 2026 20:23:14 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id AEED4C19425;\n\tMon, 27 Apr 2026 20:23:13 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777321395; cv=none;\n b=M91X7rt38nyI8cYB9UQrtcqf7Va2K7sJDTg7p5Aaj/iF6ZZNF1B6gxY3wfIQikGWvXR0PqhZMiIJ+I4upy8guc2HRfZhCv3bX5iOHMuPKj9jfYXQlK6DEcigLS4Ae45Atn3aBfcYNYPuy7qZsYKw5idNwfRGG57DtnFQYVB4jk8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777321395; c=relaxed/simple;\n\tbh=1/EGzb8C9dggAU/ed/MDU8FI3IzukIkF/zU2mo+vBUE=;\n\th=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:\n\t In-Reply-To:Content-Type;\n b=A440Yj1yKUY+e6ad5B7+orDv3zefIgKAjJgYO45QHQki0Ia1S2e5kasUu97hen4F8N+9e8wwRVK8Ipoap4KAHAAKyoUuzd8GRHglT0KHL5w+YGe3mNKUDGNU1/JwsD/A9QWsSVxsYepwcVojAjKB8L6Y92d28UFXU2RBXq+4kPA=","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=GW4vfUFX; 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=1777321394;\n\tbh=1/EGzb8C9dggAU/ed/MDU8FI3IzukIkF/zU2mo+vBUE=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=GW4vfUFXog68PwCEP+j3jKwkFUSUoiD3yE3CiMG8wxN0O4QrFUuj2MJRBHk2qxDWk\n\t 8BzsTBhYZCs6RTNVY63mG3TJHYCYaBt8y56A/L/I5lAeIBgqkQewWTYiarR/noQRN1\n\t wqdV16L1+jVjsN2zENEIoypXSybVGr8Xjo03JMuJfBFjujjSS4cdvoAfcodXUrqSFx\n\t EYUu0f/H7X+UNyCIyz0KQV3pXka2R2rRGNG467DAbQ3PLJqkm5Vr1Jdhre3GEgc3zu\n\t XDTEAAy2Ocp73tFnS6sv9g7xjXonVZXU2iph1lT2CejO9u6KHSVrh+MKnzrXUXI57f\n\t 2TI+e5n+5Aa5Q==","Message-ID":"<a805fa86-0fe7-4803-ad2e-45719415f263@kernel.org>","Date":"Tue, 28 Apr 2026 05:23:12 +0900","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","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","To":"Niklas Cassel <cassel@kernel.org>, dayou5941@163.com","Cc":"linux-ide@vger.kernel.org, liyouhong@kylinos.cn","References":"<20260427060546.1407439-1-dayou5941@163.com>\n <ae9TGoaQAi7dOVc0@ryzen>","Content-Language":"en-US","From":"Damien Le Moal <dlemoal@kernel.org>","Organization":"Western Digital Research","In-Reply-To":"<ae9TGoaQAi7dOVc0@ryzen>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit"}},{"id":3682961,"web_url":"http://patchwork.ozlabs.org/comment/3682961/","msgid":"<6149B806-C296-42DE-BF0E-119E8AF6129B@kernel.org>","list_archive_url":null,"date":"2026-04-27T20:32:35","subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","submitter":{"id":87751,"url":"http://patchwork.ozlabs.org/api/people/87751/","name":"Niklas Cassel","email":"cassel@kernel.org"},"content":"On 27 April 2026 22:23:12 CEST, Damien Le Moal <dlemoal@kernel.org> wrote:\n>On 2026/04/27 21:14, Niklas Cassel wrote:\n>>> +\t\t\t max_ports, last_port_end,\n>>> +\t\t\t (unsigned long long)bar_size);\n>> \n>> Print resource_size_t as %pa instead of casting to unsigned long long\n>> and pass bar_size by reference (&bar_size):\n>> https://docs.kernel.org/core-api/printk-formats.html#physical-address-types-phys-addr-t\n>> \n>> \n>>> +\t\treturn -ENODEV;\n>> \n>> return -EIO;\n>\n>I do not agree here. We did not do any I/O. If anything, this should be EINVAL.\n>But I think that ENODEV is safer since we are in the probe context here and we\n>do not want to see that device show up.\n\n\nHow about -ENXIO?\n\nNo such device or address\n\n\nIt is the only error code, except for -ENODEV\nthat is a valid error code to fail probe():\nhttps://elixir.bootlin.com/linux/v7.0.1/source/drivers/base/dd.c#L653\n\n\nKind regards,\nNikla","headers":{"Return-Path":"\n <linux-ide+bounces-5566-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=VBHZd74A;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-ide+bounces-5566-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=\"VBHZd74A\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::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 4g4FcV0GzBz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 06:32:42 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 672B630205C5\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 20:32:39 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 14665371046;\n\tMon, 27 Apr 2026 20:32:37 +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 E5467370D56\n\tfor <linux-ide@vger.kernel.org>; Mon, 27 Apr 2026 20:32:36 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 0CBD7C19425;\n\tMon, 27 Apr 2026 20:32:35 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777321957; cv=none;\n b=TrQu4BZaBIvmwskC52cL6o6IOzXETMD9FB8w9RhUH4XTAYVyKmRROSLR3URteKytPxuAW4P0r7G47V4wV8ja2lfLq4UHMxllYCTwpkBrshNs2MWkcx7Fq8ZauHfmE5lcmzDl9FRMTsy3xQ1jFW/uo11bCxzvFqMerM9xwetDuus=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777321957; c=relaxed/simple;\n\tbh=3ZLJCAX9kzQtvfT+xKKufH6JV5xXwKlhclsqcKfFlZ0=;\n\th=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID:\n\t MIME-Version:Content-Type;\n b=fSeq+ozOlrIJqDeiPeUkbL3Zv0dRifgMn8gZ6e6yQg0raQavV5LHR39Jdva8bkyiStjaloxYJPtNjMRz6GTL7+Upy/enKxZG5HMYeCfzwvPdpz/4Dvq7ehT4DeSpx6GEjdVr2lQEKefy70wi+M48Xv/3Yn13EvX+tzHgSlSt06A=","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=VBHZd74A; 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=1777321956;\n\tbh=3ZLJCAX9kzQtvfT+xKKufH6JV5xXwKlhclsqcKfFlZ0=;\n\th=Date:From:To:CC:Subject:In-Reply-To:References:From;\n\tb=VBHZd74AXowaFQ97VVWYaAlXsYgYzw0kXQKPSgy3+1X+DpBy2FHiWfA0RxBk4UqJp\n\t /qTdDoRI2fYoNClA0fQkJGn3izP908Hni/wwEhn6GOLflhEqTTresutblfix34ffE3\n\t v5oVxK2Rik/hNq20uslqiXPaku9C2qfHGgrcWRHl1i3YJoc4Q1cKUWfreJI9H058ck\n\t bpE0Wxru32xJKODZsR+aVujt92GRfPxCQieL+HhJMFf9F0wDH1NyQXPnDJFprdz2U9\n\t kMJm/4usziP/+FCrSQJTW5xAMUmlB297kRu/CmOb8k+Nigd0sqFR/y3DwIWu4Hnit1\n\t 5hhuNdDv5drug==","Date":"Mon, 27 Apr 2026 22:32:35 +0200","From":"Niklas Cassel <cassel@kernel.org>","To":"Damien Le Moal <dlemoal@kernel.org>, dayou5941@163.com","CC":"linux-ide@vger.kernel.org, liyouhong@kylinos.cn","Subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","User-Agent":"Thunderbird for Android","In-Reply-To":"<a805fa86-0fe7-4803-ad2e-45719415f263@kernel.org>","References":"<20260427060546.1407439-1-dayou5941@163.com>\n <ae9TGoaQAi7dOVc0@ryzen> <a805fa86-0fe7-4803-ad2e-45719415f263@kernel.org>","Message-ID":"<6149B806-C296-42DE-BF0E-119E8AF6129B@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","Content-Type":"text/plain;\n charset=utf-8","Content-Transfer-Encoding":"quoted-printable"}},{"id":3683017,"web_url":"http://patchwork.ozlabs.org/comment/3683017/","msgid":"<b135fcde-bff7-4725-87a7-3d3126af9007@kernel.org>","list_archive_url":null,"date":"2026-04-27T21:47:41","subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","submitter":{"id":86188,"url":"http://patchwork.ozlabs.org/api/people/86188/","name":"Damien Le Moal","email":"dlemoal@kernel.org"},"content":"On 2026/04/28 5:32, Niklas Cassel wrote:\n> On 27 April 2026 22:23:12 CEST, Damien Le Moal <dlemoal@kernel.org> wrote:\n>> On 2026/04/27 21:14, Niklas Cassel wrote:\n>>>> +\t\t\t max_ports, last_port_end,\n>>>> +\t\t\t (unsigned long long)bar_size);\n>>>\n>>> Print resource_size_t as %pa instead of casting to unsigned long long\n>>> and pass bar_size by reference (&bar_size):\n>>> https://docs.kernel.org/core-api/printk-formats.html#physical-address-types-phys-addr-t\n>>>\n>>>\n>>>> +\t\treturn -ENODEV;\n>>>\n>>> return -EIO;\n>>\n>> I do not agree here. We did not do any I/O. If anything, this should be EINVAL.\n>> But I think that ENODEV is safer since we are in the probe context here and we\n>> do not want to see that device show up.\n> \n> \n> How about -ENXIO?\n> \n> No such device or address\n> \n> \n> It is the only error code, except for -ENODEV\n> that is a valid error code to fail probe():\n> https://elixir.bootlin.com/linux/v7.0.1/source/drivers/base/dd.c#L653\n\nThat is my point, since we want to fail probe. So I would go with this ENODEV.","headers":{"Return-Path":"\n <linux-ide+bounces-5567-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=J7FY0X42;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-ide+bounces-5567-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=\"J7FY0X42\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\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 4g4HLX0nlrz1yHX\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 07:50:44 +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 1C037306B180\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 21:47:45 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 7D950399000;\n\tMon, 27 Apr 2026 21:47:44 +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 5AFB237F009\n\tfor <linux-ide@vger.kernel.org>; Mon, 27 Apr 2026 21:47:44 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 3FFA6C19425;\n\tMon, 27 Apr 2026 21:47:43 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777326464; cv=none;\n b=XzztKvK9iXZDvFBhC3Sj4M8ZkPVtQNwd/GN2Qe7YlkkyZI39Nv/ErBTmqE7QqEl5ggCQorX8XnRHxskExNmqQ8G96QDQ8MdF4sxbJ9V+U9kF/HVlp/c8RRtKb2xYDVMilqgaryqtP1Vm4nCvwUCRmcptSMWcH9jBR5BXfqV/qhg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777326464; c=relaxed/simple;\n\tbh=2DcM1g8muxMehZbCzbVNX2zYZngRlgEKLwXHxIrZOjs=;\n\th=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:\n\t In-Reply-To:Content-Type;\n b=IvXLwOeHWB6KNW8lK0+YBKrDzLOYEoN7nzrk0wkQkRIWQ+Dp88uPHFlC4vJtd0NfuwXRmMHnFjwkjafrs+pyFvR4qRcN3oEsjxYxL41iN1+io90X0jdcYeA2CRJ21UfhuKZWJwwbn6rDQzDLkh6MFajM305NG8W2B0TfKYy32/g=","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=J7FY0X42; 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=1777326463;\n\tbh=2DcM1g8muxMehZbCzbVNX2zYZngRlgEKLwXHxIrZOjs=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=J7FY0X42Rpz2C6Eg3RWW/l+rZQIC4qQvrxXAgretrZw5jYrELEFif029zi+FvUx+S\n\t YGRxwTJ9Rrlt63RnX2IfCIvNFHm8tLrpoQRPe0wjDmjHSsxf0Xrkn/jEn5UhrPYtut\n\t cOH8ukqtjyT6QhHxrQNhZfn3yBvzzTKvx92sUargePsNKbiZ/wISs3TLaUhYqGNxcs\n\t 5S1ISIatRdbAnonlhUpM5epTqex/2fcokuIg5OgmmYcGEQmXeiyja6H0Y4SF0I+jgi\n\t HhT4IV07PZ4VNmOJ+YFlyiefzvhU2QQRrJhrCVXME/h5N4exFLqHJgkWyXbAz+ZPzl\n\t eJ3BJuMWzcwxA==","Message-ID":"<b135fcde-bff7-4725-87a7-3d3126af9007@kernel.org>","Date":"Tue, 28 Apr 2026 06:47:41 +0900","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","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","To":"Niklas Cassel <cassel@kernel.org>, dayou5941@163.com","Cc":"linux-ide@vger.kernel.org, liyouhong@kylinos.cn","References":"<20260427060546.1407439-1-dayou5941@163.com>\n <ae9TGoaQAi7dOVc0@ryzen> <a805fa86-0fe7-4803-ad2e-45719415f263@kernel.org>\n <6149B806-C296-42DE-BF0E-119E8AF6129B@kernel.org>","Content-Language":"en-US","From":"Damien Le Moal <dlemoal@kernel.org>","Organization":"Western Digital Research","In-Reply-To":"<6149B806-C296-42DE-BF0E-119E8AF6129B@kernel.org>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit"}},{"id":3683023,"web_url":"http://patchwork.ozlabs.org/comment/3683023/","msgid":"<84062023-B38D-434B-98BE-8ABC711CE560@kernel.org>","list_archive_url":null,"date":"2026-04-27T22:10:23","subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","submitter":{"id":87751,"url":"http://patchwork.ozlabs.org/api/people/87751/","name":"Niklas Cassel","email":"cassel@kernel.org"},"content":"On 27 April 2026 23:47:41 CEST, Damien Le Moal <dlemoal@kernel.org> wrote:\n>On 2026/04/28 5:32, Niklas Cassel wrote:\n>> On 27 April 2026 22:23:12 CEST, Damien Le Moal <dlemoal@kernel.org> wrote:\n>>> On 2026/04/27 21:14, Niklas Cassel wrote:\n>>>>> +\t\t\t max_ports, last_port_end,\n>>>>> +\t\t\t (unsigned long long)bar_size);\n>>>>\n>>>> Print resource_size_t as %pa instead of casting to unsigned long long\n>>>> and pass bar_size by reference (&bar_size):\n>>>> https://docs.kernel.org/core-api/printk-formats.html#physical-address-types-phys-addr-t\n>>>>\n>>>>\n>>>>> +\t\treturn -ENODEV;\n>>>>\n>>>> return -EIO;\n>>>\n>>> I do not agree here. We did not do any I/O. If anything, this should be EINVAL.\n>>> But I think that ENODEV is safer since we are in the probe context here and we\n>>> do not want to see that device show up.\n>> \n>> \n>> How about -ENXIO?\n>> \n>> No such device or address\n>> \n>> \n>> It is the only error code, except for -ENODEV\n>> that is a valid error code to fail probe():\n>> https://elixir.bootlin.com/linux/v7.0.1/source/drivers/base/dd.c#L653\n>\n>That is my point, since we want to fail probe. So I would go with this ENODEV.\n\n\nENXIO and ENODEV are handled exactly the same way in dd.c\n\nAnyway, looking at dd.c again, any negative error code will do. The only difference seems to be that the driver core will not print an error for ENXIO and ENODEV, but will do so for any other error code.\n\nLooking at:\nhttps://linux.kernel.narkive.com/NI9fvCoJ/device-driver-probe-return-codes\n\nI don't think that my original suggestion of EIO is wrong.\n\nAnyway, considering that all error codes will fail the probe, I'm fine with any error code (except for EPROBE_DEFER :P)\n\n\nKind regards,\nNiklas","headers":{"Return-Path":"\n <linux-ide+bounces-5568-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=EcGY6a2/;\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-5568-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=\"EcGY6a2/\"","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 4g4HnN1S3Kz1xrS\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 08:10:32 +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 48958300644C\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 27 Apr 2026 22:10:26 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 696273A5E99;\n\tMon, 27 Apr 2026 22:10:24 +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 4717F3A1E92\n\tfor <linux-ide@vger.kernel.org>; Mon, 27 Apr 2026 22:10:24 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 909BBC19425;\n\tMon, 27 Apr 2026 22:10:23 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777327824; cv=none;\n b=PkgY8+KF/akoMpFQDWmVdHFV6u19jrGx6CtSEmlvNWEUbZoXl6LRlMmrlNpLTPyMBF5/McyxDZyqz7doOD+BhGx761i7GOqb3m1xkCnyDAEdnZtUEpCA9Eqt78EL0BoomMsfemtWBvCi9PPJrZzbIUG8QXacpdEsh660Ig13Pe4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777327824; c=relaxed/simple;\n\tbh=F+KvTNdxpBViaqcaTjJhVqMCrPaDb5sZ6T566Oso4XU=;\n\th=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID:\n\t MIME-Version:Content-Type;\n b=NkgpgKjp+MeDhU4E2yUL2j6H78YadbLMg6C38Abdkd8YWYnmGFBErFtWVEE9kOXpW9X5Z/Fv2U8UEug4We3xh0uXDCfbSJUzqgLb3DW40ePqQIrO4SxxXIwCZ199Mzr2voi1tsXNhqYszHloX3ZvTzYBV9a8kvtioP3PXNu0V/I=","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=EcGY6a2/; 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=1777327824;\n\tbh=F+KvTNdxpBViaqcaTjJhVqMCrPaDb5sZ6T566Oso4XU=;\n\th=Date:From:To:CC:Subject:In-Reply-To:References:From;\n\tb=EcGY6a2/HtgsEd95K/H5NKBh3mDYb/u4N0d5hP+dCIWvaUEBri/h/1pSFndxO0a0H\n\t Z0wK848IqssgJXvy5Yjq82tIY0vwoMZoMt7BlKaxL7BGabr0ijzk4h3aOx46GTMDda\n\t ETHEYsU/kZIflc4fPr+Vzc0CSJloW7jy65MHE7lT8t4IyY6xE7bbrqMROwe4CPbcxX\n\t wN9j5LmmYjeGbH6ebhm33NuanB24ILKhVGvMH0MhvmSYunmuPpIn5zZvxXn8OiTRxR\n\t h17FBwr0EdvTKB3cCw1bsviaZmqz8QS2JTNPUcpy5RDyprIY65j5kcU7N1Cbd6qr2j\n\t QVb9I02un5Rag==","Date":"Tue, 28 Apr 2026 00:10:23 +0200","From":"Niklas Cassel <cassel@kernel.org>","To":"Damien Le Moal <dlemoal@kernel.org>, dayou5941@163.com","CC":"linux-ide@vger.kernel.org, liyouhong@kylinos.cn","Subject":"Re: [PATCH v4] ata: ahci: fail probe if BAR too small for claimed\n ports","User-Agent":"Thunderbird for Android","In-Reply-To":"<b135fcde-bff7-4725-87a7-3d3126af9007@kernel.org>","References":"<20260427060546.1407439-1-dayou5941@163.com>\n <ae9TGoaQAi7dOVc0@ryzen> <a805fa86-0fe7-4803-ad2e-45719415f263@kernel.org>\n <6149B806-C296-42DE-BF0E-119E8AF6129B@kernel.org>\n <b135fcde-bff7-4725-87a7-3d3126af9007@kernel.org>","Message-ID":"<84062023-B38D-434B-98BE-8ABC711CE560@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","Content-Type":"text/plain;\n charset=utf-8","Content-Transfer-Encoding":"quoted-printable"}}]