Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Moshe Shemesh <moshe@nvidia.com>
To: Lukas Wunner <lukas@wunner.de>,
	Moshe Shemesh <moshe@mellanox.com>,
	"Saeed Mahameed" <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>, <linux-rdma@vger.kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@nvidia.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-pci@vger.kernel.org>
Subject: Re: [PATCH net-next v2 09/16] net/mlx5: Handle sync reset now event
Date: Tue, 6 May 2025 23:02:18 +0300	[thread overview]
Message-ID: <6687db3a-33b2-4982-b65a-c6ecea130cc3@nvidia.com> (raw)
In-Reply-To: <Z-g6pzpZu_TU0-nA@wunner.de>



On 3/29/2025 9:23 PM, Lukas Wunner wrote:
> 
> The following was applied as commit eabe8e5e88f5 ("net/mlx5: Handle
> sync reset now event").
> 
> It does some questionable things (from a PCI perspective), so allow
> me to ask for details:
> 
> On Wed, Oct 07, 2020 at 09:00:50AM +0300, Moshe Shemesh wrote:
>> On sync_reset_now event the driver does reload and PCI link toggle to
>> activate firmware upgrade reset. When the firmware sends this event it
>> syncs the event on all PFs, so all PFs will do PCI link toggle at once.
>> To do PCI link toggle, the driver ensures that no other device ID under
>> the same bridge by checking that all the PF functions under the same PCI
>> bridge have same device ID. If no other device it uses PCI bridge link
>> control to turn link down and up.
> [...]
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
>> @@ -156,6 +157,120 @@ static void mlx5_sync_reset_request_event(struct work_struct *work)
>>                mlx5_core_warn(dev, "PCI Sync FW Update Reset Ack. Device reset is expected.\n");
>>   }
>>
>> +#define MLX5_PCI_LINK_UP_TIMEOUT 2000
>> +
>> +static int mlx5_pci_link_toggle(struct mlx5_core_dev *dev)
>> +{
>> +     struct pci_bus *bridge_bus = dev->pdev->bus;
>> +     struct pci_dev *bridge = bridge_bus->self;
>> +     u16 reg16, dev_id, sdev_id;
>> +     unsigned long timeout;
>> +     struct pci_dev *sdev;
>> +     int cap, err;
>> +     u32 reg32;
>> +
>> +     /* Check that all functions under the pci bridge are PFs of
>> +      * this device otherwise fail this function.
>> +      */
>> +     err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, &dev_id);
>> +     if (err)
>> +             return err;
>> +     list_for_each_entry(sdev, &bridge_bus->devices, bus_list) {
>> +             err = pci_read_config_word(sdev, PCI_DEVICE_ID, &sdev_id);
>> +             if (err)
>> +                     return err;
>> +             if (sdev_id != dev_id)
>> +                     return -EPERM;
>> +     }
>> +
>> +     cap = pci_find_capability(bridge, PCI_CAP_ID_EXP);
>> +     if (!cap)
>> +             return -EOPNOTSUPP;
>> +
>> +     list_for_each_entry(sdev, &bridge_bus->devices, bus_list) {
>> +             pci_save_state(sdev);
>> +             pci_cfg_access_lock(sdev);
>> +     }
>> +     /* PCI link toggle */
>> +     err = pci_read_config_word(bridge, cap + PCI_EXP_LNKCTL, &reg16);
>> +     if (err)
>> +             return err;
>> +     reg16 |= PCI_EXP_LNKCTL_LD;
>> +     err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16);
>> +     if (err)
>> +             return err;
>> +     msleep(500);
>> +     reg16 &= ~PCI_EXP_LNKCTL_LD;
>> +     err = pci_write_config_word(bridge, cap + PCI_EXP_LNKCTL, reg16);
>> +     if (err)
>> +             return err;
> 
Sorry for late response.
> The commit message doesn't state the reason why you're toggling
> the Link Disable bit.
> 
> It propagates a Hot Reset down the hierarchy, so perhaps that's
> the reason you're doing this?
> 
> If it is, why didn't you just use one of the existing library calls
> such as pci_reset_bus(bridge)?

We need PCI link down on all the device functions (can be 2 or even 4) 
for full chip reset, to activate new FW. The hot reset by 
pci_reset_bus() has the link down only for 2 ms, not enough for sync 
reset on all functions with pci link down for new FW load and boot.
> 
> Thanks,
> 
> Lukas


      reply	other threads:[~2025-05-06 20:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1602050457-21700-1-git-send-email-moshe@mellanox.com>
     [not found] ` <1602050457-21700-10-git-send-email-moshe@mellanox.com>
2025-03-29 18:23   ` [PATCH net-next v2 09/16] net/mlx5: Handle sync reset now event Lukas Wunner
2025-05-06 20:02     ` Moshe Shemesh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6687db3a-33b2-4982-b65a-c6ecea130cc3@nvidia.com \
    --to=moshe@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=moshe@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox