Re: [PATCH v23 3/5] PCI: Avoid saving config space state if inaccessible

[email protected] Wed, 05 Aug 2026 17:05:09 +0000
Newsgroups org.kernel.vger.linux-pci,org.kernel.vger.linux-s390
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Function parameter `msg` should be declared as `const char *` instead of `char *`.
--

--- Patch [3]: [PATCH v23 3/5] PCI: Avoid saving config space state if inaccessible ---
commit d2cfd742f2dfe4c4445b198bcb7010bd9ef42491
Author: Farhan Ali <[email protected]>

PCI: Avoid saving config space state if inaccessible

This commit modifies the PCI reset process to avoid saving the device's
configuration space state if it is inaccessible. It checks the PCI_COMMAND
register to determine accessibility before attempting to save the state.

> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 350bae907ebf8..e8d7de77241a6 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c

[ ... ]

> @@ -713,6 +713,27 @@ u16 pci_find_dvsec_capability(struct pci_dev *dev, u16 vendor, u16 dvsec)
>  }
>  EXPORT_SYMBOL_GPL(pci_find_dvsec_capability);
>  
> +static bool pci_dev_config_accessible(struct pci_dev *dev, char *msg)

[Severity: Low]
This isn't a bug, but should the msg parameter be declared as const char *
instead of char *?

The function is called with string literals, which violates const
correctness and can trigger discarded-qualifier compiler warnings.

> +{
> +	u32 val;
> +
> +	/*
> +	 * If device's config space is inaccessible it can return ~0 for

[ ... ]

> @@ -5059,6 +5080,9 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)
>  	 */
>  	pci_set_power_state(dev, PCI_D0);
>  
> +	if (!pci_dev_config_accessible(dev, "save state"))
> +		return;
> +
>  	pci_save_state(dev);

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=3