[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d5d12494-aa17-4012-8265-3c91981611c4@163.com>
Date: Sat, 16 Aug 2025 23:54:02 +0800
From: Hans Zhang <18255117159@....com>
To: bhelgaas@...gle.com
Cc: ilpo.jarvinen@...ux.intel.com, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] PCI: Remove redundant TTL variable initialization
Dear Bjorn,
Because of this series, you have accepted it.
https://patchwork.kernel.org/project/linux-pci/cover/20250813144529.303548-1-18255117159@163.com/
It is already in the following branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/log/?h=capability-search
But I saw the status of patch as "Not Applicable". Is it necessary for
me to remake the v2 version based on v6.17-rc1? Or is this patch
unreasonable?
Best regards,
Hans
On 2025/6/16 23:24, Hans Zhang wrote:
> The local variables `ttl` were initialized to PCI_FIND_CAP_TTL but never
> actually used. The loop termination condition is inherently controlled
> by the TTL mechanism inside the PCI_FIND_NEXT_CAP_TTL macro, which already
> ensures protection against infinite loops.
>
> Remove these redundant operations to simplify the code and eliminate
> potential logical ambiguities. This change does not affect functionality,
> as the TTL safeguard is properly implemented within the macro.
>
> Signed-off-by: Hans Zhang <18255117159@....com>
> ---
> - Submissions based on the following patches:
> https://patchwork.kernel.org/project/linux-pci/patch/20250607161405.808585-1-18255117159@163.com/
>
> Recently, I checked the code and found that there are still some areas that can be further optimized.
> The above series of patches has been around for a long time, so I'm sending this one out for review
> as a separate patch.
> ---
> drivers/pci/quirks.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> index d7f4ee634263..50d0f193e4a3 100644
> --- a/drivers/pci/quirks.c
> +++ b/drivers/pci/quirks.c
> @@ -2742,10 +2742,10 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x9601, quirk_amd_780_apc_msi);
> */
> static int msi_ht_cap_enabled(struct pci_dev *dev)
> {
> - int pos, ttl = PCI_FIND_CAP_TTL;
> + int pos;
>
> pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING);
> - while (pos && ttl--) {
> + while (pos) {
> u8 flags;
>
> if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,
> @@ -2796,10 +2796,10 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
> /* Force enable MSI mapping capability on HT bridges */
> static void ht_enable_msi_mapping(struct pci_dev *dev)
> {
> - int pos, ttl = PCI_FIND_CAP_TTL;
> + int pos;
>
> pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING);
> - while (pos && ttl--) {
> + while (pos) {
> u8 flags;
>
> if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,
> @@ -2935,12 +2935,11 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA,
>
> static int ht_check_msi_mapping(struct pci_dev *dev)
> {
> - int pos, ttl = PCI_FIND_CAP_TTL;
> - int found = 0;
> + int pos, found = 0;
>
> /* Check if there is HT MSI cap or enabled on this device */
> pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING);
> - while (pos && ttl--) {
> + while (pos) {
> u8 flags;
>
> if (found < 1)
> @@ -3060,10 +3059,10 @@ static void nv_ht_enable_msi_mapping(struct pci_dev *dev)
>
> static void ht_disable_msi_mapping(struct pci_dev *dev)
> {
> - int pos, ttl = PCI_FIND_CAP_TTL;
> + int pos;
>
> pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING);
> - while (pos && ttl--) {
> + while (pos) {
> u8 flags;
>
> if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,
>
> base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
Powered by blists - more mailing lists