[{"id":3686734,"web_url":"http://patchwork.ozlabs.org/comment/3686734/","msgid":"<20260505215805.549C3C2BCB4@smtp.kernel.org>","list_archive_url":null,"date":"2026-05-05T21:58:04","subject":"Re: [PATCH v15 2/7] PCI: Avoid saving config space state if\n inaccessible","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- [Medium] Early return when config space is inaccessible skips device DMA disablement.\n- [Low] The 'msg' parameter in pci_dev_config_accessible() lacks a 'const' qualifier.\n--\n\ncommit 18b574199dc0470f2784ade2f4883a656c60245e\nAuthor: Farhan Ali <alifm@linux.ibm.com>\n\nPCI: Avoid saving config space state if inaccessible\n\nThe commit updates the reset process to check if a device's config space\nis accessible before attempting to save its state. This prevents saving\ninvalid values if the device is in an error state like DPC.\n\n> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c\n> index d0c9f0166af5c..e71b814153921 100644\n> --- a/drivers/pci/pci.c\n> +++ b/drivers/pci/pci.c\n> @@ -722,6 +722,27 @@ u16 pci_find_dvsec_capability(struct pci_dev *dev, u16 vendor, u16 dvsec)\n>  }\n>  EXPORT_SYMBOL_GPL(pci_find_dvsec_capability);\n>  \n> +static bool pci_dev_config_accessible(struct pci_dev *dev, char *msg)\n\nThis isn't a bug, but should the msg parameter be declared as a const\nchar pointer?\n\nThe function is later called with the string literal \"save state\".\n\n[ ... ]\n\n> @@ -5027,6 +5048,9 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)\n>  \t */\n>  \tpci_set_power_state(dev, PCI_D0);\n>  \n> +\tif (!pci_dev_config_accessible(dev, \"save state\"))\n> +\t\treturn;\n> +\n>  \tpci_save_state(dev);\n>  \t/*\n>  \t * Disable the device by clearing the Command register, except for\n>  \t * INTx-disable which is set.  This not only disables MMIO and I/O port\n>  \t * BARs, but also prevents the device from being Bus Master, preventing\n>  \t * DMA from the device including MSI/MSI-X interrupts.  For PCI 2.3\n>  \t * compliant devices, INTx-disable prevents legacy interrupts.\n>  \t */\n>  \tpci_write_config_word(dev, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE);\n\nDoes returning early here skip disabling the device DMA engine?\n\nIf the configuration space read fails due to a transient error like a\ncompletion timeout instead of the link being fully down, the device might\nstill be active.\n\nSkipping the write to PCI_COMMAND leaves Bus Master enabled, which could\nallow the device to continue performing DMA or raising interrupts during the\nreset process.\n\nCould the code conditionally skip pci_save_state() but still attempt the\nwrite to PCI_COMMAND to ensure a best-effort disablement?","headers":{"Return-Path":"\n <linux-pci+bounces-53802-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=ct/obpcP;\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-pci+bounces-53802-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=\"ct/obpcP\"","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 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g9C8c0yl7z1yJx\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 07:59:12 +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 6EB8E304C960\n\tfor <incoming@patchwork.ozlabs.org>; Tue,  5 May 2026 21:58:06 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id F26E04968F8;\n\tTue,  5 May 2026 21:58:05 +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 D04394963CC\n\tfor <linux-pci@vger.kernel.org>; Tue,  5 May 2026 21:58:05 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 549C3C2BCB4;\n\tTue,  5 May 2026 21:58:05 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778018285; cv=none;\n b=o088gMY2fCZMDCpifGjKV/L08d7i05s67/Go5J7FbXvSN2DidLuDlTWeBRIYHT+bNtGh6YjS3OfnK5G0wEhdNmF27f7SNqDI2vRuAktUR3EGrRushkdvZZzLD9D3//lSsH+E4yXMgMu9jVss6A2mkt+MTjOSzcGakZEc4koI0NQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778018285; c=relaxed/simple;\n\tbh=4TbN6/46IjYUSeFQCMrTKuAoDdetfYCwCEBGALYwES4=;\n\th=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Date:\n\t Message-Id;\n b=BjAk5kblJMd9UF9E/Leu6BOkc4BQPmNIezzS75XI+ZqzaEs6OH/Qp2V1/8cFjIyeF5MqVwuLxv27/ju+goiJsjFQYD4ehXeDbczD43DwMN7fUBWanGb7IHWDKCmLY5ZWiYFUt4eB1KqgP0+dUBLvVct+K7Tl0pTKKCTyjKPYxg0=","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=ct/obpcP; 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=1778018285;\n\tbh=4TbN6/46IjYUSeFQCMrTKuAoDdetfYCwCEBGALYwES4=;\n\th=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date:From;\n\tb=ct/obpcP/lDilEgI5DkQaNCUCJgSDIQRHGOJH7pGQAiUVCgFD4uF5aA52SbCTeZYu\n\t 94uF0SZNNlrH8gxA4M62CHIT+Yih/h4J3p6fbjF+ivKYTFc4WPdFVRPX59ZCmn6VTt\n\t 2CAyhazW80+Q/PzKqovzQq71D6xtl3qKTDqGNUCR/8U/R7Eh3pSC9S4ekyeFSOuYPj\n\t YS/reRBfxFSm8/qeP1yIYj+qfin3tgdFpUXfhbMZOfiaZnCuKP1KcDzroffzRaV0mz\n\t AlwY7zIbp34x98//KPYqHRBG/kbeaMZameh597+mSR2dVIETqZ3c+kuUUCWp6Vn1w0\n\t EBWSbLWtfl6iw==","From":"sashiko-bot@kernel.org","Subject":"Re: [PATCH v15 2/7] PCI: Avoid saving config space state if\n inaccessible","Reply-To":"sashiko@lists.linux.dev","To":"\"Farhan Ali\" <alifm@linux.ibm.com>","Cc":"linux-pci@vger.kernel.org","In-Reply-To":"<20260505200510.2954-3-alifm@linux.ibm.com>","References":"<20260505200510.2954-3-alifm@linux.ibm.com>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","Date":"Tue, 05 May 2026 21:58:04 +0000","Message-Id":"<20260505215805.549C3C2BCB4@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>"}}]