[{"id":3687568,"web_url":"http://patchwork.ozlabs.org/comment/3687568/","msgid":"<20260507075958.82CD8C2BCC7@smtp.kernel.org>","list_archive_url":null,"date":"2026-05-07T07:59:58","subject":"Re: [PATCH v8 phy-next 02/31] ata: add <linux/pm_runtime.h> where\n missing","submitter":{"id":93311,"url":"http://patchwork.ozlabs.org/api/people/93311/","name":null,"email":"sashiko-bot@kernel.org"},"content":"Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:\n- [High] Callers of `ahci_rpm_get_port()` unconditionally ignore the return value of `pm_runtime_get_sync()`, potentially accessing suspended hardware.\n- [High] AHCI interrupt handlers process interrupts without checking if the device is runtime-active, leading to spurious handling and MMIO reads on suspended devices.\n--\n\ncommit 4c8bdcda88f27ad5b4d7ed5e7d48bab865cfb2dd\nAuthor: Vladimir Oltean <vladimir.oltean@nxp.com>\n\nata: add <linux/pm_runtime.h> where missing\n\nThis patch adds the <linux/pm_runtime.h> header to several AHCI drivers\nthat use runtime PM operations but previously relied on an indirect\ninclusion from <linux/phy/phy.h>.\n\n> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c\n> index 1d73a53370cf3..1396a53bd6df3 100644\n> --- a/drivers/ata/ahci.c\n> +++ b/drivers/ata/ahci.c\n> @@ -26,6 +26,7 @@\n>  #include <linux/device.h>\n>  #include <linux/dmi.h>\n>  #include <linux/gfp.h>\n> +#include <linux/pm_runtime.h>\n>  #include <scsi/scsi_host.h>\n>  #include <scsi/scsi_cmnd.h>\n>  #include <linux/libata.h>\n\nWhile reviewing the addition of runtime PM headers, I noticed a pre-existing\nregression with how interrupts are handled in this driver.\n\nCould ahci_single_level_irq_intr() be invoked for a runtime-suspended\ndevice due to shared interrupts (IRQF_SHARED)?\n\nIf the device is powered down, would reading HOST_IRQ_STAT return 0xffffffff\nand cause the handler to call ata_qc_complete_multiple() with fatal errors\n(like PORT_IRQ_FREEZE and PORT_IRQ_ERROR), eventually triggering severe ATA\nerror handling and port resets?\n\nWould using pm_runtime_get_if_active() before accessing the hardware registers\nprevent this issue?\n\n[ ... ]\n\n> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c\n> index c79abdfcd7a9b..e0de4703a4f2d 100644\n> --- a/drivers/ata/libahci.c\n> +++ b/drivers/ata/libahci.c\n> @@ -30,6 +30,7 @@\n>  #include <scsi/scsi_cmnd.h>\n>  #include <linux/libata.h>\n>  #include <linux/pci.h>\n> +#include <linux/pm_runtime.h>\n>  #include \"ahci.h\"\n>  #include \"libata.h\"\n>  \n\nI also noticed another pre-existing regression in this driver.\n\nDoes ahci_rpm_get_port() need to have its return value checked by callers?\n\nIt looks like it directly returns the result of pm_runtime_get_sync(), but\ncallers like ahci_show_port_cmd(), ahci_read_em_buffer(), and\nahci_port_resume() seem to unconditionally ignore this return value.\n\nIf pm_runtime_get_sync() fails, could the callers proceed to access\nmemory-mapped I/O registers (such as PORT_CMD or HOST_EM_CTL) on a suspended\ndevice, potentially causing a synchronous external abort on ARM or invalid\nreads on x86?","headers":{"Return-Path":"\n <linux-pci+bounces-54048-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@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=cBwdMWz5;\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-pci+bounces-54048-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=\"cBwdMWz5\"","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 4gB4RW0kGvz1yJq\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 07 May 2026 18:00:07 +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 4843E3020FC6\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  7 May 2026 08:00:04 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 5DECA37EFF9;\n\tThu,  7 May 2026 08:00: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 780D137756E\n\tfor <linux-pci@vger.kernel.org>; Thu,  7 May 2026 07:59:59 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 82CD8C2BCC7;\n\tThu,  7 May 2026 07:59:58 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778140799; cv=none;\n b=NPjHeMzjdqXPGoSAIbiwi6KG0ACu/+azzdJj6+JQjkTqxjsCOhR6S6ZRtrKMjFE9n7WKq47BbthnwFJrTqNBMXPmhVFuTlrTOnAZ+5IHGZuZ3H3JrlBO+7dNrhEFqA97iA9Bzv78JLL+2mlCY8dF9xgbJSRaI7KZ75mpeWU/jn0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778140799; c=relaxed/simple;\n\tbh=ma3trTyqcR2zMHbTmP1FiSJo20kbC7/PwNHpY9rd2rk=;\n\th=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Date:\n\t Message-Id;\n b=PDO3G8RIlZYCC9v+zOOuTe+SmV5WaRdkGWhuZWfpws/Q1eQEDsyGiqDkLDYzTiDtYoNpyEimhXmW3nQTXsdB7cw6AByHSi2n7mnfiJYgmzAPeEDwQDV5RUBU2Zi7N1vFUMYIvYVG8r8XvGXtRq5H4X6/Ifsu18F0utLQUqh+SOg=","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=cBwdMWz5; 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=1778140798;\n\tbh=ma3trTyqcR2zMHbTmP1FiSJo20kbC7/PwNHpY9rd2rk=;\n\th=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date:From;\n\tb=cBwdMWz5PGG8LWy4eLLEb3C7KMNwLhItullSociv6CWpY24TTTMS3Ko3/f94JzCMy\n\t f2ejsYRco+bUyHtj+DGcUjrDsdWmafHeYFvPRozJHEkbsgqz1Hfo6oPdQpztrS0UaC\n\t QhBEV2hHg2I8v1PRnZrmyGT+jzOaSQNNBDBx8Ai9wKjb35KsUl5NUDe7BRg7ueEjAX\n\t WyHrzRWAyJ7y1Rfx8TU6duZx6aD3ZoPRW1W9CDNDGKqbkUnKnrjfnxK573HLmRKt+z\n\t U7W6mBRZBpyTM1RkvdUmtSxokN3Ojtgipkj1ttNL8FzNfkr32M3zuOQgmOM9LBo/jI\n\t DDbDSnsjKYDjA==","From":"sashiko-bot@kernel.org","Subject":"Re: [PATCH v8 phy-next 02/31] ata: add <linux/pm_runtime.h> where\n missing","Reply-To":"sashiko@lists.linux.dev","To":"\"Vladimir Oltean\" <vladimir.oltean@nxp.com>","Cc":"wsa+renesas@sang-engineering.com, linux-pci@vger.kernel.org","In-Reply-To":"<20260505100523.1922388-3-vladimir.oltean@nxp.com>","References":"<20260505100523.1922388-3-vladimir.oltean@nxp.com>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","Date":"Thu, 07 May 2026 07:59:58 +0000","Message-Id":"<20260507075958.82CD8C2BCC7@smtp.kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>"}}]